1 /*
2 * Copyright (c) 2016 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/internal_decoder_factory.h"
12
13 #include "api/video_codecs/sdp_video_format.h"
14 #include "api/video_codecs/video_decoder.h"
15 #include "media/base/media_constants.h"
16 #include "media/base/vp9_profile.h"
17 #include "modules/video_coding/codecs/av1/libaom_av1_decoder.h"
18 #include "test/gmock.h"
19 #include "test/gtest.h"
20
21 namespace webrtc {
22
23 using ::testing::Contains;
24 using ::testing::Field;
25 using ::testing::Not;
26
TEST(InternalDecoderFactory,TestVP8)27 TEST(InternalDecoderFactory, TestVP8) {
28 InternalDecoderFactory factory;
29 std::unique_ptr<VideoDecoder> decoder =
30 factory.CreateVideoDecoder(SdpVideoFormat(cricket::kVp8CodecName));
31 EXPECT_TRUE(decoder);
32 }
33
34 #ifdef RTC_ENABLE_VP9
TEST(InternalDecoderFactory,TestVP9Profile0)35 TEST(InternalDecoderFactory, TestVP9Profile0) {
36 InternalDecoderFactory factory;
37 std::unique_ptr<VideoDecoder> decoder =
38 factory.CreateVideoDecoder(SdpVideoFormat(
39 cricket::kVp9CodecName,
40 {{kVP9FmtpProfileId, VP9ProfileToString(VP9Profile::kProfile0)}}));
41 EXPECT_TRUE(decoder);
42 }
43
TEST(InternalDecoderFactory,TestVP9Profile1)44 TEST(InternalDecoderFactory, TestVP9Profile1) {
45 InternalDecoderFactory factory;
46 std::unique_ptr<VideoDecoder> decoder =
47 factory.CreateVideoDecoder(SdpVideoFormat(
48 cricket::kVp9CodecName,
49 {{kVP9FmtpProfileId, VP9ProfileToString(VP9Profile::kProfile1)}}));
50 EXPECT_TRUE(decoder);
51 }
52 #endif // RTC_ENABLE_VP9
53
TEST(InternalDecoderFactory,Av1)54 TEST(InternalDecoderFactory, Av1) {
55 InternalDecoderFactory factory;
56 if (kIsLibaomAv1DecoderSupported) {
57 EXPECT_THAT(factory.GetSupportedFormats(),
58 Contains(Field(&SdpVideoFormat::name, "AV1X")));
59 EXPECT_TRUE(factory.CreateVideoDecoder(SdpVideoFormat("AV1X")));
60 } else {
61 EXPECT_THAT(factory.GetSupportedFormats(),
62 Not(Contains(Field(&SdpVideoFormat::name, "AV1X"))));
63 }
64 }
65
66 } // namespace webrtc
67