Remove Unused AsTextButtonBorder RTTI helper.
[chromium-blink-merge.git] / media / cast / test / fake_video_encode_accelerator.cc
bloba766f894e249106cd9409986d7db15183e392d28
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"
9 namespace media {
10 namespace cast {
11 namespace test {
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) {
19 DCHECK(client);
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) {
29 DCHECK(client_);
31 if (output_profile != media::VP8PROFILE_MAIN &&
32 output_profile != media::H264PROFILE_MAIN) {
33 client_->NotifyError(kInvalidArgumentError);
34 return;
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) {
43 DCHECK(client_);
44 DCHECK(!available_buffer_ids_.empty());
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();
51 bool is_key_fame = force_keyframe;
52 if (first_) {
53 is_key_fame = true;
54 first_ = false;
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(
65 uint32 bitrate,
66 uint32 framerate) {
67 // No-op.
70 void FakeVideoEncodeAccelerator::Destroy() { delete this; }
72 } // namespace test
73 } // namespace cast
74 } // namespace media