~ubuntu-branches/ubuntu/maverick/ffmpeg/maverick-security

« back to all changes in this revision

Viewing changes to ffserver.c

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2010-06-16 12:53:24 UTC
  • mfrom: (1.1.13 upstream)
  • Revision ID: james.westby@ubuntu.com-20100616125324-kbhhjn7012ufc79t
Tags: 4:0.6-1ubuntu1
* merge from debian/experimental. remaining changes:
  - don't disable encoders
  - don't build against libfaad, libdirac and libopenjpeg (all in universe)
* new upstream release
  - internal vorbis encoder is disabled. LP: #585330
  - includes native AMR-NB decoder, LP: #93849
  - api-example is fixed: LP: #557319

Show diffs side-by-side

added added

removed removed

Lines of Context:
847
847
        ctx = c->rtp_ctx[i];
848
848
        if (ctx) {
849
849
            av_write_trailer(ctx);
 
850
            av_metadata_free(&ctx->metadata);
 
851
            av_free(ctx->streams[0]);
850
852
            av_free(ctx);
851
853
        }
852
854
        h = c->rtp_handles[i];
2280
2282
            http_log("Error writing output header\n");
2281
2283
            return -1;
2282
2284
        }
 
2285
        av_metadata_free(&c->fmt_ctx.metadata);
2283
2286
 
2284
2287
        len = url_close_dyn_buf(c->fmt_ctx.pb, &c->pb_buffer);
2285
2288
        c->buffer_ptr = c->pb_buffer;
2343
2346
                        }
2344
2347
                    }
2345
2348
                    for(i=0;i<c->stream->nb_streams;i++) {
2346
 
                        if (c->feed_streams[i] == pkt.stream_index) {
 
2349
                        if (c->stream->feed_streams[i] == pkt.stream_index) {
2347
2350
                            AVStream *st = c->fmt_in->streams[source_index];
2348
2351
                            pkt.stream_index = i;
2349
2352
                            if (pkt.flags & AV_PKT_FLAG_KEY &&
2879
2882
    if (*p == '\n')
2880
2883
        p++;
2881
2884
    while (*p != '\0') {
2882
 
        p1 = strchr(p, '\n');
 
2885
        p1 = memchr(p, '\n', (char *)c->buffer_ptr - p);
2883
2886
        if (!p1)
2884
2887
            break;
2885
2888
        p2 = p1;
2946
2949
        snprintf(avc->filename, 1024, "rtp://%s:%d?multicast=1?ttl=%d",
2947
2950
                 inet_ntoa(stream->multicast_ip),
2948
2951
                 stream->multicast_port, stream->multicast_ttl);
 
2952
    } else {
 
2953
        snprintf(avc->filename, 1024, "rtp://0.0.0.0");
2949
2954
    }
2950
2955
 
2951
2956
    for(i = 0; i < stream->nb_streams; i++) {
2954
2959
    }
2955
2960
    *pbuffer = av_mallocz(2048);
2956
2961
    avf_sdp_create(&avc, 1, *pbuffer, 2048);
 
2962
    av_metadata_free(&avc->metadata);
2957
2963
    av_free(avc);
2958
2964
 
2959
2965
    return strlen(*pbuffer);
3006
3012
        return;
3007
3013
    }
3008
3014
    rtsp_reply_header(c, RTSP_STATUS_OK);
 
3015
    url_fprintf(c->pb, "Content-Base: %s/\r\n", url);
3009
3016
    url_fprintf(c->pb, "Content-Type: application/sdp\r\n");
3010
3017
    url_fprintf(c->pb, "Content-Length: %d\r\n", content_length);
3011
3018
    url_fprintf(c->pb, "\r\n");
3012
3019
    put_buffer(c->pb, content, content_length);
 
3020
    av_free(content);
3013
3021
}
3014
3022
 
3015
3023
static HTTPContext *find_rtp_session(const char *session_id)
3376
3384
    st = av_mallocz(sizeof(AVStream));
3377
3385
    if (!st)
3378
3386
        goto fail;
3379
 
    st->codec= avcodec_alloc_context();
3380
3387
    ctx->nb_streams = 1;
3381
3388
    ctx->streams[0] = st;
3382
3389
 
3452
3459
/********************************************************************/
3453
3460
/* ffserver initialization */
3454
3461
 
3455
 
static AVStream *add_av_stream1(FFStream *stream, AVCodecContext *codec)
 
3462
static AVStream *add_av_stream1(FFStream *stream, AVCodecContext *codec, int copy)
3456
3463
{
3457
3464
    AVStream *fst;
3458
3465
 
3459
3466
    fst = av_mallocz(sizeof(AVStream));
3460
3467
    if (!fst)
3461
3468
        return NULL;
3462
 
    fst->codec= avcodec_alloc_context();
 
3469
    if (copy) {
 
3470
        fst->codec= avcodec_alloc_context();
 
3471
        memcpy(fst->codec, codec, sizeof(AVCodecContext));
 
3472
        if (codec->extradata_size) {
 
3473
            fst->codec->extradata = av_malloc(codec->extradata_size);
 
3474
            memcpy(fst->codec->extradata, codec->extradata,
 
3475
                codec->extradata_size);
 
3476
        }
 
3477
    } else {
 
3478
        /* live streams must use the actual feed's codec since it may be
 
3479
         * updated later to carry extradata needed by the streams.
 
3480
         */
 
3481
        fst->codec = codec;
 
3482
    }
3463
3483
    fst->priv_data = av_mallocz(sizeof(FeedData));
3464
 
    memcpy(fst->codec, codec, sizeof(AVCodecContext));
3465
3484
    fst->index = stream->nb_streams;
3466
3485
    av_set_pts_info(fst, 33, 1, 90000);
3467
3486
    stream->streams[stream->nb_streams++] = fst;
3503
3522
        }
3504
3523
    }
3505
3524
 
3506
 
    fst = add_av_stream1(feed, av);
 
3525
    fst = add_av_stream1(feed, av, 0);
3507
3526
    if (!fst)
3508
3527
        return -1;
3509
3528
    return feed->nb_streams - 1;
3614
3633
                extract_mpeg4_header(infile);
3615
3634
 
3616
3635
                for(i=0;i<infile->nb_streams;i++)
3617
 
                    add_av_stream1(stream, infile->streams[i]->codec);
 
3636
                    add_av_stream1(stream, infile->streams[i]->codec, 1);
3618
3637
 
3619
3638
                av_close_input_file(infile);
3620
3639
            }
3681
3700
                            ccs = ss->codec;
3682
3701
#define CHECK_CODEC(x)  (ccf->x != ccs->x)
3683
3702
 
3684
 
                            if (CHECK_CODEC(codec) || CHECK_CODEC(codec_type)) {
 
3703
                            if (CHECK_CODEC(codec_id) || CHECK_CODEC(codec_type)) {
3685
3704
                                http_log("Codecs do not match for stream %d\n", i);
3686
3705
                                matches = 0;
3687
3706
                            } else if (CHECK_CODEC(bit_rate) || CHECK_CODEC(flags)) {