2 * Copyright (C) 2017 Matthew Waters <matthew@centricular.com>
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.
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.
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.
25 #include "gstwebrtcbin.h"
28 _find_pad_template (GstElement * element, GstPadDirection direction,
29 GstPadPresence presence, const gchar * name)
31 GstElementClass *element_class = GST_ELEMENT_GET_CLASS (element);
32 const GList *l = gst_element_class_get_pad_template_list (element_class);
33 GstPadTemplate *templ = NULL;
35 for (; l; l = l->next) {
37 if (templ->direction != direction)
39 if (templ->presence != presence)
41 if (g_strcmp0 (templ->name_template, name) == 0) {
50 _get_latest_sdp (GstWebRTCBin * webrtc)
52 if (webrtc->current_local_description &&
53 webrtc->current_local_description->type == GST_WEBRTC_SDP_TYPE_ANSWER) {
54 return webrtc->current_local_description->sdp;
56 if (webrtc->current_remote_description &&
57 webrtc->current_remote_description->type == GST_WEBRTC_SDP_TYPE_ANSWER) {
58 return webrtc->current_remote_description->sdp;
60 if (webrtc->current_local_description &&
61 webrtc->current_local_description->type == GST_WEBRTC_SDP_TYPE_OFFER) {
62 return webrtc->current_local_description->sdp;
64 if (webrtc->current_remote_description &&
65 webrtc->current_remote_description->type == GST_WEBRTC_SDP_TYPE_OFFER) {
66 return webrtc->current_remote_description->sdp;
73 _create_pad_block (GstElement * element, GstPad * pad, gulong block_id,
74 gpointer user_data, GDestroyNotify notify)
76 struct pad_block *ret = g_new0 (struct pad_block, 1);
78 ret->element = gst_object_ref (element);
79 ret->pad = gst_object_ref (pad);
80 ret->block_id = block_id;
81 ret->user_data = user_data;
88 _free_pad_block (struct pad_block *block)
94 gst_pad_remove_probe (block->pad, block->block_id);
95 gst_object_unref (block->element);
96 gst_object_unref (block->pad);
98 block->notify (block->user_data);
103 _enum_value_to_string (GType type, guint value)
105 GEnumClass *enum_class;
106 GEnumValue *enum_value;
109 enum_class = g_type_class_ref (type);
110 enum_value = g_enum_get_value (enum_class, value);
113 str = g_strdup (enum_value->value_nick);
115 g_type_class_unref (enum_class);
121 _g_checksum_to_webrtc_string (GChecksumType type)
124 case G_CHECKSUM_SHA1:
126 case G_CHECKSUM_SHA256:
128 #ifdef G_CHECKSUM_SHA384
129 case G_CHECKSUM_SHA384:
132 case G_CHECKSUM_SHA512:
135 g_warning ("unknown GChecksumType!");