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

Unified Diff: media/renderers/renderer_impl.h

Issue 2684103005: Allow media track switching. (Closed)
Patch Set: Fixed comments Created 3 years, 8 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 | « media/renderers/default_renderer_factory.cc ('k') | media/renderers/renderer_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/renderers/renderer_impl.h
diff --git a/media/renderers/renderer_impl.h b/media/renderers/renderer_impl.h
index 0a30165b0cea2a7d96c18f4c2afe01fc5476c60d..e400e8ac161675608a38b74af23fe3d876b462f6 100644
--- a/media/renderers/renderer_impl.h
+++ b/media/renderers/renderer_impl.h
@@ -61,10 +61,6 @@ class MEDIA_EXPORT RendererImpl : public Renderer {
void SetVolume(float volume) final;
base::TimeDelta GetMediaTime() final;
- void OnStreamStatusChanged(DemuxerStream* stream,
- bool enabled,
- base::TimeDelta time);
-
// Helper functions for testing purposes. Must be called before Initialize().
void DisableUnderflowForTesting();
void EnableClocklessVideoPlaybackForTesting();
@@ -102,13 +98,42 @@ class MEDIA_EXPORT RendererImpl : public Renderer {
void OnVideoRendererInitializeDone(PipelineStatus status);
// Helper functions and callbacks for Flush().
+ void FlushInternal();
void FlushAudioRenderer();
void OnAudioRendererFlushDone();
void FlushVideoRenderer();
void OnVideoRendererFlushDone();
- void RestartAudioRenderer(base::TimeDelta time);
- void RestartVideoRenderer(base::TimeDelta time);
+ // This function notifies the renderer that the status of the demuxer |stream|
+ // has been changed, the new status is |enabled| and the change occured while
+ // playback position was |time|.
+ void OnStreamStatusChanged(DemuxerStream* stream,
+ bool enabled,
+ base::TimeDelta time);
+
+ // Reinitialize audio/video renderer during a demuxer stream switching. The
+ // renderer must be flushed first, and when the re-init is completed the
+ // corresponding callback will be invoked to restart playback.
+ // The |stream| parameter specifies the new demuxer stream, and the |time|
+ // parameter specifies the time on media timeline where the switch occured.
+ void ReinitializeAudioRenderer(DemuxerStream* stream, base::TimeDelta time);
+ void OnAudioRendererReinitialized(DemuxerStream* stream,
+ base::TimeDelta time,
+ PipelineStatus status);
+ void ReinitializeVideoRenderer(DemuxerStream* stream, base::TimeDelta time);
+ void OnVideoRendererReinitialized(DemuxerStream* stream,
+ base::TimeDelta time,
+ PipelineStatus status);
+
+ // Restart audio/video renderer playback after a demuxer stream switch or
+ // after a demuxer stream has been disabled and re-enabled. The |stream|
+ // parameter specifies which stream needs to be restarted. The |time|
+ // parameter specifies the position on the media timeline where the playback
+ // needs to be restarted. It is necessary for demuxers with independent
+ // streams (e.g. MSE / ChunkDemuxer) to synchronize data reading between those
+ // streams.
+ void RestartAudioRenderer(DemuxerStream* stream, base::TimeDelta time);
+ void RestartVideoRenderer(DemuxerStream* stream, base::TimeDelta time);
// Callback executed by filters to update statistics.
void OnStatisticsUpdate(const PipelineStatistics& stats);
@@ -124,6 +149,7 @@ class MEDIA_EXPORT RendererImpl : public Renderer {
// and PausePlayback() should be called
void OnBufferingStateChange(DemuxerStream::Type type,
BufferingState new_buffering_state);
+
// Handles the buffering notifications that we might get while an audio or a
// video stream is being restarted. In those cases we don't want to report
// underflows immediately and instead give decoders a chance to catch up with
@@ -133,6 +159,7 @@ class MEDIA_EXPORT RendererImpl : public Renderer {
bool HandleRestartedStreamBufferingChanges(
DemuxerStream::Type type,
BufferingState new_buffering_state);
+
bool WaitingForEnoughData() const;
void PausePlayback();
void StartPlayback();
@@ -167,6 +194,9 @@ class MEDIA_EXPORT RendererImpl : public Renderer {
std::unique_ptr<AudioRenderer> audio_renderer_;
std::unique_ptr<VideoRenderer> video_renderer_;
+ DemuxerStream* current_audio_stream_;
+ DemuxerStream* current_video_stream_;
+
// Renderer-provided time source used to control playback.
TimeSource* time_source_;
std::unique_ptr<WallClockTimeSource> wall_clock_time_source_;
@@ -201,7 +231,12 @@ class MEDIA_EXPORT RendererImpl : public Renderer {
bool restarting_audio_ = false;
bool restarting_video_ = false;
- std::list<base::Closure> pending_stream_status_notifications_;
+
+ // Flush operations and media track status changes must be serialized to avoid
+ // interfering with each other. This list will hold a list of postponed
+ // actions that need to be completed after the current async operation is
+ // completed.
+ std::list<base::Closure> pending_actions_;
base::WeakPtr<RendererImpl> weak_this_;
base::WeakPtrFactory<RendererImpl> weak_factory_;
« no previous file with comments | « media/renderers/default_renderer_factory.cc ('k') | media/renderers/renderer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698