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_channel.h" | 5 #include "media/gpu/ipc/service/media_channel.h" |
6 | 6 |
7 #include "gpu/ipc/service/gpu_channel.h" | 7 #include "gpu/ipc/service/gpu_channel.h" |
8 #include "media/gpu/ipc/common/media_messages.h" | 8 #include "media/gpu/ipc/common/media_messages.h" |
9 #include "media/gpu/ipc/service/gpu_video_decode_accelerator.h" | 9 #include "media/gpu/ipc/service/gpu_video_decode_accelerator.h" |
10 #include "media/gpu/ipc/service/gpu_video_encode_accelerator.h" | 10 #include "media/gpu/ipc/service/gpu_video_encode_accelerator.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 } // namespace | 31 } // namespace |
32 | 32 |
33 class MediaChannelDispatchHelper { | 33 class MediaChannelDispatchHelper { |
34 public: | 34 public: |
35 MediaChannelDispatchHelper(MediaChannel* channel, int32_t routing_id) | 35 MediaChannelDispatchHelper(MediaChannel* channel, int32_t routing_id) |
36 : channel_(channel), routing_id_(routing_id) {} | 36 : channel_(channel), routing_id_(routing_id) {} |
37 | 37 |
38 bool Send(IPC::Message* msg) { return channel_->Send(msg); } | 38 bool Send(IPC::Message* msg) { return channel_->Send(msg); } |
39 | 39 |
40 void OnCreateVideoDecoder(const media::VideoDecodeAccelerator::Config& config, | 40 void OnCreateVideoDecoder(const VideoDecodeAccelerator::Config& config, |
41 int32_t decoder_route_id, | 41 int32_t decoder_route_id, |
42 IPC::Message* reply_message) { | 42 IPC::Message* reply_message) { |
43 channel_->OnCreateVideoDecoder(routing_id_, config, decoder_route_id, | 43 channel_->OnCreateVideoDecoder(routing_id_, config, decoder_route_id, |
44 reply_message); | 44 reply_message); |
45 } | 45 } |
46 | 46 |
47 void OnCreateVideoEncoder(const media::CreateVideoEncoderParams& params, | 47 void OnCreateVideoEncoder(const CreateVideoEncoderParams& params, |
48 IPC::Message* reply_message) { | 48 IPC::Message* reply_message) { |
49 channel_->OnCreateVideoEncoder(routing_id_, params, reply_message); | 49 channel_->OnCreateVideoEncoder(routing_id_, params, reply_message); |
50 } | 50 } |
51 | 51 |
52 private: | 52 private: |
53 MediaChannel* const channel_; | 53 MediaChannel* const channel_; |
54 const int32_t routing_id_; | 54 const int32_t routing_id_; |
55 DISALLOW_COPY_AND_ASSIGN(MediaChannelDispatchHelper); | 55 DISALLOW_COPY_AND_ASSIGN(MediaChannelDispatchHelper); |
56 }; | 56 }; |
57 | 57 |
(...skipping 30 matching lines...) Expand all Loading... |
88 new GpuJpegDecodeAccelerator(channel_, channel_->io_task_runner())); | 88 new GpuJpegDecodeAccelerator(channel_, channel_->io_task_runner())); |
89 } | 89 } |
90 jpeg_decoder_->AddClient( | 90 jpeg_decoder_->AddClient( |
91 route_id, base::Bind(&SendCreateJpegDecoderResult, base::Passed(&msg), | 91 route_id, base::Bind(&SendCreateJpegDecoderResult, base::Passed(&msg), |
92 channel_->io_task_runner(), channel_->AsWeakPtr(), | 92 channel_->io_task_runner(), channel_->AsWeakPtr(), |
93 make_scoped_refptr(channel_->filter()))); | 93 make_scoped_refptr(channel_->filter()))); |
94 } | 94 } |
95 | 95 |
96 void MediaChannel::OnCreateVideoDecoder( | 96 void MediaChannel::OnCreateVideoDecoder( |
97 int32_t command_buffer_route_id, | 97 int32_t command_buffer_route_id, |
98 const media::VideoDecodeAccelerator::Config& config, | 98 const VideoDecodeAccelerator::Config& config, |
99 int32_t decoder_route_id, | 99 int32_t decoder_route_id, |
100 IPC::Message* reply_message) { | 100 IPC::Message* reply_message) { |
101 TRACE_EVENT0("gpu", "MediaChannel::OnCreateVideoDecoder"); | 101 TRACE_EVENT0("gpu", "MediaChannel::OnCreateVideoDecoder"); |
102 gpu::GpuCommandBufferStub* stub = | 102 gpu::GpuCommandBufferStub* stub = |
103 channel_->LookupCommandBuffer(command_buffer_route_id); | 103 channel_->LookupCommandBuffer(command_buffer_route_id); |
104 if (!stub) { | 104 if (!stub) { |
105 reply_message->set_reply_error(); | 105 reply_message->set_reply_error(); |
106 Send(reply_message); | 106 Send(reply_message); |
107 return; | 107 return; |
108 } | 108 } |
109 GpuVideoDecodeAccelerator* decoder = new GpuVideoDecodeAccelerator( | 109 GpuVideoDecodeAccelerator* decoder = new GpuVideoDecodeAccelerator( |
110 decoder_route_id, stub, stub->channel()->io_task_runner()); | 110 decoder_route_id, stub, stub->channel()->io_task_runner()); |
111 bool succeeded = decoder->Initialize(config); | 111 bool succeeded = decoder->Initialize(config); |
112 GpuCommandBufferMsg_CreateVideoDecoder::WriteReplyParams(reply_message, | 112 GpuCommandBufferMsg_CreateVideoDecoder::WriteReplyParams(reply_message, |
113 succeeded); | 113 succeeded); |
114 Send(reply_message); | 114 Send(reply_message); |
115 | 115 |
116 // decoder is registered as a DestructionObserver of this stub and will | 116 // decoder is registered as a DestructionObserver of this stub and will |
117 // self-delete during destruction of this stub. | 117 // self-delete during destruction of this stub. |
118 } | 118 } |
119 | 119 |
120 void MediaChannel::OnCreateVideoEncoder( | 120 void MediaChannel::OnCreateVideoEncoder(int32_t command_buffer_route_id, |
121 int32_t command_buffer_route_id, | 121 const CreateVideoEncoderParams& params, |
122 const media::CreateVideoEncoderParams& params, | 122 IPC::Message* reply_message) { |
123 IPC::Message* reply_message) { | |
124 TRACE_EVENT0("gpu", "MediaChannel::OnCreateVideoEncoder"); | 123 TRACE_EVENT0("gpu", "MediaChannel::OnCreateVideoEncoder"); |
125 gpu::GpuCommandBufferStub* stub = | 124 gpu::GpuCommandBufferStub* stub = |
126 channel_->LookupCommandBuffer(command_buffer_route_id); | 125 channel_->LookupCommandBuffer(command_buffer_route_id); |
127 if (!stub) { | 126 if (!stub) { |
128 reply_message->set_reply_error(); | 127 reply_message->set_reply_error(); |
129 Send(reply_message); | 128 Send(reply_message); |
130 return; | 129 return; |
131 } | 130 } |
132 GpuVideoEncodeAccelerator* encoder = | 131 GpuVideoEncodeAccelerator* encoder = |
133 new GpuVideoEncodeAccelerator(params.encoder_route_id, stub); | 132 new GpuVideoEncodeAccelerator(params.encoder_route_id, stub); |
134 bool succeeded = | 133 bool succeeded = |
135 encoder->Initialize(params.input_format, params.input_visible_size, | 134 encoder->Initialize(params.input_format, params.input_visible_size, |
136 params.output_profile, params.initial_bitrate); | 135 params.output_profile, params.initial_bitrate); |
137 GpuCommandBufferMsg_CreateVideoEncoder::WriteReplyParams(reply_message, | 136 GpuCommandBufferMsg_CreateVideoEncoder::WriteReplyParams(reply_message, |
138 succeeded); | 137 succeeded); |
139 Send(reply_message); | 138 Send(reply_message); |
140 | 139 |
141 // encoder is registered as a DestructionObserver of this stub and will | 140 // encoder is registered as a DestructionObserver of this stub and will |
142 // self-delete during destruction of this stub. | 141 // self-delete during destruction of this stub. |
143 } | 142 } |
144 | 143 |
145 } // namespace media | 144 } // namespace media |
OLD | NEW |