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

Side by Side Diff: media/remoting/courier_renderer.cc

Issue 2667283002: Refactor MediaResource to be multi-stream capable (Closed)
Patch Set: 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 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 "media/remoting/courier_renderer.h" 5 #include "media/remoting/courier_renderer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 FROM_HERE, base::Bind(init_cb, PIPELINE_ERROR_INVALID_STATE)); 119 FROM_HERE, base::Bind(init_cb, PIPELINE_ERROR_INVALID_STATE));
120 return; 120 return;
121 } 121 }
122 122
123 media_resource_ = media_resource; 123 media_resource_ = media_resource;
124 client_ = client; 124 client_ = client;
125 init_workflow_done_callback_ = init_cb; 125 init_workflow_done_callback_ = init_cb;
126 126
127 state_ = STATE_CREATE_PIPE; 127 state_ = STATE_CREATE_PIPE;
128 128
129 // TODO(servolk): Implement support for multiple streams. For now use the
130 // first enabled audio and video streams to preserve the existing behavior.
131 std::vector<::media::DemuxerStream*> streams = media_resource_->GetStreams();
132 ::media::DemuxerStream* audio_demuxer_stream = nullptr;
133 ::media::DemuxerStream* video_demuxer_stream = nullptr;
134 for (const auto& stream : streams) {
135 if (stream->type() == DemuxerStream::AUDIO && stream->enabled() &&
136 !audio_demuxer_stream)
137 audio_demuxer_stream = stream;
138 if (stream->type() == DemuxerStream::VIDEO && stream->enabled() &&
139 !video_demuxer_stream)
140 video_demuxer_stream = stream;
141 }
142
129 // Create audio mojo data pipe handles if audio is available. 143 // Create audio mojo data pipe handles if audio is available.
130 DemuxerStream* audio_demuxer_stream =
131 media_resource_->GetStream(DemuxerStream::AUDIO);
132 std::unique_ptr<mojo::DataPipe> audio_data_pipe; 144 std::unique_ptr<mojo::DataPipe> audio_data_pipe;
133 if (audio_demuxer_stream) { 145 if (audio_demuxer_stream) {
134 audio_data_pipe = base::WrapUnique(DemuxerStreamAdapter::CreateDataPipe()); 146 audio_data_pipe = base::WrapUnique(DemuxerStreamAdapter::CreateDataPipe());
135 } 147 }
136 148
137 // Create video mojo data pipe handles if video is available. 149 // Create video mojo data pipe handles if video is available.
138 DemuxerStream* video_demuxer_stream =
139 media_resource_->GetStream(DemuxerStream::VIDEO);
140 std::unique_ptr<mojo::DataPipe> video_data_pipe; 150 std::unique_ptr<mojo::DataPipe> video_data_pipe;
141 if (video_demuxer_stream) { 151 if (video_demuxer_stream) {
142 video_data_pipe = base::WrapUnique(DemuxerStreamAdapter::CreateDataPipe()); 152 video_data_pipe = base::WrapUnique(DemuxerStreamAdapter::CreateDataPipe());
143 } 153 }
144 154
145 // Establish remoting data pipe connection using main thread. 155 // Establish remoting data pipe connection using main thread.
146 const SharedSession::DataPipeStartCallback data_pipe_callback = 156 const SharedSession::DataPipeStartCallback data_pipe_callback =
147 base::Bind(&CourierRenderer::OnDataPipeCreatedOnMainThread, 157 base::Bind(&CourierRenderer::OnDataPipeCreatedOnMainThread,
148 media_task_runner_, weak_factory_.GetWeakPtr(), rpc_broker_); 158 media_task_runner_, weak_factory_.GetWeakPtr(), rpc_broker_);
149 main_task_runner_->PostTask( 159 main_task_runner_->PostTask(
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 int audio_rpc_handle, 329 int audio_rpc_handle,
320 int video_rpc_handle) { 330 int video_rpc_handle) {
321 VLOG(2) << __func__; 331 VLOG(2) << __func__;
322 DCHECK(media_task_runner_->BelongsToCurrentThread()); 332 DCHECK(media_task_runner_->BelongsToCurrentThread());
323 DCHECK(!init_workflow_done_callback_.is_null()); 333 DCHECK(!init_workflow_done_callback_.is_null());
324 334
325 if (state_ == STATE_ERROR) 335 if (state_ == STATE_ERROR)
326 return; // Abort because something went wrong in the meantime. 336 return; // Abort because something went wrong in the meantime.
327 DCHECK_EQ(state_, STATE_CREATE_PIPE); 337 DCHECK_EQ(state_, STATE_CREATE_PIPE);
328 338
339 // TODO(erickung): Make remote renderer multi-stream capable.
340 std::vector<::media::DemuxerStream*> streams = media_resource_->GetStreams();
341 ::media::DemuxerStream* audio_demuxer_stream = nullptr;
342 ::media::DemuxerStream* video_demuxer_stream = nullptr;
343 for (const auto& s : streams) {
344 if (s->type() == DemuxerStream::AUDIO && s->enabled() &&
345 !audio_demuxer_stream)
346 audio_demuxer_stream = s;
347 if (s->type() == DemuxerStream::VIDEO && s->enabled() &&
348 !video_demuxer_stream)
349 video_demuxer_stream = s;
350 }
351
329 // Create audio demuxer stream adapter if audio is available. 352 // Create audio demuxer stream adapter if audio is available.
330 DemuxerStream* audio_demuxer_stream =
331 media_resource_->GetStream(DemuxerStream::AUDIO);
332 if (audio_demuxer_stream && audio.is_valid() && audio_handle.is_valid() && 353 if (audio_demuxer_stream && audio.is_valid() && audio_handle.is_valid() &&
333 audio_rpc_handle != RpcBroker::kInvalidHandle) { 354 audio_rpc_handle != RpcBroker::kInvalidHandle) {
334 VLOG(2) << "Initialize audio"; 355 VLOG(2) << "Initialize audio";
335 audio_demuxer_stream_adapter_.reset(new DemuxerStreamAdapter( 356 audio_demuxer_stream_adapter_.reset(new DemuxerStreamAdapter(
336 main_task_runner_, media_task_runner_, "audio", audio_demuxer_stream, 357 main_task_runner_, media_task_runner_, "audio", audio_demuxer_stream,
337 rpc_broker_, audio_rpc_handle, std::move(audio), 358 rpc_broker_, audio_rpc_handle, std::move(audio),
338 std::move(audio_handle), 359 std::move(audio_handle),
339 base::Bind(&CourierRenderer::OnFatalError, base::Unretained(this)))); 360 base::Bind(&CourierRenderer::OnFatalError, base::Unretained(this))));
340 } 361 }
341 362
342 // Create video demuxer stream adapter if video is available. 363 // Create video demuxer stream adapter if video is available.
343 DemuxerStream* video_demuxer_stream =
344 media_resource_->GetStream(DemuxerStream::VIDEO);
345 if (video_demuxer_stream && video.is_valid() && video_handle.is_valid() && 364 if (video_demuxer_stream && video.is_valid() && video_handle.is_valid() &&
346 video_rpc_handle != RpcBroker::kInvalidHandle) { 365 video_rpc_handle != RpcBroker::kInvalidHandle) {
347 VLOG(2) << "Initialize video"; 366 VLOG(2) << "Initialize video";
348 video_demuxer_stream_adapter_.reset(new DemuxerStreamAdapter( 367 video_demuxer_stream_adapter_.reset(new DemuxerStreamAdapter(
349 main_task_runner_, media_task_runner_, "video", video_demuxer_stream, 368 main_task_runner_, media_task_runner_, "video", video_demuxer_stream,
350 rpc_broker_, video_rpc_handle, std::move(video), 369 rpc_broker_, video_rpc_handle, std::move(video),
351 std::move(video_handle), 370 std::move(video_handle),
352 base::Bind(&CourierRenderer::OnFatalError, base::Unretained(this)))); 371 base::Bind(&CourierRenderer::OnFatalError, base::Unretained(this))));
353 } 372 }
354 373
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 kBytesPerKilobit; 862 kBytesPerKilobit;
844 DCHECK_GE(kilobits_per_second, 0); 863 DCHECK_GE(kilobits_per_second, 0);
845 const base::CheckedNumeric<int> checked_kbps = kilobits_per_second; 864 const base::CheckedNumeric<int> checked_kbps = kilobits_per_second;
846 metrics_recorder_.OnVideoRateEstimate( 865 metrics_recorder_.OnVideoRateEstimate(
847 checked_kbps.ValueOrDefault(std::numeric_limits<int>::max())); 866 checked_kbps.ValueOrDefault(std::numeric_limits<int>::max()));
848 } 867 }
849 } 868 }
850 869
851 } // namespace remoting 870 } // namespace remoting
852 } // namespace media 871 } // namespace media
OLDNEW
« no previous file with comments | « media/mojo/services/mojo_demuxer_stream_adapter.cc ('k') | media/remoting/fake_media_resource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698