X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;ds=sidebyside;f=modules%2Faccess%2Fudp.c;h=399cea0527356338a78f9be6d8054e49b02585d4;hb=7092196c627494c31418a4b00ab8db1ac01ec6a6;hp=afb0555754c47abd933231e27873061c68c640ae;hpb=2d64aa5c997ea0ce4ff119940923b3cb05320fd7;p=vlc diff --git a/modules/access/udp.c b/modules/access/udp.c index afb0555754..399cea0527 100644 --- a/modules/access/udp.c +++ b/modules/access/udp.c @@ -51,7 +51,10 @@ static int Open ( vlc_object_t * ); static void Close( vlc_object_t * ); vlc_module_begin(); + set_shortname( _("UDP/RTP" ) ); set_description( _("UDP/RTP input") ); + set_category( CAT_INPUT ); + set_subcategory( SUBCAT_INPUT_ACCESS ); add_integer( "udp-caching", DEFAULT_PTS_DELAY / 1000, NULL, CACHING_TEXT, CACHING_LONGTEXT, VLC_TRUE ); @@ -103,7 +106,6 @@ static int Open( vlc_object_t *p_this ) char *psz_bind_port = ""; int i_bind_port = 0; int i_server_port = 0; - vlc_value_t val; /* First set ipv4/ipv6 */ @@ -112,6 +114,7 @@ static int Open( vlc_object_t *p_this ) if( *p_access->psz_access ) { + vlc_value_t val; /* Find out which shortcut was used */ if( !strncmp( p_access->psz_access, "udp4", 6 ) || !strncmp( p_access->psz_access, "rtp4", 6 )) @@ -201,9 +204,7 @@ static int Open( vlc_object_t *p_this ) i_server_port = strtol( psz_server_port, NULL, 10 ); if( ( i_bind_port = strtol( psz_bind_port, NULL, 10 ) ) == 0 ) { - var_Create( p_access, "server-port", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); - var_Get( p_access, "server-port", &val ); - i_bind_port = val.i_int; + i_bind_port = var_CreateGetInteger( p_access, "server-port" ); } msg_Dbg( p_access, "opening server=%s:%d local=%s:%d", @@ -211,7 +212,16 @@ static int Open( vlc_object_t *p_this ) /* Set up p_access */ p_access->pf_read = NULL; - p_access->pf_block = BlockChoose; + if( !strcasecmp( p_access->psz_access, "rtp" ) + || !strcasecmp( p_access->psz_access, "rtp4" ) + || !strcasecmp( p_access->psz_access, "rtp6" ) ) + { + p_access->pf_block = BlockRTP; + } + else + { + p_access->pf_block = BlockChoose; + } p_access->pf_control = Control; p_access->pf_seek = NULL; p_access->info.i_update = 0; @@ -234,13 +244,11 @@ static int Open( vlc_object_t *p_this ) free( psz_name ); /* FIXME */ - var_Create( p_access, "mtu", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); - var_Get( p_access, "mtu", &val); - p_sys->i_mtu = val.i_int > 0 ? val.i_int : 1500; /* avoid problem */ + p_sys->i_mtu = var_CreateGetInteger( p_access, "mtu" ); + if( p_sys->i_mtu <= 1 ) + p_sys->i_mtu = 1500; /* Avoid problem */ - var_Create( p_access, "udp-auto-mtu", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); - var_Get( p_access, "udp-auto-mtu", &val); - p_sys->b_auto_mtu = val.b_bool; + p_sys->b_auto_mtu = var_CreateGetBool( p_access, "udp-auto-mtu" );; /* Update default_pts to a suitable value for udp access */ var_Create( p_access, "udp-caching", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); @@ -269,7 +277,6 @@ static int Control( access_t *p_access, int i_query, va_list args ) vlc_bool_t *pb_bool; int *pi_int; int64_t *pi_64; - vlc_value_t val; switch( i_query ) { @@ -289,8 +296,7 @@ static int Control( access_t *p_access, int i_query, va_list args ) case ACCESS_GET_PTS_DELAY: pi_64 = (int64_t*)va_arg( args, int64_t * ); - var_Get( p_access, "udp-caching", &val ); - *pi_64 = val.i_int * 1000; + *pi_64 = var_GetInteger( p_access, "udp-caching" ) * 1000; break; /* */ @@ -298,10 +304,11 @@ static int Control( access_t *p_access, int i_query, va_list args ) case ACCESS_GET_TITLE_INFO: case ACCESS_SET_TITLE: case ACCESS_SET_SEEKPOINT: + case ACCESS_SET_PRIVATE_ID_STATE: return VLC_EGENERIC; default: - msg_Err( p_access, "unimplemented query in control" ); + msg_Warn( p_access, "unimplemented query in control" ); return VLC_EGENERIC; } @@ -318,17 +325,20 @@ static block_t *BlockUDP( access_t *p_access ) /* Read data */ p_block = block_New( p_access, p_sys->i_mtu ); - p_block->i_buffer = net_Read( p_access, p_sys->fd, p_block->p_buffer, p_sys->i_mtu, VLC_FALSE ); + p_block->i_buffer = net_Read( p_access, p_sys->fd, NULL, + p_block->p_buffer, p_sys->i_mtu, + VLC_FALSE ); if( p_block->i_buffer <= 0 ) { block_Release( p_block ); return NULL; } - if( p_block->i_buffer >= p_sys->i_mtu && p_sys->b_auto_mtu ) + if( p_block->i_buffer >= p_sys->i_mtu && p_sys->b_auto_mtu && + p_sys->i_mtu < 32767 ) { - /* Increase by 10% */ - p_sys->i_mtu += ( p_sys->i_mtu + 9 ) / 10; + /* Increase by 100% */ + p_sys->i_mtu *= 2; msg_Dbg( p_access, "increasing MTU to %d", p_sys->i_mtu ); } @@ -382,7 +392,12 @@ trash: static block_t *BlockRTP( access_t *p_access ) { - return BlockParseRTP( p_access, BlockUDP( p_access ) ); + block_t *p_block = BlockUDP( p_access ); + + if ( p_block != NULL ) + return BlockParseRTP( p_access, p_block ); + else + return NULL; } /***************************************************************************** @@ -426,17 +441,17 @@ static block_t *BlockChoose( access_t *p_access ) { case 33: msg_Dbg( p_access, "detected TS over RTP" ); - p_access->psz_demux = strdup( "ts2" ); + p_access->psz_demux = strdup( "ts" ); break; case 14: msg_Dbg( p_access, "detected MPEG audio over RTP" ); - p_access->psz_demux = strdup( "mp3" ); + p_access->psz_demux = strdup( "mpga" ); break; case 32: msg_Dbg( p_access, "detected MPEG video over RTP" ); - p_access->psz_demux = strdup( "es" ); + p_access->psz_demux = strdup( "mpgv" ); break; default: