X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fstream_out%2Frtp.c;h=c496ee34be6a96527b94e517f7bdfac9096fc208;hb=d76709e45d961e180791c799fe8daef0378330ad;hp=5f8e1b3f460ef45e2d3627596abc73349ffe97eb;hpb=55c960749e8f91763e720ac610d5dd56f90fcde1;p=vlc diff --git a/modules/stream_out/rtp.c b/modules/stream_out/rtp.c index 5f8e1b3f46..c496ee34be 100644 --- a/modules/stream_out/rtp.c +++ b/modules/stream_out/rtp.c @@ -247,7 +247,6 @@ struct sout_stream_sys_t vlc_mutex_t lock_sdp; /* SDP to disk */ - bool b_export_sdp_file; char *psz_sdp_file; /* SDP via SAP */ @@ -352,8 +351,6 @@ static int Open( vlc_object_t *p_this ) p_sys->i_port_video = var_GetInteger( p_stream, SOUT_CFG_PREFIX "port-video" ); p_sys->rtcp_mux = var_GetBool( p_stream, SOUT_CFG_PREFIX "rtcp-mux" ); - p_sys->psz_sdp_file = NULL; - if( p_sys->i_port_audio && p_sys->i_port_video == p_sys->i_port_audio ) { msg_Err( p_stream, "audio and video RTP port must be distinct" ); @@ -446,8 +443,8 @@ static int Open( vlc_object_t *p_this ) p_sys->psz_sdp = NULL; p_sys->b_export_sap = false; - p_sys->b_export_sdp_file = false; p_sys->p_session = NULL; + p_sys->psz_sdp_file = NULL; p_sys->p_httpd_host = NULL; p_sys->p_httpd_file = NULL; @@ -566,10 +563,11 @@ static void Close( vlc_object_t * p_this ) if( p_sys->p_mux ) { assert( p_sys->i_es == 1 ); - Del( p_stream, p_sys->es[0] ); sout_MuxDelete( p_sys->p_mux ); + Del( p_stream, p_sys->es[0] ); sout_AccessOutDelete( p_sys->p_grab ); + if( p_sys->packet ) { block_Release( p_sys->packet ); @@ -595,7 +593,7 @@ static void Close( vlc_object_t * p_this ) free( p_sys->psz_sdp ); - if( p_sys->b_export_sdp_file ) + if( p_sys->psz_sdp_file != NULL ) { #ifdef HAVE_UNISTD_H unlink( p_sys->psz_sdp_file ); @@ -657,16 +655,19 @@ static void SDPHandleUrl( sout_stream_t *p_stream, const char *psz_url ) } else if( url.psz_protocol && !strcasecmp( url.psz_protocol, "file" ) ) { - if( p_sys->b_export_sdp_file ) + if( p_sys->psz_sdp_file != NULL ) { msg_Err( p_stream, "you can use sdp=file:// only once" ); goto out; } - p_sys->b_export_sdp_file = true; psz_url = &psz_url[5]; if( psz_url[0] == '/' && psz_url[1] == '/' ) psz_url += 2; p_sys->psz_sdp_file = strdup( psz_url ); + if( p_sys->psz_sdp_file == NULL ) + goto out; + decode_URI( p_sys->psz_sdp_file ); /* FIXME? */ + FileSetup( p_stream ); } else { @@ -1094,6 +1095,10 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt ) id->psz_enc = "G726-40"; id->pf_packetize = rtp_packetize_g726_40; break; + default: + msg_Err( p_stream, "cannot add this stream (unsupported " + "G.726 bit rate: %u)", p_fmt->i_bitrate ); + goto error; } break; case VLC_CODEC_A52: @@ -1245,7 +1250,7 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt ) default: msg_Err( p_stream, "cannot add this stream (unsupported " - "codec:%4.4s)", (char*)&p_fmt->i_codec ); + "codec: %4.4s)", (char*)&p_fmt->i_codec ); goto error; } if (id->i_payload_type >= 96) @@ -1286,7 +1291,7 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt ) /* Update SDP (sap/file) */ if( p_sys->b_export_sap ) SapSetup( p_stream ); - if( p_sys->b_export_sdp_file ) FileSetup( p_stream ); + if( p_sys->psz_sdp_file != NULL ) FileSetup( p_stream ); return id; @@ -1329,7 +1334,7 @@ static int Del( sout_stream_t *p_stream, sout_stream_id_t *id ) /* Update SDP (sap/file) */ if( p_sys->b_export_sap && !p_sys->p_mux ) SapSetup( p_stream ); - if( p_sys->b_export_sdp_file ) FileSetup( p_stream ); + if( p_sys->psz_sdp_file != NULL ) FileSetup( p_stream ); vlc_object_detach( id ); vlc_object_release( id ); @@ -1392,6 +1397,9 @@ static int FileSetup( sout_stream_t *p_stream ) sout_stream_sys_t *p_sys = p_stream->p_sys; FILE *f; + if( p_sys->psz_sdp == NULL ) + return VLC_EGENERIC; /* too early */ + if( ( f = utf8_fopen( p_sys->psz_sdp_file, "wt" ) ) == NULL ) { msg_Err( p_stream, "cannot open file '%s' (%m)", @@ -1631,7 +1639,7 @@ unsigned rtp_get_num( const sout_stream_id_t *id ) void rtp_packetize_common( sout_stream_id_t *id, block_t *out, int b_marker, int64_t i_pts ) { - uint32_t i_timestamp = i_pts * (int64_t)id->i_clock_rate / INT64_C(1000000); + uint32_t i_timestamp = i_pts * (int64_t)id->i_clock_rate / CLOCK_FREQ; out->p_buffer[0] = 0x80; out->p_buffer[1] = (b_marker?0x80:0x00)|id->i_payload_type;