Commit 1b75d79e authored by Damien Fouilleul's avatar Damien Fouilleul

- source cleanup

- few bugs fixed
- added suport to Ole Extent measurments to improve compatibilty
parent ad67acad
......@@ -344,3 +344,9 @@ D: SSL/TLS support (core, HTTP server, HTTP input)
D: VOC files demultiplexer
S: France
N: Damien Fouilleul
E: Damien.Fouilleul@laposte.net
C: Quovodis
D: ActiveX control
S: Germany
......@@ -67,7 +67,7 @@ make sure that the plugin path is set in the registry as per following example:
[HKEY_LOCAL_MACHINE\Software\VideoLAN\VLC]
InstallDir="C:\Program Files\VideoLAN\VLC"
The InstallDir must contain the 'plugins' directory.
The InstallDir must be the parent directory of the 'plugins' directory.
WARNING: Both control and plugins must come from the same build source tree.
Otherwise, at best, the control will not play any content, at worse
......
......@@ -225,6 +225,16 @@ STDMETHODIMP VLCOleObject::GetClipboardData(DWORD dwReserved, LPDATAOBJECT *ppDa
STDMETHODIMP VLCOleObject::GetExtent(DWORD dwDrawAspect, SIZEL *pSizel)
{
if( NULL == pSizel )
return E_POINTER;
if( dwDrawAspect & DVASPECT_CONTENT )
{
*pSizel = _p_instance->getExtent();
return S_OK;
}
pSizel->cx= 0L;
pSizel->cy= 0L;
return E_NOTIMPL;
};
......@@ -314,6 +324,48 @@ STDMETHODIMP VLCOleObject::SetColorScheme(LOGPALETTE *pLogpal)
STDMETHODIMP VLCOleObject::SetExtent(DWORD dwDrawAspect, SIZEL *pSizel)
{
if( NULL == pSizel )
return E_POINTER;
if( dwDrawAspect & DVASPECT_CONTENT )
{
_p_instance->setExtent(*pSizel);
if( _p_instance->isInPlaceActive() )
{
LPOLEINPLACESITE p_inPlaceSite;
if( SUCCEEDED(_p_clientsite->QueryInterface(IID_IOleInPlaceSite, (void**)&p_inPlaceSite)) )
{
LPOLECONTROLSITE p_controlSite;
RECT posRect = _p_instance->getPosRect();
if( SUCCEEDED(_p_clientsite->QueryInterface(IID_IOleControlSite, (void**)&p_controlSite)) )
{
// use HIMETRIC to container transform
POINTL extent = { pSizel->cx, pSizel->cy };
POINTF container;
if( SUCCEEDED(p_controlSite->TransformCoords(&extent,
&container, XFORMCOORDS_SIZE|XFORMCOORDS_HIMETRICTOCONTAINER)) )
{
posRect.right = ((LONG)container.x)+posRect.left;
posRect.bottom = ((LONG)container.y)+posRect.top;
}
p_controlSite->Release();
}
else {
// use HIMETRIC to display transform
HDC hDC = CreateDevDC(NULL);
posRect.right = (pSizel->cx*GetDeviceCaps(hDC, LOGPIXELSX)/2540L)+posRect.left;
posRect.bottom = (pSizel->cy*GetDeviceCaps(hDC, LOGPIXELSY)/2540L)+posRect.top;
DeleteDC(hDC);
}
p_inPlaceSite->OnPosRectChange(&posRect);
p_inPlaceSite->Release();
}
}
return S_OK;
}
return E_NOTIMPL;
};
......
......@@ -116,7 +116,7 @@ STDMETHODIMP VLCPersistPropertyBag::Load(LPPROPERTYBAG pPropBag, LPERRORLOG pErr
return _p_instance->onLoad();
};
STDMETHODIMP VLCPersistPropertyBag::Save(LPPROPERTYBAG pPropBag, BOOL fClearDiry, BOOL fSaveAllProperties)
STDMETHODIMP VLCPersistPropertyBag::Save(LPPROPERTYBAG pPropBag, BOOL fClearDirty, BOOL fSaveAllProperties)
{
if( NULL == pPropBag )
return E_POINTER;
......
......@@ -250,6 +250,12 @@ VLCPlugin::VLCPlugin(VLCPluginClass *p_class) :
vlcObjectSafety = new VLCObjectSafety(this);
vlcControl = new VLCControl(this);
vlcViewObject = new VLCViewObject(this);
// set default/preferred size (320x240) pixels in HIMETRIC
HDC hDC = CreateDevDC(NULL);
_extent.cx = (320*2540L)/GetDeviceCaps(hDC, LOGPIXELSX);
_extent.cy = (240*2540L)/GetDeviceCaps(hDC, LOGPIXELSY);
DeleteDC(hDC);
};
VLCPlugin::~VLCPlugin()
......@@ -383,6 +389,12 @@ STDMETHODIMP VLCPlugin::QueryInterface(REFIID riid, void **ppv)
*ppv = reinterpret_cast<LPVOID>(vlcViewObject);
return NOERROR;
}
else if( IID_IViewObject2 == riid )
{
AddRef();
*ppv = reinterpret_cast<LPVOID>(vlcViewObject);
return NOERROR;
}
*ppv = NULL;
......@@ -407,29 +419,30 @@ STDMETHODIMP_(ULONG) VLCPlugin::Release(void)
//////////////////////////////////////
/*
** we use an in-place child window to represent plugin viewport,
** whose size is limited by the clipping rectangle
** all drawing within this window must follow
** cartesian coordinate system represented by _bounds.
** we use a window to represent plugin viewport,
** whose geometry is limited by the clipping rectangle
** all drawing within this window must follow must
** follow coordinates system described in lprPosRect
*/
void VLCPlugin::calcPositionChange(LPRECT lprPosRect, LPCRECT lprcClipRect)
static void getViewportCoords(LPRECT lprPosRect, LPRECT lprClipRect)
{
_bounds.right = lprPosRect->right-lprPosRect->left;
RECT bounds;
bounds.right = lprPosRect->right-lprPosRect->left;
if( lprcClipRect->left <= lprPosRect->left )
if( lprClipRect->left <= lprPosRect->left )
{
// left side is not clipped out
_bounds.left = 0;
bounds.left = 0;
if( lprcClipRect->right >= lprPosRect->right )
if( lprClipRect->right >= lprPosRect->right )
{
// right side is not clipped out, no change
}
else if( lprcClipRect->right >= lprPosRect->left )
else if( lprClipRect->right >= lprPosRect->left )
{
// right side is clipped out
lprPosRect->right = lprcClipRect->right;
lprPosRect->right = lprClipRect->right;
}
else
{
......@@ -440,36 +453,36 @@ void VLCPlugin::calcPositionChange(LPRECT lprPosRect, LPCRECT lprcClipRect)
else
{
// left side is clipped out
_bounds.left = lprPosRect->left-lprcClipRect->left;
_bounds.right += _bounds.left;
bounds.left = lprPosRect->left-lprClipRect->left;
bounds.right += bounds.left;
lprPosRect->left = lprcClipRect->left;
if( lprcClipRect->right >= lprPosRect->right )
lprPosRect->left = lprClipRect->left;
if( lprClipRect->right >= lprPosRect->right )
{
// right side is not clipped out
}
else
{
// right side is clipped out
lprPosRect->right = lprcClipRect->right;
lprPosRect->right = lprClipRect->right;
}
}
_bounds.bottom = lprPosRect->bottom-lprPosRect->top;
bounds.bottom = lprPosRect->bottom-lprPosRect->top;
if( lprcClipRect->top <= lprPosRect->top )
if( lprClipRect->top <= lprPosRect->top )
{
// top side is not clipped out
_bounds.top = 0;
bounds.top = 0;
if( lprcClipRect->bottom >= lprPosRect->bottom )
if( lprClipRect->bottom >= lprPosRect->bottom )
{
// bottom side is not clipped out, no change
}
else if( lprcClipRect->bottom >= lprPosRect->top )
else if( lprClipRect->bottom >= lprPosRect->top )
{
// bottom side is clipped out
lprPosRect->bottom = lprcClipRect->bottom;
lprPosRect->bottom = lprClipRect->bottom;
}
else
{
......@@ -479,20 +492,22 @@ void VLCPlugin::calcPositionChange(LPRECT lprPosRect, LPCRECT lprcClipRect)
}
else
{
_bounds.top = lprPosRect->top-lprcClipRect->top;
_bounds.bottom += _bounds.top;
bounds.top = lprPosRect->top-lprClipRect->top;
bounds.bottom += bounds.top;
lprPosRect->top = lprcClipRect->top;
if( lprcClipRect->bottom >= lprPosRect->bottom )
lprPosRect->top = lprClipRect->top;
if( lprClipRect->bottom >= lprPosRect->bottom )
{
// bottom side is not clipped out
}
else
{
// bottom side is clipped out
lprPosRect->bottom = lprcClipRect->bottom;
lprPosRect->bottom = lprClipRect->bottom;
}
}
*lprClipRect = *lprPosRect;
*lprPosRect = bounds;
};
HRESULT VLCPlugin::onInit(BOOL isNew)
......@@ -522,7 +537,7 @@ HRESULT VLCPlugin::onInit(BOOL isNew)
RegCloseKey( h_key );
}
#if 0
#if 1
ppsz_argv[0] = "C:\\cygwin\\home\\Damien_Fouilleul\\dev\\videolan\\vlc-trunk\\vlc";
#endif
......@@ -610,16 +625,30 @@ BOOL VLCPlugin::isInPlaceActive(void)
HRESULT VLCPlugin::onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprcPosRect, LPCRECT lprcClipRect)
{
RECT posRect = *lprcPosRect;
RECT clipRect = *lprcClipRect;
calcPositionChange(&posRect, lprcClipRect);
/*
** record keeping of control geometry within container
*/
_posRect = posRect;
/*
** convert posRect & clipRect to match control viewport coordinates
*/
getViewportCoords(&posRect, &clipRect);
/*
** Create a window for in place activated control.
** the window geometry represents the control viewport
** so that embedded video is always properly clipped.
*/
_inplacewnd = CreateWindow(_p_class->getInPlaceWndClassName(),
"VLC Plugin In-Place Window",
WS_CHILD|WS_CLIPCHILDREN|WS_TABSTOP,
posRect.left,
posRect.top,
posRect.right-posRect.left,
posRect.bottom-posRect.top,
clipRect.left,
clipRect.top,
clipRect.right-clipRect.left,
clipRect.bottom-clipRect.top,
hwndParent,
0,
_p_class->getHInstance(),
......@@ -631,13 +660,18 @@ HRESULT VLCPlugin::onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprc
SetWindowLongPtr(_inplacewnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this));
/*
** VLC embedded video geometry automatically matches parent window.
** hence create a child window so that video position and size
** is always correct relative to the viewport bounds
*/
_videownd = CreateWindow(_p_class->getVideoWndClassName(),
"VLC Plugin Video Window",
WS_CHILD|WS_CLIPCHILDREN|WS_VISIBLE,
_bounds.left,
_bounds.top,
_bounds.right-_bounds.left,
_bounds.bottom-_bounds.top,
posRect.left,
posRect.top,
posRect.right-posRect.left,
posRect.bottom-posRect.top,
_inplacewnd,
0,
_p_class->getHInstance(),
......@@ -763,36 +797,48 @@ void VLCPlugin::onPaint(HDC hdc, const RECT &bounds, const RECT &pr)
void VLCPlugin::onPositionChange(LPCRECT lprcPosRect, LPCRECT lprcClipRect)
{
RECT clipRect = *lprcClipRect;
RECT posRect = *lprcPosRect;
calcPositionChange(&posRect, lprcClipRect);
/*
** record keeping of control geometry within container
*/
_posRect = posRect;
/*
** convert posRect & clipRect to match control viewport coordinates
*/
getViewportCoords(&posRect, &clipRect);
/*
** change in-place window geometry to match clipping region
*/
MoveWindow(_inplacewnd,
posRect.left,
posRect.top,
posRect.right-posRect.left,
posRect.bottom-posRect.top,
clipRect.left,
clipRect.top,
clipRect.right-clipRect.left,
clipRect.bottom-clipRect.top,
FALSE);
/*
** change video window geometry to match object bounds within clipping region
*/
MoveWindow(_videownd,
_bounds.left,
_bounds.top,
_bounds.right-_bounds.left,
_bounds.bottom-_bounds.top,
posRect.left,
posRect.top,
posRect.right-posRect.left,
posRect.bottom-posRect.top,
FALSE);
RECT updateRect;
updateRect.left = -_bounds.left;
updateRect.top = -_bounds.top;
updateRect.right = _bounds.right-_bounds.left;
updateRect.bottom = _bounds.bottom-_bounds.top;
/*
** force a full refresh of control content
*/
RECT updateRect;
updateRect.left = -posRect.left;
updateRect.top = -posRect.top;
updateRect.right = posRect.right-posRect.left;
updateRect.bottom = posRect.bottom-posRect.top;
ValidateRect(_videownd, NULL);
InvalidateRect(_videownd, &updateRect, FALSE);
......
......@@ -116,6 +116,7 @@ public:
void setVisible(BOOL fVisible);
BOOL getVisible(void) { return _b_visible; };
// container events
void onPositionChange(LPCRECT lprcPosRect, LPCRECT lprcClipRect);
void onPaint(HDC hdc, const RECT &bounds, const RECT &pr);
......@@ -126,14 +127,19 @@ public:
void fireOnPauseEvent(void);
void fireOnStopEvent(void);
// control size in HIMETRIC
const SIZEL& getExtent(void) { return _extent; };
void setExtent(const SIZEL& extent) { _extent = extent; };
// control geometry within container
RECT getPosRect(void) { return _posRect; };
protected:
virtual ~VLCPlugin();
private:
void calcPositionChange(LPRECT lprPosRect, LPCRECT lprcClipRect);
//implemented interfaces
class VLCOleObject *vlcOleObject;
class VLCOleControl *vlcOleControl;
......@@ -152,7 +158,6 @@ private:
HWND _inplacewnd;
// video window (Drawing window)
HWND _videownd;
RECT _bounds;
VLCPluginClass *_p_class;
ULONG _i_ref;
......@@ -164,6 +169,9 @@ private:
BOOL _b_visible;
BOOL _b_sendevents;
int _i_vlc;
SIZEL _extent;
RECT _posRect;
};
#endif
......
......@@ -98,4 +98,36 @@ HRESULT GetObjectProperty(LPUNKNOWN object, DISPID dispID, VARIANT& v)
return hr;
};
HDC CreateDevDC(DVTARGETDEVICE *ptd)
{
HDC hdc=NULL;
LPDEVNAMES lpDevNames;
LPDEVMODE lpDevMode;
LPTSTR lpszDriverName;
LPTSTR lpszDeviceName;
LPTSTR lpszPortName;
if (ptd == NULL) {
hdc = CreateDC(TEXT("DISPLAY"), NULL, NULL, NULL);
goto errReturn;
}
lpDevNames = (LPDEVNAMES) ptd; // offset for size field
if (ptd->tdExtDevmodeOffset == 0) {
lpDevMode = NULL;
}else{
lpDevMode = (LPDEVMODE) ((LPTSTR)ptd + ptd->tdExtDevmodeOffset);
}
lpszDriverName = (LPTSTR) lpDevNames + ptd->tdDriverNameOffset;
lpszDeviceName = (LPTSTR) lpDevNames + ptd->tdDeviceNameOffset;
lpszPortName = (LPTSTR) lpDevNames + ptd->tdPortNameOffset;
hdc = CreateDC(lpszDriverName, lpszDeviceName, lpszPortName, lpDevMode);
errReturn:
return hdc;
};
......@@ -34,6 +34,9 @@ extern BSTR BSTRFromCStr(int codePage, const char *s);
// properties
extern HRESULT GetObjectProperty(LPUNKNOWN object, DISPID dispID, VARIANT& v);
// properties
extern HDC CreateDevDC(DVTARGETDEVICE *ptd);
// enumeration
template<class T> class VLCEnum : IUnknown
{
......
......@@ -23,7 +23,7 @@
#include "plugin.h"
#include "viewobject.h"
#include <iostream>
#include "utils.h"
using namespace std;
......@@ -31,9 +31,8 @@ STDMETHODIMP VLCViewObject::Draw(DWORD dwAspect, LONG lindex, PVOID pvAspect,
DVTARGETDEVICE *ptd, HDC hicTargetDev, HDC hdcDraw, LPCRECTL lprcBounds,
LPCRECTL lprcWBounds, BOOL(CALLBACK *pfnContinue)(DWORD), DWORD dwContinue)
{
switch( dwAspect )
if( dwAspect & DVASPECT_CONTENT )
{
case DVASPECT_CONTENT:
if( _p_instance->getVisible() )
{
RECT bounds;
......@@ -44,12 +43,6 @@ STDMETHODIMP VLCViewObject::Draw(DWORD dwAspect, LONG lindex, PVOID pvAspect,
_p_instance->onPaint(hdcDraw, bounds, bounds);
}
return S_OK;
case DVASPECT_THUMBNAIL:
break;
case DVASPECT_ICON:
break;
case DVASPECT_DOCPRINT:
break;
}
return E_NOTIMPL;
};
......@@ -60,19 +53,28 @@ STDMETHODIMP VLCViewObject::Freeze(DWORD dwAspect, LONG lindex,
if( NULL != pvAspect )
return E_INVALIDARG;
return OLE_E_BLANK;
return E_NOTIMPL;
};
STDMETHODIMP VLCViewObject::GetAdvise(LPDWORD pdwAspect, LPDWORD padvf,
LPADVISESINK *ppAdviseSink)
{
return E_NOTIMPL;
if( NULL != pdwAspect )
*pdwAspect = 0;
if( NULL != padvf )
*padvf = 0;
if( NULL != ppAdviseSink )
*ppAdviseSink = NULL;
return S_OK;
};
STDMETHODIMP VLCViewObject::GetColorSet(DWORD dwAspect, LONG lindex,
PVOID pvAspect, DVTARGETDEVICE *ptd, HDC hicTargetDev, LPLOGPALETTE *ppColorSet)
{
return E_NOTIMPL;
return S_FALSE;
};
STDMETHODIMP VLCViewObject::SetAdvise(DWORD dwAspect, DWORD advf,
......@@ -86,3 +88,16 @@ STDMETHODIMP VLCViewObject::Unfreeze(DWORD dwFreeze)
return E_NOTIMPL;
};
STDMETHODIMP VLCViewObject::GetExtent(DWORD dwAspect, LONG lindex,
DVTARGETDEVICE *ptd, LPSIZEL lpSizel)
{
if( dwAspect & DVASPECT_CONTENT )
{
*lpSizel = _p_instance->getExtent();
return S_OK;
}
lpSizel->cx= 0L;
lpSizel->cy= 0L;
return E_NOTIMPL;
};
......@@ -25,7 +25,7 @@
#include <oleidl.h>
class VLCViewObject : public IViewObject
class VLCViewObject : public IViewObject2
{
public:
......@@ -39,7 +39,8 @@ public:
if( (NULL != ppv)
&& (IID_IUnknown == riid)
&& (IID_IPersist == riid)
&& (IID_IViewObject == riid) ) {
&& (IID_IViewObject == riid)
&& (IID_IViewObject2 == riid) ) {
AddRef();
*ppv = reinterpret_cast<LPVOID>(this);
return NOERROR;
......@@ -58,6 +59,9 @@ public:
STDMETHODIMP SetAdvise(DWORD,DWORD,LPADVISESINK);
STDMETHODIMP Unfreeze(DWORD);
// IViewObject2 methods
STDMETHODIMP GetExtent(DWORD,LONG,DVTARGETDEVICE *,LPSIZEL);
private:
VLCPlugin *_p_instance;
......
......@@ -54,6 +54,9 @@ HRESULT VLCControl::getTypeInfo(void)
STDMETHODIMP VLCControl::GetTypeInfoCount(UINT* pctInfo)
{
if( NULL == pctInfo )
return E_INVALIDARG;
if( SUCCEEDED(getTypeInfo()) )
*pctInfo = 1;
else
......@@ -102,7 +105,7 @@ STDMETHODIMP VLCControl::Invoke(DISPID dispIdMember, REFIID riid,
STDMETHODIMP VLCControl::get_Value(VARIANT *pvarValue)
{
if( NULL == pvarValue )
return E_INVALIDARG;
return E_POINTER;
V_VT(pvarValue) = VT_BOOL;
return get_Playing(&V_BOOL(pvarValue));
......@@ -127,7 +130,7 @@ STDMETHODIMP VLCControl::put_Value(VARIANT pvarValue)
STDMETHODIMP VLCControl::get_Visible(VARIANT_BOOL *isVisible)
{
if( NULL == isVisible )
return E_INVALIDARG;
return E_POINTER;
*isVisible = _p_instance->getVisible();
......@@ -180,7 +183,7 @@ STDMETHODIMP VLCControl::stop(void)
STDMETHODIMP VLCControl::get_Playing(VARIANT_BOOL *isPlaying)
{
if( NULL == isPlaying )
return E_INVALIDARG;
return E_POINTER;
int i_vlc = _p_instance->getVLCObject();
if( i_vlc )
......@@ -215,7 +218,7 @@ STDMETHODIMP VLCControl::put_Playing(VARIANT_BOOL isPlaying)
STDMETHODIMP VLCControl::get_Position(float *position)
{
if( NULL == position )
return E_INVALIDARG;
return E_POINTER;
int i_vlc = _p_instance->getVLCObject();
if( i_vlc )
......@@ -241,7 +244,7 @@ STDMETHODIMP VLCControl::put_Position(float position)
STDMETHODIMP VLCControl::get_Time(int *seconds)
{
if( NULL == seconds )
return E_INVALIDARG;
return E_POINTER;
int i_vlc = _p_instance->getVLCObject();
if( i_vlc )
......@@ -289,7 +292,7 @@ STDMETHODIMP VLCControl::fullscreen(void)
STDMETHODIMP VLCControl::get_Length(int *seconds)
{
if( NULL == seconds )
return E_INVALIDARG;
return E_POINTER;
int i_vlc = _p_instance->getVLCObject();
if( i_vlc )
......@@ -326,7 +329,7 @@ STDMETHODIMP VLCControl::playSlower(void)
STDMETHODIMP VLCControl::get_Volume(int *volume)
{
if( NULL == volume )
return E_INVALIDARG;
return E_POINTER;
int i_vlc = _p_instance->getVLCObject();
if( i_vlc )
......@@ -557,7 +560,7 @@ static HRESULT createTargetOptions(int codePage, VARIANT *options, char ***cOpti
STDMETHODIMP VLCControl::addTarget( BSTR uri, VARIANT options, enum VLCPlaylistMode mode, int position)
{
if( NULL == uri )
if( 0 == SysStringLen(uri) )
return E_INVALIDARG;
HRESULT hr = E_UNEXPECTED;
......@@ -588,7 +591,7 @@ STDMETHODIMP VLCControl::addTarget( BSTR uri, VARIANT options, enum VLCPlaylistM
STDMETHODIMP VLCControl::get_PlaylistIndex(int *index)
{
if( NULL == index )
return E_INVALIDARG;
return E_POINTER;
int i_vlc = _p_instance->getVLCObject();
if( i_vlc )
......@@ -647,7 +650,7 @@ STDMETHODIMP VLCControl::playlistClear(void)
STDMETHODIMP VLCControl::get_VersionInfo(BSTR *version)
{
if( NULL == version )
return E_INVALIDARG;
return E_POINTER;
const char *versionStr = VLC_Version();
if( NULL != versionStr )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment