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 "mirsourcemediamanager.h"
25
MirSourceMediaManager::MirSourceMediaManager(const std::string &remote_address) :
26
remote_address_(remote_address) {
29
MirSourceMediaManager::~MirSourceMediaManager() {
32
SharedGObject<GstElement> MirSourceMediaManager::ConstructPipeline(const wds::H264VideoFormat &format) {
33
int width = 0, height = 0;
34
std::string profile = "constrained-baseline";
36
switch (format.profile) {
38
profile = "constrained-baseline";
45
switch (format.type) {
47
switch (format.rate_resolution) {
48
case wds::CEA640x480p60:
52
case wds::CEA720x480p60:
53
case wds::CEA720x480i60:
57
case wds::CEA720x576p50:
58
case wds::CEA720x576i50:
62
case wds::CEA1280x720p30:
63
case wds::CEA1280x720p60:
67
case wds::CEA1920x1080p30:
68
case wds::CEA1920x1080p60:
69
case wds::CEA1920x1080i60:
73
case wds::CEA1280x720p25:
74
case wds::CEA1280x720p50:
75
case wds::CEA1280x720p24:
79
case wds::CEA1920x1080p25:
80
case wds::CEA1920x1080p50:
81
case wds::CEA1920x1080i50:
82
case wds::CEA1920x1080p24:
95
ss << "mirimagesrc mir-socket=/run/mir_socket ! videoconvert ! videoscale ! ";
96
ss << Utils::Sprintf("video/x-raw,width=%d,height=%d ! ", width, height);
97
ss << "videoflip method=counterclockwise ! queue2 ! video/x-raw,format=I420 ! ";
98
ss << "x264enc aud=false byte-stream=true tune=zerolatency ! ";
99
ss << Utils::Sprintf("video/x-h264,profile=%s ! ", profile.c_str());
100
ss << "mpegtsmux ! rtpmp2tpay ! ";
101
ss << Utils::Sprintf("udpsink name=sink host=%s port=%d", remote_address_.c_str(), sink_port1_);
103
GError *error = nullptr;
104
GstElement *pipeline = gst_parse_launch(ss.str().c_str(), &error);
106
ERROR("Failed to setup GStreamer pipeline: %s", error->message);
111
return make_shared_gobject(pipeline);