]> git.sesse.net Git - vlc/commitdiff
Basic support for RTP-Info
authorRémi Denis-Courmont <rem@videolan.org>
Mon, 24 Sep 2007 18:13:55 +0000 (18:13 +0000)
committerRémi Denis-Courmont <rem@videolan.org>
Mon, 24 Sep 2007 18:13:55 +0000 (18:13 +0000)
modules/stream_out/rtp.c
modules/stream_out/rtp.h
modules/stream_out/rtsp.c

index fb0aa61095d2706d94bad2096e4cb84502e6eabe..6434f5ade2a8ef9efce4bcc133aaff97735ee8eb 100644 (file)
@@ -1473,6 +1473,32 @@ void rtp_del_sink( sout_stream_id_t *id, int fd )
     net_Close( sink.rtp_fd );
 }
 
+uint16_t rtp_get_seq( const sout_stream_id_t *id )
+{
+    /* This will return values for the next packet.
+     * Accounting for caching would not be totally trivial. */
+    return id->i_sequence;
+}
+
+/* FIXME: this is pretty bad - if we remove and then insert an ES
+ * the number will get unsynched from inside RTSP */
+unsigned rtp_get_num( const sout_stream_id_t *id )
+{
+    sout_stream_sys_t *p_sys = id->p_stream->p_sys;
+    int i;
+
+    vlc_mutex_lock( &p_sys->lock_es );
+    for( i = 0; i < p_sys->i_es; i++ )
+    {
+        if( id == p_sys->es[i] )
+            break;
+    }
+    vlc_mutex_unlock( &p_sys->lock_es );
+
+    return i;
+}
+
+
 /****************************************************************************
  * rtp_packetize_*:
  ****************************************************************************/
index 2d465c002435a216f25c1ba3c1526b5cd348cb88..f2665903592a72421894d143d0cf53265ad789fe 100644 (file)
@@ -38,6 +38,8 @@ char *SDPGenerate( const sout_stream_t *p_stream, const char *rtsp_url );
 
 int rtp_add_sink( sout_stream_id_t *id, int fd, vlc_bool_t rtcp_mux );
 void rtp_del_sink( sout_stream_id_t *id, int fd );
+uint16_t rtp_get_seq( const sout_stream_id_t *id );
+unsigned rtp_get_num( const sout_stream_id_t *id );
 
 /* RTCP */
 typedef struct rtcp_sender_t rtcp_sender_t;
index 5c4f5c433a9a3131f62360219bd25b96fa566648..e866000cd78d20d0e9231e1f2c55e638ac9e994c 100644 (file)
@@ -195,6 +195,7 @@ rtsp_stream_id_t *RtspAddId( rtsp_stream_t *rtsp, sout_stream_id_t *sid,
         id->hiport = hiport;
     }
 
+    /* FIXME: num screws up if any ES has been removed and re-added */
     snprintf( urlbuf, sizeof( urlbuf ), rtsp->track_fmt, rtsp->psz_path,
               num );
     msg_Dbg( rtsp->owner, "RTSP: adding %s", urlbuf );
@@ -603,16 +604,32 @@ static int RtspHandler( rtsp_stream_t *rtsp, rtsp_stream_id_t *id,
             ses = RtspClientGet( rtsp, psz_session );
             if( ses != NULL )
             {
+                /* FIXME: we really need to limit the number of tracks... */
+                char info[ses->trackc * ( strlen( control )
+                                  + sizeof("/trackID=123;seq=65535, ") ) + 1];
+                size_t infolen = 0;
+
                 for( int i = 0; i < ses->trackc; i++ )
                 {
                     rtsp_strack_t *tr = ses->trackv + i;
-                    if( !tr->playing
-                     && ( ( id == NULL ) || ( tr->id == id->sout_id ) ) )
+                    if( ( id == NULL ) || ( tr->id == id->sout_id ) )
                     {
-                        tr->playing = VLC_TRUE;
-                        rtp_add_sink( tr->id, tr->fd, VLC_FALSE );
+                        if( !tr->playing )
+                        {
+                            tr->playing = VLC_TRUE;
+                            rtp_add_sink( tr->id, tr->fd, VLC_FALSE );
+                        }
+                        infolen += sprintf( info + infolen,
+                                            "%s/trackID=%u;seq=%u, ", control,
+                                            rtp_get_num( tr->id ),
+                                            rtp_get_seq( tr->id ) );
                     }
                 }
+                if( infolen > 0 )
+                {
+                    info[infolen - 2] = '\0'; /* remove trailing ", " */
+                    httpd_MsgAdd( answer, "RTP-Info", "%s", info );
+                }
             }
             vlc_mutex_unlock( &rtsp->lock );