[FFmpeg-devel] [patch]add mmsh protocol and extract common code for mmst.c

zhentan feng spyfeng
Thu Aug 19 17:55:40 CEST 2010


Hi

On Thu, Aug 19, 2010 at 1:55 AM, Stefano Sabatini <
stefano.sabatini-lala at poste.it> wrote:

> On date Thursday 2010-08-19 00:49:22 +0800, zhentan feng encoded:
> [...]
> [...]
>
> > +                        dprintf(NULL, "Header len changed form %d to
> %d\n",
>
> form -> from
>
>
fixed.


> [...]
>
> > +        av_log(NULL, AV_LOG_ERROR, "Get http header data fialed!\n");
>
> fialed -> failed
>
>
fixed.


> > +        goto fail;
> > +    }
> > +
> > +    // close the socket and then reopen it for sending the second play
> request.
> > +    url_close(mms->mms_hd);
> > +    memset(headers, 0, sizeof(headers));
> > +    if (url_alloc(&mms->mms_hd, httpname, URL_RDONLY) < 0) {
> > +        return AVERROR(EIO);
> > +    }
> > +    stream_selection = av_mallocz(mms->stream_num * 19 + 1);
> > +    if (!stream_selection)
> > +        return AVERROR(ENOMEM);
> > +    for (i = 0; i < mms->stream_num; i++) {
> > +        char tmp[20];
>
> > +        err = snprintf(tmp, sizeof(tmp),
> > +                          "ffff:%d:0 ", mms->streams[i].id);
>
> strange indent
>
>
modified into one line.


>  > +        if (err < 0)
> > +            goto fail;
> > +        av_strlcat(stream_selection, tmp, mms->stream_num * 19 + 1);
> > +    }
> > +    // send play request
> > +    err = snprintf(headers, sizeof(headers),
> > +        "Accept: */*\r\n"
> > +        USERAGENT
> > +        "Host: %s:%d\r\n"
> > +        "Pragma: no-cache,rate=1.000000,request-context=%u\r\n"
> > +        "Pragma: xPlayStrm=1\r\n"
> > +        CLIENTGUID
> > +        "Pragma: stream-switch-count=%d\r\n"
> > +        "Pragma: stream-switch-entry=%s\r\n"
> > +        "Connection: Close\r\n\r\n",
> > +        host, port, mmsh->request_seq++, mms->stream_num,
> stream_selection);
> > +    av_freep(&stream_selection);
> > +    if (err < 0) {
> > +        av_log(NULL, AV_LOG_ERROR, "Build play request failed!\n");
> > +        goto fail;
> > +    }
> > +    dprintf(NULL, "out_buffer is %s", headers);
> > +    ff_http_set_headers(mms->mms_hd, headers);
> > +
> > +    err = url_connect(mms->mms_hd);
> > +    if (err) {
> > +          goto fail;
> > +    }
> > +
> > +    err = get_http_header_data(mmsh);
> > +    if (err) {
> > +        av_log(NULL, AV_LOG_ERROR, "Get http header data failed!\n");
> > +        goto fail;
> > +    }
> > +
> > +    dprintf(NULL, "Open connection successfully.\n");
>
> Connection succesfully open
>
> No need for the terminating point (inconsistent with the other messages).
>
>
changed.


>
> > +    return 0;
> > +fail:
> > +    av_freep(&stream_selection);
> > +    mmsh_close(h);
> > +    dprintf(NULL, "Open connection failed! (error = %d)\n", err);
>
> Connection failed with error %d
>
> sounds better to my non-native ears.
>
> > +    return err;
> > +}
> > +
> > +static int handle_chunk_type(MMSHContext *mmsh)
> > +{
> > +    MMSContext *mms = &mmsh->mms;
> > +    int res, len = 0;
> > +    ChunkType chunk_type;
> > +    chunk_type = get_chunk_header(mmsh, &len);
> > +
> > +    switch (chunk_type) {
> > +    case CHUNK_TYPE_END:
> > +        mmsh->chunk_seq = 0;
> > +        av_log(NULL, AV_LOG_ERROR, "The stream is end.\n");
>
> Stream ended
>
> BTW why are you using a NULL context? Would be possible to use a
> context associated with the protocol? (IIRC rtmp.c already does that.)
>
>
changed.


> > +URLProtocol mmsh_protocol = {
> > +    "mmsh",
> > +    mmsh_open,
> > +    mmsh_read,
> > +    NULL, // write
> > +    NULL, // seek
> > +    mmsh_close,
>
> .FIELD = VALUE
>
> And please add a protocols.texi entry, @section rtmp should provide a
> good template.
>
>
>
added.

please see the new patch.
zhentan
-- 
Best wishes~
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mmsh_819.patch
Type: application/octet-stream
Size: 14173 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100819/99967f8f/attachment.obj>



More information about the ffmpeg-devel mailing list