Changeset 19248128916fcc7062c7e5e6d22939ae820b76a3

Show
Ignore:
Timestamp:
07/29/04 20:48:01 (4 years ago)
Author:
Laurent Aimar <fenrir@videolan.org>
git-committer:
Laurent Aimar <fenrir@videolan.org> 1091126881 +0000
git-parent:

[dc30ef149e773a648fb090b82989b90950ed9a87]

git-author:
Laurent Aimar <fenrir@videolan.org> 1091126881 +0000
Message:
  • rtp: added port-audio and port-video option (for default port).
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/stream_out/rtp.c

    rada036d r1924812  
    5555#define PORT_LONGTEXT N_( \ 
    5656    "Allows you to specify the base port used for the RTP streaming." ) 
     57 
     58#define PORT_AUDIO_TEXT N_("Audio port") 
     59#define PORT_AUDIO_LONGTEXT N_( \ 
     60    "Allows you to specify the default audio port used for the RTP streaming." ) 
     61 
     62#define PORT_VIDEO_TEXT N_("Video port") 
     63#define PORT_VIDEO_LONGTEXT N_( \ 
     64    "Allows you to specify the default video port used for the RTP streaming." ) 
     65 
    5766#define TTL_TEXT N_("Time to live") 
    5867#define TTL_LONGTEXT N_( \ 
     
    7887                MUX_LONGTEXT, VLC_TRUE ); 
    7988 
    80     add_integer( SOUT_CFG_PREFIX "port", 1234, NULL, PORT_TEXT, 
     89    add_integer( SOUT_CFG_PREFIX "port-audio", 1234, NULL, PORT_AUDIO_TEXT, 
    8190                 PORT_LONGTEXT, VLC_TRUE ); 
     91    add_integer( SOUT_CFG_PREFIX "port-video", 1236, NULL, PORT_VIDEO_TEXT, 
     92                 PORT_LONGTEXT, VLC_TRUE ); 
     93    add_integer( SOUT_CFG_PREFIX "port", 1238, NULL, PORT_TEXT, 
     94                 PORT_LONGTEXT, VLC_TRUE ); 
     95 
    8296    add_integer( SOUT_CFG_PREFIX "ttl", 0, NULL, TTL_TEXT, 
    8397                 TTL_LONGTEXT, VLC_TRUE ); 
     
    90104 *****************************************************************************/ 
    91105static const char *ppsz_sout_options[] = { 
    92     "dst", "name", "port", "sdp", "ttl", "mux", NULL 
     106    "dst", "name", "port", "port-audio", "port-video", "sdp", "ttl", "mux", NULL 
    93107}; 
    94108 
     
    141155    char *psz_destination; 
    142156    int  i_port; 
     157    int  i_port_audio; 
     158    int  i_port_video; 
    143159    int  i_ttl; 
    144160 
     
    241257    p_sys->psz_session_name = *val.psz_string ? val.psz_string : NULL; 
    242258 
    243     var_Get( p_stream, SOUT_CFG_PREFIX "port", &val ); 
    244     p_sys->i_port = val.i_int; 
    245  
     259    p_sys->i_port       = var_GetInteger( p_stream, SOUT_CFG_PREFIX "port" ); 
     260    p_sys->i_port_audio = var_GetInteger( p_stream, SOUT_CFG_PREFIX "port-audio" ); 
     261    p_sys->i_port_video = var_GetInteger( p_stream, SOUT_CFG_PREFIX "port-video" ); 
     262 
     263    if( p_sys->i_port_audio == p_sys->i_port_video ) 
     264    { 
     265        msg_Err( p_stream, "audio and video port cannot be the same" ); 
     266        p_sys->i_port_audio = 0; 
     267        p_sys->i_port_video = 0; 
     268    } 
    246269 
    247270    if( !p_sys->psz_session_name ) 
     
    630653    sout_stream_id_t  *id; 
    631654    sout_access_out_t *p_access = NULL; 
     655    int               i_port; 
     656    char              *psz_sdp; 
    632657 
    633658    if( p_sys->p_mux != NULL ) 
     
    646671        id->pf_packetize= NULL; 
    647672        id->p_rtsp_url  = NULL; 
    648  
     673        id->i_port      = 0; 
    649674        return id; 
     675    } 
     676 
     677 
     678    /* Choose the port */ 
     679    i_port = 0; 
     680    if( p_fmt->i_cat == AUDIO_ES && p_sys->i_port_audio > 0 ) 
     681    { 
     682        i_port = p_sys->i_port_audio; 
     683        p_sys->i_port_audio = 0; 
     684    } 
     685    else if( p_fmt->i_cat == VIDEO_ES && p_sys->i_port_video > 0 ) 
     686    { 
     687        i_port = p_sys->i_port_video; 
     688        p_sys->i_port_video = 0; 
     689    } 
     690    while( i_port == 0 ) 
     691    { 
     692        if( p_sys->i_port != p_sys->i_port_audio && p_sys->i_port != p_sys->i_port_video ) 
     693        { 
     694            i_port = p_sys->i_port; 
     695            p_sys->i_port += 2; 
     696            break; 
     697        } 
     698        p_sys->i_port += 2; 
    650699    } 
    651700 
     
    664713            sprintf( access, "udp{raw}" ); 
    665714        } 
    666         sprintf( url, "%s:%d", p_sys->psz_destination, p_sys->i_port ); 
     715        sprintf( url, "%s:%d", p_sys->psz_destination, i_port ); 
    667716        if( ( p_access = sout_AccessOutNew( p_sout, access, url ) ) == NULL ) 
    668717        { 
     
    683732    id->psz_fmtp   = NULL; 
    684733    id->psz_destination = p_sys->psz_destination ? strdup( p_sys->psz_destination ) : NULL; 
    685     id->i_port = p_sys->i_port; 
     734    id->i_port = i_port; 
    686735    id->p_rtsp_url = NULL; 
    687736    vlc_mutex_init( p_stream, &id->lock_rtsp ); 
     
    820869 
    821870    /* Update p_sys context */ 
    822     /* update port used (2 -> 1 rtp, 1 rtcp )*/ 
    823871    vlc_mutex_lock( &p_sys->lock_es ); 
    824872    TAB_APPEND( p_sys->i_es, p_sys->es, id ); 
    825873    vlc_mutex_unlock( &p_sys->lock_es ); 
    826874 
    827     if( p_sys->p_mux == NULL ) 
    828     { 
    829         char *psz_sdp; 
    830         p_sys->i_port += 2; 
    831         psz_sdp = SDPGenerate( p_stream, p_sys->psz_destination, VLC_FALSE ); 
    832  
    833         vlc_mutex_lock( &p_sys->lock_sdp ); 
    834         free( p_sys->psz_sdp ); 
    835         p_sys->psz_sdp = psz_sdp; 
    836         vlc_mutex_unlock( &p_sys->lock_sdp ); 
    837  
    838         p_sys->i_sdp_version++; 
    839  
    840         fprintf( stderr, "sdp=%s", p_sys->psz_sdp ); 
    841  
    842         /* Update SDP (sap/file) */ 
    843         if( p_sys->b_export_sap ) SapSetup( p_stream ); 
    844         if( p_sys->b_export_sdp_file ) FileSetup( p_stream ); 
    845     } 
     875    psz_sdp = SDPGenerate( p_stream, p_sys->psz_destination, VLC_FALSE ); 
     876 
     877    vlc_mutex_lock( &p_sys->lock_sdp ); 
     878    free( p_sys->psz_sdp ); 
     879    p_sys->psz_sdp = psz_sdp; 
     880    vlc_mutex_unlock( &p_sys->lock_sdp ); 
     881 
     882    p_sys->i_sdp_version++; 
     883 
     884    fprintf( stderr, "sdp=%s", p_sys->psz_sdp ); 
     885 
     886    /* Update SDP (sap/file) */ 
     887    if( p_sys->b_export_sap ) SapSetup( p_stream ); 
     888    if( p_sys->b_export_sdp_file ) FileSetup( p_stream ); 
    846889 
    847890    return id; 
     
    855898    TAB_REMOVE( p_sys->i_es, p_sys->es, id ); 
    856899    vlc_mutex_unlock( &p_sys->lock_es ); 
     900 
     901    /* Release port */ 
     902    if( id->i_port > 0 ) 
     903    { 
     904        if( id->i_cat == AUDIO_ES && p_sys->i_port_audio == 0 ) 
     905            p_sys->i_port_audio = id->i_port; 
     906        else if( id->i_cat == VIDEO_ES && p_sys->i_port_video == 0 ) 
     907            p_sys->i_port_video = id->i_port; 
     908    } 
    857909 
    858910    if( id->p_access )