1 /*
2 * Copyright (c) 2015, Collabora Ltd.
3 *
4 * Redistribution and use in source and binary forms, with or without modification,
5 * are permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright notice, this
8 * list of conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this
11 * list of conditions and the following disclaimer in the documentation and/or other
12 * materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
18 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
21 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
23 * OF SUCH DAMAGE.
24 */
25 #ifdef HAVE_CONFIG_H
26 #include "config.h"
27 #endif
28
29 #include "sctpsendmeta.h"
30
31 static gboolean gst_sctp_send_meta_init (GstMeta * meta, gpointer params,
32 GstBuffer * buffer);
33 static gboolean gst_sctp_send_meta_transform (GstBuffer * transbuf,
34 GstMeta * meta, GstBuffer * buffer, GQuark type, gpointer data);
35
36 GType
gst_sctp_send_meta_api_get_type(void)37 gst_sctp_send_meta_api_get_type (void)
38 {
39 static const gchar *tags[] = { NULL };
40 static GType type;
41 if (g_once_init_enter (&type)) {
42 GType _type = gst_meta_api_type_register ("GstSctpSendMetaAPI", tags);
43 g_once_init_leave (&type, _type);
44 }
45 return type;
46 }
47
48 const GstMetaInfo *
gst_sctp_send_meta_get_info(void)49 gst_sctp_send_meta_get_info (void)
50 {
51 static const GstMetaInfo *gst_sctp_send_meta_info = NULL;
52
53 if (g_once_init_enter (&gst_sctp_send_meta_info)) {
54 const GstMetaInfo *meta = gst_meta_register (GST_SCTP_SEND_META_API_TYPE,
55 "GstSctpSendMeta",
56 sizeof (GstSctpSendMeta),
57 gst_sctp_send_meta_init,
58 (GstMetaFreeFunction) NULL,
59 gst_sctp_send_meta_transform);
60 g_once_init_leave (&gst_sctp_send_meta_info, meta);
61 }
62 return gst_sctp_send_meta_info;
63 }
64
65 static gboolean
gst_sctp_send_meta_init(GstMeta * meta,gpointer params,GstBuffer * buffer)66 gst_sctp_send_meta_init (GstMeta * meta, gpointer params, GstBuffer * buffer)
67 {
68 GstSctpSendMeta *gst_sctp_send_meta = (GstSctpSendMeta *) meta;
69 gst_sctp_send_meta->ppid = 0;
70 gst_sctp_send_meta->ordered = TRUE;
71 gst_sctp_send_meta->pr = GST_SCTP_SEND_META_PARTIAL_RELIABILITY_NONE;
72 gst_sctp_send_meta->pr_param = 0;
73 return TRUE;
74 }
75
76 static gboolean
gst_sctp_send_meta_transform(GstBuffer * transbuf,GstMeta * meta,GstBuffer * buffer,GQuark type,gpointer data)77 gst_sctp_send_meta_transform (GstBuffer * transbuf, GstMeta * meta,
78 GstBuffer * buffer, GQuark type, gpointer data)
79 {
80 GstSctpSendMeta *gst_sctp_send_meta = (GstSctpSendMeta *) meta;
81 gst_sctp_buffer_add_send_meta (transbuf, gst_sctp_send_meta->ppid,
82 gst_sctp_send_meta->ordered, gst_sctp_send_meta->pr,
83 gst_sctp_send_meta->pr_param);
84 return TRUE;
85 }
86
87 GstSctpSendMeta *
gst_sctp_buffer_add_send_meta(GstBuffer * buffer,guint32 ppid,gboolean ordered,GstSctpSendMetaPartiallyReliability pr,guint32 pr_param)88 gst_sctp_buffer_add_send_meta (GstBuffer * buffer, guint32 ppid,
89 gboolean ordered, GstSctpSendMetaPartiallyReliability pr, guint32 pr_param)
90 {
91 GstSctpSendMeta *gst_sctp_send_meta = NULL;
92
93 g_return_val_if_fail (GST_IS_BUFFER (buffer), NULL);
94 gst_sctp_send_meta =
95 (GstSctpSendMeta *) gst_buffer_add_meta (buffer, GST_SCTP_SEND_META_INFO,
96 NULL);
97 gst_sctp_send_meta->ppid = ppid;
98 gst_sctp_send_meta->ordered = ordered;
99 gst_sctp_send_meta->pr = pr;
100 gst_sctp_send_meta->pr_param = pr_param;
101 return gst_sctp_send_meta;
102 }
103