2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
11 #include "webrtc/test/configurable_frame_size_encoder.h"
15 #include "webrtc/common_video/interface/video_image.h"
16 #include "testing/gtest/include/gtest/gtest.h"
21 ConfigurableFrameSizeEncoder::ConfigurableFrameSizeEncoder(
22 uint32_t max_frame_size)
24 max_frame_size_(max_frame_size),
25 current_frame_size_(max_frame_size),
26 buffer_(new uint8_t[max_frame_size]) {
27 memset(buffer_.get(), 0, max_frame_size);
30 ConfigurableFrameSizeEncoder::~ConfigurableFrameSizeEncoder() {}
32 int32_t ConfigurableFrameSizeEncoder::InitEncode(
33 const VideoCodec* codec_settings,
34 int32_t number_of_cores,
35 uint32_t max_payload_size) {
36 return WEBRTC_VIDEO_CODEC_OK;
39 int32_t ConfigurableFrameSizeEncoder::Encode(
40 const I420VideoFrame& inputImage,
41 const CodecSpecificInfo* codecSpecificInfo,
42 const std::vector<VideoFrameType>* frame_types) {
43 EncodedImage encodedImage(
44 buffer_.get(), current_frame_size_, max_frame_size_);
45 encodedImage._completeFrame = true;
46 encodedImage._encodedHeight = inputImage.height();
47 encodedImage._encodedWidth = inputImage.width();
48 encodedImage._frameType = kKeyFrame;
49 encodedImage._timeStamp = inputImage.timestamp();
50 encodedImage.capture_time_ms_ = inputImage.render_time_ms();
51 RTPFragmentationHeader* fragmentation = NULL;
52 CodecSpecificInfo specific;
53 memset(&specific, 0, sizeof(specific));
54 callback_->Encoded(encodedImage, &specific, fragmentation);
56 return WEBRTC_VIDEO_CODEC_OK;
59 int32_t ConfigurableFrameSizeEncoder::RegisterEncodeCompleteCallback(
60 EncodedImageCallback* callback) {
62 return WEBRTC_VIDEO_CODEC_OK;
65 int32_t ConfigurableFrameSizeEncoder::Release() {
66 return WEBRTC_VIDEO_CODEC_OK;
69 int32_t ConfigurableFrameSizeEncoder::SetChannelParameters(uint32_t packet_loss,
71 return WEBRTC_VIDEO_CODEC_OK;
74 int32_t ConfigurableFrameSizeEncoder::SetRates(uint32_t new_bit_rate,
75 uint32_t frame_rate) {
76 return WEBRTC_VIDEO_CODEC_OK;
79 int32_t ConfigurableFrameSizeEncoder::SetPeriodicKeyFrames(bool enable) {
80 return WEBRTC_VIDEO_CODEC_OK;
83 int32_t ConfigurableFrameSizeEncoder::CodecConfigParameters(uint8_t* buffer,
85 return WEBRTC_VIDEO_CODEC_OK;
88 int32_t ConfigurableFrameSizeEncoder::SetFrameSize(uint32_t size) {
89 assert(size <= max_frame_size_);
90 current_frame_size_ = size;
91 return WEBRTC_VIDEO_CODEC_OK;