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

Side by Side Diff: content/renderer/gpu/stream_texture_host_android.cc

Issue 2390783003: Make stream_id internal to StreamTextureHost. (Closed)
Patch Set: Addressed review comments. Created 4 years, 2 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 "content/renderer/gpu/stream_texture_host_android.h" 5 #include "content/renderer/gpu/stream_texture_host_android.h"
6 6
7 #include "base/unguessable_token.h"
7 #include "content/renderer/render_thread_impl.h" 8 #include "content/renderer/render_thread_impl.h"
8 #include "gpu/ipc/client/gpu_channel_host.h" 9 #include "gpu/ipc/client/gpu_channel_host.h"
9 #include "gpu/ipc/common/gpu_messages.h" 10 #include "gpu/ipc/common/gpu_messages.h"
10 #include "ipc/ipc_message_macros.h" 11 #include "ipc/ipc_message_macros.h"
11 12
12 namespace content { 13 namespace content {
13 14
14 StreamTextureHost::StreamTextureHost(scoped_refptr<gpu::GpuChannelHost> channel) 15 StreamTextureHost::StreamTextureHost(scoped_refptr<gpu::GpuChannelHost> channel,
15 : stream_id_(0), 16 int32_t route_id)
17 : route_id_(route_id),
16 listener_(NULL), 18 listener_(NULL),
17 channel_(std::move(channel)), 19 channel_(std::move(channel)),
18 weak_ptr_factory_(this) { 20 weak_ptr_factory_(this) {
19 DCHECK(channel_); 21 DCHECK(channel_);
20 } 22 }
21 23
22 StreamTextureHost::~StreamTextureHost() { 24 StreamTextureHost::~StreamTextureHost() {
23 if (channel_.get() && stream_id_) 25 if (channel_.get() && route_id_)
24 channel_->RemoveRoute(stream_id_); 26 channel_->RemoveRoute(route_id_);
25 } 27 }
26 28
27 bool StreamTextureHost::BindToCurrentThread(int32_t stream_id, 29 bool StreamTextureHost::BindToCurrentThread(Listener* listener) {
28 Listener* listener) {
29 listener_ = listener; 30 listener_ = listener;
30 if (channel_.get() && stream_id && !stream_id_) { 31 if (channel_.get() && route_id_) {
31 stream_id_ = stream_id; 32 channel_->AddRoute(route_id_, weak_ptr_factory_.GetWeakPtr());
32 channel_->AddRoute(stream_id, weak_ptr_factory_.GetWeakPtr()); 33 channel_->Send(new GpuStreamTextureMsg_StartListening(route_id_));
33 channel_->Send(new GpuStreamTextureMsg_StartListening(stream_id));
34 return true; 34 return true;
35 } 35 }
36 36
37 return false; 37 return false;
38 } 38 }
39 39
40 bool StreamTextureHost::OnMessageReceived(const IPC::Message& message) { 40 bool StreamTextureHost::OnMessageReceived(const IPC::Message& message) {
41 bool handled = true; 41 bool handled = true;
42 IPC_BEGIN_MESSAGE_MAP(StreamTextureHost, message) 42 IPC_BEGIN_MESSAGE_MAP(StreamTextureHost, message)
43 IPC_MESSAGE_HANDLER(GpuStreamTextureMsg_FrameAvailable, 43 IPC_MESSAGE_HANDLER(GpuStreamTextureMsg_FrameAvailable,
44 OnFrameAvailable); 44 OnFrameAvailable);
45 IPC_MESSAGE_UNHANDLED(handled = false) 45 IPC_MESSAGE_UNHANDLED(handled = false)
46 IPC_END_MESSAGE_MAP() 46 IPC_END_MESSAGE_MAP()
47 DCHECK(handled); 47 DCHECK(handled);
48 return handled; 48 return handled;
49 } 49 }
50 50
51 void StreamTextureHost::OnChannelError() { 51 void StreamTextureHost::OnChannelError() {
52 } 52 }
53 53
54 void StreamTextureHost::OnFrameAvailable() { 54 void StreamTextureHost::OnFrameAvailable() {
55 if (listener_) 55 if (listener_)
56 listener_->OnFrameAvailable(); 56 listener_->OnFrameAvailable();
57 } 57 }
58 58
59 void StreamTextureHost::EstablishPeer(int player_id, int frame_id) {
60 if (route_id_) {
61 channel_->Send(
62 new GpuStreamTextureMsg_EstablishPeer(route_id_, frame_id, player_id));
Ken Russell (switch to Gerrit) 2016/10/10 23:34:24 Not knowing this API, it seems strange that the fr
sivag 2016/10/12 11:25:33 its used to get the MediaPlayer from the manager a
63 }
64 }
65
66 void StreamTextureHost::SetStreamTextureSize(const gfx::Size& size) {
67 if (route_id_)
68 channel_->Send(new GpuStreamTextureMsg_SetSize(route_id_, size));
69 }
70
71 void StreamTextureHost::ForwardStreamTextureForSurfaceRequest(
72 const base::UnguessableToken& request_token) {
73 if (route_id_) {
74 channel_->Send(new GpuStreamTextureMsg_ForwardForSurfaceRequest(
75 route_id_, request_token));
76 }
77 }
78
59 } // namespace content 79 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698