2 * Copyright (C) <2014> William Manley <will@williammanley.net>
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.
21 * SECTION:gstnetcontrolmessagemeta
22 * @title: GstNetControlMessageMeta
23 * @short_description: Network Control Message Meta
25 * #GstNetControlMessageMeta can be used to store control messages (ancillary
26 * data) which was received with or is to be sent alongside the buffer data.
27 * When used with socket sinks and sources which understand this meta it allows
28 * sending and receiving ancillary data such as unix credentials (See
29 * #GUnixCredentialsMessage) and Unix file descriptions (See #GUnixFDMessage).
34 #include "gstnetcontrolmessagemeta.h"
37 net_control_message_meta_init (GstMeta * meta, gpointer params,
40 GstNetControlMessageMeta *nmeta = (GstNetControlMessageMeta *) meta;
42 nmeta->message = NULL;
48 net_control_message_meta_transform (GstBuffer * transbuf, GstMeta * meta,
49 GstBuffer * buffer, GQuark type, gpointer data)
51 GstNetControlMessageMeta *smeta, *dmeta;
52 smeta = (GstNetControlMessageMeta *) meta;
54 /* we always copy no matter what transform */
55 dmeta = gst_buffer_add_net_control_message_meta (transbuf, smeta->message);
63 net_control_message_meta_free (GstMeta * meta, GstBuffer * buffer)
65 GstNetControlMessageMeta *nmeta = (GstNetControlMessageMeta *) meta;
68 g_object_unref (nmeta->message);
69 nmeta->message = NULL;
73 gst_net_control_message_meta_api_get_type (void)
75 static volatile GType type;
76 static const gchar *tags[] = { "origin", NULL };
78 if (g_once_init_enter (&type)) {
80 gst_meta_api_type_register ("GstNetControlMessageMetaAPI", tags);
81 g_once_init_leave (&type, _type);
87 gst_net_control_message_meta_get_info (void)
89 static const GstMetaInfo *meta_info = NULL;
91 if (g_once_init_enter ((GstMetaInfo **) & meta_info)) {
92 const GstMetaInfo *mi =
93 gst_meta_register (GST_NET_CONTROL_MESSAGE_META_API_TYPE,
94 "GstNetControlMessageMeta",
95 sizeof (GstNetControlMessageMeta),
96 net_control_message_meta_init,
97 net_control_message_meta_free,
98 net_control_message_meta_transform);
99 g_once_init_leave ((GstMetaInfo **) & meta_info, (GstMetaInfo *) mi);
105 * gst_buffer_add_net_control_message_meta:
106 * @buffer: a #GstBuffer
107 * @message: a @GSocketControlMessage to attach to @buffer
109 * Attaches @message as metadata in a #GstNetControlMessageMeta to @buffer.
111 * Returns: (transfer none): a #GstNetControlMessageMeta connected to @buffer
113 GstNetControlMessageMeta *
114 gst_buffer_add_net_control_message_meta (GstBuffer * buffer,
115 GSocketControlMessage * message)
117 GstNetControlMessageMeta *meta;
119 g_return_val_if_fail (GST_IS_BUFFER (buffer), NULL);
120 g_return_val_if_fail (G_IS_SOCKET_CONTROL_MESSAGE (message), NULL);
123 (GstNetControlMessageMeta *) gst_buffer_add_meta (buffer,
124 GST_NET_CONTROL_MESSAGE_META_INFO, NULL);
126 meta->message = g_object_ref (message);