]> git.sesse.net Git - vlc/blobdiff - src/input/input_ext-intf.c
* Bug fixes and enhancements in the Gtk+/Gnome interfaces.
[vlc] / src / input / input_ext-intf.c
index 346cae25bd2215d3475990e58d393a44442d4561..061fe273173a5b52c2a007c0a57891543ae20176 100644 (file)
 #include "input.h"
 
 /*****************************************************************************
- * input_SetRate: change the reading pace
+ * input_SetStatus: change the reading status
  *****************************************************************************/
-void input_SetRate( input_thread_t * p_input, int i_mode )
+void input_SetStatus( input_thread_t * p_input, int i_mode )
 {
     vlc_mutex_lock( &p_input->stream.stream_lock );
 
     switch( i_mode )
     {
-    case INPUT_RATE_PLAY:
+    case INPUT_STATUS_END:
+        p_input->stream.i_new_status = PLAYING_S;
+        p_input->b_eof = 1;
+        intf_Msg( "input: end of stream" );
+        break;
+
+    case INPUT_STATUS_PLAY:
         p_input->stream.i_new_status = PLAYING_S;
         intf_Msg( "input: playing at normal rate" );
         break;
 
-    case INPUT_RATE_PAUSE:
+    case INPUT_STATUS_PAUSE:
         /* XXX: we don't need to check i_status, because input_clock.c
          * does it for us */
         p_input->stream.i_new_status = PAUSE_S;
         intf_Msg( "input: toggling pause" );
         break;
 
-    case INPUT_RATE_FASTER:
+    case INPUT_STATUS_FASTER:
         /* If we are already going too fast, go back to default rate */
         if( p_input->stream.control.i_rate * 8 <= DEFAULT_RATE )
         {
@@ -85,7 +91,7 @@ void input_SetRate( input_thread_t * p_input, int i_mode )
         }
         break;
 
-    case INPUT_RATE_SLOWER:
+    case INPUT_STATUS_SLOWER:
         /* If we are already going too slow, go back to default rate */
         if( p_input->stream.control.i_rate >= 8 * DEFAULT_RATE )
         {
@@ -118,18 +124,174 @@ void input_SetRate( input_thread_t * p_input, int i_mode )
     vlc_mutex_unlock( &p_input->stream.stream_lock );
 }
 
+/*****************************************************************************
+ * input_SetRate: change the reading rate
+ *****************************************************************************/
+void input_SetRate( input_thread_t * p_input, int i_mode )
+{
+    ; /* FIXME: stub */
+}
 /*****************************************************************************
  * input_Seek: changes the stream postion
  *****************************************************************************/
 void input_Seek( input_thread_t * p_input, off_t i_position )
 {
+    char        psz_time1[OFFSETTOTIME_MAX_SIZE];
+    char        psz_time2[OFFSETTOTIME_MAX_SIZE];
+
     vlc_mutex_lock( &p_input->stream.stream_lock );
-    p_input->stream.i_seek = i_position;
+    p_input->stream.p_selected_area->i_seek = i_position;
 
-    intf_Msg( "input: seeking position %lld/%lld", i_position,
-                                                   p_input->stream.i_size );
+    intf_Msg( "input: seeking position %lld/%lld (%s/%s)", i_position,
+                    p_input->stream.p_selected_area->i_size,
+                    input_OffsetToTime( p_input, psz_time1, i_position ),
+                    input_OffsetToTime( p_input, psz_time2,
+                                p_input->stream.p_selected_area->i_size ) );
 
     vlc_cond_signal( &p_input->stream.stream_wait );
     vlc_mutex_unlock( &p_input->stream.stream_lock );
 }
 
+/*****************************************************************************
+ * input_OffsetToTime : converts an off_t value to a time indicator, using
+ *                      mux_rate
+ *****************************************************************************
+ * BEWARE : this function assumes that you already own the lock on
+ * p_input->stream.stream_lock
+ *****************************************************************************/
+char * input_OffsetToTime( input_thread_t * p_input, char * psz_buffer,
+                           off_t i_offset )
+{
+    mtime_t         i_seconds;
+
+    if( p_input->stream.i_mux_rate )
+    {
+        i_seconds = i_offset / 50 / p_input->stream.i_mux_rate;
+        snprintf( psz_buffer, OFFSETTOTIME_MAX_SIZE, "%d:%02d:%02d",
+                 (int) (i_seconds / (60 * 60)),
+                 (int) (i_seconds / 60 % 60),
+                 (int) (i_seconds % 60) );
+        return( psz_buffer );
+    }
+    else
+    {
+        /* Divide by zero is not my friend. */
+        sprintf( psz_buffer, "-:--:--" );
+        return( psz_buffer );
+    }
+}
+
+/*****************************************************************************
+ * input_DumpStream: dumps the contents of a stream descriptor
+ *****************************************************************************
+ * BEWARE : this function assumes that you already own the lock on
+ * p_input->stream.stream_lock
+ *****************************************************************************/
+void input_DumpStream( input_thread_t * p_input )
+{
+    int         i, j;
+    char        psz_time1[OFFSETTOTIME_MAX_SIZE];
+    char        psz_time2[OFFSETTOTIME_MAX_SIZE];
+
+#define S   p_input->stream
+    intf_Msg( "input info: Dumping stream ID 0x%x", S.i_stream_id );
+    if( S.b_seekable )
+        intf_Msg( "input info: seekable stream, position: %lld/%lld (%s/%s)",
+                  S.p_selected_area->i_tell, S.p_selected_area->i_size,
+                  input_OffsetToTime( p_input, psz_time1,
+                                      S.p_selected_area->i_tell ),
+                  input_OffsetToTime( p_input, psz_time2,
+                                      S.p_selected_area->i_size ) );
+    else
+        intf_Msg( "input info: %s", S.b_pace_control ? "pace controlled" :
+                  "pace un-controlled" );
+#undef S
+    for( i = 0; i < p_input->stream.i_pgrm_number; i++ )
+    {
+#define P   p_input->stream.pp_programs[i]
+        intf_Msg( "input info: Dumping program 0x%x, version %d (%s)",
+                  P->i_number, P->i_version,
+                  P->b_is_ok ? "complete" : "partial" );
+#undef P
+        for( j = 0; j < p_input->stream.pp_programs[i]->i_es_number; j++ )
+        {
+#define ES  p_input->stream.pp_programs[i]->pp_es[j]
+            intf_Msg( "input info: ES 0x%x, stream 0x%x, type 0x%x, %s",
+                      ES->i_id, ES->i_stream_id, ES->i_type,
+                      ES->p_decoder_fifo != NULL ? "selected" : "not selected");
+#undef ES
+        }
+    }
+}
+
+/*****************************************************************************
+ * input_ChangeES: answers to a user request with calls to (Un)SelectES
+ * ---
+ * Useful since the interface plugins know p_es
+ *****************************************************************************/
+int input_ChangeES( input_thread_t * p_input, es_descriptor_t * p_es,
+                    int i_type )
+{
+    boolean_t               b_audio;
+    boolean_t               b_spu;
+    int                     i_index;
+    int                     i;
+
+    i_index = -1;
+    b_audio = ( i_type == 1 ) ? 1 : 0;
+    b_spu   = ( i_type == 2 ) ? 1 : 0;
+
+    vlc_mutex_lock( &p_input->stream.stream_lock );
+
+    for( i = 0 ; i < p_input->stream.i_selected_es_number ; i++ )
+    {
+        if( ( b_audio && p_input->stream.pp_selected_es[i]->b_audio ) 
+         || ( b_spu   && p_input->stream.pp_selected_es[i]->b_spu ) )
+        {
+            i_index = i;
+            break;
+        }
+    }
+
+
+    if( p_es != NULL )
+    {
+
+    
+        if( i_index != -1 )
+        {
+            
+            if( p_input->stream.pp_selected_es[i_index] != p_es )
+            {
+                input_UnselectES( p_input,
+                                  p_input->stream.pp_selected_es[i_index] );
+                input_SelectES( p_input, p_es );
+                intf_WarnMsg( 1, "input info: es selected -> %s (0x%x)",
+                                                p_es->psz_desc, p_es->i_id );
+            }
+        }
+        else
+        {
+            input_SelectES( p_input, p_es );
+            intf_WarnMsg( 1, "input info: es selected -> %s (0x%x)",
+                          p_es->psz_desc, p_es->i_id );
+        }
+    }
+    else
+    {
+        if( i_index != -1 )
+        {
+            intf_WarnMsg( 1, "input info: es unselected -> %s (0x%x)",
+                          p_input->stream.pp_selected_es[i_index]->psz_desc,
+                          p_input->stream.pp_selected_es[i_index]->i_id );
+
+            input_UnselectES( p_input,
+                              p_input->stream.pp_selected_es[i_index] );
+        }
+    }
+
+    vlc_mutex_unlock( &p_input->stream.stream_lock );
+
+    return 0;
+}