webrtcbin: an element that handles the transport aspects of webrtc connections
[platform/upstream/gst-plugins-bad.git] / gst-libs / gst / webrtc / rtpsender.c
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  * <ulink url="https://www.w3.org/TR/webrtc/#rtcrtpsender-interface">https://www.w3.org/TR/webrtc/#rtcrtpsender-interface</ulink>
27  */
28
29 #ifdef HAVE_CONFIG_H
30 # include "config.h"
31 #endif
32
33 #include "rtpsender.h"
34 #include "rtptransceiver.h"
35
36 #define GST_CAT_DEFAULT gst_webrtc_rtp_sender_debug
37 GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
38
39 #define gst_webrtc_rtp_sender_parent_class parent_class
40 G_DEFINE_TYPE_WITH_CODE (GstWebRTCRTPSender, gst_webrtc_rtp_sender,
41     GST_TYPE_OBJECT, GST_DEBUG_CATEGORY_INIT (gst_webrtc_rtp_sender_debug,
42         "webrtcsender", 0, "webrtcsender");
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_STOPPED,
57   PROP_DIRECTION,
58 };
59
60 //static guint gst_webrtc_rtp_sender_signals[LAST_SIGNAL] = { 0 };
61
62 void
63 gst_webrtc_rtp_sender_set_transport (GstWebRTCRTPSender * sender,
64     GstWebRTCDTLSTransport * transport)
65 {
66   g_return_if_fail (GST_IS_WEBRTC_RTP_SENDER (sender));
67   g_return_if_fail (GST_IS_WEBRTC_DTLS_TRANSPORT (transport));
68
69   gst_object_replace ((GstObject **) & sender->transport,
70       GST_OBJECT (transport));
71 }
72
73 void
74 gst_webrtc_rtp_sender_set_rtcp_transport (GstWebRTCRTPSender * sender,
75     GstWebRTCDTLSTransport * transport)
76 {
77   g_return_if_fail (GST_IS_WEBRTC_RTP_SENDER (sender));
78   g_return_if_fail (GST_IS_WEBRTC_DTLS_TRANSPORT (transport));
79
80   gst_object_replace ((GstObject **) & sender->rtcp_transport,
81       GST_OBJECT (transport));
82 }
83
84 static void
85 gst_webrtc_rtp_sender_set_property (GObject * object, guint prop_id,
86     const GValue * value, GParamSpec * pspec)
87 {
88   switch (prop_id) {
89     default:
90       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
91       break;
92   }
93 }
94
95 static void
96 gst_webrtc_rtp_sender_get_property (GObject * object, guint prop_id,
97     GValue * value, GParamSpec * pspec)
98 {
99   switch (prop_id) {
100     default:
101       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
102       break;
103   }
104 }
105
106 static void
107 gst_webrtc_rtp_sender_finalize (GObject * object)
108 {
109   GstWebRTCRTPSender *webrtc = GST_WEBRTC_RTP_SENDER (object);
110
111   if (webrtc->transport)
112     gst_object_unref (webrtc->transport);
113   webrtc->transport = NULL;
114
115   if (webrtc->rtcp_transport)
116     gst_object_unref (webrtc->rtcp_transport);
117   webrtc->rtcp_transport = NULL;
118
119   G_OBJECT_CLASS (parent_class)->finalize (object);
120 }
121
122 static void
123 gst_webrtc_rtp_sender_class_init (GstWebRTCRTPSenderClass * klass)
124 {
125   GObjectClass *gobject_class = (GObjectClass *) klass;
126
127   gobject_class->get_property = gst_webrtc_rtp_sender_get_property;
128   gobject_class->set_property = gst_webrtc_rtp_sender_set_property;
129   gobject_class->finalize = gst_webrtc_rtp_sender_finalize;
130 }
131
132 static void
133 gst_webrtc_rtp_sender_init (GstWebRTCRTPSender * webrtc)
134 {
135 }
136
137 GstWebRTCRTPSender *
138 gst_webrtc_rtp_sender_new (GArray * send_encodings /* FIXME */ )
139 {
140   return g_object_new (GST_TYPE_WEBRTC_RTP_SENDER, NULL);
141 }