1 /* GStreamer
2 * Copyright (C) 2017 Matthew Waters <matthew@centricular.com>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20 /**
21 * SECTION:gstwebrtc-receiver
22 * @short_description: RTCRtpReceiver object
23 * @title: GstWebRTCRTPReceiver
24 * @see_also: #GstWebRTCRTPSender, #GstWebRTCRTPTransceiver
25 *
26 * <ulink url="https://www.w3.org/TR/webrtc/#rtcrtpreceiver-interface">https://www.w3.org/TR/webrtc/#rtcrtpreceiver-interface</ulink>
27 */
28
29 #ifdef HAVE_CONFIG_H
30 # include "config.h"
31 #endif
32
33 #include "rtpreceiver.h"
34
35 #define GST_CAT_DEFAULT gst_webrtc_rtp_receiver_debug
36 GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
37
38 #define gst_webrtc_rtp_receiver_parent_class parent_class
39 G_DEFINE_TYPE_WITH_CODE (GstWebRTCRTPReceiver, gst_webrtc_rtp_receiver,
40 GST_TYPE_OBJECT, GST_DEBUG_CATEGORY_INIT (gst_webrtc_rtp_receiver_debug,
41 "webrtcreceiver", 0, "webrtcreceiver"););
42
43 enum
44 {
45 SIGNAL_0,
46 LAST_SIGNAL,
47 };
48
49 enum
50 {
51 PROP_0,
52 };
53
54 //static guint gst_webrtc_rtp_receiver_signals[LAST_SIGNAL] = { 0 };
55
56 void
gst_webrtc_rtp_receiver_set_transport(GstWebRTCRTPReceiver * receiver,GstWebRTCDTLSTransport * transport)57 gst_webrtc_rtp_receiver_set_transport (GstWebRTCRTPReceiver * receiver,
58 GstWebRTCDTLSTransport * transport)
59 {
60 g_return_if_fail (GST_IS_WEBRTC_RTP_RECEIVER (receiver));
61 g_return_if_fail (GST_IS_WEBRTC_DTLS_TRANSPORT (transport));
62
63 GST_OBJECT_LOCK (receiver);
64 gst_object_replace ((GstObject **) & receiver->transport,
65 GST_OBJECT (transport));
66 GST_OBJECT_UNLOCK (receiver);
67 }
68
69 void
gst_webrtc_rtp_receiver_set_rtcp_transport(GstWebRTCRTPReceiver * receiver,GstWebRTCDTLSTransport * transport)70 gst_webrtc_rtp_receiver_set_rtcp_transport (GstWebRTCRTPReceiver * receiver,
71 GstWebRTCDTLSTransport * transport)
72 {
73 g_return_if_fail (GST_IS_WEBRTC_RTP_RECEIVER (receiver));
74 g_return_if_fail (GST_IS_WEBRTC_DTLS_TRANSPORT (transport));
75
76 GST_OBJECT_LOCK (receiver);
77 gst_object_replace ((GstObject **) & receiver->rtcp_transport,
78 GST_OBJECT (transport));
79 GST_OBJECT_UNLOCK (receiver);
80 }
81
82 static void
gst_webrtc_rtp_receiver_set_property(GObject * object,guint prop_id,const GValue * value,GParamSpec * pspec)83 gst_webrtc_rtp_receiver_set_property (GObject * object, guint prop_id,
84 const GValue * value, GParamSpec * pspec)
85 {
86 switch (prop_id) {
87 default:
88 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
89 break;
90 }
91 }
92
93 static void
gst_webrtc_rtp_receiver_get_property(GObject * object,guint prop_id,GValue * value,GParamSpec * pspec)94 gst_webrtc_rtp_receiver_get_property (GObject * object, guint prop_id,
95 GValue * value, GParamSpec * pspec)
96 {
97 switch (prop_id) {
98 default:
99 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
100 break;
101 }
102 }
103
104 static void
gst_webrtc_rtp_receiver_finalize(GObject * object)105 gst_webrtc_rtp_receiver_finalize (GObject * object)
106 {
107 GstWebRTCRTPReceiver *webrtc = GST_WEBRTC_RTP_RECEIVER (object);
108
109 if (webrtc->transport)
110 gst_object_unref (webrtc->transport);
111 webrtc->transport = NULL;
112
113 if (webrtc->rtcp_transport)
114 gst_object_unref (webrtc->rtcp_transport);
115 webrtc->rtcp_transport = NULL;
116
117 G_OBJECT_CLASS (parent_class)->finalize (object);
118 }
119
120 static void
gst_webrtc_rtp_receiver_class_init(GstWebRTCRTPReceiverClass * klass)121 gst_webrtc_rtp_receiver_class_init (GstWebRTCRTPReceiverClass * klass)
122 {
123 GObjectClass *gobject_class = (GObjectClass *) klass;
124
125 gobject_class->get_property = gst_webrtc_rtp_receiver_get_property;
126 gobject_class->set_property = gst_webrtc_rtp_receiver_set_property;
127 gobject_class->finalize = gst_webrtc_rtp_receiver_finalize;
128 }
129
130 static void
gst_webrtc_rtp_receiver_init(GstWebRTCRTPReceiver * webrtc)131 gst_webrtc_rtp_receiver_init (GstWebRTCRTPReceiver * webrtc)
132 {
133 }
134
135 GstWebRTCRTPReceiver *
gst_webrtc_rtp_receiver_new(void)136 gst_webrtc_rtp_receiver_new (void)
137 {
138 return g_object_new (GST_TYPE_WEBRTC_RTP_RECEIVER, NULL);
139 }
140