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

Side by Side Diff: webkit/media/webmediaplayer_impl.cc

Issue 9195001: Remove --simple-data-source and convert WebMediaPlayerImpl::Initialize() to a void function. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src
Patch Set: Created 8 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 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 "webkit/media/webmediaplayer_impl.h" 5 #include "webkit/media/webmediaplayer_impl.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 is_accelerated_compositing_active_(false), 125 is_accelerated_compositing_active_(false),
126 incremented_externally_allocated_memory_(false), 126 incremented_externally_allocated_memory_(false),
127 audio_source_provider_(audio_source_provider) { 127 audio_source_provider_(audio_source_provider) {
128 // Saves the current message loop. 128 // Saves the current message loop.
129 DCHECK(!main_loop_); 129 DCHECK(!main_loop_);
130 main_loop_ = MessageLoop::current(); 130 main_loop_ = MessageLoop::current();
131 media_log_->AddEvent( 131 media_log_->AddEvent(
132 media_log_->CreateEvent(media::MediaLogEvent::WEBMEDIAPLAYER_CREATED)); 132 media_log_->CreateEvent(media::MediaLogEvent::WEBMEDIAPLAYER_CREATED));
133 } 133 }
134 134
135 bool WebMediaPlayerImpl::Initialize( 135 void WebMediaPlayerImpl::Initialize(WebKit::WebFrame* frame) {
136 WebKit::WebFrame* frame,
137 bool use_simple_data_source) {
138 DCHECK_EQ(main_loop_, MessageLoop::current()); 136 DCHECK_EQ(main_loop_, MessageLoop::current());
139 MessageLoop* pipeline_message_loop = 137 MessageLoop* pipeline_message_loop =
140 message_loop_factory_->GetMessageLoop("PipelineThread"); 138 message_loop_factory_->GetMessageLoop("PipelineThread");
141 if (!pipeline_message_loop) { 139 CHECK(pipeline_message_loop) << "Failed to create a new thread";
142 NOTREACHED() << "Could not start PipelineThread";
143 return false;
144 }
145 140
146 // Let V8 know we started new thread if we did not did it yet. 141 // Let V8 know we started new thread if we did not did it yet.
147 // Made separate task to avoid deletion of player currently being created. 142 // Made separate task to avoid deletion of player currently being created.
148 // Also, delaying GC until after player starts gets rid of starting lag -- 143 // Also, delaying GC until after player starts gets rid of starting lag --
149 // collection happens in parallel with playing. 144 // collection happens in parallel with playing.
150 // TODO(enal): remove when we get rid of per-audio-stream thread. 145 // TODO(enal): remove when we get rid of per-audio-stream thread.
151 if (!incremented_externally_allocated_memory_) { 146 if (!incremented_externally_allocated_memory_) {
152 MessageLoop::current()->PostTask( 147 MessageLoop::current()->PostTask(
153 FROM_HERE, 148 FROM_HERE,
154 base::Bind(&WebMediaPlayerImpl::IncrementExternallyAllocatedMemory, 149 base::Bind(&WebMediaPlayerImpl::IncrementExternallyAllocatedMemory,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 proxy_->GetBuildObserver())); 183 proxy_->GetBuildObserver()));
189 184
190 // A sophisticated data source that does memory caching. 185 // A sophisticated data source that does memory caching.
191 scoped_ptr<media::DataSourceFactory> buffered_data_source_factory( 186 scoped_ptr<media::DataSourceFactory> buffered_data_source_factory(
192 BufferedDataSource::CreateFactory(MessageLoop::current(), frame, 187 BufferedDataSource::CreateFactory(MessageLoop::current(), frame,
193 media_log_, 188 media_log_,
194 proxy_->GetBuildObserver())); 189 proxy_->GetBuildObserver()));
195 190
196 scoped_ptr<media::CompositeDataSourceFactory> data_source_factory( 191 scoped_ptr<media::CompositeDataSourceFactory> data_source_factory(
197 new media::CompositeDataSourceFactory()); 192 new media::CompositeDataSourceFactory());
198 193 data_source_factory->AddFactory(buffered_data_source_factory.Pass());
199 if (use_simple_data_source) { 194 data_source_factory->AddFactory(simple_data_source_factory.Pass());
200 data_source_factory->AddFactory(simple_data_source_factory.Pass());
201 data_source_factory->AddFactory(buffered_data_source_factory.Pass());
202 } else {
203 data_source_factory->AddFactory(buffered_data_source_factory.Pass());
204 data_source_factory->AddFactory(simple_data_source_factory.Pass());
205 }
206 195
207 scoped_ptr<media::DemuxerFactory> demuxer_factory( 196 scoped_ptr<media::DemuxerFactory> demuxer_factory(
208 // TODO(fischman): replace the extra scoped_ptr+release() with Pass() when 197 // TODO(fischman): replace the extra scoped_ptr+release() with Pass() when
209 // http://crbug.com/109026 is fixed. 198 // http://crbug.com/109026 is fixed.
210 new media::FFmpegDemuxerFactory(scoped_ptr<media::DataSourceFactory>( 199 new media::FFmpegDemuxerFactory(scoped_ptr<media::DataSourceFactory>(
211 data_source_factory.release()), pipeline_message_loop)); 200 data_source_factory.release()), pipeline_message_loop));
212 201
213 std::string source_url = GetClient()->sourceURL().spec(); 202 std::string source_url = GetClient()->sourceURL().spec();
214 203
215 if (!source_url.empty()) { 204 if (!source_url.empty()) {
216 demuxer_factory.reset( 205 demuxer_factory.reset(
217 new media::ChunkDemuxerFactory(source_url, 206 new media::ChunkDemuxerFactory(source_url,
218 demuxer_factory.Pass(), 207 demuxer_factory.Pass(),
219 proxy_)); 208 proxy_));
220 } 209 }
221 filter_collection_->SetDemuxerFactory(demuxer_factory.Pass()); 210 filter_collection_->SetDemuxerFactory(demuxer_factory.Pass());
222 211
223 // Add in the default filter factories. 212 // Add in the default filter factories.
224 filter_collection_->AddAudioDecoder(new media::FFmpegAudioDecoder( 213 filter_collection_->AddAudioDecoder(new media::FFmpegAudioDecoder(
225 message_loop_factory_->GetMessageLoop("AudioDecoderThread"))); 214 message_loop_factory_->GetMessageLoop("AudioDecoderThread")));
226 filter_collection_->AddVideoDecoder(new media::FFmpegVideoDecoder( 215 filter_collection_->AddVideoDecoder(new media::FFmpegVideoDecoder(
227 message_loop_factory_->GetMessageLoop("VideoDecoderThread"))); 216 message_loop_factory_->GetMessageLoop("VideoDecoderThread")));
228 filter_collection_->AddAudioRenderer(new media::NullAudioRenderer()); 217 filter_collection_->AddAudioRenderer(new media::NullAudioRenderer());
229
230 return true;
231 } 218 }
232 219
233 WebMediaPlayerImpl::~WebMediaPlayerImpl() { 220 WebMediaPlayerImpl::~WebMediaPlayerImpl() {
234 DCHECK_EQ(main_loop_, MessageLoop::current()); 221 DCHECK_EQ(main_loop_, MessageLoop::current());
235 Destroy(); 222 Destroy();
236 media_log_->AddEvent( 223 media_log_->AddEvent(
237 media_log_->CreateEvent(media::MediaLogEvent::WEBMEDIAPLAYER_DESTROYED)); 224 media_log_->CreateEvent(media::MediaLogEvent::WEBMEDIAPLAYER_DESTROYED));
238 225
239 if (delegate_) 226 if (delegate_)
240 delegate_->PlayerGone(this); 227 delegate_->PlayerGone(this);
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 return audio_source_provider_; 931 return audio_source_provider_;
945 } 932 }
946 933
947 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() { 934 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() {
948 DCHECK_EQ(main_loop_, MessageLoop::current()); 935 DCHECK_EQ(main_loop_, MessageLoop::current());
949 incremented_externally_allocated_memory_ = true; 936 incremented_externally_allocated_memory_ = true;
950 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory); 937 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory);
951 } 938 }
952 939
953 } // namespace webkit_media 940 } // namespace webkit_media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698