Changeset 19248128916fcc7062c7e5e6d22939ae820b76a3
- 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
| rada036d |
r1924812 |
|
| 55 | 55 | #define PORT_LONGTEXT N_( \ |
|---|
| 56 | 56 | "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 | |
|---|
| 57 | 66 | #define TTL_TEXT N_("Time to live") |
|---|
| 58 | 67 | #define TTL_LONGTEXT N_( \ |
|---|
| … | … | |
| 78 | 87 | MUX_LONGTEXT, VLC_TRUE ); |
|---|
| 79 | 88 | |
|---|
| 80 | | add_integer( SOUT_CFG_PREFIX "port", 1234, NULL, PORT_TEXT, |
|---|
| | 89 | add_integer( SOUT_CFG_PREFIX "port-audio", 1234, NULL, PORT_AUDIO_TEXT, |
|---|
| 81 | 90 | 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 | |
|---|
| 82 | 96 | add_integer( SOUT_CFG_PREFIX "ttl", 0, NULL, TTL_TEXT, |
|---|
| 83 | 97 | TTL_LONGTEXT, VLC_TRUE ); |
|---|
| … | … | |
| 90 | 104 | *****************************************************************************/ |
|---|
| 91 | 105 | static 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 |
|---|
| 93 | 107 | }; |
|---|
| 94 | 108 | |
|---|
| … | … | |
| 141 | 155 | char *psz_destination; |
|---|
| 142 | 156 | int i_port; |
|---|
| | 157 | int i_port_audio; |
|---|
| | 158 | int i_port_video; |
|---|
| 143 | 159 | int i_ttl; |
|---|
| 144 | 160 | |
|---|
| … | … | |
| 241 | 257 | p_sys->psz_session_name = *val.psz_string ? val.psz_string : NULL; |
|---|
| 242 | 258 | |
|---|
| 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 | } |
|---|
| 246 | 269 | |
|---|
| 247 | 270 | if( !p_sys->psz_session_name ) |
|---|
| … | … | |
| 630 | 653 | sout_stream_id_t *id; |
|---|
| 631 | 654 | sout_access_out_t *p_access = NULL; |
|---|
| | 655 | int i_port; |
|---|
| | 656 | char *psz_sdp; |
|---|
| 632 | 657 | |
|---|
| 633 | 658 | if( p_sys->p_mux != NULL ) |
|---|
| … | … | |
| 646 | 671 | id->pf_packetize= NULL; |
|---|
| 647 | 672 | id->p_rtsp_url = NULL; |
|---|
| 648 | | |
|---|
| | 673 | id->i_port = 0; |
|---|
| 649 | 674 | 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; |
|---|
| 650 | 699 | } |
|---|
| 651 | 700 | |
|---|
| … | … | |
| 664 | 713 | sprintf( access, "udp{raw}" ); |
|---|
| 665 | 714 | } |
|---|
| 666 | | sprintf( url, "%s:%d", p_sys->psz_destination, p_sys->i_port ); |
|---|
| | 715 | sprintf( url, "%s:%d", p_sys->psz_destination, i_port ); |
|---|
| 667 | 716 | if( ( p_access = sout_AccessOutNew( p_sout, access, url ) ) == NULL ) |
|---|
| 668 | 717 | { |
|---|
| … | … | |
| 683 | 732 | id->psz_fmtp = NULL; |
|---|
| 684 | 733 | 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; |
|---|
| 686 | 735 | id->p_rtsp_url = NULL; |
|---|
| 687 | 736 | vlc_mutex_init( p_stream, &id->lock_rtsp ); |
|---|
| … | … | |
| 820 | 869 | |
|---|
| 821 | 870 | /* Update p_sys context */ |
|---|
| 822 | | /* update port used (2 -> 1 rtp, 1 rtcp )*/ |
|---|
| 823 | 871 | vlc_mutex_lock( &p_sys->lock_es ); |
|---|
| 824 | 872 | TAB_APPEND( p_sys->i_es, p_sys->es, id ); |
|---|
| 825 | 873 | vlc_mutex_unlock( &p_sys->lock_es ); |
|---|
| 826 | 874 | |
|---|
| 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 ); |
|---|
| 846 | 889 | |
|---|
| 847 | 890 | return id; |
|---|
| … | … | |
| 855 | 898 | TAB_REMOVE( p_sys->i_es, p_sys->es, id ); |
|---|
| 856 | 899 | 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 | } |
|---|
| 857 | 909 | |
|---|
| 858 | 910 | if( id->p_access ) |
|---|