Chromium Code Reviews| 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 "base/unguessable_token.h" | |
| 7 #include "gpu/ipc/service/gpu_channel.h" | 8 #include "gpu/ipc/service/gpu_channel.h" |
| 9 #include "ipc/message_filter.h" | |
| 8 #include "media/gpu/ipc/common/media_messages.h" | 10 #include "media/gpu/ipc/common/media_messages.h" |
| 9 #include "media/gpu/ipc/service/gpu_video_decode_accelerator.h" | 11 #include "media/gpu/ipc/service/gpu_video_decode_accelerator.h" |
| 10 #include "media/gpu/ipc/service/gpu_video_encode_accelerator.h" | 12 #include "media/gpu/ipc/service/gpu_video_encode_accelerator.h" |
| 11 | 13 |
| 12 namespace media { | 14 namespace media { |
| 13 | 15 |
| 14 namespace { | 16 namespace { |
| 15 | 17 |
| 16 void SendCreateJpegDecoderResult( | 18 void SendCreateJpegDecoderResult( |
| 17 std::unique_ptr<IPC::Message> reply_message, | 19 std::unique_ptr<IPC::Message> reply_message, |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 48 IPC::Message* reply_message) { | 50 IPC::Message* reply_message) { |
| 49 channel_->OnCreateVideoEncoder(routing_id_, params, reply_message); | 51 channel_->OnCreateVideoEncoder(routing_id_, params, reply_message); |
| 50 } | 52 } |
| 51 | 53 |
| 52 private: | 54 private: |
| 53 MediaChannel* const channel_; | 55 MediaChannel* const channel_; |
| 54 const int32_t routing_id_; | 56 const int32_t routing_id_; |
| 55 DISALLOW_COPY_AND_ASSIGN(MediaChannelDispatchHelper); | 57 DISALLOW_COPY_AND_ASSIGN(MediaChannelDispatchHelper); |
| 56 }; | 58 }; |
| 57 | 59 |
| 58 MediaChannel::MediaChannel(gpu::GpuChannel* channel) : channel_(channel) {} | 60 // Filter to respond to GetChannelToken on the IO thread. |
| 61 class MediaChannelFilter : public IPC::MessageFilter { | |
| 62 public: | |
| 63 explicit MediaChannelFilter(base::UnguessableToken channel_token) | |
|
tguilbert
2016/09/19 22:32:23
I think the official guidance danakj gave us is to
sandersd (OOO until July 31)
2016/09/19 22:40:33
Very well then.
| |
| 64 : channel_token_(channel_token) {} | |
| 65 | |
| 66 void OnFilterAdded(IPC::Channel* channel) override { channel_ = channel; } | |
| 67 bool Send(IPC::Message* msg) { return channel_->Send(msg); } | |
| 68 | |
| 69 bool OnMessageReceived(const IPC::Message& msg) override { | |
| 70 bool handled = true; | |
| 71 IPC_BEGIN_MESSAGE_MAP(MediaChannelFilter, msg) | |
| 72 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_GetChannelToken, | |
| 73 OnGetChannelToken) | |
| 74 IPC_MESSAGE_UNHANDLED(handled = false) | |
| 75 IPC_END_MESSAGE_MAP() | |
| 76 return handled; | |
| 77 } | |
| 78 | |
| 79 void OnGetChannelToken(IPC::Message* reply_message) { | |
| 80 GpuCommandBufferMsg_GetChannelToken::WriteReplyParams(reply_message, | |
| 81 channel_token_); | |
| 82 Send(reply_message); | |
| 83 } | |
| 84 | |
| 85 private: | |
| 86 ~MediaChannelFilter() override {} | |
| 87 | |
| 88 IPC::Channel* channel_; | |
| 89 base::UnguessableToken channel_token_; | |
| 90 }; | |
| 91 | |
| 92 MediaChannel::MediaChannel(gpu::GpuChannel* channel) : channel_(channel) { | |
| 93 channel_->AddFilter(new MediaChannelFilter(base::UnguessableToken::Create())); | |
| 94 } | |
| 59 | 95 |
| 60 MediaChannel::~MediaChannel() {} | 96 MediaChannel::~MediaChannel() {} |
| 61 | 97 |
| 62 bool MediaChannel::Send(IPC::Message* msg) { | 98 bool MediaChannel::Send(IPC::Message* msg) { |
| 63 return channel_->Send(msg); | 99 return channel_->Send(msg); |
| 64 } | 100 } |
| 65 | 101 |
| 66 bool MediaChannel::OnMessageReceived(const IPC::Message& message) { | 102 bool MediaChannel::OnMessageReceived(const IPC::Message& message) { |
| 67 MediaChannelDispatchHelper helper(this, message.routing_id()); | 103 MediaChannelDispatchHelper helper(this, message.routing_id()); |
| 68 bool handled = true; | 104 bool handled = true; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 135 params.output_profile, params.initial_bitrate); | 171 params.output_profile, params.initial_bitrate); |
| 136 GpuCommandBufferMsg_CreateVideoEncoder::WriteReplyParams(reply_message, | 172 GpuCommandBufferMsg_CreateVideoEncoder::WriteReplyParams(reply_message, |
| 137 succeeded); | 173 succeeded); |
| 138 Send(reply_message); | 174 Send(reply_message); |
| 139 | 175 |
| 140 // encoder is registered as a DestructionObserver of this stub and will | 176 // encoder is registered as a DestructionObserver of this stub and will |
| 141 // self-delete during destruction of this stub. | 177 // self-delete during destruction of this stub. |
| 142 } | 178 } |
| 143 | 179 |
| 144 } // namespace media | 180 } // namespace media |
| OLD | NEW |