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

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

Issue 7203002: Adding ChunkDemuxer implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address CR comments Created 9 years, 6 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
« media/webm/webm_parser.cc ('K') | « webkit/glue/webmediaplayer_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/glue/webmediaplayer_impl.h" 5 #include "webkit/glue/webmediaplayer_impl.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 new media::CompositeDataSourceFactory()); 333 new media::CompositeDataSourceFactory());
334 334
335 if (use_simple_data_source) { 335 if (use_simple_data_source) {
336 data_source_factory->AddFactory(simple_data_source_factory.release()); 336 data_source_factory->AddFactory(simple_data_source_factory.release());
337 data_source_factory->AddFactory(buffered_data_source_factory.release()); 337 data_source_factory->AddFactory(buffered_data_source_factory.release());
338 } else { 338 } else {
339 data_source_factory->AddFactory(buffered_data_source_factory.release()); 339 data_source_factory->AddFactory(buffered_data_source_factory.release());
340 data_source_factory->AddFactory(simple_data_source_factory.release()); 340 data_source_factory->AddFactory(simple_data_source_factory.release());
341 } 341 }
342 342
343 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableAdaptive)) {
344 chunk_demuxer_factory_.reset(new media::ChunkDemuxerFactory(
345 data_source_factory->Clone()));
346 }
347
343 scoped_ptr<media::DemuxerFactory> demuxer_factory( 348 scoped_ptr<media::DemuxerFactory> demuxer_factory(
344 new media::FFmpegDemuxerFactory(data_source_factory.release(), 349 new media::FFmpegDemuxerFactory(data_source_factory.release(),
345 pipeline_message_loop)); 350 pipeline_message_loop));
346 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableAdaptive)) { 351 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableAdaptive)) {
347 demuxer_factory.reset(new media::AdaptiveDemuxerFactory( 352 demuxer_factory.reset(new media::AdaptiveDemuxerFactory(
348 demuxer_factory.release())); 353 demuxer_factory.release()));
349 } 354 }
350 filter_collection_->SetDemuxerFactory(demuxer_factory.release()); 355 filter_collection_->SetDemuxerFactory(demuxer_factory.release());
351 356
352 // Add in the default filter factories. 357 // Add in the default filter factories.
(...skipping 24 matching lines...) Expand all
377 // Remove the default decoder 382 // Remove the default decoder
378 scoped_refptr<media::VideoDecoder> old_videodecoder; 383 scoped_refptr<media::VideoDecoder> old_videodecoder;
379 filter_collection_->SelectVideoDecoder(&old_videodecoder); 384 filter_collection_->SelectVideoDecoder(&old_videodecoder);
380 media::RTCVideoDecoder* rtc_video_decoder = 385 media::RTCVideoDecoder* rtc_video_decoder =
381 new media::RTCVideoDecoder( 386 new media::RTCVideoDecoder(
382 message_loop_factory_->GetMessageLoop("VideoDecoderThread"), 387 message_loop_factory_->GetMessageLoop("VideoDecoderThread"),
383 url.spec()); 388 url.spec());
384 filter_collection_->AddVideoDecoder(rtc_video_decoder); 389 filter_collection_->AddVideoDecoder(rtc_video_decoder);
385 } 390 }
386 391
392 if (chunk_demuxer_factory_.get() &&
393 chunk_demuxer_factory_->IsUrlSupported(url.spec())) {
394 media_data_sink_.reset(chunk_demuxer_factory_->CreateMediaDataSink());
395 filter_collection_->SetDemuxerFactory(chunk_demuxer_factory_.release());
396 }
397
387 // Handle any volume changes that occured before load(). 398 // Handle any volume changes that occured before load().
388 setVolume(GetClient()->volume()); 399 setVolume(GetClient()->volume());
389 // Get the preload value. 400 // Get the preload value.
390 setPreload(GetClient()->preload()); 401 setPreload(GetClient()->preload());
391 402
392 // Initialize the pipeline. 403 // Initialize the pipeline.
393 SetNetworkState(WebKit::WebMediaPlayer::Loading); 404 SetNetworkState(WebKit::WebMediaPlayer::Loading);
394 SetReadyState(WebKit::WebMediaPlayer::HaveNothing); 405 SetReadyState(WebKit::WebMediaPlayer::HaveNothing);
395 pipeline_->Start( 406 pipeline_->Start(
396 filter_collection_.release(), 407 filter_collection_.release(),
(...skipping 14 matching lines...) Expand all
411 } 422 }
412 423
413 void WebMediaPlayerImpl::pause() { 424 void WebMediaPlayerImpl::pause() {
414 DCHECK(MessageLoop::current() == main_loop_); 425 DCHECK(MessageLoop::current() == main_loop_);
415 426
416 paused_ = true; 427 paused_ = true;
417 pipeline_->SetPlaybackRate(0.0f); 428 pipeline_->SetPlaybackRate(0.0f);
418 paused_time_ = pipeline_->GetCurrentTime(); 429 paused_time_ = pipeline_->GetCurrentTime();
419 } 430 }
420 431
432 bool WebMediaPlayerImpl::addData(const unsigned char* data, unsigned length) {
scherkus (not reviewing) 2011/06/23 18:50:18 crazy naming nit we can decide on later: appendDat
acolwell GONE FROM CHROMIUM 2011/06/23 22:42:17 This will probably change to appendData() once I s
433 DCHECK(MessageLoop::current() == main_loop_);
434
435 if (!media_data_sink_.get())
436 return false;
437
438 return media_data_sink_->AddData(data, length);
439 }
440
421 bool WebMediaPlayerImpl::supportsFullscreen() const { 441 bool WebMediaPlayerImpl::supportsFullscreen() const {
422 DCHECK(MessageLoop::current() == main_loop_); 442 DCHECK(MessageLoop::current() == main_loop_);
423 return true; 443 return true;
424 } 444 }
425 445
426 bool WebMediaPlayerImpl::supportsSave() const { 446 bool WebMediaPlayerImpl::supportsSave() const {
427 DCHECK(MessageLoop::current() == main_loop_); 447 DCHECK(MessageLoop::current() == main_loop_);
428 return true; 448 return true;
429 } 449 }
430 450
(...skipping 14 matching lines...) Expand all
445 465
446 base::TimeDelta seek_time = ConvertSecondsToTimestamp(seconds); 466 base::TimeDelta seek_time = ConvertSecondsToTimestamp(seconds);
447 467
448 // Update our paused time. 468 // Update our paused time.
449 if (paused_) { 469 if (paused_) {
450 paused_time_ = seek_time; 470 paused_time_ = seek_time;
451 } 471 }
452 472
453 seeking_ = true; 473 seeking_ = true;
454 474
475 if (media_data_sink_.get())
476 media_data_sink_->Flush();
477
455 // Kick off the asynchronous seek! 478 // Kick off the asynchronous seek!
456 pipeline_->Seek( 479 pipeline_->Seek(
457 seek_time, 480 seek_time,
458 NewCallback(proxy_.get(), 481 NewCallback(proxy_.get(),
459 &WebMediaPlayerImpl::Proxy::PipelineSeekCallback)); 482 &WebMediaPlayerImpl::Proxy::PipelineSeekCallback));
460 } 483 }
461 484
462 void WebMediaPlayerImpl::setEndTime(float seconds) { 485 void WebMediaPlayerImpl::setEndTime(float seconds) {
463 DCHECK(MessageLoop::current() == main_loop_); 486 DCHECK(MessageLoop::current() == main_loop_);
464 487
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 DCHECK(MessageLoop::current() == main_loop_); 583 DCHECK(MessageLoop::current() == main_loop_);
561 584
562 base::TimeDelta duration = pipeline_->GetMediaDuration(); 585 base::TimeDelta duration = pipeline_->GetMediaDuration();
563 if (duration.InMicroseconds() == media::Limits::kMaxTimeInMicroseconds) 586 if (duration.InMicroseconds() == media::Limits::kMaxTimeInMicroseconds)
564 return std::numeric_limits<float>::infinity(); 587 return std::numeric_limits<float>::infinity();
565 return static_cast<float>(duration.InSecondsF()); 588 return static_cast<float>(duration.InSecondsF());
566 } 589 }
567 590
568 float WebMediaPlayerImpl::currentTime() const { 591 float WebMediaPlayerImpl::currentTime() const {
569 DCHECK(MessageLoop::current() == main_loop_); 592 DCHECK(MessageLoop::current() == main_loop_);
570
571 if (paused_) { 593 if (paused_) {
572 return static_cast<float>(paused_time_.InSecondsF()); 594 return static_cast<float>(paused_time_.InSecondsF());
573 } 595 }
574 return static_cast<float>(pipeline_->GetCurrentTime().InSecondsF()); 596 return static_cast<float>(pipeline_->GetCurrentTime().InSecondsF());
575 } 597 }
576 598
577 int WebMediaPlayerImpl::dataRate() const { 599 int WebMediaPlayerImpl::dataRate() const {
578 DCHECK(MessageLoop::current() == main_loop_); 600 DCHECK(MessageLoop::current() == main_loop_);
579 601
580 // TODO(hclam): Add this method call if pipeline has it in the interface. 602 // TODO(hclam): Add this method call if pipeline has it in the interface.
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 } 923 }
902 924
903 void WebMediaPlayerImpl::Destroy() { 925 void WebMediaPlayerImpl::Destroy() {
904 DCHECK(MessageLoop::current() == main_loop_); 926 DCHECK(MessageLoop::current() == main_loop_);
905 927
906 // Tell the data source to abort any pending reads so that the pipeline is 928 // Tell the data source to abort any pending reads so that the pipeline is
907 // not blocked when issuing stop commands to the other filters. 929 // not blocked when issuing stop commands to the other filters.
908 if (proxy_) 930 if (proxy_)
909 proxy_->AbortDataSources(); 931 proxy_->AbortDataSources();
910 932
933 if (media_data_sink_.get())
934 media_data_sink_->Shutdown();
935
911 // Make sure to kill the pipeline so there's no more media threads running. 936 // Make sure to kill the pipeline so there's no more media threads running.
912 // Note: stopping the pipeline might block for a long time. 937 // Note: stopping the pipeline might block for a long time.
913 if (pipeline_) { 938 if (pipeline_) {
914 media::PipelineStatusNotification note; 939 media::PipelineStatusNotification note;
915 pipeline_->Stop(note.Callback()); 940 pipeline_->Stop(note.Callback());
916 note.Wait(); 941 note.Wait();
917 } 942 }
918 943
919 message_loop_factory_.reset(); 944 message_loop_factory_.reset();
920 945
921 // And then detach the proxy, it may live on the render thread for a little 946 // And then detach the proxy, it may live on the render thread for a little
922 // longer until all the tasks are finished. 947 // longer until all the tasks are finished.
923 if (proxy_) { 948 if (proxy_) {
924 proxy_->Detach(); 949 proxy_->Detach();
925 proxy_ = NULL; 950 proxy_ = NULL;
926 } 951 }
927 } 952 }
928 953
929 WebKit::WebMediaPlayerClient* WebMediaPlayerImpl::GetClient() { 954 WebKit::WebMediaPlayerClient* WebMediaPlayerImpl::GetClient() {
930 DCHECK(MessageLoop::current() == main_loop_); 955 DCHECK(MessageLoop::current() == main_loop_);
931 DCHECK(client_); 956 DCHECK(client_);
932 return client_; 957 return client_;
933 } 958 }
934 959
935 } // namespace webkit_glue 960 } // namespace webkit_glue
OLDNEW
« media/webm/webm_parser.cc ('K') | « webkit/glue/webmediaplayer_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698