xref: /aosp_15_r20/external/webrtc/test/fake_decoder.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
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 TEST_FAKE_DECODER_H_
12 #define TEST_FAKE_DECODER_H_
13 
14 #include <stdint.h>
15 
16 #include <memory>
17 
18 #include "api/task_queue/task_queue_base.h"
19 #include "api/task_queue/task_queue_factory.h"
20 #include "api/video/encoded_image.h"
21 #include "api/video_codecs/video_decoder.h"
22 #include "modules/video_coding/include/video_codec_interface.h"
23 
24 namespace webrtc {
25 namespace test {
26 
27 class FakeDecoder : public VideoDecoder {
28  public:
29   enum { kDefaultWidth = 320, kDefaultHeight = 180 };
30 
31   FakeDecoder();
32   explicit FakeDecoder(TaskQueueFactory* task_queue_factory);
~FakeDecoder()33   virtual ~FakeDecoder() {}
34 
35   bool Configure(const Settings& settings) override;
36 
37   int32_t Decode(const EncodedImage& input,
38                  bool missing_frames,
39                  int64_t render_time_ms) override;
40 
41   int32_t RegisterDecodeCompleteCallback(
42       DecodedImageCallback* callback) override;
43 
44   int32_t Release() override;
45 
46   DecoderInfo GetDecoderInfo() const override;
47   const char* ImplementationName() const override;
48 
49   static const char* kImplementationName;
50 
51   void SetDelayedDecoding(int decode_delay_ms);
52 
53  private:
54   DecodedImageCallback* callback_;
55   int width_;
56   int height_;
57   std::unique_ptr<TaskQueueBase, TaskQueueDeleter> task_queue_;
58   TaskQueueFactory* task_queue_factory_;
59   int decode_delay_ms_;
60 };
61 
62 class FakeH264Decoder : public FakeDecoder {
63  public:
~FakeH264Decoder()64   virtual ~FakeH264Decoder() {}
65 
66   int32_t Decode(const EncodedImage& input,
67                  bool missing_frames,
68                  int64_t render_time_ms) override;
69 };
70 
71 }  // namespace test
72 }  // namespace webrtc
73 
74 #endif  // TEST_FAKE_DECODER_H_
75