blob: 3dce336da67d9879e89e6b324da0800cb9acb005 [file] [log] [blame]
stefan@webrtc.org360e3762013-08-22 09:29:561/*
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
pbos@webrtc.orgab990ae2014-09-17 09:02:2516#include "webrtc/common_types.h"
stefan@webrtc.org360e3762013-08-22 09:29:5617#include "webrtc/system_wrappers/interface/clock.h"
pbos@webrtc.orgab990ae2014-09-17 09:02:2518#include "webrtc/video_encoder.h"
stefan@webrtc.org360e3762013-08-22 09:29:5619
20namespace webrtc {
pbos@webrtc.orgcb5118c2013-09-03 09:10:3721namespace test {
stefan@webrtc.org360e3762013-08-22 09:29:5622
23class FakeEncoder : public VideoEncoder {
24 public:
25 explicit FakeEncoder(Clock* clock);
stefan@webrtc.org360e3762013-08-22 09:29:5626 virtual ~FakeEncoder();
27
pbos@webrtc.org3349ae02014-03-13 12:52:2728 // Sets max bitrate. Not thread-safe, call before registering the encoder.
29 void SetMaxBitrate(int max_kbps);
pbos@webrtc.orgcb5118c2013-09-03 09:10:3730
kjellander@webrtc.org14665ff2015-03-04 12:58:3531 int32_t InitEncode(const VideoCodec* config,
32 int32_t number_of_cores,
33 size_t max_payload_size) override;
Miguel Casas-Sanchez47650702015-05-30 00:21:4034 int32_t Encode(const VideoFrame& input_image,
kjellander@webrtc.org14665ff2015-03-04 12:58:3535 const CodecSpecificInfo* codec_specific_info,
36 const std::vector<VideoFrameType>* frame_types) override;
37 int32_t RegisterEncodeCompleteCallback(
38 EncodedImageCallback* callback) override;
39 int32_t Release() override;
40 int32_t SetChannelParameters(uint32_t packet_loss, int64_t rtt) override;
41 int32_t SetRates(uint32_t new_target_bitrate, uint32_t framerate) override;
stefan@webrtc.org360e3762013-08-22 09:29:5642
pbos@webrtc.org273a4142014-12-01 15:23:2143 protected:
pbos@webrtc.orgde1429e2014-04-28 13:00:2144 Clock* const clock_;
stefan@webrtc.org360e3762013-08-22 09:29:5645 VideoCodec config_;
46 EncodedImageCallback* callback_;
47 int target_bitrate_kbps_;
pbos@webrtc.org3349ae02014-03-13 12:52:2748 int max_target_bitrate_kbps_;
stefan@webrtc.org360e3762013-08-22 09:29:5649 int64_t last_encode_time_ms_;
pbos@webrtc.orgc095f512013-08-22 12:34:5850 uint8_t encoded_buffer_[100000];
stefan@webrtc.org360e3762013-08-22 09:29:5651};
stefan@webrtc.org79c33592014-08-06 09:24:5352
53class FakeH264Encoder : public FakeEncoder, public EncodedImageCallback {
54 public:
55 explicit FakeH264Encoder(Clock* clock);
56 virtual ~FakeH264Encoder() {}
57
kjellander@webrtc.org14665ff2015-03-04 12:58:3558 int32_t RegisterEncodeCompleteCallback(
59 EncodedImageCallback* callback) override;
stefan@webrtc.org79c33592014-08-06 09:24:5360
kjellander@webrtc.org14665ff2015-03-04 12:58:3561 int32_t Encoded(const EncodedImage& encodedImage,
62 const CodecSpecificInfo* codecSpecificInfo,
63 const RTPFragmentationHeader* fragments) override;
stefan@webrtc.org79c33592014-08-06 09:24:5364
65 private:
66 EncodedImageCallback* callback_;
67 int idr_counter_;
68};
asapersson@webrtc.org049e4ec2014-11-20 10:19:4669
70class DelayedEncoder : public test::FakeEncoder {
71 public:
72 DelayedEncoder(Clock* clock, int delay_ms);
73 virtual ~DelayedEncoder() {}
74
Miguel Casas-Sanchez47650702015-05-30 00:21:4075 int32_t Encode(const VideoFrame& input_image,
kjellander@webrtc.org14665ff2015-03-04 12:58:3576 const CodecSpecificInfo* codec_specific_info,
77 const std::vector<VideoFrameType>* frame_types) override;
asapersson@webrtc.org049e4ec2014-11-20 10:19:4678
79 private:
80 const int delay_ms_;
81};
pbos@webrtc.orgcb5118c2013-09-03 09:10:3782} // namespace test
stefan@webrtc.org360e3762013-08-22 09:29:5683} // namespace webrtc
84
85#endif // WEBRTC_VIDEO_ENGINE_TEST_COMMON_FAKE_ENCODER_H_