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

Side by Side Diff: media/base/pipeline.cc

Issue 11492003: Encrypted Media: Support Audio Decrypt-Only. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments mostly resolved (I believe); need to add/update tests if this looks good Created 8 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/base/pipeline.h" 5 #include "media/base/pipeline.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 DCHECK(seek_cb_.is_null()); 99 DCHECK(seek_cb_.is_null());
100 100
101 media_log_->AddEvent( 101 media_log_->AddEvent(
102 media_log_->CreateEvent(MediaLogEvent::PIPELINE_DESTROYED)); 102 media_log_->CreateEvent(MediaLogEvent::PIPELINE_DESTROYED));
103 } 103 }
104 104
105 void Pipeline::Start(scoped_ptr<FilterCollection> collection, 105 void Pipeline::Start(scoped_ptr<FilterCollection> collection,
106 const PipelineStatusCB& ended_cb, 106 const PipelineStatusCB& ended_cb,
107 const PipelineStatusCB& error_cb, 107 const PipelineStatusCB& error_cb,
108 const PipelineStatusCB& seek_cb, 108 const PipelineStatusCB& seek_cb,
109 const BufferingStateCB& buffering_state_cb) { 109 const BufferingStateCB& buffering_state_cb,
110 const SetDecryptorReadyCB& set_decryptor_ready_cb) {
110 base::AutoLock auto_lock(lock_); 111 base::AutoLock auto_lock(lock_);
111 CHECK(!running_) << "Media pipeline is already running"; 112 CHECK(!running_) << "Media pipeline is already running";
112 DCHECK(!buffering_state_cb.is_null()); 113 DCHECK(!buffering_state_cb.is_null());
113 114
114 running_ = true; 115 running_ = true;
115 message_loop_->PostTask(FROM_HERE, base::Bind( 116 message_loop_->PostTask(FROM_HERE, base::Bind(
116 &Pipeline::StartTask, this, base::Passed(&collection), 117 &Pipeline::StartTask, this, base::Passed(&collection),
117 ended_cb, error_cb, seek_cb, buffering_state_cb)); 118 ended_cb, error_cb, seek_cb, buffering_state_cb, set_decryptor_ready_cb));
118 } 119 }
119 120
120 void Pipeline::Stop(const base::Closure& stop_cb) { 121 void Pipeline::Stop(const base::Closure& stop_cb) {
121 base::AutoLock auto_lock(lock_); 122 base::AutoLock auto_lock(lock_);
122 message_loop_->PostTask(FROM_HERE, base::Bind( 123 message_loop_->PostTask(FROM_HERE, base::Bind(
123 &Pipeline::StopTask, this, stop_cb)); 124 &Pipeline::StopTask, this, stop_cb));
124 } 125 }
125 126
126 void Pipeline::Seek(TimeDelta time, const PipelineStatusCB& seek_cb) { 127 void Pipeline::Seek(TimeDelta time, const PipelineStatusCB& seek_cb) {
127 base::AutoLock auto_lock(lock_); 128 base::AutoLock auto_lock(lock_);
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 statistics_.audio_bytes_decoded += stats.audio_bytes_decoded; 691 statistics_.audio_bytes_decoded += stats.audio_bytes_decoded;
691 statistics_.video_bytes_decoded += stats.video_bytes_decoded; 692 statistics_.video_bytes_decoded += stats.video_bytes_decoded;
692 statistics_.video_frames_decoded += stats.video_frames_decoded; 693 statistics_.video_frames_decoded += stats.video_frames_decoded;
693 statistics_.video_frames_dropped += stats.video_frames_dropped; 694 statistics_.video_frames_dropped += stats.video_frames_dropped;
694 } 695 }
695 696
696 void Pipeline::StartTask(scoped_ptr<FilterCollection> filter_collection, 697 void Pipeline::StartTask(scoped_ptr<FilterCollection> filter_collection,
697 const PipelineStatusCB& ended_cb, 698 const PipelineStatusCB& ended_cb,
698 const PipelineStatusCB& error_cb, 699 const PipelineStatusCB& error_cb,
699 const PipelineStatusCB& seek_cb, 700 const PipelineStatusCB& seek_cb,
700 const BufferingStateCB& buffering_state_cb) { 701 const BufferingStateCB& buffering_state_cb,
702 const SetDecryptorReadyCB& set_decryptor_ready_cb) {
701 DCHECK(message_loop_->BelongsToCurrentThread()); 703 DCHECK(message_loop_->BelongsToCurrentThread());
702 CHECK_EQ(kCreated, state_) 704 CHECK_EQ(kCreated, state_)
703 << "Media pipeline cannot be started more than once"; 705 << "Media pipeline cannot be started more than once";
704 706
705 filter_collection_ = filter_collection.Pass(); 707 filter_collection_ = filter_collection.Pass();
706 ended_cb_ = ended_cb; 708 ended_cb_ = ended_cb;
707 error_cb_ = error_cb; 709 error_cb_ = error_cb;
708 seek_cb_ = seek_cb; 710 seek_cb_ = seek_cb;
709 buffering_state_cb_ = buffering_state_cb; 711 buffering_state_cb_ = buffering_state_cb;
712 set_decryptor_ready_cb_ = set_decryptor_ready_cb;
710 713
711 StateTransitionTask(PIPELINE_OK); 714 StateTransitionTask(PIPELINE_OK);
712 } 715 }
713 716
714 void Pipeline::StopTask(const base::Closure& stop_cb) { 717 void Pipeline::StopTask(const base::Closure& stop_cb) {
715 DCHECK(message_loop_->BelongsToCurrentThread()); 718 DCHECK(message_loop_->BelongsToCurrentThread());
716 DCHECK(stop_cb_.is_null()); 719 DCHECK(stop_cb_.is_null());
717 720
718 if (state_ == kStopped) { 721 if (state_ == kStopped) {
719 stop_cb.Run(); 722 stop_cb.Run();
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 DCHECK(message_loop_->BelongsToCurrentThread()); 885 DCHECK(message_loop_->BelongsToCurrentThread());
883 886
884 scoped_refptr<DemuxerStream> stream = 887 scoped_refptr<DemuxerStream> stream =
885 demuxer_->GetStream(DemuxerStream::AUDIO); 888 demuxer_->GetStream(DemuxerStream::AUDIO);
886 DCHECK(stream); 889 DCHECK(stream);
887 890
888 filter_collection_->SelectAudioRenderer(&audio_renderer_); 891 filter_collection_->SelectAudioRenderer(&audio_renderer_);
889 audio_renderer_->Initialize( 892 audio_renderer_->Initialize(
890 stream, 893 stream,
891 *filter_collection_->GetAudioDecoders(), 894 *filter_collection_->GetAudioDecoders(),
895 set_decryptor_ready_cb_,
892 done_cb, 896 done_cb,
893 base::Bind(&Pipeline::OnUpdateStatistics, this), 897 base::Bind(&Pipeline::OnUpdateStatistics, this),
894 base::Bind(&Pipeline::OnAudioUnderflow, this), 898 base::Bind(&Pipeline::OnAudioUnderflow, this),
895 base::Bind(&Pipeline::OnAudioTimeUpdate, this), 899 base::Bind(&Pipeline::OnAudioTimeUpdate, this),
896 base::Bind(&Pipeline::OnAudioRendererEnded, this), 900 base::Bind(&Pipeline::OnAudioRendererEnded, this),
897 base::Bind(&Pipeline::OnAudioDisabled, this), 901 base::Bind(&Pipeline::OnAudioDisabled, this),
898 base::Bind(&Pipeline::SetError, this)); 902 base::Bind(&Pipeline::SetError, this));
899 filter_collection_->GetAudioDecoders()->clear(); 903 filter_collection_->GetAudioDecoders()->clear();
900 } 904 }
901 905
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
945 void Pipeline::StartClockIfWaitingForTimeUpdate_Locked() { 949 void Pipeline::StartClockIfWaitingForTimeUpdate_Locked() {
946 lock_.AssertAcquired(); 950 lock_.AssertAcquired();
947 if (!waiting_for_clock_update_) 951 if (!waiting_for_clock_update_)
948 return; 952 return;
949 953
950 waiting_for_clock_update_ = false; 954 waiting_for_clock_update_ = false;
951 clock_->Play(); 955 clock_->Play();
952 } 956 }
953 957
954 } // namespace media 958 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698