plugin.h 5.39 KB
Newer Older
1 2 3
/*****************************************************************************
 * plugin.h: ActiveX control for VLC
 *****************************************************************************
4
 * Copyright (C) 2005 the VideoLAN team
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
 *
 * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
 *****************************************************************************/

#ifndef __PLUGIN_H__
#define __PLUGIN_H__

#include <ole2.h>
#include <olectl.h>

#include <vlc/vlc.h>

extern const GUID CLSID_VLCPlugin; 
extern const GUID LIBID_AXVLC; 
extern const GUID DIID_DVLCEvents; 

class VLCPluginClass : public IClassFactory
{

public:

    VLCPluginClass(LONG *p_class_ref,HINSTANCE hInstance);

    /* IUnknown methods */
    STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
    STDMETHODIMP_(ULONG) AddRef(void);
    STDMETHODIMP_(ULONG) Release(void);

    /* IClassFactory methods */
    STDMETHODIMP CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppv);
    STDMETHODIMP LockServer(BOOL fLock);

    LPCSTR getInPlaceWndClassName(void) const { return TEXT("VLC Plugin In-Place"); };
    LPCSTR getVideoWndClassName(void) const { return TEXT("VLC Plugin Video"); };
    HINSTANCE getHInstance(void) const { return _hinstance; };
    HBITMAP getInPlacePict(void) const { return _inplace_hbitmap; };

protected:

    virtual ~VLCPluginClass();

private:

    LPLONG      _p_class_ref;
    HINSTANCE   _hinstance;
    ATOM        _inplace_wndclass_atom;
    ATOM        _video_wndclass_atom;
    HBITMAP     _inplace_hbitmap;
};

class VLCPlugin : public IUnknown
{

public:

    VLCPlugin(VLCPluginClass *p_class);

    /* IUnknown methods */
    STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
    STDMETHODIMP_(ULONG) AddRef(void);
    STDMETHODIMP_(ULONG) Release(void);

    /* custom methods */
    HRESULT getTypeLib(LCID lcid, ITypeLib **pTL)
        { return LoadRegTypeLib(LIBID_AXVLC, 1, 0, lcid, pTL); };
    REFCLSID getClassID(void) { return (REFCLSID)CLSID_VLCPlugin; };
    REFIID getDispEventID(void) { return (REFIID)DIID_DVLCEvents; };

87
    HRESULT onInit(void);
88 89
    HRESULT onLoad(void);
    HRESULT onClientSiteChanged(LPOLECLIENTSITE pActiveSite);
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
    HRESULT onClose(DWORD dwSaveOption);

    BOOL isInPlaceActive(void);
    HRESULT onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprcPosRect, LPCRECT lprcClipRect);
    HRESULT onInPlaceDeactivate(void);
    HWND getInPlaceWindow(void) const { return _inplacewnd; };

    BOOL hasFocus(void);
    void setFocus(BOOL fFocus);

    UINT getCodePage(void) { return _codepage; };
    void setCodePage(UINT cp) { _codepage = cp; };

    int  getVLCObject(void) { return _i_vlc; };

105
    // persistent control properties, may be overriden by HTML & javascript
106 107 108
    void setSourceURL(const char *url) { _psz_src = strdup(url); };
    void setAutoStart(BOOL autostart) { _b_autostart = autostart; };
    void setLoopMode(BOOL loopmode) { _b_loopmode = loopmode; };
109
    void setMute(BOOL mute) { _b_mute = mute; };
110 111 112
    void setSendEvents(BOOL sendevents) { _b_sendevents = sendevents; };
    void setVisible(BOOL fVisible);
    BOOL getVisible(void) { return _b_visible; };
Damien Fouilleul's avatar
Damien Fouilleul committed
113
    
114 115
    // container events
    void onPositionChange(LPCRECT lprcPosRect, LPCRECT lprcClipRect);
116
    void onPaint(HDC hdc, const RECT &bounds, const RECT &pr);
117 118 119 120 121 122 123

    // control events
    void firePropChangedEvent(DISPID dispid);
    void fireOnPlayEvent(void);
    void fireOnPauseEvent(void);
    void fireOnStopEvent(void);

Damien Fouilleul's avatar
Damien Fouilleul committed
124 125 126 127 128 129 130
    // 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; }; 

131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
protected:

    virtual ~VLCPlugin();

private:

    //implemented interfaces
    class VLCOleObject *vlcOleObject;
    class VLCOleControl *vlcOleControl;
    class VLCOleInPlaceObject *vlcOleInPlaceObject;
    class VLCOleInPlaceActiveObject *vlcOleInPlaceActiveObject;
    class VLCPersistStreamInit *vlcPersistStreamInit;
    class VLCPersistStorage *vlcPersistStorage;
    class VLCPersistPropertyBag *vlcPersistPropertyBag;
    class VLCProvideClassInfo *vlcProvideClassInfo;
    class VLCConnectionPointContainer *vlcConnectionPointContainer;
    class VLCObjectSafety *vlcObjectSafety;
    class VLCControl *vlcControl;
149
    class VLCViewObject *vlcViewObject;
150 151 152 153 154 155 156 157 158 159 160 161 162 163

    // in place activated window (Clipping window)
    HWND _inplacewnd;
    // video window (Drawing window)
    HWND _videownd;

    VLCPluginClass *_p_class;
    ULONG _i_ref;

    UINT _codepage;
    char *_psz_src;
    BOOL _b_autostart;
    BOOL _b_loopmode;
    BOOL _b_visible;
164
    BOOL _b_mute;
165
    BOOL _b_sendevents;
Damien Fouilleul's avatar
Damien Fouilleul committed
166 167 168 169
    int  _i_vlc;

    SIZEL _extent;
    RECT _posRect;
170 171 172 173
};

#endif