Port StreamToSidePacketCalculator to api2
PiperOrigin-RevId: 538109898
This commit is contained in:
		
							parent
							
								
									ab72fccca7
								
							
						
					
					
						commit
						37290f0224
					
				| 
						 | 
					@ -1138,6 +1138,7 @@ cc_library(
 | 
				
			||||||
    deps = [
 | 
					    deps = [
 | 
				
			||||||
        "//mediapipe/framework:calculator_framework",
 | 
					        "//mediapipe/framework:calculator_framework",
 | 
				
			||||||
        "//mediapipe/framework:timestamp",
 | 
					        "//mediapipe/framework:timestamp",
 | 
				
			||||||
 | 
					        "//mediapipe/framework/api2:node",
 | 
				
			||||||
        "//mediapipe/framework/port:status",
 | 
					        "//mediapipe/framework/port:status",
 | 
				
			||||||
    ],
 | 
					    ],
 | 
				
			||||||
    alwayslink = 1,
 | 
					    alwayslink = 1,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -12,11 +12,13 @@
 | 
				
			||||||
// See the License for the specific language governing permissions and
 | 
					// See the License for the specific language governing permissions and
 | 
				
			||||||
// limitations under the License.
 | 
					// limitations under the License.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "mediapipe/framework/api2/node.h"
 | 
				
			||||||
#include "mediapipe/framework/calculator_framework.h"
 | 
					#include "mediapipe/framework/calculator_framework.h"
 | 
				
			||||||
#include "mediapipe/framework/port/status.h"
 | 
					#include "mediapipe/framework/port/status.h"
 | 
				
			||||||
#include "mediapipe/framework/timestamp.h"
 | 
					#include "mediapipe/framework/timestamp.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace mediapipe {
 | 
					namespace mediapipe {
 | 
				
			||||||
 | 
					namespace api2 {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// A calculator that takes a packet of an input stream and converts it to an
 | 
					// A calculator that takes a packet of an input stream and converts it to an
 | 
				
			||||||
// output side packet. This calculator only works under the assumption that the
 | 
					// output side packet. This calculator only works under the assumption that the
 | 
				
			||||||
| 
						 | 
					@ -28,21 +30,21 @@ namespace mediapipe {
 | 
				
			||||||
//   input_stream: "stream"
 | 
					//   input_stream: "stream"
 | 
				
			||||||
//   output_side_packet: "side_packet"
 | 
					//   output_side_packet: "side_packet"
 | 
				
			||||||
// }
 | 
					// }
 | 
				
			||||||
class StreamToSidePacketCalculator : public mediapipe::CalculatorBase {
 | 
					class StreamToSidePacketCalculator : public Node {
 | 
				
			||||||
 public:
 | 
					 public:
 | 
				
			||||||
  static absl::Status GetContract(mediapipe::CalculatorContract* cc) {
 | 
					  static constexpr Input<AnyType>::Optional kIn{""};
 | 
				
			||||||
    cc->Inputs().Index(0).SetAny();
 | 
					  static constexpr SideOutput<SameType<kIn>> kOut{""};
 | 
				
			||||||
    cc->OutputSidePackets().Index(0).SetAny();
 | 
					
 | 
				
			||||||
    return absl::OkStatus();
 | 
					  MEDIAPIPE_NODE_CONTRACT(kIn, kOut);
 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  absl::Status Process(mediapipe::CalculatorContext* cc) override {
 | 
					  absl::Status Process(mediapipe::CalculatorContext* cc) override {
 | 
				
			||||||
    mediapipe::Packet& packet = cc->Inputs().Index(0).Value();
 | 
					    kOut(cc).Set(
 | 
				
			||||||
    cc->OutputSidePackets().Index(0).Set(
 | 
					        kIn(cc).packet().As<AnyType>().At(mediapipe::Timestamp::Unset()));
 | 
				
			||||||
        packet.At(mediapipe::Timestamp::Unset()));
 | 
					 | 
				
			||||||
    return absl::OkStatus();
 | 
					    return absl::OkStatus();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
REGISTER_CALCULATOR(StreamToSidePacketCalculator);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					MEDIAPIPE_REGISTER_NODE(StreamToSidePacketCalculator);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}  // namespace api2
 | 
				
			||||||
}  // namespace mediapipe
 | 
					}  // namespace mediapipe
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user