1 /* 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 3 * 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. 9 */ 10 11 #ifndef WEBRTC_VIDEO_ENGINE_TEST_COMMON_FAKE_ENCODER_H_ 12 #define WEBRTC_VIDEO_ENGINE_TEST_COMMON_FAKE_ENCODER_H_ 13 14 #include <vector> 15 16 #include "webrtc/modules/video_coding/codecs/interface/video_codec_interface.h" 17 #include "webrtc/system_wrappers/interface/clock.h" 18 19 namespace webrtc { 20 namespace test { 21 22 class FakeEncoder : public VideoEncoder { 23 public: 24 explicit FakeEncoder(Clock* clock); 25 virtual ~FakeEncoder(); 26 27 // Sets max bitrate. Not thread-safe, call before registering the encoder. 28 void SetMaxBitrate(int max_kbps); 29 30 virtual int32_t InitEncode(const VideoCodec* config, 31 int32_t number_of_cores, 32 uint32_t max_payload_size) OVERRIDE; 33 virtual int32_t Encode( 34 const I420VideoFrame& input_image, 35 const CodecSpecificInfo* codec_specific_info, 36 const std::vector<VideoFrameType>* frame_types) OVERRIDE; 37 virtual int32_t RegisterEncodeCompleteCallback( 38 EncodedImageCallback* callback) OVERRIDE; 39 virtual int32_t Release() OVERRIDE; 40 virtual int32_t SetChannelParameters(uint32_t packet_loss, int rtt) OVERRIDE; 41 virtual int32_t SetRates(uint32_t new_target_bitrate, 42 uint32_t framerate) OVERRIDE; 43 44 private: 45 Clock* const clock_; 46 VideoCodec config_; 47 EncodedImageCallback* callback_; 48 int target_bitrate_kbps_; 49 int max_target_bitrate_kbps_; 50 int64_t last_encode_time_ms_; 51 uint8_t encoded_buffer_[100000]; 52 }; 53 } // namespace test 54 } // namespace webrtc 55 56 #endif // WEBRTC_VIDEO_ENGINE_TEST_COMMON_FAKE_ENCODER_H_ 57