blob: 055c55beca3b6424deea3c571e3562c4302b5ff5 [file] [log] [blame]
pbos@webrtc.org0181b5f2013-09-09 08:26:30 +00001/*
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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef TEST_FAKE_DECODER_H_
12#define TEST_FAKE_DECODER_H_
pbos@webrtc.org0181b5f2013-09-09 08:26:30 +000013
Yves Gerey3e707812018-11-28 16:47:49 +010014#include <stdint.h>
pbos@webrtc.org0181b5f2013-09-09 08:26:30 +000015
Ilya Nikolaevskiy2ebf5232019-05-13 16:13:36 +020016#include "api/task_queue/task_queue_factory.h"
Yves Gerey3e707812018-11-28 16:47:49 +010017#include "api/video/encoded_image.h"
18#include "api/video_codecs/video_codec.h"
19#include "api/video_codecs/video_decoder.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020020#include "modules/video_coding/include/video_codec_interface.h"
Ilya Nikolaevskiy2ebf5232019-05-13 16:13:36 +020021#include "rtc_base/task_queue.h"
pbos@webrtc.org0181b5f2013-09-09 08:26:30 +000022
23namespace webrtc {
24namespace test {
25
26class FakeDecoder : public VideoDecoder {
27 public:
28 FakeDecoder();
Ilya Nikolaevskiy2ebf5232019-05-13 16:13:36 +020029 explicit FakeDecoder(TaskQueueFactory* task_queue_factory);
stefan@webrtc.org79c33592014-08-06 09:24:53 +000030 virtual ~FakeDecoder() {}
pbos@webrtc.org0181b5f2013-09-09 08:26:30 +000031
stefan@webrtc.org48ac2262015-03-02 16:18:56 +000032 int32_t InitDecode(const VideoCodec* config,
33 int32_t number_of_cores) override;
pbos@webrtc.org0181b5f2013-09-09 08:26:30 +000034
stefan@webrtc.org48ac2262015-03-02 16:18:56 +000035 int32_t Decode(const EncodedImage& input,
36 bool missing_frames,
stefan@webrtc.org48ac2262015-03-02 16:18:56 +000037 int64_t render_time_ms) override;
pbos@webrtc.org0181b5f2013-09-09 08:26:30 +000038
stefan@webrtc.org48ac2262015-03-02 16:18:56 +000039 int32_t RegisterDecodeCompleteCallback(
40 DecodedImageCallback* callback) override;
pbos@webrtc.org0181b5f2013-09-09 08:26:30 +000041
stefan@webrtc.org48ac2262015-03-02 16:18:56 +000042 int32_t Release() override;
pbos@webrtc.org0181b5f2013-09-09 08:26:30 +000043
Peter Boströmb7d9a972015-12-18 16:01:11 +010044 const char* ImplementationName() const override;
45
46 static const char* kImplementationName;
47
Ilya Nikolaevskiy2ebf5232019-05-13 16:13:36 +020048 void SetDelayedDecoding(int decode_delay_ms);
49
pbos@webrtc.org0181b5f2013-09-09 08:26:30 +000050 private:
pbos@webrtc.org0181b5f2013-09-09 08:26:30 +000051 DecodedImageCallback* callback_;
philipel0e075722018-04-05 13:04:42 +020052 int width_;
53 int height_;
Ilya Nikolaevskiy2ebf5232019-05-13 16:13:36 +020054 std::unique_ptr<rtc::TaskQueue> task_queue_;
55 TaskQueueFactory* task_queue_factory_;
56 int decode_delay_ms_;
pbos@webrtc.org0181b5f2013-09-09 08:26:30 +000057};
stefan@webrtc.org79c33592014-08-06 09:24:53 +000058
59class FakeH264Decoder : public FakeDecoder {
60 public:
61 virtual ~FakeH264Decoder() {}
62
stefan@webrtc.org48ac2262015-03-02 16:18:56 +000063 int32_t Decode(const EncodedImage& input,
64 bool missing_frames,
stefan@webrtc.org48ac2262015-03-02 16:18:56 +000065 int64_t render_time_ms) override;
66};
67
pbos@webrtc.org0181b5f2013-09-09 08:26:30 +000068} // namespace test
69} // namespace webrtc
70
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020071#endif // TEST_FAKE_DECODER_H_