[FFmpeg-devel] Realmedia patch

Michael Niedermayer michaelni
Tue Aug 26 01:53:35 CEST 2008


On Sun, Aug 24, 2008 at 09:59:40PM -0400, Ronald S. Bultje wrote:
> Hi Michael,
> 
> On Thu, Aug 21, 2008 at 12:05 AM, Michael Niedermayer <michaelni at gmx.at> wrote:
> > On Mon, Aug 18, 2008 at 10:21:35AM -0400, Ronald S. Bultje wrote:
> >>  /**
> >>   * @returns 0 on success, <0 on error, 1 if protocol is unavailable.
> >>   */
> >>  static int
> >> -make_setup_request (AVFormatContext *s, const char *host, int port, int protocol)
> >> +make_setup_request (AVFormatContext *s, const char *host, int port,
> >> +                    int protocol, RealSetupRequestData *real_data)
> >>  {
> >
> > I think a const char *real_challenge would be enough no RealSetupRequestData
> > seems needed
> 
> Changed.
> 
> >> +void
> >> +ff_rdt_calc_response_and_checksum(char *response, char *chksum, char *challenge)
> >
> > the arguments should be const as appropriate and look like chksum[123] so
> > the size of the arrays is clearly known
> 
> Also changed.
> 
> Attached patch implements only the RDT-compatible SETUP command, and
> requires the previous patch that exports data_to_hex().
> 
[...]

> Index: ffmpeg-svn/libavformat/rdt.c
> ===================================================================
> --- /dev/null	1970-01-01 00:00:00.000000000 +0000
> +++ ffmpeg-svn/libavformat/rdt.c	2008-08-24 21:57:04.000000000 -0400
> @@ -0,0 +1,71 @@
> +/*
> + * RTP RDT (Realmedia) protocol.
> + * Copyright (c) 2007 Ronald S. Bultje
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + */
> +
> +/**
> + * @file rtp_rm.c
> + * @brief RDT (Realmedia) protocol support
> + * @author Ronald S. Bultje <rbultje at ronald.bitfreak.net>
> + */
> +
> +#include "avformat.h"
> +#include "libavutil/avstring.h"
> +#include "rtp_internal.h"
> +#include "libavutil/base64.h"
> +#include "libavutil/md5.h"
> +#include "rm.h"
> +
> +void
> +ff_rdt_calc_response_and_checksum(char response[41], char chksum[9],
> +                                  const char *challenge)
> +{
> +    int ch_len = strlen (challenge), i;
> +    unsigned char zres[16],
> +        buf[128] = { 0xa1, 0xe9, 0x14, 0x9d, 0x0e, 0x6b, 0x3b, 0x59 };
> +#define XOR_TABLE_SIZE 37
> +    const unsigned char xor_table[XOR_TABLE_SIZE] = {
> +        0x05, 0x18, 0x74, 0xd0, 0x0d, 0x09, 0x02, 0x53,
> +        0xc0, 0x01, 0x05, 0x05, 0x67, 0x03, 0x19, 0x70,
> +        0x08, 0x27, 0x66, 0x10, 0x10, 0x72, 0x08, 0x09,
> +        0x63, 0x11, 0x03, 0x71, 0x08, 0x08, 0x70, 0x02,
> +        0x10, 0x57, 0x05, 0x18, 0x54 };
> +
> +    /* some (length) checks */
> +    if (ch_len == 40) /* what a hack... */
> +        ch_len = 32;
> +    else if (ch_len > 56)
> +        ch_len = 56;
> +    memcpy(buf + 8, challenge, ch_len);
> +
> +    /* xor challenge bytewise with xor_table */
> +    for (i = 0; i < XOR_TABLE_SIZE; i++)
> +        buf[8 + i] ^= xor_table[i];
> +
> +    av_md5_sum(zres, buf, 64);
> +    ff_data_to_hex(response, zres, 16);
> +
> +    /* add tail */
> +    strcpy (response + 32, "01d0a8e3");
> +
> +    /* calculate checksum */
> +    for (i = 0; i < 8; i++)
> +        chksum[i] = response[i * 4];
> +    chksum[8] = 0;
> +}

ok

> Index: ffmpeg-svn/libavformat/rtp_internal.h
> ===================================================================
> --- ffmpeg-svn.orig/libavformat/rtp_internal.h	2008-08-24 21:34:30.000000000 -0400
> +++ ffmpeg-svn/libavformat/rtp_internal.h	2008-08-24 21:57:39.000000000 -0400
> @@ -146,5 +146,20 @@
>  
>  void av_register_rtp_dynamic_payload_handlers(void);
>  
> +/**
> + * Calculate the response (RealChallenge2 in the RTSP header) to the
> + * challenge (RealChallenge1 in the RTSP header from the Real/Helix
> + * server), which is used as some sort of client validation.
> + *
> + * @param response pointer to response buffer, it should be at least 41 bytes
> + *                 (40 data + 1 zero) bytes long.
> + * @param chksum pointer to buffer containing a checksum of the response,
> + *               it should be at least 9 (8 data + 1 zero) bytes long.
> + * @param challenge pointer to the RealChallenge1 value provided by the
> + *                  server.
> + */

> +void ff_rdt_calc_response_and_checksum(char *response, char *chksum,
> +                                       const char *challenge);

the array sizes are missing

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Asymptotically faster algorithms should always be preferred if you have
asymptotical amounts of data
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080826/285b44ca/attachment.pgp>



More information about the ffmpeg-devel mailing list