1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/renderer/pepper_platform_video_decoder_impl.h"
#include <vector>
#include "base/bind.h"
#include "base/logging.h"
#include "content/common/child_process.h"
#include "content/renderer/gpu/gpu_channel_host.h"
#include "content/renderer/render_thread.h"
using media::BitstreamBuffer;
PlatformVideoDecoderImpl::PlatformVideoDecoderImpl(
VideoDecodeAccelerator::Client* client,
int32 command_buffer_route_id,
gpu::CommandBufferHelper* cmd_buffer_helper)
: client_(client),
command_buffer_route_id_(command_buffer_route_id),
cmd_buffer_helper_(cmd_buffer_helper) {
DCHECK(client);
}
PlatformVideoDecoderImpl::~PlatformVideoDecoderImpl() {}
bool PlatformVideoDecoderImpl::Initialize(const std::vector<uint32>& configs) {
// TODO(vrk): Support multiple decoders.
if (decoder_)
return true;
RenderThread* render_thread = RenderThread::current();
DCHECK(render_thread);
// This is not synchronous, but subsequent IPC messages will be buffered, so
// it is okay to immediately send IPC messages through the returned channel.
GpuChannelHost* channel =
render_thread->EstablishGpuChannelSync(
content::CAUSE_FOR_GPU_LAUNCH_VIDEODECODEACCELERATOR_INITIALIZE);
if (!channel)
return false;
DCHECK_EQ(channel->state(), GpuChannelHost::kConnected);
// Send IPC message to initialize decoder in GPU process.
decoder_ = channel->CreateVideoDecoder(
command_buffer_route_id_, configs, cmd_buffer_helper_, this);
return true;
}
void PlatformVideoDecoderImpl::Decode(const BitstreamBuffer& bitstream_buffer) {
DCHECK(decoder_);
decoder_->Decode(bitstream_buffer);
}
void PlatformVideoDecoderImpl::AssignPictureBuffers(
const std::vector<media::PictureBuffer>& buffers) {
DCHECK(decoder_);
decoder_->AssignPictureBuffers(buffers);
}
void PlatformVideoDecoderImpl::ReusePictureBuffer(
int32 picture_buffer_id) {
DCHECK(decoder_);
decoder_->ReusePictureBuffer(picture_buffer_id);
}
void PlatformVideoDecoderImpl::Flush() {
DCHECK(decoder_);
decoder_->Flush();
}
void PlatformVideoDecoderImpl::Reset() {
DCHECK(decoder_);
decoder_->Reset();
}
void PlatformVideoDecoderImpl::Destroy() {
DCHECK(decoder_);
decoder_->Destroy();
}
void PlatformVideoDecoderImpl::NotifyEndOfStream() {
DCHECK_EQ(RenderThread::current()->message_loop(), MessageLoop::current());
client_->NotifyEndOfStream();
}
void PlatformVideoDecoderImpl::NotifyError(
VideoDecodeAccelerator::Error error) {
DCHECK_EQ(RenderThread::current()->message_loop(), MessageLoop::current());
client_->NotifyError(error);
}
void PlatformVideoDecoderImpl::ProvidePictureBuffers(
uint32 requested_num_of_buffers,
const gfx::Size& dimensions) {
DCHECK_EQ(RenderThread::current()->message_loop(), MessageLoop::current());
client_->ProvidePictureBuffers(requested_num_of_buffers, dimensions);
}
void PlatformVideoDecoderImpl::DismissPictureBuffer(int32 picture_buffer_id) {
DCHECK_EQ(RenderThread::current()->message_loop(), MessageLoop::current());
client_->DismissPictureBuffer(picture_buffer_id);
}
void PlatformVideoDecoderImpl::PictureReady(const media::Picture& picture) {
DCHECK_EQ(RenderThread::current()->message_loop(), MessageLoop::current());
client_->PictureReady(picture);
}
void PlatformVideoDecoderImpl::NotifyInitializeDone() {
DCHECK_EQ(RenderThread::current()->message_loop(), MessageLoop::current());
client_->NotifyInitializeDone();
}
void PlatformVideoDecoderImpl::NotifyEndOfBitstreamBuffer(
int32 bitstream_buffer_id) {
DCHECK_EQ(RenderThread::current()->message_loop(), MessageLoop::current());
client_->NotifyEndOfBitstreamBuffer(bitstream_buffer_id);
}
void PlatformVideoDecoderImpl::NotifyFlushDone() {
DCHECK_EQ(RenderThread::current()->message_loop(), MessageLoop::current());
client_->NotifyFlushDone();
}
void PlatformVideoDecoderImpl::NotifyResetDone() {
DCHECK_EQ(RenderThread::current()->message_loop(), MessageLoop::current());
client_->NotifyResetDone();
}
|