Changeset 2db764f9f8ebd952f53af8a6333b773ba3bfa93c
- Timestamp:
- 26/05/03 15:45:52 (6 years ago)
- git-parent:
- Files:
-
- include/announce.h (modified) (3 diffs)
- modules/stream_out/standard.c (modified) (3 diffs)
- src/stream_output/announce.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
include/announce.h
rb8443a2 r2db764f 3 3 ***************************************************************************** 4 4 * Copyright (C) 2002 VideoLAN 5 * $Id: announce.h,v 1. 1 2003/05/20 16:20:33zorglub Exp $5 * $Id: announce.h,v 1.2 2003/05/26 13:45:51 zorglub Exp $ 6 6 * 7 7 * Authors: Christophe Massiot <massiot@via.ecp.fr> … … 52 52 char psz_url[256]; 53 53 char psz_name[1024]; 54 char psz_port[8]; 54 55 module_t p_network; 55 56 unsigned int socket; … … 63 64 * Prototypes 64 65 *****************************************************************************/ 65 VLC_EXPORT( sap_session_t *, sout_SAPNew, ( sout_instance_t *,char * , char * ) );66 VLC_EXPORT( sap_session_t *, sout_SAPNew, ( sout_instance_t *,char * , char * , char * ) ); 66 67 VLC_EXPORT( void, sout_SAPSend, ( sout_instance_t *,sap_session_t * ) ); 67 68 VLC_EXPORT( void, sout_SAPDelete, ( sap_session_t * ) ); modules/stream_out/standard.c
rb8443a2 r2db764f 3 3 ***************************************************************************** 4 4 * Copyright (C) 2001, 2002 VideoLAN 5 * $Id: standard.c,v 1. 2 2003/05/20 16:20:33zorglub Exp $5 * $Id: standard.c,v 1.3 2003/05/26 13:45:52 zorglub Exp $ 6 6 * 7 7 * Authors: Laurent Aimar <fenrir@via.ecp.fr> … … 78 78 char *psz_sap = NULL; 79 79 80 char *psz_port = "1234"; 81 80 82 sap_session_t *p_sap = NULL; 81 83 … … 127 129 { 128 130 msg_Dbg( p_sout , "Creating SAP" ); 129 p_sap = sout_SAPNew( p_sout , psz_url , psz_ sap );131 p_sap = sout_SAPNew( p_sout , psz_url , psz_port , psz_sap ); 130 132 } 131 133 src/stream_output/announce.c
r8aa24cf r2db764f 4 4 * Copyright (C) 2002 VideoLAN 5 5 * 6 * Authors: Christophe Massiot <massiot@via.ecp.fr> 7 * Laurent Aimar <fenrir@via.ecp.fr> 8 * Eric Petit <titer@videolan.org> 6 * Authors: Cl�nt Stenac <zorglub@via.ecp.fr> 7 * Damien Lucas <nitrox@via.ecp.fr> 9 8 * 10 9 * This program is free software; you can redistribute it and/or modify … … 38 37 #include <network.h> 39 38 40 #define SAP_ADDR "224.2.127.254" 39 #define SAP_ADDR "224.2.127.254" /* Standard port and address for SAP */ 41 40 #define SAP_PORT 9875 42 41 … … 44 43 * sout_SAPNew: Creates a SAP Session 45 44 *****************************************************************************/ 46 sap_session_t * sout_SAPNew ( sout_instance_t *p_sout , char * psz_url_arg , char * psz_name_arg )45 sap_session_t * sout_SAPNew ( sout_instance_t *p_sout , char * psz_url_arg , char *psz_port_arg , char * psz_name_arg ) 47 46 { 48 47 sap_session_t *p_new; … … 57 56 sprintf ( p_new->psz_url , "%s" , psz_url_arg ); 58 57 sprintf ( p_new->psz_name , "%s" , psz_name_arg ); 58 sprintf ( p_new->psz_port, "%s" , psz_port_arg ); /* Not implemented in SO */ 59 59 60 60 msg_Dbg (p_sout , "Creating SAP Socket" ); … … 107 107 void sout_SAPSend( sout_instance_t *p_sout, sap_session_t * p_this ) 108 108 { 109 char sap_msg[2048];110 char *user="VideoLAN";111 char * machine="VideoLAN";112 char * site="VideoLAN";109 char *sap_head; 110 char sap_msg[1000]; 111 char *sap_send; 112 char *payload_type="application/sdp"; 113 113 int i_send_result; 114 int i; 115 int i_header_size; 116 int i_msg_size; 117 int i_size; 114 118 115 if(p_this->sendnow == 24) 116 { 117 sprintf(sap_msg," ***øv=0 \n\ 118 o=%s 3247692199 3247895918 IN IP4 %s \n\ 119 s=%s\n\ 120 u=%s \n\ 121 t=3247691400 3250117800 \n\ 122 a=type:test \n\ 123 m=audio 1234 udp 14 \n\ 124 c=IN IP4 %s/15 \n\ 125 xxxxxxxxxxxxxxxxxxxxx \n ",user,machine,p_this->psz_name,site,p_this->psz_url); 126 127 i_send_result = sendto( p_this->socket , sap_msg , strlen(sap_msg) , 0 , (struct sockaddr *)&p_this->addr , sizeof(p_this->addr) ); 119 if( p_this->sendnow == 1 ) 120 { 121 i_header_size = 9 + strlen( payload_type ); 122 sap_head = ( char * )malloc( i_header_size * sizeof( char ) ); 123 124 sap_head[0]=0x20; /* Means IPv4, not encrypted, not compressed */ 125 sap_head[1]=0x00; /* No authentification */ 126 sap_head[2]=0x42; /* Version */ 127 sap_head[3]=0x12; /* Version */ 128 129 sap_head[4]=0x01; /* Source IP FIXME: we should get the real address */ 130 sap_head[5]=0x02; /* idem */ 131 sap_head[6]=0x03; /* idem */ 132 sap_head[7]=0x04; /* idem */ 133 134 strncpy( sap_head+8 , payload_type , 15 ); 135 sap_head[ i_header_size-1 ] = '\0'; 136 137 /* Do not add spaces at beginning of the lines ! */ 138 sprintf(sap_msg,"v=0\n\ 139 o=VideoLAN 3247692199 3247895918 IN IP4 VideoLAN\n\ 140 s=%s\n\ 141 u=VideoLAN\n\ 142 t=0 0\n\ 143 m=audio %s udp 14\n\ 144 c=IN IP4 %s/15\n\ 145 a=type:test\n", p_this->psz_name , p_this->psz_port , p_this->psz_url ); 128 146 147 i_msg_size = strlen( sap_msg ); 148 i_size = i_msg_size + i_header_size; 149 150 sap_send = ( char* )malloc( i_size*sizeof(char) ); 151 152 for(i=0 ; i<i_header_size ; i++) 153 { 154 sap_send[i] = sap_head[i]; 155 } 156 157 for( ; i<i_size; i++) 158 { 159 sap_send[i] = sap_msg[i-i_header_size]; 160 } 161 162 /* What we send is the SAP header and the SDP packet */ 163 164 if(i_size<1024) /* We mustn't send packets larger than 1024B */ 165 i_send_result = sendto( p_this->socket , sap_send , i_size , 0 , (struct sockaddr *)&p_this->addr , sizeof(p_this->addr) ); 166 129 167 if(i_send_result == -1) 130 168 { 131 msg_Warn(p_sout , "SAP Send failed on socket %i. " , p_this->socket );132 perror("send");169 msg_Warn(p_sout , "SAP Send failed on socket %i. " , p_this->socket ); 170 perror("sendto"); 133 171 } 134 p_this->sendnow=0; 135 } 136 p_this->sendnow++; 172 p_this->sendnow = 0; 173 if(sap_send) free(sap_send); 174 if(sap_head) free(sap_head); 175 } 176 p_this->sendnow++; 137 177 }
