]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/rtpdec.c
cosmetics, remove whitespace
[ffmpeg] / libavformat / rtpdec.c
index dc9e0442272a163422af74d842639768156c6aeb..70b29e73dde4168b654e101d4f4409126fb1a810 100644 (file)
@@ -19,6 +19,9 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+/* needed for gethostname() */
+#define _XOPEN_SOURCE 500
+
 #include "libavcodec/bitstream.h"
 #include "avformat.h"
 #include "mpegts.h"
@@ -250,13 +253,9 @@ int rtp_check_and_send_back_rr(RTPDemuxContext *s, int count)
     len = url_close_dyn_buf(pb, &buf);
     if ((len > 0) && buf) {
         int result;
-#if defined(DEBUG)
-        printf("sending %d bytes of RR\n", len);
-#endif
+        dprintf(s->ic, "sending %d bytes of RR\n", len);
         result= url_write(s->rtp_ctx, buf, len);
-#if defined(DEBUG)
-        printf("result from url_write: %d\n", result);
-#endif
+        dprintf(s->ic, "result from url_write: %d\n", result);
         av_free(buf);
     }
     return 0;
@@ -289,6 +288,7 @@ RTPDemuxContext *rtp_parse_open(AVFormatContext *s1, AVStream *st, URLContext *r
             return NULL;
         }
     } else {
+        av_set_pts_info(st, 32, 1, 90000);
         switch(st->codec->codec_id) {
         case CODEC_ID_MPEG1VIDEO:
         case CODEC_ID_MPEG2VIDEO:
@@ -299,6 +299,9 @@ RTPDemuxContext *rtp_parse_open(AVFormatContext *s1, AVStream *st, URLContext *r
             st->need_parsing = AVSTREAM_PARSE_FULL;
             break;
         default:
+            if (st->codec->codec_type == CODEC_TYPE_AUDIO) {
+                av_set_pts_info(st, 32, 1, st->codec->sample_rate);
+            }
             break;
         }
     }
@@ -361,31 +364,15 @@ static int rtp_parse_mp4_au(RTPDemuxContext *s, const uint8_t *buf)
  */
 static void finalize_packet(RTPDemuxContext *s, AVPacket *pkt, uint32_t timestamp)
 {
-    switch(s->st->codec->codec_id) {
-        case CODEC_ID_MP2:
-        case CODEC_ID_MPEG1VIDEO:
-        case CODEC_ID_MPEG2VIDEO:
-            if (s->last_rtcp_ntp_time != AV_NOPTS_VALUE) {
-                int64_t addend;
-
-                int delta_timestamp;
-                /* XXX: is it really necessary to unify the timestamp base ? */
-                /* compute pts from timestamp with received ntp_time */
-                delta_timestamp = timestamp - s->last_rtcp_timestamp;
-                /* convert to 90 kHz without overflow */
-                addend = (s->last_rtcp_ntp_time - s->first_rtcp_ntp_time) >> 14;
-                addend = (addend * 5625) >> 14;
-                pkt->pts = addend + delta_timestamp;
-            }
-            break;
-        case CODEC_ID_AAC:
-        case CODEC_ID_H264:
-        case CODEC_ID_MPEG4:
-            pkt->pts = timestamp;
-            break;
-        default:
-            /* no timestamp info yet */
-            break;
+    if (s->last_rtcp_ntp_time != AV_NOPTS_VALUE) {
+        int64_t addend;
+        int delta_timestamp;
+
+        /* compute pts from timestamp with received ntp_time */
+        delta_timestamp = timestamp - s->last_rtcp_timestamp;
+        /* convert to the PTS timebase */
+        addend = av_rescale(s->last_rtcp_ntp_time - s->first_rtcp_ntp_time, s->st->time_base.den, (uint64_t)s->st->time_base.num << 32);
+        pkt->pts = addend + delta_timestamp;
     }
     pkt->stream_index = s->st->index;
 }