Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 | |
| OLD | NEW |