Chromium Code Reviews| 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..c853638e1256d9065649284f339ffc293d159ca5 |
| --- /dev/null |
| +++ b/services/media/common/timeline_control_site.h |
| @@ -0,0 +1,97 @@ |
| +// 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 <memory> |
|
kulakowski
2016/05/24 13:57:24
What's this header used for?
dalesat
2016/05/24 18:09:16
Nothing, apparently. Removed.
|
| +#include <vector> |
| + |
| +#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_ |