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-transceiver
22 * @short_description: RTCRtpTransceiver object
23 * @title: GstWebRTCRTPTransceiver
24 * @see_also: #GstWebRTCRTPSender, #GstWebRTCRTPReceiver
25 *
26 * <ulink url="https://www.w3.org/TR/webrtc/#rtcrtptransceiver-interface">https://www.w3.org/TR/webrtc/#rtcrtptransceiver-interface</ulink>
27 */
28
29 #ifdef HAVE_CONFIG_H
30 # include "config.h"
31 #endif
32
33 #include "rtptransceiver.h"
34
35 #define GST_CAT_DEFAULT gst_webrtc_rtp_transceiver_debug
36 GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
37
38 #define gst_webrtc_rtp_transceiver_parent_class parent_class
39 G_DEFINE_ABSTRACT_TYPE_WITH_CODE (GstWebRTCRTPTransceiver,
40 gst_webrtc_rtp_transceiver, GST_TYPE_OBJECT,
41 GST_DEBUG_CATEGORY_INIT (gst_webrtc_rtp_transceiver_debug,
42 "webrtctransceiver", 0, "webrtctransceiver");
43 );
44
45 enum
46 {
47 SIGNAL_0,
48 LAST_SIGNAL,
49 };
50
51 enum
52 {
53 PROP_0,
54 PROP_MID,
55 PROP_SENDER,
56 PROP_RECEIVER,
57 PROP_STOPPED, // FIXME
58 PROP_DIRECTION, // FIXME
59 PROP_MLINE,
60 };
61
62 //static guint gst_webrtc_rtp_transceiver_signals[LAST_SIGNAL] = { 0 };
63
64 static void
gst_webrtc_rtp_transceiver_set_property(GObject * object,guint prop_id,const GValue * value,GParamSpec * pspec)65 gst_webrtc_rtp_transceiver_set_property (GObject * object, guint prop_id,
66 const GValue * value, GParamSpec * pspec)
67 {
68 GstWebRTCRTPTransceiver *webrtc = GST_WEBRTC_RTP_TRANSCEIVER (object);
69
70 switch (prop_id) {
71 case PROP_SENDER:
72 webrtc->sender = g_value_dup_object (value);
73 break;
74 case PROP_RECEIVER:
75 webrtc->receiver = g_value_dup_object (value);
76 break;
77 case PROP_MLINE:
78 webrtc->mline = g_value_get_uint (value);
79 break;
80 default:
81 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
82 break;
83 }
84 }
85
86 static void
gst_webrtc_rtp_transceiver_get_property(GObject * object,guint prop_id,GValue * value,GParamSpec * pspec)87 gst_webrtc_rtp_transceiver_get_property (GObject * object, guint prop_id,
88 GValue * value, GParamSpec * pspec)
89 {
90 GstWebRTCRTPTransceiver *webrtc = GST_WEBRTC_RTP_TRANSCEIVER (object);
91
92 switch (prop_id) {
93 case PROP_SENDER:
94 g_value_set_object (value, webrtc->sender);
95 break;
96 case PROP_RECEIVER:
97 g_value_set_object (value, webrtc->receiver);
98 break;
99 case PROP_MLINE:
100 g_value_set_uint (value, webrtc->mline);
101 break;
102 default:
103 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
104 break;
105 }
106 }
107
108 static void
gst_webrtc_rtp_transceiver_constructed(GObject * object)109 gst_webrtc_rtp_transceiver_constructed (GObject * object)
110 {
111 GstWebRTCRTPTransceiver *webrtc = GST_WEBRTC_RTP_TRANSCEIVER (object);
112
113 gst_object_set_parent (GST_OBJECT (webrtc->sender), GST_OBJECT (webrtc));
114 gst_object_set_parent (GST_OBJECT (webrtc->receiver), GST_OBJECT (webrtc));
115
116 G_OBJECT_CLASS (parent_class)->constructed (object);
117 }
118
119 static void
gst_webrtc_rtp_transceiver_dispose(GObject * object)120 gst_webrtc_rtp_transceiver_dispose (GObject * object)
121 {
122 GstWebRTCRTPTransceiver *webrtc = GST_WEBRTC_RTP_TRANSCEIVER (object);
123
124 if (webrtc->sender) {
125 GST_OBJECT_PARENT (webrtc->sender) = NULL;
126 gst_object_unref (webrtc->sender);
127 }
128 webrtc->sender = NULL;
129 if (webrtc->receiver) {
130 GST_OBJECT_PARENT (webrtc->receiver) = NULL;
131 gst_object_unref (webrtc->receiver);
132 }
133 webrtc->receiver = NULL;
134
135 G_OBJECT_CLASS (parent_class)->dispose (object);
136 }
137
138 static void
gst_webrtc_rtp_transceiver_finalize(GObject * object)139 gst_webrtc_rtp_transceiver_finalize (GObject * object)
140 {
141 GstWebRTCRTPTransceiver *webrtc = GST_WEBRTC_RTP_TRANSCEIVER (object);
142
143 g_free (webrtc->mid);
144 if (webrtc->codec_preferences)
145 gst_caps_unref (webrtc->codec_preferences);
146
147 G_OBJECT_CLASS (parent_class)->finalize (object);
148 }
149
150 static void
gst_webrtc_rtp_transceiver_class_init(GstWebRTCRTPTransceiverClass * klass)151 gst_webrtc_rtp_transceiver_class_init (GstWebRTCRTPTransceiverClass * klass)
152 {
153 GObjectClass *gobject_class = (GObjectClass *) klass;
154
155 gobject_class->get_property = gst_webrtc_rtp_transceiver_get_property;
156 gobject_class->set_property = gst_webrtc_rtp_transceiver_set_property;
157 gobject_class->constructed = gst_webrtc_rtp_transceiver_constructed;
158 gobject_class->dispose = gst_webrtc_rtp_transceiver_dispose;
159 gobject_class->finalize = gst_webrtc_rtp_transceiver_finalize;
160
161 g_object_class_install_property (gobject_class,
162 PROP_SENDER,
163 g_param_spec_object ("sender", "Sender",
164 "The RTP sender for this transceiver",
165 GST_TYPE_WEBRTC_RTP_SENDER,
166 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
167
168 g_object_class_install_property (gobject_class,
169 PROP_RECEIVER,
170 g_param_spec_object ("receiver", "Receiver",
171 "The RTP receiver for this transceiver",
172 GST_TYPE_WEBRTC_RTP_RECEIVER,
173 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
174
175 g_object_class_install_property (gobject_class,
176 PROP_MLINE,
177 g_param_spec_uint ("mlineindex", "Media Line Index",
178 "Index in the SDP of the Media",
179 0, G_MAXUINT, 0,
180 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
181 }
182
183 static void
gst_webrtc_rtp_transceiver_init(GstWebRTCRTPTransceiver * webrtc)184 gst_webrtc_rtp_transceiver_init (GstWebRTCRTPTransceiver * webrtc)
185 {
186 }
187