- added 'vlc.video.crop' property for ActiveX/Mozilla
authorDamien Fouilleul <damienf@videolan.org>
Mon, 8 Jan 2007 17:37:59 +0000 (17:37 +0000)
committerDamien Fouilleul <damienf@videolan.org>
Mon, 8 Jan 2007 17:37:59 +0000 (17:37 +0000)
activex/axvlc.idl
activex/axvlc.tlb
activex/axvlc_idl.c
activex/axvlc_idl.h
activex/vlccontrol2.cpp
activex/vlccontrol2.h
mozilla/control/npolibvlc.cpp

index cad9cde..910557c 100644 (file)
@@ -422,8 +422,16 @@ library AXVLC
         [propput, helpstring("Sets video aspect ratio.")]\r
         HRESULT aspectRatio([in] BSTR aspect);\r
 \r
+        [propget, helpstring("Returns crop filter geometry.")]\r
+        HRESULT crop([out, retval] BSTR* geometry);\r
+        [propput, helpstring("Sets crop filter geometry.")]\r
+        HRESULT crop([in] BSTR geometry);\r
+\r
         [helpstring("toggle fullscreen/windowed state.")]\r
         HRESULT toggleFullscreen();\r
+\r
+        [helpstring("take video snapshot and save into into filePath.")]\r
+        HRESULT takeSnapshot(BSTR filePath);\r
     };\r
 \r
     [\r
index ddfb4bc..4839f43 100644 (file)
Binary files a/activex/axvlc.tlb and b/activex/axvlc.tlb differ
index d8cc8db..17b6b83 100644 (file)
@@ -1,4 +1,4 @@
-/*** Autogenerated by WIDL 0.9.28 from axvlc.idl - Do not edit ***/
+/*** Autogenerated by WIDL 0.9.27 from axvlc.idl - Do not edit ***/
 
 #include <rpc.h>
 #include <rpcndr.h>
index 05ae006..014ebf1 100644 (file)
@@ -1,4 +1,4 @@
-/*** Autogenerated by WIDL 0.9.28 from axvlc.idl - Do not edit ***/
+/*** Autogenerated by WIDL 0.9.27 from axvlc.idl - Do not edit ***/
 #include <rpc.h>
 #include <rpcndr.h>
 
@@ -2253,9 +2253,18 @@ interface IVLCVideo : public IDispatch
     virtual HRESULT STDMETHODCALLTYPE put_aspectRatio(
         BSTR aspect) = 0;
 
+    virtual HRESULT STDMETHODCALLTYPE get_crop(
+        BSTR* geometry) = 0;
+
+    virtual HRESULT STDMETHODCALLTYPE put_crop(
+        BSTR geometry) = 0;
+
     virtual HRESULT STDMETHODCALLTYPE toggleFullscreen(
         ) = 0;
 
+    virtual HRESULT STDMETHODCALLTYPE takeSnapshot(
+        BSTR filePath) = 0;
+
 };
 #else
 typedef struct IVLCVideoVtbl {
@@ -2328,9 +2337,21 @@ typedef struct IVLCVideoVtbl {
         IVLCVideo* This,
         BSTR aspect);
 
+    HRESULT (STDMETHODCALLTYPE *get_crop)(
+        IVLCVideo* This,
+        BSTR* geometry);
+
+    HRESULT (STDMETHODCALLTYPE *put_crop)(
+        IVLCVideo* This,
+        BSTR geometry);
+
     HRESULT (STDMETHODCALLTYPE *toggleFullscreen)(
         IVLCVideo* This);
 
+    HRESULT (STDMETHODCALLTYPE *takeSnapshot)(
+        IVLCVideo* This,
+        BSTR filePath);
+
     END_INTERFACE
 } IVLCVideoVtbl;
 interface IVLCVideo {
@@ -2354,7 +2375,10 @@ interface IVLCVideo {
 #define IVLCVideo_get_height(p,a) (p)->lpVtbl->get_height(p,a)
 #define IVLCVideo_get_aspectRatio(p,a) (p)->lpVtbl->get_aspectRatio(p,a)
 #define IVLCVideo_put_aspectRatio(p,a) (p)->lpVtbl->put_aspectRatio(p,a)
+#define IVLCVideo_get_crop(p,a) (p)->lpVtbl->get_crop(p,a)
+#define IVLCVideo_put_crop(p,a) (p)->lpVtbl->put_crop(p,a)
 #define IVLCVideo_toggleFullscreen(p) (p)->lpVtbl->toggleFullscreen(p)
+#define IVLCVideo_takeSnapshot(p,a) (p)->lpVtbl->takeSnapshot(p,a)
 #endif
 
 #endif
@@ -2407,6 +2431,22 @@ void __RPC_STUB IVLCVideo_put_aspectRatio_Stub(
     IRpcChannelBuffer* pRpcChannelBuffer,
     PRPC_MESSAGE pRpcMessage,
     DWORD* pdwStubPhase);
+HRESULT CALLBACK IVLCVideo_get_crop_Proxy(
+    IVLCVideo* This,
+    BSTR* geometry);
+void __RPC_STUB IVLCVideo_get_crop_Stub(
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
+    PRPC_MESSAGE pRpcMessage,
+    DWORD* pdwStubPhase);
+HRESULT CALLBACK IVLCVideo_put_crop_Proxy(
+    IVLCVideo* This,
+    BSTR geometry);
+void __RPC_STUB IVLCVideo_put_crop_Stub(
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
+    PRPC_MESSAGE pRpcMessage,
+    DWORD* pdwStubPhase);
 HRESULT CALLBACK IVLCVideo_toggleFullscreen_Proxy(
     IVLCVideo* This);
 void __RPC_STUB IVLCVideo_toggleFullscreen_Stub(
@@ -2414,6 +2454,14 @@ void __RPC_STUB IVLCVideo_toggleFullscreen_Stub(
     IRpcChannelBuffer* pRpcChannelBuffer,
     PRPC_MESSAGE pRpcMessage,
     DWORD* pdwStubPhase);
+HRESULT CALLBACK IVLCVideo_takeSnapshot_Proxy(
+    IVLCVideo* This,
+    BSTR filePath);
+void __RPC_STUB IVLCVideo_takeSnapshot_Stub(
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
+    PRPC_MESSAGE pRpcMessage,
+    DWORD* pdwStubPhase);
 
 #endif  /* __IVLCVideo_INTERFACE_DEFINED__ */
 
index 7e70774..e0e9b4a 100644 (file)
@@ -2098,14 +2098,13 @@ STDMETHODIMP VLCVideo::put_aspectRatio(BSTR aspect)
     HRESULT hr = _p_instance->getVLC(&p_libvlc);
     if( SUCCEEDED(hr) )
     {
-        char *psz_aspect = NULL;
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
         libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
         if( ! libvlc_exception_raised(&ex) )
         {
-            psz_aspect = CStrFromBSTR(CP_UTF8, aspect);
+            char *psz_aspect = CStrFromBSTR(CP_UTF8, aspect);
             if( NULL == psz_aspect )
             {
                 return E_OUTOFMEMORY;
@@ -2128,6 +2127,124 @@ STDMETHODIMP VLCVideo::put_aspectRatio(BSTR aspect)
     return hr;
 };
 
+STDMETHODIMP VLCVideo::get_crop(BSTR* geometry)
+{
+    if( NULL == geometry )
+        return E_POINTER;
+
+    libvlc_instance_t* p_libvlc;
+    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
+        if( ! libvlc_exception_raised(&ex) )
+        {
+            char *psz_geometry = libvlc_video_get_crop_geometry(p_input, &ex);
+
+            libvlc_input_free(p_input);
+            if( ! libvlc_exception_raised(&ex) )
+            {
+                if( NULL == psz_geometry )
+                    return E_OUTOFMEMORY;
+
+                *geometry = BSTRFromCStr(CP_UTF8, psz_geometry);
+                free( psz_geometry );
+                psz_geometry = NULL;
+                return (NULL == geometry) ? E_OUTOFMEMORY : NOERROR;
+            }
+            if( psz_geometry ) free( psz_geometry );
+            psz_geometry = NULL;
+        }
+        _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
+        libvlc_exception_clear(&ex);
+        return E_FAIL;
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCVideo::put_crop(BSTR geometry)
+{
+    if( NULL == geometry )
+        return E_POINTER;
+
+    if( 0 == SysStringLen(geometry) )
+        return E_INVALIDARG;
+
+    libvlc_instance_t* p_libvlc;
+    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
+        if( ! libvlc_exception_raised(&ex) )
+        {
+            char *psz_geometry = CStrFromBSTR(CP_UTF8, geometry);
+            if( NULL == psz_geometry )
+            {
+                return E_OUTOFMEMORY;
+            }
+
+            libvlc_video_set_crop_geometry(p_input, psz_geometry, &ex);
+
+            CoTaskMemFree(psz_geometry);
+            libvlc_input_free(p_input);
+            if( libvlc_exception_raised(&ex) )
+            {
+                _p_instance->setErrorInfo(IID_IVLCVideo,
+                    libvlc_exception_get_message(&ex));
+                libvlc_exception_clear(&ex);
+                return E_FAIL;
+            }
+        }
+        return NOERROR;
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCVideo::takeSnapshot(BSTR filePath)
+{
+    if( NULL == filePath )
+        return E_POINTER;
+
+    if( 0 == SysStringLen(filePath) )
+        return E_INVALIDARG;
+
+    libvlc_instance_t* p_libvlc;
+    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
+        if( ! libvlc_exception_raised(&ex) )
+        {
+            char *psz_filepath = CStrFromBSTR(CP_UTF8, filePath);
+            if( NULL == psz_filepath )
+            {
+                return E_OUTOFMEMORY;
+            }
+            /* TODO: check file security */
+
+            libvlc_video_take_snapshot(p_input, psz_filepath, &ex);
+            libvlc_input_free(p_input);
+            if( ! libvlc_exception_raised(&ex) )
+            {
+                return NOERROR;
+            }
+        }
+        _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
+        libvlc_exception_clear(&ex);
+        return E_FAIL;
+    }
+    return hr;
+};
+
 STDMETHODIMP VLCVideo::toggleFullscreen()
 {
     libvlc_instance_t* p_libvlc;
index 37adc97..1bee4fa 100644 (file)
@@ -522,6 +522,9 @@ public:
     STDMETHODIMP get_height(long*);
     STDMETHODIMP get_aspectRatio(BSTR*);
     STDMETHODIMP put_aspectRatio(BSTR);
+    STDMETHODIMP get_crop(BSTR*);
+    STDMETHODIMP put_crop(BSTR);
+    STDMETHODIMP takeSnapshot(BSTR);
     STDMETHODIMP toggleFullscreen();
 
 protected:
index f5ebe0e..32fc31d 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