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

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

Issue 2491043003: MediaResource refactoring to support multiple streams (Closed)
Patch Set: rebase Created 3 years, 10 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
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_impl.h" 5 #include "media/base/pipeline_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 DCHECK(media_task_runner_->BelongsToCurrentThread()); 852 DCHECK(media_task_runner_->BelongsToCurrentThread());
853 853
854 demuxer_->Initialize(this, done_cb, !!text_renderer_); 854 demuxer_->Initialize(this, done_cb, !!text_renderer_);
855 } 855 }
856 856
857 void PipelineImpl::RendererWrapper::InitializeRenderer( 857 void PipelineImpl::RendererWrapper::InitializeRenderer(
858 const PipelineStatusCB& done_cb) { 858 const PipelineStatusCB& done_cb) {
859 DCHECK(media_task_runner_->BelongsToCurrentThread()); 859 DCHECK(media_task_runner_->BelongsToCurrentThread());
860 860
861 switch (demuxer_->GetType()) { 861 switch (demuxer_->GetType()) {
862 case DemuxerStreamProvider::Type::STREAM: 862 case MediaResource::Type::STREAM:
863 if (!demuxer_->GetStream(DemuxerStream::AUDIO) && 863 if (demuxer_->GetStreams().empty()) {
864 !demuxer_->GetStream(DemuxerStream::VIDEO)) {
865 DVLOG(1) << "Error: demuxer does not have an audio or a video stream."; 864 DVLOG(1) << "Error: demuxer does not have an audio or a video stream.";
866 done_cb.Run(PIPELINE_ERROR_COULD_NOT_RENDER); 865 done_cb.Run(PIPELINE_ERROR_COULD_NOT_RENDER);
867 return; 866 return;
868 } 867 }
869 break; 868 break;
870 869
871 case DemuxerStreamProvider::Type::URL: 870 case MediaResource::Type::URL:
872 // NOTE: Empty GURL are not valid. 871 // NOTE: Empty GURL are not valid.
873 if (!demuxer_->GetMediaUrlParams().media_url.is_valid()) { 872 if (!demuxer_->GetMediaUrlParams().media_url.is_valid()) {
874 DVLOG(1) << "Error: demuxer does not have a valid URL."; 873 DVLOG(1) << "Error: demuxer does not have a valid URL.";
875 done_cb.Run(PIPELINE_ERROR_COULD_NOT_RENDER); 874 done_cb.Run(PIPELINE_ERROR_COULD_NOT_RENDER);
876 return; 875 return;
877 } 876 }
878 break; 877 break;
879 } 878 }
880 879
881 if (cdm_context_) 880 if (cdm_context_)
(...skipping 12 matching lines...) Expand all
894 { 893 {
895 base::AutoLock auto_lock(shared_state_lock_); 894 base::AutoLock auto_lock(shared_state_lock_);
896 renderer.swap(shared_state_.renderer); 895 renderer.swap(shared_state_.renderer);
897 } 896 }
898 } 897 }
899 898
900 void PipelineImpl::RendererWrapper::ReportMetadata() { 899 void PipelineImpl::RendererWrapper::ReportMetadata() {
901 DCHECK(media_task_runner_->BelongsToCurrentThread()); 900 DCHECK(media_task_runner_->BelongsToCurrentThread());
902 901
903 PipelineMetadata metadata; 902 PipelineMetadata metadata;
904 DemuxerStream* stream; 903 std::vector<DemuxerStream*> streams;
905 904
906 switch (demuxer_->GetType()) { 905 switch (demuxer_->GetType()) {
907 case DemuxerStreamProvider::Type::STREAM: 906 case MediaResource::Type::STREAM:
908 metadata.timeline_offset = demuxer_->GetTimelineOffset(); 907 metadata.timeline_offset = demuxer_->GetTimelineOffset();
909 stream = demuxer_->GetStream(DemuxerStream::VIDEO); 908 // TODO(servolk): What should we do about metadata for multiple streams?
910 if (stream) { 909 streams = demuxer_->GetStreams();
911 metadata.has_video = true; 910 for (const auto& stream : streams) {
912 metadata.natural_size = 911 if (stream->type() == DemuxerStream::VIDEO && !metadata.has_video) {
913 GetRotatedVideoSize(stream->video_rotation(), 912 metadata.has_video = true;
914 stream->video_decoder_config().natural_size()); 913 metadata.natural_size = GetRotatedVideoSize(
915 metadata.video_rotation = stream->video_rotation(); 914 stream->video_rotation(),
916 metadata.video_decoder_config = stream->video_decoder_config(); 915 stream->video_decoder_config().natural_size());
917 } 916 metadata.video_rotation = stream->video_rotation();
918 stream = demuxer_->GetStream(DemuxerStream::AUDIO); 917 metadata.video_decoder_config = stream->video_decoder_config();
919 if (stream) { 918 }
920 metadata.has_audio = true; 919 if (stream->type() == DemuxerStream::AUDIO && !metadata.has_audio) {
921 metadata.audio_decoder_config = stream->audio_decoder_config(); 920 metadata.has_audio = true;
921 metadata.audio_decoder_config = stream->audio_decoder_config();
922 }
xhwang 2017/02/01 18:26:03 This will set the meta data according to the last
servolk 2017/02/01 22:29:17 No, this will set metadata according to the first
922 } 923 }
923 break; 924 break;
924 925
925 case DemuxerStreamProvider::Type::URL: 926 case MediaResource::Type::URL:
926 // We don't know if the MediaPlayerRender has Audio/Video until we start 927 // We don't know if the MediaPlayerRender has Audio/Video until we start
927 // playing. Conservatively assume that they do. 928 // playing. Conservatively assume that they do.
928 metadata.has_video = true; 929 metadata.has_video = true;
929 metadata.has_audio = true; 930 metadata.has_audio = true;
930 break; 931 break;
931 } 932 }
932 933
933 main_task_runner_->PostTask(FROM_HERE, base::Bind(&PipelineImpl::OnMetadata, 934 main_task_runner_->PostTask(FROM_HERE, base::Bind(&PipelineImpl::OnMetadata,
934 weak_pipeline_, metadata)); 935 weak_pipeline_, metadata));
935 } 936 }
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
1338 void PipelineImpl::OnSuspendDone() { 1339 void PipelineImpl::OnSuspendDone() {
1339 DVLOG(3) << __func__; 1340 DVLOG(3) << __func__;
1340 DCHECK(thread_checker_.CalledOnValidThread()); 1341 DCHECK(thread_checker_.CalledOnValidThread());
1341 DCHECK(IsRunning()); 1342 DCHECK(IsRunning());
1342 1343
1343 DCHECK(!suspend_cb_.is_null()); 1344 DCHECK(!suspend_cb_.is_null());
1344 base::ResetAndReturn(&suspend_cb_).Run(PIPELINE_OK); 1345 base::ResetAndReturn(&suspend_cb_).Run(PIPELINE_OK);
1345 } 1346 }
1346 1347
1347 } // namespace media 1348 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698