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 "media/gpu/ipc/service/media_gpu_channel.h" | 5 #include "media/gpu/ipc/service/media_gpu_channel.h" |
6 | 6 |
7 #include "base/single_thread_task_runner.h" | 7 #include "base/single_thread_task_runner.h" |
8 #include "base/unguessable_token.h" | 8 #include "base/unguessable_token.h" |
9 #include "gpu/ipc/service/gpu_channel.h" | 9 #include "gpu/ipc/service/gpu_channel.h" |
10 #include "ipc/message_filter.h" | 10 #include "ipc/message_filter.h" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 bool MediaGpuChannel::OnMessageReceived(const IPC::Message& message) { | 97 bool MediaGpuChannel::OnMessageReceived(const IPC::Message& message) { |
98 MediaGpuChannelDispatchHelper helper(this, message.routing_id()); | 98 MediaGpuChannelDispatchHelper helper(this, message.routing_id()); |
99 bool handled = true; | 99 bool handled = true; |
100 IPC_BEGIN_MESSAGE_MAP(MediaGpuChannel, message) | 100 IPC_BEGIN_MESSAGE_MAP(MediaGpuChannel, message) |
101 IPC_MESSAGE_FORWARD_DELAY_REPLY( | 101 IPC_MESSAGE_FORWARD_DELAY_REPLY( |
102 GpuCommandBufferMsg_CreateVideoDecoder, &helper, | 102 GpuCommandBufferMsg_CreateVideoDecoder, &helper, |
103 MediaGpuChannelDispatchHelper::OnCreateVideoDecoder) | 103 MediaGpuChannelDispatchHelper::OnCreateVideoDecoder) |
104 IPC_MESSAGE_FORWARD_DELAY_REPLY( | 104 IPC_MESSAGE_FORWARD_DELAY_REPLY( |
105 GpuCommandBufferMsg_CreateVideoEncoder, &helper, | 105 GpuCommandBufferMsg_CreateVideoEncoder, &helper, |
106 MediaGpuChannelDispatchHelper::OnCreateVideoEncoder) | 106 MediaGpuChannelDispatchHelper::OnCreateVideoEncoder) |
107 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuChannelMsg_CreateJpegDecoder, | |
108 OnCreateJpegDecoder) | |
109 IPC_MESSAGE_UNHANDLED(handled = false) | 107 IPC_MESSAGE_UNHANDLED(handled = false) |
110 IPC_END_MESSAGE_MAP() | 108 IPC_END_MESSAGE_MAP() |
111 return handled; | 109 return handled; |
112 } | 110 } |
113 | 111 |
114 namespace { | |
115 | |
116 void SendCreateJpegDecoderResult( | |
117 std::unique_ptr<IPC::Message> reply_message, | |
118 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, | |
119 base::WeakPtr<IPC::Sender> channel, | |
120 scoped_refptr<MediaGpuChannelFilter> filter, | |
121 bool result) { | |
122 GpuChannelMsg_CreateJpegDecoder::WriteReplyParams(reply_message.get(), | |
123 result); | |
124 if (io_task_runner->BelongsToCurrentThread()) { | |
125 filter->Send(reply_message.release()); | |
126 } else if (channel) { | |
127 channel->Send(reply_message.release()); | |
128 } | |
129 } | |
130 | |
131 } // namespace | |
132 | |
133 void MediaGpuChannel::OnCreateJpegDecoder(int32_t route_id, | |
134 IPC::Message* reply_msg) { | |
135 std::unique_ptr<IPC::Message> msg(reply_msg); | |
136 if (!jpeg_decoder_) { | |
137 // The lifetime of |jpeg_decoder_| is managed by a gpu::GpuChannel. The | |
138 // GpuChannels destroy all the GpuJpegDecodeAccelerator that they own when | |
139 // they are destroyed. Therefore, passing |channel_| as a raw pointer is | |
140 // safe. | |
141 jpeg_decoder_.reset( | |
142 new GpuJpegDecodeAccelerator(channel_, channel_->io_task_runner())); | |
143 } | |
144 jpeg_decoder_->AddClient( | |
145 route_id, | |
146 base::Bind(&SendCreateJpegDecoderResult, base::Passed(&msg), | |
147 channel_->io_task_runner(), channel_->AsWeakPtr(), filter_)); | |
148 } | |
149 | |
150 void MediaGpuChannel::OnCreateVideoDecoder( | 112 void MediaGpuChannel::OnCreateVideoDecoder( |
151 int32_t command_buffer_route_id, | 113 int32_t command_buffer_route_id, |
152 const VideoDecodeAccelerator::Config& config, | 114 const VideoDecodeAccelerator::Config& config, |
153 int32_t decoder_route_id, | 115 int32_t decoder_route_id, |
154 IPC::Message* reply_message) { | 116 IPC::Message* reply_message) { |
155 TRACE_EVENT0("gpu", "MediaGpuChannel::OnCreateVideoDecoder"); | 117 TRACE_EVENT0("gpu", "MediaGpuChannel::OnCreateVideoDecoder"); |
156 gpu::GpuCommandBufferStub* stub = | 118 gpu::GpuCommandBufferStub* stub = |
157 channel_->LookupCommandBuffer(command_buffer_route_id); | 119 channel_->LookupCommandBuffer(command_buffer_route_id); |
158 if (!stub) { | 120 if (!stub) { |
159 reply_message->set_reply_error(); | 121 reply_message->set_reply_error(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 params.output_profile, params.initial_bitrate); | 153 params.output_profile, params.initial_bitrate); |
192 GpuCommandBufferMsg_CreateVideoEncoder::WriteReplyParams(reply_message, | 154 GpuCommandBufferMsg_CreateVideoEncoder::WriteReplyParams(reply_message, |
193 succeeded); | 155 succeeded); |
194 Send(reply_message); | 156 Send(reply_message); |
195 | 157 |
196 // encoder is registered as a DestructionObserver of this stub and will | 158 // encoder is registered as a DestructionObserver of this stub and will |
197 // self-delete during destruction of this stub. | 159 // self-delete during destruction of this stub. |
198 } | 160 } |
199 | 161 |
200 } // namespace media | 162 } // namespace media |
OLD | NEW |