155afdbe08faa2e2020a95705d06f32ea503ac1cfstefan@webrtc.org/* 255afdbe08faa2e2020a95705d06f32ea503ac1cfstefan@webrtc.org * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 355afdbe08faa2e2020a95705d06f32ea503ac1cfstefan@webrtc.org * 455afdbe08faa2e2020a95705d06f32ea503ac1cfstefan@webrtc.org * Use of this source code is governed by a BSD-style license 555afdbe08faa2e2020a95705d06f32ea503ac1cfstefan@webrtc.org * that can be found in the LICENSE file in the root of the source 655afdbe08faa2e2020a95705d06f32ea503ac1cfstefan@webrtc.org * tree. An additional intellectual property rights grant can be found 755afdbe08faa2e2020a95705d06f32ea503ac1cfstefan@webrtc.org * in the file PATENTS. All contributing project authors may 855afdbe08faa2e2020a95705d06f32ea503ac1cfstefan@webrtc.org * be found in the AUTHORS file in the root of the source tree. 955afdbe08faa2e2020a95705d06f32ea503ac1cfstefan@webrtc.org */ 1055afdbe08faa2e2020a95705d06f32ea503ac1cfstefan@webrtc.org 1155afdbe08faa2e2020a95705d06f32ea503ac1cfstefan@webrtc.org#ifndef WEBRTC_VIDEO_ENGINE_TEST_COMMON_FAKE_ENCODER_H_ 1255afdbe08faa2e2020a95705d06f32ea503ac1cfstefan@webrtc.org#define WEBRTC_VIDEO_ENGINE_TEST_COMMON_FAKE_ENCODER_H_ 1355afdbe08faa2e2020a95705d06f32ea503ac1cfstefan@webrtc.org 1455afdbe08faa2e2020a95705d06f32ea503ac1cfstefan@webrtc.org#include <vector> 1555afdbe08faa2e2020a95705d06f32ea503ac1cfstefan@webrtc.org 161c655450cf12d21bfa5b2ff277f337335149186apbos@webrtc.org#include "webrtc/common_types.h" 1755afdbe08faa2e2020a95705d06f32ea503ac1cfstefan@webrtc.org#include "webrtc/system_wrappers/interface/clock.h" 181c655450cf12d21bfa5b2ff277f337335149186apbos@webrtc.org#include "webrtc/video_encoder.h" 1955afdbe08faa2e2020a95705d06f32ea503ac1cfstefan@webrtc.org 2055afdbe08faa2e2020a95705d06f32ea503ac1cfstefan@webrtc.orgnamespace webrtc { 219e7094052565007ef9e873a7659f5110517438e4pbos@webrtc.orgnamespace test { 2255afdbe08faa2e2020a95705d06f32ea503ac1cfstefan@webrtc.org 2355afdbe08faa2e2020a95705d06f32ea503ac1cfstefan@webrtc.orgclass FakeEncoder : public VideoEncoder { 2455afdbe08faa2e2020a95705d06f32ea503ac1cfstefan@webrtc.org public: 2555afdbe08faa2e2020a95705d06f32ea503ac1cfstefan@webrtc.org explicit FakeEncoder(Clock* clock); 2655afdbe08faa2e2020a95705d06f32ea503ac1cfstefan@webrtc.org virtual ~FakeEncoder(); 2755afdbe08faa2e2020a95705d06f32ea503ac1cfstefan@webrtc.org 283f83f9cae99b605aee71b46839e902653baeb3f6pbos@webrtc.org // Sets max bitrate. Not thread-safe, call before registering the encoder. 293f83f9cae99b605aee71b46839e902653baeb3f6pbos@webrtc.org void SetMaxBitrate(int max_kbps); 309e7094052565007ef9e873a7659f5110517438e4pbos@webrtc.org 3155afdbe08faa2e2020a95705d06f32ea503ac1cfstefan@webrtc.org virtual int32_t InitEncode(const VideoCodec* config, 3255afdbe08faa2e2020a95705d06f32ea503ac1cfstefan@webrtc.org int32_t number_of_cores, 3355afdbe08faa2e2020a95705d06f32ea503ac1cfstefan@webrtc.org uint32_t max_payload_size) OVERRIDE; 3455afdbe08faa2e2020a95705d06f32ea503ac1cfstefan@webrtc.org virtual int32_t Encode( 3555afdbe08faa2e2020a95705d06f32ea503ac1cfstefan@webrtc.org const I420VideoFrame& input_image, 3655afdbe08faa2e2020a95705d06f32ea503ac1cfstefan@webrtc.org const CodecSpecificInfo* codec_specific_info, 3755afdbe08faa2e2020a95705d06f32ea503ac1cfstefan@webrtc.org const std::vector<VideoFrameType>* frame_types) OVERRIDE; 3855afdbe08faa2e2020a95705d06f32ea503ac1cfstefan@webrtc.org virtual int32_t RegisterEncodeCompleteCallback( 3955afdbe08faa2e2020a95705d06f32ea503ac1cfstefan@webrtc.org EncodedImageCallback* callback) OVERRIDE; 4055afdbe08faa2e2020a95705d06f32ea503ac1cfstefan@webrtc.org virtual int32_t Release() OVERRIDE; 4155afdbe08faa2e2020a95705d06f32ea503ac1cfstefan@webrtc.org virtual int32_t SetChannelParameters(uint32_t packet_loss, int rtt) OVERRIDE; 4255afdbe08faa2e2020a95705d06f32ea503ac1cfstefan@webrtc.org virtual int32_t SetRates(uint32_t new_target_bitrate, 4355afdbe08faa2e2020a95705d06f32ea503ac1cfstefan@webrtc.org uint32_t framerate) OVERRIDE; 4455afdbe08faa2e2020a95705d06f32ea503ac1cfstefan@webrtc.org 4555afdbe08faa2e2020a95705d06f32ea503ac1cfstefan@webrtc.org private: 46c476e64d056c5e342bc5b23eecd493abf6d85d7fpbos@webrtc.org Clock* const clock_; 4755afdbe08faa2e2020a95705d06f32ea503ac1cfstefan@webrtc.org VideoCodec config_; 4855afdbe08faa2e2020a95705d06f32ea503ac1cfstefan@webrtc.org EncodedImageCallback* callback_; 4955afdbe08faa2e2020a95705d06f32ea503ac1cfstefan@webrtc.org int target_bitrate_kbps_; 503f83f9cae99b605aee71b46839e902653baeb3f6pbos@webrtc.org int max_target_bitrate_kbps_; 5155afdbe08faa2e2020a95705d06f32ea503ac1cfstefan@webrtc.org int64_t last_encode_time_ms_; 520f911c9479fea4c9e4f54e15d12ef18d85c3986bpbos@webrtc.org uint8_t encoded_buffer_[100000]; 5355afdbe08faa2e2020a95705d06f32ea503ac1cfstefan@webrtc.org}; 54617e272fea14f31c0b32aa6c47afc81dbb65697bstefan@webrtc.org 55617e272fea14f31c0b32aa6c47afc81dbb65697bstefan@webrtc.orgclass FakeH264Encoder : public FakeEncoder, public EncodedImageCallback { 56617e272fea14f31c0b32aa6c47afc81dbb65697bstefan@webrtc.org public: 57617e272fea14f31c0b32aa6c47afc81dbb65697bstefan@webrtc.org explicit FakeH264Encoder(Clock* clock); 58617e272fea14f31c0b32aa6c47afc81dbb65697bstefan@webrtc.org virtual ~FakeH264Encoder() {} 59617e272fea14f31c0b32aa6c47afc81dbb65697bstefan@webrtc.org 60617e272fea14f31c0b32aa6c47afc81dbb65697bstefan@webrtc.org virtual int32_t RegisterEncodeCompleteCallback( 61617e272fea14f31c0b32aa6c47afc81dbb65697bstefan@webrtc.org EncodedImageCallback* callback) OVERRIDE; 62617e272fea14f31c0b32aa6c47afc81dbb65697bstefan@webrtc.org 63617e272fea14f31c0b32aa6c47afc81dbb65697bstefan@webrtc.org virtual int32_t Encoded( 64617e272fea14f31c0b32aa6c47afc81dbb65697bstefan@webrtc.org EncodedImage& encodedImage, 65617e272fea14f31c0b32aa6c47afc81dbb65697bstefan@webrtc.org const CodecSpecificInfo* codecSpecificInfo = NULL, 66617e272fea14f31c0b32aa6c47afc81dbb65697bstefan@webrtc.org const RTPFragmentationHeader* fragments = NULL) OVERRIDE; 67617e272fea14f31c0b32aa6c47afc81dbb65697bstefan@webrtc.org 68617e272fea14f31c0b32aa6c47afc81dbb65697bstefan@webrtc.org private: 69617e272fea14f31c0b32aa6c47afc81dbb65697bstefan@webrtc.org EncodedImageCallback* callback_; 70617e272fea14f31c0b32aa6c47afc81dbb65697bstefan@webrtc.org int idr_counter_; 71617e272fea14f31c0b32aa6c47afc81dbb65697bstefan@webrtc.org}; 729e7094052565007ef9e873a7659f5110517438e4pbos@webrtc.org} // namespace test 7355afdbe08faa2e2020a95705d06f32ea503ac1cfstefan@webrtc.org} // namespace webrtc 7455afdbe08faa2e2020a95705d06f32ea503ac1cfstefan@webrtc.org 7555afdbe08faa2e2020a95705d06f32ea503ac1cfstefan@webrtc.org#endif // WEBRTC_VIDEO_ENGINE_TEST_COMMON_FAKE_ENCODER_H_ 76