Revision 886e89d0

View differences:

libavformat/rdt.c
81 81

  
82 82
struct PayloadContext {
83 83
    AVFormatContext *rmctx;
84
    RMStream *rmst[MAX_STREAMS];
84 85
    uint8_t *mlti_data;
85 86
    unsigned int mlti_data_size;
86 87
    char buffer[RTP_MAX_PACKET_LENGTH + FF_INPUT_BUFFER_PADDING_SIZE];
......
174 175
        size = rdt->mlti_data_size;
175 176
        url_fseek(&pb, 0, SEEK_SET);
176 177
    }
177
    if (ff_rm_read_mdpr_codecdata(rdt->rmctx, &pb, st, size) < 0)
178
    if (ff_rm_read_mdpr_codecdata(rdt->rmctx, &pb, st, rdt->rmst[0], size) < 0)
178 179
        return -1;
179 180

  
180 181
    return 0;
......
301 302

  
302 303
        init_put_byte(&pb, buf, len, 0, NULL, NULL, NULL, NULL);
303 304
        flags = (flags & PKT_FLAG_KEY) ? 2 : 0;
304
        res = ff_rm_parse_packet (rdt->rmctx, &pb, st, len, pkt,
305
        res = ff_rm_parse_packet (rdt->rmctx, &pb, st, rdt->rmst[0], len, pkt,
305 306
                                  &seq, &flags, timestamp);
306 307
        pos = url_ftell(&pb);
307 308
        if (res < 0)
......
314 315
                                                NULL, NULL, NULL, NULL);
315 316
        }
316 317
    } else {
317
        ff_rm_retrieve_cache (rdt->rmctx, rdt->rmctx->pb, st, pkt);
318
        ff_rm_retrieve_cache (rdt->rmctx, rdt->rmctx->pb, st, rdt->rmst[0], pkt);
318 319
        if (rdt->audio_pkt_cnt[st->id] == 0 &&
319 320
            st->codec->codec_id == CODEC_ID_AAC)
320 321
            av_freep(&rdt->rmctx->pb);
......
426 427
    PayloadContext *rdt = av_mallocz(sizeof(PayloadContext));
427 428

  
428 429
    av_open_input_stream(&rdt->rmctx, NULL, "", &rdt_demuxer, NULL);
430
    rdt->rmst[0] = ff_rm_alloc_rmstream();
429 431

  
430 432
    return rdt;
431 433
}
......
433 435
static void
434 436
rdt_free_extradata (PayloadContext *rdt)
435 437
{
438
    ff_rm_free_rmstream(rdt->rmst[0]);
436 439
    if (rdt->rmctx)
437 440
        av_close_input_stream(rdt->rmctx);
438 441
    av_freep(&rdt->mlti_data);
libavformat/rm.h
40 40
 * @param pb context to read the data from
41 41
 * @param st the stream that the MDPR chunk belongs to and where to store the
42 42
 *           parameters read from the chunk into
43
 * @param rst real-specific stream information
43 44
 * @param codec_data_size size of the MDPR chunk
44 45
 * @return 0 on success, errno codes on error
45 46
 */
46 47
int ff_rm_read_mdpr_codecdata (AVFormatContext *s, ByteIOContext *pb,
47
                               AVStream *st, int codec_data_size);
48
                               AVStream *st, RMStream *rst,
49
                               int codec_data_size);
48 50

  
49 51
/**
50 52
 * Parse one rm-stream packet from the input bytestream.
......
52 54
 * @param s context containing RMContext and ByteIOContext for stream reading
53 55
 * @param pb context to read the data from
54 56
 * @param st stream to which the packet to be read belongs
57
 * @param rst Real-specific stream information
55 58
 * @param len packet length to read from the input
56 59
 * @param pkt packet location to store the parsed packet data
57 60
 * @param seq pointer to an integer containing the sequence number, may be
......
64 67
 *         errno codes on error
65 68
 */
66 69
int ff_rm_parse_packet (AVFormatContext *s, ByteIOContext *pb,
67
                        AVStream *st, int len,
70
                        AVStream *st, RMStream *rst, int len,
68 71
                        AVPacket *pkt, int *seq, int *flags, int64_t *ts);
69 72

  
70 73
/**
......
78 81
 * @param s context containing RMContext and ByteIOContext for stream reading
79 82
 * @param pb context to read the data from
80 83
 * @param st stream that this packet belongs to
84
 * @param rst Real-specific stream information
81 85
 * @param pkt location to store the packet data
82 86
 */
83 87
void ff_rm_retrieve_cache (AVFormatContext *s, ByteIOContext *pb,
84
                           AVStream *st, AVPacket *pkt);
88
                           AVStream *st, RMStream *rst, AVPacket *pkt);
85 89

  
86 90
#endif /* AVFORMAT_RM_H */
libavformat/rmdec.c
87 87
}
88 88

  
89 89
static int rm_read_audio_stream_info(AVFormatContext *s, ByteIOContext *pb,
90
                                     AVStream *st, int read_all)
90
                                     AVStream *st, RMStream *ast, int read_all)
91 91
{
92
    RMStream *ast = st->priv_data;
93 92
    char buf[256];
94 93
    uint32_t version;
95 94

  
......
228 227

  
229 228
int
230 229
ff_rm_read_mdpr_codecdata (AVFormatContext *s, ByteIOContext *pb,
231
                           AVStream *st, int codec_data_size)
230
                           AVStream *st, RMStream *rst, int codec_data_size)
232 231
{
233 232
    unsigned int v;
234 233
    int size;
235 234
    int64_t codec_pos;
236
    RMStream *rst;
237 235

  
238
    st->priv_data = rst = ff_rm_alloc_rmstream();
239 236
    av_set_pts_info(st, 64, 1, 1000);
240 237
    codec_pos = url_ftell(pb);
241 238
    v = get_be32(pb);
242 239
    if (v == MKTAG(0xfd, 'a', 'r', '.')) {
243 240
        /* ra type header */
244
        if (rm_read_audio_stream_info(s, pb, st, 0))
241
        if (rm_read_audio_stream_info(s, pb, st, rst, 0))
245 242
            return -1;
246 243
    } else {
247 244
        int fps, fps2;
......
308 305
    st = av_new_stream(s, 0);
309 306
    if (!st)
310 307
        return -1;
311
    return rm_read_audio_stream_info(s, s->pb, st, 1);
308
    st->priv_data = ff_rm_alloc_rmstream();
309
    return rm_read_audio_stream_info(s, s->pb, st, st->priv_data, 1);
312 310
}
313 311

  
314 312
static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap)
......
390 388
            get_str8(pb, buf, sizeof(buf)); /* desc */
391 389
            get_str8(pb, buf, sizeof(buf)); /* mimetype */
392 390
            st->codec->codec_type = CODEC_TYPE_DATA;
393
            if (ff_rm_read_mdpr_codecdata(s, s->pb, st, get_be32(pb)) < 0)
391
            st->priv_data = ff_rm_alloc_rmstream();
392
            if (ff_rm_read_mdpr_codecdata(s, s->pb, st, st->priv_data,
393
                                          get_be32(pb)) < 0)
394 394
                return -1;
395 395
            break;
396 396
        case MKTAG('D', 'A', 'T', 'A'):
......
584 584

  
585 585
int
586 586
ff_rm_parse_packet (AVFormatContext *s, ByteIOContext *pb,
587
                    AVStream *st, int len, AVPacket *pkt,
587
                    AVStream *st, RMStream *ast, int len, AVPacket *pkt,
588 588
                    int *seq, int *flags, int64_t *timestamp)
589 589
{
590 590
    RMDemuxContext *rm = s->priv_data;
591 591

  
592 592
    if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
593 593
        rm->current_stream= st->id;
594
        if(rm_assemble_video_frame(s, pb, rm, st->priv_data, pkt, len) == 1)
594
        if(rm_assemble_video_frame(s, pb, rm, ast, pkt, len) == 1)
595 595
            return -1; //got partial frame
596 596
    } else if (st->codec->codec_type == CODEC_TYPE_AUDIO) {
597
        RMStream *ast = st->priv_data;
598

  
599 597
        if ((st->codec->codec_id == CODEC_ID_RA_288) ||
600 598
            (st->codec->codec_id == CODEC_ID_COOK) ||
601 599
            (st->codec->codec_id == CODEC_ID_ATRAC3) ||
......
685 683

  
686 684
void
687 685
ff_rm_retrieve_cache (AVFormatContext *s, ByteIOContext *pb,
688
                      AVStream *st, AVPacket *pkt)
686
                      AVStream *st, RMStream *ast, AVPacket *pkt)
689 687
{
690 688
    RMDemuxContext *rm = s->priv_data;
691
    RMStream *ast = st->priv_data;
692 689

  
693 690
    assert (rm->audio_pkt_cnt > 0);
694 691

  
......
717 714
    if (rm->audio_pkt_cnt) {
718 715
        // If there are queued audio packet return them first
719 716
        st = s->streams[rm->audio_stream_num];
720
        ff_rm_retrieve_cache(s, s->pb, st, pkt);
717
        ff_rm_retrieve_cache(s, s->pb, st, st->priv_data, pkt);
721 718
    } else if (rm->old_format) {
722 719
        RMStream *ast;
723 720

  
......
756 753
            return AVERROR(EIO);
757 754
        st = s->streams[i];
758 755

  
759
        if (ff_rm_parse_packet (s, s->pb, st, len, pkt, &seq, &flags, &timestamp) < 0)
756
        if (ff_rm_parse_packet (s, s->pb, st, st->priv_data, len, pkt,
757
                                &seq, &flags, &timestamp) < 0)
760 758
            goto resync;
761 759

  
762 760
        if((flags&2) && (seq&0x7F) == 1)

Also available in: Unified diff