blob: a0d8e167c74e72710eab50128dcd4f695940e75d [file] [log] [blame]
Ilya Nikolaevskiyb0588e62018-08-27 14:12:27 +02001/*
2 * Copyright (c) 2018 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 TEST_FAKE_VP8_ENCODER_H_
12#define TEST_FAKE_VP8_ENCODER_H_
13
Yves Gerey3e707812018-11-28 16:47:49 +010014#include <stddef.h>
15#include <stdint.h>
Elad Aloncde8ab22019-03-20 11:56:20 +010016
Ilya Nikolaevskiyb0588e62018-08-27 14:12:27 +020017#include <memory>
Ilya Nikolaevskiyb0588e62018-08-27 14:12:27 +020018
Elad Alon45befc52019-07-02 11:20:09 +020019#include "api/fec_controller_override.h"
Yves Gerey3e707812018-11-28 16:47:49 +010020#include "api/video/encoded_image.h"
21#include "api/video_codecs/video_codec.h"
22#include "api/video_codecs/video_encoder.h"
Elad Aloncde8ab22019-03-20 11:56:20 +010023#include "api/video_codecs/vp8_frame_buffer_controller.h"
Erik Språng4529fbc2018-10-12 10:30:31 +020024#include "api/video_codecs/vp8_temporal_layers.h"
Yves Gerey3e707812018-11-28 16:47:49 +010025#include "modules/include/module_common_types.h"
26#include "modules/video_coding/include/video_codec_interface.h"
Sebastian Janssonb55015e2019-04-09 13:44:04 +020027#include "rtc_base/synchronization/sequence_checker.h"
Yves Gerey3e707812018-11-28 16:47:49 +010028#include "rtc_base/thread_annotations.h"
29#include "system_wrappers/include/clock.h"
30#include "test/fake_encoder.h"
Ilya Nikolaevskiyb0588e62018-08-27 14:12:27 +020031
32namespace webrtc {
33namespace test {
34
Niels Möllerd7380712019-03-06 10:09:47 +010035class FakeVP8Encoder : public FakeEncoder {
Ilya Nikolaevskiyb0588e62018-08-27 14:12:27 +020036 public:
37 explicit FakeVP8Encoder(Clock* clock);
38 virtual ~FakeVP8Encoder() = default;
39
Ilya Nikolaevskiyb0588e62018-08-27 14:12:27 +020040 int32_t InitEncode(const VideoCodec* config,
Elad Alon370f93a2019-06-11 14:57:57 +020041 const Settings& settings) override;
Ilya Nikolaevskiyb0588e62018-08-27 14:12:27 +020042
43 int32_t Release() override;
44
Erik Språng86336a52018-11-15 15:38:05 +010045 EncoderInfo GetEncoderInfo() const override;
46
Ilya Nikolaevskiyb0588e62018-08-27 14:12:27 +020047 private:
Ilya Nikolaevskiyb0588e62018-08-27 14:12:27 +020048 void PopulateCodecSpecific(CodecSpecificInfo* codec_specific,
Erik Språng59021ba2018-10-03 11:05:16 +020049 size_t size_bytes,
Niels Möller87e2d782019-03-07 10:18:23 +010050 VideoFrameType frame_type,
Ilya Nikolaevskiyb0588e62018-08-27 14:12:27 +020051 int stream_idx,
52 uint32_t timestamp);
53
Niels Möllerd7380712019-03-06 10:09:47 +010054 std::unique_ptr<RTPFragmentationHeader> EncodeHook(
55 EncodedImage* encoded_image,
56 CodecSpecificInfo* codec_specific) override;
57
Sebastian Janssonb55015e2019-04-09 13:44:04 +020058 SequenceChecker sequence_checker_;
Ilya Nikolaevskiyb0588e62018-08-27 14:12:27 +020059
Elad Alon45befc52019-07-02 11:20:09 +020060 class FakeFecControllerOverride : public FecControllerOverride {
61 public:
62 ~FakeFecControllerOverride() override = default;
63
64 void SetFecAllowed(bool fec_allowed) override {}
65 };
66
67 FakeFecControllerOverride fec_controller_override_
68 RTC_GUARDED_BY(sequence_checker_);
69
Elad Aloncde8ab22019-03-20 11:56:20 +010070 std::unique_ptr<Vp8FrameBufferController> frame_buffer_controller_
Ilya Nikolaevskiyb0588e62018-08-27 14:12:27 +020071 RTC_GUARDED_BY(sequence_checker_);
72};
73
74} // namespace test
75} // namespace webrtc
76
77#endif // TEST_FAKE_VP8_ENCODER_H_