fake_encoder.h revision de1429e9ad9a3a207ca191e1d748aa7271066860
1360e3768729d40a10543641cee2cf56e0cf7dddestefan@webrtc.org/* 2360e3768729d40a10543641cee2cf56e0cf7dddestefan@webrtc.org * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 3360e3768729d40a10543641cee2cf56e0cf7dddestefan@webrtc.org * 4360e3768729d40a10543641cee2cf56e0cf7dddestefan@webrtc.org * Use of this source code is governed by a BSD-style license 5360e3768729d40a10543641cee2cf56e0cf7dddestefan@webrtc.org * that can be found in the LICENSE file in the root of the source 6360e3768729d40a10543641cee2cf56e0cf7dddestefan@webrtc.org * tree. An additional intellectual property rights grant can be found 7360e3768729d40a10543641cee2cf56e0cf7dddestefan@webrtc.org * in the file PATENTS. All contributing project authors may 8360e3768729d40a10543641cee2cf56e0cf7dddestefan@webrtc.org * be found in the AUTHORS file in the root of the source tree. 9360e3768729d40a10543641cee2cf56e0cf7dddestefan@webrtc.org */ 10360e3768729d40a10543641cee2cf56e0cf7dddestefan@webrtc.org 11360e3768729d40a10543641cee2cf56e0cf7dddestefan@webrtc.org#ifndef WEBRTC_VIDEO_ENGINE_TEST_COMMON_FAKE_ENCODER_H_ 12360e3768729d40a10543641cee2cf56e0cf7dddestefan@webrtc.org#define WEBRTC_VIDEO_ENGINE_TEST_COMMON_FAKE_ENCODER_H_ 13360e3768729d40a10543641cee2cf56e0cf7dddestefan@webrtc.org 14360e3768729d40a10543641cee2cf56e0cf7dddestefan@webrtc.org#include <vector> 15360e3768729d40a10543641cee2cf56e0cf7dddestefan@webrtc.org 16360e3768729d40a10543641cee2cf56e0cf7dddestefan@webrtc.org#include "webrtc/modules/video_coding/codecs/interface/video_codec_interface.h" 17360e3768729d40a10543641cee2cf56e0cf7dddestefan@webrtc.org#include "webrtc/system_wrappers/interface/clock.h" 18360e3768729d40a10543641cee2cf56e0cf7dddestefan@webrtc.org 19360e3768729d40a10543641cee2cf56e0cf7dddestefan@webrtc.orgnamespace webrtc { 20cb5118c14cc578cf232f381c23da8c252c95a4fapbos@webrtc.orgnamespace test { 21360e3768729d40a10543641cee2cf56e0cf7dddestefan@webrtc.org 22360e3768729d40a10543641cee2cf56e0cf7dddestefan@webrtc.orgclass FakeEncoder : public VideoEncoder { 23360e3768729d40a10543641cee2cf56e0cf7dddestefan@webrtc.org public: 24360e3768729d40a10543641cee2cf56e0cf7dddestefan@webrtc.org explicit FakeEncoder(Clock* clock); 25360e3768729d40a10543641cee2cf56e0cf7dddestefan@webrtc.org virtual ~FakeEncoder(); 26360e3768729d40a10543641cee2cf56e0cf7dddestefan@webrtc.org 273349ae0cdcff9d2d3cae2e82a938b8db806c36f6pbos@webrtc.org // Sets max bitrate. Not thread-safe, call before registering the encoder. 283349ae0cdcff9d2d3cae2e82a938b8db806c36f6pbos@webrtc.org void SetMaxBitrate(int max_kbps); 29cb5118c14cc578cf232f381c23da8c252c95a4fapbos@webrtc.org 30360e3768729d40a10543641cee2cf56e0cf7dddestefan@webrtc.org virtual int32_t InitEncode(const VideoCodec* config, 31360e3768729d40a10543641cee2cf56e0cf7dddestefan@webrtc.org int32_t number_of_cores, 32360e3768729d40a10543641cee2cf56e0cf7dddestefan@webrtc.org uint32_t max_payload_size) OVERRIDE; 33360e3768729d40a10543641cee2cf56e0cf7dddestefan@webrtc.org virtual int32_t Encode( 34360e3768729d40a10543641cee2cf56e0cf7dddestefan@webrtc.org const I420VideoFrame& input_image, 35360e3768729d40a10543641cee2cf56e0cf7dddestefan@webrtc.org const CodecSpecificInfo* codec_specific_info, 36360e3768729d40a10543641cee2cf56e0cf7dddestefan@webrtc.org const std::vector<VideoFrameType>* frame_types) OVERRIDE; 37360e3768729d40a10543641cee2cf56e0cf7dddestefan@webrtc.org virtual int32_t RegisterEncodeCompleteCallback( 38360e3768729d40a10543641cee2cf56e0cf7dddestefan@webrtc.org EncodedImageCallback* callback) OVERRIDE; 39360e3768729d40a10543641cee2cf56e0cf7dddestefan@webrtc.org virtual int32_t Release() OVERRIDE; 40360e3768729d40a10543641cee2cf56e0cf7dddestefan@webrtc.org virtual int32_t SetChannelParameters(uint32_t packet_loss, int rtt) OVERRIDE; 41360e3768729d40a10543641cee2cf56e0cf7dddestefan@webrtc.org virtual int32_t SetRates(uint32_t new_target_bitrate, 42360e3768729d40a10543641cee2cf56e0cf7dddestefan@webrtc.org uint32_t framerate) OVERRIDE; 43360e3768729d40a10543641cee2cf56e0cf7dddestefan@webrtc.org 44360e3768729d40a10543641cee2cf56e0cf7dddestefan@webrtc.org private: 45de1429e9ad9a3a207ca191e1d748aa7271066860pbos@webrtc.org Clock* const clock_; 46360e3768729d40a10543641cee2cf56e0cf7dddestefan@webrtc.org VideoCodec config_; 47360e3768729d40a10543641cee2cf56e0cf7dddestefan@webrtc.org EncodedImageCallback* callback_; 48360e3768729d40a10543641cee2cf56e0cf7dddestefan@webrtc.org int target_bitrate_kbps_; 493349ae0cdcff9d2d3cae2e82a938b8db806c36f6pbos@webrtc.org int max_target_bitrate_kbps_; 50360e3768729d40a10543641cee2cf56e0cf7dddestefan@webrtc.org int64_t last_encode_time_ms_; 51c095f510b6fb7a36131bd4e8c753c7e2c146faacpbos@webrtc.org uint8_t encoded_buffer_[100000]; 52360e3768729d40a10543641cee2cf56e0cf7dddestefan@webrtc.org}; 53cb5118c14cc578cf232f381c23da8c252c95a4fapbos@webrtc.org} // namespace test 54360e3768729d40a10543641cee2cf56e0cf7dddestefan@webrtc.org} // namespace webrtc 55360e3768729d40a10543641cee2cf56e0cf7dddestefan@webrtc.org 56360e3768729d40a10543641cee2cf56e0cf7dddestefan@webrtc.org#endif // WEBRTC_VIDEO_ENGINE_TEST_COMMON_FAKE_ENCODER_H_ 57