]> git.sesse.net Git - vlc/blobdiff - src/control/video.c
libvlc_release(): removes unused exception
[vlc] / src / control / video.c
index 90b6d8c89a8d6f26ea079789f7a2676ed8a28a0c..4ba2d3d0325f802d7f946cc441d8118e0c733056 100644 (file)
@@ -3,7 +3,7 @@
  *****************************************************************************
  * Copyright (C) 2005 the VideoLAN team
  *
- * $Id: core.c 14187 2006-02-07 16:37:40Z courmisch $
+ * $Id$
  *
  * Authors: Cl�ent Stenac <zorglub@videolan.org>
  *          Filippo Carone <littlejohn@videolan.org>
@@ -26,6 +26,7 @@
  *****************************************************************************/
 
 #include "libvlc_internal.h"
+
 #include <vlc/libvlc.h>
 #include <vlc_input.h>
 #include <vlc_vout.h>
@@ -42,7 +43,7 @@ static vout_thread_t *GetVout( libvlc_media_instance_t *p_mi,
 
     if( p_input_thread )
     {
-        p_vout = vlc_object_find( p_input_thread, VLC_OBJECT_VOUT, FIND_CHILD );
+        p_vout = vlc_object_find( p_input_thread, VLC_OBJECT_VOUT, FIND_ANYWHERE );
         if( !p_vout )
         {
             libvlc_exception_raise( p_exception, "No active video output" );
@@ -126,7 +127,7 @@ void libvlc_toggle_fullscreen( libvlc_media_instance_t *p_mi,
 
 void
 libvlc_video_take_snapshot( libvlc_media_instance_t *p_mi, char *psz_filepath,
-                       libvlc_exception_t *p_e )
+        unsigned int i_width, unsigned int i_height, libvlc_exception_t *p_e )
 {
     vout_thread_t *p_vout = GetVout( p_mi, p_e );
     input_thread_t *p_input_thread;
@@ -143,10 +144,10 @@ libvlc_video_take_snapshot( libvlc_media_instance_t *p_mi, char *psz_filepath,
         return;
     }
 
+    var_SetInteger( p_vout, "snapshot-width", i_width );
+    var_SetInteger( p_vout, "snapshot-height", i_height );
 
-    p_input_thread = (input_thread_t*)vlc_object_get(
-                                 p_mi->p_libvlc_instance->p_libvlc_int,
-                                 p_mi->i_input_id );
+    p_input_thread = (input_thread_t*)vlc_object_get( p_mi->i_input_id );
     if( !p_input_thread )
     {
         libvlc_exception_raise( p_e, "Input does not exist" );
@@ -162,7 +163,7 @@ libvlc_video_take_snapshot( libvlc_media_instance_t *p_mi, char *psz_filepath,
 }
 
 int libvlc_video_get_height( libvlc_media_instance_t *p_mi,
-                             libvlc_exception_t *p_e ) 
+                             libvlc_exception_t *p_e )
 {
     vout_thread_t *p_vout1 = GetVout( p_mi, p_e );
     if( !p_vout1 )
@@ -174,7 +175,7 @@ int libvlc_video_get_height( libvlc_media_instance_t *p_mi,
 }
 
 int libvlc_video_get_width( libvlc_media_instance_t *p_mi,
-                            libvlc_exception_t *p_e ) 
+                            libvlc_exception_t *p_e )
 {
     vout_thread_t *p_vout1 = GetVout( p_mi, p_e );
     if( !p_vout1 )
@@ -275,10 +276,12 @@ void libvlc_video_set_parent( libvlc_instance_t *p_instance, libvlc_drawable_t d
 
 libvlc_drawable_t libvlc_video_get_parent( libvlc_instance_t *p_instance, libvlc_exception_t *p_e )
 {
+    VLC_UNUSED(p_e);
+
     libvlc_drawable_t result;
-    
     result = var_GetInteger( p_instance->p_libvlc_int, "drawable" );
-    
     return result;
 }
 
@@ -358,9 +361,9 @@ char *libvlc_video_get_aspect_ratio( libvlc_media_instance_t *p_mi,
     if( !p_vout )
         return 0;
 
-    psz_aspect = var_GetString( p_vout, "aspect-ratio" );
+    psz_aspect = var_GetNonEmptyString( p_vout, "aspect-ratio" );
     vlc_object_release( p_vout );
-    return psz_aspect;
+    return psz_aspect ? psz_aspect : strdup("");
 }
 
 void libvlc_video_set_aspect_ratio( libvlc_media_instance_t *p_mi,
@@ -457,9 +460,9 @@ char *libvlc_video_get_crop_geometry( libvlc_media_instance_t *p_mi,
     if( !p_vout )
         return 0;
 
-    psz_geometry = var_GetString( p_vout, "crop" );
+    psz_geometry = var_GetNonEmptyString( p_vout, "crop" );
     vlc_object_release( p_vout );
-    return psz_geometry;
+    return psz_geometry ? psz_geometry : strdup("");
 }
 
 void libvlc_video_set_crop_geometry( libvlc_media_instance_t *p_mi,
@@ -483,12 +486,20 @@ int libvlc_video_get_teletext( libvlc_media_instance_t *p_mi,
                                libvlc_exception_t *p_e )
 {
     vout_thread_t *p_vout = GetVout( p_mi, p_e );
+    vlc_object_t *p_vbi;
     int i_ret = -1;
 
     if( !p_vout )
         return i_ret;
 
-    i_ret = var_GetInteger( p_vout, "vbi-page" );
+    p_vbi = (vlc_object_t *) vlc_object_find_name( p_vout, "zvbi",
+                                                   FIND_ANYWHERE );
+    if( p_vbi )
+    {
+        i_ret = var_GetInteger( p_vbi, "vbi-page" );
+        vlc_object_release( p_vbi );
+    }
+
     vlc_object_release( p_vout );
     return i_ret;
 }
@@ -497,23 +508,55 @@ void libvlc_video_set_teletext( libvlc_media_instance_t *p_mi, int i_page,
                                 libvlc_exception_t *p_e )
 {
     vout_thread_t *p_vout = GetVout( p_mi, p_e );
+    vlc_object_t *p_vbi;
     int i_ret = -1;
 
     if( !p_vout )
         return;
 
-    i_ret = var_SetInteger( p_vout, "vbi-page", i_page );
+    p_vbi = (vlc_object_t *) vlc_object_find_name( p_vout, "zvbi",
+                                                   FIND_ANYWHERE );
+    if( p_vbi )
+    {
+        i_ret = var_SetInteger( p_vbi, "vbi-page", i_page );
+        vlc_object_release( p_vbi );
+    }
     if( i_ret )
         libvlc_exception_raise( p_e,
                         "Unexpected error while setting teletext page" );
     vlc_object_release( p_vout );
 }
 
+void libvlc_toggle_teletext( libvlc_media_instance_t *p_mi,
+                             libvlc_exception_t *p_e )
+{
+    /* We only work on the first vout */
+    vout_thread_t *p_vout = GetVout( p_mi, p_e );
+    vlc_value_t val; int i_ret;
+
+    /* GetVout will raise the exception for us */
+    if( !p_vout )
+        return;
+
+    i_ret = var_Get( p_vout, "vbi-opaque", &val );
+    if( i_ret )
+        libvlc_exception_raise( p_e,
+                        "Unexpected error while looking up teletext value" );
+
+    val.b_bool = !val.b_bool;
+    i_ret = var_Set( p_vout, "vbi-opaque", val );
+    if( i_ret )
+        libvlc_exception_raise( p_e,
+                        "Unexpected error while setting teletext value" );
+
+    vlc_object_release( p_vout );
+}
+
 int libvlc_video_destroy( libvlc_media_instance_t *p_mi,
                           libvlc_exception_t *p_e )
 {
     vout_thread_t *p_vout = GetVout( p_mi, p_e );
-    vlc_object_detach( p_vout ); 
+    vlc_object_detach( p_vout );
     vlc_object_release( p_vout );
     vout_Destroy( p_vout );