]> git.sesse.net Git - vlc/blobdiff - src/input/input_ext-intf.c
* include: removed a few deprecated functions.
[vlc] / src / input / input_ext-intf.c
index 81b70e6288c5fd55cf9931d9ee114d90e7d05fef..9c471585fd9bdc2ad7489998c0c2e646be800664 100644 (file)
@@ -1,15 +1,16 @@
 /*****************************************************************************
  * input_ext-intf.c: services to the interface
  *****************************************************************************
- * Copyright (C) 1998, 1999, 2000 VideoLAN
+ * Copyright (C) 1998-2004 VideoLAN
+ * $Id$
  *
- * Authors: Christophe Massiot <massiot@via.ecp.fr>
+ * Author: Christophe Massiot <massiot@via.ecp.fr>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include "defs.h"
-
-#include "config.h"
-#include "common.h"
-#include "threads.h"
-#include "mtime.h"
+#include <string.h>                                    /* memcpy(), memset() */
 
-#include "intf_msg.h"
+#include <vlc/vlc.h>
 
 #include "stream_control.h"
 #include "input_ext-dec.h"
 #include "input_ext-intf.h"
-
-#include "input.h"
+#include "input_ext-plugins.h"
 
 /*****************************************************************************
- * input_Play: comes back to the normal pace of reading
+ * 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
  *****************************************************************************/
-void input_Play( input_thread_t * p_input )
+char * input_OffsetToTime( input_thread_t * p_input, char * psz_buffer,
+                           off_t i_offset )
 {
-    intf_Msg( "input: playing at normal rate" );
-    vlc_mutex_lock( &p_input->stream.stream_lock );
-    p_input->stream.i_new_status = PLAYING_S;
-    vlc_cond_signal( &p_input->stream.stream_wait );
-    vlc_mutex_unlock( &p_input->stream.stream_lock );
+    mtime_t         i_seconds;
+
+    if( p_input->stream.i_mux_rate )
+    {
+        i_seconds = i_offset / 50 / p_input->stream.i_mux_rate;
+        return secstotimestr( psz_buffer, i_seconds );
+    }
+    else
+    {
+        /* Divide by zero is not my friend. */
+        sprintf( psz_buffer, "-:--:--" );
+        return( psz_buffer );
+    }
 }
 
 /*****************************************************************************
- * input_Forward: manages fast forward and slow motion
+ * input_ToggleES: answers to a user request with calls to (Un)SelectES
  *****************************************************************************
- * Note that if i_rate > DEFAULT_RATE, the pace is slower.
+ * Useful since the interface plugins know p_es.
+ * It only works for audio & spu ( to be sure nothing nasty is being done ).
+ * b_select is a boolean to know if we have to select or unselect ES
  *****************************************************************************/
-void input_Forward( input_thread_t * p_input, int i_rate )
+int input_ToggleES( input_thread_t * p_input, es_descriptor_t * p_es,
+                    vlc_bool_t b_select )
 {
-    if ( i_rate > DEFAULT_RATE )
-    {
-        intf_Msg( "input: playing at 1:%i slow motion", i_rate / 1000 );
-    }
-    else if( i_rate < DEFAULT_RATE )
-    {
-        intf_Msg( "input: playing at %i:1 fast forward", 1000 / i_rate );
-    }
-    else
+    vlc_mutex_lock( &p_input->stream.stream_lock );
+
+    if( p_es != NULL )
     {
-        /* Not very joli, but this is going to disappear soon anyway */
-        input_Play( p_input );
-        return;
+        if( b_select )
+        {
+            p_input->stream.p_newly_selected_es = p_es;
+        }
+        else
+        {
+            p_input->stream.p_removed_es = p_es;
+        }
     }
 
-    vlc_mutex_lock( &p_input->stream.stream_lock );
-    p_input->stream.i_new_status = FORWARD_S;
-    p_input->stream.i_new_rate = i_rate;
-    vlc_cond_signal( &p_input->stream.stream_wait );
     vlc_mutex_unlock( &p_input->stream.stream_lock );
+
+    return 0;
 }
 
-/*****************************************************************************
- * input_Pause: temporarily stops the reading of the stream
- *****************************************************************************/
-void input_Pause( input_thread_t * p_input )
+/****************************************************************************
+ * input_ChangeArea: interface request an area change
+ ****************************************************************************/
+int input_ChangeArea( input_thread_t * p_input, input_area_t * p_area )
 {
-    intf_Msg( "input: paused" );
     vlc_mutex_lock( &p_input->stream.stream_lock );
-    p_input->stream.i_new_status = PAUSE_S;
-    vlc_cond_signal( &p_input->stream.stream_wait );
+
+    p_input->stream.p_new_area = p_area;
+
     vlc_mutex_unlock( &p_input->stream.stream_lock );
+
+    return 0;
 }
 
-/*****************************************************************************
- * input_Seek: changes the stream postion
- *****************************************************************************/
-void input_Seek( input_thread_t * p_input, off_t i_position )
+/****************************************************************************
+ * input_ChangeProgram: interface request a program change
+ ****************************************************************************/
+int input_ChangeProgram( input_thread_t * p_input, uint16_t i_program_number )
 {
-    intf_Msg( "input: seeking position %d/%d", i_position,
-                                               p_input->stream.i_size );
+    pgrm_descriptor_t *       p_program;
+    vlc_value_t val;
+
     vlc_mutex_lock( &p_input->stream.stream_lock );
-    p_input->stream.i_seek = i_position;
-    vlc_cond_signal( &p_input->stream.stream_wait );
+
+    p_program = input_FindProgram( p_input, i_program_number );
+
+    if ( p_program == NULL )
+    {
+        msg_Err( p_input, "could not find selected program" );
+        return -1;
+    }
+
+    p_input->stream.p_new_program = p_program;
+
     vlc_mutex_unlock( &p_input->stream.stream_lock );
-}
 
+    /* Update the navigation variables without triggering a callback */
+    val.i_int = i_program_number;
+    var_Change( p_input, "program", VLC_VAR_SETVALUE, &val, NULL );
+
+    return 0;
+}