*/
/**
- * @file rdt.c
+ * @file libavformat/rdt.c
* @brief Realmedia RTSP protocol (RDT) support
* @author Ronald S. Bultje <rbultje@ronald.bitfreak.net>
*/
#include "avformat.h"
#include "libavutil/avstring.h"
-#include "rtp.h"
+#include "rtpdec.h"
#include "rdt.h"
#include "libavutil/base64.h"
#include "libavutil/md5.h"
#include "rm.h"
#include "internal.h"
-#include "libavcodec/bitstream.h"
+#include "libavcodec/get_bits.h"
struct RDTDemuxContext {
AVFormatContext *ic; /**< the containing (RTSP) demux context */
/**< return 0 on packet, no more left, 1 on packet, 1 on partial packet... */
static int
-rdt_parse_packet (PayloadContext *rdt, AVStream *st,
+rdt_parse_packet (AVFormatContext *ctx, PayloadContext *rdt, AVStream *st,
AVPacket *pkt, uint32_t *timestamp,
const uint8_t *buf, int len, int flags)
{
int pos;
init_put_byte(&pb, buf, len, 0, NULL, NULL, NULL, NULL);
- flags = (flags & PKT_FLAG_KEY) ? 2 : 0;
+ flags = (flags & RTP_FLAG_KEY) ? 2 : 0;
res = ff_rm_parse_packet (rdt->rmctx, &pb, st, rdt->rmst[st->index], len, pkt,
&seq, &flags, timestamp);
pos = url_ftell(&pb);
if (res < 0)
return res;
- rdt->audio_pkt_cnt = res;
- if (rdt->audio_pkt_cnt > 0 &&
- st->codec->codec_id == CODEC_ID_AAC) {
- memcpy (rdt->buffer, buf + pos, len - pos);
- rdt->rmctx->pb = av_alloc_put_byte (rdt->buffer, len - pos, 0,
- NULL, NULL, NULL, NULL);
+ if (res > 0) {
+ if (st->codec->codec_id == CODEC_ID_AAC) {
+ memcpy (rdt->buffer, buf + pos, len - pos);
+ rdt->rmctx->pb = av_alloc_put_byte (rdt->buffer, len - pos, 0,
+ NULL, NULL, NULL, NULL);
+ }
+ goto get_cache;
}
} else {
+get_cache:
rdt->audio_pkt_cnt =
ff_rm_retrieve_cache (rdt->rmctx, rdt->rmctx->pb,
st, rdt->rmst[st->index], pkt);
if (!buf && s->prev_stream_id != -1) {
/* return the next packets, if any */
timestamp= 0; ///< Should not be used if buf is NULL, but should be set to the timestamp of the packet returned....
- rv= s->parse_packet(s->dynamic_protocol_context,
+ rv= s->parse_packet(s->ic, s->dynamic_protocol_context,
s->streams[s->prev_stream_id],
pkt, ×tamp, NULL, 0, flags);
return rv;
if (is_keyframe &&
(set_id != s->prev_set_id || timestamp != s->prev_timestamp ||
stream_id != s->prev_stream_id)) {
- flags |= PKT_FLAG_KEY;
+ flags |= RTP_FLAG_KEY;
s->prev_set_id = set_id;
s->prev_timestamp = timestamp;
}
return -1;
}
- rv = s->parse_packet(s->dynamic_protocol_context,
+ rv = s->parse_packet(s->ic, s->dynamic_protocol_context,
s->streams[s->prev_stream_id],
pkt, ×tamp, buf, len, flags);