Revision 4ffff367

View differences:

libavformat/rtpdec.c
471 471
    if (!st) {
472 472
        /* specific MPEG2TS demux support */
473 473
        ret = ff_mpegts_parse_packet(s->ts, pkt, buf, len);
474
        if (ret < 0) {
475
            s->prev_ret = -1;
474
        if (ret < 0)
476 475
            return -1;
477
        }
478 476
        if (ret < len) {
479 477
            s->read_buf_size = len - ret;
480 478
            memcpy(s->buf, buf + ret, s->read_buf_size);
481 479
            s->read_buf_index = 0;
482
            s->prev_ret = 1;
483 480
            return 1;
484 481
        }
485
        s->prev_ret = 0;
486 482
        return 0;
487 483
    } else if (s->parse_packet) {
488 484
        rv = s->parse_packet(s->ic, s->dynamic_protocol_context,
......
531 527
    // now perform timestamp things....
532 528
    finalize_packet(s, pkt, timestamp);
533 529

  
534
    s->prev_ret = rv;
535 530
    return rv;
536 531
}
537 532

  
......
606 601
    av_free(s->queue);
607 602
    s->queue = next;
608 603
    s->queue_len--;
609
    return rv ? rv : has_next_packet(s);
604
    return rv;
610 605
}
611 606

  
612
/**
613
 * Parse an RTP or RTCP packet directly sent as a buffer.
614
 * @param s RTP parse context.
615
 * @param pkt returned packet
616
 * @param bufptr pointer to the input buffer or NULL to read the next packets
617
 * @param len buffer len
618
 * @return 0 if a packet is returned, 1 if a packet is returned and more can follow
619
 * (use buf as NULL to read the next). -1 if no packet (error or no more packet).
620
 */
621
int rtp_parse_packet(RTPDemuxContext *s, AVPacket *pkt,
607
static int rtp_parse_one_packet(RTPDemuxContext *s, AVPacket *pkt,
622 608
                     uint8_t **bufptr, int len)
623 609
{
624 610
    uint8_t* buf = bufptr ? *bufptr : NULL;
......
640 626
            rv= s->parse_packet(s->ic, s->dynamic_protocol_context,
641 627
                                s->st, pkt, &timestamp, NULL, 0, flags);
642 628
            finalize_packet(s, pkt, timestamp);
643
            s->prev_ret = rv;
644
            return rv ? rv : has_next_packet(s);
629
            return rv;
645 630
        } else {
646 631
            // TODO: Move to a dynamic packet handler (like above)
647
            if (s->read_buf_index >= s->read_buf_size) {
648
                s->prev_ret = -1;
632
            if (s->read_buf_index >= s->read_buf_size)
649 633
                return -1;
650
            }
651 634
            ret = ff_mpegts_parse_packet(s->ts, pkt, s->buf + s->read_buf_index,
652 635
                                      s->read_buf_size - s->read_buf_index);
653
            if (ret < 0) {
654
                s->prev_ret = -1;
636
            if (ret < 0)
655 637
                return -1;
656
            }
657 638
            s->read_buf_index += ret;
658 639
            if (s->read_buf_index < s->read_buf_size)
659 640
                return 1;
660
            else {
661
                s->prev_ret = 0;
662
                return has_next_packet(s);
663
            }
641
            else
642
                return 0;
664 643
        }
665 644
    }
666 645

  
......
687 666
        } else if (diff <= 1) {
688 667
            /* Correct packet */
689 668
            rv = rtp_parse_packet_internal(s, pkt, buf, len);
690
            return rv ? rv : has_next_packet(s);
669
            return rv;
691 670
        } else {
692 671
            /* Still missing some packet, enqueue this one. */
693 672
            enqueue_packet(s, buf, len);
......
701 680
    }
702 681
}
703 682

  
683
/**
684
 * Parse an RTP or RTCP packet directly sent as a buffer.
685
 * @param s RTP parse context.
686
 * @param pkt returned packet
687
 * @param bufptr pointer to the input buffer or NULL to read the next packets
688
 * @param len buffer len
689
 * @return 0 if a packet is returned, 1 if a packet is returned and more can follow
690
 * (use buf as NULL to read the next). -1 if no packet (error or no more packet).
691
 */
692
int rtp_parse_packet(RTPDemuxContext *s, AVPacket *pkt,
693
                     uint8_t **bufptr, int len)
694
{
695
    int rv = rtp_parse_one_packet(s, pkt, bufptr, len);
696
    s->prev_ret = rv;
697
    return rv ? rv : has_next_packet(s);
698
}
699

  
704 700
void rtp_parse_close(RTPDemuxContext *s)
705 701
{
706 702
    ff_rtp_reset_packet_queue(s);

Also available in: Unified diff