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

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

Issue 1986303002: Motown: Use new TimelineTransform and related definitions (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Fixes per feedback. 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
« no previous file with comments | « services/media/common/rate_control_base.cc ('k') | services/media/common/timeline_control_site.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/media/common/timeline_control_site.h
diff --git a/services/media/common/timeline_control_site.h b/services/media/common/timeline_control_site.h
new file mode 100644
index 0000000000000000000000000000000000000000..4b2506f1ff64b96d7257fe59facf89fd58ae6704
--- /dev/null
+++ b/services/media/common/timeline_control_site.h
@@ -0,0 +1,94 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MOJO_SERVICES_MEDIA_COMMON_TIMELINE_CONTROL_SITE_IMPL_H_
+#define MOJO_SERVICES_MEDIA_COMMON_TIMELINE_CONTROL_SITE_IMPL_H_
+
+#include "base/single_thread_task_runner.h"
+#include "base/synchronization/lock.h"
+#include "mojo/public/cpp/bindings/binding.h"
+#include "mojo/services/media/common/cpp/timeline_function.h"
+#include "mojo/services/media/core/interfaces/timeline_controller.mojom.h"
+#include "services/media/common/mojo_publisher.h"
+
+namespace mojo {
+namespace media {
+
+// MediaTimelineControlSite implementation.
+class TimelineControlSite : public MediaTimelineControlSite,
+ public TimelineConsumer {
+ public:
+ TimelineControlSite();
+
+ ~TimelineControlSite() override;
+
+ // Binds to the control site. If a binding exists already, it is closed.
+ void Bind(InterfaceRequest<MediaTimelineControlSite> request);
+
+ // Determines whether the control site is currently bound.
+ bool is_bound() { return control_site_binding_.is_bound(); }
+
+ // Unbinds from clients and resets to initial state.
+ void Reset();
+
+ // Get the TimelineFunction for the reference_time (which should be 'now',
+ // approximately).
+ void SnapshotCurrentFunction(int64_t reference_time,
+ TimelineFunction* out,
+ uint32_t* generation = nullptr);
+
+ // MediaTimelineControlSite implementation.
+ void GetStatus(uint64_t version_last_seen,
+ const GetStatusCallback& callback) override;
+
+ void GetTimelineConsumer(
+ InterfaceRequest<TimelineConsumer> timeline_consumer) override;
+
+ // TimelineConsumer implementation.
+ void SetTimelineTransform(
+ int64_t subject_time,
+ uint32_t reference_delta,
+ uint32_t subject_delta,
+ int64_t effective_reference_time,
+ int64_t effective_subject_time,
+ const SetTimelineTransformCallback& callback) override;
+
+ private:
+ // Applies pending_timeline_function_ if it's time to do so based on the
+ // given reference time.
+ void ApplyPendingChangesUnsafe(int64_t reference_time);
+
+ // Clears the pending timeline function and calls its associated callback
+ // with the indicated completed status.
+ void ClearPendingTimelineFunctionUnsafe(bool completed);
+
+ // Determines if an unrealized timeline function is currently pending.
+ bool TimelineFunctionPendingUnsafe() {
+ return pending_timeline_function_.reference_time() != kUnspecifiedTime;
+ }
+
+ // Unbinds from clients and resets to initial state.
+ void ResetUnsafe();
+
+ static void RunCallback(SetTimelineTransformCallback callback,
+ bool completed);
+
+ Binding<MediaTimelineControlSite> control_site_binding_;
+ Binding<TimelineConsumer> consumer_binding_;
+ MojoPublisher<GetStatusCallback> status_publisher_;
+
+ base::Lock lock_;
+ // BEGIN fields synchronized using lock_.
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
+ TimelineFunction current_timeline_function_;
+ TimelineFunction pending_timeline_function_;
+ SetTimelineTransformCallback set_timeline_transform_callback_;
+ uint32_t generation_ = 1;
+ // END fields synchronized using lock_.
+};
+
+} // namespace media
+} // namespace mojo
+
+#endif // MOJO_SERVICES_MEDIA_COMMON_TIMELINE_CONTROL_SITE_IMPL_H_
« no previous file with comments | « services/media/common/rate_control_base.cc ('k') | services/media/common/timeline_control_site.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698