Revision 01f4895c ffserver.c

View differences:

ffserver.c
728 728
        /* close each frame parser */
729 729
        for(i=0;i<c->fmt_in->nb_streams;i++) {
730 730
            st = c->fmt_in->streams[i];
731
            if (st->codec.codec) {
732
                avcodec_close(&st->codec);
731
            if (st->codec->codec) {
732
                avcodec_close(st->codec);
733 733
            }
734 734
        }
735 735
        av_close_input_file(c->fmt_in);
......
1002 1002
    int best = -1;
1003 1003

  
1004 1004
    for (i = 0; i < feed->nb_streams; i++) {
1005
        AVCodecContext *feed_codec = &feed->streams[i]->codec;
1005
        AVCodecContext *feed_codec = feed->streams[i]->codec;
1006 1006

  
1007 1007
        if (feed_codec->codec_id != codec->codec_id ||
1008 1008
            feed_codec->sample_rate != codec->sample_rate ||
......
1044 1044
        return 0;
1045 1045

  
1046 1046
    for (i = 0; i < req->nb_streams; i++) {
1047
        AVCodecContext *codec = &req->streams[i]->codec;
1047
        AVCodecContext *codec = req->streams[i]->codec;
1048 1048

  
1049 1049
        switch(rates[i]) {
1050 1050
            case 0:
......
1659 1659

  
1660 1660
                    for(i=0;i<stream->nb_streams;i++) {
1661 1661
                        AVStream *st = stream->streams[i];
1662
                        AVCodec *codec = avcodec_find_encoder(st->codec.codec_id);
1663
                        switch(st->codec.codec_type) {
1662
                        AVCodec *codec = avcodec_find_encoder(st->codec->codec_id);
1663
                        switch(st->codec->codec_type) {
1664 1664
                        case CODEC_TYPE_AUDIO:
1665
                            audio_bit_rate += st->codec.bit_rate;
1665
                            audio_bit_rate += st->codec->bit_rate;
1666 1666
                            if (codec) {
1667 1667
                                if (*audio_codec_name)
1668 1668
                                    audio_codec_name_extra = "...";
......
1670 1670
                            }
1671 1671
                            break;
1672 1672
                        case CODEC_TYPE_VIDEO:
1673
                            video_bit_rate += st->codec.bit_rate;
1673
                            video_bit_rate += st->codec->bit_rate;
1674 1674
                            if (codec) {
1675 1675
                                if (*video_codec_name)
1676 1676
                                    video_codec_name_extra = "...";
......
1678 1678
                            }
1679 1679
                            break;
1680 1680
                        case CODEC_TYPE_DATA:
1681
                            video_bit_rate += st->codec.bit_rate;
1681
                            video_bit_rate += st->codec->bit_rate;
1682 1682
                            break;
1683 1683
                        default:
1684 1684
                            av_abort();
......
1744 1744

  
1745 1745
            for (i = 0; i < stream->nb_streams; i++) {
1746 1746
                AVStream *st = stream->streams[i];
1747
                AVCodec *codec = avcodec_find_encoder(st->codec.codec_id);
1747
                AVCodec *codec = avcodec_find_encoder(st->codec->codec_id);
1748 1748
                const char *type = "unknown";
1749 1749
                char parameters[64];
1750 1750

  
1751 1751
                parameters[0] = 0;
1752 1752

  
1753
                switch(st->codec.codec_type) {
1753
                switch(st->codec->codec_type) {
1754 1754
                case CODEC_TYPE_AUDIO:
1755 1755
                    type = "audio";
1756 1756
                    break;
1757 1757
                case CODEC_TYPE_VIDEO:
1758 1758
                    type = "video";
1759
                    snprintf(parameters, sizeof(parameters), "%dx%d, q=%d-%d, fps=%d", st->codec.width, st->codec.height,
1760
                                st->codec.qmin, st->codec.qmax, st->codec.time_base.den / st->codec.time_base.num);
1759
                    snprintf(parameters, sizeof(parameters), "%dx%d, q=%d-%d, fps=%d", st->codec->width, st->codec->height,
1760
                                st->codec->qmin, st->codec->qmax, st->codec->time_base.den / st->codec->time_base.num);
1761 1761
                    break;
1762 1762
                default:
1763 1763
                    av_abort();
1764 1764
                }
1765 1765
                url_fprintf(pb, "<tr><td align=right>%d<td>%s<td align=right>%d<td>%s<td>%s\n",
1766
                        i, type, st->codec.bit_rate/1000, codec ? codec->name : "", parameters);
1766
                        i, type, st->codec->bit_rate/1000, codec ? codec->name : "", parameters);
1767 1767
            }
1768 1768
            url_fprintf(pb, "</table>\n");
1769 1769

  
......
1786 1786
            for(i=0;i<stream->nb_streams;i++) {
1787 1787
                AVStream *st = stream->streams[i];
1788 1788
                FeedData *fdata = st->priv_data;
1789
                enc = &st->codec;
1789
                enc = st->codec;
1790 1790
            
1791 1791
                avcodec_string(buf, sizeof(buf), enc);
1792 1792
                avg = fdata->avg_frame_size * (float)enc->rate * 8.0;
......
1822 1822
        if (c1->stream) {
1823 1823
            for (j = 0; j < c1->stream->nb_streams; j++) {
1824 1824
                if (!c1->stream->feed) {
1825
                    bitrate += c1->stream->streams[j]->codec.bit_rate;
1825
                    bitrate += c1->stream->streams[j]->codec->bit_rate;
1826 1826
                } else {
1827 1827
                    if (c1->feed_streams[j] >= 0) {
1828
                        bitrate += c1->stream->feed->streams[c1->feed_streams[j]]->codec.bit_rate;
1828
                        bitrate += c1->stream->feed->streams[c1->feed_streams[j]]->codec->bit_rate;
1829 1829
                    }
1830 1830
                }
1831 1831
            }
......
1867 1867
    AVStream *st = s->streams[i];
1868 1868
    AVCodec *codec;
1869 1869

  
1870
    if (!st->codec.codec) {
1871
        codec = avcodec_find_decoder(st->codec.codec_id);
1870
    if (!st->codec->codec) {
1871
        codec = avcodec_find_decoder(st->codec->codec_id);
1872 1872
        if (codec && (codec->capabilities & CODEC_CAP_PARSE_ONLY)) {
1873
            st->codec.parse_only = 1;
1874
            if (avcodec_open(&st->codec, codec) < 0) {
1875
                st->codec.parse_only = 0;
1873
            st->codec->parse_only = 1;
1874
            if (avcodec_open(st->codec, codec) < 0) {
1875
                st->codec->parse_only = 0;
1876 1876
            }
1877 1877
        }
1878 1878
    }
......
1935 1935
    c->pts_stream_index = 0;
1936 1936
    for(i=0;i<c->stream->nb_streams;i++) {
1937 1937
        if (c->pts_stream_index == 0 && 
1938
            c->stream->streams[i]->codec.codec_type == CODEC_TYPE_VIDEO) {
1938
            c->stream->streams[i]->codec->codec_type == CODEC_TYPE_VIDEO) {
1939 1939
            c->pts_stream_index = i;
1940 1940
        }
1941 1941
    }
......
2010 2010

  
2011 2011
	    *st = *src;
2012 2012
	    st->priv_data = 0;
2013
            st->codec.frame_number = 0; /* XXX: should be done in
2013
            st->codec->frame_number = 0; /* XXX: should be done in
2014 2014
                                           AVStream, not in codec */
2015 2015
            /* I'm pretty sure that this is not correct...
2016 2016
             * However, without it, we crash
2017 2017
             */
2018
            st->codec.coded_frame = &dummy_frame;
2018
            st->codec->coded_frame = &dummy_frame;
2019 2019
        }
2020 2020
        c->got_key_frame = 0;
2021 2021

  
......
2144 2144
                              av_free_packet(&pkt);
2145 2145
                              break;
2146 2146
                            }
2147
                            codec = &ctx->streams[0]->codec;
2147
                            codec = ctx->streams[0]->codec;
2148 2148
                            /* only one stream per RTP connection */
2149 2149
                            pkt.stream_index = 0;
2150 2150
                        } else {
2151 2151
                            ctx = &c->fmt_ctx;
2152 2152
                            /* Fudge here */
2153
                            codec = &ctx->streams[pkt.stream_index]->codec;
2153
                            codec = ctx->streams[pkt.stream_index]->codec;
2154 2154
                        }
2155 2155
                        
2156 2156
                        codec->coded_frame->key_frame = ((pkt.flags & PKT_FLAG_KEY) != 0);
......
2462 2462
                goto fail;
2463 2463
            }
2464 2464
            for (i = 0; i < s.nb_streams; i++) {
2465
                memcpy(&feed->streams[i]->codec, 
2466
                       &s.streams[i]->codec, sizeof(AVCodecContext));
2465
                memcpy(feed->streams[i]->codec, 
2466
                       s.streams[i]->codec, sizeof(AVCodecContext));
2467 2467
            } 
2468 2468
            av_freep(&s.priv_data);
2469 2469
        }
......
2638 2638
    private_payload_type = RTP_PT_PRIVATE;
2639 2639
    for(i = 0; i < stream->nb_streams; i++) {
2640 2640
        st = stream->streams[i];
2641
        if (st->codec.codec_id == CODEC_ID_MPEG2TS) {
2641
        if (st->codec->codec_id == CODEC_ID_MPEG2TS) {
2642 2642
            mediatype = "video";
2643 2643
        } else {
2644
            switch(st->codec.codec_type) {
2644
            switch(st->codec->codec_type) {
2645 2645
            case CODEC_TYPE_AUDIO:
2646 2646
                mediatype = "audio";
2647 2647
                break;
......
2655 2655
        }
2656 2656
        /* NOTE: the port indication is not correct in case of
2657 2657
           unicast. It is not an issue because RTSP gives it */
2658
        payload_type = rtp_get_payload_type(&st->codec);
2658
        payload_type = rtp_get_payload_type(st->codec);
2659 2659
        if (payload_type < 0)
2660 2660
            payload_type = private_payload_type++;
2661 2661
        if (stream->is_multicast) {
......
2667 2667
                    mediatype, port, payload_type);
2668 2668
        if (payload_type >= RTP_PT_PRIVATE) {
2669 2669
            /* for private payload type, we need to give more info */
2670
            switch(st->codec.codec_id) {
2670
            switch(st->codec->codec_id) {
2671 2671
            case CODEC_ID_MPEG4:
2672 2672
                {
2673 2673
                    uint8_t *data;
2674 2674
                    url_fprintf(pb, "a=rtpmap:%d MP4V-ES/%d\n", 
2675 2675
                                payload_type, 90000);
2676 2676
                    /* we must also add the mpeg4 header */
2677
                    data = st->codec.extradata;
2677
                    data = st->codec->extradata;
2678 2678
                    if (data) {
2679 2679
                        url_fprintf(pb, "a=fmtp:%d config=", payload_type);
2680
                        for(j=0;j<st->codec.extradata_size;j++) {
2680
                        for(j=0;j<st->codec->extradata_size;j++) {
2681 2681
                            url_fprintf(pb, "%02x", data[j]);
2682 2682
                        }
2683 2683
                        url_fprintf(pb, "\n");
......
3222 3222
    if (!fst)
3223 3223
        return NULL;
3224 3224
    fst->priv_data = av_mallocz(sizeof(FeedData));
3225
    memcpy(&fst->codec, codec, sizeof(AVCodecContext));
3226
    fst->codec.coded_frame = &dummy_frame;
3225
    memcpy(fst->codec, codec, sizeof(AVCodecContext));
3226
    fst->codec->coded_frame = &dummy_frame;
3227 3227
    fst->index = stream->nb_streams;
3228 3228
    av_set_pts_info(fst, 33, 1, 90000);
3229 3229
    stream->streams[stream->nb_streams++] = fst;
......
3237 3237
    AVCodecContext *av, *av1;
3238 3238
    int i;
3239 3239

  
3240
    av = &st->codec;
3240
    av = st->codec;
3241 3241
    for(i=0;i<feed->nb_streams;i++) {
3242 3242
        st = feed->streams[i];
3243
        av1 = &st->codec;
3243
        av1 = st->codec;
3244 3244
        if (av1->codec_id == av->codec_id &&
3245 3245
            av1->codec_type == av->codec_type &&
3246 3246
            av1->bit_rate == av->bit_rate) {
......
3297 3297
    mpeg4_count = 0;
3298 3298
    for(i=0;i<infile->nb_streams;i++) {
3299 3299
        st = infile->streams[i];
3300
        if (st->codec.codec_id == CODEC_ID_MPEG4 &&
3301
            st->codec.extradata_size == 0) {
3300
        if (st->codec->codec_id == CODEC_ID_MPEG4 &&
3301
            st->codec->extradata_size == 0) {
3302 3302
            mpeg4_count++;
3303 3303
        }
3304 3304
    }
......
3310 3310
        if (av_read_packet(infile, &pkt) < 0)
3311 3311
            break;
3312 3312
        st = infile->streams[pkt.stream_index];
3313
        if (st->codec.codec_id == CODEC_ID_MPEG4 &&
3314
            st->codec.extradata_size == 0) {
3315
            av_freep(&st->codec.extradata);
3313
        if (st->codec->codec_id == CODEC_ID_MPEG4 &&
3314
            st->codec->extradata_size == 0) {
3315
            av_freep(&st->codec->extradata);
3316 3316
            /* fill extradata with the header */
3317 3317
            /* XXX: we make hard suppositions here ! */
3318 3318
            p = pkt.data;
......
3322 3322
                    p[2] == 0x01 && p[3] == 0xb6) {
3323 3323
                    size = p - pkt.data;
3324 3324
                    //                    av_hex_dump(pkt.data, size);
3325
                    st->codec.extradata = av_malloc(size);
3326
                    st->codec.extradata_size = size;
3327
                    memcpy(st->codec.extradata, pkt.data, size);
3325
                    st->codec->extradata = av_malloc(size);
3326
                    st->codec->extradata_size = size;
3327
                    memcpy(st->codec->extradata, pkt.data, size);
3328 3328
                    break;
3329 3329
                }
3330 3330
                p++;
......
3376 3376
                extract_mpeg4_header(infile);
3377 3377

  
3378 3378
                for(i=0;i<infile->nb_streams;i++) {
3379
                    add_av_stream1(stream, &infile->streams[i]->codec);
3379
                    add_av_stream1(stream, infile->streams[i]->codec);
3380 3380
                }
3381 3381
                av_close_input_file(infile);
3382 3382
            }
......
3441 3441
                        } else {
3442 3442
                            AVCodecContext *ccf, *ccs;
3443 3443

  
3444
                            ccf = &sf->codec;
3445
                            ccs = &ss->codec;
3444
                            ccf = sf->codec;
3445
                            ccs = ss->codec;
3446 3446
#define CHECK_CODEC(x)  (ccf->x != ccs->x)
3447 3447

  
3448 3448
                            if (CHECK_CODEC(codec) || CHECK_CODEC(codec_type)) {
......
3550 3550
        bandwidth = 0;
3551 3551
        for(i=0;i<stream->nb_streams;i++) {
3552 3552
            AVStream *st = stream->streams[i];
3553
            switch(st->codec.codec_type) {
3553
            switch(st->codec->codec_type) {
3554 3554
            case CODEC_TYPE_AUDIO:
3555 3555
            case CODEC_TYPE_VIDEO:
3556
                bandwidth += st->codec.bit_rate;
3556
                bandwidth += st->codec->bit_rate;
3557 3557
                break;
3558 3558
            default:
3559 3559
                break;
......
3665 3665
    if (!st)
3666 3666
        return;
3667 3667
    stream->streams[stream->nb_streams++] = st;
3668
    memcpy(&st->codec, av, sizeof(AVCodecContext));
3668
    memcpy(st->codec, av, sizeof(AVCodecContext));
3669 3669
}
3670 3670

  
3671 3671
static int opt_audio_codec(const char *arg)

Also available in: Unified diff