From c3c4b07ad3259eab6afabece12186959c4e92e72 Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Thu, 6 Dec 2018 23:25:54 +1100 Subject: [PATCH] webrtc/transceiver: add a set_direction function Matches the setDirection() from the W3C spec and allows changing the transceiver direction at the next negotiation cycle. --- ext/webrtc/webrtctransceiver.c | 10 ++++++++++ gst-libs/gst/webrtc/rtptransceiver.c | 16 ++++++++++++++++ gst-libs/gst/webrtc/rtptransceiver.h | 10 +++++++++- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/ext/webrtc/webrtctransceiver.c b/ext/webrtc/webrtctransceiver.c index c1a3faa1c2..64030acdbe 100644 --- a/ext/webrtc/webrtctransceiver.c +++ b/ext/webrtc/webrtctransceiver.c @@ -97,6 +97,12 @@ webrtc_transceiver_get_rtcp_dtls_transport (GstWebRTCRTPTransceiver * trans) return NULL; } +static void +webrtc_transceiver_set_direction (GstWebRTCRTPTransceiver * trans, + GstWebRTCRTPTransceiverDirection direction) +{ +} + static void webrtc_transceiver_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) @@ -172,12 +178,16 @@ webrtc_transceiver_finalize (GObject * object) static void webrtc_transceiver_class_init (WebRTCTransceiverClass * klass) { + GstWebRTCRTPTransceiverClass *trans_class = + (GstWebRTCRTPTransceiverClass *) klass; GObjectClass *gobject_class = (GObjectClass *) klass; gobject_class->get_property = webrtc_transceiver_get_property; gobject_class->set_property = webrtc_transceiver_set_property; gobject_class->finalize = webrtc_transceiver_finalize; + trans_class->set_direction = webrtc_transceiver_set_direction; + /* some acrobatics are required to set the parent before _constructed() * has been called */ g_object_class_install_property (gobject_class, diff --git a/gst-libs/gst/webrtc/rtptransceiver.c b/gst-libs/gst/webrtc/rtptransceiver.c index d0d9628d0f..332c1bd058 100644 --- a/gst-libs/gst/webrtc/rtptransceiver.c +++ b/gst-libs/gst/webrtc/rtptransceiver.c @@ -61,6 +61,22 @@ enum //static guint gst_webrtc_rtp_transceiver_signals[LAST_SIGNAL] = { 0 }; +void +gst_webrtc_rtp_transceiver_set_direction (GstWebRTCRTPTransceiver * trans, + GstWebRTCRTPTransceiverDirection direction) +{ + GstWebRTCRTPTransceiverClass *trans_class; + + GST_OBJECT_LOCK (trans); + trans->direction = direction; + + trans_class = GST_WEBRTC_RTP_TRANSCEIVER_GET_CLASS (trans); + + g_assert (trans_class->set_direction); + trans_class->set_direction (trans, direction); + GST_OBJECT_UNLOCK (trans); +} + static void gst_webrtc_rtp_transceiver_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) diff --git a/gst-libs/gst/webrtc/rtptransceiver.h b/gst-libs/gst/webrtc/rtptransceiver.h index 4e5c0a5af0..78c8a6d7ee 100644 --- a/gst-libs/gst/webrtc/rtptransceiver.h +++ b/gst-libs/gst/webrtc/rtptransceiver.h @@ -61,13 +61,21 @@ struct _GstWebRTCRTPTransceiverClass { GstObjectClass parent_class; - gpointer _padding[GST_PADDING]; + void (*set_direction) (GstWebRTCRTPTransceiver * trans, + GstWebRTCRTPTransceiverDirection direction); + + /* FIXME; reset */ + gpointer _padding[GST_PADDING-1]; }; #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstWebRTCRTPTransceiver, gst_object_unref) #endif +GST_WEBRTC_API +void gst_webrtc_rtp_transceiver_set_direction (GstWebRTCRTPTransceiver * trans, + GstWebRTCRTPTransceiverDirection direction); + G_END_DECLS #endif /* __GST_WEBRTC_RTP_TRANSCEIVER_H__ */