OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef MOJO_SERVICES_MEDIA_COMMON_TIMELINE_CONTROL_SITE_IMPL_H_ | |
6 #define MOJO_SERVICES_MEDIA_COMMON_TIMELINE_CONTROL_SITE_IMPL_H_ | |
7 | |
8 #include <memory> | |
kulakowski
2016/05/24 13:57:24
What's this header used for?
dalesat
2016/05/24 18:09:16
Nothing, apparently. Removed.
| |
9 #include <vector> | |
10 | |
11 #include "base/single_thread_task_runner.h" | |
12 #include "base/synchronization/lock.h" | |
13 #include "mojo/public/cpp/bindings/binding.h" | |
14 #include "mojo/services/media/common/cpp/timeline_function.h" | |
15 #include "mojo/services/media/core/interfaces/timeline_controller.mojom.h" | |
16 #include "services/media/common/mojo_publisher.h" | |
17 | |
18 namespace mojo { | |
19 namespace media { | |
20 | |
21 // MediaTimelineControlSite implementation. | |
22 class TimelineControlSite : public MediaTimelineControlSite, | |
23 public TimelineConsumer { | |
24 public: | |
25 TimelineControlSite(); | |
26 | |
27 ~TimelineControlSite() override; | |
28 | |
29 // Binds to the control site. If a binding exists already, it is closed. | |
30 void Bind(InterfaceRequest<MediaTimelineControlSite> request); | |
31 | |
32 // Determines whether the control site is currently bound. | |
33 bool is_bound() { return control_site_binding_.is_bound(); } | |
34 | |
35 // Unbinds from clients and resets to initial state. | |
36 void Reset(); | |
37 | |
38 // Get the TimelineFunction for the reference_time (which should be 'now', | |
39 // approximately). | |
40 void SnapshotCurrentFunction(int64_t reference_time, | |
41 TimelineFunction* out, | |
42 uint32_t* generation = nullptr); | |
43 | |
44 // MediaTimelineControlSite implementation. | |
45 void GetStatus(uint64_t version_last_seen, | |
46 const GetStatusCallback& callback) override; | |
47 | |
48 void GetTimelineConsumer( | |
49 InterfaceRequest<TimelineConsumer> timeline_consumer) override; | |
50 | |
51 // TimelineConsumer implementation. | |
52 void SetTimelineTransform( | |
53 int64_t subject_time, | |
54 uint32_t reference_delta, | |
55 uint32_t subject_delta, | |
56 int64_t effective_reference_time, | |
57 int64_t effective_subject_time, | |
58 const SetTimelineTransformCallback& callback) override; | |
59 | |
60 private: | |
61 // Applies pending_timeline_function_ if it's time to do so based on the | |
62 // given reference time. | |
63 void ApplyPendingChangesUnsafe(int64_t reference_time); | |
64 | |
65 // Clears the pending timeline function and calls its associated callback | |
66 // with the indicated completed status. | |
67 void ClearPendingTimelineFunctionUnsafe(bool completed); | |
68 | |
69 // Determines if an unrealized timeline function is currently pending. | |
70 bool TimelineFunctionPendingUnsafe() { | |
71 return pending_timeline_function_.reference_time() != kUnspecifiedTime; | |
72 } | |
73 | |
74 // Unbinds from clients and resets to initial state. | |
75 void ResetUnsafe(); | |
76 | |
77 static void RunCallback(SetTimelineTransformCallback callback, | |
78 bool completed); | |
79 | |
80 Binding<MediaTimelineControlSite> control_site_binding_; | |
81 Binding<TimelineConsumer> consumer_binding_; | |
82 MojoPublisher<GetStatusCallback> status_publisher_; | |
83 | |
84 base::Lock lock_; | |
85 // BEGIN fields synchronized using lock_. | |
86 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | |
87 TimelineFunction current_timeline_function_; | |
88 TimelineFunction pending_timeline_function_; | |
89 SetTimelineTransformCallback set_timeline_transform_callback_; | |
90 uint32_t generation_ = 1; | |
91 // END fields synchronized using lock_. | |
92 }; | |
93 | |
94 } // namespace media | |
95 } // namespace mojo | |
96 | |
97 #endif // MOJO_SERVICES_MEDIA_COMMON_TIMELINE_CONTROL_SITE_IMPL_H_ | |
OLD | NEW |