1 /*
2  * This file is part of Wireless Display Software for Linux OS
3  *
4  * Copyright (C) 2014 Intel Corporation.
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19  * 02110-1301 USA
20  */
21 
22 #include <iostream>
23 
24 #include "sink.h"
25 #include "gst_sink_media_manager.h"
26 
Sink(const std::string & remote_host,int remote_rtsp_port,const std::string & local_host)27 Sink::Sink(const std::string& remote_host, int remote_rtsp_port, const std::string& local_host)
28   : MiracBroker(remote_host, std::to_string(remote_rtsp_port)),
29     local_host_(local_host) {
30 }
31 
~Sink()32 Sink::~Sink() {}
33 
got_message(const std::string & message)34 void Sink::got_message(const std::string& message) {
35   wfd_sink_->RTSPDataReceived(message);
36 }
37 
on_connected()38 void Sink::on_connected() {
39   media_manager_.reset(new GstSinkMediaManager(local_host_));
40   wfd_sink_.reset(wds::Sink::Create(this, media_manager_.get()));
41   wfd_sink_->Start();
42 }
43 
on_connection_failure(ConnectionFailure failure)44 void Sink::on_connection_failure(ConnectionFailure failure) {
45   switch (failure) {
46       case CONNECTION_LOST:
47           std::cout << "* RTSP connection lost" << std::endl;
48       case CONNECTION_TIMEOUT:
49           ;
50   }
51 }
52 
Play()53 void Sink::Play() {
54   wfd_sink_->Play();
55 }
56 
Pause()57 void Sink::Pause() {
58   wfd_sink_->Pause();
59 }
60 
Teardown()61 void Sink::Teardown() {
62   wfd_sink_->Teardown();
63 }
64 
Peer() const65 wds::Peer* Sink::Peer() const {
66   return wfd_sink_.get();
67 }
68 
69