Internal change

PiperOrigin-RevId: 489135553
This commit is contained in:
Hadon Nash
2022-11-17 00:07:59 -08:00
committed by Copybara-Service
parent 899c87466e
commit ea4989b6f1
6 changed files with 302 additions and 101 deletions
+19 -7
View File
@@ -98,14 +98,13 @@ void CalculatorGraph::GraphInputStream::SetHeader(const Packet& header) {
manager_->LockIntroData();
}
void CalculatorGraph::GraphInputStream::SetNextTimestampBound(
Timestamp timestamp) {
shard_.SetNextTimestampBound(timestamp);
}
void CalculatorGraph::GraphInputStream::PropagateUpdatesToMirrors() {
// Since GraphInputStream doesn't allow SetOffset() and
// SetNextTimestampBound(), the timestamp bound to propagate is only
// determined by the timestamp of the output packets.
CHECK(!shard_.IsEmpty()) << "Shard with name \"" << manager_->Name()
<< "\" failed";
manager_->PropagateUpdatesToMirrors(
shard_.LastAddedPacketTimestamp().NextAllowedInStream(), &shard_);
manager_->PropagateUpdatesToMirrors(shard_.NextTimestampBound(), &shard_);
}
void CalculatorGraph::GraphInputStream::Close() {
@@ -868,6 +867,19 @@ absl::Status CalculatorGraph::AddPacketToInputStream(
return AddPacketToInputStreamInternal(stream_name, std::move(packet));
}
absl::Status CalculatorGraph::SetInputStreamTimestampBound(
const std::string& stream_name, Timestamp timestamp) {
std::unique_ptr<GraphInputStream>* stream =
mediapipe::FindOrNull(graph_input_streams_, stream_name);
RET_CHECK(stream).SetNoLogging() << absl::Substitute(
"SetInputStreamTimestampBound called on input stream \"$0\" which is not "
"a graph input stream.",
stream_name);
(*stream)->SetNextTimestampBound(timestamp);
(*stream)->PropagateUpdatesToMirrors();
return absl::OkStatus();
}
// We avoid having two copies of this code for AddPacketToInputStream(
// const Packet&) and AddPacketToInputStream(Packet &&) by having this
// internal-only templated version. T&& is a forwarding reference here, so