]> git.sesse.net Git - vlc/commitdiff
(Forward port of [17380]) Aspect ratio property for ActiveX plugin
authorJean-Paul Saman <jpsaman@videolan.org>
Mon, 30 Oct 2006 16:26:43 +0000 (16:26 +0000)
committerJean-Paul Saman <jpsaman@videolan.org>
Mon, 30 Oct 2006 16:26:43 +0000 (16:26 +0000)
activex/axvlc.idl
activex/axvlc_idl.h
activex/vlccontrol2.cpp
activex/vlccontrol2.h

index 25b401b11f5fe2ae220f6f7176a36658497acc9c..0cd7992318b0333f948590a6b5db5dc9533a1c05 100644 (file)
@@ -402,6 +402,11 @@ library AXVLC
         [propget, helpstring("Returns video original height.")]\r
         HRESULT height([out, retval] long* height);\r
 \r
+        [propget, helpstring("Returns video aspect ratio.")]\r
+        HRESULT aspectRatio([out, retval] BSTR *aspect);\r
+        [propput, helpstring("Sets video aspect ratio.")]\r
+        HRESULT aspectRatio([in] BSTR aspect);\r
+\r
         [helpstring("toggle fullscreen/windowed state.")]\r
         HRESULT toggleFullscreen();\r
     };\r
index 838d20fe9e3ad5a5ea663c107678288734c1bca3..ec703cca53cfa8e78d0399a51f233b141de7cddb 100644 (file)
@@ -2034,6 +2034,12 @@ interface IVLCVideo : public IDispatch
     virtual HRESULT STDMETHODCALLTYPE get_height(
         long* height) = 0;
 
+    virtual HRESULT STDMETHODCALLTYPE get_aspectRatio(
+        BSTR* aspect) = 0;
+
+    virtual HRESULT STDMETHODCALLTYPE put_aspectRatio(
+        BSTR aspect) = 0;
+
     virtual HRESULT STDMETHODCALLTYPE toggleFullscreen(
         ) = 0;
 
@@ -2101,6 +2107,14 @@ typedef struct IVLCVideoVtbl {
         IVLCVideo* This,
         long* height);
 
+    HRESULT (STDMETHODCALLTYPE *get_aspectRatio)(
+        IVLCVideo* This,
+        BSTR* aspect);
+
+    HRESULT (STDMETHODCALLTYPE *put_aspectRatio)(
+        IVLCVideo* This,
+        BSTR aspect);
+
     HRESULT (STDMETHODCALLTYPE *toggleFullscreen)(
         IVLCVideo* This);
 
@@ -2125,6 +2139,8 @@ interface IVLCVideo {
 #define IVLCVideo_put_fullscreen(p,a) (p)->lpVtbl->put_fullscreen(p,a)
 #define IVLCVideo_get_width(p,a) (p)->lpVtbl->get_width(p,a)
 #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_toggleFullscreen(p) (p)->lpVtbl->toggleFullscreen(p)
 #endif
 
@@ -2162,6 +2178,22 @@ void __RPC_STUB IVLCVideo_get_height_Stub(
     IRpcChannelBuffer* pRpcChannelBuffer,
     PRPC_MESSAGE pRpcMessage,
     DWORD* pdwStubPhase);
+HRESULT CALLBACK IVLCVideo_get_aspectRatio_Proxy(
+    IVLCVideo* This,
+    BSTR* aspect);
+void __RPC_STUB IVLCVideo_get_aspectRatio_Stub(
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
+    PRPC_MESSAGE pRpcMessage,
+    DWORD* pdwStubPhase);
+HRESULT CALLBACK IVLCVideo_put_aspectRatio_Proxy(
+    IVLCVideo* This,
+    BSTR aspect);
+void __RPC_STUB IVLCVideo_put_aspectRatio_Stub(
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
+    PRPC_MESSAGE pRpcMessage,
+    DWORD* pdwStubPhase);
 HRESULT CALLBACK IVLCVideo_toggleFullscreen_Proxy(
     IVLCVideo* This);
 void __RPC_STUB IVLCVideo_toggleFullscreen_Stub(
index 711c26f5b8968f7779c19a34e048e13b9ee4daab..7c1b8ed48376d4a1a4dea3f6eb1b6b137b178054 100755 (executable)
@@ -1758,6 +1758,88 @@ STDMETHODIMP VLCVideo::get_height(long* height)
     return hr;
 };
 
+STDMETHODIMP VLCVideo::get_aspectRatio(BSTR *aspect)
+{
+    if( NULL == *aspect )
+        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_aspect = libvlc_video_get_aspect_ratio(p_input, &ex);
+
+            if( !psz_aspect )
+                return E_OUTOFMEMORY;
+
+            if( ! libvlc_exception_raised(&ex) )
+            {
+                *aspect = SysAllocStringByteLen(psz_aspect, strlen(psz_aspect));
+                free( psz_aspect );
+                psz_aspect = NULL;
+                libvlc_input_free(p_input);
+                if( ! libvlc_exception_raised(&ex) )
+                {
+                    return NOERROR;
+                }
+           }
+           if( psz_aspect ) free( psz_aspect );
+        }
+        _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
+        libvlc_exception_clear(&ex);
+        return E_FAIL;
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCVideo::put_aspectRatio(BSTR aspect)
+{
+    if( NULL == aspect )
+        return E_POINTER;
+
+    if( 0 == SysStringLen(aspect) )
+        return E_INVALIDARG;
+
+    libvlc_instance_t* p_libvlc;
+    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);
+            if( NULL == psz_aspect )
+            {
+                return E_OUTOFMEMORY;
+            }
+
+            libvlc_video_set_aspect_ratio(p_input, psz_aspect, &ex);
+
+            CoTaskMemFree(psz_aspect);
+            libvlc_input_free(p_input);
+            if( libvlc_exception_raised(&ex) )
+            {
+                _p_instance->setErrorInfo(IID_IVLCPlaylist,
+                    libvlc_exception_get_message(&ex));
+                libvlc_exception_clear(&ex);
+                return E_FAIL;
+            }
+        }
+        return NOERROR;
+    }
+    return hr;
+};
+
 STDMETHODIMP VLCVideo::toggleFullscreen()
 {
     libvlc_instance_t* p_libvlc;
index a1b748184bbecd892bada2f0aebd8e18f7a4ba46..380a38cf99bca7a33abc7adc667b344caf9c573b 100755 (executable)
@@ -121,7 +121,7 @@ public:
     STDMETHODIMP put_rate(double);
     STDMETHODIMP get_fps(double*);
     STDMETHODIMP get_hasVout(VARIANT_BOOL*);
-    
+
 protected:
     HRESULT loadTypeInfo();
 
@@ -460,6 +460,8 @@ public:
     STDMETHODIMP put_fullscreen(VARIANT_BOOL);
     STDMETHODIMP get_width(long*);
     STDMETHODIMP get_height(long*);
+    STDMETHODIMP get_aspectRatio(BSTR*);
+    STDMETHODIMP put_aspectRatio(BSTR);
     STDMETHODIMP toggleFullscreen();
  
 protected: