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

Side by Side Diff: content/renderer/media/android/media_player_renderer_client.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 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 "content/renderer/media/android/media_player_renderer_client.h" 5 #include "content/renderer/media/android/media_player_renderer_client.h"
6 6
7 #include "base/callback_helpers.h" 7 #include "base/callback_helpers.h"
8 8
9 namespace content { 9 namespace content {
10 10
11 MediaPlayerRendererClient::MediaPlayerRendererClient( 11 MediaPlayerRendererClient::MediaPlayerRendererClient(
12 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner, 12 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner,
13 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner, 13 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner,
14 media::MojoRenderer* mojo_renderer, 14 media::MojoRenderer* mojo_renderer,
15 media::ScopedStreamTextureWrapper stream_texture_wrapper, 15 media::ScopedStreamTextureWrapper stream_texture_wrapper,
16 media::VideoRendererSink* sink) 16 media::VideoRendererSink* sink)
17 : mojo_renderer_(mojo_renderer), 17 : mojo_renderer_(mojo_renderer),
18 stream_texture_wrapper_(std::move(stream_texture_wrapper)), 18 stream_texture_wrapper_(std::move(stream_texture_wrapper)),
19 client_(nullptr), 19 client_(nullptr),
20 sink_(sink), 20 sink_(sink),
21 media_task_runner_(std::move(media_task_runner)), 21 media_task_runner_(std::move(media_task_runner)),
22 compositor_task_runner_(std::move(compositor_task_runner)), 22 compositor_task_runner_(std::move(compositor_task_runner)),
23 weak_factory_(this) {} 23 weak_factory_(this) {}
24 24
25 MediaPlayerRendererClient::~MediaPlayerRendererClient() {} 25 MediaPlayerRendererClient::~MediaPlayerRendererClient() {}
26 26
27 void MediaPlayerRendererClient::Initialize( 27 void MediaPlayerRendererClient::Initialize(
28 media::DemuxerStreamProvider* demuxer_stream_provider, 28 media::MediaResource* media_resource,
29 media::RendererClient* client, 29 media::RendererClient* client,
30 const media::PipelineStatusCB& init_cb) { 30 const media::PipelineStatusCB& init_cb) {
31 DCHECK(media_task_runner_->BelongsToCurrentThread()); 31 DCHECK(media_task_runner_->BelongsToCurrentThread());
32 DCHECK(!init_cb_); 32 DCHECK(!init_cb_);
33 33
34 client_ = client; 34 client_ = client;
35 init_cb_ = init_cb; 35 init_cb_ = init_cb;
36 36
37 // Initialize the StreamTexture using a 1x1 texture because we do not have 37 // Initialize the StreamTexture using a 1x1 texture because we do not have
38 // any size information from the MediaPlayer yet. 38 // any size information from the MediaPlayer yet.
39 // The size will be automatically updated in OnVideoNaturalSizeChange() once 39 // The size will be automatically updated in OnVideoNaturalSizeChange() once
40 // we parse the media's metadata. 40 // we parse the media's metadata.
41 // Unretained is safe here because |stream_texture_wrapper_| resets the 41 // Unretained is safe here because |stream_texture_wrapper_| resets the
42 // Closure it has before destroying itself on |compositor_task_runner_|, 42 // Closure it has before destroying itself on |compositor_task_runner_|,
43 // and |this| is garanteed to live until the Closure has been reset. 43 // and |this| is garanteed to live until the Closure has been reset.
44 stream_texture_wrapper_->Initialize( 44 stream_texture_wrapper_->Initialize(
45 base::Bind(&MediaPlayerRendererClient::OnFrameAvailable, 45 base::Bind(&MediaPlayerRendererClient::OnFrameAvailable,
46 base::Unretained(this)), 46 base::Unretained(this)),
47 gfx::Size(1, 1), compositor_task_runner_, 47 gfx::Size(1, 1), compositor_task_runner_,
48 base::Bind(&MediaPlayerRendererClient::OnStreamTextureWrapperInitialized, 48 base::Bind(&MediaPlayerRendererClient::OnStreamTextureWrapperInitialized,
49 weak_factory_.GetWeakPtr(), demuxer_stream_provider)); 49 weak_factory_.GetWeakPtr(), media_resource));
50 } 50 }
51 51
52 void MediaPlayerRendererClient::OnStreamTextureWrapperInitialized( 52 void MediaPlayerRendererClient::OnStreamTextureWrapperInitialized(
53 media::DemuxerStreamProvider* demuxer_stream_provider, 53 media::MediaResource* media_resource,
54 bool success) { 54 bool success) {
55 DCHECK(media_task_runner_->BelongsToCurrentThread()); 55 DCHECK(media_task_runner_->BelongsToCurrentThread());
56 if (!success) { 56 if (!success) {
57 base::ResetAndReturn(&init_cb_).Run( 57 base::ResetAndReturn(&init_cb_).Run(
58 media::PipelineStatus::PIPELINE_ERROR_INITIALIZATION_FAILED); 58 media::PipelineStatus::PIPELINE_ERROR_INITIALIZATION_FAILED);
59 return; 59 return;
60 } 60 }
61 61
62 mojo_renderer_->Initialize( 62 mojo_renderer_->Initialize(
63 demuxer_stream_provider, this, 63 media_resource, this,
64 base::Bind(&MediaPlayerRendererClient::OnRemoteRendererInitialized, 64 base::Bind(&MediaPlayerRendererClient::OnRemoteRendererInitialized,
65 weak_factory_.GetWeakPtr())); 65 weak_factory_.GetWeakPtr()));
66 } 66 }
67 67
68 void MediaPlayerRendererClient::OnScopedSurfaceRequested( 68 void MediaPlayerRendererClient::OnScopedSurfaceRequested(
69 const base::UnguessableToken& request_token) { 69 const base::UnguessableToken& request_token) {
70 DCHECK(request_token); 70 DCHECK(request_token);
71 stream_texture_wrapper_->ForwardStreamTextureForSurfaceRequest(request_token); 71 stream_texture_wrapper_->ForwardStreamTextureForSurfaceRequest(request_token);
72 } 72 }
73 73
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 146
147 void MediaPlayerRendererClient::OnVideoOpacityChange(bool opaque) { 147 void MediaPlayerRendererClient::OnVideoOpacityChange(bool opaque) {
148 client_->OnVideoOpacityChange(opaque); 148 client_->OnVideoOpacityChange(opaque);
149 } 149 }
150 150
151 void MediaPlayerRendererClient::OnDurationChange(base::TimeDelta duration) { 151 void MediaPlayerRendererClient::OnDurationChange(base::TimeDelta duration) {
152 client_->OnDurationChange(duration); 152 client_->OnDurationChange(duration);
153 } 153 }
154 154
155 } // namespace content 155 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698