changeset 24856:4365a0d7a4b8

Fix fps guessing
author lu_zero
date Mon, 29 Oct 2007 19:24:55 +0000
parents 2c790baff42c
children 45359b137c95
files libmpdemux/demux_nemesi.c
diffstat 1 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_nemesi.c	Mon Oct 29 18:31:47 2007 +0000
+++ b/libmpdemux/demux_nemesi.c	Mon Oct 29 19:24:55 2007 +0000
@@ -21,6 +21,7 @@
 #define HAVE_STRUCT_SOCKADDR_STORAGE
 #include "nemesi/rtsp.h"
 #include "nemesi/rtp.h"
+#include <sched.h>
 
 int rtsp_transport_tcp = 0;
 int rtsp_transport_sctp = 0;
@@ -54,8 +55,13 @@
         buff = &trash_buff;
 
     if ( (buff != NULL) || (fps != NULL) ) {
-        while ( !(ssrc = rtp_session_get_ssrc(sess, ctl)) );
-        rtp_fill_buffer(ssrc, fr, buff);
+        while ( !(ssrc = rtp_session_get_ssrc(sess, ctl)) ) //Wait for the ssrc to be registered
+            sched_yield();
+
+        rtp_fill_buffer(ssrc, fr, buff); //Prefetch the first packet
+
+        while ( !(rtp_get_pkt(ssrc, NULL)) ) //Wait for the second packet to calculate FPS
+            sched_yield();
 
         if ( (force_fps == 0.0) && (fps != NULL) ) {
             rtp_fill_buffers(rtsp_get_rtp_th(ctl));
@@ -199,8 +205,10 @@
                 d_video->sh = sh_video;
                 sh_video->ds = d_video;
 
-                if (fps)
+                if (fps) {
                     sh_video->fps = fps;
+                    sh_video->frametime = 1.0/fps;
+                }
 
                 //List of known video formats
                 if (!strcmp(format_name, "MPV")) {