]> git.sesse.net Git - vlc/blobdiff - modules/control/netsync.c
Fix hashing when using RFC4711
[vlc] / modules / control / netsync.c
index 139eee08103856d2e059a7527313b409527e296e..f76630dd26dd108708d44a9ef804bdb3efba5f9c 100644 (file)
@@ -26,8 +26,9 @@
  *****************************************************************************/
 #include <stdlib.h>
 #include <vlc/vlc.h>
-#include <vlc/intf.h>
-#include <vlc/input.h>
+#include <vlc_interface.h>
+#include <vlc_input.h>
+#include <vlc_es_out.h>
 
 #ifdef HAVE_UNISTD_H
 #    include <unistd.h>
@@ -39,7 +40,7 @@
 #   include <sys/types.h>
 #endif
 
-#include "network.h"
+#include <vlc_network.h>
 
 #define NETSYNC_PORT 9875
 
@@ -48,6 +49,9 @@
 #define INADDR_NONE 0xffffffff
 #endif
 
+/* FIXME: UGLY UGLY !! Netsync should be totally reworked */
+#include "../../src/input/input_internal.h"
+
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
@@ -56,12 +60,14 @@ static void Close   ( vlc_object_t * );
 
 static mtime_t GetClockRef( intf_thread_t *, mtime_t );
 
-#define NETSYNC_TEXT N_( "Act as master for network synchronisation" )
-#define NETSYNC_LONGTEXT N_( "Allows you to specify if this client should " \
-  "act as the master client for the network synchronisation." )
+/// \bug [String] This string is BAD.
+#define NETSYNC_TEXT N_( "Act as master" )
+#define NETSYNC_LONGTEXT N_( "Should " \
+  "act as the master client for the network synchronisation?" )
 
+/// \bug [String] This string is BAD.
 #define MIP_TEXT N_( "Master client ip address" )
-#define MIP_LONGTEXT N_( "Allows you to specify the ip address of " \
+#define MIP_LONGTEXT N_( "IP address of " \
   "the master client used for the network synchronisation." )
 
 vlc_module_begin();
@@ -142,22 +148,22 @@ static void Run( intf_thread_t *p_intf )
     }
 
     if( b_master )
-        i_socket = net_OpenUDP( p_intf, NULL, NETSYNC_PORT, NULL, 0 );
+        i_socket = net_ListenUDP1( VLC_OBJECT(p_intf), NULL, NETSYNC_PORT );
     else
-        i_socket = net_ConnectUDP( p_intf, psz_master, NETSYNC_PORT, 0 );
+        i_socket = net_ConnectUDP( VLC_OBJECT(p_intf), psz_master, NETSYNC_PORT, 0 );
 
     if( psz_master ) free( psz_master );
 
     if( i_socket < 0 )
     {
-        msg_Err( p_intf, "failed opening UDP socket." );
+        msg_Err( p_intf, "failed opening UDP socket" ); /* str review: is this good enough? */
         return;
     }
 
     /* High priority thread */
     vlc_thread_set_priority( p_intf, VLC_THREAD_PRIORITY_INPUT );
 
-    while( !p_intf->b_die )
+    while( !intf_ShouldDie( p_intf ) )
     {
         struct timeval timeout;
         fd_set fds_r;
@@ -211,7 +217,7 @@ static void Run( intf_thread_t *p_intf )
             /* We received something */
             i_struct_size = sizeof( from );
             i_read = recvfrom( i_socket, p_data, MAX_MSG_LENGTH, 0,
-                               (struct sockaddr*)&from, 
+                               (struct sockaddr*)&from,
                                (unsigned int *)&i_struct_size );
 
             i_clockref = ntoh64(*(int64_t *)p_data);
@@ -293,7 +299,7 @@ static void Run( intf_thread_t *p_intf )
 #if 0
             msg_Dbg( p_intf, "Slave clockref: "I64Fd" -> "I64Fd" -> "I64Fd", "
                      "clock diff: "I64Fd" drift: "I64Fd,
-                     i_clockref, i_master_clockref, 
+                     i_clockref, i_master_clockref,
                      i_client_clockref, i_diff_date, i_drift );
 #endif
 
@@ -311,9 +317,9 @@ static mtime_t GetClockRef( intf_thread_t *p_intf, mtime_t i_pts )
     input_thread_t *p_input = p_intf->p_sys->p_input;
     mtime_t i_ts;
 
-    if( !p_input || !p_input->p_es_out ) return 0;
+    if( !p_input || !p_input->p->p_es_out ) return 0;
 
-    if( es_out_Control( p_input->p_es_out, ES_OUT_GET_TS, i_pts, &i_ts ) ==
+    if( es_out_Control( p_input->p->p_es_out, ES_OUT_GET_TS, i_pts, &i_ts ) ==
         VLC_SUCCESS )
     {
         return i_ts;