Added control code for "frame-next" variable.
authorLaurent Aimar <fenrir@videolan.org>
Mon, 13 Oct 2008 21:13:29 +0000 (23:13 +0200)
committerLaurent Aimar <fenrir@videolan.org>
Wed, 22 Oct 2008 20:21:43 +0000 (22:21 +0200)
It is ignored.

src/input/es_out.c
src/input/es_out.h
src/input/input.c
src/input/input_internal.h
src/input/var.c

index 93a3cb6..790269c 100644 (file)
@@ -544,6 +544,38 @@ bool input_EsOutIsBuffering( es_out_t *out )
 {
     return out->p_sys->b_buffering;
 }
+void input_EsOutFrameNext( es_out_t *out )
+{
+    es_out_sys_t *p_sys = out->p_sys;
+    es_out_id_t *p_es_video = NULL;
+
+    for( int i = 0; i < p_sys->i_es; i++ )
+    {
+        es_out_id_t *p_es = p_sys->es[i];
+
+        if( p_es->fmt.i_cat == VIDEO_ES && p_es->p_dec )
+        {
+            p_es_video = p_es;
+            break;
+        }
+    }
+
+    if( !p_es_video )
+    {
+        msg_Warn( p_sys->p_input, "No video track selected, ignoring 'frame next'" );
+        return;
+    }
+
+#if 0
+    input_DecoderFrameNext( p_es_video->p_dec );
+    if( !p_sys->b_buffering )
+    {
+        TODO();
+    }
+#endif
+
+    msg_Err( out->p_sys->p_input, "TODO input_EsOutFrameNext" );
+}
 
 /*****************************************************************************
  *
index 3578d5a..dbf79df 100644 (file)
@@ -42,5 +42,6 @@ void       input_EsOutChangePause( es_out_t *, bool b_paused, mtime_t i_date );
 void       input_EsOutChangePosition( es_out_t * );
 bool       input_EsOutDecodersIsEmpty( es_out_t * );
 bool       input_EsOutIsBuffering( es_out_t * );
+void       input_EsOutFrameNext( es_out_t * );
 
 #endif
index 35e4b4c..1720a1c 100644 (file)
@@ -1485,6 +1485,58 @@ static void ControlReduce( input_thread_t *p_input )
         }
     }
 }
+/* Pause input */
+static void ControlPause( input_thread_t *p_input, mtime_t i_control_date )
+{
+    int i_ret;
+    int i_state;
+    if( p_input->p->input.p_access )
+        i_ret = access_Control( p_input->p->input.p_access,
+                                 ACCESS_SET_PAUSE_STATE, true );
+    else
+        i_ret = demux_Control( p_input->p->input.p_demux,
+                                DEMUX_SET_PAUSE_STATE, true );
+
+    i_state = PAUSE_S;
+    if( i_ret )
+    {
+        msg_Warn( p_input, "cannot set pause state" );
+        i_state = p_input->i_state;
+    }
+
+    /* Switch to new state */
+    input_ChangeStateWithVarCallback( p_input, i_state, false );
+
+    /* */
+    if( !i_ret )
+        input_EsOutChangePause( p_input->p->p_es_out, true, i_control_date );
+}
+static void ControlUnpause( input_thread_t *p_input, mtime_t i_control_date )
+{
+    int i_ret;
+    if( p_input->p->input.p_access )
+        i_ret = access_Control( p_input->p->input.p_access,
+                                 ACCESS_SET_PAUSE_STATE, false );
+    else
+        i_ret = demux_Control( p_input->p->input.p_demux,
+                                DEMUX_SET_PAUSE_STATE, false );
+
+    if( i_ret )
+    {
+        /* FIXME What to do ? */
+        msg_Warn( p_input, "cannot unset pause -> EOF" );
+        vlc_mutex_unlock( &p_input->p->lock_control );
+        input_ControlPush( p_input, INPUT_CONTROL_SET_DIE, NULL );
+        vlc_mutex_lock( &p_input->p->lock_control );
+    }
+
+    /* Switch to play */
+    input_ChangeStateWithVarCallback( p_input, PLAYING_S, false );
+
+    /* */
+    if( !i_ret )
+        input_EsOutChangePause( p_input->p->p_es_out, false, i_control_date );
+}
 
 static bool Control( input_thread_t *p_input, int i_type,
                            vlc_value_t val )
@@ -1608,61 +1660,16 @@ static bool Control( input_thread_t *p_input, int i_type,
             if( ( val.i_int == PLAYING_S && p_input->i_state == PAUSE_S ) ||
                 ( val.i_int == PAUSE_S && p_input->i_state == PAUSE_S ) )
             {
-                int i_ret;
-                if( p_input->p->input.p_access )
-                    i_ret = access_Control( p_input->p->input.p_access,
-                                             ACCESS_SET_PAUSE_STATE, false );
-                else
-                    i_ret = demux_Control( p_input->p->input.p_demux,
-                                            DEMUX_SET_PAUSE_STATE, false );
-
-                if( i_ret )
-                {
-                    /* FIXME What to do ? */
-                    msg_Warn( p_input, "cannot unset pause -> EOF" );
-                    vlc_mutex_unlock( &p_input->p->lock_control );
-                    input_ControlPush( p_input, INPUT_CONTROL_SET_DIE, NULL );
-                    vlc_mutex_lock( &p_input->p->lock_control );
-                }
+                ControlUnpause( p_input, i_control_date );
 
                 b_force_update = true;
-
-                /* Switch to play */
-                input_ChangeStateWithVarCallback( p_input, PLAYING_S, false );
-
-                /* */
-                if( !i_ret )
-                    input_EsOutChangePause( p_input->p->p_es_out, false, i_control_date );
             }
             else if( val.i_int == PAUSE_S && p_input->i_state == PLAYING_S &&
                      p_input->p->b_can_pause )
             {
-                int i_ret, state;
-                if( p_input->p->input.p_access )
-                    i_ret = access_Control( p_input->p->input.p_access,
-                                             ACCESS_SET_PAUSE_STATE, true );
-                else
-                    i_ret = demux_Control( p_input->p->input.p_demux,
-                                            DEMUX_SET_PAUSE_STATE, true );
+                ControlPause( p_input, i_control_date );
 
                 b_force_update = true;
-
-                if( i_ret )
-                {
-                    msg_Warn( p_input, "cannot set pause state" );
-                    state = p_input->i_state;
-                }
-                else
-                {
-                    state = PAUSE_S;
-                }
-
-                /* Switch to new state */
-                input_ChangeStateWithVarCallback( p_input, state, false );
-
-                /* */
-                if( !i_ret )
-                    input_EsOutChangePause( p_input->p->p_es_out, true, i_control_date );
             }
             else if( val.i_int == PAUSE_S && !p_input->p->b_can_pause )
             {
@@ -2031,6 +2038,25 @@ static bool Control( input_thread_t *p_input, int i_type,
             }
             break;
 
+        case INPUT_CONTROL_SET_FRAME_NEXT:
+            if( !p_input->p->b_can_pause )
+                break;
+
+            if( p_input->i_state == PAUSE_S )
+            {
+                input_EsOutFrameNext( p_input->p->p_es_out );
+            }
+            else if( p_input->i_state == PLAYING_S )
+            {
+                ControlPause( p_input, i_control_date );
+            }
+            else
+            {
+                msg_Err( p_input, "invalid state for frame next" );
+            }
+            b_force_update = true;
+            break;
+
         case INPUT_CONTROL_SET_BOOKMARK:
         default:
             msg_Err( p_input, "not yet implemented" );
index 993ce97..17e676c 100644 (file)
@@ -193,6 +193,8 @@ enum input_control_e
     INPUT_CONTROL_ADD_SUBTITLE,
 
     INPUT_CONTROL_SET_RECORD_STATE,
+
+    INPUT_CONTROL_SET_FRAME_NEXT,
 };
 
 /* Internal helpers */
index 2714786..089d415 100644 (file)
@@ -64,6 +64,9 @@ static int BookmarkCallback( vlc_object_t *p_this, char const *psz_cmd,
 static int RecordCallback( vlc_object_t *p_this, char const *psz_cmd,
                            vlc_value_t oldval, vlc_value_t newval,
                            void *p_data );
+static int FrameNextCallback( vlc_object_t *p_this, char const *psz_cmd,
+                              vlc_value_t oldval, vlc_value_t newval,
+                              void *p_data );
 
 typedef struct
 {
@@ -98,6 +101,7 @@ static const vlc_input_callback_t p_input_callbacks[] =
     CALLBACK( "audio-es", ESCallback ),
     CALLBACK( "spu-es", ESCallback ),
     CALLBACK( "record", RecordCallback ),
+    CALLBACK( "frame-next", FrameNextCallback ),
 
     CALLBACK( NULL, NULL )
 };
@@ -139,6 +143,8 @@ void input_ControlVarInit ( input_thread_t *p_input )
 
     var_Create( p_input, "rate-faster", VLC_VAR_VOID );
 
+    var_Create( p_input, "frame-next", VLC_VAR_VOID );
+
     /* Position */
     var_Create( p_input, "position",  VLC_VAR_FLOAT );
     var_Create( p_input, "position-offset",  VLC_VAR_FLOAT );
@@ -806,3 +812,15 @@ static int RecordCallback( vlc_object_t *p_this, char const *psz_cmd,
 
     return VLC_SUCCESS;
 }
+static int FrameNextCallback( vlc_object_t *p_this, char const *psz_cmd,
+                              vlc_value_t oldval, vlc_value_t newval,
+                              void *p_data )
+{
+    input_thread_t *p_input = (input_thread_t*)p_this;
+    VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval); VLC_UNUSED(p_data);
+
+    input_ControlPush( p_input, INPUT_CONTROL_SET_FRAME_NEXT, NULL );
+
+    return VLC_SUCCESS;
+}
+