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

Side by Side Diff: media/mojo/clients/mojo_renderer.cc

Issue 2668393002: Rename DemuxerStreamProvider into MediaResource (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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/mojo/clients/mojo_renderer.h" 5 #include "media/mojo/clients/mojo_renderer.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/single_thread_task_runner.h" 12 #include "base/single_thread_task_runner.h"
13 #include "media/base/demuxer_stream_provider.h" 13 #include "media/base/media_resource.h"
14 #include "media/base/pipeline_status.h" 14 #include "media/base/pipeline_status.h"
15 #include "media/base/renderer_client.h" 15 #include "media/base/renderer_client.h"
16 #include "media/base/video_renderer_sink.h" 16 #include "media/base/video_renderer_sink.h"
17 #include "media/mojo/clients/mojo_demuxer_stream_impl.h" 17 #include "media/mojo/clients/mojo_demuxer_stream_impl.h"
18 #include "media/renderers/video_overlay_factory.h" 18 #include "media/renderers/video_overlay_factory.h"
19 19
20 namespace media { 20 namespace media {
21 21
22 MojoRenderer::MojoRenderer( 22 MojoRenderer::MojoRenderer(
23 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, 23 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
24 std::unique_ptr<VideoOverlayFactory> video_overlay_factory, 24 std::unique_ptr<VideoOverlayFactory> video_overlay_factory,
25 VideoRendererSink* video_renderer_sink, 25 VideoRendererSink* video_renderer_sink,
26 mojom::RendererPtr remote_renderer) 26 mojom::RendererPtr remote_renderer)
27 : task_runner_(task_runner), 27 : task_runner_(task_runner),
28 video_overlay_factory_(std::move(video_overlay_factory)), 28 video_overlay_factory_(std::move(video_overlay_factory)),
29 video_renderer_sink_(video_renderer_sink), 29 video_renderer_sink_(video_renderer_sink),
30 remote_renderer_info_(remote_renderer.PassInterface()), 30 remote_renderer_info_(remote_renderer.PassInterface()),
31 client_binding_(this), 31 client_binding_(this),
32 media_time_interpolator_(&media_clock_) { 32 media_time_interpolator_(&media_clock_) {
33 DVLOG(1) << __func__; 33 DVLOG(1) << __func__;
34 } 34 }
35 35
36 MojoRenderer::~MojoRenderer() { 36 MojoRenderer::~MojoRenderer() {
37 DVLOG(1) << __func__; 37 DVLOG(1) << __func__;
38 DCHECK(task_runner_->BelongsToCurrentThread()); 38 DCHECK(task_runner_->BelongsToCurrentThread());
39 39
40 CancelPendingCallbacks(); 40 CancelPendingCallbacks();
41 } 41 }
42 42
43 void MojoRenderer::Initialize(DemuxerStreamProvider* demuxer_stream_provider, 43 void MojoRenderer::Initialize(MediaResource* media_resource,
44 media::RendererClient* client, 44 media::RendererClient* client,
45 const PipelineStatusCB& init_cb) { 45 const PipelineStatusCB& init_cb) {
46 DVLOG(1) << __func__; 46 DVLOG(1) << __func__;
47 DCHECK(task_runner_->BelongsToCurrentThread()); 47 DCHECK(task_runner_->BelongsToCurrentThread());
48 DCHECK(demuxer_stream_provider); 48 DCHECK(media_resource);
49 49
50 if (encountered_error_) { 50 if (encountered_error_) {
51 task_runner_->PostTask( 51 task_runner_->PostTask(
52 FROM_HERE, base::Bind(init_cb, PIPELINE_ERROR_INITIALIZATION_FAILED)); 52 FROM_HERE, base::Bind(init_cb, PIPELINE_ERROR_INITIALIZATION_FAILED));
53 return; 53 return;
54 } 54 }
55 55
56 demuxer_stream_provider_ = demuxer_stream_provider; 56 media_resource_ = media_resource;
57 init_cb_ = init_cb; 57 init_cb_ = init_cb;
58 58
59 switch (demuxer_stream_provider_->GetType()) { 59 switch (media_resource_->GetType()) {
60 case DemuxerStreamProvider::Type::STREAM: 60 case MediaResource::Type::STREAM:
61 InitializeRendererFromStreams(client); 61 InitializeRendererFromStreams(client);
62 break; 62 break;
63 case DemuxerStreamProvider::Type::URL: 63 case MediaResource::Type::URL:
64 InitializeRendererFromUrl(client); 64 InitializeRendererFromUrl(client);
65 break; 65 break;
66 } 66 }
67 } 67 }
68 68
69 void MojoRenderer::InitializeRendererFromStreams( 69 void MojoRenderer::InitializeRendererFromStreams(
70 media::RendererClient* client) { 70 media::RendererClient* client) {
71 DVLOG(1) << __func__; 71 DVLOG(1) << __func__;
72 DCHECK(task_runner_->BelongsToCurrentThread()); 72 DCHECK(task_runner_->BelongsToCurrentThread());
73 73
74 // Create audio and video mojom::DemuxerStream and bind its lifetime to 74 // Create audio and video mojom::DemuxerStream and bind its lifetime to
75 // the pipe. 75 // the pipe.
76 DemuxerStream* const audio = 76 DemuxerStream* const audio = media_resource_->GetStream(DemuxerStream::AUDIO);
77 demuxer_stream_provider_->GetStream(DemuxerStream::AUDIO); 77 DemuxerStream* const video = media_resource_->GetStream(DemuxerStream::VIDEO);
78 DemuxerStream* const video =
79 demuxer_stream_provider_->GetStream(DemuxerStream::VIDEO);
80 78
81 std::vector<mojom::DemuxerStreamPtr> streams; 79 std::vector<mojom::DemuxerStreamPtr> streams;
82 if (audio) { 80 if (audio) {
83 mojom::DemuxerStreamPtr audio_stream; 81 mojom::DemuxerStreamPtr audio_stream;
84 std::unique_ptr<MojoDemuxerStreamImpl> mojo_stream = 82 std::unique_ptr<MojoDemuxerStreamImpl> mojo_stream =
85 base::MakeUnique<MojoDemuxerStreamImpl>(audio, 83 base::MakeUnique<MojoDemuxerStreamImpl>(audio,
86 MakeRequest(&audio_stream)); 84 MakeRequest(&audio_stream));
87 // Using base::Unretained(this) is safe because |this| owns |mojo_stream|, 85 // Using base::Unretained(this) is safe because |this| owns |mojo_stream|,
88 // and the error handler can't be invoked once |mojo_stream| is destroyed. 86 // and the error handler can't be invoked once |mojo_stream| is destroyed.
89 mojo_stream->set_connection_error_handler( 87 mojo_stream->set_connection_error_handler(
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 121
124 void MojoRenderer::InitializeRendererFromUrl(media::RendererClient* client) { 122 void MojoRenderer::InitializeRendererFromUrl(media::RendererClient* client) {
125 DVLOG(2) << __func__; 123 DVLOG(2) << __func__;
126 DCHECK(task_runner_->BelongsToCurrentThread()); 124 DCHECK(task_runner_->BelongsToCurrentThread());
127 125
128 BindRemoteRendererIfNeeded(); 126 BindRemoteRendererIfNeeded();
129 127
130 mojom::RendererClientAssociatedPtrInfo client_ptr_info; 128 mojom::RendererClientAssociatedPtrInfo client_ptr_info;
131 client_binding_.Bind(&client_ptr_info, remote_renderer_.associated_group()); 129 client_binding_.Bind(&client_ptr_info, remote_renderer_.associated_group());
132 130
133 MediaUrlParams url_params = demuxer_stream_provider_->GetMediaUrlParams(); 131 MediaUrlParams url_params = media_resource_->GetMediaUrlParams();
134 132
135 // Using base::Unretained(this) is safe because |this| owns 133 // Using base::Unretained(this) is safe because |this| owns
136 // |remote_renderer_|, and the callback won't be dispatched if 134 // |remote_renderer_|, and the callback won't be dispatched if
137 // |remote_renderer_| is destroyed. 135 // |remote_renderer_| is destroyed.
138 std::vector<mojom::DemuxerStreamPtr> streams; 136 std::vector<mojom::DemuxerStreamPtr> streams;
139 remote_renderer_->Initialize( 137 remote_renderer_->Initialize(
140 std::move(client_ptr_info), std::move(streams), url_params.media_url, 138 std::move(client_ptr_info), std::move(streams), url_params.media_url,
141 url_params.first_party_for_cookies, 139 url_params.first_party_for_cookies,
142 base::Bind(&MojoRenderer::OnInitialized, base::Unretained(this), client)); 140 base::Bind(&MojoRenderer::OnInitialized, base::Unretained(this), client));
143 } 141 }
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 base::ResetAndReturn(&init_cb_).Run(PIPELINE_ERROR_INITIALIZATION_FAILED); 391 base::ResetAndReturn(&init_cb_).Run(PIPELINE_ERROR_INITIALIZATION_FAILED);
394 392
395 if (!flush_cb_.is_null()) 393 if (!flush_cb_.is_null())
396 base::ResetAndReturn(&flush_cb_).Run(); 394 base::ResetAndReturn(&flush_cb_).Run();
397 395
398 if (!cdm_attached_cb_.is_null()) 396 if (!cdm_attached_cb_.is_null())
399 base::ResetAndReturn(&cdm_attached_cb_).Run(false); 397 base::ResetAndReturn(&cdm_attached_cb_).Run(false);
400 } 398 }
401 399
402 } // namespace media 400 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698