diff options
author | scherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-30 02:14:00 +0000 |
---|---|---|
committer | scherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-30 02:14:00 +0000 |
commit | 277a5667342ca6a579e2a2a3d561dd84178a2ea4 (patch) | |
tree | 3a7b4e407f39d80c46f0321f5be7e434d7dd2c40 /media/base/android | |
parent | 29e17b0c93ebdf58447202c33d6ea0bd30ec6073 (diff) | |
download | chromium_src-277a5667342ca6a579e2a2a3d561dd84178a2ea4.zip chromium_src-277a5667342ca6a579e2a2a3d561dd84178a2ea4.tar.gz chromium_src-277a5667342ca6a579e2a2a3d561dd84178a2ea4.tar.bz2 |
Rename MediaPlayerHostMsg_{DemuxerReady,ReadFromDemuxerAck}_Params to Demuxer{Configs,Data}.
Life is short and we've only got so much horizontal whitespace to work with.
This also helps pave the way for introducing Android demuxer client interfaces for media/ code.
BUG=263652
TBR=palmer
Review URL: https://chromiumcodereview.appspot.com/23787002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@220478 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base/android')
-rw-r--r-- | media/base/android/demuxer_stream_player_params.cc | 13 | ||||
-rw-r--r-- | media/base/android/demuxer_stream_player_params.h | 12 | ||||
-rw-r--r-- | media/base/android/media_decoder_job.cc | 11 | ||||
-rw-r--r-- | media/base/android/media_decoder_job.h | 5 | ||||
-rw-r--r-- | media/base/android/media_player_android.cc | 6 | ||||
-rw-r--r-- | media/base/android/media_player_android.h | 7 | ||||
-rw-r--r-- | media/base/android/media_source_player.cc | 36 | ||||
-rw-r--r-- | media/base/android/media_source_player.h | 6 | ||||
-rw-r--r-- | media/base/android/media_source_player_unittest.cc | 132 |
9 files changed, 106 insertions, 122 deletions
diff --git a/media/base/android/demuxer_stream_player_params.cc b/media/base/android/demuxer_stream_player_params.cc index 827be11..d5021a9 100644 --- a/media/base/android/demuxer_stream_player_params.cc +++ b/media/base/android/demuxer_stream_player_params.cc @@ -6,8 +6,7 @@ namespace media { -MediaPlayerHostMsg_DemuxerReady_Params:: - MediaPlayerHostMsg_DemuxerReady_Params() +DemuxerConfigs::DemuxerConfigs() : audio_codec(kUnknownAudioCodec), audio_channels(0), audio_sampling_rate(0), @@ -16,18 +15,14 @@ MediaPlayerHostMsg_DemuxerReady_Params:: is_video_encrypted(false), duration_ms(0) {} -MediaPlayerHostMsg_DemuxerReady_Params:: - ~MediaPlayerHostMsg_DemuxerReady_Params() {} +DemuxerConfigs::~DemuxerConfigs() {} AccessUnit::AccessUnit() : end_of_stream(false) {} AccessUnit::~AccessUnit() {} -MediaPlayerHostMsg_ReadFromDemuxerAck_Params:: - MediaPlayerHostMsg_ReadFromDemuxerAck_Params() - : type(DemuxerStream::UNKNOWN) {} +DemuxerData::DemuxerData() : type(DemuxerStream::UNKNOWN) {} -MediaPlayerHostMsg_ReadFromDemuxerAck_Params:: - ~MediaPlayerHostMsg_ReadFromDemuxerAck_Params() {} +DemuxerData::~DemuxerData() {} } // namespace media diff --git a/media/base/android/demuxer_stream_player_params.h b/media/base/android/demuxer_stream_player_params.h index a9fb052..92ef74f 100644 --- a/media/base/android/demuxer_stream_player_params.h +++ b/media/base/android/demuxer_stream_player_params.h @@ -17,9 +17,9 @@ namespace media { -struct MEDIA_EXPORT MediaPlayerHostMsg_DemuxerReady_Params { - MediaPlayerHostMsg_DemuxerReady_Params(); - ~MediaPlayerHostMsg_DemuxerReady_Params(); +struct MEDIA_EXPORT DemuxerConfigs { + DemuxerConfigs(); + ~DemuxerConfigs(); AudioCodec audio_codec; int audio_channels; @@ -50,9 +50,9 @@ struct MEDIA_EXPORT AccessUnit { std::vector<media::SubsampleEntry> subsamples; }; -struct MEDIA_EXPORT MediaPlayerHostMsg_ReadFromDemuxerAck_Params { - MediaPlayerHostMsg_ReadFromDemuxerAck_Params(); - ~MediaPlayerHostMsg_ReadFromDemuxerAck_Params(); +struct MEDIA_EXPORT DemuxerData { + DemuxerData(); + ~DemuxerData(); DemuxerStream::Type type; std::vector<AccessUnit> access_units; diff --git a/media/base/android/media_decoder_job.cc b/media/base/android/media_decoder_job.cc index 814742a..0a2e147 100644 --- a/media/base/android/media_decoder_job.cc +++ b/media/base/android/media_decoder_job.cc @@ -35,8 +35,7 @@ MediaDecoderJob::MediaDecoderJob( MediaDecoderJob::~MediaDecoderJob() {} -void MediaDecoderJob::OnDataReceived( - const MediaPlayerHostMsg_ReadFromDemuxerAck_Params& params) { +void MediaDecoderJob::OnDataReceived(const DemuxerData& data) { DCHECK(ui_loop_->BelongsToCurrentThread()); DCHECK(!on_data_received_cb_.is_null()); @@ -48,7 +47,7 @@ void MediaDecoderJob::OnDataReceived( } access_unit_index_ = 0; - received_data_ = params; + received_data_ = data; done_cb.Run(); } @@ -92,7 +91,7 @@ bool MediaDecoderJob::Decode( received_data_.access_units[access_unit_index_].status) { // Clear received data because we need to handle a config change. decode_cb_.Reset(); - received_data_ = MediaPlayerHostMsg_ReadFromDemuxerAck_Params(); + received_data_ = DemuxerData(); access_unit_index_ = 0; return false; } @@ -113,7 +112,7 @@ void MediaDecoderJob::Flush() { // Do nothing, flush when the next Decode() happens. needs_flush_ = true; - received_data_ = MediaPlayerHostMsg_ReadFromDemuxerAck_Params(); + received_data_ = DemuxerData(); access_unit_index_ = 0; on_data_received_cb_.Reset(); } @@ -172,7 +171,7 @@ void MediaDecoderJob::RequestData(const base::Closure& done_cb) { DCHECK(ui_loop_->BelongsToCurrentThread()); DCHECK(on_data_received_cb_.is_null()); - received_data_ = MediaPlayerHostMsg_ReadFromDemuxerAck_Params(); + received_data_ = DemuxerData(); access_unit_index_ = 0; on_data_received_cb_ = done_cb; diff --git a/media/base/android/media_decoder_job.h b/media/base/android/media_decoder_job.h index 45bafe6..00e20cf 100644 --- a/media/base/android/media_decoder_job.h +++ b/media/base/android/media_decoder_job.h @@ -45,8 +45,7 @@ class MediaDecoderJob { virtual ~MediaDecoderJob(); // Called by MediaSourcePlayer when more data for this object has arrived. - void OnDataReceived( - const MediaPlayerHostMsg_ReadFromDemuxerAck_Params& params); + void OnDataReceived(const DemuxerData& data); // Returns true if this object has data to decode. bool HasData() const; @@ -162,7 +161,7 @@ class MediaDecoderJob { size_t access_unit_index_; // Data received over IPC from last RequestData() operation. - MediaPlayerHostMsg_ReadFromDemuxerAck_Params received_data_; + DemuxerData received_data_; bool stop_decode_pending_; diff --git a/media/base/android/media_player_android.cc b/media/base/android/media_player_android.cc index c005506..6b1626a 100644 --- a/media/base/android/media_player_android.cc +++ b/media/base/android/media_player_android.cc @@ -63,13 +63,11 @@ void MediaPlayerAndroid::ReleaseMediaResourcesFromManager() { manager_->ReleaseMediaResources(player_id_); } -void MediaPlayerAndroid::DemuxerReady( - const MediaPlayerHostMsg_DemuxerReady_Params& params) { +void MediaPlayerAndroid::DemuxerReady(const DemuxerConfigs& configs) { NOTREACHED() << "Unexpected ipc received"; } -void MediaPlayerAndroid::ReadFromDemuxerAck( - const MediaPlayerHostMsg_ReadFromDemuxerAck_Params& params) { +void MediaPlayerAndroid::ReadFromDemuxerAck(const DemuxerData& data) { NOTREACHED() << "Unexpected ipc received"; } diff --git a/media/base/android/media_player_android.h b/media/base/android/media_player_android.h index f1c9c37..06cb573 100644 --- a/media/base/android/media_player_android.h +++ b/media/base/android/media_player_android.h @@ -88,11 +88,10 @@ class MEDIA_EXPORT MediaPlayerAndroid { // Methods for DemuxerStreamPlayer. // Informs DemuxerStreamPlayer that the demuxer is ready. - virtual void DemuxerReady( - const MediaPlayerHostMsg_DemuxerReady_Params& params); + virtual void DemuxerReady(const DemuxerConfigs& configs); + // Called when the requested data is received from the demuxer. - virtual void ReadFromDemuxerAck( - const MediaPlayerHostMsg_ReadFromDemuxerAck_Params& params); + virtual void ReadFromDemuxerAck(const DemuxerData& data); // Called when a seek request is acked by the render process. virtual void OnSeekRequestAck(unsigned seek_request_id); diff --git a/media/base/android/media_source_player.cc b/media/base/android/media_source_player.cc index 4fe1f03..ba87bf0 100644 --- a/media/base/android/media_source_player.cc +++ b/media/base/android/media_source_player.cc @@ -207,17 +207,16 @@ void MediaSourcePlayer::StartInternal() { ProcessPendingEvents(); } -void MediaSourcePlayer::DemuxerReady( - const MediaPlayerHostMsg_DemuxerReady_Params& params) { +void MediaSourcePlayer::DemuxerReady(const DemuxerConfigs& configs) { DVLOG(1) << __FUNCTION__; - duration_ = base::TimeDelta::FromMilliseconds(params.duration_ms); + duration_ = base::TimeDelta::FromMilliseconds(configs.duration_ms); clock_.SetDuration(duration_); - audio_codec_ = params.audio_codec; - num_channels_ = params.audio_channels; - sampling_rate_ = params.audio_sampling_rate; - is_audio_encrypted_ = params.is_audio_encrypted; - audio_extra_data_ = params.audio_extra_data; + audio_codec_ = configs.audio_codec; + num_channels_ = configs.audio_channels; + sampling_rate_ = configs.audio_sampling_rate; + is_audio_encrypted_ = configs.is_audio_encrypted; + audio_extra_data_ = configs.audio_extra_data; if (HasAudio()) { DCHECK_GT(num_channels_, 0); audio_timestamp_helper_.reset(new AudioTimestampHelper(sampling_rate_)); @@ -226,10 +225,10 @@ void MediaSourcePlayer::DemuxerReady( audio_timestamp_helper_.reset(); } - video_codec_ = params.video_codec; - width_ = params.video_size.width(); - height_ = params.video_size.height(); - is_video_encrypted_ = params.is_video_encrypted; + video_codec_ = configs.video_codec; + width_ = configs.video_size.width(); + height_ = configs.video_size.height(); + is_video_encrypted_ = configs.is_video_encrypted; OnMediaMetadataChanged(duration_, width_, height_, true); @@ -253,14 +252,13 @@ void MediaSourcePlayer::DemuxerReady( } } -void MediaSourcePlayer::ReadFromDemuxerAck( - const MediaPlayerHostMsg_ReadFromDemuxerAck_Params& params) { - DVLOG(1) << __FUNCTION__ << "(" << params.type << ")"; - DCHECK_LT(0u, params.access_units.size()); - if (params.type == DemuxerStream::AUDIO) - audio_decoder_job_->OnDataReceived(params); +void MediaSourcePlayer::ReadFromDemuxerAck(const DemuxerData& data) { + DVLOG(1) << __FUNCTION__ << "(" << data.type << ")"; + DCHECK_LT(0u, data.access_units.size()); + if (data.type == DemuxerStream::AUDIO) + audio_decoder_job_->OnDataReceived(data); else - video_decoder_job_->OnDataReceived(params); + video_decoder_job_->OnDataReceived(data); } void MediaSourcePlayer::DurationChanged(const base::TimeDelta& duration) { diff --git a/media/base/android/media_source_player.h b/media/base/android/media_source_player.h index 2ea9dde..decc5cc 100644 --- a/media/base/android/media_source_player.h +++ b/media/base/android/media_source_player.h @@ -58,10 +58,8 @@ class MEDIA_EXPORT MediaSourcePlayer : public MediaPlayerAndroid { virtual bool CanSeekBackward() OVERRIDE; virtual bool IsPlayerReady() OVERRIDE; virtual void OnSeekRequestAck(unsigned seek_request_id) OVERRIDE; - virtual void DemuxerReady( - const MediaPlayerHostMsg_DemuxerReady_Params& params) OVERRIDE; - virtual void ReadFromDemuxerAck( - const MediaPlayerHostMsg_ReadFromDemuxerAck_Params& params) OVERRIDE; + virtual void DemuxerReady(const DemuxerConfigs& configs) OVERRIDE; + virtual void ReadFromDemuxerAck(const DemuxerData& data) OVERRIDE; virtual void DurationChanged(const base::TimeDelta& duration) OVERRIDE; virtual void SetDrmBridge(MediaDrmBridge* drm_bridge) OVERRIDE; diff --git a/media/base/android/media_source_player_unittest.cc b/media/base/android/media_source_player_unittest.cc index 77cca95..e3dbf20 100644 --- a/media/base/android/media_source_player_unittest.cc +++ b/media/base/android/media_source_player_unittest.cc @@ -108,72 +108,70 @@ class MediaSourcePlayerTest : public testing::Test { // Starts an audio decoder job. void StartAudioDecoderJob() { - MediaPlayerHostMsg_DemuxerReady_Params params; - params.audio_codec = kCodecVorbis; - params.audio_channels = 2; - params.audio_sampling_rate = 44100; - params.is_audio_encrypted = false; - params.duration_ms = kDefaultDurationInMs; + DemuxerConfigs configs; + configs.audio_codec = kCodecVorbis; + configs.audio_channels = 2; + configs.audio_sampling_rate = 44100; + configs.is_audio_encrypted = false; + configs.duration_ms = kDefaultDurationInMs; scoped_refptr<DecoderBuffer> buffer = ReadTestDataFile("vorbis-extradata"); - params.audio_extra_data = std::vector<uint8>( + configs.audio_extra_data = std::vector<uint8>( buffer->data(), buffer->data() + buffer->data_size()); - Start(params); + Start(configs); } void StartVideoDecoderJob() { - MediaPlayerHostMsg_DemuxerReady_Params params; - params.video_codec = kCodecVP8; - params.video_size = gfx::Size(320, 240); - params.is_video_encrypted = false; - params.duration_ms = kDefaultDurationInMs; - Start(params); + DemuxerConfigs configs; + configs.video_codec = kCodecVP8; + configs.video_size = gfx::Size(320, 240); + configs.is_video_encrypted = false; + configs.duration_ms = kDefaultDurationInMs; + Start(configs); } // Starts decoding the data. - void Start(const MediaPlayerHostMsg_DemuxerReady_Params& params) { - player_->DemuxerReady(params); + void Start(const DemuxerConfigs& configs) { + player_->DemuxerReady(configs); player_->Start(); } - MediaPlayerHostMsg_ReadFromDemuxerAck_Params - CreateReadFromDemuxerAckForAudio(int packet_id) { - MediaPlayerHostMsg_ReadFromDemuxerAck_Params ack_params; - ack_params.type = DemuxerStream::AUDIO; - ack_params.access_units.resize(1); - ack_params.access_units[0].status = DemuxerStream::kOk; + DemuxerData CreateReadFromDemuxerAckForAudio(int packet_id) { + DemuxerData data; + data.type = DemuxerStream::AUDIO; + data.access_units.resize(1); + data.access_units[0].status = DemuxerStream::kOk; scoped_refptr<DecoderBuffer> buffer = ReadTestDataFile( base::StringPrintf("vorbis-packet-%d", packet_id)); - ack_params.access_units[0].data = std::vector<uint8>( + data.access_units[0].data = std::vector<uint8>( buffer->data(), buffer->data() + buffer->data_size()); // Vorbis needs 4 extra bytes padding on Android to decode properly. Check // NuMediaExtractor.cpp in Android source code. uint8 padding[4] = { 0xff , 0xff , 0xff , 0xff }; - ack_params.access_units[0].data.insert( - ack_params.access_units[0].data.end(), padding, padding + 4); - return ack_params; + data.access_units[0].data.insert( + data.access_units[0].data.end(), padding, padding + 4); + return data; } - MediaPlayerHostMsg_ReadFromDemuxerAck_Params - CreateReadFromDemuxerAckForVideo() { - MediaPlayerHostMsg_ReadFromDemuxerAck_Params ack_params; - ack_params.type = DemuxerStream::VIDEO; - ack_params.access_units.resize(1); - ack_params.access_units[0].status = DemuxerStream::kOk; + DemuxerData CreateReadFromDemuxerAckForVideo() { + DemuxerData data; + data.type = DemuxerStream::VIDEO; + data.access_units.resize(1); + data.access_units[0].status = DemuxerStream::kOk; scoped_refptr<DecoderBuffer> buffer = ReadTestDataFile("vp8-I-frame-320x240"); - ack_params.access_units[0].data = std::vector<uint8>( + data.access_units[0].data = std::vector<uint8>( buffer->data(), buffer->data() + buffer->data_size()); - return ack_params; + return data; } - MediaPlayerHostMsg_ReadFromDemuxerAck_Params CreateEOSAck(bool is_audio) { - MediaPlayerHostMsg_ReadFromDemuxerAck_Params ack_params; - ack_params.type = is_audio ? DemuxerStream::AUDIO : DemuxerStream::VIDEO; - ack_params.access_units.resize(1); - ack_params.access_units[0].status = DemuxerStream::kOk; - ack_params.access_units[0].end_of_stream = true; - return ack_params; + DemuxerData CreateEOSAck(bool is_audio) { + DemuxerData data; + data.type = is_audio ? DemuxerStream::AUDIO : DemuxerStream::VIDEO; + data.access_units.resize(1); + data.access_units[0].status = DemuxerStream::kOk; + data.access_units[0].end_of_stream = true; + return data; } base::TimeTicks StartTimeTicks() { @@ -202,16 +200,16 @@ TEST_F(MediaSourcePlayerTest, StartAudioDecoderWithInvalidConfig) { return; // Test audio decoder job will not be created when failed to start the codec. - MediaPlayerHostMsg_DemuxerReady_Params params; - params.audio_codec = kCodecVorbis; - params.audio_channels = 2; - params.audio_sampling_rate = 44100; - params.is_audio_encrypted = false; - params.duration_ms = kDefaultDurationInMs; + DemuxerConfigs configs; + configs.audio_codec = kCodecVorbis; + configs.audio_channels = 2; + configs.audio_sampling_rate = 44100; + configs.is_audio_encrypted = false; + configs.duration_ms = kDefaultDurationInMs; uint8 invalid_codec_data[] = { 0x00, 0xff, 0xff, 0xff, 0xff }; - params.audio_extra_data.insert(params.audio_extra_data.begin(), + configs.audio_extra_data.insert(configs.audio_extra_data.begin(), invalid_codec_data, invalid_codec_data + 4); - Start(params); + Start(configs); EXPECT_EQ(NULL, GetMediaDecoderJob(true)); EXPECT_EQ(0, manager_->num_requests()); } @@ -307,13 +305,13 @@ TEST_F(MediaSourcePlayerTest, StartAfterSeekFinish) { return; // Test decoder job will not start until all pending seek event is handled. - MediaPlayerHostMsg_DemuxerReady_Params params; - params.audio_codec = kCodecVorbis; - params.audio_channels = 2; - params.audio_sampling_rate = 44100; - params.is_audio_encrypted = false; - params.duration_ms = kDefaultDurationInMs; - player_->DemuxerReady(params); + DemuxerConfigs configs; + configs.audio_codec = kCodecVorbis; + configs.audio_channels = 2; + configs.audio_sampling_rate = 44100; + configs.is_audio_encrypted = false; + configs.duration_ms = kDefaultDurationInMs; + player_->DemuxerReady(configs); EXPECT_EQ(NULL, GetMediaDecoderJob(true)); EXPECT_EQ(0, manager_->num_requests()); @@ -371,20 +369,20 @@ TEST_F(MediaSourcePlayerTest, DecoderJobsCannotStartWithoutAudio) { // Test that when Start() is called, video decoder jobs will wait for audio // decoder job before start decoding the data. - MediaPlayerHostMsg_DemuxerReady_Params params; - params.audio_codec = kCodecVorbis; - params.audio_channels = 2; - params.audio_sampling_rate = 44100; - params.is_audio_encrypted = false; + DemuxerConfigs configs; + configs.audio_codec = kCodecVorbis; + configs.audio_channels = 2; + configs.audio_sampling_rate = 44100; + configs.is_audio_encrypted = false; scoped_refptr<DecoderBuffer> buffer = ReadTestDataFile("vorbis-extradata"); - params.audio_extra_data = std::vector<uint8>( + configs.audio_extra_data = std::vector<uint8>( buffer->data(), buffer->data() + buffer->data_size()); - params.video_codec = kCodecVP8; - params.video_size = gfx::Size(320, 240); - params.is_video_encrypted = false; - params.duration_ms = kDefaultDurationInMs; - Start(params); + configs.video_codec = kCodecVP8; + configs.video_size = gfx::Size(320, 240); + configs.is_video_encrypted = false; + configs.duration_ms = kDefaultDurationInMs; + Start(configs); EXPECT_EQ(0, manager_->num_requests()); scoped_refptr<gfx::SurfaceTexture> surface_texture( |