xref: /aosp_15_r20/external/webrtc/media/engine/fake_video_codec_factory.cc (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1 /*
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 #include "media/engine/fake_video_codec_factory.h"
12 
13 #include <memory>
14 
15 #include "api/video_codecs/sdp_video_format.h"
16 #include "api/video_codecs/video_decoder.h"
17 #include "api/video_codecs/video_encoder.h"
18 #include "modules/video_coding/include/video_codec_interface.h"
19 #include "modules/video_coding/include/video_error_codes.h"
20 #include "rtc_base/checks.h"
21 #include "rtc_base/logging.h"
22 #include "test/fake_decoder.h"
23 #include "test/fake_encoder.h"
24 
25 namespace {
26 
27 static const char kFakeCodecFactoryCodecName[] = "FakeCodec";
28 
29 }  // anonymous namespace
30 
31 namespace webrtc {
32 
33 FakeVideoEncoderFactory::FakeVideoEncoderFactory() = default;
34 
35 // static
CreateVideoEncoder()36 std::unique_ptr<VideoEncoder> FakeVideoEncoderFactory::CreateVideoEncoder() {
37   return std::make_unique<test::FakeEncoder>(Clock::GetRealTimeClock());
38 }
39 
GetSupportedFormats() const40 std::vector<SdpVideoFormat> FakeVideoEncoderFactory::GetSupportedFormats()
41     const {
42   return std::vector<SdpVideoFormat>(
43       1, SdpVideoFormat(kFakeCodecFactoryCodecName));
44 }
45 
CreateVideoEncoder(const SdpVideoFormat & format)46 std::unique_ptr<VideoEncoder> FakeVideoEncoderFactory::CreateVideoEncoder(
47     const SdpVideoFormat& format) {
48   return std::make_unique<test::FakeEncoder>(Clock::GetRealTimeClock());
49 }
50 
51 FakeVideoDecoderFactory::FakeVideoDecoderFactory() = default;
52 
53 // static
CreateVideoDecoder()54 std::unique_ptr<VideoDecoder> FakeVideoDecoderFactory::CreateVideoDecoder() {
55   return std::make_unique<test::FakeDecoder>();
56 }
57 
GetSupportedFormats() const58 std::vector<SdpVideoFormat> FakeVideoDecoderFactory::GetSupportedFormats()
59     const {
60   return std::vector<SdpVideoFormat>(
61       1, SdpVideoFormat(kFakeCodecFactoryCodecName));
62 }
63 
CreateVideoDecoder(const SdpVideoFormat & format)64 std::unique_ptr<VideoDecoder> FakeVideoDecoderFactory::CreateVideoDecoder(
65     const SdpVideoFormat& format) {
66   return std::make_unique<test::FakeDecoder>();
67 }
68 
69 }  // namespace webrtc
70