wmp_private.h 3.8 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
/*
 * Copyright 2014 Jacek Caban for CodeWeavers
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */

#define COBJMACROS

#include "windows.h"
22
#include "wine/heap.h"
23
#include "wine/unicode.h"
24
#include "ole2.h"
25
#include "dshow.h"
26 27
#include "wmp.h"

28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
#define TID_LIST \
    XIID(NULL) \
    CTID(WindowsMediaPlayer)

typedef enum {
#define XIID(iface) iface ## _tid,
#define CTID(name) name ## _tid,
TID_LIST
#undef XIID
#undef CTID
    LAST_tid
} typeinfo_id;

HRESULT get_typeinfo(typeinfo_id tid, ITypeInfo **typeinfo) DECLSPEC_HIDDEN;

43 44 45 46 47 48 49 50 51 52 53
typedef struct {
    IConnectionPoint IConnectionPoint_iface;

    IConnectionPointContainer *container;

    IDispatch **sinks;
    DWORD sinks_size;

    IID iid;
} ConnectionPoint;

54 55 56 57 58 59
typedef struct {
    IWMPMedia IWMPMedia_iface;

    LONG ref;

    WCHAR *url;
60 61

    DOUBLE duration;
62 63
} WMPMedia;

64 65 66 67 68 69
struct WindowsMediaPlayer {
    IOleObject IOleObject_iface;
    IProvideClassInfo2 IProvideClassInfo2_iface;
    IPersistStreamInit IPersistStreamInit_iface;
    IOleInPlaceObjectWindowless IOleInPlaceObjectWindowless_iface;
    IConnectionPointContainer IConnectionPointContainer_iface;
70
    IOleControl IOleControl_iface;
71
    IWMPPlayer4 IWMPPlayer4_iface;
72
    IWMPPlayer IWMPPlayer_iface;
73
    IWMPSettings IWMPSettings_iface;
74
    IWMPControls IWMPControls_iface;
75
    IWMPNetwork IWMPNetwork_iface;
76 77 78 79

    LONG ref;

    IOleClientSite *client_site;
80
    HWND hwnd;
81
    SIZEL extent;
82

83 84 85 86
    /* Settings */
    VARIANT_BOOL auto_start;
    VARIANT_BOOL invoke_urls;
    VARIANT_BOOL enable_error_dialogs;
87
    LONG volume;
88

89
    ConnectionPoint *wmpocx;
90

91
    WMPMedia *media;
92 93 94 95

    /* DirectShow stuff */
    IGraphBuilder* filter_graph;
    IMediaControl* media_control;
96
    IMediaEvent* media_event;
97
    IMediaSeeking* media_seeking;
98
    IBasicAudio* basic_audio;
99 100 101

    /* Async event notification */
    HWND msg_window;
102 103
};

104
BOOL init_player(WindowsMediaPlayer*) DECLSPEC_HIDDEN;
105
void destroy_player(WindowsMediaPlayer*) DECLSPEC_HIDDEN;
106
WMPMedia *unsafe_impl_from_IWMPMedia(IWMPMedia *iface) DECLSPEC_HIDDEN;
107
HRESULT create_media_from_url(BSTR url, double duration, IWMPMedia **ppMedia) DECLSPEC_HIDDEN;
108 109
void ConnectionPointContainer_Init(WindowsMediaPlayer *wmp) DECLSPEC_HIDDEN;
void ConnectionPointContainer_Destroy(WindowsMediaPlayer *wmp) DECLSPEC_HIDDEN;
110
void call_sink(ConnectionPoint *This, DISPID dispid, DISPPARAMS *dispparams) DECLSPEC_HIDDEN;
111

112 113
HRESULT WINAPI WMPFactory_CreateInstance(IClassFactory*,IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;

114
void unregister_wmp_class(void) DECLSPEC_HIDDEN;
115
void unregister_player_msg_class(void) DECLSPEC_HIDDEN;
116

117
extern HINSTANCE wmp_instance DECLSPEC_HIDDEN;
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133

static inline WCHAR *heap_strdupW(const WCHAR *str)
{
    WCHAR *ret;

    if(str) {
        size_t size = strlenW(str)+1;
        ret = heap_alloc(size*sizeof(WCHAR));
        if(ret)
            memcpy(ret, str, size*sizeof(WCHAR));
    }else {
        ret = NULL;
    }

    return ret;
}
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149

static inline HRESULT return_bstr(const WCHAR *value, BSTR *p)
{
    if(!p)
        return E_INVALIDARG;

    if(value) {
        *p = SysAllocString(value);
        if(!*p)
            return E_OUTOFMEMORY;
    }else {
        *p = NULL;
    }

    return S_OK;
}