Help about Network PS stream decode error

Li Lifeng lilf at sunlab138.xmu.edu.cn
Thu Jun 21 13:19:04 CEST 2001


Hi,

  Here is the code I add in input.c to support multicast
and input_ps.c to support ps://server:port streams.

sorry for not use diff, you can search what I change use "Lilf"

Regards, 

Lilf

<<<<<<<<<<<<<<<<<<<<<< input.c >>>>>>>>>>>>>>>>>>>

    /* Build the local socket */
    if ( network_BuildLocalAddr( &sock, i_port, psz_broadcast ) == -1 )
    {
        intf_ErrMsg( "input error: can't build local address" );
        close( p_input->i_handle );
        p_input->b_error = 1;
        return;
    }

//Lilf overwrite localaddr to INADDR_ANY to satisfy multicast recv
    sock.sin_addr.s_addr = INADDR_ANY;
    
    /* Bind it */
    if( bind( p_input->i_handle, (struct sockaddr *)&sock, 
              sizeof( sock ) ) < 0 )
    {
        intf_ErrMsg("input error: can't bind socket (%s)", strerror(errno));
        close( p_input->i_handle );
        p_input->b_error = 1;
        return;
    }

    /* Build socket for remote connection */
    if ( network_BuildRemoteAddr( &sock, psz_server ) == -1 )
    {
        intf_ErrMsg( "input error: can't build remote address" );
        close( p_input->i_handle );
        p_input->b_error = 1;
        return;
    }

//Lilf add 16 lines to handle multicast join a group
    if((sock.sin_addr.s_addr & 0xf0) == 0xe0)             //224.*.*.*
    {
        struct ip_mreq mr;

        mr.imr_multiaddr.s_addr = sock.sin_addr.s_addr;
        mr.imr_interface.s_addr = INADDR_ANY;
        if(setsockopt(p_input->i_handle,IPPROTO_IP,IP_ADD_MEMBERSHIP,&mr,sizeof(mr)) == -1)
        {
            intf_ErrMsg( "input error: can't join multicast, %s", strerror(errno) );
            close( p_input->i_handle );
            p_input->b_error = 1;
            return;
        }
        intf_WarnMsg( 3, "input: successfully join multicast group" );
    }
    else
    /* And connect it ... should we really connect ? */
    if( connect( p_input->i_handle, (struct sockaddr *) &sock,
                 sizeof( sock ) ) == (-1) )
    {
        intf_ErrMsg( "input error: can't connect socket, %s", 
                     strerror(errno) );
        close( p_input->i_handle );
        p_input->b_error = 1;
        return;
    }

    /* We can't pace control, but FIXME : bug in meuuh's code to sync PCR
     * with the server. */
    p_input->stream.b_pace_control = 0;
    p_input->stream.b_seekable = 0;

<<<<<<<<<<<<<<<<<<<<<<<< end >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

<<<<<<<<<<<<<<<<<<<<<<<<<code change in input_ps.c >>>>>>>>>>>>>>>>
/*****************************************************************************
 * Local prototypes
 *****************************************************************************/
static int  PSProbe     ( probedata_t * );
//Lilf add 1 lines
static void PSFakeOpen( input_thread_t * p_input );

//Lilf change 1 lines
//    input.pf_open             = NULL; /* Set in PSInit */
    input.pf_open             = PSFakeOpen; 

    if( TestMethod( INPUT_METHOD_VAR, "ps" ) )
    {
        return( 999 );
    }

//Lilf add 5 lines
    if( ( strlen(psz_name) > 3 ) && !strncasecmp( psz_name, "ps:", 3 ) )
    {
        /* If the user specified "ps:" then it's probably a network program stream */
        return( 999 );
    }


//Lilf add  function PSFakeOpen
/*****************************************************************************
 * PSFakeOpen: open the stream and set pf_close
 *****************************************************************************/
void PSFakeOpen( input_thread_t * p_input )
{
#if !defined( SYS_BEOS ) && !defined( SYS_NTO )
    char *psz_name = p_input->p_source;

    if( ( strlen(psz_name) > 3 ) && !strncasecmp( psz_name, "ps:", 3 ) )
    {
        /* If the user specified "ps:" he wants a network stream */
        p_input->pf_open  = p_input->pf_network_open;
        p_input->pf_close = p_input->pf_network_close;
    }
    else
#endif
    {
        p_input->pf_open  = p_input->pf_file_open;
        p_input->pf_close = p_input->pf_file_close;
    }

    p_input->pf_open( p_input );
}

    p_input->p_method_data = (void *)p_packet_cache;

//Lilf comment out 3 lines
//    /* Set callback */
//    p_input->pf_open  = p_input->pf_file_open;
//    p_input->pf_close = p_input->pf_file_close;

    /* Initialize packet cache mutex */
    vlc_mutex_init( &p_packet_cache->lock );
    

        vlc_mutex_lock( &p_input->stream.stream_lock );
//Lilf changet 1 line, not seekable is Network stream
//        p_input->stream.i_method = INPUT_METHOD_FILE;
        p_input->stream.i_method = INPUT_METHOD_NETWORK;
        p_input->stream.pp_programs[0]->b_is_ok = 0;
        vlc_mutex_unlock( &p_input->stream.stream_lock );

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< end >>>>>>>>>>>>>>>>>>>>>>>


>On Wed, Jun 20, 2001, Li Lifeng wrote:
>
>>    I had find why vlc lock when read from multicast socket, 
>> It's because multicast socket had to bind to INADDR_ANY(I don't know why)
>> 
>>    But PS decoder still had error, vlc can pop-up a video windows,
>> but it is black and show nothing. From below messages, I think maybe decoder
>> error, help me please, here is error messages generate by
>>  ./vlc --yuv yuv --warning 4.
>
>The stream read by the decoder is obviously invalid. Could you put the
>source code of your input plug-in somewhere so we can have a look ?
>
>-- 
>Christophe Massiot.





More information about the vlc-devel mailing list