wmp_private.h 4.12 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 "ole2.h"
24
#include "dshow.h"
25 26
#include "wmp.h"

27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
#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;

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

    IConnectionPointContainer *container;

    IDispatch **sinks;
    DWORD sinks_size;

    IID iid;
} ConnectionPoint;

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

    LONG ref;

    WCHAR *url;
59
    WCHAR *name;
60 61

    DOUBLE duration;
62 63
} WMPMedia;

64 65 66 67
typedef struct {
    IWMPPlaylist IWMPPlaylist_iface;

    LONG ref;
68
    LONG count;
69 70 71 72 73

    WCHAR *url;
    WCHAR *name;
} WMPPlaylist;

74 75 76 77 78 79
struct WindowsMediaPlayer {
    IOleObject IOleObject_iface;
    IProvideClassInfo2 IProvideClassInfo2_iface;
    IPersistStreamInit IPersistStreamInit_iface;
    IOleInPlaceObjectWindowless IOleInPlaceObjectWindowless_iface;
    IConnectionPointContainer IConnectionPointContainer_iface;
80
    IOleControl IOleControl_iface;
81
    IWMPPlayer4 IWMPPlayer4_iface;
82
    IWMPPlayer IWMPPlayer_iface;
83
    IWMPSettings IWMPSettings_iface;
84
    IWMPControls IWMPControls_iface;
85
    IWMPNetwork IWMPNetwork_iface;
86 87 88 89

    LONG ref;

    IOleClientSite *client_site;
90
    HWND hwnd;
91
    SIZEL extent;
92

93 94 95 96
    /* Settings */
    VARIANT_BOOL auto_start;
    VARIANT_BOOL invoke_urls;
    VARIANT_BOOL enable_error_dialogs;
97
    LONG volume;
98

99
    ConnectionPoint *wmpocx;
100

101
    WMPMedia *media;
102
    WMPPlaylist *playlist;
103 104 105 106

    /* DirectShow stuff */
    IGraphBuilder* filter_graph;
    IMediaControl* media_control;
107
    IMediaEvent* media_event;
108
    IMediaSeeking* media_seeking;
109
    IBasicAudio* basic_audio;
110 111 112

    /* Async event notification */
    HWND msg_window;
113 114
};

115
BOOL init_player(WindowsMediaPlayer*) DECLSPEC_HIDDEN;
116
void destroy_player(WindowsMediaPlayer*) DECLSPEC_HIDDEN;
117
WMPMedia *unsafe_impl_from_IWMPMedia(IWMPMedia *iface) DECLSPEC_HIDDEN;
118
WMPPlaylist *unsafe_impl_from_IWMPPlaylist(IWMPPlaylist *iface) DECLSPEC_HIDDEN;
119
HRESULT create_media_from_url(BSTR url, double duration, IWMPMedia **ppMedia) DECLSPEC_HIDDEN;
120
HRESULT create_playlist(BSTR name, BSTR url, LONG count, IWMPPlaylist **ppPlaylist) DECLSPEC_HIDDEN;
121 122
void ConnectionPointContainer_Init(WindowsMediaPlayer *wmp) DECLSPEC_HIDDEN;
void ConnectionPointContainer_Destroy(WindowsMediaPlayer *wmp) DECLSPEC_HIDDEN;
123
void call_sink(ConnectionPoint *This, DISPID dispid, DISPPARAMS *dispparams) DECLSPEC_HIDDEN;
124

125 126
HRESULT WINAPI WMPFactory_CreateInstance(IClassFactory*,IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;

127
void unregister_wmp_class(void) DECLSPEC_HIDDEN;
128
void unregister_player_msg_class(void) DECLSPEC_HIDDEN;
129

130
extern HINSTANCE wmp_instance DECLSPEC_HIDDEN;
131 132 133 134 135 136

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

    if(str) {
137
        size_t size = lstrlenW(str)+1;
138 139 140 141 142 143 144 145 146
        ret = heap_alloc(size*sizeof(WCHAR));
        if(ret)
            memcpy(ret, str, size*sizeof(WCHAR));
    }else {
        ret = NULL;
    }

    return ret;
}
147 148 149 150

static inline HRESULT return_bstr(const WCHAR *value, BSTR *p)
{
    if(!p)
151
        return E_POINTER;
152 153 154 155 156 157 158 159 160 161 162

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

    return S_OK;
}