2017-01-31 09:56:59 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 2017 Matthew Waters <matthew@centricular.com>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __GST_WEBRTC_BIN_H__
|
|
|
|
#define __GST_WEBRTC_BIN_H__
|
|
|
|
|
|
|
|
#include <gst/sdp/sdp.h>
|
|
|
|
#include "fwd.h"
|
2018-09-10 13:52:05 +00:00
|
|
|
#include "transportstream.h"
|
2021-05-07 06:12:25 +00:00
|
|
|
#include "webrtcsctptransport.h"
|
2017-01-31 09:56:59 +00:00
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
|
|
|
GType gst_webrtc_bin_pad_get_type(void);
|
|
|
|
#define GST_TYPE_WEBRTC_BIN_PAD (gst_webrtc_bin_pad_get_type())
|
|
|
|
#define GST_WEBRTC_BIN_PAD(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_WEBRTC_BIN_PAD,GstWebRTCBinPad))
|
|
|
|
#define GST_IS_WEBRTC_BIN_PAD(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_WEBRTC_BIN_PAD))
|
|
|
|
#define GST_WEBRTC_BIN_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass) ,GST_TYPE_WEBRTC_BIN_PAD,GstWebRTCBinPadClass))
|
|
|
|
#define GST_IS_WEBRTC_BIN_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass) ,GST_TYPE_WEBRTC_BIN_PAD))
|
|
|
|
#define GST_WEBRTC_BIN_PAD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj) ,GST_TYPE_WEBRTC_BIN_PAD,GstWebRTCBinPadClass))
|
|
|
|
|
|
|
|
typedef struct _GstWebRTCBinPad GstWebRTCBinPad;
|
|
|
|
typedef struct _GstWebRTCBinPadClass GstWebRTCBinPadClass;
|
|
|
|
|
2022-10-18 01:17:04 +00:00
|
|
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GstWebRTCBinPad, gst_object_unref);
|
|
|
|
|
2017-01-31 09:56:59 +00:00
|
|
|
struct _GstWebRTCBinPad
|
|
|
|
{
|
|
|
|
GstGhostPad parent;
|
|
|
|
|
|
|
|
GstWebRTCRTPTransceiver *trans;
|
2017-11-29 16:57:52 +00:00
|
|
|
gulong block_id;
|
|
|
|
|
|
|
|
GstCaps *received_caps;
|
2022-10-18 01:17:04 +00:00
|
|
|
char *msid;
|
2017-01-31 09:56:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _GstWebRTCBinPadClass
|
|
|
|
{
|
|
|
|
GstGhostPadClass parent_class;
|
|
|
|
};
|
|
|
|
|
2022-10-18 01:17:04 +00:00
|
|
|
G_DECLARE_FINAL_TYPE (GstWebRTCBinSinkPad, gst_webrtc_bin_sink_pad, GST,
|
|
|
|
WEBRTC_BIN_SINK_PAD, GstWebRTCBinPad);
|
|
|
|
#define GST_TYPE_WEBRTC_BIN_SINK_PAD (gst_webrtc_bin_sink_pad_get_type())
|
|
|
|
|
|
|
|
G_DECLARE_FINAL_TYPE (GstWebRTCBinSrcPad, gst_webrtc_bin_src_pad, GST,
|
|
|
|
WEBRTC_BIN_SRC_PAD, GstWebRTCBinPad);
|
|
|
|
#define GST_TYPE_WEBRTC_BIN_SRC_PAD (gst_webrtc_bin_src_pad_get_type())
|
|
|
|
|
2017-01-31 09:56:59 +00:00
|
|
|
GType gst_webrtc_bin_get_type(void);
|
|
|
|
#define GST_TYPE_WEBRTC_BIN (gst_webrtc_bin_get_type())
|
|
|
|
#define GST_WEBRTC_BIN(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_WEBRTC_BIN,GstWebRTCBin))
|
|
|
|
#define GST_IS_WEBRTC_BIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_WEBRTC_BIN))
|
|
|
|
#define GST_WEBRTC_BIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass) ,GST_TYPE_WEBRTC_BIN,GstWebRTCBinClass))
|
|
|
|
#define GST_IS_WEBRTC_BIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass) ,GST_TYPE_WEBRTC_BIN))
|
|
|
|
#define GST_WEBRTC_BIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj) ,GST_TYPE_WEBRTC_BIN,GstWebRTCBinClass))
|
|
|
|
|
|
|
|
struct _GstWebRTCBin
|
|
|
|
{
|
|
|
|
GstBin parent;
|
|
|
|
|
|
|
|
GstElement *rtpbin;
|
2018-09-13 22:08:34 +00:00
|
|
|
GstElement *rtpfunnel;
|
2017-01-31 09:56:59 +00:00
|
|
|
|
|
|
|
GstWebRTCSignalingState signaling_state;
|
|
|
|
GstWebRTCICEGatheringState ice_gathering_state;
|
|
|
|
GstWebRTCICEConnectionState ice_connection_state;
|
|
|
|
GstWebRTCPeerConnectionState peer_connection_state;
|
|
|
|
|
|
|
|
GstWebRTCSessionDescription *current_local_description;
|
|
|
|
GstWebRTCSessionDescription *pending_local_description;
|
|
|
|
GstWebRTCSessionDescription *current_remote_description;
|
|
|
|
GstWebRTCSessionDescription *pending_remote_description;
|
|
|
|
|
2018-09-13 22:08:34 +00:00
|
|
|
GstWebRTCBundlePolicy bundle_policy;
|
2019-01-17 14:06:06 +00:00
|
|
|
GstWebRTCICETransportPolicy ice_transport_policy;
|
2018-09-13 22:08:34 +00:00
|
|
|
|
2017-01-31 09:56:59 +00:00
|
|
|
GstWebRTCBinPrivate *priv;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _GstWebRTCBinClass
|
|
|
|
{
|
|
|
|
GstBinClass parent_class;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _GstWebRTCBinPrivate
|
|
|
|
{
|
|
|
|
guint max_sink_pad_serial;
|
2021-11-03 09:46:23 +00:00
|
|
|
guint src_pad_counter;
|
2017-01-31 09:56:59 +00:00
|
|
|
|
|
|
|
gboolean bundle;
|
2020-03-09 19:21:19 +00:00
|
|
|
GPtrArray *transceivers;
|
|
|
|
GPtrArray *transports;
|
|
|
|
GPtrArray *data_channels;
|
2018-09-10 13:52:05 +00:00
|
|
|
/* list of data channels we've received a sctp stream for but no data
|
|
|
|
* channel protocol for */
|
2020-03-09 19:21:19 +00:00
|
|
|
GPtrArray *pending_data_channels;
|
2021-04-22 08:43:55 +00:00
|
|
|
/* dc_lock protects data_channels and pending_data_channels */
|
|
|
|
/* lock ordering is pc_lock first, then dc_lock */
|
|
|
|
GMutex dc_lock;
|
2018-09-10 13:52:05 +00:00
|
|
|
|
2020-06-23 19:35:06 +00:00
|
|
|
guint jb_latency;
|
|
|
|
|
2021-05-07 06:12:25 +00:00
|
|
|
WebRTCSCTPTransport *sctp_transport;
|
2018-09-10 13:52:05 +00:00
|
|
|
TransportStream *data_channel_transport;
|
2017-01-31 09:56:59 +00:00
|
|
|
|
|
|
|
GstWebRTCICE *ice;
|
|
|
|
GArray *ice_stream_map;
|
2020-03-09 17:22:57 +00:00
|
|
|
GMutex ice_lock;
|
|
|
|
GArray *pending_remote_ice_candidates;
|
2020-03-09 18:18:40 +00:00
|
|
|
GArray *pending_local_ice_candidates;
|
2017-01-31 09:56:59 +00:00
|
|
|
|
|
|
|
/* peerconnection variables */
|
|
|
|
gboolean is_closed;
|
|
|
|
gboolean need_negotiation;
|
|
|
|
|
|
|
|
/* peerconnection helper thread for promises */
|
|
|
|
GMainContext *main_context;
|
|
|
|
GMainLoop *loop;
|
|
|
|
GThread *thread;
|
|
|
|
GMutex pc_lock;
|
|
|
|
GCond pc_cond;
|
|
|
|
|
|
|
|
gboolean running;
|
|
|
|
gboolean async_pending;
|
|
|
|
|
|
|
|
GList *pending_pads;
|
2017-11-29 16:57:52 +00:00
|
|
|
GList *pending_sink_transceivers;
|
2017-01-31 09:56:59 +00:00
|
|
|
|
|
|
|
/* count of the number of media streams we've offered for uniqueness */
|
|
|
|
/* FIXME: overflow? */
|
|
|
|
guint media_counter;
|
2018-11-28 06:23:31 +00:00
|
|
|
/* the number of times create_offer has been called for the version field */
|
|
|
|
guint offer_count;
|
2019-07-03 03:48:49 +00:00
|
|
|
GstWebRTCSessionDescription *last_generated_offer;
|
|
|
|
GstWebRTCSessionDescription *last_generated_answer;
|
2017-01-31 09:56:59 +00:00
|
|
|
|
2020-07-08 21:24:36 +00:00
|
|
|
gboolean tos_attached;
|
2017-01-31 09:56:59 +00:00
|
|
|
};
|
|
|
|
|
2021-04-01 18:51:30 +00:00
|
|
|
typedef GstStructure *(*GstWebRTCBinFunc) (GstWebRTCBin * webrtc, gpointer data);
|
2017-01-31 09:56:59 +00:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GstWebRTCBin *webrtc;
|
|
|
|
GstWebRTCBinFunc op;
|
|
|
|
gpointer data;
|
|
|
|
GDestroyNotify notify;
|
2020-05-05 14:30:34 +00:00
|
|
|
GstPromise *promise;
|
2017-01-31 09:56:59 +00:00
|
|
|
} GstWebRTCBinTask;
|
|
|
|
|
2020-05-05 14:30:34 +00:00
|
|
|
gboolean gst_webrtc_bin_enqueue_task (GstWebRTCBin * pc,
|
2017-01-31 09:56:59 +00:00
|
|
|
GstWebRTCBinFunc func,
|
|
|
|
gpointer data,
|
2020-05-05 14:30:34 +00:00
|
|
|
GDestroyNotify notify,
|
|
|
|
GstPromise *promise);
|
2017-01-31 09:56:59 +00:00
|
|
|
|
|
|
|
G_END_DECLS
|
|
|
|
|
|
|
|
#endif /* __GST_WEBRTC_BIN_H__ */
|