Commit 29256049 authored by Jean-Paul Saman's avatar Jean-Paul Saman

Merge branch 'branch/libdvbpsi-ng' of git.m2x.eu:libdvbpsi

Conflicts:
	configure.ac
	examples/decode_mpeg.c
	examples/get_pcr_pid.c
	src/Makefile.am
	src/demux.h
	src/dvbpsi.h
	src/dvbpsi_private.h
	src/psi.h
	src/tables/bat.h
	src/tables/bat_private.h
	src/tables/cat.h
	src/tables/cat_private.h
	src/tables/eit.h
	src/tables/eit_private.h
	src/tables/nit.h
	src/tables/nit_private.h
	src/tables/pat.h
	src/tables/pat_private.h
	src/tables/pmt.h
	src/tables/pmt_private.h
	src/tables/sdt.h
	src/tables/sdt_private.h
	src/tables/sis.h
	src/tables/sis_private.h
	src/tables/tot.h
	src/tables/tot_private.h
parents 08e3266c 2fede7bd
......@@ -21,12 +21,14 @@ configure
libtool
stamp-*
*-stamp
doc/doxygen
examples/decode_mpeg
examples/decode_pat
examples/decode_pmt
examples/decode_sdt
examples/decode_bat
examples/get_pcr_pid
examples/dvbinfo/dvbinfo
misc/gen_crc
misc/gen_pat
misc/gen_pmt
......
INSTALL file for "libdvbpsi".
* Developers
* Configuring "libdvbpsi"
* Building "libdvbpsi"
* Installing and using "libdvbpsi"
* Building documentation
* Building packages
Developers
==========
Before starting to enhance libdvbpsi as you downloaded it from the git repository
at git.videolan.org make sure you have autotools (autoconf, automake, m4, libtool)
installed.
Clone the repository:
git clone git://git.videolan.org/libdvbpsi.git
In contrast to other autotools enabled programs libdvbpsi uses a script named
'bootstrap' to generate the configure script. Others use a program 'autogen.sh'
for that. For libdvbpsi you need to run:
./bootstrap
Run the configure script for development:
./configure --prefix=/usr --enable-debug --disable-release
Now you can start enhancing libdvbpsi.
Configuring "libdvbpsi"
=======================
......@@ -26,7 +55,6 @@ Building "libdvbpsi"
Once configured, run 'make' to build the library and the programs
located in the 'examples' and 'misc' directories.
Installing and using "libdvbpsi"
================================
......@@ -54,5 +82,10 @@ doxygen tool (http://www.doxygen.org/) and the graphviz tool
Building packages
=================
Further writing.
Once configure, run 'make dist', this will generate a libdvbpsi-${VERSION}.tar.gz
and libdvbpsi-${VERSION}.tar.bz2. If you intend to build a package for RPM based
linux distributions, then you can run 'rpmbuild -ta libdvbpsi-${VERSION}.tar.gz'
or 'rpmbuild -ta libdvbpsi-${VERSION}.tar.bz2'.
For distributions that use another package management system look at their documentation
on howto create a installable package for it.
$Id$
Changes between 0.2.2 and 1.0.0:
--------------------------------
* new example application dvbinfo
* updated documentation (new api howto)
* add log callback (remove fprintf's)
* make API more consistent
- introduces dvbpsi_t typedef
- removed dvbpis_handle
Changes between 0.2.1 and 0.2.2:
--------------------------------
......
AC_INIT(libdvbpsi, 0.2.2)
AC_INIT(libdvbpsi, 1.0.0)
AC_PREREQ(2.50)
AC_CONFIG_AUX_DIR(.auto)
......@@ -7,7 +7,7 @@ AC_CANONICAL_SYSTEM
AM_INIT_AUTOMAKE
AM_CONFIG_HEADER(config.h)
#AC_CANONICAL_HOST
dnl AC_CANONICAL_HOST
AC_PROG_CC
AC_STDC_HEADERS
AC_C_INLINE
......@@ -15,9 +15,8 @@ AC_C_INLINE
AC_LIBTOOL_WIN32_DLL
AM_PROG_LIBTOOL
dnl default CFLAGS
CFLAGS="${CFLAGS} -Wall -DDVBPSI_DIST --std=gnu99"
CFLAGS="${CFLAGS} -Wall -Werror --std=gnu99 -D_GNU_SOURCE"
CFLAGS="${CFLAGS} -Wpointer-arith -Wcast-align -Wcast-qual -Wstrict-prototypes -Wshadow -Waggregate-return -Wmissing-prototypes -Wnested-externs -Wsign-compare"
dnl check the operating system
......@@ -37,7 +36,7 @@ AC_ARG_ENABLE(debug,
esac],[debug=false])
if test "$debug" = "true"
then
CFLAGS="${CFLAGS} -DDEBUG -g"
CFLAGS="${CFLAGS} -g -ggdb3"
fi
......@@ -53,12 +52,12 @@ if test "$release" = "true"
then
CFLAGS="${CFLAGS} -O6"
else
CFLAGS="${CFLAGS} -O2"
CFLAGS="${CFLAGS} -O2 -DDVBPSI_DIST"
fi
dnl Check for headers
AC_CHECK_HEADERS(stdint.h inttypes.h)
AC_CHECK_FUNCS(gettimeofday)
AC_CHECK_HEADERS(stdbool.h stdint.h inttypes.h getopt.h strings.h sys/time.h)
dnl AC_CHECK_FUNCS([gettimeofday])
AC_CHECK_HEADERS(sys/socket.h, [ac_have_sys_socket_h=yes])
AM_CONDITIONAL(HAVE_SYS_SOCKET_H, test "${ac_have_sys_socket_h}" = "yes")
......@@ -79,6 +78,7 @@ fi
AC_OUTPUT([Makefile
src/Makefile
examples/Makefile
examples/dvbinfo/Makefile
misc/Makefile
doc/Makefile
wince/Makefile
......
## Process this file with automake to produce Makefile.in
EXTRA_DIST=index.doxygen structure.doxygen usage.doxygen newdec.doxygen \
howto-new-api.doxygen \
decoder.dot doxygen.cfg
MOSTLYCLEANFILES=decoder.png
......
......@@ -31,7 +31,7 @@ PROJECT_NAME = libdvbpsi
# This could be handy for archiving the generated documentation or
# if some version control system is used.
PROJECT_NUMBER = 0.2.2
PROJECT_NUMBER = 1.0.0
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.
......@@ -585,6 +585,7 @@ INPUT = index.doxygen \
structure.doxygen \
usage.doxygen \
newdec.doxygen \
howto-new-api.doxygen \
../src \
../src/tables \
../src/descriptors
......
/*! \page Howto port dvbpsi API (upto version 0.2.0) to version 1.0.0
<p>An update to libdvbpsi API was long overdue. In time the API grew to be inconsistent and
needed some cleanup. The following issue are addressed in this version:</p>
<ul>
<li>explicit library handle allocation with <em>dvbpsi_NewHandle()</em> (delete with <em>dvbpsi_DeleteHandle()</em>)</li>
<li>consistent API for table and descriptor decoder/encoders</li>
<li>message callback function for easier intergrating libdvbpsi logging in applications</li>
</ul>
<p>The biggest change is the addition off an explicit dvbpsi_t pointer to
ALL table decoder and encoder API's. This dvbpsi_t pointer is a dvbpsi handle
which must be allocated using <em>dvbpsi_NewHandle()</em> and takes a callback function
for logging.
</p>
<code>dvbpsi_t *dvbpsi_NewHandle(dvbpsi_message_cb callback, enum dvbpsi_msg_level level);</code>
<p>The dvbpsi_t pointer must be released by calling <em>dvbpsi_DeleteHandle()</em></p>
<code>void dvbpsi_DeleteHandle(dvbpsi_t *handle);</code>
<h2>Example</h2>
<p>
The following examples shows howto translate existing applications. In these examples only
source code snippits are used and can thus not be compiled standalone. The examples are taken
from existing applications using libdvbpsi.
</p>
<p>In many existing applications the following scheme is used to attaching a PAT decoder to a dvbpsi handle:</p>
<code>
dvbpsi_handle handle;
dvbpsi_AttachPAT(handle, handle_PAT, data);
</code>
<p>The same scheme is used for other PSI tables too, this translate to the following code sequence:</p>
<code>
dvbpsi_t *handle = dvbpsi_NewHandle(&dvbpsi_message, DVBPSI_MSG_DEBUG);
if (handle == NULL)
goto error;
if (!dvbpsi_AttachPAT(handle, handle_PAT, data))
{
dvbpsi_DeleteHandle(handle);
handle = NULL;
goto error;
}
return 0;
error:
if (dvbpsi_HasDecoder(handle))
dvbpsi_DetachPAT(andle);
if (handle)
dvbpsi_DeleteHandle(handle);
return -1;
</code>
<p>The <em>message callback function</em> <b>dvbpsi_message</b> is defined as follows below. In this case
the output goes directly to the console. Applications however can call into their messaging API and pass
along libdvbpsi messages if wanted.
</p>
<code>
static void dvbpsi_message(dvbpsi_t *p_dvbpsi, const dvbpsi_msg_level_t level, const char* msg)
{
switch(level)
{
case DVBPSI_MSG_ERROR: fprintf(stderr, "Error: "); break;
case DVBPSI_MSG_WARN: fprintf(stderr, "Warning: "); break;
case DVBPSI_MSG_DEBUG: fprintf(stderr, "Debug: "); break;
default:
return;
}
fprintf(stderr, "%s\n", msg);
}
</code>
*/
......@@ -15,7 +15,9 @@ describes how to use it and the "C" API.</p>
<h2>What is libdvbpsi ?</h2>
<p><em>libdvbpsi</em> is a set of tools which allows to decode and generate all the Program specific Information (<em>PSI</em>) present in a MPEG2 TS or a DVB stream.</p>
<p><em>libdvbpsi</em> is a library that provides API's to decode and generate all the Program specific Information (<em>PSI</em>) and descriptors present in a MPEG2 TS or a DVB stream.</p>
<p><b><em>libdvbpsi</em> version 1.0.0 breaks API compatibility with earlier versions</b>. The benefits are a more consistent API and the library no longer makes calls to printf which improves its use in threaded applications.</p>
<p>The two keywords are <em>portability</em> and <em>simplicity</em>.</p>
......@@ -44,6 +46,7 @@ describes how to use it and the "C" API.</p>
<li>\ref structure</li>
<li>\ref usage</li>
<li>\ref newdec</li>
<li>\ref howto-new-api</li>
</ul>
*/
......@@ -29,4 +29,6 @@ tables.</p>
\ref usage
\ref howto-new-api
*/
/*! \page usage API usage
<p>When the application needs a new decoder it just has to call the
<p>Each application requires a handle to the dvbpsi library. The function
dvbpsi_NewHandle(&message_cb, DVBPSI_MSG_DEBUG) will return a handle. All
error, warning or debug messages will trigger the <em>message_cb</em> function.
Unless DVBPSI_MSG_NONE is passed to dvbpsi_NewHandle(). For each <em>
dvbpsi_AttachXXX()</em> function a unique dvbpsi handle must be used.</p>
<p>A dvbpsi handle must be passed to an <em>dvbpsi_AttachXXX()</em> function
which attaches a decoder to the (dvbpsi_t*)->p_private pointer. The
<em>dvbpsi_AttachXXX()</em> function where XXX is the name of the table
(ex: dvbpsi_AttachPAT()). The function returns a handle on the new
decoder.</p>
(ex: dvbpsi_AttachPAT()). The function returns the dvbpsi handle with the
new decoder attached decoder.</p>
<p>Then the application has to send the TS packets needed by the decoder
by calling the dvbpsi_PushPacket() function. If a new table is complete
......@@ -12,10 +19,9 @@ called <em>dvbpsi_AttachXXX()</em>.</p>
<p>When the application don't need the decoder anymore it just has to
call the <em>dvbpsi_DetachXXX()</em> function (ex:
dvbpsi_DetachPAT()).</p>
<p>In this version of <em>libdvbpsi</em> the descriptors aren't decoded.
These decoders will come in the next release.</p>
dvbpsi_DetachPAT()). The dvbpsi handle must be released by calling
dvbpsi_DeleteHandle(). At the time of calling the decoder must already
have been detached.</p>
<p>For specific tools, the best to do is to have a look at the include
file:</p>
......@@ -35,4 +41,6 @@ file:</p>
\ref structure
\ref howto-new-api
*/
## Process this file with automake to produce Makefile.in
SUBDIRS = dvbinfo
DIST_SUBDIRS = $(SUBDIRS)
noinst_PROGRAMS = decode_pat decode_pmt get_pcr_pid decode_sdt decode_mpeg decode_bat
decode_pat_SOURCES = decode_pat.c
decode_pat_CPPFLAGS = -DDVBPSI_DIST
decode_pat_LDFLAGS = -L../src -ldvbpsi
decode_pmt_SOURCES = decode_pmt.c
decode_pmt_CPPFLAGS = -DDVBPSI_DIST
decode_pmt_LDFLAGS = -L../src -ldvbpsi -lm
get_pcr_pid_SOURCES = get_pcr_pid.c
get_pcr_pid_CPPFLAGS = -DDVBPSI_DIST
get_pcr_pid_LDFLAGS = -L../src -ldvbpsi -lm
decode_sdt_SOURCES = decode_sdt.c
decode_sdt_CPPFLAGS = -DDVBPSI_DIST
decode_sdt_LDFLAGS = -L../src -ldvbpsi
decode_mpeg_SOURCES = decode_mpeg.c
if HAVE_SYS_SOCKET_H
decode_mpeg_SOURCES += connect.c connect.h
endif
decode_mpeg_CPPFLAGS = -D_FILE_OFFSET_BITS=64 -DDVBPSI_DIST
decode_mpeg_LDFLAGS = -L../src -ldvbpsi -lm
decode_bat_SOURCES = decode_bat.c
decode_bat_CPPFLAGS = -DDVBPSI_DIST
decode_bat_LDFLAGS = -L../src -ldvbpsi
/*****************************************************************************
* decode_bat.c: BAT decoder example
*----------------------------------------------------------------------------
* Copyright (C) 2001-2010 VideoLAN
* Copyright (C) 2001-2011 VideoLAN
* $Id: decode_bat.c 01 2010-04-01 17:55:18 zhuzlu $
*
* Authors: Zhu zhenglu <zhuzlu@gmail.com>
......@@ -24,11 +24,11 @@
*
*****************************************************************************/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <unistd.h>
#include <fcntl.h>
......@@ -56,7 +56,7 @@
/*****************************************************************************
* ReadPacket
*****************************************************************************/
static int ReadPacket(int i_fd, uint8_t* p_dst)
static bool ReadPacket(int i_fd, uint8_t* p_dst)
{
int i = 187;
int i_rc = 1;
......@@ -75,7 +75,7 @@ static int ReadPacket(int i_fd, uint8_t* p_dst)
i -= i_rc;
}
return (i == 0) ? 1 : 0;
return (i == 0) ? true : false;
}
......@@ -198,15 +198,28 @@ static void DumpBAT(void* p_zero, dvbpsi_bat_t* p_bat)
/*****************************************************************************
* NewSubtable
*****************************************************************************/
static void NewSubtableBAT(void * p_zero, dvbpsi_handle h_dvbpsi,
static void NewSubtableBAT(void * p_zero, dvbpsi_t *p_dvbpsi,
uint8_t i_table_id, uint16_t i_extension)
{
if(i_table_id == 0x4a)
{
dvbpsi_AttachBAT(h_dvbpsi, i_table_id, i_extension, DumpBAT, NULL);
if (!dvbpsi_AttachBAT(p_dvbpsi, i_table_id, i_extension, DumpBAT, NULL))
fprintf(stderr, "failed to attach BAT subdecoder\n");
}
}
static void message(dvbpsi_t *handle, const dvbpsi_msg_level_t level, const char* msg)
{
switch(level)
{
case DVBPSI_MSG_ERROR: fprintf(stderr, "Error: "); break;
case DVBPSI_MSG_WARN: fprintf(stderr, "Warning: "); break;
case DVBPSI_MSG_DEBUG: fprintf(stderr, "Debug: "); break;
default: /* do nothing */
return;
}
fprintf(stderr, "%s\n", msg);
}
/*****************************************************************************
* main
......@@ -215,15 +228,21 @@ int main(int i_argc, char* pa_argv[])
{
int i_fd;
uint8_t data[188];
dvbpsi_handle h_dvbpsi;
int b_ok;
dvbpsi_t *p_dvbpsi;
bool b_ok;
if(i_argc != 2)
return 1;
i_fd = open(pa_argv[1], 0);
if (i_fd < 0)
return 1;
h_dvbpsi = dvbpsi_AttachDemux(NewSubtableBAT, NULL);
p_dvbpsi = dvbpsi_NewHandle(&message, DVBPSI_MSG_DEBUG);
if (p_dvbpsi == NULL)
goto out;
if (!dvbpsi_AttachDemux(p_dvbpsi, NewSubtableBAT, NULL))
goto out;
b_ok = ReadPacket(i_fd, data);
......@@ -231,11 +250,16 @@ int main(int i_argc, char* pa_argv[])
{
uint16_t i_pid = ((uint16_t)(data[1] & 0x1f) << 8) + data[2];
if(i_pid == 0x11)
dvbpsi_PushPacket(h_dvbpsi, data);
dvbpsi_PushPacket(p_dvbpsi, data);
b_ok = ReadPacket(i_fd, data);
}
dvbpsi_DetachDemux(h_dvbpsi);
out:
if (p_dvbpsi)
{
dvbpsi_DetachDemux(p_dvbpsi);
dvbpsi_DeleteHandle(p_dvbpsi);
}
close(i_fd);
return 0;
}
/*****************************************************************************
* decode_mpeg.c: MPEG decoder example
*----------------------------------------------------------------------------
* Copyright (C) 2001-2010 VideoLAN
* Copyright (C) 2001-2011 VideoLAN
* $Id: decode_mpeg.c 104 2005-03-21 13:38:56Z massiot $
*
* Authors: Jean-Paul Saman <jpsaman #_at_# m2x dot nl>
......@@ -29,10 +29,14 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#ifdef HAVE_SYS_TIME_H
#define HAVE_GETTIMEOFDAY 1
#include <sys/time.h>
#endif
#include <time.h>
#include <unistd.h>
#include <fcntl.h>
......@@ -100,7 +104,7 @@ typedef int64_t mtime_t;
typedef struct
{
dvbpsi_handle handle;
dvbpsi_t * handle;
int i_pat_version;
int i_ts_id;
......@@ -119,7 +123,7 @@ typedef struct ts_pid_s
typedef struct ts_pmt_s
{
dvbpsi_handle handle;
dvbpsi_t * handle;
int i_number; /* i_number = 0 is actually a NIT */
int i_pmt_version;
......@@ -183,6 +187,10 @@ static int ReadPacketFromSocket( int i_socket, uint8_t* p_dst, size_t i_size)
*****************************************************************************/
static void report_Header( int i_report )
{
#ifndef HAVE_GETTIMEOFDAY
printf("*** WARNING: !!! no gettimeofday support found !!! timing information will not be given !!! ***\n");
#endif
switch(i_report)
{
case REPORT_PCR:
......@@ -200,11 +208,7 @@ static void report_Header( int i_report )
*****************************************************************************/
#ifdef HAVE_GETTIMEOFDAY
static mtime_t report_UDPPacketTiming( int32_t i_seqno, int32_t bytes, mtime_t time_prev, mtime_t *time_base )
#else
static void report_UDPPacketTiming( int32_t i_seqno, int32_t bytes )
#endif
{
#ifdef HAVE_GETTIMEOFDAY
mtime_t time_current;
mtime_t tv_delta;
struct timeval tv;
......@@ -226,10 +230,14 @@ static void report_UDPPacketTiming( int32_t i_seqno, int32_t bytes )
time_prev = time_current;
printf( "%d\n", bytes );
return time_prev;
}
#else
printf( "\n" );
#endif
static void report_UDPPacketTiming( int32_t i_seqno, int32_t bytes )
{
printf( "%.2d %"PRId64" %"PRId64" ", i_seqno, 0UL, 0UL );
printf( "%d\n", bytes );
}
#endif
#ifdef HAVE_GETTIMEOFDAY
static mtime_t report_PCRPacketTiming( int i_cc, ts_pid_t *ts_pid,
......@@ -285,6 +293,19 @@ static void report_PCRPacketTiming( int i_cc, ts_pid_t *ts_pid,
#endif
}
static void message(dvbpsi_t *handle, const dvbpsi_msg_level_t level, const char* msg)
{
switch(level)
{
case DVBPSI_MSG_ERROR: fprintf(stderr, "Error: "); break;
case DVBPSI_MSG_WARN: fprintf(stderr, "Warning: "); break;
case DVBPSI_MSG_DEBUG: fprintf(stderr, "Debug: "); break;
default: /* do nothing */
return;
}
fprintf(stderr, "%s\n", msg);
}
/*****************************************************************************
* DumpPAT
*****************************************************************************/
......@@ -293,6 +314,14 @@ static void DumpPAT(void* p_data, dvbpsi_pat_t* p_pat)
dvbpsi_pat_program_t* p_program = p_pat->p_first_program;
ts_stream_t* p_stream = (ts_stream_t*) p_data;
if (p_stream->pmt.handle)
{
fprintf(stderr, "freeing old PMT\n");
dvbpsi_DetachPMT(p_stream->pmt.handle);
dvbpsi_DeleteHandle(p_stream->pmt.handle);
p_stream->pmt.handle = NULL;
}
p_stream->pat.i_pat_version = p_pat->i_version;
p_stream->pat.i_ts_id = p_pat->i_ts_id;
......@@ -303,12 +332,28 @@ static void DumpPAT(void* p_data, dvbpsi_pat_t* p_pat)
fprintf( stderr, " | program_number @ [NIT|PMT]_PID\n");
while( p_program )
{
if (p_stream->pmt.handle)
{
dvbpsi_DetachPMT(p_stream->pmt.handle);
dvbpsi_DeleteHandle(p_stream->pmt.handle);
p_stream->pmt.handle = NULL;
}
p_stream->i_pmt++;
p_stream->pmt.i_number = p_program->i_number;
p_stream->pmt.pid_pmt = &p_stream->pid[p_program->i_pid];
p_stream->pmt.pid_pmt->i_pid = p_program->i_pid;
p_stream->pmt.handle = dvbpsi_AttachPMT( p_program->i_number, DumpPMT, p_stream );
p_stream->pmt.handle = dvbpsi_NewHandle(&message, DVBPSI_MSG_DEBUG);
if (p_stream->pmt.handle == NULL)
{
fprintf(stderr, "could not allocate new dvbpsi_t handle\n");
break;
}
if (!dvbpsi_AttachPMT(p_stream->pmt.handle, p_program->i_number, DumpPMT, p_stream ))
{
dvbpsi_DeleteHandle(p_stream->pmt.handle);
fprintf(stderr, "could not attach PMT\n");
break;
}
fprintf( stderr, " | %14d @ 0x%x (%d)\n",
p_program->i_number, p_program->i_pid, p_program->i_pid);
p_program = p_program->p_next;
......@@ -546,7 +591,7 @@ int main(int i_argc, char* pa_argv[])
uint8_t *p_data = NULL;
ts_stream_t *p_stream = NULL;
int i_len = 0;
int b_verbose = 0;
bool b_verbose = false;
/* parser commandline arguments */
do {
......@@ -581,7 +626,7 @@ int main(int i_argc, char* pa_argv[])
break;
#endif
case 'v':
b_verbose = 1;
b_verbose = true;
break;
case -1:
break;
......@@ -636,8 +681,13 @@ int main(int i_argc, char* pa_argv[])
report_Header( i_report );
#endif
p_stream->pat.handle = dvbpsi_NewHandle(&message, DVBPSI_MSG_DEBUG);
if (p_stream->pat.handle == NULL)
goto dvbpsi_out;
if (!dvbpsi_AttachPAT(p_stream->pat.handle, DumpPAT, p_stream))
goto dvbpsi_out;
/* Enter infinite loop */
p_stream->pat.handle = dvbpsi_AttachPAT( DumpPAT, p_stream );
while( i_len > 0 )
{
int i = 0;
......@@ -663,6 +713,15 @@ int main(int i_argc, char* pa_argv[])
b_first = VLC_TRUE;
}
#endif
if (p_data[i] != 0x47) /* no sync skip this packet */
{
fprintf( stderr, "Missing TS sync word, skipping 188 bytes\n" );
break;
}
if (i_pid == 0x1FFF) /* null packet - TS content undefined */
continue;
if( i_pid == 0x0 )
dvbpsi_PushPacket(p_stream->pat.handle, p_tmp);
else if( p_stream->pmt.pid_pmt && i_pid == p_stream->pmt.pid_pmt->i_pid )
......@@ -726,7 +785,7 @@ int main(int i_argc, char* pa_argv[])
#endif
i_bytes = 0; /* reset byte counter */
if( b_discontinuity_seen )
if( b_discontinuity_indicator )
{
/* cc discontinuity is expected */
fprintf( stderr, "Server signalled the continuity counter discontinuity\n" );
......@@ -758,9 +817,15 @@ int main(int i_argc, char* pa_argv[])
#endif
}
if( p_stream->pmt.handle )
{
dvbpsi_DetachPMT( p_stream->pmt.handle );
dvbpsi_DeleteHandle( p_stream->pmt.handle );
}
if( p_stream->pat.handle )
dvbpsi_DetachPAT( p_stream->pat.handle );
{
dvbpsi_DetachPAT( p_stream->pat.handle );
dvbpsi_DeleteHandle( p_stream->pat.handle );
}
/* clean up */
if( filename )
......@@ -783,6 +848,13 @@ int main(int i_argc, char* pa_argv[])
out_of_memory:
fprintf( stderr, "Out of memory\n" );
dvbpsi_out:
if( p_stream->pat.handle )
{
dvbpsi_DetachPAT( p_stream->pat.handle );
dvbpsi_DeleteHandle( p_stream->pat.handle );
}
error:
if( p_data ) free( p_data );
if( filename ) free( filename );
......
/*****************************************************************************
* decode_pat.c: PAT decoder example
*----------------------------------------------------------------------------
* Copyright (C) 2001-2010 VideoLAN
* Copyright (C) 2001-2011 VideoLAN
* $Id$
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
......@@ -24,11 +24,11 @@
*
*****************************************************************************/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <unistd.h>
#include <fcntl.h>
......@@ -49,11 +49,10 @@
#include <dvbpsi/pat.h>
#endif
/*****************************************************************************
* ReadPacket
*****************************************************************************/
static int ReadPacket(int i_fd, uint8_t* p_dst)
static bool ReadPacket(int i_fd, uint8_t* p_dst)
{
int i = 187;
int i_rc = 1;
......@@ -72,7 +71,7 @@ static int ReadPacket(int i_fd, uint8_t* p_dst)
i -= i_rc;
}
return (i == 0) ? 1 : 0;
return (i == 0) ? true : false;
}
......@@ -97,6 +96,18 @@ static void DumpPAT(void* p_zero, dvbpsi_pat_t* p_pat)
dvbpsi_DeletePAT(p_pat);
}
static void message(dvbpsi_t *handle, const dvbpsi_msg_level_t level, const char* msg)
{
switch(level)
{
case DVBPSI_MSG_ERROR: fprintf(stderr, "Error: "); break;
case DVBPSI_MSG_WARN: fprintf(stderr, "Warning: "); break;
case DVBPSI_MSG_DEBUG: fprintf(stderr, "Debug: "); break;
default: /* do nothing */
return;
}
fprintf(stderr, "%s\n", msg);
}
/*****************************************************************************
* main
......@@ -105,15 +116,22 @@ int main(int i_argc, char* pa_argv[])
{
int i_fd;
uint8_t data[188];
dvbpsi_handle h_dvbpsi;
int b_ok;
dvbpsi_t *p_dvbpsi;
bool b_ok;
if(i_argc != 2)
return 1;
if (i_argc != 2)
return 1;
i_fd = open(pa_argv[1], 0);
if (i_fd < 0)
return 1;
h_dvbpsi = dvbpsi_AttachPAT(DumpPAT, NULL);
p_dvbpsi = dvbpsi_NewHandle(&message, DVBPSI_MSG_DEBUG);
if (p_dvbpsi == NULL)
goto out;
if (!dvbpsi_AttachPAT(p_dvbpsi, DumpPAT, NULL))
goto out;
b_ok = ReadPacket(i_fd, data);
......@@ -121,11 +139,17 @@ int main(int i_argc, char* pa_argv[])
{
uint16_t i_pid = ((uint16_t)(data[1] & 0x1f) << 8) + data[2];
if(i_pid == 0x0)
dvbpsi_PushPacket(h_dvbpsi, data);
dvbpsi_PushPacket(p_dvbpsi, data);
b_ok = ReadPacket(i_fd, data);
}
dvbpsi_DetachPAT(h_dvbpsi);
out:
if (p_dvbpsi)
{
dvbpsi_DetachPAT(p_dvbpsi);
dvbpsi_DeleteHandle(p_dvbpsi);
}
close(i_fd);
return 0;
}
......
/*****************************************************************************
* decode_pmt.c: PAT decoder example
*----------------------------------------------------------------------------
* Copyright (C) 2001-2010 VideoLAN
* Copyright (C) 2001-2011 VideoLAN
* $Id$
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
......@@ -24,11 +24,11 @@
*
*****************************************************************************/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <unistd.h>
#include <fcntl.h>
#include <math.h>
......@@ -62,7 +62,7 @@
/*****************************************************************************
* ReadPacket
*****************************************************************************/
static int ReadPacket(int i_fd, uint8_t* p_dst)
static bool ReadPacket(int i_fd, uint8_t* p_dst)
{
int i = 187;
int i_rc = 1;
......@@ -81,7 +81,7 @@ static int ReadPacket(int i_fd, uint8_t* p_dst)
i -= i_rc;
}
return (i == 0) ? 1 : 0;
return (i == 0) ? true : false;
}
/*****************************************************************************
......@@ -239,6 +239,18 @@ static void DumpPMT(void* p_zero, dvbpsi_pmt_t* p_pmt)
dvbpsi_DeletePMT(p_pmt);
}
static void message(dvbpsi_t *handle, const dvbpsi_msg_level_t level, const char* msg)
{
switch(level)
{
case DVBPSI_MSG_ERROR: fprintf(stderr, "Error: "); break;
case DVBPSI_MSG_WARN: fprintf(stderr, "Warning: "); break;
case DVBPSI_MSG_DEBUG: fprintf(stderr, "Debug: "); break;
default: /* do nothing */
return;
}
fprintf(stderr, "%s\n", msg);
}
/*****************************************************************************
* main
......@@ -247,18 +259,26 @@ int main(int i_argc, char* pa_argv[])
{
int i_fd;
uint8_t data[188];
dvbpsi_handle h_dvbpsi;
int b_ok;
dvbpsi_t *p_dvbpsi;
bool b_ok;
uint16_t i_program_number, i_pmt_pid;
if(i_argc != 4)
if (i_argc != 4)
return 1;
i_fd = open(pa_argv[1], 0);
if (i_fd < 0)
return 1;
i_program_number = atoi(pa_argv[2]);
i_pmt_pid = atoi(pa_argv[3]);
h_dvbpsi = dvbpsi_AttachPMT(i_program_number, DumpPMT, NULL);
p_dvbpsi = dvbpsi_NewHandle(&message, DVBPSI_MSG_DEBUG);
if (p_dvbpsi == NULL)
goto out;
if (!dvbpsi_AttachPMT(p_dvbpsi, i_program_number, DumpPMT, NULL))
goto out;
b_ok = ReadPacket(i_fd, data);
......@@ -266,11 +286,17 @@ int main(int i_argc, char* pa_argv[])
{
uint16_t i_pid = ((uint16_t)(data[1] & 0x1f) << 8) + data[2];
if(i_pid == i_pmt_pid)
dvbpsi_PushPacket(h_dvbpsi, data);
dvbpsi_PushPacket(p_dvbpsi, data);
b_ok = ReadPacket(i_fd, data);
}
dvbpsi_DetachPMT(h_dvbpsi);
out:
if (p_dvbpsi)
{
dvbpsi_DetachPMT(p_dvbpsi);
dvbpsi_DeleteHandle(p_dvbpsi);
}
close(i_fd);
return 0;
}
......
/*****************************************************************************
* decode_sdt.c: SDT decoder example
*----------------------------------------------------------------------------
* Copyright (C) 2001-2010 VideoLAN
* Copyright (C) 2001-2011 VideoLAN
* $Id: decode_sdt.c,v 1.1 2002/12/11 13:04:56 jobi Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
......@@ -25,11 +25,11 @@
*
*****************************************************************************/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <unistd.h>
#include <fcntl.h>
......@@ -54,11 +54,10 @@
#include <dvbpsi/sdt.h>
#endif
/*****************************************************************************
* ReadPacket
*****************************************************************************/
static int ReadPacket(int i_fd, uint8_t* p_dst)
static bool ReadPacket(int i_fd, uint8_t* p_dst)
{
int i = 187;
int i_rc = 1;
......@@ -77,7 +76,7 @@ static int ReadPacket(int i_fd, uint8_t* p_dst)
i -= i_rc;
}
return (i == 0) ? 1 : 0;
return (i == 0) ? true : false;
}
......@@ -123,15 +122,32 @@ static void DumpSDT(void* p_zero, dvbpsi_sdt_t* p_sdt)
dvbpsi_DeleteSDT(p_sdt);
}
/*****************************************************************************
* DVBPSI messaging callback
*****************************************************************************/
static void message(dvbpsi_t *handle, const dvbpsi_msg_level_t level, const char* msg)
{
switch(level)
{
case DVBPSI_MSG_ERROR: fprintf(stderr, "Error: "); break;
case DVBPSI_MSG_WARN: fprintf(stderr, "Warning: "); break;
case DVBPSI_MSG_DEBUG: fprintf(stderr, "Debug: "); break;
default: /* do nothing */
return;
}
fprintf(stderr, "%s\n", msg);
}
/*****************************************************************************
* NewSubtable
*****************************************************************************/
static void NewSubtable(void * p_zero, dvbpsi_handle h_dvbpsi,
static void NewSubtable(void * p_zero, dvbpsi_t *p_dvbpsi,
uint8_t i_table_id, uint16_t i_extension)
{
if(i_table_id == 0x42)
{
dvbpsi_AttachSDT(h_dvbpsi, i_table_id, i_extension, DumpSDT, NULL);
if (!dvbpsi_AttachSDT(p_dvbpsi, i_table_id, i_extension, DumpSDT, NULL))
fprintf(stderr, "Failed to attach SDT subdecoder\n");
}
}
......@@ -142,15 +158,22 @@ int main(int i_argc, char* pa_argv[])
{
int i_fd;
uint8_t data[188];
dvbpsi_handle h_dvbpsi;
int b_ok;
dvbpsi_t *p_dvbpsi;
bool b_ok;
if(i_argc != 2)
return 1;
i_fd = open(pa_argv[1], 0);
if (i_fd < 0)
return 1;
p_dvbpsi = dvbpsi_NewHandle(&message, DVBPSI_MSG_DEBUG);
if (p_dvbpsi == NULL)
goto out;
h_dvbpsi = dvbpsi_AttachDemux(NewSubtable, NULL);
if (!dvbpsi_AttachDemux(p_dvbpsi, NewSubtable, NULL))
goto out;
b_ok = ReadPacket(i_fd, data);
......@@ -158,12 +181,17 @@ int main(int i_argc, char* pa_argv[])
{
uint16_t i_pid = ((uint16_t)(data[1] & 0x1f) << 8) + data[2];
if(i_pid == 0x11)
dvbpsi_PushPacket(h_dvbpsi, data);
dvbpsi_PushPacket(p_dvbpsi, data);
b_ok = ReadPacket(i_fd, data);
}
dvbpsi_DetachDemux(h_dvbpsi);
out:
if (p_dvbpsi)
{
dvbpsi_DetachDemux(p_dvbpsi);
dvbpsi_DeleteHandle(p_dvbpsi);
}
close(i_fd);
return 0;
}
# Makefile.am for dvbinfo
#
noinst_PROGRAMS = dvbinfo
dvbinfo_SOURCES = dvbinfo.c dvbinfo.h libdvbpsi.c libdvbpsi.h buffer.c buffer.h
if HAVE_SYS_SOCKET_H
dvbinfo_SOURCES += tcp.c tcp.h udp.c udp.h
endif
dvbinfo_CPPFLAGS = -D_FILE_OFFSET_BITS=64 -DDVBPSI_DIST
dvbinfo_LDFLAGS = -L../../src -ldvbpsi -pthread -lm
/*****************************************************************************
* buffer.c: buffer management
*****************************************************************************
* Copyright (C) 2011 M2X BV
*
* Authors: Jean-Paul Saman <jpsaman@videolan.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*****************************************************************************/
#include "config.h"
#include <stdlib.h>
#include <stdbool.h>
#include <pthread.h>
#if defined(HAVE_INTTYPES_H)
# include <inttypes.h>
#elif defined(HAVE_STDINT_H)
# include <stdint.h>
#endif
#include <assert.h>
typedef int64_t mtime_t;
#include "buffer.h"
struct fifo_s
{
pthread_mutex_t lock;
pthread_cond_t wait;
bool b_force_wake;
ssize_t i_count;
buffer_t *p_first;
buffer_t **pp_last;
};
/* */
buffer_t *buffer_new(size_t i_size)
{
buffer_t *buffer = (buffer_t*)malloc(sizeof(buffer_t) + i_size);
if (buffer == NULL) return NULL;
buffer->i_size = i_size;
buffer->i_date = 0;
buffer->p_next = NULL;
buffer->p_data = (uint8_t*)((uint8_t *)buffer + sizeof(buffer_t));
return buffer;
}
void buffer_free(buffer_t *buffer)
{
free(buffer);
buffer = NULL;
}
/* Fifo */
fifo_t *fifo_new(void)
{
fifo_t *fifo = (fifo_t *) malloc(sizeof(fifo_t));
if (fifo == NULL) return NULL;
fifo->i_count = 0;
fifo->b_force_wake = false;
fifo->p_first = NULL;
fifo->pp_last = &fifo->p_first;
pthread_mutex_init(&fifo->lock, NULL);
pthread_cond_init(&fifo->wait, NULL);
return fifo;
}
void fifo_free(fifo_t *fifo)
{
if (fifo == NULL)
return;
pthread_mutex_lock(&fifo->lock);
buffer_t *p = fifo->p_first;
if (p != NULL)
{
fifo->i_count = 0;
fifo->p_first = NULL;
fifo->pp_last = &fifo->p_first;
}
pthread_mutex_unlock(&fifo->lock);
while (p != NULL)
{
buffer_t *buffer;
buffer = p->p_next;
buffer_free(p);
p = buffer;
}
pthread_cond_destroy(&fifo->wait);
pthread_mutex_destroy(&fifo->lock);
free(fifo);
fifo = NULL;
}
void fifo_wake(fifo_t *fifo)
{
pthread_mutex_lock(&fifo->lock);
if (fifo->p_first == NULL)
fifo->b_force_wake = true;
pthread_cond_broadcast(&fifo->wait);
pthread_mutex_unlock(&fifo->lock);
}
ssize_t fifo_count(fifo_t *fifo)
{
pthread_mutex_lock(&fifo->lock);
ssize_t count = fifo->i_count;
pthread_mutex_unlock(&fifo->lock);
return count;
}
void fifo_push(fifo_t *fifo, buffer_t *buffer)
{
buffer_t *p_last;
size_t i_depth = 0;
if (buffer == NULL)
return;
pthread_mutex_lock(&fifo->lock);
for (p_last = buffer; ; p_last = p_last->p_next)
{
i_depth ++;
if (!p_last->p_next)
break;
}
*fifo->pp_last = buffer;
fifo->pp_last = &p_last->p_next;
fifo->i_count += i_depth;
assert(fifo->p_first != NULL);
assert(fifo->pp_last != NULL);
pthread_cond_signal(&fifo->wait);
pthread_mutex_unlock(&fifo->lock);
}
buffer_t *fifo_pop(fifo_t *fifo)
{
buffer_t *buffer;
pthread_mutex_lock(&fifo->lock);
while ((fifo->p_first == NULL) && !fifo->b_force_wake)
pthread_cond_wait(&fifo->wait, &fifo->lock);
buffer = fifo->p_first;
fifo->b_force_wake = false;
if (buffer == NULL)
{
pthread_mutex_unlock(&fifo->lock);
return NULL;
}
fifo->p_first = buffer->p_next;
fifo->i_count--;
if (fifo->p_first == NULL)
{
fifo->pp_last = &fifo->p_first;
}
pthread_mutex_unlock(&fifo->lock);
buffer->p_next = NULL;
return buffer;
}
/*****************************************************************************
* buffer.h: buffer management
*****************************************************************************
* Copyright (C) 2011 M2X BV
*
* Authors: Jean-Paul Saman <jpsaman@videolan.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*****************************************************************************/
#ifndef DVBINFO_BUFFER_H_
#define DVBINFO_BUFFER_H_
typedef struct buffer_s buffer_t;
struct buffer_s
{
size_t i_size; /* size of buffer data */
mtime_t i_date; /* timestamp */
buffer_t *p_next; /* pointer to next buffer_t */
uint8_t *p_data; /* actuall buffer data */
};
typedef struct fifo_s fifo_t;
/* Buffer management:
* buffer_new() - create new buffer of size i_size + plus header structure
* buffer_free() - free buffer
*/
buffer_t *buffer_new(size_t i_size);
void buffer_free(buffer_t *buffer);
/* Fifo:
* fifo_new() - create a new fifo holding buffer_t pointers
* fifo_free() - release fifo and all buffers contained therein
* fifo_count()- number of buffers in fifo_t
* fifo_push() - push buffer at end of fifo
* fifo_pop() - pop buffer from start of fifo
* fifo_wake() - wake up fifo listeners
*/
fifo_t *fifo_new(void);
void fifo_free(fifo_t *fifo);
ssize_t fifo_count(fifo_t *fifo);
void fifo_push(fifo_t *fifo, buffer_t *buffer);
buffer_t *fifo_pop(fifo_t *fifo);
void fifo_wake(fifo_t *fifo);
#endif
This diff is collapsed.
/*****************************************************************************
* dvbinfo.h: DVB PSI Information
*****************************************************************************
* Copyright (C) 2010-2011 M2X BV
*
* Authors: Jean-Paul Saman <jpsaman@videolan.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*****************************************************************************/
#ifndef DVBINFO_H_
#define DVBINFO_H_
typedef struct params_s
{
/* parameters */
char *output;
char *input;
int port;
bool b_udp;
bool b_tcp;
/* */
int fd_in;
int fd_out;
int debug;
bool b_verbose;
/* read data from file of socket */
ssize_t (*pf_read)(int fd, void *buf, size_t count);
ssize_t (*pf_write)(int fd, const void *buf, size_t count);
} params_t;
#endif
This diff is collapsed.
/*****************************************************************************
* libdvbpsi.h: DVB PSI Information
*****************************************************************************
* Copyright (C) 2010-2011 M2X BV
*
* Authors: Jean-Paul Saman <jpsaman@videolan.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*****************************************************************************/
#ifndef DVBINFO_DVBPSI_H_
#define DVBINFO_DVBPSI_H_
typedef int64_t mtime_t;
mtime_t mdate(void);
/* MPEG-TS PSI decoders */
typedef struct ts_stream_t ts_stream_t;
/* */
ts_stream_t *libdvbpsi_init(int debug);
bool libdvbpsi_process(ts_stream_t *stream, uint8_t *buf, ssize_t length, mtime_t date);
void libdvbpsi_summary(ts_stream_t *stream);
void libdvbpsi_exit(ts_stream_t *stream);
#endif
/*****************************************************************************
* tcp.c: network socket abstractions
*****************************************************************************
* Copyright (C) 2010-2011 M2X BV
*
* Authors: Jean-Paul Saman <jpsaman@videolan.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*****************************************************************************/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>
#if defined(HAVE_INTTYPES_H)
# include <inttypes.h>
#elif defined(HAVE_STDINT_H)
# include <stdint.h>
#endif
#include <sys/time.h>
#include <sys/types.h>
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
# include <netinet/in.h>
# include <net/if.h>
# if defined(WIN32)
# include <netinet/if_ether.h>
# endif
# include <netdb.h>
# ifndef BSD
# include <netinet/ip.h>
# endif
# include <netinet/udp.h>
# include <arpa/inet.h>
#endif
#include "tcp.h"
#ifdef HAVE_SYS_SOCKET_H
int tcp_close(int fd)
{
int result = 0;
result = shutdown(fd, 2);
if (result < 0)
perror("tcp shutdown error");
return result;
}
int tcp_open(const char *ipaddress, int port)
{
int s_ctl = -1;
int result = -1;
if (!ipaddress) return -1;
/* only support ipv4 */
struct addrinfo hints, *addr;
char *psz_service;
if ((port > 65535) || (port < 0))
{
fprintf(stderr, "tcp error: invalid port %d specified\n", port);
return -1;
}
if (asprintf(&psz_service, "%d", port) < 0)
return -1;
memset (&hints, 0, sizeof (hints));
hints.ai_family = AF_INET; /* use AF_INET6 for ipv6 */
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;
hints.ai_flags = AI_CANONNAME | 0;
result = getaddrinfo(ipaddress, psz_service, &hints, &addr);
if (result < 0)
{
fprintf(stderr, "tcp address error: %s\n", gai_strerror(result));
free(psz_service);
return -1;
}
for (struct addrinfo *ptr = addr; ptr != NULL; ptr = ptr->ai_next )
{
s_ctl = socket(ptr->ai_family, ptr->ai_socktype, ptr->ai_protocol);
if (s_ctl <= 0)
{
perror("tcp socket error");
continue;
}
setsockopt (s_ctl, SOL_SOCKET, SO_REUSEADDR, &(int){ 1 }, sizeof (int));
result = connect( s_ctl, ptr->ai_addr, ptr->ai_addrlen );
if (result < 0)
{
close(s_ctl);
perror( "tcp connect error" );
continue;
}
}
freeaddrinfo(addr);
free(psz_service);
return s_ctl;
}
ssize_t tcp_read(int fd, void *buf, size_t count)
{
ssize_t err;
again:
err = recv(fd, buf, count, MSG_CMSG_CLOEXEC | MSG_WAITALL);
if (err < 0)
{
switch(errno)
{
case EINTR:
case EAGAIN:
goto again;
case ECONNREFUSED:
fprintf(stderr, "remote host refused connection\n");
break;
case ENOTCONN:
fprintf(stderr, "connection not established\n");
break;
default:
fprintf(stderr, "recv error: %s\n", strerror(errno));
return -1;
}
}
return err;
}
#endif
/*****************************************************************************
* tcp.c: network socket abstractions
*****************************************************************************
* Copyright (C) 2010-2011 M2X BV
*
* Authors: Jean-Paul Saman <jpsaman@videolan.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*****************************************************************************/
#ifndef DVBINFO_TCP_H_
#define DVBINFO_TCP_H_
int tcp_open(const char *ipaddress, int port);
int tcp_close(int fd);
ssize_t tcp_read(int fd, void *buf, size_t count);
#endif
/*****************************************************************************
* udp.c: network socket abstractions
*****************************************************************************
* Copyright (C) 2010-2011 M2X BV
*
* Authors: Jean-Paul Saman <jpsaman@videolan.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*****************************************************************************/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/types.h>
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
# include <netinet/in.h>
# include <net/if.h>
# if defined(WIN32)
# include <netinet/if_ether.h>
# endif
# include <netdb.h>
# ifndef BSD
# include <netinet/ip.h>
# endif
# include <netinet/udp.h>
# include <arpa/inet.h>
#endif
#include "udp.h"
#ifdef HAVE_SYS_SOCKET_H
int udp_close(int fd)
{
int result = 0;
result = shutdown(fd, 2);
if (result < 0)
perror("udp shutdown error");
return result;
}
int udp_open(const char *ipaddress, int port)
{
int s_ctl = -1;
int result = -1;
if (!ipaddress) return -1;
/* only support ipv4 */
struct addrinfo hints, *addr;
char *psz_service;
if ((port > 65535) || (port < 0))
{
fprintf(stderr, "udp error: invalid port %d specified\n", port);
return -1;
}
if (asprintf(&psz_service, "%d", port) < 0)
return -1;
memset (&hints, 0, sizeof (hints));
hints.ai_family = AF_INET; /* use AF_INET6 for ipv6 */
hints.ai_socktype = SOCK_DGRAM;
hints.ai_protocol = IPPROTO_TCP;
hints.ai_flags = IPPROTO_UDP | 0;
result = getaddrinfo(ipaddress, psz_service, &hints, &addr);
if (result < 0)
{
fprintf(stderr, "udp address error: %s\n", gai_strerror(result));
free(psz_service);
return -1;
}
for (struct addrinfo *ptr = addr; ptr != NULL; ptr = ptr->ai_next )
{
s_ctl = socket(ptr->ai_family, ptr->ai_socktype, ptr->ai_protocol);
if (s_ctl <= 0)
{
perror("udp socket error");
continue;
}
/* Increase the receive buffer size to 1/2MB (8Mb/s during 1/2s)
* to avoid packet loss caused in case of scheduling hiccups */
setsockopt (s_ctl, SOL_SOCKET, SO_RCVBUF,
(void *)&(int){ 0x80000 }, sizeof (int));
setsockopt (s_ctl, SOL_SOCKET, SO_SNDBUF,
(void *)&(int){ 0x80000 }, sizeof (int));
setsockopt (s_ctl, SOL_SOCKET, SO_REUSEADDR, &(int){ 1 }, sizeof (int));
result = bind(s_ctl, ptr->ai_addr, ptr->ai_addrlen);
if (result < 0)
{
close(s_ctl);
perror("udp bind error");
continue;
}
}
freeaddrinfo(addr);
free(psz_service);
return s_ctl;
}
ssize_t udp_read(int fd, void *buf, size_t count)
{
ssize_t err;
again:
err = recv(fd, buf, count, MSG_CMSG_CLOEXEC);
if (err < 0)
{
switch(errno)
{
case EINTR:
case EAGAIN:
goto again;
case ECONNREFUSED:
fprintf(stderr, "remote host refused connection\n");
break;
case ENOTCONN:
fprintf(stderr, "connection not established\n");
break;
default:
fprintf(stderr, "recv error: %s\n", strerror(errno));
return -1;
}
}
return err;
}
#endif
/*****************************************************************************
* udp.c: network socket abstractions
*****************************************************************************
* Copyright (C) 2010-2011 M2X BV
*
* Authors: Jean-Paul Saman <jpsaman@videolan.org>
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*****************************************************************************/
#ifndef DVBINFO_UDP_H_
#define DVBINFO_UDP_H_
int udp_open(const char *ipaddress, int port);
int udp_close(int fd);
ssize_t udp_read(int fd, void *buf, size_t count);
#endif
/*****************************************************************************
* get_pcr_pid.c: stdout the PID of the PCR of a given program
*****************************************************************************
* Copyright (C) 2009-2010 VideoLAN
* Copyright (C) 2009-2011 VideoLAN
* $Id: pcread.c 15 2006-06-15 22:17:58Z cmassiot $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
......@@ -25,6 +25,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
......@@ -63,11 +64,27 @@
static int i_fd = -1;
static int i_ts_read = 0;
static dvbpsi_handle p_pat_dvbpsi_fd;
static dvbpsi_t *p_pat_dvbpsi_fd;
static int i_nb_programs = 0;
static uint16_t i_program = 0;
static uint16_t pi_pmt_pids[MAX_PROGRAMS];
static dvbpsi_handle p_pmt_dvbpsi_fds[MAX_PROGRAMS];
static dvbpsi_t *p_pmt_dvbpsi_fds[MAX_PROGRAMS];
/*****************************************************************************
* DVBPSI messaging callback
*****************************************************************************/
static void message(dvbpsi_t *handle, const dvbpsi_msg_level_t level, const char* msg)
{
switch(level)
{
case DVBPSI_MSG_ERROR: fprintf(stderr, "Error: "); break;
case DVBPSI_MSG_WARN: fprintf(stderr, "Warning: "); break;
case DVBPSI_MSG_DEBUG: fprintf(stderr, "Debug: "); break;
default: /* do nothing */
return;
}
fprintf(stderr, "%s\n", msg);
}
/*****************************************************************************
* PMTCallback
......@@ -92,6 +109,13 @@ static void PATCallback( void *_unused, dvbpsi_pat_t *p_pat )
{
dvbpsi_pat_program_t *p_program;
if (i_nb_programs >= MAX_PROGRAMS)
{
fprintf(stderr, "Too many PMT programs\n");
dvbpsi_DeletePAT( p_pat );
return;
}
for( p_program = p_pat->p_first_program; p_program != NULL;
p_program = p_program->p_next )
{
......@@ -99,10 +123,13 @@ static void PATCallback( void *_unused, dvbpsi_pat_t *p_pat )
&& (!i_program || i_program == p_program->i_number) )
{
pi_pmt_pids[i_nb_programs] = p_program->i_pid;
p_pmt_dvbpsi_fds[i_nb_programs] =
dvbpsi_AttachPMT( p_program->i_number, PMTCallback,
NULL );
i_nb_programs++;
p_pmt_dvbpsi_fds[i_nb_programs] = dvbpsi_NewHandle(&message, DVBPSI_MSG_DEBUG);
if (p_pmt_dvbpsi_fds[i_nb_programs])
{
if (dvbpsi_AttachPMT(p_pmt_dvbpsi_fds[i_nb_programs],
p_program->i_number, PMTCallback, NULL))
i_nb_programs++;
}
}
}
......@@ -152,6 +179,7 @@ static void TSHandle( uint8_t *p_ts )
int main( int i_argc, char **pp_argv )
{
uint8_t *p_buffer;
int result = EXIT_FAILURE;
if ( i_argc < 2 || i_argc > 3 || !strcmp( pp_argv[1], "-" ) )
{
......@@ -169,12 +197,15 @@ int main( int i_argc, char **pp_argv )
if ( i_argc == 3 )
i_program = strtol( pp_argv[2], NULL, 0 );
p_pat_dvbpsi_fd = dvbpsi_AttachPAT( PATCallback, NULL );
if ( p_pat_dvbpsi_fd == NULL )
p_pat_dvbpsi_fd = dvbpsi_NewHandle(&message, DVBPSI_MSG_DEBUG);
if (p_pat_dvbpsi_fd == NULL)
goto out;
if (!dvbpsi_AttachPAT(p_pat_dvbpsi_fd, PATCallback, NULL ))
goto out;
p_buffer = malloc( TS_SIZE * READ_ONCE );
if ( p_buffer == NULL )
if (p_buffer == NULL)
goto out;
for ( ; ; )
......@@ -201,11 +232,24 @@ int main( int i_argc, char **pp_argv )
}
free( p_buffer );
for( int i = 0; i < MAX_PROGRAMS; i++)
{
if (p_pmt_dvbpsi_fds[i])
{
dvbpsi_DetachPMT(p_pmt_dvbpsi_fds[i]);
dvbpsi_DeleteHandle(p_pmt_dvbpsi_fds[i]);
}
p_pmt_dvbpsi_fds[i] = NULL;
}
result = EXIT_SUCCESS;
out:
if ( p_pat_dvbpsi_fd ) dvbpsi_DetachPAT( p_pat_dvbpsi_fd );
if (p_pat_dvbpsi_fd)
{
dvbpsi_DetachPAT(p_pat_dvbpsi_fd);
dvbpsi_DeleteHandle(p_pat_dvbpsi_fd);
}
close( i_fd );
fprintf( stderr, "no PAT/PMT found\n" );
return EXIT_FAILURE;
return result;
}
......@@ -50,7 +50,7 @@ the %name package installed.
%setup -q -n %{lib_name}-%{version}
%build
%configure2_5x --enable-release
%configure2_5x --enable-release
%make
%install
......
......@@ -14,6 +14,7 @@
#include "config.h"
#include &lt;stdio.h&gt;
#include &lt;stdbool.h&gt;
#if defined(HAVE_INTTYPES_H)
#include &lt;inttypes.h&gt;
......@@ -37,7 +38,7 @@
<xsl:apply-templates mode="code" />
/* main function */
int main()
int main(void)
{
int i_err = 0;
<xsl:apply-templates mode="main" />
......@@ -60,7 +61,7 @@ int main()
<xsl:template match="descriptor" mode="code">
/* <xsl:value-of select="@name" /> */
int main_<xsl:value-of select="@sname" />_<xsl:value-of select="@msuffix" />()
static int main_<xsl:value-of select="@sname" />_<xsl:value-of select="@msuffix" />(void)
{
BOZO_VARS(<xsl:value-of select="@sname" />);
BOZO_START(<xsl:value-of select="@name" />);
......
/*****************************************************************************
* gen_pat.c: PAT generator
*----------------------------------------------------------------------------
* Copyright (C) 2001-2010 VideoLAN
* Copyright (C) 2001-2011 VideoLAN
* $Id: gen_pat.c,v 1.3 2002/10/07 14:15:14 sam Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
......@@ -28,6 +28,7 @@
#include "config.h"
#include <stdio.h>
#include <stdbool.h>
#if defined(HAVE_INTTYPES_H)
#include <inttypes.h>
......@@ -46,7 +47,6 @@
#include <dvbpsi/pat.h>
#endif
/*****************************************************************************
* writePSI
*****************************************************************************/
......@@ -95,6 +95,18 @@ static void writePSI(uint8_t* p_packet, dvbpsi_psi_section_t* p_section)
}
}
static void message(dvbpsi_t *handle, const dvbpsi_msg_level_t level, const char* msg)
{
switch(level)
{
case DVBPSI_MSG_ERROR: fprintf(stderr, "Error: "); break;
case DVBPSI_MSG_WARN: fprintf(stderr, "Warning: "); break;
case DVBPSI_MSG_DEBUG: fprintf(stderr, "Debug: "); break;
default: /* do nothing */
return;
}
fprintf(stderr, "%s\n", msg);
}
/*****************************************************************************
* main
......@@ -108,6 +120,10 @@ int main(int i_argc, char* pa_argv[])
dvbpsi_psi_section_t* p_section5, * p_section6;
int i;
dvbpsi_t *p_dvbpsi = dvbpsi_NewHandle(&message, DVBPSI_MSG_DEBUG);
if (p_dvbpsi == NULL)
return 1;
/* PAT generation */
dvbpsi_InitPAT(&pat, 1, 0, 0);
dvbpsi_PATAddProgram(&pat, 0, 0x12);
......@@ -117,23 +133,23 @@ int main(int i_argc, char* pa_argv[])
for(i = 4; i < 43; i++)
dvbpsi_PATAddProgram(&pat, i, i);
p_section1 = dvbpsi_GenPATSections(&pat, 4);
p_section1 = dvbpsi_GenPATSections(p_dvbpsi, &pat, 4);
pat.b_current_next = 1;
p_section2 = dvbpsi_GenPATSections(&pat, 8);
p_section2 = dvbpsi_GenPATSections(p_dvbpsi, &pat, 8);
pat.i_version = 1;
pat.b_current_next = 0;
p_section3 = dvbpsi_GenPATSections(&pat, 16);
p_section3 = dvbpsi_GenPATSections(p_dvbpsi, &pat, 16);
pat.b_current_next = 1;
p_section4 = dvbpsi_GenPATSections(&pat, 300);
p_section4 = dvbpsi_GenPATSections(p_dvbpsi, &pat, 300);
pat.i_version = 2;
pat.b_current_next = 0;
p_section5 = dvbpsi_GenPATSections(&pat, 16);
p_section5 = dvbpsi_GenPATSections(p_dvbpsi, &pat, 16);
pat.b_current_next = 1;
p_section6 = dvbpsi_GenPATSections(&pat, 16);
p_section6 = dvbpsi_GenPATSections(p_dvbpsi, &pat, 16);
/* TS packets generation */
packet[0] = 0x47;
......@@ -147,7 +163,6 @@ int main(int i_argc, char* pa_argv[])
writePSI(packet, p_section5);
writePSI(packet, p_section6);
dvbpsi_DeletePSISections(p_section1);
dvbpsi_DeletePSISections(p_section2);
dvbpsi_DeletePSISections(p_section3);
......@@ -157,6 +172,7 @@ int main(int i_argc, char* pa_argv[])
dvbpsi_EmptyPAT(&pat);
dvbpsi_DeleteHandle(p_dvbpsi);
return 0;
}
/*****************************************************************************
* gen_pmt.c: PMT generator
*----------------------------------------------------------------------------
* Copyright (C) 2001-2010 VideoLAN
* Copyright (C) 2001-2011 VideoLAN
* $Id$
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
......@@ -28,6 +28,7 @@
#include "config.h"
#include <stdio.h>
#include <stdbool.h>
#if defined(HAVE_INTTYPES_H)
#include <inttypes.h>
......@@ -97,6 +98,18 @@ static void writePSI(uint8_t* p_packet, dvbpsi_psi_section_t* p_section)
}
}
static void message(dvbpsi_t *handle, const dvbpsi_msg_level_t level, const char* msg)
{
switch(level)
{
case DVBPSI_MSG_ERROR: fprintf(stderr, "Error: "); break;
case DVBPSI_MSG_WARN: fprintf(stderr, "Warning: "); break;
case DVBPSI_MSG_DEBUG: fprintf(stderr, "Debug: "); break;
default: /* do nothing */
return;
}
fprintf(stderr, "%s\n", msg);
}
/*****************************************************************************
* main
......@@ -111,6 +124,10 @@ int main(int i_argc, char* pa_argv[])
dvbpsi_psi_section_t* p_section3, * p_section4;
dvbpsi_psi_section_t* p_section5, * p_section6;
dvbpsi_t *p_dvbpsi = dvbpsi_NewHandle(&message, DVBPSI_MSG_DEBUG);
if (p_dvbpsi == NULL)
return 1;
/* PMT generation */
dvbpsi_InitPMT(&pmt, 12, 0, 0, 42);
dvbpsi_PMTAddDescriptor(&pmt, 12, 26, data);
......@@ -123,23 +140,23 @@ int main(int i_argc, char* pa_argv[])
dvbpsi_PMTESAddDescriptor(p_es, 2, 1, data + 4);
dvbpsi_PMTESAddDescriptor(p_es, 0, 4, data + 7);
p_section1 = dvbpsi_GenPMTSections(&pmt);
p_section1 = dvbpsi_GenPMTSections(p_dvbpsi, &pmt);
pmt.b_current_next = 1;
p_section2 = dvbpsi_GenPMTSections(&pmt);
p_section2 = dvbpsi_GenPMTSections(p_dvbpsi, &pmt);
pmt.i_version = 1;
pmt.b_current_next = 0;
p_section3 = dvbpsi_GenPMTSections(&pmt);
p_section3 = dvbpsi_GenPMTSections(p_dvbpsi, &pmt);
pmt.b_current_next = 1;
p_section4 = dvbpsi_GenPMTSections(&pmt);
p_section4 = dvbpsi_GenPMTSections(p_dvbpsi, &pmt);
pmt.i_version = 2;
pmt.b_current_next = 0;
p_section5 = dvbpsi_GenPMTSections(&pmt);
p_section5 = dvbpsi_GenPMTSections(p_dvbpsi, &pmt);
pmt.b_current_next = 1;
p_section6 = dvbpsi_GenPMTSections(&pmt);
p_section6 = dvbpsi_GenPMTSections(p_dvbpsi, &pmt);
/* TS packets generation */
packet[0] = 0x47;
......@@ -163,7 +180,7 @@ int main(int i_argc, char* pa_argv[])
dvbpsi_DeletePSISections(p_section6);
dvbpsi_EmptyPMT(&pmt);
dvbpsi_DeleteHandle(p_dvbpsi);
return 0;
}
......@@ -5,6 +5,7 @@
#include "config.h"
#include <stdio.h>
#include <stdbool.h>
#if defined(HAVE_INTTYPES_H)
#include <inttypes.h>
......@@ -25,14 +26,14 @@
#include "test_dr.h"
/* video stream (b_mpeg2 = false) */
static int main_vstream_1(void)
{
BOZO_VARS(vstream);
BOZO_START(video stream (b_mpeg2 = false));
/* check b_multiple_frame_rate */
BOZO_init_boolean(b_multiple_frame_rate, 0);
BOZO_init_integer(i_frame_rate_code, 0);
......@@ -93,7 +94,7 @@ static int main_vstream_2(void)
BOZO_VARS(vstream);
BOZO_START(video stream (b_mpeg2 = true));
/* check b_multiple_frame_rate */
BOZO_init_boolean(b_multiple_frame_rate, 0);
BOZO_init_integer(i_frame_rate_code, 0);
......@@ -211,7 +212,7 @@ static int main_astream_(void)
BOZO_VARS(astream);
BOZO_START(audio stream);
/* check b_free_format */
BOZO_init_boolean(b_free_format, 0);
BOZO_init_integer(i_id, 0);
......@@ -254,7 +255,7 @@ static int main_hierarchy_(void)
BOZO_VARS(hierarchy);
BOZO_START(hierarchy);
/* check i_h_type */
BOZO_init_integer(i_h_type, 0);
BOZO_init_integer(i_h_layer_index, 0);
......@@ -311,7 +312,7 @@ static int main_registration_(void)
BOZO_VARS(registration);
BOZO_START(registration);
/* check i_format_identifier */
s_decoded.i_additional_length = 0;
BOZO_init_integer(i_format_identifier, 0);
......@@ -333,7 +334,7 @@ static int main_ds_alignment_(void)
BOZO_VARS(ds_alignment);
BOZO_START(data stream alignment);
/* check i_alignment_type */
BOZO_init_integer(i_alignment_type, 0);
BOZO_begin_integer(i_alignment_type, 8)
......@@ -354,7 +355,7 @@ static int main_target_bg_grid_(void)
BOZO_VARS(target_bg_grid);
BOZO_START(target background grid);
/* check i_horizontal_size */
BOZO_init_integer(i_horizontal_size, 0);
BOZO_init_integer(i_vertical_size, 0);
......@@ -397,7 +398,7 @@ static int main_vwindow_(void)
BOZO_VARS(vwindow);
BOZO_START(video window);
/* check i_horizontal_offset */
BOZO_init_integer(i_horizontal_offset, 0);
BOZO_init_integer(i_vertical_offset, 0);
......@@ -440,7 +441,7 @@ static int main_ca_(void)
BOZO_VARS(ca);
BOZO_START(conditional access);
/* check i_ca_system_id */
s_decoded.i_private_length = 0;
BOZO_init_integer(i_ca_system_id, 0);
......@@ -473,7 +474,7 @@ static int main_system_clock_(void)
BOZO_VARS(system_clock);
BOZO_START(system clock);
/* check b_external_clock_ref */
BOZO_init_boolean(b_external_clock_ref, 0);
BOZO_init_integer(i_clock_accuracy_integer, 0);
......@@ -516,7 +517,7 @@ static int main_mx_buff_utilization_(void)
BOZO_VARS(mx_buff_utilization);
BOZO_START(multiplex buffer utilization);
/* check b_mdv_valid */
BOZO_init_boolean(b_mdv_valid, 0);
BOZO_init_integer(i_mx_delay_variation, 0);
......@@ -559,7 +560,7 @@ static int main_copyright_(void)
BOZO_VARS(copyright);
BOZO_START(copyright);
/* check i_copyright_identifier */
s_decoded.i_additional_length = 0;
BOZO_init_integer(i_copyright_identifier, 0);
......@@ -581,7 +582,7 @@ static int main_max_bitrate_(void)
BOZO_VARS(max_bitrate);
BOZO_START(maximum bitrate);
/* check i_max_bitrate */
BOZO_init_integer(i_max_bitrate, 0);
BOZO_begin_integer(i_max_bitrate, 22)
......@@ -602,7 +603,7 @@ static int main_private_data_(void)
BOZO_VARS(private_data);
BOZO_START(private data indicator);
/* check i_private_data */
BOZO_init_integer(i_private_data, 0);
BOZO_begin_integer(i_private_data, 32)
......@@ -623,7 +624,7 @@ static int main_service_(void)
BOZO_VARS(service);
BOZO_START(service);
/* check i_service_type */
s_decoded.i_service_provider_name_length = 0;
s_decoded.i_service_name_length = 0;
......@@ -645,7 +646,7 @@ static int main_service_(void)
int main(void)
{
int i_err = 0;
i_err |= main_vstream_1();
i_err |= main_vstream_2();
i_err |= main_astream_();
......
......@@ -11,7 +11,7 @@ libdvbpsi_la_SOURCES = dvbpsi.c dvbpsi_private.h \
$(tables_src) \
$(descriptors_src)
libdvbpsi_la_LDFLAGS = -version-info 7:0:0 -no-undefined
libdvbpsi_la_LDFLAGS = -version-info 8:0:0 -no-undefined
pkginclude_HEADERS = dvbpsi.h psi.h descriptor.h demux.h \
tables/pat.h tables/pmt.h tables/sdt.h tables/eit.h \
......
......@@ -5,6 +5,7 @@
* $Id$
*
* Authors: Johan Bilien <jobi@via.ecp.fr>
* Jean-Paul Saman <jpsaman@videolan.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -24,11 +25,11 @@
*
*****************************************************************************/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#if defined(HAVE_INTTYPES_H)
#include <inttypes.h>
......@@ -36,6 +37,8 @@
#include <stdint.h>
#endif
#include <assert.h>
#include "dvbpsi.h"
#include "dvbpsi_private.h"
#include "psi.h"
......@@ -46,39 +49,26 @@
*****************************************************************************
* Creation of the demux structure
*****************************************************************************/
dvbpsi_handle dvbpsi_AttachDemux(dvbpsi_demux_new_cb_t pf_new_cb,
void * p_new_cb_data)
bool dvbpsi_AttachDemux(dvbpsi_t * p_dvbpsi,
dvbpsi_demux_new_cb_t pf_new_cb,
void * p_new_cb_data)
{
dvbpsi_handle h_dvbpsi = (dvbpsi_decoder_t*)malloc(sizeof(dvbpsi_decoder_t));
dvbpsi_demux_t * p_demux;
if(h_dvbpsi == NULL)
return NULL;
p_demux = (dvbpsi_demux_t*)malloc(sizeof(dvbpsi_demux_t));
if(p_demux == NULL)
{
free(h_dvbpsi);
return NULL;
}
/* PSI decoder configuration */
h_dvbpsi->pf_callback = &dvbpsi_Demux;
h_dvbpsi->p_private_decoder = p_demux;
h_dvbpsi->i_section_max_size = 4096;
/* PSI decoder initial state */
h_dvbpsi->i_continuity_counter = 31;
h_dvbpsi->b_discontinuity = 1;
h_dvbpsi->p_current_section = NULL;
/* Sutables demux configuration */
p_demux->p_decoder = h_dvbpsi;
p_demux->p_first_subdec = NULL;
p_demux->pf_new_callback = pf_new_cb;
p_demux->p_new_cb_data = p_new_cb_data;
return h_dvbpsi;
assert(p_dvbpsi);
assert(p_dvbpsi->p_private == NULL);
dvbpsi_demux_t *p_demux;
p_demux = (dvbpsi_demux_t*) dvbpsi_NewDecoder(&dvbpsi_Demux, 4096, true,
sizeof(dvbpsi_demux_t));
if (p_demux == NULL)
return false;
/* Subtables demux configuration */
p_demux->p_first_subdec = NULL;
p_demux->pf_new_callback = pf_new_cb;
p_demux->p_new_cb_data = p_new_cb_data;
p_dvbpsi->p_private = (void *)p_demux;
return true;
}
/*****************************************************************************
......@@ -90,18 +80,18 @@ dvbpsi_demux_subdec_t * dvbpsi_demuxGetSubDec(dvbpsi_demux_t * p_demux,
uint8_t i_table_id,
uint16_t i_extension)
{
uint32_t i_id = (uint32_t)i_table_id << 16 |(uint32_t)i_extension;
dvbpsi_demux_subdec_t * p_subdec = p_demux->p_first_subdec;
uint32_t i_id = (uint32_t)i_table_id << 16 |(uint32_t)i_extension;
dvbpsi_demux_subdec_t * p_subdec = p_demux->p_first_subdec;
while(p_subdec)
{
if(p_subdec->i_id == i_id)
break;
while (p_subdec)
{
if (p_subdec->i_id == i_id)
break;
p_subdec = p_subdec->p_next;
}
p_subdec = p_subdec->p_next;
}
return p_subdec;
return p_subdec;
}
/*****************************************************************************
......@@ -109,37 +99,35 @@ dvbpsi_demux_subdec_t * dvbpsi_demuxGetSubDec(dvbpsi_demux_t * p_demux,
*****************************************************************************
* Sends a PSI section to the right subtable decoder
*****************************************************************************/
void dvbpsi_Demux(dvbpsi_handle p_decoder, dvbpsi_psi_section_t * p_section)
void dvbpsi_Demux(dvbpsi_t *p_dvbpsi, dvbpsi_psi_section_t *p_section)
{
dvbpsi_demux_t * p_demux;
dvbpsi_demux_subdec_t * p_subdec;
p_demux = (dvbpsi_demux_t *)p_decoder->p_private_decoder;
p_subdec = dvbpsi_demuxGetSubDec(p_demux, p_section->i_table_id,
p_section->i_extension);
if(p_subdec == NULL)
{
/* Tell the application we found a new subtable, so that it may attach a
* subtable decoder */
p_demux->pf_new_callback(p_demux->p_new_cb_data, p_decoder,
p_section->i_table_id,
p_section->i_extension);
/* Check if a new subtable decoder is available */
p_subdec = dvbpsi_demuxGetSubDec(p_demux, p_section->i_table_id,
p_section->i_extension);
}
if(p_subdec)
{
p_subdec->pf_callback(p_demux->p_decoder, p_subdec->p_cb_data, p_section);
}
else
{
dvbpsi_DeletePSISections(p_section);
}
assert(p_dvbpsi);
assert(p_dvbpsi->p_private);
dvbpsi_demux_t * p_demux = (dvbpsi_demux_t *)p_dvbpsi->p_private;
dvbpsi_demux_subdec_t * p_subdec = dvbpsi_demuxGetSubDec(p_demux, p_section->i_table_id,
p_section->i_extension);
if (p_subdec == NULL)
{
/* Tell the application we found a new subtable, so that it may attach a
* subtable decoder */
p_demux->pf_new_callback(p_demux->p_new_cb_data, p_dvbpsi,
p_section->i_table_id, p_section->i_extension);
/* Check if a new subtable decoder is available */
p_subdec = dvbpsi_demuxGetSubDec(p_demux, p_section->i_table_id,
p_section->i_extension);
}
if (p_subdec)
{
p_subdec->pf_callback(p_dvbpsi, p_subdec->p_cb_data, p_section);
}
else
{
dvbpsi_DeletePSISections(p_section);
}
}
/*****************************************************************************
......@@ -147,26 +135,25 @@ void dvbpsi_Demux(dvbpsi_handle p_decoder, dvbpsi_psi_section_t * p_section)
*****************************************************************************
* Destroys a demux structure
*****************************************************************************/
void dvbpsi_DetachDemux(dvbpsi_handle h_dvbpsi)
void dvbpsi_DetachDemux(dvbpsi_t *p_dvbpsi)
{
dvbpsi_demux_t* p_demux
= (dvbpsi_demux_t*)h_dvbpsi->p_private_decoder;
dvbpsi_demux_subdec_t* p_subdec
= p_demux->p_first_subdec;
dvbpsi_demux_subdec_t* p_subdec_temp;
while(p_subdec)
{
p_subdec_temp = p_subdec;
p_subdec = p_subdec->p_next;
if(p_subdec_temp->pf_detach)
p_subdec_temp->pf_detach(p_demux, (p_subdec_temp->i_id >> 16) & 0xFFFF,
p_subdec_temp->i_id & 0xFFFF);
else free(p_subdec_temp);
}
free(p_demux);
if(h_dvbpsi->p_current_section)
dvbpsi_DeletePSISections(h_dvbpsi->p_current_section);
free(h_dvbpsi);
assert(p_dvbpsi);
assert(p_dvbpsi->p_private);
dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *)p_dvbpsi->p_private;
dvbpsi_demux_subdec_t* p_subdec = p_demux->p_first_subdec;
while (p_subdec)
{
dvbpsi_demux_subdec_t* p_subdec_temp = p_subdec;
p_subdec = p_subdec->p_next;
if (p_subdec_temp->pf_detach)
p_subdec_temp->pf_detach(p_dvbpsi, (p_subdec_temp->i_id >> 16) & 0xFFFF,
p_subdec_temp->i_id & 0xFFFF);
else free(p_subdec_temp);
}
dvbpsi_DeleteDecoder((dvbpsi_decoder_t *)p_dvbpsi->p_private);
p_dvbpsi->p_private = NULL;
}
......@@ -5,6 +5,7 @@
* $Id$
*
* Authors: Johan Bilien <jobi@via.ecp.fr>
* Jean-Paul Saman <jpsaman@videolan.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -37,19 +38,18 @@
extern "C" {
#endif
/*****************************************************************************
* dvbpsi_demux_new_cb_t
*****************************************************************************/
/*!
* \typedef void(* dvbpsi_demux_new_cb_t) (void * p_cb_data,
dvbpsi_handle h_dvbpsi,
dvbpsi_t *p_dvbpsi,
uint8_t i_table_id,
uint16_t i_extension);
* \brief Callback used in case of a new subtable detected.
*/
typedef void (*dvbpsi_demux_new_cb_t) (void * p_cb_data,
dvbpsi_handle h_dvbpsi,
dvbpsi_t *p_dvbpsi,
uint8_t i_table_id,
uint16_t i_extension);
......@@ -58,15 +58,15 @@ typedef void (*dvbpsi_demux_new_cb_t) (void * p_cb_data,
*****************************************************************************/
/*!
* \typedef void (*dvbpsi_demux_subdec_cb_t)
(dvbpsi_decoder_t* p_psi_decoder,
void* p_private_decoder,
dvbpsi_psi_section_t* p_section);
(dvbpsi_t *p_dvbpsi,
void *p_private_decoder,
dvbpsi_psi_section_t *p_section);
* \brief Subtable specific decoder.
*/
typedef void (*dvbpsi_demux_subdec_cb_t)
(dvbpsi_decoder_t* p_psi_decoder,
void* p_private_decoder,
dvbpsi_psi_section_t* p_section);
(dvbpsi_t *p_dvbpsi,
void *p_private_decoder,
dvbpsi_psi_section_t *p_section);
/*****************************************************************************
* dvbpsi_demux_subdec_t
......@@ -85,17 +85,17 @@ typedef void (*dvbpsi_demux_subdec_cb_t)
struct dvbpsi_demux_s;
typedef struct dvbpsi_demux_subdec_s
{
uint32_t i_id;
dvbpsi_demux_subdec_cb_t pf_callback;
void * p_cb_data;
struct dvbpsi_demux_subdec_s * p_next;
uint32_t i_id; /*!< subtable id */
dvbpsi_demux_subdec_cb_t pf_callback; /*!< subdec callback */
void * p_cb_data; /*!< subdec callback data */
struct dvbpsi_demux_subdec_s * p_next; /*!< next subdec */
void (*pf_detach)(struct dvbpsi_demux_s *, uint8_t, uint16_t);
void (*pf_detach)(dvbpsi_t *, uint8_t, uint16_t); /*!< detach subdec callback */
} dvbpsi_demux_subdec_t;
/*****************************************************************************
* dvbpsi_demux_t
* dvbpsi_demux_s
*****************************************************************************/
/*!
* \struct dvbpsi_demux_s
......@@ -108,42 +108,45 @@ typedef struct dvbpsi_demux_subdec_s
* \typedef struct dvbpsi_demux_s dvbpsi_demux_t
* \brief dvbpsi_demux_t type definition.
*/
typedef struct dvbpsi_demux_s
typedef struct dvbpsi_demux_s dvbpsi_demux_t;
struct dvbpsi_demux_s
{
dvbpsi_handle p_decoder; /*!< Parent PSI Decoder */
dvbpsi_demux_subdec_t * p_first_subdec; /*!< First subtable decoder */
/* New subtable callback */
dvbpsi_demux_new_cb_t pf_new_callback; /*!< New subtable callback */
void * p_new_cb_data; /*!< Data provided to the
previous callback */
DVBPSI_DECODER_COMMON
} dvbpsi_demux_t;
dvbpsi_demux_subdec_t * p_first_subdec; /*!< First subtable decoder */
/* New subtable callback */
dvbpsi_demux_new_cb_t pf_new_callback; /*!< New subtable callback */
void * p_new_cb_data; /*!< Data provided to the
previous callback */
};
/*****************************************************************************
* dvbpsi_AttachDemux
*****************************************************************************/
/*!
* \fn dvbpsi_handle_t dvbpsi_NewPSISection(dvbpsi_demux_new_cb_t pf_new_cb, void * p_new_cb_data)
* \brief Creates a new demux structure.
* \fn bool dvbpsi_AttachDemux(dvbpsi_t *p_dvbpsi, dvbpsi_demux_new_cb_t pf_new_cb, void * p_new_cb_data)
* \brief Attaches a new demux structure on dvbpsi_t* handle.
* \param p_dvbpsi pointer to dvbpsi_t handle
* \param pf_new_cb A callcack called when a new type of subtable is found.
* \param p_new_cb_data Data given to the previous callback.
* \return a handle to the new demux structure.
* \return true on success, false on failure
*/
__attribute__((deprecated))
dvbpsi_handle dvbpsi_AttachDemux(dvbpsi_demux_new_cb_t pf_new_cb,
void * p_new_cb_data);
bool dvbpsi_AttachDemux(dvbpsi_t * p_dvbpsi,
dvbpsi_demux_new_cb_t pf_new_cb,
void * p_new_cb_data);
/*****************************************************************************
* dvbpsi_DetachDemux
*****************************************************************************/
/*!
* \fn void dvbpsi_DetachDemux(dvbpsi_handle h_dvbpsi)
* \fn void dvbpsi_DetachDemux(dvbpsi_t *p_dvbpsi)
* \brief Destroys a demux structure.
* \param h_dvbpsi The handle of the demux to be destroyed.
* \param p_dvbpsi The handle of the demux to be destroyed.
* \return nothing
*/
__attribute__((deprecated))
void dvbpsi_DetachDemux(dvbpsi_handle h_dvbpsi);
void dvbpsi_DetachDemux(dvbpsi_t *p_dvbpsi);
/*****************************************************************************
* dvbpsi_demuxGetSubDec
......@@ -165,15 +168,13 @@ dvbpsi_demux_subdec_t * dvbpsi_demuxGetSubDec(dvbpsi_demux_t * p_demux,
* dvbpsi_Demux
*****************************************************************************/
/*!
* \fn void dvbpsi_Demux(dvbpsi_handle h_dvbpsi,
* \fn void dvbpsi_Demux(dvbpsi_t *p_dvbpsi,
dvbpsi_psi_section_t * p_section)
* \brief Sends the PSI sections to the right subtable decoder according to their table ID and extension.
* \param h_dvbpsi PSI decoder handle.
* \param p_dvbpsi PSI decoder handle.
* \param p_section PSI section.
*/
__attribute__((deprecated))
void dvbpsi_Demux(dvbpsi_handle h_dvbpsi,
dvbpsi_psi_section_t * p_section);
void dvbpsi_Demux(dvbpsi_t *p_dvbpsi, dvbpsi_psi_section_t *p_section);
#ifdef __cplusplus
};
......
/*****************************************************************************
* descriptor.c: descriptors functions
*----------------------------------------------------------------------------
* Copyright (C) 2001-2010 VideoLAN
* Copyright (C) 2001-2011 VideoLAN
* $Id: descriptor.c,v 1.6 2002/10/07 14:15:14 sam Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
......@@ -24,10 +24,10 @@
*
*****************************************************************************/
#include "config.h"
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#if defined(HAVE_INTTYPES_H)
......@@ -48,33 +48,31 @@
dvbpsi_descriptor_t* dvbpsi_NewDescriptor(uint8_t i_tag, uint8_t i_length,
uint8_t* p_data)
{
dvbpsi_descriptor_t* p_descriptor
dvbpsi_descriptor_t* p_descriptor
= (dvbpsi_descriptor_t*)malloc(sizeof(dvbpsi_descriptor_t));
if(p_descriptor)
{
p_descriptor->p_data = (uint8_t*)malloc(i_length * sizeof(uint8_t));
if (p_descriptor == NULL)
return NULL;
if(p_descriptor->p_data)
p_descriptor->p_data = (uint8_t*)malloc(i_length * sizeof(uint8_t));
if (p_descriptor->p_data)
{
p_descriptor->i_tag = i_tag;
p_descriptor->i_length = i_length;
if(p_data)
memcpy(p_descriptor->p_data, p_data, i_length);
p_descriptor->p_decoded = NULL;
p_descriptor->p_next = NULL;
p_descriptor->i_tag = i_tag;
p_descriptor->i_length = i_length;
if (p_data)
memcpy(p_descriptor->p_data, p_data, i_length);
p_descriptor->p_decoded = NULL;
p_descriptor->p_next = NULL;
}
else
{
free(p_descriptor);
p_descriptor = NULL;
free(p_descriptor);
p_descriptor = NULL;
}
}
return p_descriptor;
return p_descriptor;
}
/*****************************************************************************
* dvbpsi_DeleteDescriptors
*****************************************************************************
......@@ -82,18 +80,17 @@ dvbpsi_descriptor_t* dvbpsi_NewDescriptor(uint8_t i_tag, uint8_t i_length,
*****************************************************************************/
void dvbpsi_DeleteDescriptors(dvbpsi_descriptor_t* p_descriptor)
{
while(p_descriptor != NULL)
{
dvbpsi_descriptor_t* p_next = p_descriptor->p_next;
while(p_descriptor != NULL)
{
dvbpsi_descriptor_t* p_next = p_descriptor->p_next;
if(p_descriptor->p_data != NULL)
free(p_descriptor->p_data);
if (p_descriptor->p_data != NULL)
free(p_descriptor->p_data);
if(p_descriptor->p_decoded != NULL)
free(p_descriptor->p_decoded);
if (p_descriptor->p_decoded != NULL)
free(p_descriptor->p_decoded);
free(p_descriptor);
p_descriptor = p_next;
}
free(p_descriptor);
p_descriptor = p_next;
}
}
......@@ -27,6 +27,9 @@
* \brief Common descriptor tools.
*
* Descriptor structure and its Manipulation tools.
*
* NOTE: Descriptor generators and decoder functions return a pointer on success
* and NULL on error. They do not use a dvbpsi_t handle as first argument.
*/
#ifndef _DVBPSI_DESCRIPTOR_H_
......
/*****************************************************************************
* dr_02.c
* Copyright (C) 2001-2010 VideoLAN
* Copyright (C) 2001-2011 VideoLAN
* $Id: dr_02.c,v 1.7 2003/07/25 20:20:40 fenrir Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
......@@ -21,11 +21,11 @@
*
*****************************************************************************/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#if defined(HAVE_INTTYPES_H)
......@@ -40,7 +40,6 @@
#include "dr_02.h"
/*****************************************************************************
* dvbpsi_DecodeVStreamDr
*****************************************************************************/
......@@ -50,10 +49,7 @@ dvbpsi_vstream_dr_t * dvbpsi_DecodeVStreamDr(dvbpsi_descriptor_t * p_descriptor)
/* Check the tag */
if(p_descriptor->i_tag != 0x02)
{
DVBPSI_ERROR_ARG("dr_02 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
/* Don't decode twice */
if(p_descriptor->p_decoded)
......@@ -61,36 +57,28 @@ dvbpsi_vstream_dr_t * dvbpsi_DecodeVStreamDr(dvbpsi_descriptor_t * p_descriptor)
/* Allocate memory */
p_decoded = (dvbpsi_vstream_dr_t*)malloc(sizeof(dvbpsi_vstream_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_02 decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
/* Decode data and check the length */
p_decoded->b_mpeg2 = (p_descriptor->p_data[0] & 0x04) ? 1 : 0;
p_decoded->b_mpeg2 = (p_descriptor->p_data[0] & 0x04) ? true : false;
if( (!p_decoded->b_mpeg2 && (p_descriptor->i_length != 1))
|| (p_decoded->b_mpeg2 && (p_descriptor->i_length != 3)))
{
DVBPSI_ERROR_ARG("dr_02 decoder", "bad length (%d)",
p_descriptor->i_length);
free(p_decoded);
return NULL;
}
p_decoded->b_multiple_frame_rate = (p_descriptor->p_data[0] & 0x80) ? 1 : 0;
p_decoded->b_multiple_frame_rate = (p_descriptor->p_data[0] & 0x80) ? true : false;
p_decoded->i_frame_rate_code = (p_descriptor->p_data[0] & 0x78) >> 3;
p_decoded->b_constrained_parameter = (p_descriptor->p_data[0] & 0x02) ? 1 : 0;
p_decoded->b_still_picture = (p_descriptor->p_data[0] & 0x01) ? 1 : 0;
p_decoded->b_constrained_parameter = (p_descriptor->p_data[0] & 0x02) ? true : false;
p_decoded->b_still_picture = (p_descriptor->p_data[0] & 0x01) ? true : false;
if(p_decoded->b_mpeg2)
{
p_decoded->i_profile_level_indication = p_descriptor->p_data[1];
p_decoded->i_chroma_format = (p_descriptor->p_data[2] & 0xc0) >> 6;
p_decoded->b_frame_rate_extension =
(p_descriptor->p_data[2] & 0x20) ? 1 : 0;
(p_descriptor->p_data[2] & 0x20) ? true : false;
}
p_descriptor->p_decoded = (void*)p_decoded;
......@@ -103,7 +91,7 @@ dvbpsi_vstream_dr_t * dvbpsi_DecodeVStreamDr(dvbpsi_descriptor_t * p_descriptor)
* dvbpsi_GenVStreamDr
*****************************************************************************/
dvbpsi_descriptor_t * dvbpsi_GenVStreamDr(dvbpsi_vstream_dr_t * p_decoded,
int b_duplicate)
bool b_duplicate)
{
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor =
......@@ -145,4 +133,3 @@ dvbpsi_descriptor_t * dvbpsi_GenVStreamDr(dvbpsi_vstream_dr_t * p_decoded,
return p_descriptor;
}
......@@ -56,16 +56,16 @@ extern "C" {
*/
typedef struct dvbpsi_vstream_dr_s
{
int b_multiple_frame_rate; /*!< multiple_frame_rate_flag */
bool b_multiple_frame_rate; /*!< multiple_frame_rate_flag */
uint8_t i_frame_rate_code; /*!< frame_rate_code */
int b_mpeg2; /*!< MPEG_2_flag */
int b_constrained_parameter; /*!< constrained_parameter_flag */
int b_still_picture; /*!< still_picture_flag */
bool b_mpeg2; /*!< MPEG_2_flag */
bool b_constrained_parameter; /*!< constrained_parameter_flag */
bool b_still_picture; /*!< still_picture_flag */
/* used if b_mpeg2 is true */
uint8_t i_profile_level_indication; /*!< profile_and_level_indication */
uint8_t i_chroma_format; /*!< chroma_format */
int b_frame_rate_extension; /*!< frame_rate_extension_flag */
bool b_frame_rate_extension; /*!< frame_rate_extension_flag */
} dvbpsi_vstream_dr_t;
......@@ -89,15 +89,15 @@ dvbpsi_vstream_dr_t* dvbpsi_DecodeVStreamDr(dvbpsi_descriptor_t * p_descriptor);
*****************************************************************************/
/*!
* \fn dvbpsi_descriptor_t * dvbpsi_GenVStreamDr(
dvbpsi_vstream_dr_t * p_decoded, int b_duplicate)
dvbpsi_vstream_dr_t * p_decoded, bool b_duplicate)
* \brief "video stream" descriptor generator.
* \param p_decoded pointer to a decoded "video stream" descriptor structure
* \param b_duplicate if non zero then duplicate the p_decoded structure into
* \param b_duplicate if true then duplicate the p_decoded structure into
* the descriptor
* \return a pointer to a new descriptor structure which contains encoded data.
*/
dvbpsi_descriptor_t * dvbpsi_GenVStreamDr(dvbpsi_vstream_dr_t * p_decoded,
int b_duplicate);
bool b_duplicate);
#ifdef __cplusplus
......
/*****************************************************************************
* dr_03.c
* Copyright (C) 2001-2010 VideoLAN
* Copyright (C) 2001-2011 VideoLAN
* $Id: dr_03.c,v 1.4 2003/07/25 20:20:40 fenrir Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
......@@ -21,11 +21,11 @@
*
*****************************************************************************/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#if defined(HAVE_INTTYPES_H)
......@@ -50,10 +50,7 @@ dvbpsi_astream_dr_t * dvbpsi_DecodeAStreamDr(dvbpsi_descriptor_t * p_descriptor)
/* Check the tag */
if(p_descriptor->i_tag != 0x03)
{
DVBPSI_ERROR_ARG("dr_03 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
/* Don't decode twice */
if(p_descriptor->p_decoded)
......@@ -61,17 +58,11 @@ dvbpsi_astream_dr_t * dvbpsi_DecodeAStreamDr(dvbpsi_descriptor_t * p_descriptor)
/* Allocate memory */
p_decoded = (dvbpsi_astream_dr_t*)malloc(sizeof(dvbpsi_astream_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_03 decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
/* Decode data and check the length */
if(p_descriptor->i_length != 1)
{
DVBPSI_ERROR_ARG("dr_03 decoder", "bad length (%d)",
p_descriptor->i_length);
free(p_decoded);
return NULL;
}
......@@ -90,7 +81,7 @@ dvbpsi_astream_dr_t * dvbpsi_DecodeAStreamDr(dvbpsi_descriptor_t * p_descriptor)
* dvbpsi_GenAStreamDr
*****************************************************************************/
dvbpsi_descriptor_t * dvbpsi_GenAStreamDr(dvbpsi_astream_dr_t * p_decoded,
int b_duplicate)
bool b_duplicate)
{
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x03, 1, NULL);
......
......@@ -56,7 +56,7 @@ extern "C" {
*/
typedef struct dvbpsi_astream_dr_s
{
int b_free_format; /*!< free_format_flag */
bool b_free_format; /*!< free_format_flag */
uint8_t i_id; /*!< ID */
uint8_t i_layer; /*!< layer */
......@@ -82,15 +82,15 @@ dvbpsi_astream_dr_t* dvbpsi_DecodeAStreamDr(dvbpsi_descriptor_t * p_descriptor);
*****************************************************************************/
/*!
* \fn dvbpsi_descriptor_t * dvbpsi_GenAStreamDr(
dvbpsi_astream_dr_t * p_decoded, int b_duplicate)
dvbpsi_astream_dr_t * p_decoded, bool b_duplicate)
* \brief "audio stream" descriptor generator.
* \param p_decoded pointer to a decoded "video stream" descriptor structure
* \param b_duplicate if non zero then duplicate the p_decoded structure into
* \param b_duplicate if true then duplicate the p_decoded structure into
* the descriptor
* \return a pointer to a new descriptor structure which contains encoded data.
*/
dvbpsi_descriptor_t * dvbpsi_GenAStreamDr(dvbpsi_astream_dr_t * p_decoded,
int b_duplicate);
bool b_duplicate);
#ifdef __cplusplus
......
/*****************************************************************************
* dr_04.c
* Copyright (C) 2001-2010 VideoLAN
* Copyright (C) 2001-2011 VideoLAN
* $Id: dr_04.c,v 1.3 2003/07/25 20:20:40 fenrir Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
......@@ -21,11 +21,11 @@
*
*****************************************************************************/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#if defined(HAVE_INTTYPES_H)
......@@ -51,10 +51,7 @@ dvbpsi_hierarchy_dr_t * dvbpsi_DecodeHierarchyDr(
/* Check the tag */
if(p_descriptor->i_tag != 0x04)
{
DVBPSI_ERROR_ARG("dr_04 decoder", "bad tag (0x%x)", p_descriptor->i_tag);
return NULL;
}
/* Don't decode twice */
if(p_descriptor->p_decoded)
......@@ -62,17 +59,11 @@ dvbpsi_hierarchy_dr_t * dvbpsi_DecodeHierarchyDr(
/* Allocate memory */
p_decoded = (dvbpsi_hierarchy_dr_t*)malloc(sizeof(dvbpsi_hierarchy_dr_t));
if(!p_decoded)
{
DVBPSI_ERROR("dr_04 decoder", "out of memory");
return NULL;
}
if(!p_decoded) return NULL;
/* Decode data and check the length */
if(p_descriptor->i_length != 4)
{
DVBPSI_ERROR_ARG("dr_04 decoder", "bad length (%d)",
p_descriptor->i_length);
free(p_decoded);
return NULL;
}
......@@ -92,7 +83,7 @@ dvbpsi_hierarchy_dr_t * dvbpsi_DecodeHierarchyDr(
* dvbpsi_GenHierarchyDr
*****************************************************************************/
dvbpsi_descriptor_t * dvbpsi_GenHierarchyDr(dvbpsi_hierarchy_dr_t * p_decoded,
int b_duplicate)
bool b_duplicate)
{
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor = dvbpsi_NewDescriptor(0x04, 4, NULL);
......
......@@ -84,15 +84,15 @@ dvbpsi_hierarchy_dr_t* dvbpsi_DecodeHierarchyDr(
*****************************************************************************/
/*!
* \fn dvbpsi_descriptor_t * dvbpsi_GenHierarchyDr(
dvbpsi_hierarchy_dr_t * p_decoded, int b_duplicate)
dvbpsi_hierarchy_dr_t * p_decoded, bool b_duplicate)
* \brief "hierarchy" descriptor generator.
* \param p_decoded pointer to a decoded "hierarchy" descriptor structure
* \param b_duplicate if non zero then duplicate the p_decoded structure into
* \param b_duplicate if true then duplicate the p_decoded structure into
* the descriptor
* \return a pointer to a new descriptor structure which contains encoded data.
*/
dvbpsi_descriptor_t * dvbpsi_GenHierarchyDr(dvbpsi_hierarchy_dr_t * p_decoded,
int b_duplicate);
bool b_duplicate);
#ifdef __cplusplus
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment