1 /*
2 * Copyright (c) 2017 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 <memory>
12 #include <vector>
13
14 #include "api/test/create_videocodec_test_fixture.h"
15 #include "media/base/media_constants.h"
16 #include "modules/video_coding/codecs/test/objc_codec_factory_helper.h"
17 #include "modules/video_coding/codecs/test/videocodec_test_fixture_impl.h"
18 #include "test/gtest.h"
19 #include "test/testsupport/file_utils.h"
20
21 namespace webrtc {
22 namespace test {
23
24 namespace {
25 const int kForemanNumFrames = 300;
26
CreateConfig()27 VideoCodecTestFixture::Config CreateConfig() {
28 VideoCodecTestFixture::Config config;
29 config.filename = "foreman_cif";
30 config.filepath = ResourcePath(config.filename, "yuv");
31 config.num_frames = kForemanNumFrames;
32 return config;
33 }
34
CreateTestFixtureWithConfig(VideoCodecTestFixture::Config config)35 std::unique_ptr<VideoCodecTestFixture> CreateTestFixtureWithConfig(
36 VideoCodecTestFixture::Config config) {
37 auto decoder_factory = CreateObjCDecoderFactory();
38 auto encoder_factory = CreateObjCEncoderFactory();
39 return CreateVideoCodecTestFixture(config, std::move(decoder_factory),
40 std::move(encoder_factory));
41 }
42 } // namespace
43
44 // TODO(webrtc:9099): Disabled until the issue is fixed.
45 // HW codecs don't work on simulators. Only run these tests on device.
46 // #if TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
47 // #define MAYBE_TEST TEST
48 // #else
49 #define MAYBE_TEST(s, name) TEST(s, DISABLED_##name)
50 // #endif
51
52 // TODO(kthelgason): Use RC Thresholds when the internal bitrateAdjuster is no
53 // longer in use.
MAYBE_TEST(VideoCodecTestVideoToolbox,ForemanCif500kbpsH264CBP)54 MAYBE_TEST(VideoCodecTestVideoToolbox, ForemanCif500kbpsH264CBP) {
55 const auto frame_checker =
56 std::make_unique<VideoCodecTestFixtureImpl::H264KeyframeChecker>();
57 auto config = CreateConfig();
58 config.SetCodecSettings(cricket::kH264CodecName, 1, 1, 1, false, false, false,
59 352, 288);
60 config.encoded_frame_checker = frame_checker.get();
61 auto fixture = CreateTestFixtureWithConfig(config);
62
63 std::vector<RateProfile> rate_profiles = {{500, 30, 0}};
64
65 std::vector<QualityThresholds> quality_thresholds = {{33, 29, 0.9, 0.82}};
66
67 fixture->RunTest(rate_profiles, nullptr, &quality_thresholds, nullptr);
68 }
69
MAYBE_TEST(VideoCodecTestVideoToolbox,ForemanCif500kbpsH264CHP)70 MAYBE_TEST(VideoCodecTestVideoToolbox, ForemanCif500kbpsH264CHP) {
71 const auto frame_checker =
72 std::make_unique<VideoCodecTestFixtureImpl::H264KeyframeChecker>();
73 auto config = CreateConfig();
74 config.h264_codec_settings.profile = H264::kProfileConstrainedHigh;
75 config.SetCodecSettings(cricket::kH264CodecName, 1, 1, 1, false, false, false,
76 352, 288);
77 config.encoded_frame_checker = frame_checker.get();
78 auto fixture = CreateTestFixtureWithConfig(config);
79
80 std::vector<RateProfile> rate_profiles = {{500, 30, 0}};
81
82 std::vector<QualityThresholds> quality_thresholds = {{33, 30, 0.91, 0.83}};
83
84 fixture->RunTest(rate_profiles, nullptr, &quality_thresholds, nullptr);
85 }
86
87 } // namespace test
88 } // namespace webrtc
89