1 /* GStreamer Opus Encoder
2 * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3 * Copyright (C) <2008> Sebastian Dröge <sebastian.droege@collabora.co.uk>
4 * Copyright (C) <2011> Vincent Penquerc'h <vincent.penquerch@collabora.co.uk>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
25 #include <gst/tag/tag.h>
26 #include <gst/base/gstbytewriter.h>
27 #include "gstopusheader.h"
30 gst_opus_header_is_header (GstBuffer * buf, const char *magic, guint magic_size)
32 return (gst_buffer_get_size (buf) >= magic_size
33 && !gst_buffer_memcmp (buf, 0, magic, magic_size));
37 gst_opus_header_is_id_header (GstBuffer * buf)
39 gsize size = gst_buffer_get_size (buf);
41 guint8 version, channels, channel_mapping_family, n_streams, n_stereo_streams;
47 if (!gst_opus_header_is_header (buf, "OpusHead", 8))
50 gst_buffer_map (buf, &map, GST_MAP_READ);
55 if (version >= 0x0f) /* major version >=0 is what we grok */
63 channel_mapping_family = data[18];
65 if (channel_mapping_family == 0) {
70 if (size < 21 + channels)
73 n_stereo_streams = data[20];
76 if (n_stereo_streams > n_streams)
78 if (n_streams + n_stereo_streams > 255)
85 gst_buffer_unmap (buf, &map);
90 gst_opus_header_is_comment_header (GstBuffer * buf)
92 return gst_opus_header_is_header (buf, "OpusTags", 8);