]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/rdt.c
Moves the display of metadata to dump_format()
[ffmpeg] / libavformat / rdt.c
index 1b936622390daf210c61ad6350528cce8963ccc1..24ee6a993de2324331cc456e20a4503017053bd3 100644 (file)
  */
 
 /**
- * @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_internal.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 */
@@ -295,7 +295,7 @@ ff_rdt_parse_header(const uint8_t *buf, int len,
 
 /**< 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)
 {
@@ -306,20 +306,22 @@ rdt_parse_packet (PayloadContext *rdt, AVStream *st,
         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);
+                                  &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);
@@ -347,7 +349,7 @@ ff_rdt_parse_packet(RDTDemuxContext *s, AVPacket *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, &timestamp, NULL, 0, flags);
         return rv;
@@ -361,7 +363,7 @@ ff_rdt_parse_packet(RDTDemuxContext *s, AVPacket *pkt,
     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;
     }
@@ -374,7 +376,7 @@ ff_rdt_parse_packet(RDTDemuxContext *s, AVPacket *pkt,
          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, &timestamp, buf, len, flags);
 
@@ -509,7 +511,7 @@ ff_real_parse_sdp_a_line (AVFormatContext *s, int stream_index,
 }
 
 static PayloadContext *
-rdt_new_extradata (void)
+rdt_new_context (void)
 {
     PayloadContext *rdt = av_mallocz(sizeof(PayloadContext));
 
@@ -519,7 +521,7 @@ rdt_new_extradata (void)
 }
 
 static void
-rdt_free_extradata (PayloadContext *rdt)
+rdt_free_context (PayloadContext *rdt)
 {
     int i;
 
@@ -536,13 +538,13 @@ rdt_free_extradata (PayloadContext *rdt)
 
 #define RDT_HANDLER(n, s, t) \
 static RTPDynamicProtocolHandler ff_rdt_ ## n ## _handler = { \
-    s, \
-    t, \
-    CODEC_ID_NONE, \
-    rdt_parse_sdp_line, \
-    rdt_new_extradata, \
-    rdt_free_extradata, \
-    rdt_parse_packet \
+    .enc_name         = s, \
+    .codec_type       = t, \
+    .codec_id         = CODEC_ID_NONE, \
+    .parse_sdp_a_line = rdt_parse_sdp_line, \
+    .open             = rdt_new_context, \
+    .close            = rdt_free_context, \
+    .parse_packet     = rdt_parse_packet \
 };
 
 RDT_HANDLER(live_video, "x-pn-multirate-realvideo-live", CODEC_TYPE_VIDEO);