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-sender
22 * @short_description: RTCRtpSender object
23 * @title: GstWebRTCRTPSender
24 * @see_also: #GstWebRTCRTPReceiver, #GstWebRTCRTPTransceiver
25 *
26 * <https://www.w3.org/TR/webrtc/#rtcrtpsender-interface>
27 */
28
29 #ifdef HAVE_CONFIG_H
30 # include "config.h"
31 #endif
32
33 #include "rtpsender.h"
34 #include "rtptransceiver.h"
35 #include "webrtc-priv.h"
36
37 #define GST_CAT_DEFAULT gst_webrtc_rtp_sender_debug
38 GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
39
40 #define gst_webrtc_rtp_sender_parent_class parent_class
41 G_DEFINE_TYPE_WITH_CODE (GstWebRTCRTPSender, gst_webrtc_rtp_sender,
42 GST_TYPE_OBJECT, GST_DEBUG_CATEGORY_INIT (gst_webrtc_rtp_sender_debug,
43 "webrtcsender", 0, "webrtcsender");
44 );
45
46 enum
47 {
48 SIGNAL_0,
49 LAST_SIGNAL,
50 };
51
52 enum
53 {
54 PROP_0,
55 PROP_PRIORITY,
56 PROP_TRANSPORT,
57 };
58
59 //static guint gst_webrtc_rtp_sender_signals[LAST_SIGNAL] = { 0 };
60
61 /**
62 * gst_webrtc_rtp_sender_set_priority:
63 * @sender: a #GstWebRTCRTPSender
64 * @priority: The priority of this sender
65 *
66 * Sets the content of the IPv4 Type of Service (ToS), also known as DSCP
67 * (Differentiated Services Code Point).
68 * This also sets the Traffic Class field of IPv6.
69 *
70 * Since: 1.20
71 */
72
73 void
gst_webrtc_rtp_sender_set_priority(GstWebRTCRTPSender * sender,GstWebRTCPriorityType priority)74 gst_webrtc_rtp_sender_set_priority (GstWebRTCRTPSender * sender,
75 GstWebRTCPriorityType priority)
76 {
77 GST_OBJECT_LOCK (sender);
78 sender->priority = priority;
79 GST_OBJECT_UNLOCK (sender);
80 g_object_notify (G_OBJECT (sender), "priority");
81 }
82
83 static void
gst_webrtc_rtp_sender_set_property(GObject * object,guint prop_id,const GValue * value,GParamSpec * pspec)84 gst_webrtc_rtp_sender_set_property (GObject * object, guint prop_id,
85 const GValue * value, GParamSpec * pspec)
86 {
87 GstWebRTCRTPSender *sender = GST_WEBRTC_RTP_SENDER (object);
88
89 switch (prop_id) {
90 case PROP_PRIORITY:
91 gst_webrtc_rtp_sender_set_priority (sender, g_value_get_uint (value));
92 break;
93 default:
94 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
95 break;
96 }
97 }
98
99 static void
gst_webrtc_rtp_sender_get_property(GObject * object,guint prop_id,GValue * value,GParamSpec * pspec)100 gst_webrtc_rtp_sender_get_property (GObject * object, guint prop_id,
101 GValue * value, GParamSpec * pspec)
102 {
103 GstWebRTCRTPSender *sender = GST_WEBRTC_RTP_SENDER (object);
104
105 switch (prop_id) {
106 case PROP_PRIORITY:
107 GST_OBJECT_LOCK (sender);
108 g_value_set_uint (value, sender->priority);
109 GST_OBJECT_UNLOCK (sender);
110 break;
111 case PROP_TRANSPORT:
112 GST_OBJECT_LOCK (sender);
113 g_value_set_object (value, sender->transport);
114 GST_OBJECT_UNLOCK (sender);
115 break;
116 default:
117 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
118 break;
119 }
120 }
121
122 static void
gst_webrtc_rtp_sender_finalize(GObject * object)123 gst_webrtc_rtp_sender_finalize (GObject * object)
124 {
125 GstWebRTCRTPSender *sender = GST_WEBRTC_RTP_SENDER (object);
126
127 if (sender->transport)
128 gst_object_unref (sender->transport);
129 sender->transport = NULL;
130
131 G_OBJECT_CLASS (parent_class)->finalize (object);
132 }
133
134 static void
gst_webrtc_rtp_sender_class_init(GstWebRTCRTPSenderClass * klass)135 gst_webrtc_rtp_sender_class_init (GstWebRTCRTPSenderClass * klass)
136 {
137 GObjectClass *gobject_class = (GObjectClass *) klass;
138
139 gobject_class->get_property = gst_webrtc_rtp_sender_get_property;
140 gobject_class->set_property = gst_webrtc_rtp_sender_set_property;
141 gobject_class->finalize = gst_webrtc_rtp_sender_finalize;
142
143 /**
144 * GstWebRTCRTPSender:priority:
145 *
146 * The priority from which to set the DSCP field on packets
147 *
148 * Since: 1.20
149 */
150 g_object_class_install_property (gobject_class,
151 PROP_PRIORITY,
152 g_param_spec_enum ("priority",
153 "Priority",
154 "The priority from which to set the DSCP field on packets",
155 GST_TYPE_WEBRTC_PRIORITY_TYPE, GST_WEBRTC_PRIORITY_TYPE_LOW,
156 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
157
158 /**
159 * GstWebRTCRTPSender:transport:
160 *
161 * The DTLS transport for this sender
162 *
163 * Since: 1.20
164 */
165 g_object_class_install_property (gobject_class,
166 PROP_TRANSPORT,
167 g_param_spec_object ("transport", "Transport",
168 "The DTLS transport for this sender",
169 GST_TYPE_WEBRTC_DTLS_TRANSPORT,
170 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
171 }
172
173 static void
gst_webrtc_rtp_sender_init(GstWebRTCRTPSender * webrtc)174 gst_webrtc_rtp_sender_init (GstWebRTCRTPSender * webrtc)
175 {
176 }
177
178 GstWebRTCRTPSender *
gst_webrtc_rtp_sender_new(void)179 gst_webrtc_rtp_sender_new (void)
180 {
181 return g_object_new (GST_TYPE_WEBRTC_RTP_SENDER, NULL);
182 }
183