OLD | NEW |
---|---|
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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
95 << "Pipeline must be destroyed on same thread that created it"; | 95 << "Pipeline must be destroyed on same thread that created it"; |
96 #endif | 96 #endif |
97 DCHECK(!running_) << "Stop() must complete before destroying object"; | 97 DCHECK(!running_) << "Stop() must complete before destroying object"; |
98 DCHECK(stop_cb_.is_null()); | 98 DCHECK(stop_cb_.is_null()); |
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( |
106 const PipelineStatusCB& ended_cb, | 106 scoped_ptr<FilterCollection> collection, |
107 const PipelineStatusCB& error_cb, | 107 const PipelineStatusCB& ended_cb, |
108 const PipelineStatusCB& seek_cb, | 108 const PipelineStatusCB& error_cb, |
109 const BufferingStateCB& buffering_state_cb) { | 109 const PipelineStatusCB& seek_cb, |
110 const BufferingStateCB& buffering_state_cb, | |
111 const RequestDecryptorNotificationCB& request_decryptor_notification_cb) { | |
110 base::AutoLock auto_lock(lock_); | 112 base::AutoLock auto_lock(lock_); |
111 CHECK(!running_) << "Media pipeline is already running"; | 113 CHECK(!running_) << "Media pipeline is already running"; |
112 DCHECK(!buffering_state_cb.is_null()); | 114 DCHECK(!buffering_state_cb.is_null()); |
113 | 115 |
114 running_ = true; | 116 running_ = true; |
115 message_loop_->PostTask(FROM_HERE, base::Bind( | 117 message_loop_->PostTask(FROM_HERE, base::Bind( |
116 &Pipeline::StartTask, this, base::Passed(&collection), | 118 &Pipeline::StartTask, this, base::Passed(&collection), |
117 ended_cb, error_cb, seek_cb, buffering_state_cb)); | 119 ended_cb, error_cb, seek_cb, buffering_state_cb, |
120 request_decryptor_notification_cb)); | |
118 } | 121 } |
119 | 122 |
120 void Pipeline::Stop(const base::Closure& stop_cb) { | 123 void Pipeline::Stop(const base::Closure& stop_cb) { |
121 base::AutoLock auto_lock(lock_); | 124 base::AutoLock auto_lock(lock_); |
122 message_loop_->PostTask(FROM_HERE, base::Bind( | 125 message_loop_->PostTask(FROM_HERE, base::Bind( |
123 &Pipeline::StopTask, this, stop_cb)); | 126 &Pipeline::StopTask, this, stop_cb)); |
124 } | 127 } |
125 | 128 |
126 void Pipeline::Seek(TimeDelta time, const PipelineStatusCB& seek_cb) { | 129 void Pipeline::Seek(TimeDelta time, const PipelineStatusCB& seek_cb) { |
127 base::AutoLock auto_lock(lock_); | 130 base::AutoLock auto_lock(lock_); |
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
686 | 689 |
687 // Called from any thread. | 690 // Called from any thread. |
688 void Pipeline::OnUpdateStatistics(const PipelineStatistics& stats) { | 691 void Pipeline::OnUpdateStatistics(const PipelineStatistics& stats) { |
689 base::AutoLock auto_lock(lock_); | 692 base::AutoLock auto_lock(lock_); |
690 statistics_.audio_bytes_decoded += stats.audio_bytes_decoded; | 693 statistics_.audio_bytes_decoded += stats.audio_bytes_decoded; |
691 statistics_.video_bytes_decoded += stats.video_bytes_decoded; | 694 statistics_.video_bytes_decoded += stats.video_bytes_decoded; |
692 statistics_.video_frames_decoded += stats.video_frames_decoded; | 695 statistics_.video_frames_decoded += stats.video_frames_decoded; |
693 statistics_.video_frames_dropped += stats.video_frames_dropped; | 696 statistics_.video_frames_dropped += stats.video_frames_dropped; |
694 } | 697 } |
695 | 698 |
696 void Pipeline::StartTask(scoped_ptr<FilterCollection> filter_collection, | 699 void Pipeline::StartTask( |
697 const PipelineStatusCB& ended_cb, | 700 scoped_ptr<FilterCollection> filter_collection, |
698 const PipelineStatusCB& error_cb, | 701 const PipelineStatusCB& ended_cb, |
699 const PipelineStatusCB& seek_cb, | 702 const PipelineStatusCB& error_cb, |
700 const BufferingStateCB& buffering_state_cb) { | 703 const PipelineStatusCB& seek_cb, |
704 const BufferingStateCB& buffering_state_cb, | |
705 const RequestDecryptorNotificationCB& request_decryptor_notification_cb) { | |
701 DCHECK(message_loop_->BelongsToCurrentThread()); | 706 DCHECK(message_loop_->BelongsToCurrentThread()); |
702 CHECK_EQ(kCreated, state_) | 707 CHECK_EQ(kCreated, state_) |
703 << "Media pipeline cannot be started more than once"; | 708 << "Media pipeline cannot be started more than once"; |
704 | 709 |
705 filter_collection_ = filter_collection.Pass(); | 710 filter_collection_ = filter_collection.Pass(); |
706 ended_cb_ = ended_cb; | 711 ended_cb_ = ended_cb; |
707 error_cb_ = error_cb; | 712 error_cb_ = error_cb; |
708 seek_cb_ = seek_cb; | 713 seek_cb_ = seek_cb; |
709 buffering_state_cb_ = buffering_state_cb; | 714 buffering_state_cb_ = buffering_state_cb; |
715 request_decryptor_notification_cb_ = request_decryptor_notification_cb; | |
710 | 716 |
711 StateTransitionTask(PIPELINE_OK); | 717 StateTransitionTask(PIPELINE_OK); |
712 } | 718 } |
713 | 719 |
714 void Pipeline::StopTask(const base::Closure& stop_cb) { | 720 void Pipeline::StopTask(const base::Closure& stop_cb) { |
715 DCHECK(message_loop_->BelongsToCurrentThread()); | 721 DCHECK(message_loop_->BelongsToCurrentThread()); |
716 DCHECK(stop_cb_.is_null()); | 722 DCHECK(stop_cb_.is_null()); |
717 | 723 |
718 if (state_ == kStopped) { | 724 if (state_ == kStopped) { |
719 stop_cb.Run(); | 725 stop_cb.Run(); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
882 DCHECK(message_loop_->BelongsToCurrentThread()); | 888 DCHECK(message_loop_->BelongsToCurrentThread()); |
883 | 889 |
884 scoped_refptr<DemuxerStream> stream = | 890 scoped_refptr<DemuxerStream> stream = |
885 demuxer_->GetStream(DemuxerStream::AUDIO); | 891 demuxer_->GetStream(DemuxerStream::AUDIO); |
886 DCHECK(stream); | 892 DCHECK(stream); |
887 | 893 |
888 filter_collection_->SelectAudioRenderer(&audio_renderer_); | 894 filter_collection_->SelectAudioRenderer(&audio_renderer_); |
889 audio_renderer_->Initialize( | 895 audio_renderer_->Initialize( |
890 stream, | 896 stream, |
891 *filter_collection_->GetAudioDecoders(), | 897 *filter_collection_->GetAudioDecoders(), |
898 request_decryptor_notification_cb_, | |
scherkus (not reviewing)
2012/12/11 20:52:15
why does this have to go in via Initialize() versu
xhwang
2012/12/12 23:43:28
That's actually my first attempt. It didn't work w
| |
892 done_cb, | 899 done_cb, |
893 base::Bind(&Pipeline::OnUpdateStatistics, this), | 900 base::Bind(&Pipeline::OnUpdateStatistics, this), |
894 base::Bind(&Pipeline::OnAudioUnderflow, this), | 901 base::Bind(&Pipeline::OnAudioUnderflow, this), |
895 base::Bind(&Pipeline::OnAudioTimeUpdate, this), | 902 base::Bind(&Pipeline::OnAudioTimeUpdate, this), |
896 base::Bind(&Pipeline::OnAudioRendererEnded, this), | 903 base::Bind(&Pipeline::OnAudioRendererEnded, this), |
897 base::Bind(&Pipeline::OnAudioDisabled, this), | 904 base::Bind(&Pipeline::OnAudioDisabled, this), |
898 base::Bind(&Pipeline::SetError, this)); | 905 base::Bind(&Pipeline::SetError, this)); |
899 filter_collection_->GetAudioDecoders()->clear(); | 906 filter_collection_->GetAudioDecoders()->clear(); |
900 } | 907 } |
901 | 908 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
945 void Pipeline::StartClockIfWaitingForTimeUpdate_Locked() { | 952 void Pipeline::StartClockIfWaitingForTimeUpdate_Locked() { |
946 lock_.AssertAcquired(); | 953 lock_.AssertAcquired(); |
947 if (!waiting_for_clock_update_) | 954 if (!waiting_for_clock_update_) |
948 return; | 955 return; |
949 | 956 |
950 waiting_for_clock_update_ = false; | 957 waiting_for_clock_update_ = false; |
951 clock_->Play(); | 958 clock_->Play(); |
952 } | 959 } |
953 | 960 |
954 } // namespace media | 961 } // namespace media |
OLD | NEW |