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

Side by Side Diff: content/common/gpu/media/media_channel.cc

Issue 1736643005: Decouple Media Service (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Another try to fix Windows Created 4 years, 9 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/common/gpu/media/media_channel.h"
6
7 #include "content/common/gpu/gpu_channel.h"
8 #include "content/common/gpu/media/gpu_video_decode_accelerator.h"
9 #include "content/common/gpu/media/gpu_video_encode_accelerator.h"
10 #include "content/common/gpu/media/media_messages.h"
11
12 namespace content {
13
14 namespace {
15
16 void SendCreateJpegDecoderResult(
17 scoped_ptr<IPC::Message> reply_message,
18 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
19 base::WeakPtr<GpuChannel> channel,
20 scoped_refptr<GpuChannelMessageFilter> filter,
21 bool result) {
22 GpuChannelMsg_CreateJpegDecoder::WriteReplyParams(reply_message.get(),
23 result);
24 if (io_task_runner->BelongsToCurrentThread()) {
25 filter->Send(reply_message.release());
26 } else if (channel) {
27 channel->Send(reply_message.release());
28 }
29 }
30
31 } // namespace
32
33 MediaChannel::MediaChannel(GpuChannel* channel) : channel_(channel) {}
34
35 MediaChannel::~MediaChannel() {}
36
37 bool MediaChannel::Send(IPC::Message* msg) {
38 return channel_->Send(msg);
39 }
40
41 bool MediaChannel::OnMessageReceived(const IPC::Message& message) {
42 GpuCommandBufferStub* stub =
43 channel_->LookupCommandBuffer(message.routing_id());
44 DCHECK(stub);
45 bool handled = true;
46 IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(MediaChannel, message, stub)
47 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_CreateVideoDecoder,
48 OnCreateVideoDecoder)
49 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_CreateVideoEncoder,
50 OnCreateVideoEncoder)
51 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuChannelMsg_CreateJpegDecoder,
52 OnCreateJpegDecoder)
53 IPC_MESSAGE_UNHANDLED(handled = false)
54 IPC_END_MESSAGE_MAP()
55 return handled;
56 }
57
58 void MediaChannel::OnCreateJpegDecoder(GpuCommandBufferStub* stub,
59 int32_t route_id,
60 IPC::Message* reply_msg) {
61 scoped_ptr<IPC::Message> msg(reply_msg);
62 if (!jpeg_decoder_) {
63 jpeg_decoder_.reset(
64 new GpuJpegDecodeAccelerator(channel_, channel_->io_task_runner()));
65 }
66 jpeg_decoder_->AddClient(
67 route_id, base::Bind(&SendCreateJpegDecoderResult, base::Passed(&msg),
68 channel_->io_task_runner(), channel_->AsWeakPtr(),
69 make_scoped_refptr(channel_->filter())));
70 }
71
72 void MediaChannel::OnCreateVideoDecoder(
73 GpuCommandBufferStub* stub,
74 const media::VideoDecodeAccelerator::Config& config,
75 int32_t decoder_route_id,
76 IPC::Message* reply_message) {
77 TRACE_EVENT0("gpu", "MediaChannel::OnCreateVideoDecoder");
78 GpuVideoDecodeAccelerator* decoder = new GpuVideoDecodeAccelerator(
79 decoder_route_id, stub, stub->channel()->io_task_runner());
80 bool succeeded = decoder->Initialize(config);
81 GpuCommandBufferMsg_CreateVideoDecoder::WriteReplyParams(reply_message,
82 succeeded);
83 Send(reply_message);
84
85 // decoder is registered as a DestructionObserver of this stub and will
86 // self-delete during destruction of this stub.
87 }
88
89 void MediaChannel::OnCreateVideoEncoder(GpuCommandBufferStub* stub,
90 media::VideoPixelFormat input_format,
91 const gfx::Size& input_visible_size,
92 media::VideoCodecProfile output_profile,
93 uint32_t initial_bitrate,
94 int32_t encoder_route_id,
95 IPC::Message* reply_message) {
96 TRACE_EVENT0("gpu", "MediaChannel::OnCreateVideoEncoder");
97 GpuVideoEncodeAccelerator* encoder =
98 new GpuVideoEncodeAccelerator(encoder_route_id, stub);
99 bool succeeded = encoder->Initialize(input_format, input_visible_size,
100 output_profile, initial_bitrate);
101 GpuCommandBufferMsg_CreateVideoEncoder::WriteReplyParams(reply_message,
102 succeeded);
103 Send(reply_message);
104
105 // encoder is registered as a DestructionObserver of this stub and will
106 // self-delete during destruction of this stub.
107 }
108
109 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698