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

Side by Side Diff: media/cast/test/fake_video_encode_accelerator.cc

Issue 116623002: Cast: Adding support for GPU accelerated encode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed dependency on content Created 7 years 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 2013 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 "media/cast/test/fake_video_encode_accelerator.h"
6
7 namespace media {
8 namespace cast {
9 namespace test {
10
11 static const unsigned int kMinimumInputCount = 1;
12 static const size_t kMinimumOutputBufferSize = 123456;
13
14 FakeVideoEncodeAccelerator::FakeVideoEncodeAccelerator(
15 VideoEncodeAccelerator::Client* client)
16 : client_(client ),
mikhal1 2013/12/17 22:39:47 remove extra space
pwestin 2013/12/19 16:03:47 Done.
17 first_(true) {
mikhal1 2013/12/17 22:39:47 DCHECK on client?
pwestin 2013/12/19 16:03:47 Done.
18 }
19
20 FakeVideoEncodeAccelerator::~FakeVideoEncodeAccelerator() {
21 }
22
23 void FakeVideoEncodeAccelerator::Initialize(
24 media::VideoFrame::Format input_format,
25 const gfx::Size& input_visible_size,
26 VideoCodecProfile output_profile,
27 uint32 initial_bitrate) {
28 DCHECK(client_);
29
30 if (output_profile != media::VP8PROFILE_MAIN &&
31 output_profile != media::H264PROFILE_MAIN) {
32 client_->NotifyError(kInvalidArgumentError);
33 return;
34 }
35 client_->NotifyInitializeDone();
36 client_->RequireBitstreamBuffers(kMinimumInputCount,
37 input_visible_size,
38 kMinimumOutputBufferSize);
39 }
40
41 void FakeVideoEncodeAccelerator::Encode(const scoped_refptr<VideoFrame>& frame,
42 bool force_keyframe) {
43 DCHECK(client_);
44 DCHECK(!available_buffer_ids_.empty());
45
46 // Fake that we have encoded the frame; resulting in using the full output
47 // buffer.
48 int32 id = available_buffer_ids_.front();
49 available_buffer_ids_.pop_front();
50
51 bool is_key_fame = force_keyframe;
52 if (first_) {
mikhal1 2013/12/17 22:39:47 If it's the first frame, won't the encoder create
pwestin 2013/12/19 16:03:47 in normal case yes but this is a fake encoder, no
53 is_key_fame = true;
54 first_ = false;
55 }
56 client_->BitstreamBufferReady(id, kMinimumOutputBufferSize, is_key_fame);
57 }
58
59 void FakeVideoEncodeAccelerator::UseOutputBitstreamBuffer(
60 const BitstreamBuffer& buffer) {
61 available_buffer_ids_.push_back(buffer.id());
62 }
63
64 void FakeVideoEncodeAccelerator::RequestEncodingParametersChange(
65 uint32 bitrate, uint32 framerate) {
66 // No-op.
mikhal1 2013/12/17 22:39:47 What does this mean?
pwestin 2013/12/19 16:03:47 No operation; frequently used in chrome ~940 times
67 }
68
69 void FakeVideoEncodeAccelerator::Destroy() {
70 delete this;
71 }
72
73 } // namespace test
74 } // namespace cast
75 } // namespace media
76
77
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698