OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chromecast/browser/media/cast_renderer.h" | 5 #include "chromecast/browser/media/cast_renderer.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
9 #include "chromecast/base/task_runner_impl.h" | 9 #include "chromecast/base/task_runner_impl.h" |
10 #include "chromecast/media/cma/base/balanced_media_task_runner_factory.h" | 10 #include "chromecast/media/cma/base/balanced_media_task_runner_factory.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 CastRenderer::~CastRenderer() { | 40 CastRenderer::~CastRenderer() { |
41 CMALOG(kLogControl) << __FUNCTION__ << ": " << this; | 41 CMALOG(kLogControl) << __FUNCTION__ << ": " << this; |
42 DCHECK(task_runner_->BelongsToCurrentThread()); | 42 DCHECK(task_runner_->BelongsToCurrentThread()); |
43 } | 43 } |
44 | 44 |
45 void CastRenderer::Initialize( | 45 void CastRenderer::Initialize( |
46 ::media::DemuxerStreamProvider* demuxer_stream_provider, | 46 ::media::DemuxerStreamProvider* demuxer_stream_provider, |
47 const ::media::PipelineStatusCB& init_cb, | 47 const ::media::PipelineStatusCB& init_cb, |
48 const ::media::StatisticsCB& statistics_cb, | 48 const ::media::StatisticsCB& statistics_cb, |
49 const ::media::BufferingStateCB& buffering_state_cb, | 49 const ::media::BufferingStateCB& buffering_state_cb, |
| 50 const ::media::NaturalSizeChangedCB& natural_size_changed_cb, |
50 const base::Closure& ended_cb, | 51 const base::Closure& ended_cb, |
51 const ::media::PipelineStatusCB& error_cb, | 52 const ::media::PipelineStatusCB& error_cb, |
52 const base::Closure& waiting_for_decryption_key_cb) { | 53 const base::Closure& waiting_for_decryption_key_cb) { |
53 CMALOG(kLogControl) << __FUNCTION__ << ": " << this; | 54 CMALOG(kLogControl) << __FUNCTION__ << ": " << this; |
54 DCHECK(task_runner_->BelongsToCurrentThread()); | 55 DCHECK(task_runner_->BelongsToCurrentThread()); |
55 | 56 |
56 // Create pipeline backend. | 57 // Create pipeline backend. |
57 backend_task_runner_.reset(new TaskRunnerImpl()); | 58 backend_task_runner_.reset(new TaskRunnerImpl()); |
58 // TODO(erickung): crbug.com/443956. Need to provide right LoadType. | 59 // TODO(erickung): crbug.com/443956. Need to provide right LoadType. |
59 LoadType load_type = kLoadTypeMediaSource; | 60 LoadType load_type = kLoadTypeMediaSource; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 return; | 94 return; |
94 } | 95 } |
95 audio_stream->EnableBitstreamConverter(); | 96 audio_stream->EnableBitstreamConverter(); |
96 } | 97 } |
97 | 98 |
98 // Initialize video. | 99 // Initialize video. |
99 ::media::DemuxerStream* video_stream = | 100 ::media::DemuxerStream* video_stream = |
100 demuxer_stream_provider->GetStream(::media::DemuxerStream::VIDEO); | 101 demuxer_stream_provider->GetStream(::media::DemuxerStream::VIDEO); |
101 if (video_stream) { | 102 if (video_stream) { |
102 VideoPipelineClient video_client; | 103 VideoPipelineClient video_client; |
103 // TODO(alokp): Set VideoPipelineClient::natural_size_changed_cb. | |
104 video_client.av_pipeline_client.wait_for_key_cb = | 104 video_client.av_pipeline_client.wait_for_key_cb = |
105 waiting_for_decryption_key_cb; | 105 waiting_for_decryption_key_cb; |
106 video_client.av_pipeline_client.eos_cb = | 106 video_client.av_pipeline_client.eos_cb = |
107 base::Bind(&CastRenderer::OnEos, base::Unretained(this), STREAM_VIDEO); | 107 base::Bind(&CastRenderer::OnEos, base::Unretained(this), STREAM_VIDEO); |
108 video_client.av_pipeline_client.playback_error_cb = error_cb; | 108 video_client.av_pipeline_client.playback_error_cb = error_cb; |
109 video_client.av_pipeline_client.statistics_cb = statistics_cb; | 109 video_client.av_pipeline_client.statistics_cb = statistics_cb; |
| 110 video_client.natural_size_changed_cb = natural_size_changed_cb; |
110 // TODO(alokp): Change MediaPipelineImpl API to accept a single config | 111 // TODO(alokp): Change MediaPipelineImpl API to accept a single config |
111 // after CmaRenderer is deprecated. | 112 // after CmaRenderer is deprecated. |
112 std::vector<::media::VideoDecoderConfig> video_configs; | 113 std::vector<::media::VideoDecoderConfig> video_configs; |
113 video_configs.push_back(video_stream->video_decoder_config()); | 114 video_configs.push_back(video_stream->video_decoder_config()); |
114 std::unique_ptr<CodedFrameProvider> frame_provider(new DemuxerStreamAdapter( | 115 std::unique_ptr<CodedFrameProvider> frame_provider(new DemuxerStreamAdapter( |
115 task_runner_, media_task_runner_factory_, video_stream)); | 116 task_runner_, media_task_runner_factory_, video_stream)); |
116 ::media::PipelineStatus status = pipeline_->InitializeVideo( | 117 ::media::PipelineStatus status = pipeline_->InitializeVideo( |
117 video_configs, video_client, std::move(frame_provider)); | 118 video_configs, video_client, std::move(frame_provider)); |
118 if (status != ::media::PIPELINE_OK) { | 119 if (status != ::media::PIPELINE_OK) { |
119 init_cb.Run(status); | 120 init_cb.Run(status); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 DCHECK(!eos_[stream]); | 175 DCHECK(!eos_[stream]); |
175 eos_[stream] = true; | 176 eos_[stream] = true; |
176 CMALOG(kLogControl) << __FUNCTION__ << ": eos_audio=" << eos_[STREAM_AUDIO] | 177 CMALOG(kLogControl) << __FUNCTION__ << ": eos_audio=" << eos_[STREAM_AUDIO] |
177 << " eos_video=" << eos_[STREAM_VIDEO]; | 178 << " eos_video=" << eos_[STREAM_VIDEO]; |
178 if (eos_[STREAM_AUDIO] && eos_[STREAM_VIDEO]) | 179 if (eos_[STREAM_AUDIO] && eos_[STREAM_VIDEO]) |
179 ended_cb_.Run(); | 180 ended_cb_.Run(); |
180 } | 181 } |
181 | 182 |
182 } // namespace media | 183 } // namespace media |
183 } // namespace chromecast | 184 } // namespace chromecast |
OLD | NEW |