Chromium Code Reviews| 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" |
| 11 #include "base/callback_helpers.h" | 11 #include "base/callback_helpers.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
| 15 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
| 16 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
| 17 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
| 18 #include "base/synchronization/condition_variable.h" | 18 #include "base/synchronization/condition_variable.h" |
| 19 #include "media/base/audio_decoder.h" | 19 #include "media/base/audio_decoder.h" |
| 20 #include "media/base/audio_renderer.h" | 20 #include "media/base/audio_renderer.h" |
| 21 #include "media/base/clock.h" | 21 #include "media/base/clock.h" |
| 22 #include "media/base/filter_collection.h" | 22 #include "media/base/filter_collection.h" |
| 23 #include "media/base/media_log.h" | 23 #include "media/base/media_log.h" |
| 24 #include "media/base/text_renderer.h" | |
| 24 #include "media/base/video_decoder.h" | 25 #include "media/base/video_decoder.h" |
| 25 #include "media/base/video_decoder_config.h" | 26 #include "media/base/video_decoder_config.h" |
| 26 #include "media/base/video_renderer.h" | 27 #include "media/base/video_renderer.h" |
| 27 | 28 |
| 28 using base::TimeDelta; | 29 using base::TimeDelta; |
| 29 | 30 |
| 30 namespace media { | 31 namespace media { |
| 31 | 32 |
| 32 Pipeline::Pipeline(const scoped_refptr<base::MessageLoopProxy>& message_loop, | 33 Pipeline::Pipeline(const scoped_refptr<base::MessageLoopProxy>& message_loop, |
| 33 MediaLog* media_log) | 34 MediaLog* media_log) |
| 34 : message_loop_(message_loop), | 35 : message_loop_(message_loop), |
| 35 media_log_(media_log), | 36 media_log_(media_log), |
| 36 running_(false), | 37 running_(false), |
| 37 did_loading_progress_(false), | 38 did_loading_progress_(false), |
| 38 total_bytes_(0), | 39 total_bytes_(0), |
| 39 natural_size_(0, 0), | 40 natural_size_(0, 0), |
| 40 volume_(1.0f), | 41 volume_(1.0f), |
| 41 playback_rate_(0.0f), | 42 playback_rate_(0.0f), |
| 42 clock_(new Clock(&default_tick_clock_)), | 43 clock_(new Clock(&default_tick_clock_)), |
| 43 waiting_for_clock_update_(false), | 44 waiting_for_clock_update_(false), |
| 44 status_(PIPELINE_OK), | 45 status_(PIPELINE_OK), |
| 45 has_audio_(false), | 46 has_audio_(false), |
| 46 has_video_(false), | 47 has_video_(false), |
| 47 state_(kCreated), | 48 state_(kCreated), |
| 48 audio_ended_(false), | 49 audio_ended_(false), |
| 49 video_ended_(false), | 50 video_ended_(false), |
| 51 text_ended_(false), | |
| 50 audio_disabled_(false), | 52 audio_disabled_(false), |
| 51 demuxer_(NULL), | 53 demuxer_(NULL), |
| 52 creation_time_(default_tick_clock_.NowTicks()) { | 54 creation_time_(default_tick_clock_.NowTicks()) { |
| 53 media_log_->AddEvent(media_log_->CreatePipelineStateChangedEvent(kCreated)); | 55 media_log_->AddEvent(media_log_->CreatePipelineStateChangedEvent(kCreated)); |
| 54 media_log_->AddEvent( | 56 media_log_->AddEvent( |
| 55 media_log_->CreateEvent(MediaLogEvent::PIPELINE_CREATED)); | 57 media_log_->CreateEvent(MediaLogEvent::PIPELINE_CREATED)); |
| 56 } | 58 } |
| 57 | 59 |
| 58 Pipeline::~Pipeline() { | 60 Pipeline::~Pipeline() { |
| 59 DCHECK(thread_checker_.CalledOnValidThread()) | 61 DCHECK(thread_checker_.CalledOnValidThread()) |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 286 break; | 288 break; |
| 287 } | 289 } |
| 288 NOTREACHED() << "State has no transition: " << state_; | 290 NOTREACHED() << "State has no transition: " << state_; |
| 289 return state_; | 291 return state_; |
| 290 } | 292 } |
| 291 | 293 |
| 292 void Pipeline::OnDemuxerError(PipelineStatus error) { | 294 void Pipeline::OnDemuxerError(PipelineStatus error) { |
| 293 SetError(error); | 295 SetError(error); |
| 294 } | 296 } |
| 295 | 297 |
| 298 void Pipeline::AddTextStream(DemuxerStream* text_stream, | |
| 299 const TextTrackConfig& config) { | |
| 300 message_loop_->PostTask(FROM_HERE, base::Bind( | |
| 301 &Pipeline::AddTextStreamTask, base::Unretained(this), | |
| 302 text_stream, config)); | |
| 303 } | |
| 304 | |
| 305 void Pipeline::RemoveTextStream(DemuxerStream* text_stream) { | |
| 306 #if 0 | |
|
acolwell GONE FROM CHROMIUM
2013/10/24 18:57:51
Remove #if
Matthew Heaney (Chromium)
2013/10/25 03:05:38
Done.
| |
| 307 DCHECK(message_loop_->BelongsToCurrentThread()); | |
| 308 if (text_renderer_) | |
| 309 text_renderer_->RemoveTextStream(text_stream); | |
| 310 #else | |
| 311 message_loop_->PostTask(FROM_HERE, base::Bind( | |
| 312 &Pipeline::RemoveTextStreamTask, base::Unretained(this), | |
| 313 text_stream)); | |
| 314 #endif | |
| 315 } | |
| 316 | |
| 296 void Pipeline::SetError(PipelineStatus error) { | 317 void Pipeline::SetError(PipelineStatus error) { |
| 297 DCHECK(IsRunning()); | 318 DCHECK(IsRunning()); |
| 298 DCHECK_NE(PIPELINE_OK, error); | 319 DCHECK_NE(PIPELINE_OK, error); |
| 299 VLOG(1) << "Media pipeline error: " << error; | 320 VLOG(1) << "Media pipeline error: " << error; |
| 300 | 321 |
| 301 message_loop_->PostTask(FROM_HERE, base::Bind( | 322 message_loop_->PostTask(FROM_HERE, base::Bind( |
| 302 &Pipeline::ErrorChangedTask, base::Unretained(this), error)); | 323 &Pipeline::ErrorChangedTask, base::Unretained(this), error)); |
| 303 | 324 |
| 304 media_log_->AddEvent(media_log_->CreatePipelineErrorEvent(error)); | 325 media_log_->AddEvent(media_log_->CreatePipelineErrorEvent(error)); |
| 305 } | 326 } |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 530 | 551 |
| 531 // Pause. | 552 // Pause. |
| 532 if (audio_renderer_) { | 553 if (audio_renderer_) { |
| 533 bound_fns.Push(base::Bind( | 554 bound_fns.Push(base::Bind( |
| 534 &AudioRenderer::Pause, base::Unretained(audio_renderer_.get()))); | 555 &AudioRenderer::Pause, base::Unretained(audio_renderer_.get()))); |
| 535 } | 556 } |
| 536 if (video_renderer_) { | 557 if (video_renderer_) { |
| 537 bound_fns.Push(base::Bind( | 558 bound_fns.Push(base::Bind( |
| 538 &VideoRenderer::Pause, base::Unretained(video_renderer_.get()))); | 559 &VideoRenderer::Pause, base::Unretained(video_renderer_.get()))); |
| 539 } | 560 } |
| 561 if (text_renderer_) { | |
| 562 bound_fns.Push(base::Bind( | |
| 563 &TextRenderer::Pause, base::Unretained(text_renderer_.get()))); | |
| 564 } | |
| 540 | 565 |
| 541 // Flush. | 566 // Flush. |
| 542 if (audio_renderer_) { | 567 if (audio_renderer_) { |
| 543 bound_fns.Push(base::Bind( | 568 bound_fns.Push(base::Bind( |
| 544 &AudioRenderer::Flush, base::Unretained(audio_renderer_.get()))); | 569 &AudioRenderer::Flush, base::Unretained(audio_renderer_.get()))); |
| 545 } | 570 } |
| 546 if (video_renderer_) { | 571 if (video_renderer_) { |
| 547 bound_fns.Push(base::Bind( | 572 bound_fns.Push(base::Bind( |
| 548 &VideoRenderer::Flush, base::Unretained(video_renderer_.get()))); | 573 &VideoRenderer::Flush, base::Unretained(video_renderer_.get()))); |
| 549 } | 574 } |
| 575 if (text_renderer_) { | |
| 576 bound_fns.Push(base::Bind( | |
| 577 &TextRenderer::Flush, base::Unretained(text_renderer_.get()))); | |
| 578 } | |
| 550 | 579 |
| 551 // Seek demuxer. | 580 // Seek demuxer. |
| 552 bound_fns.Push(base::Bind( | 581 bound_fns.Push(base::Bind( |
| 553 &Demuxer::Seek, base::Unretained(demuxer_), seek_timestamp)); | 582 &Demuxer::Seek, base::Unretained(demuxer_), seek_timestamp)); |
| 554 | 583 |
| 555 // Preroll renderers. | 584 // Preroll renderers. |
| 556 if (audio_renderer_) { | 585 if (audio_renderer_) { |
| 557 bound_fns.Push(base::Bind( | 586 bound_fns.Push(base::Bind( |
| 558 &AudioRenderer::Preroll, base::Unretained(audio_renderer_.get()), | 587 &AudioRenderer::Preroll, base::Unretained(audio_renderer_.get()), |
| 559 seek_timestamp)); | 588 seek_timestamp)); |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 579 if (audio_renderer_) { | 608 if (audio_renderer_) { |
| 580 bound_fns.Push(base::Bind( | 609 bound_fns.Push(base::Bind( |
| 581 &AudioRenderer::Play, base::Unretained(audio_renderer_.get()))); | 610 &AudioRenderer::Play, base::Unretained(audio_renderer_.get()))); |
| 582 } | 611 } |
| 583 | 612 |
| 584 if (video_renderer_) { | 613 if (video_renderer_) { |
| 585 bound_fns.Push(base::Bind( | 614 bound_fns.Push(base::Bind( |
| 586 &VideoRenderer::Play, base::Unretained(video_renderer_.get()))); | 615 &VideoRenderer::Play, base::Unretained(video_renderer_.get()))); |
| 587 } | 616 } |
| 588 | 617 |
| 618 if (text_renderer_) { | |
| 619 bound_fns.Push(base::Bind( | |
| 620 &TextRenderer::Play, base::Unretained(text_renderer_.get()))); | |
| 621 } | |
| 622 | |
| 589 pending_callbacks_ = SerialRunner::Run(bound_fns, done_cb); | 623 pending_callbacks_ = SerialRunner::Run(bound_fns, done_cb); |
| 590 } | 624 } |
| 591 | 625 |
| 592 void Pipeline::DoStop(const PipelineStatusCB& done_cb) { | 626 void Pipeline::DoStop(const PipelineStatusCB& done_cb) { |
| 593 DCHECK(message_loop_->BelongsToCurrentThread()); | 627 DCHECK(message_loop_->BelongsToCurrentThread()); |
| 594 DCHECK(!pending_callbacks_.get()); | 628 DCHECK(!pending_callbacks_.get()); |
| 595 SerialRunner::Queue bound_fns; | 629 SerialRunner::Queue bound_fns; |
| 596 | 630 |
| 597 if (demuxer_) { | 631 if (demuxer_) { |
| 598 bound_fns.Push(base::Bind( | 632 bound_fns.Push(base::Bind( |
| 599 &Demuxer::Stop, base::Unretained(demuxer_))); | 633 &Demuxer::Stop, base::Unretained(demuxer_))); |
| 600 } | 634 } |
| 601 | 635 |
| 602 if (audio_renderer_) { | 636 if (audio_renderer_) { |
| 603 bound_fns.Push(base::Bind( | 637 bound_fns.Push(base::Bind( |
| 604 &AudioRenderer::Stop, base::Unretained(audio_renderer_.get()))); | 638 &AudioRenderer::Stop, base::Unretained(audio_renderer_.get()))); |
| 605 } | 639 } |
| 606 | 640 |
| 607 if (video_renderer_) { | 641 if (video_renderer_) { |
| 608 bound_fns.Push(base::Bind( | 642 bound_fns.Push(base::Bind( |
| 609 &VideoRenderer::Stop, base::Unretained(video_renderer_.get()))); | 643 &VideoRenderer::Stop, base::Unretained(video_renderer_.get()))); |
| 610 } | 644 } |
| 611 | 645 |
| 646 if (text_renderer_) { | |
| 647 bound_fns.Push(base::Bind( | |
| 648 &TextRenderer::Stop, base::Unretained(text_renderer_.get()))); | |
| 649 } | |
| 650 | |
| 612 pending_callbacks_ = SerialRunner::Run(bound_fns, done_cb); | 651 pending_callbacks_ = SerialRunner::Run(bound_fns, done_cb); |
| 613 } | 652 } |
| 614 | 653 |
| 615 void Pipeline::OnStopCompleted(PipelineStatus status) { | 654 void Pipeline::OnStopCompleted(PipelineStatus status) { |
| 616 DCHECK(message_loop_->BelongsToCurrentThread()); | 655 DCHECK(message_loop_->BelongsToCurrentThread()); |
| 617 DCHECK_EQ(state_, kStopping); | 656 DCHECK_EQ(state_, kStopping); |
| 618 { | 657 { |
| 619 base::AutoLock l(lock_); | 658 base::AutoLock l(lock_); |
| 620 running_ = false; | 659 running_ = false; |
| 621 } | 660 } |
| 622 | 661 |
| 623 SetState(kStopped); | 662 SetState(kStopped); |
| 624 pending_callbacks_.reset(); | 663 pending_callbacks_.reset(); |
| 625 filter_collection_.reset(); | 664 filter_collection_.reset(); |
| 626 audio_renderer_.reset(); | 665 audio_renderer_.reset(); |
| 627 video_renderer_.reset(); | 666 video_renderer_.reset(); |
| 667 text_renderer_.reset(); | |
| 628 demuxer_ = NULL; | 668 demuxer_ = NULL; |
| 629 | 669 |
| 630 // If we stop during initialization/seeking we want to run |seek_cb_| | 670 // If we stop during initialization/seeking we want to run |seek_cb_| |
| 631 // followed by |stop_cb_| so we don't leave outstanding callbacks around. | 671 // followed by |stop_cb_| so we don't leave outstanding callbacks around. |
| 632 if (!seek_cb_.is_null()) { | 672 if (!seek_cb_.is_null()) { |
| 633 base::ResetAndReturn(&seek_cb_).Run(status_); | 673 base::ResetAndReturn(&seek_cb_).Run(status_); |
| 634 error_cb_.Reset(); | 674 error_cb_.Reset(); |
| 635 } | 675 } |
| 636 if (!stop_cb_.is_null()) { | 676 if (!stop_cb_.is_null()) { |
| 637 error_cb_.Reset(); | 677 error_cb_.Reset(); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 678 media_log_->AddEvent(media_log_->CreateEvent(MediaLogEvent::AUDIO_ENDED)); | 718 media_log_->AddEvent(media_log_->CreateEvent(MediaLogEvent::AUDIO_ENDED)); |
| 679 } | 719 } |
| 680 | 720 |
| 681 void Pipeline::OnVideoRendererEnded() { | 721 void Pipeline::OnVideoRendererEnded() { |
| 682 // Force post to process ended messages after current execution frame. | 722 // Force post to process ended messages after current execution frame. |
| 683 message_loop_->PostTask(FROM_HERE, base::Bind( | 723 message_loop_->PostTask(FROM_HERE, base::Bind( |
| 684 &Pipeline::DoVideoRendererEnded, base::Unretained(this))); | 724 &Pipeline::DoVideoRendererEnded, base::Unretained(this))); |
| 685 media_log_->AddEvent(media_log_->CreateEvent(MediaLogEvent::VIDEO_ENDED)); | 725 media_log_->AddEvent(media_log_->CreateEvent(MediaLogEvent::VIDEO_ENDED)); |
| 686 } | 726 } |
| 687 | 727 |
| 728 void Pipeline::OnTextRendererEnded() { | |
| 729 // Force post to process ended messages after current execution frame. | |
| 730 message_loop_->PostTask(FROM_HERE, base::Bind( | |
| 731 &Pipeline::DoTextRendererEnded, base::Unretained(this))); | |
| 732 media_log_->AddEvent(media_log_->CreateEvent(MediaLogEvent::TEXT_ENDED)); | |
| 733 } | |
| 734 | |
| 688 // Called from any thread. | 735 // Called from any thread. |
| 689 void Pipeline::OnUpdateStatistics(const PipelineStatistics& stats) { | 736 void Pipeline::OnUpdateStatistics(const PipelineStatistics& stats) { |
| 690 base::AutoLock auto_lock(lock_); | 737 base::AutoLock auto_lock(lock_); |
| 691 statistics_.audio_bytes_decoded += stats.audio_bytes_decoded; | 738 statistics_.audio_bytes_decoded += stats.audio_bytes_decoded; |
| 692 statistics_.video_bytes_decoded += stats.video_bytes_decoded; | 739 statistics_.video_bytes_decoded += stats.video_bytes_decoded; |
| 693 statistics_.video_frames_decoded += stats.video_frames_decoded; | 740 statistics_.video_frames_decoded += stats.video_frames_decoded; |
| 694 statistics_.video_frames_dropped += stats.video_frames_dropped; | 741 statistics_.video_frames_dropped += stats.video_frames_dropped; |
| 695 } | 742 } |
| 696 | 743 |
| 697 void Pipeline::StartTask(scoped_ptr<FilterCollection> filter_collection, | 744 void Pipeline::StartTask(scoped_ptr<FilterCollection> filter_collection, |
| 698 const base::Closure& ended_cb, | 745 const base::Closure& ended_cb, |
| 699 const PipelineStatusCB& error_cb, | 746 const PipelineStatusCB& error_cb, |
| 700 const PipelineStatusCB& seek_cb, | 747 const PipelineStatusCB& seek_cb, |
| 701 const BufferingStateCB& buffering_state_cb, | 748 const BufferingStateCB& buffering_state_cb, |
| 702 const base::Closure& duration_change_cb) { | 749 const base::Closure& duration_change_cb) { |
| 703 DCHECK(message_loop_->BelongsToCurrentThread()); | 750 DCHECK(message_loop_->BelongsToCurrentThread()); |
| 704 CHECK_EQ(kCreated, state_) | 751 CHECK_EQ(kCreated, state_) |
| 705 << "Media pipeline cannot be started more than once"; | 752 << "Media pipeline cannot be started more than once"; |
| 706 | 753 |
| 707 filter_collection_ = filter_collection.Pass(); | 754 filter_collection_ = filter_collection.Pass(); |
| 708 ended_cb_ = ended_cb; | 755 ended_cb_ = ended_cb; |
| 709 error_cb_ = error_cb; | 756 error_cb_ = error_cb; |
| 710 seek_cb_ = seek_cb; | 757 seek_cb_ = seek_cb; |
| 711 buffering_state_cb_ = buffering_state_cb; | 758 buffering_state_cb_ = buffering_state_cb; |
| 712 duration_change_cb_ = duration_change_cb; | 759 duration_change_cb_ = duration_change_cb; |
| 713 | 760 |
| 761 text_renderer_ = filter_collection_->GetTextRenderer(); | |
| 762 | |
| 763 if (text_renderer_) { | |
| 764 text_renderer_->Initialize( | |
| 765 base::Bind(&Pipeline::OnTextRendererEnded, base::Unretained(this))); | |
| 766 } | |
| 767 | |
| 714 StateTransitionTask(PIPELINE_OK); | 768 StateTransitionTask(PIPELINE_OK); |
| 715 } | 769 } |
| 716 | 770 |
| 717 void Pipeline::StopTask(const base::Closure& stop_cb) { | 771 void Pipeline::StopTask(const base::Closure& stop_cb) { |
| 718 DCHECK(message_loop_->BelongsToCurrentThread()); | 772 DCHECK(message_loop_->BelongsToCurrentThread()); |
| 719 DCHECK(stop_cb_.is_null()); | 773 DCHECK(stop_cb_.is_null()); |
| 720 | 774 |
| 721 if (state_ == kStopped) { | 775 if (state_ == kStopped) { |
| 722 stop_cb.Run(); | 776 stop_cb.Run(); |
| 723 return; | 777 return; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 793 return; | 847 return; |
| 794 } | 848 } |
| 795 | 849 |
| 796 DCHECK(seek_cb_.is_null()); | 850 DCHECK(seek_cb_.is_null()); |
| 797 | 851 |
| 798 SetState(kSeeking); | 852 SetState(kSeeking); |
| 799 base::TimeDelta seek_timestamp = std::max(time, demuxer_->GetStartTime()); | 853 base::TimeDelta seek_timestamp = std::max(time, demuxer_->GetStartTime()); |
| 800 seek_cb_ = seek_cb; | 854 seek_cb_ = seek_cb; |
| 801 audio_ended_ = false; | 855 audio_ended_ = false; |
| 802 video_ended_ = false; | 856 video_ended_ = false; |
| 857 text_ended_ = false; | |
| 803 | 858 |
| 804 // Kick off seeking! | 859 // Kick off seeking! |
| 805 { | 860 { |
| 806 base::AutoLock auto_lock(lock_); | 861 base::AutoLock auto_lock(lock_); |
| 807 if (clock_->IsPlaying()) | 862 if (clock_->IsPlaying()) |
| 808 clock_->Pause(); | 863 clock_->Pause(); |
| 809 clock_->SetTime(seek_timestamp, seek_timestamp); | 864 clock_->SetTime(seek_timestamp, seek_timestamp); |
| 810 } | 865 } |
| 811 DoSeek(seek_timestamp, base::Bind( | 866 DoSeek(seek_timestamp, base::Bind( |
| 812 &Pipeline::OnStateTransition, base::Unretained(this))); | 867 &Pipeline::OnStateTransition, base::Unretained(this))); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 836 | 891 |
| 837 if (state_ != kStarted) | 892 if (state_ != kStarted) |
| 838 return; | 893 return; |
| 839 | 894 |
| 840 DCHECK(!video_ended_); | 895 DCHECK(!video_ended_); |
| 841 video_ended_ = true; | 896 video_ended_ = true; |
| 842 | 897 |
| 843 RunEndedCallbackIfNeeded(); | 898 RunEndedCallbackIfNeeded(); |
| 844 } | 899 } |
| 845 | 900 |
| 901 void Pipeline::DoTextRendererEnded() { | |
| 902 DCHECK(message_loop_->BelongsToCurrentThread()); | |
| 903 | |
| 904 if (state_ != kStarted) | |
| 905 return; | |
| 906 | |
| 907 DCHECK(!text_ended_); | |
| 908 text_ended_ = true; | |
| 909 | |
| 910 RunEndedCallbackIfNeeded(); | |
| 911 } | |
| 912 | |
| 846 void Pipeline::RunEndedCallbackIfNeeded() { | 913 void Pipeline::RunEndedCallbackIfNeeded() { |
| 847 DCHECK(message_loop_->BelongsToCurrentThread()); | 914 DCHECK(message_loop_->BelongsToCurrentThread()); |
| 848 | 915 |
| 849 if (audio_renderer_ && !audio_ended_ && !audio_disabled_) | 916 if (audio_renderer_ && !audio_ended_ && !audio_disabled_) |
| 850 return; | 917 return; |
| 851 | 918 |
| 852 if (video_renderer_ && !video_ended_) | 919 if (video_renderer_ && !video_ended_) |
| 853 return; | 920 return; |
| 854 | 921 |
| 922 if (text_renderer_ && text_renderer_->HasTracks() && !text_ended_) | |
| 923 return; | |
| 924 | |
| 855 { | 925 { |
| 856 base::AutoLock auto_lock(lock_); | 926 base::AutoLock auto_lock(lock_); |
| 857 clock_->EndOfStream(); | 927 clock_->EndOfStream(); |
| 858 } | 928 } |
| 859 | 929 |
| 860 DCHECK_EQ(status_, PIPELINE_OK); | 930 DCHECK_EQ(status_, PIPELINE_OK); |
| 861 ended_cb_.Run(); | 931 ended_cb_.Run(); |
| 862 } | 932 } |
| 863 | 933 |
| 864 void Pipeline::AudioDisabledTask() { | 934 void Pipeline::AudioDisabledTask() { |
| 865 DCHECK(message_loop_->BelongsToCurrentThread()); | 935 DCHECK(message_loop_->BelongsToCurrentThread()); |
| 866 | 936 |
| 867 base::AutoLock auto_lock(lock_); | 937 base::AutoLock auto_lock(lock_); |
| 868 has_audio_ = false; | 938 has_audio_ = false; |
| 869 audio_disabled_ = true; | 939 audio_disabled_ = true; |
| 870 | 940 |
| 871 // Notify our demuxer that we're no longer rendering audio. | 941 // Notify our demuxer that we're no longer rendering audio. |
| 872 demuxer_->OnAudioRendererDisabled(); | 942 demuxer_->OnAudioRendererDisabled(); |
| 873 | 943 |
| 874 // Start clock since there is no more audio to trigger clock updates. | 944 // Start clock since there is no more audio to trigger clock updates. |
| 875 clock_->SetMaxTime(clock_->Duration()); | 945 clock_->SetMaxTime(clock_->Duration()); |
| 876 StartClockIfWaitingForTimeUpdate_Locked(); | 946 StartClockIfWaitingForTimeUpdate_Locked(); |
| 877 } | 947 } |
| 878 | 948 |
| 949 void Pipeline::AddTextStreamTask(DemuxerStream* text_stream, | |
| 950 const TextTrackConfig& config) { | |
| 951 DCHECK(message_loop_->BelongsToCurrentThread()); | |
| 952 text_renderer_->AddTextStream(text_stream, config); | |
| 953 } | |
| 954 | |
| 955 void Pipeline::RemoveTextStreamTask(DemuxerStream* text_stream) { | |
| 956 DCHECK(message_loop_->BelongsToCurrentThread()); | |
| 957 if (text_renderer_) | |
|
acolwell GONE FROM CHROMIUM
2013/10/24 18:57:51
Why is this needed? It shouldn't be possible for t
Matthew Heaney (Chromium)
2013/10/25 03:05:38
Done.
| |
| 958 text_renderer_->RemoveTextStream(text_stream); | |
| 959 } | |
| 960 | |
| 879 void Pipeline::InitializeDemuxer(const PipelineStatusCB& done_cb) { | 961 void Pipeline::InitializeDemuxer(const PipelineStatusCB& done_cb) { |
| 880 DCHECK(message_loop_->BelongsToCurrentThread()); | 962 DCHECK(message_loop_->BelongsToCurrentThread()); |
| 881 | 963 |
| 882 demuxer_ = filter_collection_->GetDemuxer(); | 964 demuxer_ = filter_collection_->GetDemuxer(); |
| 883 demuxer_->Initialize(this, done_cb); | 965 demuxer_->Initialize(this, done_cb); |
|
acolwell GONE FROM CHROMIUM
2013/10/24 18:57:51
WDYT about passing the enable_text_tracks bool her
acolwell GONE FROM CHROMIUM
2013/10/29 21:14:19
Please address this comment.
Matthew Heaney (Chromium)
2013/11/05 04:52:40
Done.
Matthew Heaney (Chromium)
2013/11/05 04:52:40
Done.
| |
| 884 } | 966 } |
| 885 | 967 |
| 886 void Pipeline::InitializeAudioRenderer(const PipelineStatusCB& done_cb) { | 968 void Pipeline::InitializeAudioRenderer(const PipelineStatusCB& done_cb) { |
| 887 DCHECK(message_loop_->BelongsToCurrentThread()); | 969 DCHECK(message_loop_->BelongsToCurrentThread()); |
| 888 | 970 |
| 889 audio_renderer_ = filter_collection_->GetAudioRenderer(); | 971 audio_renderer_ = filter_collection_->GetAudioRenderer(); |
| 890 audio_renderer_->Initialize( | 972 audio_renderer_->Initialize( |
| 891 demuxer_->GetStream(DemuxerStream::AUDIO), | 973 demuxer_->GetStream(DemuxerStream::AUDIO), |
| 892 done_cb, | 974 done_cb, |
| 893 base::Bind(&Pipeline::OnUpdateStatistics, base::Unretained(this)), | 975 base::Bind(&Pipeline::OnUpdateStatistics, base::Unretained(this)), |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 940 void Pipeline::StartClockIfWaitingForTimeUpdate_Locked() { | 1022 void Pipeline::StartClockIfWaitingForTimeUpdate_Locked() { |
| 941 lock_.AssertAcquired(); | 1023 lock_.AssertAcquired(); |
| 942 if (!waiting_for_clock_update_) | 1024 if (!waiting_for_clock_update_) |
| 943 return; | 1025 return; |
| 944 | 1026 |
| 945 waiting_for_clock_update_ = false; | 1027 waiting_for_clock_update_ = false; |
| 946 clock_->Play(); | 1028 clock_->Play(); |
| 947 } | 1029 } |
| 948 | 1030 |
| 949 } // namespace media | 1031 } // namespace media |
| OLD | NEW |