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

Unified Diff: media/base/android/media_source_player.h

Issue 254473010: Refactor MSE implementation on Android to simplify the logic and improve the performance (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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
Index: media/base/android/media_source_player.h
diff --git a/media/base/android/media_source_player.h b/media/base/android/media_source_player.h
index bd8457ed734ebfeb5ef97dea2cd530154d4cf9e8..7577b35976d90fc466389d9707a423f41501785a 100644
--- a/media/base/android/media_source_player.h
+++ b/media/base/android/media_source_player.h
@@ -100,15 +100,6 @@ class MEDIA_EXPORT MediaSourcePlayer : public MediaPlayerAndroid,
// Handle pending events if all the decoder jobs are not currently decoding.
void ProcessPendingEvents();
- // Helper method to clear any pending |SURFACE_CHANGE_EVENT_PENDING|
- // and reset |video_decoder_job_| to null.
- void ResetVideoDecoderJob();
- void ResetAudioDecoderJob();
-
- // Helper methods to configure the decoder jobs.
- void ConfigureVideoDecoderJob();
- void ConfigureAudioDecoderJob();
-
// Flush the decoders and clean up all the data needs to be decoded.
void ClearDecodingData();
@@ -155,9 +146,6 @@ class MEDIA_EXPORT MediaSourcePlayer : public MediaPlayerAndroid,
// since last keyframe. See http://crbug.com/304234.
void BrowserSeekToCurrentTime();
- // Helper function to set the volume.
- void SetVolumeInternal();
-
// Helper function to determine whether a protected surface is needed for
// video playback.
bool IsProtectedSurfaceRequired();
@@ -168,6 +156,9 @@ class MEDIA_EXPORT MediaSourcePlayer : public MediaPlayerAndroid,
// resync with audio and starts decoding.
void OnPrefetchDone();
+ // Called when the demuxer config changes.
+ void OnDemuxerConfigsChanged();
+
// Test-only method to setup hook for the completion of the next decode cycle.
// This callback state is cleared when it is next run.
// Prevent usage creep by only calling this from the
@@ -182,10 +173,9 @@ class MEDIA_EXPORT MediaSourcePlayer : public MediaPlayerAndroid,
enum PendingEventFlags {
NO_EVENT_PENDING = 0,
SEEK_EVENT_PENDING = 1 << 0,
- SURFACE_CHANGE_EVENT_PENDING = 1 << 1,
- CONFIG_CHANGE_EVENT_PENDING = 1 << 2,
- PREFETCH_REQUEST_EVENT_PENDING = 1 << 3,
- PREFETCH_DONE_EVENT_PENDING = 1 << 4,
+ PREFETCH_REQUEST_EVENT_PENDING = 1 << 1,
+ PREFETCH_DONE_EVENT_PENDING = 1 << 2,
+ DECODER_CREATION_EVENT_PENDING = 1 << 3,
};
static const char* GetEventName(PendingEventFlags event);
@@ -200,20 +190,7 @@ class MEDIA_EXPORT MediaSourcePlayer : public MediaPlayerAndroid,
// Stats about the media.
base::TimeDelta duration_;
- int width_;
- int height_;
- AudioCodec audio_codec_;
- VideoCodec video_codec_;
- int num_channels_;
- int sampling_rate_;
- // TODO(xhwang/qinmin): Add |video_extra_data_|.
- std::vector<uint8> audio_extra_data_;
- bool reached_audio_eos_;
- bool reached_video_eos_;
bool playing_;
- bool is_audio_encrypted_;
- bool is_video_encrypted_;
- double volume_;
// base::TickClock used by |clock_|.
base::DefaultTickClock default_tick_clock_;
@@ -230,16 +207,6 @@ class MEDIA_EXPORT MediaSourcePlayer : public MediaPlayerAndroid,
base::TimeTicks start_time_ticks_;
base::TimeDelta start_presentation_timestamp_;
- // The surface object currently owned by the player.
- gfx::ScopedJavaSurface surface_;
-
- // Track whether or not the player has received any video data since the most
- // recent of player construction, end of last seek, or receiving and
- // detecting a |kConfigChanged| access unit from the demuxer.
- // If no such video data has been received, the next video data begins with
- // an I-frame. Otherwise, we have no such guarantee.
- bool next_video_data_is_iframe_;
-
// Flag that is true if doing a hack browser seek or false if doing a
// regular seek. Only valid when |SEEK_EVENT_PENDING| is pending.
// TODO(wolenetz): Instead of doing hack browser seek, replay cached data
@@ -257,9 +224,6 @@ class MEDIA_EXPORT MediaSourcePlayer : public MediaPlayerAndroid,
scoped_ptr<AudioDecoderJob, MediaDecoderJob::Deleter> audio_decoder_job_;
scoped_ptr<VideoDecoderJob, MediaDecoderJob::Deleter> video_decoder_job_;
- bool reconfig_audio_decoder_;
- bool reconfig_video_decoder_;
-
// Track the most recent preroll target. Decoder re-creation needs this to
// resume any in-progress preroll.
base::TimeDelta preroll_timestamp_;
@@ -276,16 +240,19 @@ class MEDIA_EXPORT MediaSourcePlayer : public MediaPlayerAndroid,
// try to start playback again.
bool is_waiting_for_key_;
+ // Indicates whether the player is waiting for audio or video decoder to be
+ // created.
+ // TODO(qinmin): currently only |is_waiting_for_audio_decoder_| is used due to
+ // empty surface. Will remove is_|waiting_for_audio_decoder_| if needed.
+ bool is_waiting_for_audio_decoder_;
+ bool is_waiting_for_video_decoder_;
+
// Test-only callback for hooking the completion of the next decode cycle.
base::Closure decode_callback_for_testing_;
// Whether |surface_| is currently used by the player.
bool is_surface_in_use_;
- // Whether there are pending data requests by the decoder.
- bool has_pending_audio_data_request_;
- bool has_pending_video_data_request_;
-
// Weak pointer passed to media decoder jobs for callbacks.
// NOTE: Weak pointers must be invalidated before all other member variables.
base::WeakPtrFactory<MediaSourcePlayer> weak_factory_;

Powered by Google App Engine
This is Rietveld 408576698