2
* Copyright (C) 2015 Canonical, Ltd.
4
* This program is free software: you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License version 3, as published
6
* by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranties of
10
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11
* PURPOSE. See the GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License along
14
* with this program. If not, see <http://www.gnu.org/licenses/>.
20
#include <gtest/gtest.h>
22
#include <wds/video_format.h>
24
std::vector<wds::H264VideoCodec> GetLocalH264VideoCodecs() {
25
static std::vector<wds::H264VideoCodec> codecs;
27
wds::RateAndResolutionsBitmap cea_rr;
28
wds::RateAndResolutionsBitmap vesa_rr;
29
wds::RateAndResolutionsBitmap hh_rr;
30
wds::RateAndResolution i;
32
for (i = wds::CEA640x480p60; i <= wds::CEA1920x1080p24; ++i)
34
for (i = wds::VESA800x600p30; i <= wds::VESA1920x1200p30; ++i)
36
for (i = wds::HH800x480p30; i <= wds::HH848x480p60; ++i)
39
wds::H264VideoCodec codec(wds::CHP, wds::k4_2, cea_rr, vesa_rr, hh_rr);
40
codecs.push_back(codec);
46
TEST(VideoFormatSelection, SelectsExpectedFormat) {
47
wds::RateAndResolutionsBitmap cea_rr;
48
wds::RateAndResolutionsBitmap vesa_rr;
49
wds::RateAndResolutionsBitmap hh_rr;
50
wds::RateAndResolution i;
52
for (i = wds::CEA640x480p60; i <= wds::CEA1920x1080p24; ++i)
55
std::vector<wds::H264VideoCodec> sink_codecs;
56
wds::H264VideoCodec sink_codec(wds::CBP, wds::k3_2, cea_rr, vesa_rr, hh_rr);
57
sink_codecs.push_back(sink_codec);
59
wds::NativeVideoFormat sink_native_format;
60
sink_native_format.type = wds::CEA;
61
sink_native_format.rate_resolution = wds::CEA1920x1080p60;
65
wds::H264VideoFormat format = wds::FindOptimalVideoFormat(sink_native_format, GetLocalH264VideoCodecs(), sink_codecs, &success);
68
EXPECT_EQ(wds::k3_2, format.level);
69
EXPECT_EQ(wds::CBP, format.profile);
70
EXPECT_EQ(wds::CEA, format.type);
71
EXPECT_EQ(wds::CEA1920x1080p60, format.rate_resolution);