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

Unified Diff: content/renderer/media/android/media_source_delegate.cc

Issue 136343002: Remove Chrome for TV code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 6 years, 11 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: content/renderer/media/android/media_source_delegate.cc
diff --git a/content/renderer/media/android/media_source_delegate.cc b/content/renderer/media/android/media_source_delegate.cc
index bd4cf1a02adcf5ee482d2fe9117035aca8e8136c..0476633281c530097f1053bdde88a99eecc61bcf 100644
--- a/content/renderer/media/android/media_source_delegate.cc
+++ b/content/renderer/media/android/media_source_delegate.cc
@@ -58,7 +58,6 @@ MediaSourceDelegate::MediaSourceDelegate(
demuxer_client_(demuxer_client),
demuxer_client_id_(demuxer_client_id),
media_log_(media_log),
- demuxer_(NULL),
is_demuxer_ready_(false),
audio_stream_(NULL),
video_stream_(NULL),
@@ -66,9 +65,6 @@ MediaSourceDelegate::MediaSourceDelegate(
doing_browser_seek_(false),
browser_seek_time_(media::kNoTimestamp()),
expecting_regular_seek_(false),
-#if defined(GOOGLE_TV)
- key_added_(false),
-#endif
access_unit_size_(0) {
DCHECK(main_loop_->BelongsToCurrentThread());
}
@@ -77,7 +73,6 @@ MediaSourceDelegate::~MediaSourceDelegate() {
DCHECK(main_loop_->BelongsToCurrentThread());
DVLOG(1) << __FUNCTION__ << " : " << demuxer_client_id_;
DCHECK(!chunk_demuxer_);
- DCHECK(!demuxer_);
DCHECK(!demuxer_client_);
DCHECK(!audio_decrypting_demuxer_stream_);
DCHECK(!video_decrypting_demuxer_stream_);
@@ -89,7 +84,7 @@ void MediaSourceDelegate::Destroy() {
DCHECK(main_loop_->BelongsToCurrentThread());
DVLOG(1) << __FUNCTION__ << " : " << demuxer_client_id_;
- if (!demuxer_) {
+ if (!chunk_demuxer_) {
DCHECK(!demuxer_client_);
delete this;
return;
@@ -102,8 +97,7 @@ void MediaSourceDelegate::Destroy() {
main_weak_factory_.InvalidateWeakPtrs();
DCHECK(!main_weak_factory_.HasWeakPtrs());
- if (chunk_demuxer_)
- chunk_demuxer_->Shutdown();
+ chunk_demuxer_->Shutdown();
// |this| will be transferred to the callback StopDemuxer() and
// OnDemuxerStopDone(). They own |this| and OnDemuxerStopDone() will delete
@@ -115,7 +109,7 @@ void MediaSourceDelegate::Destroy() {
void MediaSourceDelegate::StopDemuxer() {
DCHECK(media_loop_->BelongsToCurrentThread());
- DCHECK(demuxer_);
+ DCHECK(chunk_demuxer_);
demuxer_client_->RemoveDelegate(demuxer_client_id_);
demuxer_client_ = NULL;
@@ -132,8 +126,8 @@ void MediaSourceDelegate::StopDemuxer() {
// The callback OnDemuxerStopDone() owns |this| and will delete it when
// called. Hence using base::Unretained(this) is safe here.
- demuxer_->Stop(base::Bind(&MediaSourceDelegate::OnDemuxerStopDone,
- base::Unretained(this)));
+ chunk_demuxer_->Stop(base::Bind(&MediaSourceDelegate::OnDemuxerStopDone,
+ base::Unretained(this)));
}
void MediaSourceDelegate::InitializeMediaSource(
@@ -157,7 +151,6 @@ void MediaSourceDelegate::InitializeMediaSource(
media::BindToCurrentLoop(base::Bind(
&MediaSourceDelegate::OnNeedKey, main_weak_this_)),
base::Bind(&LogMediaSourceError, media_log_)));
- demuxer_ = chunk_demuxer_.get();
// |this| will be retained until StopDemuxer() is posted, so Unretained() is
// safe here.
@@ -169,31 +162,12 @@ void MediaSourceDelegate::InitializeMediaSource(
void MediaSourceDelegate::InitializeDemuxer() {
DCHECK(media_loop_->BelongsToCurrentThread());
demuxer_client_->AddDelegate(demuxer_client_id_, this);
- demuxer_->Initialize(this, base::Bind(&MediaSourceDelegate::OnDemuxerInitDone,
+ chunk_demuxer_->Initialize(this,
+ base::Bind(&MediaSourceDelegate::OnDemuxerInitDone,
media_weak_factory_.GetWeakPtr()),
- false);
+ false);
}
-#if defined(GOOGLE_TV)
-void MediaSourceDelegate::InitializeMediaStream(
- media::Demuxer* demuxer,
- const UpdateNetworkStateCB& update_network_state_cb) {
- DCHECK(main_loop_->BelongsToCurrentThread());
- DCHECK(demuxer);
- demuxer_ = demuxer;
- update_network_state_cb_ = media::BindToCurrentLoop(update_network_state_cb);
- // When playing Media Stream, don't wait to accumulate multiple packets per
- // IPC communication.
- access_unit_size_ = 1;
-
- // |this| will be retained until StopDemuxer() is posted, so Unretained() is
- // safe here.
- media_loop_->PostTask(FROM_HERE,
- base::Bind(&MediaSourceDelegate::InitializeDemuxer,
- base::Unretained(this)));
-}
-#endif
-
const blink::WebTimeRanges& MediaSourceDelegate::Buffered() {
buffered_web_time_ranges_ =
ConvertToWebTimeRanges(buffered_time_ranges_);
@@ -313,7 +287,7 @@ void MediaSourceDelegate::Seek(
void MediaSourceDelegate::SeekInternal(const base::TimeDelta& seek_time) {
DCHECK(media_loop_->BelongsToCurrentThread());
DCHECK(IsSeeking());
- demuxer_->Seek(seek_time, base::Bind(
+ chunk_demuxer_->Seek(seek_time, base::Bind(
&MediaSourceDelegate::OnDemuxerSeekDone,
media_weak_factory_.GetWeakPtr()));
}
@@ -388,7 +362,7 @@ void MediaSourceDelegate::OnBufferReady(
<< ((!buffer || buffer->end_of_stream()) ?
-1 : buffer->timestamp().InMilliseconds())
<< ") : " << demuxer_client_id_;
- DCHECK(demuxer_);
+ DCHECK(chunk_demuxer_);
// No new OnReadFromDemuxer() will be called during seeking. So this callback
// must be from previous OnReadFromDemuxer() call and should be ignored.
@@ -451,7 +425,6 @@ void MediaSourceDelegate::OnBufferReady(
data->access_units[index].data.assign(
buffer->data(), buffer->data() + buffer->data_size());
-#if !defined(GOOGLE_TV)
// Vorbis needs 4 extra bytes padding on Android. Check
// NuMediaExtractor.cpp in Android source code.
if (is_audio && media::kCodecVorbis ==
@@ -460,7 +433,6 @@ void MediaSourceDelegate::OnBufferReady(
data->access_units[index].data.end(), kVorbisPadding,
kVorbisPadding + 4);
}
-#endif
if (buffer->decrypt_config()) {
data->access_units[index].key_id = std::vector<char>(
buffer->decrypt_config()->key_id().begin(),
@@ -508,15 +480,15 @@ void MediaSourceDelegate::RemoveTextStream(
void MediaSourceDelegate::OnDemuxerInitDone(media::PipelineStatus status) {
DCHECK(media_loop_->BelongsToCurrentThread());
DVLOG(1) << __FUNCTION__ << "(" << status << ") : " << demuxer_client_id_;
- DCHECK(demuxer_);
+ DCHECK(chunk_demuxer_);
if (status != media::PIPELINE_OK) {
OnDemuxerError(status);
return;
}
- audio_stream_ = demuxer_->GetStream(DemuxerStream::AUDIO);
- video_stream_ = demuxer_->GetStream(DemuxerStream::VIDEO);
+ audio_stream_ = chunk_demuxer_->GetStream(DemuxerStream::AUDIO);
+ video_stream_ = chunk_demuxer_->GetStream(DemuxerStream::VIDEO);
if (audio_stream_ && audio_stream_->audio_decoder_config().is_encrypted() &&
!set_decryptor_ready_cb_.is_null()) {
@@ -568,7 +540,7 @@ void MediaSourceDelegate::OnAudioDecryptingDemuxerStreamInitDone(
media::PipelineStatus status) {
DCHECK(media_loop_->BelongsToCurrentThread());
DVLOG(1) << __FUNCTION__ << "(" << status << ") : " << demuxer_client_id_;
- DCHECK(demuxer_);
+ DCHECK(chunk_demuxer_);
if (status != media::PIPELINE_OK)
audio_decrypting_demuxer_stream_.reset();
@@ -591,7 +563,7 @@ void MediaSourceDelegate::OnVideoDecryptingDemuxerStreamInitDone(
media::PipelineStatus status) {
DCHECK(media_loop_->BelongsToCurrentThread());
DVLOG(1) << __FUNCTION__ << "(" << status << ") : " << demuxer_client_id_;
- DCHECK(demuxer_);
+ DCHECK(chunk_demuxer_);
if (status != media::PIPELINE_OK)
video_decrypting_demuxer_stream_.reset();
@@ -666,7 +638,6 @@ void MediaSourceDelegate::DeleteSelf() {
DCHECK(main_loop_->BelongsToCurrentThread());
DVLOG(1) << __FUNCTION__ << " : " << demuxer_client_id_;
chunk_demuxer_.reset();
- demuxer_ = NULL;
delete this;
}
@@ -677,42 +648,9 @@ void MediaSourceDelegate::OnMediaConfigRequest() {
NotifyDemuxerReady();
}
-#if defined(GOOGLE_TV)
-// TODO(kjyoun): Enhance logic to detect when to call NotifyDemuxerReady()
-// For now, we call it when the first key is added. See http://crbug.com/255781
-void MediaSourceDelegate::NotifyKeyAdded(const std::string& key_system) {
- if (!media_loop_->BelongsToCurrentThread()) {
- media_loop_->PostTask(FROM_HERE,
- base::Bind(&MediaSourceDelegate::NotifyKeyAdded,
- base::Unretained(this), key_system));
- return;
- }
- DVLOG(1) << __FUNCTION__ << " : " << demuxer_client_id_;
- if (key_added_)
- return;
- key_added_ = true;
- key_system_ = key_system;
- if (!CanNotifyDemuxerReady())
- return;
- if (HasEncryptedStream())
- NotifyDemuxerReady();
-}
-#endif // defined(GOOGLE_TV)
-
bool MediaSourceDelegate::CanNotifyDemuxerReady() {
DCHECK(media_loop_->BelongsToCurrentThread());
- // This can happen when a key is added before the demuxer is initialized.
- // See NotifyKeyAdded().
- // TODO(kjyoun): Remove NotifyDemxuerReady() call from NotifyKeyAdded() so
- // that we can remove all is_demuxer_ready_/key_added_/key_system_ madness.
- // See http://crbug.com/255781
- if (!is_demuxer_ready_)
- return false;
-#if defined(GOOGLE_TV)
- if (HasEncryptedStream() && !key_added_)
- return false;
-#endif // defined(GOOGLE_TV)
- return true;
+ return is_demuxer_ready_;
}
void MediaSourceDelegate::NotifyDemuxerReady() {
@@ -741,10 +679,6 @@ void MediaSourceDelegate::NotifyDemuxerReady() {
}
configs->duration_ms = GetDurationMs();
-#if defined(GOOGLE_TV)
- configs->key_system = HasEncryptedStream() ? key_system_ : "";
-#endif
-
if (demuxer_client_)
demuxer_client_->DemuxerReady(demuxer_client_id_, *configs);
}
« no previous file with comments | « content/renderer/media/android/media_source_delegate.h ('k') | content/renderer/media/android/renderer_media_player_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698