~phablet-team/aethercast/fix-for-microsoft-dongle

« back to all changes in this revision

Viewing changes to tests/wds/videoformatselection_tests.cpp

Add hardware encoding and video streaming support.

The hardware encoding is currently only for Android 5.x based devices. On all others encoding will simply not work. The streaming part of aethercast (MPEGTS packetizing, RTP sending) as based on some code from Android.

Approved by PS Jenkins bot, Thomas Voß, Jim Hodapp.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2015 Canonical, Ltd.
 
3
 *
 
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.
 
7
 *
 
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.
 
12
 *
 
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/>.
 
15
 *
 
16
 */
 
17
 
 
18
#include <algorithm>
 
19
 
 
20
#include <gtest/gtest.h>
 
21
 
 
22
#include <wds/video_format.h>
 
23
 
 
24
std::vector<wds::H264VideoCodec> GetLocalH264VideoCodecs() {
 
25
    static std::vector<wds::H264VideoCodec> codecs;
 
26
    if (codecs.empty()) {
 
27
        wds::RateAndResolutionsBitmap cea_rr;
 
28
        wds::RateAndResolutionsBitmap vesa_rr;
 
29
        wds::RateAndResolutionsBitmap hh_rr;
 
30
        wds::RateAndResolution i;
 
31
 
 
32
        for (i = wds::CEA640x480p60; i <= wds::CEA1920x1080p24; ++i)
 
33
            cea_rr.set(i);
 
34
        for (i = wds::VESA800x600p30; i <= wds::VESA1920x1200p30; ++i)
 
35
            vesa_rr.set(i);
 
36
        for (i = wds::HH800x480p30; i <= wds::HH848x480p60; ++i)
 
37
            hh_rr.set(i);
 
38
 
 
39
        wds::H264VideoCodec codec(wds::CHP, wds::k4_2, cea_rr, vesa_rr, hh_rr);
 
40
        codecs.push_back(codec);
 
41
    }
 
42
 
 
43
    return codecs;
 
44
}
 
45
 
 
46
TEST(VideoFormatSelection, SelectsExpectedFormat) {
 
47
    wds::RateAndResolutionsBitmap cea_rr;
 
48
    wds::RateAndResolutionsBitmap vesa_rr;
 
49
    wds::RateAndResolutionsBitmap hh_rr;
 
50
    wds::RateAndResolution i;
 
51
 
 
52
    for (i = wds::CEA640x480p60; i <= wds::CEA1920x1080p24; ++i)
 
53
      cea_rr.set(i);
 
54
 
 
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);
 
58
 
 
59
    wds::NativeVideoFormat sink_native_format;
 
60
    sink_native_format.type = wds::CEA;
 
61
    sink_native_format.rate_resolution = wds::CEA1920x1080p60;
 
62
 
 
63
    bool success = false;
 
64
 
 
65
    wds::H264VideoFormat format = wds::FindOptimalVideoFormat(sink_native_format, GetLocalH264VideoCodecs(), sink_codecs, &success);
 
66
 
 
67
    EXPECT_TRUE(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);
 
72
}