]> git.sesse.net Git - vlc/blobdiff - mozilla/control/npolibvlc.cpp
- added 'vlc.video.crop' property for ActiveX/Mozilla
[vlc] / mozilla / control / npolibvlc.cpp
index f5ebe0e4948637c2517f785f37cca2015d3e2f2d..32fc31d1850e7e322e57269a66bec7c7a7c3553e 100755 (executable)
@@ -1761,7 +1761,8 @@ const NPUTF8 * const LibvlcVideoNPObject::propertyNames[] =
     "fullscreen",\r
     "height",\r
     "width",\r
-    "aspectRatio"\r
+    "aspectRatio",\r
+    "crop"\r
 };\r
 \r
 enum LibvlcVideoNPObjectPropertyIds\r
@@ -1769,7 +1770,8 @@ enum LibvlcVideoNPObjectPropertyIds
     ID_video_fullscreen,\r
     ID_video_height,\r
     ID_video_width,\r
-    ID_video_aspectratio\r
+    ID_video_aspectratio,\r
+    ID_video_crop\r
 };\r
 \r
 const int LibvlcVideoNPObject::propertyCount = sizeof(LibvlcVideoNPObject::propertyNames)/sizeof(NPUTF8 *);\r
@@ -1847,6 +1849,22 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::getProperty(int index, NPVari
                 STRINGZ_TO_NPVARIANT(psz_aspect, result);\r
                 return INVOKERESULT_NO_ERROR;\r
             }\r
+            case ID_video_crop:\r
+            {\r
+                NPUTF8 *psz_geometry = libvlc_video_get_crop_geometry(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_geometry )\r
+                    return INVOKERESULT_GENERIC_ERROR;\r
+\r
+                STRINGZ_TO_NPVARIANT(psz_geometry, result);\r
+                return INVOKERESULT_NO_ERROR;\r
+            }\r
         }\r
         libvlc_input_free(p_input);\r
     }\r
@@ -1882,6 +1900,7 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::setProperty(int index, const
                 int val = NPVARIANT_TO_BOOLEAN(value);\r
                 libvlc_set_fullscreen(p_input, val, &ex);\r
                 libvlc_input_free(p_input);\r
+\r
                 if( libvlc_exception_raised(&ex) )\r
                 {\r
                     NPN_SetException(this, libvlc_exception_get_message(&ex));\r
@@ -1908,10 +1927,38 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::setProperty(int index, const
                 }\r
 \r
                 libvlc_video_set_aspect_ratio(p_input, psz_aspect, &ex);\r
-                if( psz_aspect )\r
-                    free(psz_aspect );\r
+                free(psz_aspect );\r
+                libvlc_input_free(p_input);\r
+\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
+            case ID_video_crop:\r
+            {\r
+                char *psz_geometry = NULL;\r
+\r
+                if( ! NPVARIANT_IS_STRING(value) )\r
+                {\r
+                    libvlc_input_free(p_input);\r
+                    return INVOKERESULT_INVALID_VALUE;\r
+                }\r
 \r
+                psz_geometry = stringValue(NPVARIANT_TO_STRING(value));\r
+                if( !psz_geometry )\r
+                {\r
+                    libvlc_input_free(p_input);\r
+                    return INVOKERESULT_GENERIC_ERROR;\r
+                }\r
+\r
+                libvlc_video_set_crop_geometry(p_input, psz_geometry, &ex);\r
+                free(psz_geometry );\r
                 libvlc_input_free(p_input);\r
+\r
                 if( libvlc_exception_raised(&ex) )\r
                 {\r
                     NPN_SetException(this, libvlc_exception_get_message(&ex));\r