Commit 2e95f74f authored by Jean-Paul Saman's avatar Jean-Paul Saman

examples/dvbinfo: prints DVB PSI information for DVB and MPEG-TS streams.

The dvbpsi-info tool provides information about the DVB PSI tables in
DVB and MPEG-TS streams (or files). It uses libdvbpsi to gather all
information and prints it to stdout.
parent 834db590
...@@ -27,6 +27,7 @@ examples/decode_pmt ...@@ -27,6 +27,7 @@ examples/decode_pmt
examples/decode_sdt examples/decode_sdt
examples/decode_bat examples/decode_bat
examples/get_pcr_pid examples/get_pcr_pid
examples/dvbinfo/dvbinfo
misc/gen_crc misc/gen_crc
misc/gen_pat misc/gen_pat
misc/gen_pmt misc/gen_pmt
......
...@@ -7,16 +7,15 @@ AC_CANONICAL_SYSTEM ...@@ -7,16 +7,15 @@ AC_CANONICAL_SYSTEM
AM_INIT_AUTOMAKE AM_INIT_AUTOMAKE
AM_CONFIG_HEADER(config.h) AM_CONFIG_HEADER(config.h)
#AC_CANONICAL_HOST dnl AC_CANONICAL_HOST
AC_PROG_CC AC_PROG_CC
AC_STDC_HEADERS AC_STDC_HEADERS
AC_C_INLINE AC_C_INLINE
AM_PROG_LIBTOOL AM_PROG_LIBTOOL
dnl default CFLAGS dnl default CFLAGS
CFLAGS="${CFLAGS} -Wall -Werror -DDVBPSI_DIST --std=gnu99 -D_GNU_SOURCE" 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" CFLAGS="${CFLAGS} -Wpointer-arith -Wcast-align -Wcast-qual -Wstrict-prototypes -Wshadow -Waggregate-return -Wmissing-prototypes -Wnested-externs -Wsign-compare"
dnl check the operating system dnl check the operating system
...@@ -52,7 +51,7 @@ if test "$release" = "true" ...@@ -52,7 +51,7 @@ if test "$release" = "true"
then then
CFLAGS="${CFLAGS} -O6" CFLAGS="${CFLAGS} -O6"
else else
CFLAGS="${CFLAGS} -O2" CFLAGS="${CFLAGS} -O2 -DDVBPSI_DIST"
fi fi
dnl Check for headers dnl Check for headers
...@@ -78,6 +77,7 @@ fi ...@@ -78,6 +77,7 @@ fi
AC_OUTPUT([Makefile AC_OUTPUT([Makefile
src/Makefile src/Makefile
examples/Makefile examples/Makefile
examples/dvbinfo/Makefile
misc/Makefile misc/Makefile
doc/Makefile doc/Makefile
wince/Makefile wince/Makefile
......
## Process this file with automake to produce Makefile.in ## 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 noinst_PROGRAMS = decode_pat decode_pmt get_pcr_pid decode_sdt decode_mpeg decode_bat
decode_pat_SOURCES = decode_pat.c decode_pat_SOURCES = decode_pat.c
decode_pat_CPPFLAGS = -DDVBPSI_DIST
decode_pat_LDFLAGS = -L../src -ldvbpsi decode_pat_LDFLAGS = -L../src -ldvbpsi
decode_pmt_SOURCES = decode_pmt.c decode_pmt_SOURCES = decode_pmt.c
decode_pmt_CPPFLAGS = -DDVBPSI_DIST
decode_pmt_LDFLAGS = -L../src -ldvbpsi -lm decode_pmt_LDFLAGS = -L../src -ldvbpsi -lm
get_pcr_pid_SOURCES = get_pcr_pid.c get_pcr_pid_SOURCES = get_pcr_pid.c
get_pcr_pid_CPPFLAGS = -DDVBPSI_DIST
get_pcr_pid_LDFLAGS = -L../src -ldvbpsi -lm get_pcr_pid_LDFLAGS = -L../src -ldvbpsi -lm
decode_sdt_SOURCES = decode_sdt.c decode_sdt_SOURCES = decode_sdt.c
decode_sdt_CPPFLAGS = -DDVBPSI_DIST
decode_sdt_LDFLAGS = -L../src -ldvbpsi decode_sdt_LDFLAGS = -L../src -ldvbpsi
decode_mpeg_SOURCES = decode_mpeg.c decode_mpeg_SOURCES = decode_mpeg.c
if HAVE_SYS_SOCKET_H if HAVE_SYS_SOCKET_H
decode_mpeg_SOURCES += connect.c connect.h decode_mpeg_SOURCES += connect.c connect.h
endif endif
decode_mpeg_CPPFLAGS = -D_FILE_OFFSET_BITS=64 -DDVBPSI_DIST
decode_mpeg_LDFLAGS = -L../src -ldvbpsi -lm decode_mpeg_LDFLAGS = -L../src -ldvbpsi -lm
decode_bat_SOURCES = decode_bat.c decode_bat_SOURCES = decode_bat.c
decode_bat_CPPFLAGS = -DDVBPSI_DIST
decode_bat_LDFLAGS = -L../src -ldvbpsi decode_bat_LDFLAGS = -L../src -ldvbpsi
# 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;
for (p_last = buffer; ; p_last = p_last->p_next)
{
i_depth ++;
if (!p_last->p_next)
break;
}
pthread_mutex_lock(&fifo->lock);
*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);
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 __FreeBSD__
# 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 __FreeBSD__
# 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
...@@ -64,17 +64,13 @@ typedef void (* dvbpsi_message_cb)(dvbpsi_t *handle, ...@@ -64,17 +64,13 @@ typedef void (* dvbpsi_message_cb)(dvbpsi_t *handle,
/*! /*!
* \enum dvbpsi_msg_level * \enum dvbpsi_msg_level
* \brief DVBPSI message level enum * \brief DVBPSI message level enum
* DVBPSI_MSG_NONE -1 : No messages
* DVBPSI_MSG_ERROR 0 : Error messages, only
* DVBPSI_MSG_WARNING 1 : Error and Warning messages
* DVBPSI_MSG_DEBUG 2 : Error, warning and debug messages
*/ */
enum dvbpsi_msg_level enum dvbpsi_msg_level
{ {
DVBPSI_MSG_NONE = -1, DVBPSI_MSG_NONE = -1, /*!< No messages */
DVBPSI_MSG_ERROR = 0, DVBPSI_MSG_ERROR = 0, /*!< Error messages only */
DVBPSI_MSG_WARN = 1, DVBPSI_MSG_WARN = 1, /*!< Error and Warning messages */
DVBPSI_MSG_DEBUG = 2, DVBPSI_MSG_DEBUG = 2, /*!< Error, warning and debug messages */
}; };
/***************************************************************************** /*****************************************************************************
......
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