webrtcbin: an element that handles the transport aspects of webrtc connections
[platform/upstream/gst-plugins-bad.git] / gst-libs / gst / webrtc / rtpreceiver.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-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
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_replace ((GstObject **) & receiver->transport,
64       GST_OBJECT (transport));
65 }
66
67 void
68 gst_webrtc_rtp_receiver_set_rtcp_transport (GstWebRTCRTPReceiver * receiver,
69     GstWebRTCDTLSTransport * transport)
70 {
71   g_return_if_fail (GST_IS_WEBRTC_RTP_RECEIVER (receiver));
72   g_return_if_fail (GST_IS_WEBRTC_DTLS_TRANSPORT (transport));
73
74   gst_object_replace ((GstObject **) & receiver->rtcp_transport,
75       GST_OBJECT (transport));
76 }
77
78 static void
79 gst_webrtc_rtp_receiver_set_property (GObject * object, guint prop_id,
80     const GValue * value, GParamSpec * pspec)
81 {
82   switch (prop_id) {
83     default:
84       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
85       break;
86   }
87 }
88
89 static void
90 gst_webrtc_rtp_receiver_get_property (GObject * object, guint prop_id,
91     GValue * value, GParamSpec * pspec)
92 {
93   switch (prop_id) {
94     default:
95       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
96       break;
97   }
98 }
99
100 static void
101 gst_webrtc_rtp_receiver_finalize (GObject * object)
102 {
103   GstWebRTCRTPReceiver *webrtc = GST_WEBRTC_RTP_RECEIVER (object);
104
105   if (webrtc->transport)
106     gst_object_unref (webrtc->transport);
107   webrtc->transport = NULL;
108
109   if (webrtc->rtcp_transport)
110     gst_object_unref (webrtc->rtcp_transport);
111   webrtc->rtcp_transport = NULL;
112
113   G_OBJECT_CLASS (parent_class)->finalize (object);
114 }
115
116 static void
117 gst_webrtc_rtp_receiver_class_init (GstWebRTCRTPReceiverClass * klass)
118 {
119   GObjectClass *gobject_class = (GObjectClass *) klass;
120
121   gobject_class->get_property = gst_webrtc_rtp_receiver_get_property;
122   gobject_class->set_property = gst_webrtc_rtp_receiver_set_property;
123   gobject_class->finalize = gst_webrtc_rtp_receiver_finalize;
124 }
125
126 static void
127 gst_webrtc_rtp_receiver_init (GstWebRTCRTPReceiver * webrtc)
128 {
129 }
130
131 GstWebRTCRTPReceiver *
132 gst_webrtc_rtp_receiver_new (void)
133 {
134   return g_object_new (GST_TYPE_WEBRTC_RTP_RECEIVER, NULL);
135 }