mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 10:11:08 +00:00
iec958: remove this plugin
I think it can just go away. Audio sinks can and should payload things themselves using the helper API in libgstaudio. If such a plugin still makes sense, it should probably be rewritten using the library functions (and be put into -good or so).
This commit is contained in:
parent
df031523f8
commit
0983339a6e
12 changed files with 1 additions and 1280 deletions
|
@ -6,7 +6,6 @@ GST_PLUGINS_UGLY_TOP := $(LOCAL_PATH)
|
|||
GST_PLUGINS_UGLY_BUILT_SOURCES = \
|
||||
ext/mad/Android.mk \
|
||||
gst/synaesthesia/Android.mk \
|
||||
gst/iec958/Android.mk \
|
||||
gst/mpegaudioparse/Android.mk \
|
||||
gst/mpegstream/Android.mk \
|
||||
gst/realmedia/Android.mk \
|
||||
|
|
|
@ -210,15 +210,13 @@ dnl *** plug-ins to include ***
|
|||
|
||||
dnl Non ported plugins (non-dependant, then dependant)
|
||||
dnl Make sure you have a space before and after all plugins
|
||||
GST_PLUGINS_NONPORTED=" iec958 synaesthesia xingmux \
|
||||
mpegstream cdio twolame "
|
||||
GST_PLUGINS_NONPORTED=" synaesthesia xingmux mpegstream cdio twolame "
|
||||
AC_SUBST(GST_PLUGINS_NONPORTED)
|
||||
|
||||
dnl these are all the gst plug-ins, compilable without additional libs
|
||||
AG_GST_CHECK_PLUGIN(asfdemux)
|
||||
AG_GST_CHECK_PLUGIN(dvdlpcmdec)
|
||||
AG_GST_CHECK_PLUGIN(dvdsub)
|
||||
AG_GST_CHECK_PLUGIN(iec958)
|
||||
AG_GST_CHECK_PLUGIN(xingmux)
|
||||
AG_GST_CHECK_PLUGIN(mpegstream)
|
||||
AG_GST_CHECK_PLUGIN(realmedia)
|
||||
|
@ -443,7 +441,6 @@ gst/Makefile
|
|||
gst/asfdemux/Makefile
|
||||
gst/dvdlpcmdec/Makefile
|
||||
gst/dvdsub/Makefile
|
||||
gst/iec958/Makefile
|
||||
gst/mpegstream/Makefile
|
||||
gst/realmedia/Makefile
|
||||
gst/synaesthesia/Makefile
|
||||
|
|
|
@ -47,7 +47,6 @@
|
|||
<xi:include href="xml/plugin-dvdlpcmdec.xml" />
|
||||
<xi:include href="xml/plugin-dvdread.xml" />
|
||||
<xi:include href="xml/plugin-dvdsub.xml" />
|
||||
<xi:include href="xml/plugin-iec958.xml" />
|
||||
<xi:include href="xml/plugin-lame.xml" />
|
||||
<xi:include href="xml/plugin-mad.xml" />
|
||||
<xi:include href="xml/plugin-mpeg2dec.xml" />
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
<plugin>
|
||||
<name>iec958</name>
|
||||
<description>Convert raw AC3 into IEC958 (S/PDIF) frames</description>
|
||||
<filename>../../gst/iec958/.libs/libgstiec958.so</filename>
|
||||
<basename>libgstiec958.so</basename>
|
||||
<version>0.10.18.1</version>
|
||||
<license>LGPL</license>
|
||||
<source>gst-plugins-ugly</source>
|
||||
<package>GStreamer Ugly Plug-ins git</package>
|
||||
<origin>Unknown package origin</origin>
|
||||
<elements>
|
||||
<element>
|
||||
<name>ac3iec958</name>
|
||||
<longname>AC3 to IEC958 filter</longname>
|
||||
<class>Codec/Muxer/Audio</class>
|
||||
<description>Pads AC3 frames into IEC958 frames suitable for a raw S/PDIF interface</description>
|
||||
<author>Martin Soto <martinsoto@users.sourceforge.net></author>
|
||||
<pads>
|
||||
<caps>
|
||||
<name>sink</name>
|
||||
<direction>sink</direction>
|
||||
<presence>always</presence>
|
||||
<details>audio/x-private1-ac3; audio/x-ac3; audio/ac3</details>
|
||||
</caps>
|
||||
<caps>
|
||||
<name>src</name>
|
||||
<direction>source</direction>
|
||||
<presence>always</presence>
|
||||
<details>audio/x-iec958, rate=(int){ 32000, 44100, 48000 }; audio/x-raw-int, endianness=(int)4321, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int){ 32000, 44100, 48000 }, channels=(int)2</details>
|
||||
</caps>
|
||||
</pads>
|
||||
</element>
|
||||
</elements>
|
||||
</plugin>
|
|
@ -94,7 +94,6 @@ rm -rf $RPM_BUILD_ROOT
|
|||
%doc AUTHORS COPYING README REQUIREMENTS gst-plugins-ugly.doap
|
||||
%{_libdir}/gstreamer-%{majorminor}/libgstasf.so
|
||||
%{_libdir}/gstreamer-%{majorminor}/libgstdvdlpcmdec.so
|
||||
# %{_libdir}/gstreamer-%{majorminor}/libgstiec958.so
|
||||
# %{_libdir}/gstreamer-%{majorminor}/libgstxingmux.so
|
||||
# %{_libdir}/gstreamer-%{majorminor}/libgstmpegstream.so
|
||||
# %{_libdir}/gstreamer-%{majorminor}/libgstrmdemux.so
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
plugin_LTLIBRARIES = libgstiec958.la
|
||||
|
||||
libgstiec958_la_SOURCES = ac3iec.c ac3_padder.c
|
||||
libgstiec958_la_CFLAGS = $(GST_CFLAGS)
|
||||
libgstiec958_la_LIBADD = $(GST_LIBS)
|
||||
libgstiec958_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
|
||||
libgstiec958_la_LIBTOOLFLAGS = --tag=disable-static
|
||||
|
||||
noinst_HEADERS = ac3_padder.h ac3iec.h
|
||||
|
||||
Android.mk: Makefile.am $(BUILT_SOURCES)
|
||||
androgenizer \
|
||||
-:PROJECT libgstiec958 -:SHARED libgstiec958 \
|
||||
-:TAGS eng debug \
|
||||
-:REL_TOP $(top_srcdir) -:ABS_TOP $(abs_top_srcdir) \
|
||||
-:SOURCES $(libgstiec958_la_SOURCES) \
|
||||
-:CFLAGS $(DEFS) $(DEFAULT_INCLUDES) $(libgstiec958_la_CFLAGS) \
|
||||
-:LDFLAGS $(libgstiec958_la_LDFLAGS) \
|
||||
$(libgstiec958_la_LIBADD) \
|
||||
-ldl \
|
||||
-:PASSTHROUGH LOCAL_ARM_MODE:=arm \
|
||||
LOCAL_MODULE_PATH:='$$(TARGET_OUT)/lib/gstreamer-0.10' \
|
||||
> $@
|
|
@ -1,394 +0,0 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2003, 2004 Martin Soto <martinsoto@users.sourceforge.net>
|
||||
* 2005 Michael Smith <msmith@fluendo.com>
|
||||
*
|
||||
* ac3_padder.c: Pad AC3 frames for use with an SPDIF interface.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "ac3_padder.h"
|
||||
|
||||
struct frmsize_s
|
||||
{
|
||||
unsigned short bit_rate;
|
||||
unsigned short frm_size[3];
|
||||
};
|
||||
|
||||
static const struct frmsize_s frmsizecod_tbl[] = {
|
||||
{32, {64, 69, 96}},
|
||||
{32, {64, 70, 96}},
|
||||
{40, {80, 87, 120}},
|
||||
{40, {80, 88, 120}},
|
||||
{48, {96, 104, 144}},
|
||||
{48, {96, 105, 144}},
|
||||
{56, {112, 121, 168}},
|
||||
{56, {112, 122, 168}},
|
||||
{64, {128, 139, 192}},
|
||||
{64, {128, 140, 192}},
|
||||
{80, {160, 174, 240}},
|
||||
{80, {160, 175, 240}},
|
||||
{96, {192, 208, 288}},
|
||||
{96, {192, 209, 288}},
|
||||
{112, {224, 243, 336}},
|
||||
{112, {224, 244, 336}},
|
||||
{128, {256, 278, 384}},
|
||||
{128, {256, 279, 384}},
|
||||
{160, {320, 348, 480}},
|
||||
{160, {320, 349, 480}},
|
||||
{192, {384, 417, 576}},
|
||||
{192, {384, 418, 576}},
|
||||
{224, {448, 487, 672}},
|
||||
{224, {448, 488, 672}},
|
||||
{256, {512, 557, 768}},
|
||||
{256, {512, 558, 768}},
|
||||
{320, {640, 696, 960}},
|
||||
{320, {640, 697, 960}},
|
||||
{384, {768, 835, 1152}},
|
||||
{384, {768, 836, 1152}},
|
||||
{448, {896, 975, 1344}},
|
||||
{448, {896, 976, 1344}},
|
||||
{512, {1024, 1114, 1536}},
|
||||
{512, {1024, 1115, 1536}},
|
||||
{576, {1152, 1253, 1728}},
|
||||
{576, {1152, 1254, 1728}},
|
||||
{640, {1280, 1393, 1920}},
|
||||
{640, {1280, 1394, 1920}}
|
||||
};
|
||||
|
||||
static const guint16 ac3_crc_lut[256] = {
|
||||
0x0000, 0x8005, 0x800f, 0x000a, 0x801b, 0x001e, 0x0014, 0x8011,
|
||||
0x8033, 0x0036, 0x003c, 0x8039, 0x0028, 0x802d, 0x8027, 0x0022,
|
||||
0x8063, 0x0066, 0x006c, 0x8069, 0x0078, 0x807d, 0x8077, 0x0072,
|
||||
0x0050, 0x8055, 0x805f, 0x005a, 0x804b, 0x004e, 0x0044, 0x8041,
|
||||
0x80c3, 0x00c6, 0x00cc, 0x80c9, 0x00d8, 0x80dd, 0x80d7, 0x00d2,
|
||||
0x00f0, 0x80f5, 0x80ff, 0x00fa, 0x80eb, 0x00ee, 0x00e4, 0x80e1,
|
||||
0x00a0, 0x80a5, 0x80af, 0x00aa, 0x80bb, 0x00be, 0x00b4, 0x80b1,
|
||||
0x8093, 0x0096, 0x009c, 0x8099, 0x0088, 0x808d, 0x8087, 0x0082,
|
||||
0x8183, 0x0186, 0x018c, 0x8189, 0x0198, 0x819d, 0x8197, 0x0192,
|
||||
0x01b0, 0x81b5, 0x81bf, 0x01ba, 0x81ab, 0x01ae, 0x01a4, 0x81a1,
|
||||
0x01e0, 0x81e5, 0x81ef, 0x01ea, 0x81fb, 0x01fe, 0x01f4, 0x81f1,
|
||||
0x81d3, 0x01d6, 0x01dc, 0x81d9, 0x01c8, 0x81cd, 0x81c7, 0x01c2,
|
||||
0x0140, 0x8145, 0x814f, 0x014a, 0x815b, 0x015e, 0x0154, 0x8151,
|
||||
0x8173, 0x0176, 0x017c, 0x8179, 0x0168, 0x816d, 0x8167, 0x0162,
|
||||
0x8123, 0x0126, 0x012c, 0x8129, 0x0138, 0x813d, 0x8137, 0x0132,
|
||||
0x0110, 0x8115, 0x811f, 0x011a, 0x810b, 0x010e, 0x0104, 0x8101,
|
||||
0x8303, 0x0306, 0x030c, 0x8309, 0x0318, 0x831d, 0x8317, 0x0312,
|
||||
0x0330, 0x8335, 0x833f, 0x033a, 0x832b, 0x032e, 0x0324, 0x8321,
|
||||
0x0360, 0x8365, 0x836f, 0x036a, 0x837b, 0x037e, 0x0374, 0x8371,
|
||||
0x8353, 0x0356, 0x035c, 0x8359, 0x0348, 0x834d, 0x8347, 0x0342,
|
||||
0x03c0, 0x83c5, 0x83cf, 0x03ca, 0x83db, 0x03de, 0x03d4, 0x83d1,
|
||||
0x83f3, 0x03f6, 0x03fc, 0x83f9, 0x03e8, 0x83ed, 0x83e7, 0x03e2,
|
||||
0x83a3, 0x03a6, 0x03ac, 0x83a9, 0x03b8, 0x83bd, 0x83b7, 0x03b2,
|
||||
0x0390, 0x8395, 0x839f, 0x039a, 0x838b, 0x038e, 0x0384, 0x8381,
|
||||
0x0280, 0x8285, 0x828f, 0x028a, 0x829b, 0x029e, 0x0294, 0x8291,
|
||||
0x82b3, 0x02b6, 0x02bc, 0x82b9, 0x02a8, 0x82ad, 0x82a7, 0x02a2,
|
||||
0x82e3, 0x02e6, 0x02ec, 0x82e9, 0x02f8, 0x82fd, 0x82f7, 0x02f2,
|
||||
0x02d0, 0x82d5, 0x82df, 0x02da, 0x82cb, 0x02ce, 0x02c4, 0x82c1,
|
||||
0x8243, 0x0246, 0x024c, 0x8249, 0x0258, 0x825d, 0x8257, 0x0252,
|
||||
0x0270, 0x8275, 0x827f, 0x027a, 0x826b, 0x026e, 0x0264, 0x8261,
|
||||
0x0220, 0x8225, 0x822f, 0x022a, 0x823b, 0x023e, 0x0234, 0x8231,
|
||||
0x8213, 0x0216, 0x021c, 0x8219, 0x0208, 0x820d, 0x8207, 0x0202
|
||||
};
|
||||
|
||||
static gint ac3_sample_rates[] = { 48000, 44100, 32000, -1 };
|
||||
|
||||
typedef guint16 ac3_crc_state;
|
||||
|
||||
static void
|
||||
ac3_crc_init (ac3_crc_state * state)
|
||||
{
|
||||
*state = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
ac3_crc_update (ac3_crc_state * state, guint8 * data, guint32 num_bytes)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < num_bytes; i++)
|
||||
*state = ac3_crc_lut[data[i] ^ (*state >> 8)] ^ (*state << 8);
|
||||
}
|
||||
|
||||
static int
|
||||
ac3_crc_validate (ac3_crc_state * state)
|
||||
{
|
||||
return (*state == 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* ac3p_init
|
||||
* @padder: The padder structure to initialize.
|
||||
*
|
||||
* Initializes an AC3 stream padder. This structure can be
|
||||
* subsequently used to parse an AC3 stream and convert it to IEC958
|
||||
* (S/PDIF) padded packets.
|
||||
*/
|
||||
void
|
||||
ac3p_init (ac3_padder * padder)
|
||||
{
|
||||
const guint8 sync[4] = { 0xF8, 0x72, 0x4E, 0x1F };
|
||||
|
||||
padder->state = AC3P_STATE_SYNC1;
|
||||
|
||||
padder->skipped = 0;
|
||||
|
||||
/* No material to read yet. */
|
||||
padder->buffer = NULL;
|
||||
padder->buffer_end = 0;
|
||||
padder->buffer_cur = 0;
|
||||
padder->buffer_size = 0;
|
||||
|
||||
/* Initialize the sync bytes in the frame. */
|
||||
memcpy (padder->frame.header, sync, 4);
|
||||
}
|
||||
|
||||
void
|
||||
ac3p_clear (ac3_padder * padder)
|
||||
{
|
||||
g_free (padder->buffer);
|
||||
}
|
||||
|
||||
static void
|
||||
resync (ac3_padder * padder, int offset, int skipped)
|
||||
{
|
||||
padder->buffer_cur -= offset;
|
||||
padder->state = AC3P_STATE_SYNC1;
|
||||
padder->skipped += skipped;
|
||||
|
||||
/* We don't want our buffer to grow unboundedly if we fail to find sync, but
|
||||
* nor do we want to do this every time we call resync() */
|
||||
if (padder->buffer_cur > 4096) {
|
||||
memmove (padder->buffer, padder->buffer + padder->buffer_cur,
|
||||
padder->buffer_end - padder->buffer_cur);
|
||||
padder->buffer_end -= padder->buffer_cur;
|
||||
padder->buffer_cur = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ac3_push_data:
|
||||
* @padder: The padder structure.
|
||||
* @data: A pointer to a buffer with new data to parse. This should
|
||||
* correspond to a new piece of a stream containing raw AC3 data.
|
||||
* @size: The number of available bytes in the buffer.
|
||||
*
|
||||
* Pushes a new buffer of data to be parsed by the ac3 padder. The
|
||||
* ac3_parse() function will actually parse the data and report when
|
||||
* new frames are found. This funcion should only be called once at
|
||||
* the beginning of the parsing process, or when the ac3_parse()
|
||||
* function returns the %AC3P_EVENT_PUSH event.
|
||||
*/
|
||||
extern void
|
||||
ac3p_push_data (ac3_padder * padder, guchar * data, guint size)
|
||||
{
|
||||
if (padder->buffer_end + size > padder->buffer_size) {
|
||||
padder->buffer_size = padder->buffer_end + size;
|
||||
padder->buffer = g_realloc (padder->buffer, padder->buffer_size);
|
||||
}
|
||||
|
||||
memcpy (padder->buffer + padder->buffer_end, data, size);
|
||||
padder->buffer_end += size;
|
||||
}
|
||||
|
||||
/**
|
||||
* ac3p_parse:
|
||||
* @padder: The padder structure.
|
||||
*
|
||||
* Parses the bytes already pushed into the padder structure (see
|
||||
* ac3p_push_data()) and returns an event value depending on the
|
||||
* results of the parsing.
|
||||
*
|
||||
* Returns: %AC3P_EVENT_FRAME to indicate that a new AC3 was found and
|
||||
* padded for IEC958 transmission. This frame can be read inmediatly
|
||||
* with ac3p_frame(). %AC3P_EVENT_PUSH to indicate that new data from
|
||||
* the input stream must be pushed into the padder using
|
||||
* ac3p_push_data(). This function should be called again after
|
||||
* pushing the data.
|
||||
*
|
||||
* Note that the returned data (which naturally comes in 16 bit sub-frames) is
|
||||
* big-endian, and may need to be byte-swapped for little-endian output.
|
||||
*/
|
||||
extern int
|
||||
ac3p_parse (ac3_padder * padder)
|
||||
{
|
||||
while (padder->buffer_cur < padder->buffer_end) {
|
||||
switch (padder->state) {
|
||||
case AC3P_STATE_SYNC1:
|
||||
if (padder->buffer[padder->buffer_cur++] == 0x0b) {
|
||||
/* The first sync byte was found. Go to the next state. */
|
||||
padder->frame.sync_byte1 = 0x0b;
|
||||
padder->state = AC3P_STATE_SYNC2;
|
||||
} else
|
||||
resync (padder, 0, 1);
|
||||
break;
|
||||
|
||||
case AC3P_STATE_SYNC2:
|
||||
if (padder->buffer[padder->buffer_cur++] == 0x77) {
|
||||
/* The second sync byte was seen right after the first. Go to
|
||||
the next state. */
|
||||
padder->frame.sync_byte2 = 0x77;
|
||||
padder->state = AC3P_STATE_HEADER;
|
||||
|
||||
/* Prepare for reading the header. */
|
||||
padder->out_ptr = (guchar *) & (padder->frame.crc1);
|
||||
/* Discount the 2 sync bytes from the header size. */
|
||||
padder->bytes_to_copy = AC3P_AC3_HEADER_SIZE - 2;
|
||||
} else {
|
||||
/* The second sync byte was not seen. Go back to the
|
||||
first state. */
|
||||
resync (padder, 0, 2);
|
||||
}
|
||||
break;
|
||||
|
||||
case AC3P_STATE_HEADER:
|
||||
if (padder->bytes_to_copy > 0) {
|
||||
/* Copy one byte. */
|
||||
*(padder->out_ptr++) = padder->buffer[padder->buffer_cur++];
|
||||
padder->bytes_to_copy--;
|
||||
} else {
|
||||
int fscod;
|
||||
|
||||
/* The header is ready: */
|
||||
|
||||
fscod = (padder->frame.code >> 6) & 0x03;
|
||||
|
||||
/* fscod == 3 is a reserved code, we're not meant to do playback in
|
||||
* this case. frmsizecod being out-of-range (there are 38 entries)
|
||||
* doesn't appear to be well-defined, but treat the same.
|
||||
* The likely cause of both of these is false sync, so skip back to
|
||||
* just in front of the previous sync word and start looking again.
|
||||
*/
|
||||
if (fscod == 3 || (padder->frame.code & 0x3f) >= 38) {
|
||||
resync (padder, AC3P_AC3_HEADER_SIZE - 2, 2);
|
||||
continue;
|
||||
}
|
||||
|
||||
padder->rate = ac3_sample_rates[fscod];
|
||||
|
||||
/* Calculate the frame size (in 16 bit units). */
|
||||
padder->ac3_frame_size =
|
||||
frmsizecod_tbl[padder->frame.code & 0x3f].frm_size[fscod];
|
||||
|
||||
/* Prepare for reading the body. */
|
||||
padder->bytes_to_copy = padder->ac3_frame_size * 2
|
||||
- AC3P_AC3_HEADER_SIZE;
|
||||
|
||||
padder->state = AC3P_STATE_CONTENT;
|
||||
}
|
||||
break;
|
||||
|
||||
case AC3P_STATE_CONTENT:
|
||||
if (padder->bytes_to_copy > 0) {
|
||||
/* Copy one byte. */
|
||||
*(padder->out_ptr++) = padder->buffer[padder->buffer_cur++];
|
||||
padder->bytes_to_copy--;
|
||||
} else {
|
||||
int framesize;
|
||||
int crclen1, crclen2;
|
||||
guint8 *tmp;
|
||||
ac3_crc_state state;
|
||||
|
||||
/* Frame ready. Prepare for output: */
|
||||
|
||||
/* Zero the non AC3 portion of the padded frame. */
|
||||
memset (&(padder->frame.sync_byte1) + padder->ac3_frame_size * 2, 0,
|
||||
AC3P_IEC_FRAME_SIZE - AC3P_IEC_HEADER_SIZE -
|
||||
padder->ac3_frame_size * 2);
|
||||
|
||||
/* Now checking the two CRCs. If either fails, then we re-feed all
|
||||
* the data starting immediately after the 16-bit syncword (which we
|
||||
* can now assume was a false sync) */
|
||||
|
||||
/* Length of CRC1 is defined as
|
||||
truncate(framesize/2) + truncate(framesize/8)
|
||||
units (each of which is 16 bit, as is 'framesize'), but this
|
||||
includes the syncword, which is NOT calculated as part of
|
||||
the CRC.
|
||||
*/
|
||||
framesize = padder->ac3_frame_size;
|
||||
crclen1 = (framesize / 2 + framesize / 8) * 2 - 2;
|
||||
tmp = (guint8 *) (&(padder->frame.crc1));
|
||||
|
||||
ac3_crc_init (&state);
|
||||
ac3_crc_update (&state, tmp, crclen1);
|
||||
|
||||
if (!ac3_crc_validate (&state)) {
|
||||
/* Rewind current stream pointer to immediately following the last
|
||||
* attempted sync point, then continue parsing in initial state */
|
||||
resync (padder, padder->ac3_frame_size - 2, 2);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Now check CRC2, which covers the entire frame other than the
|
||||
* 16-bit syncword */
|
||||
crclen2 = padder->ac3_frame_size * 2 - 2;
|
||||
|
||||
ac3_crc_init (&state);
|
||||
ac3_crc_update (&state, tmp, crclen2);
|
||||
|
||||
if (!ac3_crc_validate (&state)) {
|
||||
/* Rewind current stream pointer to immediately following the last
|
||||
* attempted sync point, then continue parsing in initial state */
|
||||
resync (padder, padder->ac3_frame_size - 2, 2);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Now set up the rest of the IEC header (we already filled in the
|
||||
32 bit sync word. */
|
||||
|
||||
/* Byte 5 has:
|
||||
bits 0-4: data type dependent. For AC3, the bottom 3 of these bits
|
||||
are copied from the AC3 frame (bsmod value), the top 2
|
||||
bits are reserved, and set to zero.
|
||||
bits 5-7: data stream number. We only do one data stream, so it's
|
||||
zero.
|
||||
*/
|
||||
padder->frame.header[4] = padder->frame.bsidmod & 0x07;
|
||||
|
||||
/* Byte 6:
|
||||
bits 0-4: data type. 1 for AC3.
|
||||
bits 5-6: reserved, zero.
|
||||
bit 7: error_flag. Zero if frame contains no errors
|
||||
*/
|
||||
padder->frame.header[5] = 1; /* AC3 is defined as datatype 1 */
|
||||
|
||||
/* Now, 16 bit frame size, in bits. */
|
||||
padder->frame.header[6] = ((padder->ac3_frame_size * 16) >> 8) & 0xFF;
|
||||
padder->frame.header[7] = (padder->ac3_frame_size * 16) & 0xFF;
|
||||
|
||||
/* We're done, reset state and signal that we have a frame */
|
||||
padder->skipped = 0;
|
||||
padder->state = AC3P_STATE_SYNC1;
|
||||
|
||||
memmove (padder->buffer, padder->buffer + padder->buffer_cur,
|
||||
padder->buffer_end - padder->buffer_cur);
|
||||
padder->buffer_end -= padder->buffer_cur;
|
||||
padder->buffer_cur = 0;
|
||||
|
||||
return AC3P_EVENT_FRAME;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return AC3P_EVENT_PUSH;
|
||||
|
||||
}
|
|
@ -1,139 +0,0 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2003 Martin Soto <martinsoto@users.sourceforge.net>
|
||||
*
|
||||
* ac3_padder.h: Pad AC3 frames for use with an SPDIF interface.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef AC3_PADDER_INC
|
||||
#define AC3_PADDER_INC
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
|
||||
/* Size of an IEC958 padded AC3 frame. */
|
||||
#define AC3P_IEC_FRAME_SIZE 6144
|
||||
/* Size of the IEC958 header. */
|
||||
#define AC3P_IEC_HEADER_SIZE 8
|
||||
/* Size of the AC3 header. */
|
||||
#define AC3P_AC3_HEADER_SIZE 7
|
||||
|
||||
|
||||
/* An IEC958 padded AC3 frame. */
|
||||
typedef struct {
|
||||
/* IEC header. */
|
||||
guchar header[AC3P_IEC_HEADER_SIZE];
|
||||
|
||||
/* Begin of AC3 header. */
|
||||
guchar sync_byte1;
|
||||
guchar sync_byte2;
|
||||
|
||||
guchar crc1[2];
|
||||
guchar code;
|
||||
guchar bsidmod;
|
||||
guchar acmod;
|
||||
/* End of AC3 header. */
|
||||
|
||||
unsigned char data[AC3P_IEC_FRAME_SIZE - AC3P_IEC_HEADER_SIZE
|
||||
- AC3P_AC3_HEADER_SIZE];
|
||||
} ac3p_iec958_burst_frame;
|
||||
|
||||
|
||||
/* Possible states for the reading automaton: */
|
||||
|
||||
/* Searching for sync byte 1. */
|
||||
#define AC3P_STATE_SYNC1 1
|
||||
/* Searching for sync byte 2. */
|
||||
#define AC3P_STATE_SYNC2 2
|
||||
/* Reading AC3 header. */
|
||||
#define AC3P_STATE_HEADER 3
|
||||
/* Reading packet contents.*/
|
||||
#define AC3P_STATE_CONTENT 4
|
||||
|
||||
|
||||
/* Events generated by the parse function: */
|
||||
|
||||
/* The parser needs new data to be pushed. */
|
||||
#define AC3P_EVENT_PUSH 1
|
||||
/* There is a new padded frame ready to read from the padder structure. */
|
||||
#define AC3P_EVENT_FRAME 2
|
||||
|
||||
|
||||
/* The internal state for the padder. */
|
||||
typedef struct {
|
||||
guint state; /* State of the reading automaton. */
|
||||
|
||||
guchar *buffer; /* Input buffer */
|
||||
|
||||
gint buffer_end; /* End offset, in bytes, of currently valid data in
|
||||
buffer */
|
||||
|
||||
gint buffer_size; /* Allocated size of buffer */
|
||||
|
||||
gint buffer_cur; /* Current position in buffer */
|
||||
|
||||
guchar *out_ptr; /* Output pointer, marking the current
|
||||
position in the output frame. */
|
||||
gint bytes_to_copy;
|
||||
/* Number of bytes that still must be copied
|
||||
to the output frame *during this reading
|
||||
stage*. */
|
||||
|
||||
gint ac3_frame_size;
|
||||
/* The size in 16-bit units of the pure AC3 portion
|
||||
of the current frame. */
|
||||
|
||||
gint skipped; /* Number of bytes skipped while trying to find sync */
|
||||
|
||||
gint rate; /* Sample rate of ac3 data */
|
||||
|
||||
ac3p_iec958_burst_frame frame;
|
||||
/* The current output frame. */
|
||||
} ac3_padder;
|
||||
|
||||
|
||||
|
||||
extern void
|
||||
ac3p_init(ac3_padder *padder);
|
||||
|
||||
extern void
|
||||
ac3p_clear(ac3_padder *padder);
|
||||
|
||||
extern void
|
||||
ac3p_push_data(ac3_padder *padder, guchar *data, guint size);
|
||||
|
||||
extern int
|
||||
ac3p_parse(ac3_padder *padder);
|
||||
|
||||
|
||||
/**
|
||||
* ac3p_frame
|
||||
* @padder: The padder structure.
|
||||
*
|
||||
* Returns: a pointer to the padded frame contained in the padder.
|
||||
*/
|
||||
#define ac3p_frame(padder) ((guint8 *) &((padder)->frame))
|
||||
|
||||
/**
|
||||
* ac3p_frame_size
|
||||
* @padder: The padder structure.
|
||||
*
|
||||
* Returns: the length in bytes of the last read raw AC3 frame.
|
||||
*/
|
||||
#define ac3p_frame_size(padder) ((padder)->ac3_frame_size * 2)
|
||||
|
||||
#endif
|
|
@ -1,463 +0,0 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2004 Martin Soto <martinsoto@users.sourceforge.net>
|
||||
2005 Michael Smith <msmith@fluendo.com>
|
||||
*
|
||||
* ac3iec.c: Pad AC3 frames into IEC958 frames for the S/PDIF interface.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <gst/gst.h>
|
||||
|
||||
#include "ac3iec.h"
|
||||
|
||||
|
||||
GST_DEBUG_CATEGORY_STATIC (ac3iec_debug);
|
||||
#define GST_CAT_DEFAULT (ac3iec_debug)
|
||||
|
||||
|
||||
/* The duration of a single IEC958 frame. */
|
||||
#define IEC958_FRAME_DURATION (32 * GST_MSECOND)
|
||||
|
||||
/* AC3IEC signals and args */
|
||||
enum
|
||||
{
|
||||
LAST_SIGNAL,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_RAW_AUDIO,
|
||||
};
|
||||
|
||||
|
||||
static GstStaticPadTemplate ac3iec_sink_template =
|
||||
GST_STATIC_PAD_TEMPLATE ("sink",
|
||||
GST_PAD_SINK,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS ("audio/x-private1-ac3; audio/x-ac3; audio/ac3")
|
||||
);
|
||||
|
||||
/* Two different output caps are possible. */
|
||||
#define NORMAL_CAPS_DEF "audio/x-iec958, rate = (int){32000, 44100, 48000}"
|
||||
#define RAW_AUDIO_CAPS_DEF "audio/x-raw-int, " \
|
||||
"endianness = (int) " G_STRINGIFY (G_BIG_ENDIAN) ", " \
|
||||
"signed = (boolean) true, " \
|
||||
"width = (int) 16, " \
|
||||
"depth = (int) 16, " \
|
||||
"rate = (int){32000, 44100, 48000}, " \
|
||||
"channels = (int) 2"
|
||||
|
||||
static GstStaticCaps normal_caps = GST_STATIC_CAPS (NORMAL_CAPS_DEF);
|
||||
static GstStaticCaps raw_audio_caps = GST_STATIC_CAPS (RAW_AUDIO_CAPS_DEF);
|
||||
|
||||
static GstStaticPadTemplate ac3iec_src_template =
|
||||
GST_STATIC_PAD_TEMPLATE ("src",
|
||||
GST_PAD_SRC,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS (NORMAL_CAPS_DEF ";" RAW_AUDIO_CAPS_DEF));
|
||||
|
||||
static void ac3iec_base_init (gpointer g_class);
|
||||
static void ac3iec_class_init (AC3IECClass * klass);
|
||||
static void ac3iec_init (AC3IEC * ac3iec);
|
||||
static void ac3iec_finalize (GObject * object);
|
||||
|
||||
static void ac3iec_set_property (GObject * object,
|
||||
guint prop_id, const GValue * value, GParamSpec * pspec);
|
||||
static void ac3iec_get_property (GObject * object,
|
||||
guint prop_id, GValue * value, GParamSpec * pspec);
|
||||
|
||||
static gboolean ac3iec_setcaps (GstPad * pad, GstCaps * caps);
|
||||
static GstFlowReturn ac3iec_chain_dvd (GstPad * pad, GstBuffer * buf);
|
||||
static GstFlowReturn ac3iec_chain_raw (GstPad * pad, GstBuffer * buf);
|
||||
|
||||
static GstStateChangeReturn ac3iec_change_state (GstElement * element,
|
||||
GstStateChange transition);
|
||||
|
||||
|
||||
static GstElementClass *parent_class = NULL;
|
||||
|
||||
/* static guint ac3iec_signals[LAST_SIGNAL] = { 0 }; */
|
||||
|
||||
|
||||
GType
|
||||
ac3iec_get_type (void)
|
||||
{
|
||||
static GType ac3iec_type = 0;
|
||||
|
||||
if (!ac3iec_type) {
|
||||
static const GTypeInfo ac3iec_info = {
|
||||
sizeof (AC3IECClass),
|
||||
ac3iec_base_init,
|
||||
NULL,
|
||||
(GClassInitFunc) ac3iec_class_init,
|
||||
NULL,
|
||||
NULL,
|
||||
sizeof (AC3IEC),
|
||||
0,
|
||||
(GInstanceInitFunc) ac3iec_init,
|
||||
};
|
||||
ac3iec_type = g_type_register_static (GST_TYPE_ELEMENT,
|
||||
"AC3IEC", &ac3iec_info, 0);
|
||||
|
||||
GST_DEBUG_CATEGORY_INIT (ac3iec_debug, "ac3iec", 0,
|
||||
"AC3 to IEC958 padding element");
|
||||
}
|
||||
return ac3iec_type;
|
||||
}
|
||||
|
||||
static void
|
||||
ac3iec_base_init (gpointer g_class)
|
||||
{
|
||||
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
||||
|
||||
gst_element_class_set_details_simple (element_class, "AC3 to IEC958 filter",
|
||||
"Codec/Muxer/Audio",
|
||||
"Pads AC3 frames into IEC958 frames suitable for a raw S/PDIF interface",
|
||||
"Martin Soto <martinsoto@users.sourceforge.net>");
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&ac3iec_sink_template));
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&ac3iec_src_template));
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
ac3iec_class_init (AC3IECClass * klass)
|
||||
{
|
||||
GObjectClass *gobject_class;
|
||||
GstElementClass *gstelement_class;
|
||||
|
||||
gobject_class = (GObjectClass *) klass;
|
||||
gstelement_class = (GstElementClass *) klass;
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
gobject_class->set_property = ac3iec_set_property;
|
||||
gobject_class->get_property = ac3iec_get_property;
|
||||
gobject_class->finalize = ac3iec_finalize;
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_RAW_AUDIO,
|
||||
g_param_spec_boolean ("raw-audio", "raw-audio",
|
||||
"If true, source pad caps are set to raw audio.",
|
||||
FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
gstelement_class->change_state = ac3iec_change_state;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
ac3iec_init (AC3IEC * ac3iec)
|
||||
{
|
||||
ac3iec->sink =
|
||||
gst_pad_new_from_static_template (&ac3iec_sink_template, "sink");
|
||||
gst_pad_set_setcaps_function (ac3iec->sink, ac3iec_setcaps);
|
||||
gst_pad_set_chain_function (ac3iec->sink, ac3iec_chain_dvd);
|
||||
gst_element_add_pad (GST_ELEMENT (ac3iec), ac3iec->sink);
|
||||
|
||||
ac3iec->src = gst_pad_new_from_static_template (&ac3iec_src_template, "src");
|
||||
gst_pad_use_fixed_caps (ac3iec->src);
|
||||
gst_element_add_pad (GST_ELEMENT (ac3iec), ac3iec->src);
|
||||
|
||||
ac3iec->cur_ts = GST_CLOCK_TIME_NONE;
|
||||
|
||||
ac3iec->padder = g_malloc (sizeof (ac3_padder));
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
ac3iec_finalize (GObject * object)
|
||||
{
|
||||
AC3IEC *ac3iec = AC3IEC (object);
|
||||
|
||||
g_free (ac3iec->padder);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
ac3iec_set_property (GObject * object, guint prop_id,
|
||||
const GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
AC3IEC *ac3iec = AC3IEC (object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_RAW_AUDIO:
|
||||
{
|
||||
ac3iec->raw_audio = g_value_get_boolean (value);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
ac3iec_setcaps (GstPad * pad, GstCaps * caps)
|
||||
{
|
||||
AC3IEC *ac3iec = AC3IEC (gst_pad_get_parent (pad));
|
||||
GstStructure *structure = gst_caps_get_structure (caps, 0);
|
||||
|
||||
if (structure && gst_structure_has_name (structure, "audio/x-private1-ac3"))
|
||||
ac3iec->dvdmode = TRUE;
|
||||
else
|
||||
ac3iec->dvdmode = FALSE;
|
||||
|
||||
gst_object_unref (ac3iec);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
ac3iec_get_property (GObject * object, guint prop_id,
|
||||
GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
AC3IEC *ac3iec = AC3IEC (object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_RAW_AUDIO:
|
||||
g_value_set_boolean (value, ac3iec->raw_audio);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static GstFlowReturn
|
||||
ac3iec_chain_dvd (GstPad * pad, GstBuffer * buf)
|
||||
{
|
||||
guint first_access;
|
||||
guint8 *data;
|
||||
guint size;
|
||||
gint offset;
|
||||
gint len;
|
||||
GstBuffer *subbuf;
|
||||
GstFlowReturn ret;
|
||||
AC3IEC *ac3iec = AC3IEC (gst_pad_get_parent (pad));
|
||||
|
||||
if (ac3iec->dvdmode) {
|
||||
size = GST_BUFFER_SIZE (buf);
|
||||
data = GST_BUFFER_DATA (buf);
|
||||
|
||||
first_access = (data[0] << 8) | data[1];
|
||||
|
||||
/* Skip the first_access header */
|
||||
offset = 2;
|
||||
|
||||
if (first_access > 1) {
|
||||
/* Length of data before first_access */
|
||||
len = first_access - 1;
|
||||
|
||||
/* Ensure we don't crash if fed totally invalid data */
|
||||
if (offset + len > size) {
|
||||
ret = GST_FLOW_ERROR;
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (len > 0) {
|
||||
subbuf = gst_buffer_create_sub (buf, offset, len);
|
||||
GST_BUFFER_TIMESTAMP (subbuf) = GST_CLOCK_TIME_NONE;
|
||||
ret = ac3iec_chain_raw (pad, subbuf);
|
||||
if (ret != GST_FLOW_OK)
|
||||
goto done;
|
||||
}
|
||||
|
||||
offset += len;
|
||||
len = size - offset;
|
||||
|
||||
subbuf = gst_buffer_create_sub (buf, offset, len);
|
||||
GST_BUFFER_TIMESTAMP (subbuf) = GST_BUFFER_TIMESTAMP (buf);
|
||||
|
||||
ret = ac3iec_chain_raw (pad, subbuf);
|
||||
} else {
|
||||
/* Ensure we don't crash if fed totally invalid data */
|
||||
if (size < 2) {
|
||||
ret = GST_FLOW_ERROR;
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* No first_access, so no timestamp */
|
||||
subbuf = gst_buffer_create_sub (buf, offset, size - offset);
|
||||
GST_BUFFER_TIMESTAMP (subbuf) = GST_CLOCK_TIME_NONE;
|
||||
ret = ac3iec_chain_raw (pad, subbuf);
|
||||
}
|
||||
} else {
|
||||
ret = ac3iec_chain_raw (pad, buf);
|
||||
gst_object_unref (ac3iec);
|
||||
return ret;
|
||||
}
|
||||
|
||||
done:
|
||||
gst_object_unref (ac3iec);
|
||||
gst_buffer_unref (buf);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static GstFlowReturn
|
||||
ac3iec_chain_raw (GstPad * pad, GstBuffer * buf)
|
||||
{
|
||||
GstBuffer *new;
|
||||
AC3IEC *ac3iec;
|
||||
int event;
|
||||
GstFlowReturn ret = GST_FLOW_OK;
|
||||
|
||||
g_return_val_if_fail (pad != NULL, GST_FLOW_ERROR);
|
||||
g_return_val_if_fail (GST_IS_PAD (pad), GST_FLOW_ERROR);
|
||||
g_return_val_if_fail (buf != NULL, GST_FLOW_ERROR);
|
||||
|
||||
ac3iec = AC3IEC (gst_pad_get_parent (pad));
|
||||
|
||||
if (GST_BUFFER_TIMESTAMP (buf) != GST_CLOCK_TIME_NONE) {
|
||||
/* Whoever tells me why it is necessary to add a frame in order to
|
||||
get synchronized sound will get a beer from me. */
|
||||
ac3iec->cur_ts = GST_BUFFER_TIMESTAMP (buf) + IEC958_FRAME_DURATION;
|
||||
}
|
||||
|
||||
/* Push the new data into the padder. */
|
||||
ac3p_push_data (ac3iec->padder, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
|
||||
|
||||
/* Parse the data. */
|
||||
event = ac3p_parse (ac3iec->padder);
|
||||
while (event != AC3P_EVENT_PUSH) {
|
||||
if (event == AC3P_EVENT_FRAME) {
|
||||
GstCaps *bufcaps = NULL;
|
||||
|
||||
if (ac3iec->caps == NULL) {
|
||||
gint rate = ac3iec->padder->rate;
|
||||
|
||||
if (ac3iec->raw_audio) {
|
||||
ac3iec->caps =
|
||||
gst_caps_make_writable (gst_static_caps_get (&raw_audio_caps));
|
||||
} else {
|
||||
ac3iec->caps =
|
||||
gst_caps_make_writable (gst_static_caps_get (&normal_caps));
|
||||
}
|
||||
gst_structure_set (gst_caps_get_structure (ac3iec->caps, 0), "rate",
|
||||
G_TYPE_INT, rate, NULL);
|
||||
gst_pad_set_caps (ac3iec->src, ac3iec->caps);
|
||||
}
|
||||
|
||||
/* We have a new frame: */
|
||||
bufcaps = GST_PAD_CAPS (ac3iec->src);
|
||||
|
||||
/* Create a new buffer, and copy the frame data into it. */
|
||||
ret =
|
||||
gst_pad_alloc_buffer_and_set_caps (ac3iec->src, 0,
|
||||
AC3P_IEC_FRAME_SIZE, bufcaps, &new);
|
||||
if (ret != GST_FLOW_OK)
|
||||
goto buffer_alloc_failed;
|
||||
|
||||
memcpy (GST_BUFFER_DATA (new), ac3p_frame (ac3iec->padder),
|
||||
AC3P_IEC_FRAME_SIZE);
|
||||
|
||||
/* Set the timestamp. */
|
||||
GST_BUFFER_TIMESTAMP (new) = ac3iec->cur_ts;
|
||||
GST_BUFFER_DURATION (new) = IEC958_FRAME_DURATION;
|
||||
ac3iec->cur_ts = GST_CLOCK_TIME_NONE;
|
||||
|
||||
GST_LOG_OBJECT (ac3iec, "Pushing IEC958 buffer of size %d",
|
||||
GST_BUFFER_SIZE (new));
|
||||
/* Push the buffer to the source pad. */
|
||||
ret = gst_pad_push (ac3iec->src, new);
|
||||
}
|
||||
|
||||
event = ac3p_parse (ac3iec->padder);
|
||||
}
|
||||
|
||||
gst_buffer_unref (buf);
|
||||
|
||||
done:
|
||||
gst_object_unref (ac3iec);
|
||||
|
||||
return ret;
|
||||
|
||||
buffer_alloc_failed:
|
||||
gst_buffer_unref (buf);
|
||||
goto done;
|
||||
|
||||
}
|
||||
|
||||
|
||||
static GstStateChangeReturn
|
||||
ac3iec_change_state (GstElement * element, GstStateChange transition)
|
||||
{
|
||||
AC3IEC *ac3iec;
|
||||
GstStateChangeReturn ret;
|
||||
|
||||
g_return_val_if_fail (GST_IS_AC3IEC (element), GST_STATE_CHANGE_FAILURE);
|
||||
|
||||
ac3iec = AC3IEC (element);
|
||||
|
||||
switch (transition) {
|
||||
case GST_STATE_CHANGE_NULL_TO_READY:
|
||||
break;
|
||||
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
||||
ac3p_init (ac3iec->padder);
|
||||
break;
|
||||
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
|
||||
|
||||
switch (transition) {
|
||||
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
|
||||
break;
|
||||
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
||||
ac3p_clear (ac3iec->padder);
|
||||
if (ac3iec->caps) {
|
||||
gst_caps_unref (ac3iec->caps);
|
||||
ac3iec->caps = NULL;
|
||||
}
|
||||
break;
|
||||
case GST_STATE_CHANGE_READY_TO_NULL:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
plugin_init (GstPlugin * plugin)
|
||||
{
|
||||
if (!gst_element_register (plugin, "ac3iec958", GST_RANK_NONE,
|
||||
GST_TYPE_AC3IEC)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
||||
GST_VERSION_MINOR,
|
||||
"iec958",
|
||||
"Convert raw AC3 into IEC958 (S/PDIF) frames",
|
||||
plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN);
|
|
@ -1,88 +0,0 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2004 Martin Soto <martinsoto@users.sourceforge.net>
|
||||
*
|
||||
* ac3iec.h: Pad AC3 frames into IEC958 frames for the SP/DIF interface.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __AC3IEC_H__
|
||||
#define __AC3IEC_H__
|
||||
|
||||
#include <gst/gst.h>
|
||||
|
||||
#include "ac3_padder.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
#define GST_TYPE_AC3IEC \
|
||||
(ac3iec_get_type())
|
||||
#define AC3IEC(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AC3IEC,AC3IEC))
|
||||
#define AC3IEC_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AC3IEC,AC3IECClass))
|
||||
#define GST_IS_AC3IEC(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AC3IEC))
|
||||
#define GST_IS_AC3IEC_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AC3IEC))
|
||||
|
||||
|
||||
typedef struct _AC3IEC AC3IEC;
|
||||
typedef struct _AC3IECClass AC3IECClass;
|
||||
|
||||
|
||||
typedef enum {
|
||||
AC3IEC_OPEN = (GST_ELEMENT_FLAG_LAST << 0),
|
||||
AC3IEC_FLAG_LAST = (GST_ELEMENT_FLAG_LAST << 2)
|
||||
} Ac3iecFlags;
|
||||
|
||||
|
||||
struct _AC3IEC {
|
||||
GstElement element;
|
||||
|
||||
GstPad *sink;
|
||||
GstPad *src;
|
||||
|
||||
GstCaps *caps; /* source pad caps, once known */
|
||||
|
||||
GstClockTime cur_ts; /* Time stamp for the current
|
||||
frame. */
|
||||
GstClockTime next_ts; /* Time stamp for the next frame. */
|
||||
|
||||
ac3_padder *padder; /* AC3 to SPDIF padder object. */
|
||||
|
||||
gboolean dvdmode; /* TRUE if DVD mode (input is
|
||||
demultiplexed from a DVD) is
|
||||
active. */
|
||||
|
||||
gboolean raw_audio; /* TRUE if output pad should use raw
|
||||
audio capabilities. */
|
||||
};
|
||||
|
||||
|
||||
struct _AC3IECClass {
|
||||
GstElementClass parent_class;
|
||||
|
||||
/* Signals */
|
||||
};
|
||||
|
||||
|
||||
extern GType ac3iec_get_type (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __AC3IEC_H__ */
|
|
@ -5,7 +5,6 @@ win32/vs6/libgstac3parse.dsp
|
|||
win32/vs6/libgstasfdemux.dsp
|
||||
win32/vs6/libgstdvdlpcmdec.dsp
|
||||
win32/vs6/libgstdvdsub.dsp
|
||||
win32/vs6/libgstiec958.dsp
|
||||
win32/vs6/libgstlame.dsp
|
||||
win32/vs6/libgstmad.dsp
|
||||
win32/vs6/libgstmpegaudioparse.dsp
|
||||
|
|
|
@ -1,131 +0,0 @@
|
|||
# Microsoft Developer Studio Project File - Name="libgstiec958" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
|
||||
CFG=libgstiec958 - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "libgstiec958.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "libgstiec958.mak" CFG="libgstiec958 - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "libgstiec958 - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "libgstiec958 - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "libgstiec958 - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBGSTIEC958_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /O2 /I "./" /I "../../gst-libs" /I "../../../gstreamer" /I "../common" /I "../../../gstreamer/libs" /I "../../../gst-plugins-base/gst-libs" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBGSTIEC958_EXPORTS" /D "HAVE_CONFIG_H" /FD /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x40c /d "NDEBUG"
|
||||
# ADD RSC /l 0x40c /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
|
||||
# ADD LINK32 libgstriff-0.10.lib libgstreamer-0.10.lib libgstbase-0.10.lib glib-2.0.lib gobject-2.0.lib /nologo /dll /machine:I386 /libpath:"../../../gstreamer/win32/vs6/release" /libpath:"./release" /libpath:"../../../gst-plugins-base/win32/vs6/release"
|
||||
# Begin Special Build Tool
|
||||
TargetPath=.\Release\libgstiec958.dll
|
||||
SOURCE="$(InputPath)"
|
||||
PostBuild_Cmds=copy /Y $(TargetPath) c:\gstreamer\lib\gstreamer-0.10
|
||||
# End Special Build Tool
|
||||
|
||||
!ELSEIF "$(CFG)" == "libgstiec958 - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBGSTIEC958_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "../../gst-libs" /I "../../../gstreamer" /I "../common" /I "../../../gstreamer/libs" /I "../../../gst-plugins-base/gst-libs" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBGSTIEC958_EXPORTS" /D "HAVE_CONFIG_H" /FD /GZ /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x40c /d "_DEBUG"
|
||||
# ADD RSC /l 0x40c /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 libgstriff-0.10.lib libgstreamer-0.10.lib libgstbase-0.10.lib glib-2.0D.lib gobject-2.0D.lib /nologo /dll /debug /machine:I386 /pdbtype:sept /libpath:"../../../gstreamer/win32/vs6/debug" /libpath:"./debug" /libpath:"../../../gst-plugins-base/win32/vs6/debug"
|
||||
# Begin Special Build Tool
|
||||
TargetPath=.\Debug\libgstiec958.dll
|
||||
SOURCE="$(InputPath)"
|
||||
PostBuild_Cmds=copy /Y $(TargetPath) c:\gstreamer\debug\lib\gstreamer-0.10
|
||||
# End Special Build Tool
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "libgstiec958 - Win32 Release"
|
||||
# Name "libgstiec958 - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\gst\iec958\ac3_padder.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\gst\iec958\ac3iec.c
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\gst\iec958\ac3_padder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\gst\iec958\ac3iec.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
Loading…
Reference in a new issue