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

Unified Diff: services/media/factory_service/media_player_impl.h

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/factory_service/media_player_impl.h
diff --git a/services/media/factory_service/media_player_impl.h b/services/media/factory_service/media_player_impl.h
index 0a09d9c85b9cff8e95d7911e1384c04492a88b22..d9b5be879db3460633da38fe873d34d1844ffd69 100644
--- a/services/media/factory_service/media_player_impl.h
+++ b/services/media/factory_service/media_player_impl.h
@@ -10,11 +10,14 @@
#include "mojo/public/cpp/application/application_impl.h"
#include "mojo/public/cpp/bindings/binding.h"
+#include "mojo/services/media/common/cpp/timeline.h"
+#include "mojo/services/media/common/cpp/timeline_function.h"
#include "mojo/services/media/common/interfaces/media_transport.mojom.h"
#include "mojo/services/media/control/interfaces/media_factory.mojom.h"
#include "mojo/services/media/core/interfaces/seeking_reader.mojom.h"
#include "services/media/common/mojo_publisher.h"
#include "services/media/factory_service/factory_service.h"
+#include "services/media/framework/util/callback_joiner.h"
namespace mojo {
namespace media {
@@ -41,24 +44,13 @@ class MediaPlayerImpl : public MediaFactoryService::Product<MediaPlayer>,
void Seek(int64_t position) override;
private:
- const int64_t kNotSeeking = std::numeric_limits<int64_t>::max();
+ static constexpr int64_t kMinimumLeadTime = Timeline::ns_from_ms(30);
// Internal state.
enum class State {
kWaiting, // Waiting for some work to complete.
kPaused,
- kWaitingForSinksToPlay,
kPlaying,
- kWaitingForSinksToPause
- };
-
- // For matching sink states.
- enum class SinkState {
- kPaused,
- kPlaying,
- kEnded,
- kPausedOrEnded,
- kPlayingOrEnded
};
struct Stream {
@@ -66,10 +58,12 @@ class MediaPlayerImpl : public MediaFactoryService::Product<MediaPlayer>,
~Stream();
size_t index_;
bool enabled_ = false;
- MediaState state_ = MediaState::UNPREPARED;
+ bool end_of_stream_ = false;
MediaTypePtr media_type_;
MediaTypeConverterPtr decoder_;
MediaSinkPtr sink_;
+ MediaTimelineControlSitePtr timeline_control_site_;
+ TimelineConsumerPtr timeline_consumer_;
MediaProducerPtr encoded_producer_;
MediaProducerPtr decoded_producer_;
};
@@ -87,14 +81,22 @@ class MediaPlayerImpl : public MediaFactoryService::Product<MediaPlayer>,
// Handles seeking in paused state with flushed pipeline.
void WhenFlushedAndSeeking();
- // Tells the sinks to change state.
- void ChangeSinkStates(MediaState media_state);
+ // Sets the timeline transforms on all the sinks. transform_subject_time_ is
+ // used for the subject_time, and the effective_reference_time is now plus an
+ // epsilon.
+ void SetSinkTimelineTransforms(uint32_t reference_delta,
+ uint32_t subject_delta);
- // Determines if all the enabled sinks have the specified state.
- bool AllSinksAre(SinkState sink_state);
+ // Sets the timeline transforms on all the sinks.
+ void SetSinkTimelineTransforms(int64_t subject_time,
+ uint32_t reference_delta,
+ uint32_t subject_delta,
+ int64_t effective_reference_time,
+ int64_t effective_subject_time);
- // Sets the reported_media_state_ field, calling StatusUpdated as needed.
- void SetReportedMediaState(MediaState media_state);
+ // Determines if all the enabled sinks have reached end-of-stream. Returns
+ // false if there are no enabled streams.
+ bool AllSinksAtEndOfStream();
// Prepares a stream.
void PrepareStream(Stream* stream,
@@ -113,21 +115,23 @@ class MediaPlayerImpl : public MediaFactoryService::Product<MediaPlayer>,
uint64_t version = MediaDemux::kInitialMetadata,
MediaMetadataPtr metadata = nullptr);
- // Handles a status update from a sink. When called with the default
- // argument values, initiates sink status updates.
- void HandleSinkStatusUpdates(Stream* stream,
- uint64_t version = MediaSink::kInitialStatus,
- MediaSinkStatusPtr status = nullptr);
+ // Handles a status update from a control site. When called with the default
+ // argument values, initiates control site. status updates.
+ void HandleTimelineControlSiteStatusUpdates(
+ Stream* stream,
+ uint64_t version = MediaTimelineControlSite::kInitialStatus,
+ MediaTimelineControlSiteStatusPtr status = nullptr);
MediaFactoryPtr factory_;
MediaDemuxPtr demux_;
std::vector<std::unique_ptr<Stream>> streams_;
State state_ = State::kWaiting;
+ State target_state_ = State::kPaused;
bool flushed_ = true;
- MediaState reported_media_state_ = MediaState::UNPREPARED;
- MediaState target_state_ = MediaState::PAUSED;
- int64_t target_position_ = kNotSeeking;
- TimelineTransformPtr transform_;
+ int64_t target_position_ = kUnspecifiedTime;
+ int64_t transform_subject_time_ = kUnspecifiedTime;
+ TimelineFunction timeline_function_;
+ CallbackJoiner set_transform_joiner_;
MediaMetadataPtr metadata_;
MojoPublisher<GetStatusCallback> status_publisher_;
};

Powered by Google App Engine
This is Rietveld 408576698