diff --git a/mediapipe/framework/api2/builder.h b/mediapipe/framework/api2/builder.h index 5af9ee5e0..6d3323b97 100644 --- a/mediapipe/framework/api2/builder.h +++ b/mediapipe/framework/api2/builder.h @@ -176,22 +176,40 @@ class SourceImpl { : SourceImpl(&GetWithAutoGrow(vec, 0)) {} explicit SourceImpl(SourceBase* base) : base_(base) {} + // Connects MediaPipe stream or side packet to a destination: + // - node input (input stream) / side input (input side packet) + // - graph output (output stream) / side output (output side packet). + // + // MediaPipe streams and side packets can be connected to multiple + // destinations. Side packets and packets added to streams are sent to all + // connected destinations. template {}, int>::type = 0> - Src& AddTarget(const Dst& dest) { + Src& ConnectTo(const Dst& dest) { CHECK(dest.base_.source == nullptr); dest.base_.source = base_; base_->dests_.emplace_back(&dest.base_); return *this; } + + // Shortcut for `ConnectTo`. + // + // Connects MediaPipe stream or side packet to a destination: + // - node input (input stream) / side input (input side packet) + // - graph output (output stream) / side output (output side packet). + // + // MediaPipe streams and side packets can be connected to multiple + // destinations. Side packets and packets added to streams are sent to all + // connected destinations. + template + Src& operator>>(const Dst& dest) { + return ConnectTo(dest); + } + Src& SetName(std::string name) { base_->name_ = std::move(name); return *this; } - template - Src& operator>>(const Dst& dest) { - return AddTarget(dest); - } template {}, int> = 0>