| 837 | } |
| 838 | |
| 839 | static int rm_read_packet(AVFormatContext *s, AVPacket *pkt) |
| 840 | { |
| 841 | RMDemuxContext *rm = s->priv_data; |
| 842 | AVStream *st; |
| 843 | int i, len, res, seq = 1; |
| 844 | int64_t timestamp, pos; |
| 845 | int flags; |
| 846 | |
| 847 | for (;;) { |
| 848 | if (rm->audio_pkt_cnt) { |
| 849 | // If there are queued audio packet return them first |
| 850 | st = s->streams[rm->audio_stream_num]; |
| 851 | ff_rm_retrieve_cache(s, s->pb, st, st->priv_data, pkt); |
| 852 | flags = 0; |
| 853 | } else { |
| 854 | if (rm->old_format) { |
| 855 | RMStream *ast; |
| 856 | |
| 857 | st = s->streams[0]; |
| 858 | ast = st->priv_data; |
| 859 | timestamp = AV_NOPTS_VALUE; |
| 860 | len = !ast->audio_framesize ? RAW_PACKET_SIZE : |
| 861 | ast->coded_framesize * ast->sub_packet_h / 2; |
| 862 | flags = (seq++ == 1) ? 2 : 0; |
| 863 | pos = url_ftell(s->pb); |
| 864 | } else { |
| 865 | len=sync(s, ×tamp, &flags, &i, &pos); |
| 866 | if (len > 0) |
| 867 | st = s->streams[i]; |
| 868 | } |
| 869 | |
| 870 | if(len<0 || url_feof(s->pb)) |
| 871 | return AVERROR(EIO); |
| 872 | |
| 873 | res = ff_rm_parse_packet (s, s->pb, st, st->priv_data, len, pkt, |
| 874 | &seq, flags, timestamp); |
| 875 | if((flags&2) && (seq&0x7F) == 1) |
| 876 | av_add_index_entry(st, pos, timestamp, 0, 0, AVINDEX_KEYFRAME); |
| 877 | if (res) |
| 878 | continue; |
| 879 | } |
| 880 | |
| 881 | if( (st->discard >= AVDISCARD_NONKEY && !(flags&2)) |
| 882 | || st->discard >= AVDISCARD_ALL){ |
| 883 | av_free_packet(pkt); |
| 884 | } else |
| 885 | break; |
| 886 | } |
| 887 | |
| 888 | return 0; |
| 889 | } |
| 890 | |
| 891 | static int rm_read_close(AVFormatContext *s) |
| 892 | { |
nothing calls this directly
no test coverage detected