Commit 103b7ff0 authored by gatty's avatar gatty

Added IPv6 support for output and duplicate (-d) targets. See INSTALL file for usage info.

git-svn-id: svn://svn.videolan.org/dvblast/trunk@93 55d3f8b6-4a41-4d2d-a900-313d1436a5b8
parent ebfd5297
...@@ -7,14 +7,15 @@ ...@@ -7,14 +7,15 @@
# The fields are: name (N), email (E), web-address (W), CVS account login (C), # The fields are: name (N), email (E), web-address (W), CVS account login (C),
# PGP key ID and fingerprint (P), description (D), and snail-mail address (S). # PGP key ID and fingerprint (P), description (D), and snail-mail address (S).
N: Marian Ďurkovič N: Marian Durkovic
E: md AT bts DOT sk E: md AT bts DOT sk
C: md C: md
D: numerous bug fixes D: numerous bug fixes
N: Andy Gatward N: Andy Gatward
E: a DOT j DOT gatward AT reading DOT ac DOT uk E: a DOT j DOT gatward AT reading DOT ac DOT uk
D: EIT pass-through mode and misc fixes C: gatty
D: EIT pass-through, IPv6 support, various bug fixes
N: Christophe Massiot N: Christophe Massiot
E: massiot AT via DOT ecp DOT fr E: massiot AT via DOT ecp DOT fr
......
...@@ -40,6 +40,17 @@ For instance : ...@@ -40,6 +40,17 @@ For instance :
The configuration file can be reloaded by sending "HUP" to the program, or The configuration file can be reloaded by sending "HUP" to the program, or
via the dvblastctl program. via the dvblastctl program.
IPv6 is supported, the destination address must be specified in the format
described by RFC2732. When using link-local scope addresses, it is
mandatory to include the interface name in the address, as shown in the
example below. If you do not include the interface name, you will see an
"invalid argument" error. The interface name is optional for site-local and
global scope addresses.
For example :
[ff12::1%eth0]:1234 1 10750
[ff15::abcd]:1234 1 10750
The "always on" flag tells DVBlast whether the channel is expected to The "always on" flag tells DVBlast whether the channel is expected to
be on at all times or if it may break. If set to "1", then DVBlast will be on at all times or if it may break. If set to "1", then DVBlast will
regularly reset the CAM module if it fails to descramble the service, regularly reset the CAM module if it fails to descramble the service,
...@@ -114,12 +125,18 @@ Advanced features ...@@ -114,12 +125,18 @@ Advanced features
================= =================
DVBlast may handle several DVB adapters in the same machine with the -a switch: DVBlast may handle several DVB adapters in the same machine with the -a switch:
-a 3 will use /dev/dvb/adapter3. -a 3 will use /dev/dvb/adapter3. Additionally, selecting between frontends on
a single card is supported with the -n switch. This is useful for hybrid
DVB/S + DVB/T cards.
For better latency, run DVBlast in real-time priority (-i 1). For better latency, run DVBlast in real-time priority (-i 1).
DVBlast can also stream the entire transponder to an address : DVBlast can also stream the entire transponder to an IPv4 or IPv6 address :
dvblast -u -d 172.16.42.42:1235 -f 11570000 -s 27500000 -v 18 dvblast -u -d 172.16.42.42:1235 -f 11570000 -s 27500000 -v 18
dvblast -u -d [fe80::0ca:feff:fec0:ffee]:1235 -f 11570000 -s 27500000 -v 18
Note that IPv6 addresses specified on command line may need to have the square
brackets escaped (\[ and \]), depending on your shell.
The -u switch disables the PID filters, so that all PIDs, even the The -u switch disables the PID filters, so that all PIDs, even the
unused ones, can be output. With -e, dvblast also streams EIT and SDT packets unused ones, can be output. With -e, dvblast also streams EIT and SDT packets
......
$Id$ $Id$
Changes between 1.1 and 1.2-svn:
--------------------------------
* Support for IPv6 output and duplicate
* Support input from ASI card
* Support input from (IPv4) RTP / UDP stream
* Miscellaneous CAM and demux fixes
Changes between 1.0 and 1.1: Changes between 1.0 and 1.1:
---------------------------- ----------------------------
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* Andy Gatward <a.j.gatward@reading.ac.uk> * Andy Gatward <a.j.gatward@reading.ac.uk>
* Marian Ďurkovič <md@bts.sk> * Marian Durkovic <md@bts.sk>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
...@@ -280,8 +280,8 @@ static void demux_Handle( block_t *p_ts ) ...@@ -280,8 +280,8 @@ static void demux_Handle( block_t *p_ts )
pp_outputs[j]->i_nb_errors = 0; pp_outputs[j]->i_nb_errors = 0;
msg_Warn( NULL, msg_Warn( NULL,
"too many errors for stream %s:%d, resetting", "too many errors for stream %s, resetting",
inet_ntoa( p_output->maddr.sin_addr ), p_output->maddr.sin_port ); p_output->psz_displayname );
en50221_Reset(); en50221_Reset();
} }
} }
......
This diff is collapsed.
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
* $Id$ * $Id$
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* Andy Gatward <a.j.gatward@reading.ac.uk>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
...@@ -25,9 +26,13 @@ ...@@ -25,9 +26,13 @@
#include <dvbpsi/descriptor.h> #include <dvbpsi/descriptor.h>
#include <dvbpsi/pmt.h> #include <dvbpsi/pmt.h>
#include "netdb.h"
#include "sys/socket.h"
#define DEFAULT_PORT 3001 #define DEFAULT_PORT 3001
#define TS_SIZE 188 #define TS_SIZE 188
#define NB_BLOCKS 7 #define NB_BLOCKS 7
#define NB_BLOCKS_IPV6 6 // assume MTU of 1280 bytes for IPv6
#define RTP_SIZE 12 #define RTP_SIZE 12
#define EMPTY_PID 8192 #define EMPTY_PID 8192
#define PADDING_PID 8191 #define PADDING_PID 8191
...@@ -41,16 +46,14 @@ ...@@ -41,16 +46,14 @@
* Bit 1 : Set output still present * Bit 1 : Set output still present
* Bit 2 : Set if output is valid (replaces m_addr != 0 tests) * Bit 2 : Set if output is valid (replaces m_addr != 0 tests)
* Bit 3 : Set for UDP, otherwise use RTP if a network stream * Bit 3 : Set for UDP, otherwise use RTP if a network stream
* Bit 4 : Set for IPv6, unset for IPv4 (future use) * Bit 4 : Set for file / FIFO output, unset for network (future use)
* Bit 5 : Set for file / FIFO output, unset for network (future use)
*****************************************************************************/ *****************************************************************************/
#define OUTPUT_WATCH 0x01 #define OUTPUT_WATCH 0x01
#define OUTPUT_STILL_PRESENT 0x02 #define OUTPUT_STILL_PRESENT 0x02
#define OUTPUT_VALID 0x04 #define OUTPUT_VALID 0x04
#define OUTPUT_UDP 0x08 #define OUTPUT_UDP 0x08
#define OUTPUT_IPV6 0x10 #define OUTPUT_FILE 0x10
#define OUTPUT_FILE 0x20
typedef int64_t mtime_t; typedef int64_t mtime_t;
...@@ -63,7 +66,12 @@ typedef struct block_t ...@@ -63,7 +66,12 @@ typedef struct block_t
typedef struct output_t typedef struct output_t
{ {
struct sockaddr_in maddr; /* address information, protocol agnostic */
struct sockaddr_storage *p_addr;
socklen_t i_addrlen;
/* display string */
char *psz_displayname;
/* output */ /* output */
int i_handle; int i_handle;
...@@ -161,8 +169,8 @@ void demux_Change( output_t *p_output, uint16_t i_sid, ...@@ -161,8 +169,8 @@ void demux_Change( output_t *p_output, uint16_t i_sid,
void demux_ResendCAPMTs( void ); void demux_ResendCAPMTs( void );
int PIDIsSelected( uint16_t i_pid ); int PIDIsSelected( uint16_t i_pid );
output_t *output_Create( in_addr_t i_maddr, uint16_t i_port ); output_t *output_Create( uint8_t i_config, char *psz_displayname, void *p_init_data );
int output_Init( output_t *p_output, in_addr_t i_maddr, uint16_t i_port ); int output_Init( output_t *p_output, uint8_t i_config, char *psz_displayname, void *p_init_data );
void output_Close( output_t *p_output ); void output_Close( output_t *p_output );
void output_Put( output_t *p_output, block_t *p_block ); void output_Put( output_t *p_output, block_t *p_block );
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
* $Id$ * $Id$
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* Andy Gatward <a.j.gatward@reading.ac.uk>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
...@@ -25,6 +26,7 @@ ...@@ -25,6 +26,7 @@
#include <unistd.h> #include <unistd.h>
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
#include <stdio.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <arpa/inet.h> #include <arpa/inet.h>
...@@ -44,7 +46,7 @@ static void rtp_SetHdr( output_t *p_output, uint8_t *p_hdr ); ...@@ -44,7 +46,7 @@ static void rtp_SetHdr( output_t *p_output, uint8_t *p_hdr );
/***************************************************************************** /*****************************************************************************
* output_Create : called from main thread * output_Create : called from main thread
*****************************************************************************/ *****************************************************************************/
output_t *output_Create( in_addr_t i_maddr, uint16_t i_port ) output_t *output_Create( uint8_t i_config, char *psz_displayname, void *p_init_data )
{ {
int i; int i;
output_t *p_output = NULL; output_t *p_output = NULL;
...@@ -67,7 +69,7 @@ output_t *output_Create( in_addr_t i_maddr, uint16_t i_port ) ...@@ -67,7 +69,7 @@ output_t *output_Create( in_addr_t i_maddr, uint16_t i_port )
pp_outputs[i] = p_output; pp_outputs[i] = p_output;
} }
if ( output_Init( p_output, i_maddr, i_port ) < 0 ) if ( output_Init( p_output, i_config, psz_displayname, p_init_data ) < 0 )
return NULL; return NULL;
return p_output; return p_output;
...@@ -76,7 +78,7 @@ output_t *output_Create( in_addr_t i_maddr, uint16_t i_port ) ...@@ -76,7 +78,7 @@ output_t *output_Create( in_addr_t i_maddr, uint16_t i_port )
/***************************************************************************** /*****************************************************************************
* output_Init * output_Init
*****************************************************************************/ *****************************************************************************/
int output_Init( output_t *p_output, in_addr_t i_maddr, uint16_t i_port ) int output_Init( output_t *p_output, uint8_t i_config, char *psz_displayname, void *p_init_data )
{ {
p_output->i_sid = 0; p_output->i_sid = 0;
p_output->i_depth = 0; p_output->i_depth = 0;
...@@ -100,10 +102,16 @@ int output_Init( output_t *p_output, in_addr_t i_maddr, uint16_t i_port ) ...@@ -100,10 +102,16 @@ int output_Init( output_t *p_output, in_addr_t i_maddr, uint16_t i_port )
p_output->i_ref_timestamp = 0; p_output->i_ref_timestamp = 0;
p_output->i_ref_wallclock = 0; p_output->i_ref_wallclock = 0;
p_output->maddr.sin_family = AF_INET; p_output->i_config = i_config;
p_output->maddr.sin_addr.s_addr = i_maddr; p_output->psz_displayname = psz_displayname;
p_output->maddr.sin_port = htons(i_port);
if ( (p_output->i_handle = net_Open(p_output)) < 0 ) struct addrinfo *p_ai = (struct addrinfo *)p_init_data;
p_output->i_addrlen = p_ai->ai_addrlen;
p_output->p_addr = malloc( p_output->i_addrlen );
memcpy( p_output->p_addr, p_ai->ai_addr,
p_output->i_addrlen );
if ( ( p_output->i_handle = net_Open( p_output ) ) < 0 )
{ {
p_output->i_config &= ~OUTPUT_VALID; p_output->i_config &= ~OUTPUT_VALID;
return -1; return -1;
...@@ -141,7 +149,9 @@ static void output_Flush( output_t *p_output ) ...@@ -141,7 +149,9 @@ static void output_Flush( output_t *p_output )
struct iovec p_iov[NB_BLOCKS + 1]; struct iovec p_iov[NB_BLOCKS + 1];
uint8_t p_rtp_hdr[RTP_SIZE]; uint8_t p_rtp_hdr[RTP_SIZE];
int i; int i;
int i_outblocks = NB_BLOCKS;
int i_block_cnt = ( p_output->p_addr->ss_family == AF_INET6 ) ? NB_BLOCKS_IPV6 : NB_BLOCKS;
int i_outblocks = i_block_cnt;
if ( !b_output_udp && !(p_output->i_config & OUTPUT_UDP) ) if ( !b_output_udp && !(p_output->i_config & OUTPUT_UDP) )
{ {
...@@ -149,7 +159,7 @@ static void output_Flush( output_t *p_output ) ...@@ -149,7 +159,7 @@ static void output_Flush( output_t *p_output )
p_iov[0].iov_len = sizeof(p_rtp_hdr); p_iov[0].iov_len = sizeof(p_rtp_hdr);
rtp_SetHdr( p_output, p_rtp_hdr ); rtp_SetHdr( p_output, p_rtp_hdr );
for ( i = 1; i < NB_BLOCKS + 1; i++ ) for ( i = 1; i < i_block_cnt + 1; i++ )
{ {
p_iov[i].iov_base = p_output->pp_blocks[i - 1]->p_ts; p_iov[i].iov_base = p_output->pp_blocks[i - 1]->p_ts;
p_iov[i].iov_len = TS_SIZE; p_iov[i].iov_len = TS_SIZE;
...@@ -159,7 +169,7 @@ static void output_Flush( output_t *p_output ) ...@@ -159,7 +169,7 @@ static void output_Flush( output_t *p_output )
} }
else else
{ {
for ( i = 0; i < NB_BLOCKS; i++ ) for ( i = 0; i < i_block_cnt; i++ )
{ {
p_iov[i].iov_base = p_output->pp_blocks[i]->p_ts; p_iov[i].iov_base = p_output->pp_blocks[i]->p_ts;
p_iov[i].iov_len = TS_SIZE; p_iov[i].iov_len = TS_SIZE;
...@@ -168,11 +178,11 @@ static void output_Flush( output_t *p_output ) ...@@ -168,11 +178,11 @@ static void output_Flush( output_t *p_output )
if ( writev( p_output->i_handle, p_iov, i_outblocks ) < 0 ) if ( writev( p_output->i_handle, p_iov, i_outblocks ) < 0 )
{ {
msg_Err( NULL, "couldn't writev to %s:%u (%s)", inet_ntoa( p_output->maddr.sin_addr ), msg_Err( NULL, "couldn't writev to %s (%s)",
p_output->maddr.sin_port, strerror(errno) ); p_output->psz_displayname, strerror(errno) );
} }
for ( i = 0; i < NB_BLOCKS; i++ ) for ( i = 0; i < i_block_cnt; i++ )
{ {
p_output->pp_blocks[i]->i_refcount--; p_output->pp_blocks[i]->i_refcount--;
if ( !p_output->pp_blocks[i]->i_refcount ) if ( !p_output->pp_blocks[i]->i_refcount )
...@@ -191,7 +201,10 @@ void output_Put( output_t *p_output, block_t *p_block ) ...@@ -191,7 +201,10 @@ void output_Put( output_t *p_output, block_t *p_block )
p_output->pp_blocks[p_output->i_depth] = p_block; p_output->pp_blocks[p_output->i_depth] = p_block;
p_output->i_depth++; p_output->i_depth++;
if ( p_output->i_depth >= NB_BLOCKS ) if ( ( ( p_output->p_addr->ss_family == AF_INET6 ) &&
( p_output->i_depth >= NB_BLOCKS_IPV6 ) ) ||
( ( p_output->p_addr->ss_family == AF_INET ) &&
( p_output->i_depth >= NB_BLOCKS ) ) )
output_Flush( p_output ); output_Flush( p_output );
} }
...@@ -200,22 +213,43 @@ void output_Put( output_t *p_output, block_t *p_block ) ...@@ -200,22 +213,43 @@ void output_Put( output_t *p_output, block_t *p_block )
*****************************************************************************/ *****************************************************************************/
static int net_Open( output_t *p_output ) static int net_Open( output_t *p_output )
{ {
int i_handle = socket( AF_INET, SOCK_DGRAM, 0 ); int i_handle = socket( p_output->p_addr->ss_family, SOCK_DGRAM, IPPROTO_UDP );
if ( connect( i_handle, (struct sockaddr *)&p_output->maddr, sizeof( p_output->maddr ) ) < 0 ) if ( i_handle < 0 )
{ {
msg_Err( NULL, "couldn't connect to %s:%u (%s)", inet_ntoa( p_output->maddr.sin_addr ), msg_Err( NULL, "couldn't create socket for %s (%s)",
p_output->maddr.sin_port, strerror(errno) ); p_output->psz_displayname, strerror(errno) );
close( i_handle ); return -errno;
return -1;
} }
if ( IN_MULTICAST( ntohl(p_output->maddr.sin_addr.s_addr ) ) ) if ( p_output->p_addr->ss_family == AF_INET6 )
{
struct sockaddr_in6 *addr = (struct sockaddr_in6 *)p_output->p_addr;
if ( IN6_IS_ADDR_MULTICAST( addr->sin6_addr.s6_addr ) )
{
int i = i_ttl;
setsockopt( i_handle, IPPROTO_IPV6, IPV6_MULTICAST_HOPS,
(void *)&i, sizeof(i) );
}
}
else if ( p_output->p_addr->ss_family == AF_INET )
{
struct sockaddr_in *addr = (struct sockaddr_in *)p_output->p_addr;
if ( IN_MULTICAST( ntohl( addr->sin_addr.s_addr ) ) )
{ {
int i = i_ttl; int i = i_ttl;
setsockopt( i_handle, IPPROTO_IP, IP_MULTICAST_TTL, setsockopt( i_handle, IPPROTO_IP, IP_MULTICAST_TTL,
(void *)&i, sizeof(i) ); (void *)&i, sizeof(i) );
} }
}
if ( connect( i_handle, (struct sockaddr *)p_output->p_addr, p_output->i_addrlen ) < 0 )
{
msg_Err( NULL, "couldn't connect socket to %s (%s)",
p_output->psz_displayname, strerror(errno) );
close( i_handle );
return -errno;
}
return i_handle; return i_handle;
} }
......
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