reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
GstRtpSession.hxx
Go to the documentation of this file.
1#ifndef RESIP_GSTRTPSESSION
2#define RESIP_GSTRTPSESSION
3
4#ifdef HAVE_CONFIG_H
5#include "config.h"
6#endif
7
8#ifdef USE_GSTREAMER
9#include <map>
10#include <utility>
11#include <type_traits>
12#include <glibmm/main.h>
13#include <glibmm/exceptionhandler.h>
14#include <glibmm/ustring.h>
15#include <gstreamermm.h>
16
17#include <gst/webrtc/webrtc.h>
18
19#include "../../rutil/Subsystem.hxx"
20#include "../../rutil/Log.hxx"
21#include "../../rutil/hep/HepAgent.hxx"
22#include "../../resip/stack/SdpContents.hxx"
23#include "../../resip/stack/Tuple.hxx"
24#include "../../rutil/hep/HepAgent.hxx"
25
26#include "../RTPPortManager.hxx"
27
28#include "GstRtpManager.hxx"
29
30namespace resipgst
31{
32
33class GstRtpManager;
34
35class GstRtpSession
36{
37 public:
39 virtual ~GstRtpSession();
40 virtual std::shared_ptr<resip::SdpContents> buildOffer(bool audio, bool video);
41 virtual std::shared_ptr<resip::SdpContents> buildAnswer(std::shared_ptr<resip::SdpContents> remoteOffer);
42 virtual void processAnswer(std::shared_ptr<resip::SdpContents> remoteAnswer);
43
44 virtual Glib::RefPtr<Gst::Caps> getCaps(resip::SdpContents::Session::Medium& m);
45 // FIXME - assumes only one medium for each name
46 virtual Glib::RefPtr<Gst::Caps> getCaps(const resip::Data& mediumName);
47
48 Glib::RefPtr<Gst::Bin> createOutgoingPipeline(const Glib::RefPtr<Gst::Caps> caps);
49 Glib::RefPtr<Gst::Bin> createDecodeBin(const resip::Data& streamKey, const Glib::ustring& srcPadName, bool isWebRTC);
50 Glib::RefPtr<Gst::Pad> createMediaSink(Glib::RefPtr<Gst::Caps> caps, unsigned int streamId);
51
52 virtual Glib::RefPtr<Gst::Bin> getMediaBin() { return mMediaBin; };
53 //virtual void setRtpTransportBin(Glib::RefPtr<Gst::Bin> bin);
54 virtual Glib::RefPtr<Gst::Bin> getRtpTransportBin();
55
56 // FIXME - use a signal handler to invoke this, make it private
57 virtual void onPlaying();
58
59 std::shared_ptr<resip::SdpContents> getLocalSdp() const { return mLocal; };
60 void setLocalSdp(std::shared_ptr<resip::SdpContents> local) { mLocal = local; };
61 std::shared_ptr<resip::SdpContents> getRemoteSdp() const { return mRemote; };
62 void setRemoteSdp(std::shared_ptr<resip::SdpContents> remote);
63
64 typedef std::vector<Glib::RefPtr<Gst::Caps>> CapsVector;
65 const CapsVector& getOutgoingCaps() const { return mOutgoingCaps; };
66 typedef std::vector<Glib::RefPtr<Gst::Pad>> PadVector;
67 const PadVector& getOutgoingPads() const { return mOutgoingPads; };
68
69 virtual bool isWebRTC() const { return mWebRTC; };
70
72
73 virtual unsigned int getStreamCount();
74
75 virtual void initOutgoingBins();
76
77 virtual void initHomer(const resip::Data& correlationId, std::shared_ptr<resip::HepAgent> hepAgent);
78
79 virtual void addStream(Glib::RefPtr<Gst::Caps> caps);
80
81 private:
82 virtual void initRtpRxPorts();
83 virtual void initRtpTxPorts();
84 virtual void createRtpTransportBin();
85 virtual void createDecodeBinForStream(const Glib::RefPtr<Gst::Pad>& pad, unsigned int streamId, int pt);
86
87 const resip::Data& getLocalAddress() const;
88 unsigned int allocatePort();
89
90 virtual void initCaps(std::shared_ptr<resip::SdpContents> sdp, CapsVector& sessionCaps);
91
93 bool mWebRTC;
94
95 std::shared_ptr<resip::SdpContents> mLocal;
96 std::shared_ptr<resip::SdpContents> mRemote;
97
98 // contains the encode and decodes and the transport wrapper
99 Glib::RefPtr<Gst::Bin> mMediaBin;
100 // wraps the transport (webrtcbin or rtpbin)
101 Glib::RefPtr<Gst::Bin> mRtpTransportBin;
102
103 std::vector<Glib::RefPtr<Gst::Pad> > mSourcePads;
104 std::map<unsigned int, Glib::RefPtr<Gst::Element> > mSendSinks;
105 std::map<unsigned int, Glib::RefPtr<Gst::Element> > mSendRtcpSinks;
106
107 unsigned int mStreamCount = 0;
108 unsigned int mDecodes = 0;
109
110 std::function<void()> mOnKeyframeRequired;
111
114
115 // for HOMER / HEP / EEP
117 std::shared_ptr<resip::HepAgent> mHepAgent;
118};
119
120}
121
122#endif
123
124#endif
125
126/* ====================================================================
127 *
128 * Copyright (c) 2022, Software Freedom Institute https://softwarefreedom.institute
129 * Copyright (c) 2022, Daniel Pocock https://danielpocock.com
130 *
131 * Redistribution and use in source and binary forms, with or without
132 * modification, are permitted provided that the following conditions
133 * are met:
134 *
135 * 1. Redistributions of source code must retain the above copyright
136 * notice, this list of conditions and the following disclaimer.
137 *
138 * 2. Redistributions in binary form must reproduce the above copyright
139 * notice, this list of conditions and the following disclaimer in
140 * the documentation and/or other materials provided with the
141 * distribution.
142 *
143 * 3. Neither the name of the author(s) nor the names of any contributors
144 * may be used to endorse or promote products derived from this software
145 * without specific prior written permission.
146 *
147 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND CONTRIBUTORS "AS IS" AND
148 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
149 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
150 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTORS BE LIABLE
151 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
152 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
153 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
154 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
155 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
156 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
157 * SUCH DAMAGE.
158 *
159 * ====================================================================
160 *
161 *
162 */
static const Data pad("\0\0\0\0\0\0\0", 7)
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
process m= (media announcement) blocks
void list()
Definition userAdmin.cxx:66