1 // Copyright 2014 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.
5 #include "media/cast/test/fake_video_encode_accelerator.h"
7 #include "base/logging.h"
13 static const unsigned int kMinimumInputCount
= 1;
14 static const size_t kMinimumOutputBufferSize
= 123456;
16 FakeVideoEncodeAccelerator::FakeVideoEncodeAccelerator(
17 VideoEncodeAccelerator::Client
* client
)
18 : client_(client
), first_(true) {
22 FakeVideoEncodeAccelerator::~FakeVideoEncodeAccelerator() {}
24 void FakeVideoEncodeAccelerator::Initialize(
25 media::VideoFrame::Format input_format
,
26 const gfx::Size
& input_visible_size
,
27 VideoCodecProfile output_profile
,
28 uint32 initial_bitrate
) {
31 if (output_profile
!= media::VP8PROFILE_MAIN
&&
32 output_profile
!= media::H264PROFILE_MAIN
) {
33 client_
->NotifyError(kInvalidArgumentError
);
36 client_
->NotifyInitializeDone();
37 client_
->RequireBitstreamBuffers(
38 kMinimumInputCount
, input_visible_size
, kMinimumOutputBufferSize
);
41 void FakeVideoEncodeAccelerator::Encode(const scoped_refptr
<VideoFrame
>& frame
,
42 bool force_keyframe
) {
44 DCHECK(!available_buffer_ids_
.empty());
46 // Fake that we have encoded the frame; resulting in using the full output
48 int32 id
= available_buffer_ids_
.front();
49 available_buffer_ids_
.pop_front();
51 bool is_key_fame
= force_keyframe
;
56 client_
->BitstreamBufferReady(id
, kMinimumOutputBufferSize
, is_key_fame
);
59 void FakeVideoEncodeAccelerator::UseOutputBitstreamBuffer(
60 const BitstreamBuffer
& buffer
) {
61 available_buffer_ids_
.push_back(buffer
.id());
64 void FakeVideoEncodeAccelerator::RequestEncodingParametersChange(
70 void FakeVideoEncodeAccelerator::Destroy() { delete this; }