Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(348)

Unified Diff: services/media/common/timeline_control_site.cc

Issue 2006093004: Motown: Convert MediaSink to expose MediaTimelineControlSite (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: services/media/common/timeline_control_site.cc
diff --git a/services/media/common/timeline_control_site.cc b/services/media/common/timeline_control_site.cc
index 26dc07f214a603745aca3408e5bdd86c77683d93..bafb5dd468950f5be5447442109cb971cca0b85a 100644
--- a/services/media/common/timeline_control_site.cc
+++ b/services/media/common/timeline_control_site.cc
@@ -36,7 +36,7 @@ TimelineControlSite::TimelineControlSite()
status = MediaTimelineControlSiteStatus::New();
status->timeline_transform =
TimelineTransform::From(current_timeline_function_);
- status->end_of_stream = false; // TODO(dalesat): Provide this.
+ status->end_of_stream = ReachedEndOfStreamUnsafe();
}
callback.Run(version, status.Pass());
});
@@ -82,6 +82,29 @@ void TimelineControlSite::SnapshotCurrentFunction(int64_t reference_time,
if (generation) {
*generation = generation_;
}
+
+ if (ReachedEndOfStreamUnsafe() && !end_of_stream_published_) {
+ end_of_stream_published_ = true;
+ task_runner_->PostTask(
+ FROM_HERE, base::Bind(&MojoPublisher<GetStatusCallback>::SendUpdates,
+ base::Unretained(&status_publisher_)));
+ }
+}
+
+void TimelineControlSite::SetEndOfStreamPts(int64_t end_of_stream_pts) {
+ base::AutoLock lock(lock_);
+ if (end_of_stream_pts_ != end_of_stream_pts) {
+ end_of_stream_pts_ = end_of_stream_pts;
+ end_of_stream_published_ = false;
+ }
+}
+
+bool TimelineControlSite::ReachedEndOfStreamUnsafe() {
+ lock_.AssertAcquired();
+
+ return end_of_stream_pts_ != kUnspecifiedTime &&
+ current_timeline_function_(Timeline::local_now()) >=
+ end_of_stream_pts_;
}
void TimelineControlSite::GetStatus(uint64_t version_last_seen,
@@ -115,6 +138,12 @@ void TimelineControlSite::SetTimelineTransform(
current_timeline_function_.subject_delta() != 0);
RCHECK(reference_delta != 0);
+ if (subject_time != kUnspecifiedTime &&
+ end_of_stream_pts_ != kUnspecifiedTime) {
+ end_of_stream_pts_ = kUnspecifiedTime;
+ end_of_stream_published_ = false;
+ }
+
if (effective_subject_time != kUnspecifiedTime) {
// Infer effective_reference_time from effective_subject_time.
effective_reference_time =

Powered by Google App Engine
This is Rietveld 408576698