3
* This library is free software; you can redistribute it and/or
4
* modify it under the terms of the GNU Library General Public
5
* License as published by the Free Software Foundation; either
6
* version 2 of the License, or (at your option) any later version.
8
* This library is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
* Library General Public License for more details.
13
* You should have received a copy of the GNU Library General Public
14
* License along with this library; if not, write to the
15
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16
* Boston, MA 02111-1307, USA.
18
* The Original Code is Fluendo MPEG Demuxer plugin.
20
* The Initial Developer of the Original Code is Fluendo, S.L.
21
* Portions created by Fluendo, S.L. are Copyright (C) 2005
22
* Fluendo, S.L. All Rights Reserved.
24
* Contributor(s): Wim Taymans <wim@fluendo.com>
32
#include "gstmpegdesc.h"
34
GST_DEBUG_CATEGORY (gstmpegtsdesc_debug);
35
#define GST_CAT_DEFAULT (gstmpegtsdesc_debug)
38
gst_mpeg_descriptor_free (GstMPEGDescriptor * desc)
40
g_return_if_fail (desc != NULL);
46
gst_mpeg_descriptor_parse_1 (guint8 * data, guint size)
51
/* need at least 2 bytes for tag and length */
59
GST_DEBUG ("tag: 0x%02x, length: %d", tag, length);
64
GST_MEMDUMP ("tag contents:", data, length);
70
gst_mpeg_descriptor_parse (guint8 * data, guint size)
73
guint consumed, total, n_desc;
74
GstMPEGDescriptor *result;
76
g_return_val_if_fail (data != NULL, NULL);
83
consumed = gst_mpeg_descriptor_parse_1 (current, size);
94
GST_DEBUG ("parsed %d descriptors", n_desc);
99
result = g_malloc (sizeof (GstMPEGDescriptor) + total);
100
result->n_desc = n_desc;
101
result->data_length = total;
102
result->data = ((guint8 *) result) + sizeof (GstMPEGDescriptor);
104
memcpy (result->data, data, total);
110
gst_mpeg_descriptor_n_desc (GstMPEGDescriptor * desc)
112
g_return_val_if_fail (desc != NULL, 0);
118
gst_mpeg_descriptor_find (GstMPEGDescriptor * desc, gint tag)
124
g_return_val_if_fail (desc != NULL, NULL);
126
current = desc->data;
127
length = desc->data_length;
130
if (DESC_TAG (current) == tag)
133
size = DESC_LENGTH (current) + 2;
141
/* array needs freeing afterwards */
143
gst_mpeg_descriptor_find_all (GstMPEGDescriptor * desc, gint tag)
151
g_return_val_if_fail (desc != NULL, NULL);
152
all = g_array_new (TRUE, TRUE, sizeof (guint8 *));
154
current = desc->data;
155
length = desc->data_length;
158
if (DESC_TAG (current) == tag)
159
g_array_append_val (all, current);
160
size = DESC_LENGTH (current) + 2;
166
GST_DEBUG ("found tag 0x%02x %d times", tag, all->len);
172
gst_mpeg_descriptor_nth (GstMPEGDescriptor * desc, guint i)
178
g_return_val_if_fail (desc != NULL, NULL);
180
if (i > desc->n_desc)
183
current = desc->data;
184
length = desc->data_length;
190
size = DESC_LENGTH (current) + 2;
201
gst_mpegtsdesc_init_debug (void)
203
GST_DEBUG_CATEGORY_INIT (gstmpegtsdesc_debug, "mpegtsdesc", 0,
204
"MPEG transport stream parser (descriptor)");