]> git.sesse.net Git - vlc/commitdiff
(Forward port of [17371]) Implement Aspect Ratio property for Mozilla plugin
authorJean-Paul Saman <jpsaman@videolan.org>
Mon, 30 Oct 2006 12:15:47 +0000 (12:15 +0000)
committerJean-Paul Saman <jpsaman@videolan.org>
Mon, 30 Oct 2006 12:15:47 +0000 (12:15 +0000)
include/vlc/libvlc.h
mozilla/control/npolibvlc.cpp
src/control/video.c

index 9e3a6e36a1589b1e48e4ca2211311890197f38e3..f6074ff8a8a3de8568680b89215bcef71c728f84 100644 (file)
@@ -137,10 +137,12 @@ void libvlc_destroy( libvlc_instance_t *, libvlc_exception_t * );
  * LibVLC Playlist handling
  * @{
  */
+
 /**
  * Set loop variable
  */
 void libvlc_playlist_loop( libvlc_instance_t* , vlc_bool_t, libvlc_exception_t * );
+
 /**
  * Start playing. You can give some additionnal playlist item options
  * that will be added to the item before playing it.
@@ -239,7 +241,7 @@ int libvlc_playlist_add_extended( libvlc_instance_t *, const char *,
  */
 int libvlc_playlist_delete_item( libvlc_instance_t *, int,
                                  libvlc_exception_t * );
-    
+
 typedef struct libvlc_input_t libvlc_input_t;
 
 /* Get the input that is currently being played by the playlist
@@ -276,7 +278,7 @@ vlc_bool_t  libvlc_input_will_play      ( libvlc_input_t *, libvlc_exception_t *
 float       libvlc_input_get_rate       ( libvlc_input_t *, libvlc_exception_t *);
 void        libvlc_input_set_rate       ( libvlc_input_t *, float, libvlc_exception_t *);
 int         libvlc_input_get_state      ( libvlc_input_t *, libvlc_exception_t *);
-        
+
 /** @} */
 
 /** defgroup libvlc_video Video
@@ -315,7 +317,7 @@ void libvlc_set_fullscreen( libvlc_input_t *, int, libvlc_exception_t * );
  * \return the fullscreen status (boolean)
  */
 int libvlc_get_fullscreen( libvlc_input_t *, libvlc_exception_t * );
-    
+
 /**
  * Get current video height
  * \param p_input the input
@@ -332,6 +334,22 @@ int libvlc_video_get_height( libvlc_input_t *, libvlc_exception_t * );
  */
 int libvlc_video_get_width( libvlc_input_t *, libvlc_exception_t * );
 
+/**
+ * Get current video aspect ratio
+ * \param p_input the input
+ * \param p_exception an initialized exception
+ * \return the video aspect ratio
+ */
+char *libvlc_video_get_aspect_ratio( libvlc_input_t *, libvlc_exception_t * );
+
+/**
+ * Set new video aspect ratio
+ * \param p_input the input
+ * \param psz_aspect new video aspect-ratio
+ * \param p_exception an initialized exception
+ */
+void libvlc_video_set_aspect_ratio( libvlc_input_t *, char *, libvlc_exception_t * );
+
 /**
  * Take a snapshot of the current video window
  * \param p_input the input
@@ -339,10 +357,9 @@ int libvlc_video_get_width( libvlc_input_t *, libvlc_exception_t * );
  * \param p_exception an initialized exception
  */
 void libvlc_video_take_snapshot( libvlc_input_t *, char *, libvlc_exception_t * );
-    
+
 int libvlc_video_destroy( libvlc_input_t *, libvlc_exception_t *);
 
-    
 /**
  * Resize the current video output window
  * \param p_instance libvlc instance
@@ -352,7 +369,7 @@ int libvlc_video_destroy( libvlc_input_t *, libvlc_exception_t *);
  * \return the mute status (boolean)
  */
 void libvlc_video_resize( libvlc_input_t *, int, int, libvlc_exception_t *);
-    
+
 /**
 * Downcast to this general type as placeholder for a platform specific one, such as:
 *  Drawable on X11,
@@ -453,7 +470,6 @@ vlc_bool_t libvlc_audio_get_mute( libvlc_instance_t *, libvlc_exception_t * );
  */
 void libvlc_audio_set_mute( libvlc_instance_t *, vlc_bool_t , libvlc_exception_t * );
 
-
 /**
  * Get current audio level
  * \param p_instance libvlc instance
@@ -462,7 +478,6 @@ void libvlc_audio_set_mute( libvlc_instance_t *, vlc_bool_t , libvlc_exception_t
  */
 int libvlc_audio_get_volume( libvlc_instance_t *, libvlc_exception_t * );
 
-
 /**
  * Set current audio level
  * \param p_instance libvlc instance
@@ -539,9 +554,6 @@ void libvlc_vlm_set_input( libvlc_instance_t *, char *, char*,
 void libvlc_vlm_set_loop( libvlc_instance_t *, char *, int,
                           libvlc_exception_t *);
 
-
-
-
 /**
  * Edit the parameters of a media. This will delete all existing inputs and
  * add the specified one.
@@ -563,7 +575,7 @@ void libvlc_vlm_change_media( libvlc_instance_t *, char *, char *, char* ,
  * \param p_instance the instance
  * \param psz_name the name of the broadcast
  * \param p_exception an initialized exception
- */ 
+ */
 void libvlc_vlm_play_media ( libvlc_instance_t *, char *, libvlc_exception_t * );
 
 /**
@@ -574,7 +586,6 @@ void libvlc_vlm_play_media ( libvlc_instance_t *, char *, libvlc_exception_t * )
  */ 
 void libvlc_vlm_stop_media ( libvlc_instance_t *, char *, libvlc_exception_t * );
 
-    
 /**
  * Pauses the named broadcast.
  * \param p_instance the instance
@@ -643,6 +654,7 @@ typedef struct libvlc_log_message_t
     const char *psz_header;   /* optional header */
     const char *psz_message;  /* message */
 } libvlc_log_message_t;
+
 /**
  * Returns the VLC messaging verbosity level
  * \param p_instance libvlc instance
index c689fb2bff45ecad1daf99ee9e3381c14f91a013..60f9a0c26bb550624a4975cb96ede0248f951402 100755 (executable)
@@ -1078,7 +1078,7 @@ enum LibvlcPlaylistNPObjectMethodIds
     ID_next,\r
     ID_prev,\r
     ID_clear,\r
-    ID_removeitem,\r
+    ID_removeitem\r
 };\r
 \r
 RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result)\r
@@ -1323,7 +1323,7 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::invoke(int index, const NP
     }\r
     return INVOKERESULT_GENERIC_ERROR;\r
 }\r
\r
+\r
 void LibvlcPlaylistNPObject::parseOptions(const NPString &s, int *i_options, char*** ppsz_options)\r
 {\r
     if( s.utf8length )\r
@@ -1460,6 +1460,7 @@ const NPUTF8 * const LibvlcVideoNPObject::propertyNames[] =
     "fullscreen",\r
     "height",\r
     "width",\r
+    "aspectRatio"\r
 };\r
 \r
 enum LibvlcVideoNPObjectPropertyIds\r
@@ -1467,6 +1468,7 @@ enum LibvlcVideoNPObjectPropertyIds
     ID_fullscreen,\r
     ID_height,\r
     ID_width,\r
+    ID_aspectratio\r
 };\r
 \r
 const int LibvlcVideoNPObject::propertyCount = sizeof(LibvlcVideoNPObject::propertyNames)/sizeof(NPUTF8 *);\r
@@ -1528,6 +1530,22 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::getProperty(int index, NPVari
                 INT32_TO_NPVARIANT(val, result);\r
                 return INVOKERESULT_NO_ERROR;\r
             }\r
+            case ID_aspectratio:\r
+            {\r
+                NPUTF8 *psz_aspect = libvlc_video_get_aspect_ratio(p_input, &ex);\r
+                libvlc_input_free(p_input);\r
+                if( libvlc_exception_raised(&ex) )\r
+                {\r
+                    NPN_SetException(this, libvlc_exception_get_message(&ex));\r
+                    libvlc_exception_clear(&ex);\r
+                    return INVOKERESULT_GENERIC_ERROR;\r
+                }\r
+                if( !psz_aspect )\r
+                    return INVOKERESULT_GENERIC_ERROR;\r
+\r
+                STRINGZ_TO_NPVARIANT(psz_aspect, result);\r
+                return INVOKERESULT_NO_ERROR;\r
+            }\r
         }\r
         libvlc_input_free(p_input);\r
     }\r
@@ -1571,6 +1589,33 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::setProperty(int index, const
                 }\r
                 return INVOKERESULT_NO_ERROR;\r
             }\r
+            case ID_aspectratio:\r
+            {\r
+                char *psz_aspect = NULL;\r
+\r
+                if( ! NPVARIANT_IS_STRING(value) )\r
+                {\r
+                    libvlc_input_free(p_input);\r
+                    return INVOKERESULT_INVALID_VALUE;\r
+                }\r
+\r
+                psz_aspect = stringValue(NPVARIANT_TO_STRING(value));\r
+                if( !psz_aspect )\r
+                    return INVOKERESULT_GENERIC_ERROR;\r
+\r
+                libvlc_video_set_aspect_ratio(p_input, psz_aspect, &ex);\r
+                if( psz_aspect )\r
+                    free(psz_aspect );\r
+\r
+                libvlc_input_free(p_input);\r
+                if( libvlc_exception_raised(&ex) )\r
+                {\r
+                    NPN_SetException(this, libvlc_exception_get_message(&ex));\r
+                    libvlc_exception_clear(&ex);\r
+                    return INVOKERESULT_GENERIC_ERROR;\r
+                }\r
+                return INVOKERESULT_NO_ERROR;\r
+            }\r
         }\r
         libvlc_input_free(p_input);\r
     }\r
index 7617eb369a3b9f14c13f5fb290f016d37039abee..1e2ac26e13087e41e6c495735b81b815071e73ab 100644 (file)
@@ -210,7 +210,6 @@ vlc_bool_t libvlc_input_has_vout( libvlc_input_t *p_input,
     return VLC_TRUE;
 }
 
-
 int libvlc_video_reparent( libvlc_input_t *p_input, libvlc_drawable_t d,
                            libvlc_exception_t *p_e )
 {
@@ -305,7 +304,7 @@ void libvlc_video_set_viewport( libvlc_instance_t *p_instance,
         libvlc_input_t *p_input = libvlc_playlist_get_input(p_instance, p_e);
         if( p_input )
         {
-           vout_thread_t *p_vout = GetVout( p_input, p_e );
+            vout_thread_t *p_vout = GetVout( p_input, p_e );
             if( p_vout )
             {
                 /* change viewport for running vout */
@@ -319,6 +318,37 @@ void libvlc_video_set_viewport( libvlc_instance_t *p_instance,
     }
 }
 
+char *libvlc_video_get_aspect_ratio( libvlc_input_t *p_input,
+                                   libvlc_exception_t *p_e )
+{
+    char *psz_aspect = 0;
+    vout_thread_t *p_vout = GetVout( p_input, p_e );
+
+    if( !p_vout )
+        return 0;
+
+    psz_aspect = var_GetString( p_vout1, "aspect-ratio" );
+    vlc_object_release( p_vout );
+    return psz_aspect;
+}
+
+void libvlc_video_set_aspect_ratio( libvlc_input_t *p_input,
+                                    char *psz_aspect, libvlc_exception_t *p_e )
+{
+    vout_thread_t *p_vout = GetVout( p_input, p_e );
+    int i_ret = -1;
+
+    if( !p_vout )
+        return;
+
+    i_ret = var_SetString( p_vout, "aspect-ratio", psz_aspect );
+    if( i_ret )
+        libvlc_exception_raise( p_e,
+                        "Unexpected error while setting aspect-ratio value" );
+
+    vlc_object_release( p_vout );
+}
+
 int libvlc_video_destroy( libvlc_input_t *p_input,
                           libvlc_exception_t *p_e )
 {