1#ifndef RESIP_GSTREAMER_UTILS
2#define RESIP_GSTREAMER_UTILS
12#include <glibmm/main.h>
13#include <glibmm/exceptionhandler.h>
14#include <glibmm/ustring.h>
15#include <gstreamermm.h>
17#include <gst/webrtc/webrtc.h>
42static const std::map<GstWebRTCICEConnectionState, const resip::Data> iCEConnectionStates =
44 {GST_WEBRTC_ICE_CONNECTION_STATE_NEW,
"new"},
45 {GST_WEBRTC_ICE_CONNECTION_STATE_CHECKING,
"checking"},
46 {GST_WEBRTC_ICE_CONNECTION_STATE_CONNECTED,
"connected"},
47 {GST_WEBRTC_ICE_CONNECTION_STATE_COMPLETED,
"completed"},
48 {GST_WEBRTC_ICE_CONNECTION_STATE_FAILED,
"failed"},
49 {GST_WEBRTC_ICE_CONNECTION_STATE_DISCONNECTED,
"disconnected"},
50 {GST_WEBRTC_ICE_CONNECTION_STATE_CLOSED,
"closed"}
53static const std::map<GstWebRTCICEGatheringState, const resip::Data> iCEGatheringStates =
55 {GST_WEBRTC_ICE_GATHERING_STATE_NEW,
"new"},
56 {GST_WEBRTC_ICE_GATHERING_STATE_GATHERING,
"gathering"},
57 {GST_WEBRTC_ICE_GATHERING_STATE_COMPLETE,
"complete"}
60static const std::map<GstWebRTCSignalingState, const resip::Data> signalingStates =
62 {GST_WEBRTC_SIGNALING_STATE_STABLE,
"stable"},
63 {GST_WEBRTC_SIGNALING_STATE_CLOSED,
"closed"},
64 {GST_WEBRTC_SIGNALING_STATE_HAVE_LOCAL_OFFER,
"local-offer"},
65 {GST_WEBRTC_SIGNALING_STATE_HAVE_REMOTE_OFFER,
"remote-offer"},
66 {GST_WEBRTC_SIGNALING_STATE_HAVE_LOCAL_PRANSWER,
"local-pranswer"},
67 {GST_WEBRTC_SIGNALING_STATE_HAVE_REMOTE_PRANSWER,
"remote-pranswer"}
71const Data& lookupGstreamerStateName(std::map<T, const Data> m, T v)
77 static Data unknown(
"UNKNOWN STATE");
83Glib::RefPtr<Gst::Element> buildTestSource(
const Data& streamName);
87MediaTypeName getMediaTypeName(
const Glib::RefPtr<Gst::Caps>& caps);
89int getStreamIdFromPadName(
const Glib::ustring padName);
91resip::Data deduceKeyForPadName(
const Glib::ustring padName);
100void storeGstreamerGraph(Glib::RefPtr<Gst::Bin>& bin,
const resip::Data& fileNamePrefix);
102void gstWebRTCSetDescription(Glib::RefPtr<Gst::Element> element,
const gchar* signalName, GstWebRTCSessionDescription* gstwebrtcdesc);
106std::shared_ptr<GstWebRTCSessionDescription> createGstWebRTCSessionDescriptionFromSdpContents(GstWebRTCSDPType sdpType,
const resip::SdpContents& sdp);
108void addGstreamerKeyframeProbe(
const Glib::RefPtr<Gst::Pad>&
pad, std::function<
void()> onKeyframeRequired);
115typedef std::vector<RtcpPeerSpec> RtcpPeerSpecVector;
118bool addGstreamerRtcpMonitoringPads(Glib::RefPtr<Gst::Bin> bin, std::shared_ptr<HepAgent> hepAgent,
const RtcpPeerSpecVector& peerSpecs,
const Data& correlationId);
126void linkGstreamerRtcpHomer(Glib::RefPtr<Gst::Bin> bin, Glib::RefPtr<Gst::Pad>
pad, std::shared_ptr<resip::HepAgent> hepAgent,
const RtcpPeerSpecVector& peerSpecs,
const resip::Data& correlationId);
128RtcpPeerSpecVector createRtcpPeerSpecs(
const SdpContents& local,
const SdpContents& remote);
137static inline T transform(T p) {
return p; }
139static inline Glib::RefPtr<Gst::Caps> transform (
GstCaps*
c) {
return Glib::wrap(
c,
true); }
140static inline Glib::RefPtr<Gst::Pad> transform (
GstPad*
c) {
return Glib::wrap(
c,
true); }
141static inline Glib::RefPtr<Gst::Element> transform (
GstElement*
c) {
return Glib::wrap(
c,
true); }
146 template<
class U,
typename=
typename U::element_type::BaseObjectType>
147 static typename U::element_type::BaseObjectType* test (
int);
152 using type =
decltype (
test<T> (0));
156template<
typename SlotType,
typename ...T>
160 Gst::Element*
obj =
dynamic_cast<Gst::Element*
>(Glib::ObjectBase::_get_current_wrapper((
GObject*)
self));
166 if(sigc::slot_base *
const slot = Glib::SignalProxyNormal::data_to_slot(data))
173 Glib::exception_handlers_invoke();
179typedef std::pair<GType,Glib::ustring>
SIDictKey;
185 std::shared_ptr<SignalProxyInfo> info;
static const Data pad("\0\0\0\0\0\0\0", 7)
#define resip_assert(x)
This file needs to work for both C and C++ code.
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Provides an interface to process and generate SDP bodies (MIME content-type application/sdp).
Represents a network address.
dcm! – add UnusedChecking(_enum) below;