Changeset 2db764f9f8ebd952f53af8a6333b773ba3bfa93c

Show
Ignore:
Timestamp:
26/05/03 15:45:52 (6 years ago)
Author:
Clément Stenac <zorglub@videolan.org>
git-committer:
Clément Stenac <zorglub@videolan.org> 1053956752 +0000
git-parent:

[9de7a7eb3966c9b459ea899544fd3c982c1a7c21]

git-author:
Clément Stenac <zorglub@videolan.org> 1053956752 +0000
Message:

* The VLC-integrated SAP server now sends compliant packets. They can

only be viewed with the CVS version of VLC

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • include/announce.h

    rb8443a2 r2db764f  
    33 ***************************************************************************** 
    44 * Copyright (C) 2002 VideoLAN 
    5  * $Id: announce.h,v 1.1 2003/05/20 16:20:33 zorglub Exp $ 
     5 * $Id: announce.h,v 1.2 2003/05/26 13:45:51 zorglub Exp $ 
    66 * 
    77 * Authors: Christophe Massiot <massiot@via.ecp.fr> 
     
    5252        char psz_url[256]; 
    5353        char psz_name[1024]; 
     54        char psz_port[8]; 
    5455        module_t p_network; 
    5556        unsigned int socket; 
     
    6364 * Prototypes 
    6465 *****************************************************************************/ 
    65 VLC_EXPORT( sap_session_t *,            sout_SAPNew,         ( sout_instance_t *,char * , char * ) ); 
     66VLC_EXPORT( sap_session_t *,            sout_SAPNew,         ( sout_instance_t *,char * , char * , char * ) ); 
    6667VLC_EXPORT( void,            sout_SAPSend,        ( sout_instance_t *,sap_session_t * ) ); 
    6768VLC_EXPORT( void,            sout_SAPDelete,      ( sap_session_t * ) ); 
  • modules/stream_out/standard.c

    rb8443a2 r2db764f  
    33 ***************************************************************************** 
    44 * Copyright (C) 2001, 2002 VideoLAN 
    5  * $Id: standard.c,v 1.2 2003/05/20 16:20:33 zorglub Exp $ 
     5 * $Id: standard.c,v 1.3 2003/05/26 13:45:52 zorglub Exp $ 
    66 * 
    77 * Authors: Laurent Aimar <fenrir@via.ecp.fr> 
     
    7878    char                *psz_sap = NULL; 
    7979 
     80    char                *psz_port = "1234"; 
     81     
    8082    sap_session_t       *p_sap = NULL; 
    8183     
     
    127129    {         
    128130        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 ); 
    130132    }    
    131133     
  • src/stream_output/announce.c

    r8aa24cf r2db764f  
    44 * Copyright (C) 2002 VideoLAN 
    55 * 
    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> 
    98 * 
    109 * This program is free software; you can redistribute it and/or modify 
     
    3837#include <network.h> 
    3938 
    40 #define SAP_ADDR "224.2.127.254" 
     39#define SAP_ADDR "224.2.127.254" /* Standard port and address for SAP */ 
    4140#define SAP_PORT 9875 
    4241 
     
    4443 * sout_SAPNew: Creates a SAP Session 
    4544 *****************************************************************************/ 
    46 sap_session_t * sout_SAPNew ( sout_instance_t *p_sout , char * psz_url_arg , char * psz_name_arg ) 
     45sap_session_t * sout_SAPNew ( sout_instance_t *p_sout , char * psz_url_arg , char *psz_port_arg , char * psz_name_arg ) 
    4746{ 
    4847        sap_session_t           *p_new; 
     
    5756        sprintf ( p_new->psz_url , "%s" , psz_url_arg ); 
    5857        sprintf ( p_new->psz_name , "%s" , psz_name_arg ); 
     58        sprintf ( p_new->psz_port, "%s" , psz_port_arg ); /* Not implemented in SO */ 
    5959         
    6060        msg_Dbg (p_sout , "Creating SAP Socket" ); 
     
    107107void sout_SAPSend( sout_instance_t *p_sout, sap_session_t * p_this ) 
    108108{  
    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"; 
    113113      int i_send_result; 
     114      int i; 
     115      int i_header_size; 
     116      int i_msg_size; 
     117      int i_size; 
    114118      
    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\ 
     139o=VideoLAN 3247692199 3247895918 IN IP4 VideoLAN\n\ 
     140s=%s\n\ 
     141u=VideoLAN\n\ 
     142t=0 0\n\ 
     143m=audio %s udp 14\n\ 
     144c=IN IP4 %s/15\n\ 
     145a=type:test\n", p_this->psz_name , p_this->psz_port , p_this->psz_url ); 
    128146      
     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     
    129167     if(i_send_result == -1) 
    130168     { 
    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");  
    133171     } 
    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++;   
    137177}