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

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: Fixed merge nits Created 6 years, 11 months 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 #include "base/logging.h"
8
9 namespace media {
10 namespace cast {
11 namespace test {
12
13 static const unsigned int kMinimumInputCount = 1;
14 static const size_t kMinimumOutputBufferSize = 123456;
15
16 FakeVideoEncodeAccelerator::FakeVideoEncodeAccelerator(
17 VideoEncodeAccelerator::Client* client)
18 : client_(client),
19 first_(true) {
20 DCHECK(client);
21 }
22
23 FakeVideoEncodeAccelerator::~FakeVideoEncodeAccelerator() {
24 }
25
26 void FakeVideoEncodeAccelerator::Initialize(
27 media::VideoFrame::Format input_format,
28 const gfx::Size& input_visible_size,
29 VideoCodecProfile output_profile,
30 uint32 initial_bitrate) {
31 DCHECK(client_);
32
33 if (output_profile != media::VP8PROFILE_MAIN &&
34 output_profile != media::H264PROFILE_MAIN) {
35 client_->NotifyError(kInvalidArgumentError);
36 return;
37 }
38 client_->NotifyInitializeDone();
39 client_->RequireBitstreamBuffers(kMinimumInputCount,
40 input_visible_size,
41 kMinimumOutputBufferSize);
42 }
43
44 void FakeVideoEncodeAccelerator::Encode(const scoped_refptr<VideoFrame>& frame,
45 bool force_keyframe) {
46 DCHECK(client_);
47 DCHECK(!available_buffer_ids_.empty());
48
49 // Fake that we have encoded the frame; resulting in using the full output
50 // buffer.
51 int32 id = available_buffer_ids_.front();
52 available_buffer_ids_.pop_front();
53
54 bool is_key_fame = force_keyframe;
55 if (first_) {
56 is_key_fame = true;
57 first_ = false;
58 }
59 client_->BitstreamBufferReady(id, kMinimumOutputBufferSize, is_key_fame);
60 }
61
62 void FakeVideoEncodeAccelerator::UseOutputBitstreamBuffer(
63 const BitstreamBuffer& buffer) {
64 available_buffer_ids_.push_back(buffer.id());
65 }
66
67 void FakeVideoEncodeAccelerator::RequestEncodingParametersChange(
68 uint32 bitrate, uint32 framerate) {
69 // No-op.
70 }
71
72 void FakeVideoEncodeAccelerator::Destroy() {
73 delete this;
74 }
75
76 } // namespace test
77 } // namespace cast
78 } // namespace media
79
80
OLDNEW
« no previous file with comments | « media/cast/test/fake_video_encode_accelerator.h ('k') | media/cast/video_receiver/video_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698