]> git.sesse.net Git - ffmpeg/commitdiff
rtsp/rtpdec: Allow rtp_parse_packet to take ownership of the packet buffer
authorMartin Storsjö <martin@martin.st>
Fri, 1 Oct 2010 17:43:27 +0000 (17:43 +0000)
committerMartin Storsjö <martin@martin.st>
Fri, 1 Oct 2010 17:43:27 +0000 (17:43 +0000)
Do the same change for ff_rdt_parse_packet, too, to keep the interfaces
similar.

Originally committed as revision 25289 to svn://svn.ffmpeg.org/ffmpeg/trunk

libavformat/rdt.c
libavformat/rdt.h
libavformat/rtpdec.c
libavformat/rtpdec.h
libavformat/rtsp.c

index 8baceca15376cc1df1f7430dd41525390eff0573..303a2a814566646c727f2133c99cbc691942362d 100644 (file)
@@ -337,8 +337,9 @@ get_cache:
 
 int
 ff_rdt_parse_packet(RDTDemuxContext *s, AVPacket *pkt,
-                    const uint8_t *buf, int len)
+                    uint8_t **bufptr, int len)
 {
+    uint8_t *buf = bufptr ? *bufptr : NULL;
     int seq_no, flags = 0, stream_id, set_id, is_keyframe;
     uint32_t timestamp;
     int rv= 0;
index 8117989d2434c773e9f239b813841ca140eb3eff..19a4a7bc1f7c88203b7d80b5abb88ee70de3b8a7 100644 (file)
@@ -96,7 +96,7 @@ int ff_rdt_parse_header(const uint8_t *buf, int len,
  * Usage similar to rtp_parse_packet().
  */
 int ff_rdt_parse_packet(RDTDemuxContext *s, AVPacket *pkt,
-                        const uint8_t *buf, int len);
+                        uint8_t **buf, int len);
 
 /**
  * Parse a server-related SDP line.
index 942b8d71c88338bb599ceabc73d4b8108fab7176..65fa0646826e1fbcf16df0708bf5bd8b012e30fa 100644 (file)
@@ -414,14 +414,15 @@ static void finalize_packet(RTPDemuxContext *s, AVPacket *pkt, uint32_t timestam
  * Parse an RTP or RTCP packet directly sent as a buffer.
  * @param s RTP parse context.
  * @param pkt returned packet
- * @param buf input buffer or NULL to read the next packets
+ * @param bufptr pointer to the input buffer or NULL to read the next packets
  * @param len buffer len
  * @return 0 if a packet is returned, 1 if a packet is returned and more can follow
  * (use buf as NULL to read the next). -1 if no packet (error or no more packet).
  */
 int rtp_parse_packet(RTPDemuxContext *s, AVPacket *pkt,
-                     const uint8_t *buf, int len)
+                     uint8_t **bufptr, int len)
 {
+    uint8_t* buf = bufptr ? *bufptr : NULL;
     unsigned int ssrc, h;
     int payload_type, seq, ret, flags = 0;
     AVStream *st;
index 8548459d85a08672b07cf2e07faa93f26a0408be..df2ec77680f8df70ca0e05da4605edffd855ed1d 100644 (file)
@@ -39,7 +39,7 @@ RTPDemuxContext *rtp_parse_open(AVFormatContext *s1, AVStream *st, URLContext *r
 void rtp_parse_set_dynamic_protocol(RTPDemuxContext *s, PayloadContext *ctx,
                                     RTPDynamicProtocolHandler *handler);
 int rtp_parse_packet(RTPDemuxContext *s, AVPacket *pkt,
-                     const uint8_t *buf, int len);
+                     uint8_t **buf, int len);
 void rtp_parse_close(RTPDemuxContext *s);
 #if (LIBAVFORMAT_VERSION_MAJOR <= 53)
 int rtp_get_local_port(URLContext *h);
index be99587f81e9ce971d75e4a3e66cb94b402c5075..b1ef46f6d0d91ce64949ae05d49de35e41b6bc52 100644 (file)
@@ -1843,9 +1843,9 @@ static int rtsp_fetch_packet(AVFormatContext *s, AVPacket *pkt)
     if (len == 0)
         return AVERROR_EOF;
     if (rt->transport == RTSP_TRANSPORT_RDT) {
-        ret = ff_rdt_parse_packet(rtsp_st->transport_priv, pkt, rt->recvbuf, len);
+        ret = ff_rdt_parse_packet(rtsp_st->transport_priv, pkt, &rt->recvbuf, len);
     } else {
-        ret = rtp_parse_packet(rtsp_st->transport_priv, pkt, rt->recvbuf, len);
+        ret = rtp_parse_packet(rtsp_st->transport_priv, pkt, &rt->recvbuf, len);
         if (ret < 0) {
             /* Either bad packet, or a RTCP packet. Check if the
              * first_rtcp_ntp_time field was initialized. */