[vlc-devel] [PATCH] Support the Metacube protocol when streaming over HTTP.

Denis Charmet typx at dinauz.org
Tue Feb 18 10:01:03 CET 2014


Hi,

Le mardi 18 février 2014 à 01:19:53, Steinar H. Gunderson a écrit :
> +uint16_t metacube2_compute_crc(const struct metacube2_block_header *hdr)
> +{
> +    static const int data_len = sizeof(hdr->size) + sizeof(hdr->flags);
why static?
> +    const uint8_t *data = (uint8_t *)&hdr->size;
> +    uint16_t crc = METACUBE2_CRC_START;
> +    int i, j;
use C99, you can declare your variable inside your for.
> +
> +    for (i = 0; i < data_len; ++i) {
> +        uint8_t c = data[i];
> +        for (j = 0; j < 8; j++) {
> +            int bit = crc & 0x8000;
> +            crc = (crc << 1) | ((c >> (7 - j)) & 0x01);
> +            if (bit) {
> +                crc ^= METACUBE2_CRC_POLYNOMIAL;
> +            }
> +        }
> +    }
> +
> +    /* Finalize. */
> +    for (i = 0; i < 16; i++) {
> +        int bit = crc & 0x8000;
> +        crc = crc << 1;
> +        if (bit) {
> +            crc ^= METACUBE2_CRC_POLYNOMIAL;
> +        }
> +    }
> +
> +    return crc;
> +}
> +
>  /*****************************************************************************
>   * Open: open the file
>   *****************************************************************************/
> @@ -189,6 +259,9 @@ static int Open( vlc_object_t *p_this )
>          psz_mime = var_GetNonEmptyString( p_access, SOUT_CFG_PREFIX "mime" );
>      }
>  
> +    p_sys->b_metacube = var_GetBool( p_access, SOUT_CFG_PREFIX "metacube" );
> +    p_sys->b_has_keyframes = false;
> +
>      p_sys->p_httpd_stream =
>          httpd_StreamNew( p_sys->p_httpd_host, path, psz_mime,
>                           psz_user, psz_pwd );
> @@ -205,6 +278,12 @@ static int Open( vlc_object_t *p_this )
>          return VLC_EGENERIC;
>      }
>  
> +    if( p_sys->b_metacube )
> +    {
> +        httpd_header headers[] = {{ "Content-encoding", "metacube" }};
> +        httpd_StreamSetHTTPHeaders( p_sys->p_httpd_stream, headers, sizeof( headers ) / sizeof( httpd_header ) );
This function returns error when lacking memory.
> +    }
> +
>      p_sys->i_header_allocated = 1024;
>      p_sys->i_header_size      = 0;
>      p_sys->p_header           = xmalloc( p_sys->i_header_allocated );

Regards,

-- 
Denis Charmet - TypX
Le mauvais esprit est un art de vivre



More information about the vlc-devel mailing list