#include "vlccontrol2.h"
#include "viewobject.h"
#include "dataobject.h"
+#include "supporterrorinfo.h"
#include "utils.h"
//class factory
static LRESULT CALLBACK VLCInPlaceClassWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
- switch( uMsg )
- {
- case WM_ERASEBKGND:
- return 1L;
-
- case WM_PAINT:
- PAINTSTRUCT ps;
- if( GetUpdateRect(hWnd, NULL, FALSE) )
- {
- BeginPaint(hWnd, &ps);
- EndPaint(hWnd, &ps);
- }
- return 0L;
-
- default:
- return DefWindowProc(hWnd, uMsg, wParam, lParam);
- }
-};
-
-static LRESULT CALLBACK VLCVideoClassWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
VLCPlugin *p_instance = reinterpret_cast<VLCPlugin *>(GetWindowLongPtr(hWnd, GWLP_USERDATA));
switch( uMsg )
wClass.hbrBackground = NULL;
wClass.lpszMenuName = NULL;
wClass.lpszClassName = getInPlaceWndClassName();
-
+
_inplace_wndclass_atom = RegisterClass(&wClass);
}
else
_inplace_wndclass_atom = 0;
}
- if( ! GetClassInfo(hInstance, getVideoWndClassName(), &wClass) )
- {
- wClass.style = CS_NOCLOSE;
- wClass.lpfnWndProc = VLCVideoClassWndProc;
- wClass.cbClsExtra = 0;
- wClass.cbWndExtra = 0;
- wClass.hInstance = hInstance;
- wClass.hIcon = NULL;
- wClass.hCursor = LoadCursor(NULL, IDC_ARROW);
- wClass.hbrBackground = NULL;
- wClass.lpszMenuName = NULL;
- wClass.lpszClassName = getVideoWndClassName();
-
- _video_wndclass_atom = RegisterClass(&wClass);
- }
- else
- {
- _video_wndclass_atom = 0;
- }
-
HBITMAP hbitmap = (HBITMAP)LoadImage(getHInstance(), TEXT("INPLACE-PICT"), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
if( NULL != hbitmap )
{
if( 0 != _inplace_wndclass_atom )
UnregisterClass(MAKEINTATOM(_inplace_wndclass_atom), _hinstance);
- if( 0 != _video_wndclass_atom )
- UnregisterClass(MAKEINTATOM(_video_wndclass_atom), _hinstance);
-
if( NULL != _inplace_picture )
_inplace_picture->Release();
};
VLCPlugin::VLCPlugin(VLCPluginClass *p_class, LPUNKNOWN pUnkOuter) :
_inplacewnd(NULL),
- _videownd(NULL),
_p_class(p_class),
_i_ref(1UL),
_p_libvlc(NULL),
vlcViewObject = new VLCViewObject(this);
vlcDataObject = new VLCDataObject(this);
vlcOleObject = new VLCOleObject(this);
+ vlcSupportErrorInfo = new VLCSupportErrorInfo(this);
// configure controlling IUnknown interface for implemented interfaces
this->pUnkOuter = (NULL != pUnkOuter) ? pUnkOuter : dynamic_cast<LPUNKNOWN>(this);
VLCPlugin::~VLCPlugin()
{
+ delete vlcSupportErrorInfo;
delete vlcOleObject;
delete vlcDataObject;
delete vlcViewObject;
_p_pict->Release();
SysFreeString(_bstr_mrl);
+ SysFreeString(_bstr_baseurl);
_p_class->Release();
};
*ppv = reinterpret_cast<LPVOID>(vlcViewObject);
else if( IID_IDataObject == riid )
*ppv = reinterpret_cast<LPVOID>(vlcDataObject);
+ else if( IID_ISupportErrorInfo == riid )
+ *ppv = reinterpret_cast<LPVOID>(vlcSupportErrorInfo);
else
{
*ppv = NULL;
//////////////////////////////////////
-/*
-** 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
-*/
-
-static void getViewportCoords(LPRECT lprPosRect, LPRECT lprClipRect)
-{
- RECT bounds;
- bounds.right = lprPosRect->right-lprPosRect->left;
-
- if( lprClipRect->left <= lprPosRect->left )
- {
- // left side is not clipped out
- bounds.left = 0;
-
- if( lprClipRect->right >= lprPosRect->right )
- {
- // right side is not clipped out, no change
- }
- else if( lprClipRect->right >= lprPosRect->left )
- {
- // right side is clipped out
- lprPosRect->right = lprClipRect->right;
- }
- else
- {
- // outside of clipping rectange, not visible
- lprPosRect->right = lprPosRect->left;
- }
- }
- else
- {
- // left side is clipped out
- bounds.left = lprPosRect->left-lprClipRect->left;
- bounds.right += bounds.left;
-
- lprPosRect->left = lprClipRect->left;
- if( lprClipRect->right >= lprPosRect->right )
- {
- // right side is not clipped out
- }
- else
- {
- // right side is clipped out
- lprPosRect->right = lprClipRect->right;
- }
- }
-
- bounds.bottom = lprPosRect->bottom-lprPosRect->top;
-
- if( lprClipRect->top <= lprPosRect->top )
- {
- // top side is not clipped out
- bounds.top = 0;
-
- if( lprClipRect->bottom >= lprPosRect->bottom )
- {
- // bottom side is not clipped out, no change
- }
- else if( lprClipRect->bottom >= lprPosRect->top )
- {
- // bottom side is clipped out
- lprPosRect->bottom = lprClipRect->bottom;
- }
- else
- {
- // outside of clipping rectange, not visible
- lprPosRect->right = lprPosRect->left;
- }
- }
- else
- {
- bounds.top = lprPosRect->top-lprClipRect->top;
- bounds.bottom += bounds.top;
-
- lprPosRect->top = lprClipRect->top;
- if( lprClipRect->bottom >= lprPosRect->bottom )
- {
- // bottom side is not clipped out
- }
- else
- {
- // bottom side is clipped out
- lprPosRect->bottom = lprClipRect->bottom;
- }
- }
- *lprClipRect = *lprPosRect;
- *lprPosRect = bounds;
-};
-
HRESULT VLCPlugin::onInit(void)
{
if( NULL == _p_libvlc )
int ppsz_argc = 1;
HKEY h_key;
- DWORD i_type, i_data = MAX_PATH + 1;
- char p_data[MAX_PATH + 1];
- if( RegOpenKeyEx( HKEY_LOCAL_MACHINE, "Software\\VideoLAN\\VLC",
+ char p_data[MAX_PATH];
+ if( RegOpenKeyEx( HKEY_LOCAL_MACHINE, TEXT("Software\\VideoLAN\\VLC"),
0, KEY_READ, &h_key ) == ERROR_SUCCESS )
{
- if( RegQueryValueEx( h_key, "InstallDir", 0, &i_type,
- (LPBYTE)p_data, &i_data ) == ERROR_SUCCESS )
- {
- if( i_type == REG_SZ )
- {
- strcat( p_data, "\\plugins" );
- ppsz_argv[ppsz_argc++] = "--plugin-path";
- ppsz_argv[ppsz_argc++] = p_data;
- }
- }
- RegCloseKey( h_key );
+ DWORD i_type, i_data = MAX_PATH;
+ TCHAR w_data[MAX_PATH];
+ if( RegQueryValueEx( h_key, TEXT("InstallDir"), 0, &i_type,
+ (LPBYTE)w_data, &i_data ) == ERROR_SUCCESS )
+ {
+ if( i_type == REG_SZ )
+ {
+ if( WideCharToMultiByte(CP_UTF8, 0, w_data, -1, p_data,
+ sizeof(p_data)-sizeof("\\plugins")+1, NULL, NULL) )
+ {
+ strcat( p_data, "\\plugins" );
+ ppsz_argv[ppsz_argc++] = "--plugin-path";
+ ppsz_argv[ppsz_argc++] = p_data;
+ }
+ }
+ }
+ RegCloseKey( h_key );
}
- char p_path[MAX_PATH+1];
- DWORD len = GetModuleFileNameA(DllGetModule(), p_path, sizeof(p_path));
- if( len > 0 )
- {
- p_path[len] = '\0';
- ppsz_argv[0] = p_path;
- }
+ char p_path[MAX_PATH];
+ {
+ TCHAR w_path[MAX_PATH];
+ DWORD len = GetModuleFileName(DllGetModule(), w_path, MAX_PATH);
+ if( len > 0 )
+ {
+ len = WideCharToMultiByte(CP_UTF8, 0, w_path, len, p_path,
+ sizeof(p_path)-1, NULL, NULL);
+ if( len > 0 )
+ {
+ p_path[len] = '\0';
+ ppsz_argv[0] = p_path;
+ }
+ }
+ }
// make sure plugin isn't affected with VLC single instance mode
ppsz_argv[ppsz_argc++] = "--no-one-instance";
if( _b_autoloop )
ppsz_argv[ppsz_argc++] = "--loop";
- // initial volume setting
- char volBuffer[16];
- ppsz_argv[ppsz_argc++] = "--volume";
- if( _b_mute )
- {
- ppsz_argv[ppsz_argc++] = "0";
- }
- else
- {
- snprintf(volBuffer, sizeof(volBuffer), "%d", _i_volume);
- ppsz_argv[ppsz_argc++] = volBuffer;
- }
-
if( IsDebuggerPresent() )
{
/*
return E_FAIL;
}
+ // initial volume setting
+ libvlc_audio_set_volume(_p_libvlc, _i_volume, NULL);
+ if( _b_mute )
+ {
+ libvlc_audio_set_mute(_p_libvlc, TRUE, NULL);
+ }
+
+ // initial playlist item
if( SysStringLen(_bstr_mrl) > 0 )
{
char *psz_mrl = NULL;
if( SysStringLen(_bstr_baseurl) > 0 )
{
- DWORD len = INTERNET_MAX_URL_LENGTH;
- LPOLESTR abs_url = (LPOLESTR)CoTaskMemAlloc(sizeof(OLECHAR)*len);
+ /*
+ ** if the MRL a relative URL, we should end up with an absolute URL
+ */
+ LPWSTR abs_url = CombineURL(_bstr_baseurl, _bstr_mrl);
if( NULL != abs_url )
{
- /*
- ** if the MRL a relative URL, we should end up with an absolute URL
- */
- if( SUCCEEDED(UrlCombineW(_bstr_baseurl, _bstr_mrl, abs_url, &len,
- URL_ESCAPE_UNSAFE|URL_PLUGGABLE_PROTOCOL)) )
- {
- psz_mrl = CStrFromBSTR(CP_UTF8, abs_url);
- }
- else
- {
- psz_mrl = CStrFromBSTR(CP_UTF8, _bstr_mrl);
- }
+ psz_mrl = CStrFromWSTR(CP_UTF8, abs_url, wcslen(abs_url));
CoTaskMemFree(abs_url);
}
+ else
+ {
+ psz_mrl = CStrFromBSTR(CP_UTF8, _bstr_mrl);
+ }
}
else
{
return S_OK;
};
+void VLCPlugin::setErrorInfo(REFIID riid, const char *description)
+{
+ vlcSupportErrorInfo->setErrorInfo( getClassID() == CLSID_VLCPlugin2 ?
+ OLESTR("VideoLAN.VLCPlugin.2") : OLESTR("VideoLAN.VLCPlugin.1"),
+ riid, description );
+};
+
HRESULT VLCPlugin::onAmbientChanged(LPUNKNOWN pContainer, DISPID dispID)
{
VARIANT v;
{
libvlc_instance_t* p_libvlc = _p_libvlc;
+ IVLCLog *p_log;
+ if( SUCCEEDED(vlcControl2->get_log(&p_log)) )
+ {
+ // make sure the log is disabled
+ p_log->put_verbosity(-1);
+ p_log->Release();
+ }
+
_p_libvlc = NULL;
vlcDataObject->onClose();
HRESULT VLCPlugin::onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprcPosRect, LPCRECT lprcClipRect)
{
- RECT posRect = *lprcPosRect;
RECT clipRect = *lprcClipRect;
/*
** record keeping of control geometry within container
*/
- _posRect = posRect;
-
- /*
- ** convert posRect & clipRect to match control viewport coordinates
- */
- getViewportCoords(&posRect, &clipRect);
+ _posRect = *lprcPosRect;
/*
** Create a window for in place activated control.
** the window geometry matches the control viewport
** within container so that embedded video is always
- ** properly clipped.
+ ** properly displayed.
*/
_inplacewnd = CreateWindow(_p_class->getInPlaceWndClassName(),
- "VLC Plugin In-Place Window",
+ TEXT("VLC Plugin In-Place Window"),
WS_CHILD|WS_CLIPCHILDREN|WS_CLIPSIBLINGS,
- clipRect.left,
- clipRect.top,
- clipRect.right-clipRect.left,
- clipRect.bottom-clipRect.top,
+ lprcPosRect->left,
+ lprcPosRect->top,
+ lprcPosRect->right-lprcPosRect->left,
+ lprcPosRect->bottom-lprcPosRect->top,
hwndParent,
0,
_p_class->getHInstance(),
SetWindowLongPtr(_inplacewnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this));
- /*
- ** VLC embedded video automatically grows to cover client
- ** area of parent window.
- ** hence create a such a 'parent' window whose geometry
- ** is always correct relative to the viewport bounds
- */
- _videownd = CreateWindow(_p_class->getVideoWndClassName(),
- "VLC Plugin Video Window",
- WS_CHILD|WS_CLIPCHILDREN|WS_VISIBLE,
- posRect.left,
- posRect.top,
- posRect.right-posRect.left,
- posRect.bottom-posRect.top,
- _inplacewnd,
- 0,
- _p_class->getHInstance(),
- NULL
- );
-
- if( NULL == _videownd )
- {
- DestroyWindow(_inplacewnd);
- return E_FAIL;
- }
+ /* change cliprect coordinates system relative to window bounding rect */
+ OffsetRect(&clipRect, -lprcPosRect->left, -lprcPosRect->top);
- SetWindowLongPtr(_videownd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this));
+ HRGN clipRgn = CreateRectRgnIndirect(&clipRect);
+ SetWindowRgn(_inplacewnd, clipRgn, TRUE);
if( _b_usermode )
{
/* set internal video width and height */
libvlc_video_set_size(p_libvlc,
- posRect.right-posRect.left,
- posRect.bottom-posRect.top,
+ lprcPosRect->right-lprcPosRect->left,
+ lprcPosRect->bottom-lprcPosRect->top,
NULL );
/* set internal video parent window */
libvlc_video_set_parent(p_libvlc,
- reinterpret_cast<libvlc_drawable_t>(_videownd), NULL);
+ reinterpret_cast<libvlc_drawable_t>(_inplacewnd), NULL);
if( _b_autoplay & (libvlc_playlist_items_count(p_libvlc, NULL) > 0) )
{
fireOnStopEvent();
}
- DestroyWindow(_videownd);
- _videownd = NULL;
DestroyWindow(_inplacewnd);
_inplacewnd = NULL;
-
+
return S_OK;
};
{
ShowWindow(_inplacewnd, fVisible ? SW_SHOW : SW_HIDE);
if( fVisible )
- InvalidateRect(_videownd, NULL, TRUE);
+ InvalidateRect(_inplacewnd, NULL, TRUE);
}
setDirty(TRUE);
firePropChangedEvent(DISPID_Visible);
void VLCPlugin::onPositionChange(LPCRECT lprcPosRect, LPCRECT lprcClipRect)
{
RECT clipRect = *lprcClipRect;
- RECT posRect = *lprcPosRect;
//RedrawWindow(GetParent(_inplacewnd), &_posRect, NULL, RDW_INVALIDATE|RDW_ERASE|RDW_ALLCHILDREN);
/*
** record keeping of control geometry within container
*/
- _posRect = posRect;
-
- /*
- ** convert posRect & clipRect to match control viewport coordinates
- */
- getViewportCoords(&posRect, &clipRect);
+ _posRect = *lprcPosRect;
/*
** change in-place window geometry to match clipping region
*/
SetWindowPos(_inplacewnd, NULL,
- clipRect.left,
- clipRect.top,
- clipRect.right-clipRect.left,
- clipRect.bottom-clipRect.top,
+ lprcPosRect->left,
+ lprcPosRect->top,
+ lprcPosRect->right-lprcPosRect->left,
+ lprcPosRect->bottom-lprcPosRect->top,
SWP_NOACTIVATE|
SWP_NOCOPYBITS|
SWP_NOZORDER|
SWP_NOOWNERZORDER );
- /*
- ** change video window geometry to match object bounds within clipping region
- */
- SetWindowPos(_videownd, NULL,
- posRect.left,
- posRect.top,
- posRect.right-posRect.left,
- posRect.bottom-posRect.top,
- SWP_NOACTIVATE|
- SWP_NOCOPYBITS|
- SWP_NOZORDER|
- SWP_NOOWNERZORDER );
+ /* change cliprect coordinates system relative to window bounding rect */
+ OffsetRect(&clipRect, -lprcPosRect->left, -lprcPosRect->top);
+ HRGN clipRgn = CreateRectRgnIndirect(&clipRect);
+ SetWindowRgn(_inplacewnd, clipRgn, FALSE);
//RedrawWindow(_videownd, &posRect, NULL, RDW_INVALIDATE|RDW_ERASE|RDW_ALLCHILDREN);
if( isRunning() )
{
libvlc_video_set_size(_p_libvlc,
- posRect.right-posRect.left,
- posRect.bottom-posRect.top,
+ lprcPosRect->right-lprcPosRect->left,
+ lprcPosRect->bottom-lprcPosRect->top,
NULL );
}
};
DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
vlcConnectionPointContainer->fireEvent(DISPID_StopEvent, &dispparamsNoArgs);
};
-