Debian Codegraph @

gst/mxf/mxfessence.c

raw symbols SCIP
1 /* GStreamer
2 * Copyright (C) 2009 Sebastian Dröge <[email protected]>
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 #ifdef HAVE_CONFIG_H
21 #include "config.h"
22 #endif
23
24 #include <gst/gst.h>
25 #include <string.h>
26
27 #include "mxfessence.h"
28
29 GST_DEBUG_CATEGORY_EXTERN (mxf_debug);
30 #define GST_CAT_DEFAULT mxf_debug
31
32 static GSList *_mxf_essence_element_handler_registry = NULL;
33
34 void
35 mxf_essence_element_handler_register (const MXFEssenceElementHandler * handler)
36 {
37 _mxf_essence_element_handler_registry =
38 g_slist_prepend (_mxf_essence_element_handler_registry,
39 (gpointer) handler);
40 }
41
42 const MXFEssenceElementHandler *
43 mxf_essence_element_handler_find (const MXFMetadataTimelineTrack * track)
44 {
45 GSList *l;
46 guint i;
47 MXFMetadataTrack *parent = (MXFMetadataTrack *) track;
48
49 g_return_val_if_fail (track != NULL, NULL);
50
51 if (parent->descriptor == NULL)
52 return NULL;
53
54 for (i = 0; i < parent->n_descriptor; i++) {
55 MXFMetadataFileDescriptor *d = parent->descriptor[i];
56
57 if (d) {
58 for (l = _mxf_essence_element_handler_registry; l; l = l->next) {
59 MXFEssenceElementHandler *current = l->data;
60
61 if (current->handles_descriptor (d))
62 return current;
63 }
64 }
65 }
66
67 return NULL;
68 }
69
70 static GList *_essence_element_writer_registry = NULL;
71 static GPtrArray *_essence_element_writer_pad_templates = NULL;
72
73 void
74 mxf_essence_element_writer_register (const MXFEssenceElementWriter * writer)
75 {
76 _essence_element_writer_registry =
77 g_list_prepend (_essence_element_writer_registry, (gpointer) writer);
78
79 if (!_essence_element_writer_pad_templates)
80 _essence_element_writer_pad_templates = g_ptr_array_new ();
81
82 if (_essence_element_writer_pad_templates->len > 0 &&
83 g_ptr_array_index (_essence_element_writer_pad_templates,
84 _essence_element_writer_pad_templates->len - 1) == NULL)
85 g_ptr_array_remove_index (_essence_element_writer_pad_templates,
86 _essence_element_writer_pad_templates->len - 1);
87
88 g_ptr_array_add (_essence_element_writer_pad_templates,
89 (gpointer) writer->pad_template);
90 }
91
92 const GstPadTemplate **
93 mxf_essence_element_writer_get_pad_templates (void)
94 {
95 if (!_essence_element_writer_pad_templates
96 || _essence_element_writer_pad_templates->len == 0)
97 return NULL;
98
99 if (g_ptr_array_index (_essence_element_writer_pad_templates,
100 _essence_element_writer_pad_templates->len - 1))
101 g_ptr_array_add (_essence_element_writer_pad_templates, NULL);
102
103 return (const GstPadTemplate **) _essence_element_writer_pad_templates->pdata;
104 }
105
106 const MXFEssenceElementWriter *
107 mxf_essence_element_writer_find (const GstPadTemplate * templ)
108 {
109 GList *l = _essence_element_writer_registry;
110
111 for (; l; l = l->next) {
112 MXFEssenceElementWriter *writer = l->data;
113
114 if (writer->pad_template == templ)
115 return writer;
116 }
117
118 return NULL;
119 }