Commit ad619b43 authored by Sam Hocevar's avatar Sam Hocevar

* Build decode_mpeg on Win32, just don’t build the network part.

parent c44a14d8
...@@ -23,11 +23,7 @@ case x"${target_os}" in ...@@ -23,11 +23,7 @@ case x"${target_os}" in
xdarwin*) xdarwin*)
CFLAGS="${CFLAGS} -no-cpp-precomp" CFLAGS="${CFLAGS} -no-cpp-precomp"
;; ;;
*mingw32* | *cygwin* | *wince* | *mingwce* | *pe*)
HAVE_WIN32=yes
;;
esac esac
AM_CONDITIONAL(HAVE_WIN32, test "${HAVE_WIN32}" = "yes")
dnl --enable-debug dnl --enable-debug
AC_ARG_ENABLE(debug, AC_ARG_ENABLE(debug,
...@@ -37,7 +33,7 @@ AC_ARG_ENABLE(debug, ...@@ -37,7 +33,7 @@ AC_ARG_ENABLE(debug,
no) debug=false ;; no) debug=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;; *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;;
esac],[debug=false]) esac],[debug=false])
if test x$debug = xtrue if test "$debug" = "true"
then then
CFLAGS="${CFLAGS} -DDEBUG -g" CFLAGS="${CFLAGS} -DDEBUG -g"
fi fi
...@@ -51,7 +47,7 @@ AC_ARG_ENABLE(release, ...@@ -51,7 +47,7 @@ AC_ARG_ENABLE(release,
no) release=false ;; no) release=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-release) ;; *) AC_MSG_ERROR(bad value ${enableval} for --enable-release) ;;
esac],[release=false]) esac],[release=false])
if test x$release = xtrue if test "$release" = "true"
then then
CFLAGS="${CFLAGS} -O6" CFLAGS="${CFLAGS} -O6"
else else
...@@ -61,6 +57,9 @@ fi ...@@ -61,6 +57,9 @@ fi
dnl Check for headers dnl Check for headers
AC_CHECK_HEADERS(stdint.h inttypes.h) AC_CHECK_HEADERS(stdint.h inttypes.h)
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")
dnl Check for variadic macros dnl Check for variadic macros
AC_CACHE_CHECK([for variadic cpp macros], AC_CACHE_CHECK([for variadic cpp macros],
[ac_cv_cpp_variadic_macros], [ac_cv_cpp_variadic_macros],
...@@ -74,7 +73,13 @@ if test "${ac_cv_cpp_variadic_macros}" != "no"; then ...@@ -74,7 +73,13 @@ if test "${ac_cv_cpp_variadic_macros}" != "no"; then
AC_DEFINE(HAVE_VARIADIC_MACROS, 1, Support for variadic macros) AC_DEFINE(HAVE_VARIADIC_MACROS, 1, Support for variadic macros)
fi fi
AC_OUTPUT([Makefile src/Makefile examples/Makefile misc/Makefile doc/Makefile debian/Makefile wince/Makefile]) AC_OUTPUT([Makefile
src/Makefile
examples/Makefile
misc/Makefile
doc/Makefile
debian/Makefile
wince/Makefile])
echo " echo "
libdvbpsi configuration libdvbpsi configuration
......
## Process this file with automake to produce Makefile.in ## Process this file with automake to produce Makefile.in
noinst_PROGRAMS = decode_pat decode_pmt decode_sdt noinst_PROGRAMS = decode_pat decode_pmt decode_sdt decode_mpeg
if !HAVE_WIN32
noinst_PROGRAMS += decode_mpeg
endif
decode_pat_SOURCES = decode_pat.c decode_pat_SOURCES = decode_pat.c
decode_pat_LDFLAGS = -L../src -ldvbpsi decode_pat_LDFLAGS = -L../src -ldvbpsi
...@@ -14,6 +11,9 @@ decode_pmt_LDFLAGS = -L../src -ldvbpsi -lm ...@@ -14,6 +11,9 @@ decode_pmt_LDFLAGS = -L../src -ldvbpsi -lm
decode_sdt_SOURCES = decode_sdt.c decode_sdt_SOURCES = decode_sdt.c
decode_sdt_LDFLAGS = -L../src -ldvbpsi decode_sdt_LDFLAGS = -L../src -ldvbpsi
decode_mpeg_SOURCES = connect.c decode_mpeg.c decode_mpeg_SOURCES = decode_mpeg.c
if HAVE_SYS_SOCKET_H
decode_mpeg_SOURCES += connect.c
endif
decode_mpeg_LDFLAGS = -L../src -ldvbpsi -lm decode_mpeg_LDFLAGS = -L../src -ldvbpsi -lm
...@@ -161,6 +161,7 @@ int ReadPacket( int i_fd, uint8_t* p_dst ) ...@@ -161,6 +161,7 @@ int ReadPacket( int i_fd, uint8_t* p_dst )
return (i == 0) ? 1 : 0; return (i == 0) ? 1 : 0;
} }
#ifdef HAVE_SYS_SOCKET_H
int ReadPacketFromSocket( int i_socket, uint8_t* p_dst, size_t i_size) int ReadPacketFromSocket( int i_socket, uint8_t* p_dst, size_t i_size)
{ {
int i_rc = -1; int i_rc = -1;
...@@ -169,6 +170,7 @@ int ReadPacketFromSocket( int i_socket, uint8_t* p_dst, size_t i_size) ...@@ -169,6 +170,7 @@ int ReadPacketFromSocket( int i_socket, uint8_t* p_dst, size_t i_size)
i_rc = read( i_socket, p_dst, i_size ); i_rc = read( i_socket, p_dst, i_size );
return (i_rc <= i_size ) ? 1 : 0; return (i_rc <= i_size ) ? 1 : 0;
} }
#endif
/***************************************************************************** /*****************************************************************************
* DumpPAT * DumpPAT
...@@ -363,17 +365,26 @@ void DumpPMT(void* p_data, dvbpsi_pmt_t* p_pmt) ...@@ -363,17 +365,26 @@ void DumpPMT(void* p_data, dvbpsi_pmt_t* p_pmt)
*****************************************************************************/ *****************************************************************************/
void usage( char *name ) void usage( char *name )
{ {
#ifdef HAVE_SYS_SOCKET_H
printf( "Usage: %s [--file <filename>|--udp <ipaddress> --port <port> -mtu <mtu>|--help]\n", name ); printf( "Usage: %s [--file <filename>|--udp <ipaddress> --port <port> -mtu <mtu>|--help]\n", name );
printf( " %s [-f <filename>|-u <ipaddress> -p <port> -m <mtu>|-h]\n", name ); printf( " %s [-f <filename>|-u <ipaddress> -p <port> -m <mtu>|-h]\n", name );
#else
printf( "Usage: %s [--file <filename>|--help]\n", name );
printf( " %s [-f <filename>|-h]\n", name );
#endif
printf( "\n" ); printf( "\n" );
printf( " %s --help\n", name ); printf( " %s --help\n", name );
printf( " %s --file <filename>\n", name ); printf( " %s --file <filename>\n", name );
#ifdef HAVE_SYS_SOCKET_H
printf( " %s --udp <ipaddres> --port <port> --mtu <mtu>\n", name ); printf( " %s --udp <ipaddres> --port <port> --mtu <mtu>\n", name );
#endif
printf( "Arguments:\n" ); printf( "Arguments:\n" );
printf( "file : read MPEG2-TS stream from file\n" ); printf( "file : read MPEG2-TS stream from file\n" );
#ifdef HAVE_SYS_SOCKET_H
printf( "udp : read MPEG2-TS stream from network using UDP protocol\n" ); printf( "udp : read MPEG2-TS stream from network using UDP protocol\n" );
printf( "port : read MPEG2-TS stream from this port number\n" ); printf( "port : read MPEG2-TS stream from this port number\n" );
printf( "mtu : read MPEG2-TS stream from network using maximum transfer unit (mtu) = 1316\n" ); printf( "mtu : read MPEG2-TS stream from network using maximum transfer unit (mtu) = 1316\n" );
#endif
printf( "help : print this help message\n" ); printf( "help : print this help message\n" );
} }
...@@ -382,27 +393,35 @@ void usage( char *name ) ...@@ -382,27 +393,35 @@ void usage( char *name )
*****************************************************************************/ *****************************************************************************/
int main(int i_argc, char* pa_argv[]) int main(int i_argc, char* pa_argv[])
{ {
#ifdef HAVE_SYS_SOCKET_H
const char* const short_options = "hf:m:p:u:"; const char* const short_options = "hf:m:p:u:";
#else
const char* const short_options = "hf:";
#endif
const struct option long_options[] = const struct option long_options[] =
{ {
{ "help", 0, NULL, 'h' }, { "help", 0, NULL, 'h' },
{ "file", 0, NULL, 'f' }, { "file", 0, NULL, 'f' },
#ifdef HAVE_SYS_SOCKET_H
{ "mtu", 0, NULL, 'm' }, { "mtu", 0, NULL, 'm' },
{ "port", 0, NULL, 'p' }, { "port", 0, NULL, 'p' },
{ "udp", 0, NULL, 'u' }, { "udp", 0, NULL, 'u' },
#endif
{ NULL, 0, NULL, 0 } { NULL, 0, NULL, 0 }
}; };
int next_option = 0; int next_option = 0;
int i_fd = -1; int i_fd = -1;
int i_port = 0;
int i_mtu = 1316; /* (7 * 188) = 1316 < 1500 network MTU */ int i_mtu = 1316; /* (7 * 188) = 1316 < 1500 network MTU */
#ifdef HAVE_SYS_SOCKET_H
int i_port = 0;
char *ipaddress = NULL; char *ipaddress = NULL;
#endif
char *filename = NULL; char *filename = NULL;
uint8_t *p_data = NULL; uint8_t *p_data = NULL;
ts_stream_t *p_stream = NULL; ts_stream_t *p_stream = NULL;
int b_ok; int b_ok = 0;
/* parser commandline arguments */ /* parser commandline arguments */
do { do {
...@@ -416,6 +435,7 @@ int main(int i_argc, char* pa_argv[]) ...@@ -416,6 +435,7 @@ int main(int i_argc, char* pa_argv[])
usage( pa_argv[0] ); usage( pa_argv[0] );
goto error; goto error;
break; break;
#ifdef HAVE_SYS_SOCKET_H
case 'm': case 'm':
i_mtu = atoi( optarg ); i_mtu = atoi( optarg );
if( i_mtu < 0 ) i_mtu = 1316; if( i_mtu < 0 ) i_mtu = 1316;
...@@ -426,6 +446,7 @@ int main(int i_argc, char* pa_argv[]) ...@@ -426,6 +446,7 @@ int main(int i_argc, char* pa_argv[])
case 'u': case 'u':
ipaddress = strdup( optarg ); ipaddress = strdup( optarg );
break; break;
#endif
case -1: case -1:
break; break;
default: default:
...@@ -442,6 +463,7 @@ int main(int i_argc, char* pa_argv[]) ...@@ -442,6 +463,7 @@ int main(int i_argc, char* pa_argv[])
if( !p_data ) if( !p_data )
goto out_of_memory; goto out_of_memory;
} }
#ifdef HAVE_SYS_SOCKET_H
if( ipaddress ) if( ipaddress )
{ {
i_fd = create_udp_connection( ipaddress, i_port ); i_fd = create_udp_connection( ipaddress, i_port );
...@@ -449,6 +471,7 @@ int main(int i_argc, char* pa_argv[]) ...@@ -449,6 +471,7 @@ int main(int i_argc, char* pa_argv[])
if( !p_data ) if( !p_data )
goto out_of_memory; goto out_of_memory;
} }
#endif
p_stream = (ts_stream_t *) malloc( sizeof(ts_stream_t) ); p_stream = (ts_stream_t *) malloc( sizeof(ts_stream_t) );
if( !p_stream ) if( !p_stream )
goto out_of_memory; goto out_of_memory;
...@@ -457,8 +480,10 @@ int main(int i_argc, char* pa_argv[]) ...@@ -457,8 +480,10 @@ int main(int i_argc, char* pa_argv[])
/* Read first packet */ /* Read first packet */
if( filename ) if( filename )
b_ok = ReadPacket( i_fd, p_data); b_ok = ReadPacket( i_fd, p_data);
#ifdef HAVE_SYS_SOCKET_H
else else
b_ok = ReadPacketFromSocket( i_fd, p_data, i_mtu ); b_ok = ReadPacketFromSocket( i_fd, p_data, i_mtu );
#endif
/* Enter infinite loop */ /* Enter infinite loop */
p_stream->pat.handle = dvbpsi_AttachPAT( DumpPAT, p_stream ); p_stream->pat.handle = dvbpsi_AttachPAT( DumpPAT, p_stream );
...@@ -539,7 +564,7 @@ int main(int i_argc, char* pa_argv[]) ...@@ -539,7 +564,7 @@ int main(int i_argc, char* pa_argv[])
if( b_discontinuity_indicator ) if( b_discontinuity_indicator )
{ {
if( b_pcr ) if( b_pcr )
printf( "New PCR pid %d value %ld \n", i_pid, p_stream->pid[i_pid].i_pcr ); printf( "New PCR pid %d value %lld \n", i_pid, (long long int)p_stream->pid[i_pid].i_pcr );
if( b_discontinuity_seen ) if( b_discontinuity_seen )
{ {
/* cc discontinuity is expected */ /* cc discontinuity is expected */
...@@ -560,8 +585,10 @@ int main(int i_argc, char* pa_argv[]) ...@@ -560,8 +585,10 @@ int main(int i_argc, char* pa_argv[])
/* Read next packet */ /* Read next packet */
if( filename ) if( filename )
b_ok = ReadPacket( i_fd, p_data); b_ok = ReadPacket( i_fd, p_data);
#ifdef HAVE_SYS_SOCKET_H
else else
b_ok = ReadPacketFromSocket( i_fd, p_data, i_mtu ); b_ok = ReadPacketFromSocket( i_fd, p_data, i_mtu );
#endif
} }
dvbpsi_DetachPMT( p_stream->pmt.handle ); dvbpsi_DetachPMT( p_stream->pmt.handle );
dvbpsi_DetachPAT( p_stream->pat.handle ); dvbpsi_DetachPAT( p_stream->pat.handle );
...@@ -569,12 +596,16 @@ int main(int i_argc, char* pa_argv[]) ...@@ -569,12 +596,16 @@ int main(int i_argc, char* pa_argv[])
/* clean up */ /* clean up */
if( filename ) if( filename )
close( i_fd ); close( i_fd );
#ifdef HAVE_SYS_SOCKET_H
else else
close_connection( i_fd ); close_connection( i_fd );
#endif
if( p_data ) free( p_data ); if( p_data ) free( p_data );
if( filename ) free( filename ); if( filename ) free( filename );
#ifdef HAVE_SYS_SOCKET_H
if( ipaddress ) free( ipaddress ); if( ipaddress ) free( ipaddress );
#endif
/* free other stuff first ;-)*/ /* free other stuff first ;-)*/
if( p_stream ) free( p_stream ); if( p_stream ) free( p_stream );
...@@ -586,7 +617,9 @@ out_of_memory: ...@@ -586,7 +617,9 @@ out_of_memory:
error: error:
if( p_data ) free( p_data ); if( p_data ) free( p_data );
if( filename ) free( filename ); if( filename ) free( filename );
#ifdef HAVE_SYS_SOCKET_H
if( ipaddress ) free( ipaddress ); if( ipaddress ) free( ipaddress );
#endif
/* free other stuff first ;-)*/ /* free other stuff first ;-)*/
if( p_stream ) free( p_stream ); if( p_stream ) free( p_stream );
......
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