mfplat: Make functionality of GetMediaTypeHandler more clear.
[wine.git] / dlls / dmstyle / dmobject.h
blobd347020691cdf31be75b002cf3d35dfbbca38542
1 /*
2 * Base IDirectMusicObject Implementation
3 * Keep in sync with the master in dlls/dmusic/dmobject.h
5 * Copyright (C) 2014 Michael Stefaniuc
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "wine/debug.h"
24 /* RIFF stream parsing */
25 struct chunk_entry;
26 struct chunk_entry {
27 FOURCC id;
28 DWORD size;
29 FOURCC type; /* valid only for LIST and RIFF chunks */
30 ULARGE_INTEGER offset; /* chunk offset from start of stream */
31 const struct chunk_entry *parent; /* enclosing RIFF or LIST chunk */
34 HRESULT stream_get_chunk(IStream *stream, struct chunk_entry *chunk) DECLSPEC_HIDDEN;
35 HRESULT stream_next_chunk(IStream *stream, struct chunk_entry *chunk) DECLSPEC_HIDDEN;
36 HRESULT stream_skip_chunk(IStream *stream, struct chunk_entry *chunk) DECLSPEC_HIDDEN;
38 HRESULT stream_chunk_get_data(IStream *stream, const struct chunk_entry *chunk, void *data,
39 ULONG size) DECLSPEC_HIDDEN;
40 HRESULT stream_chunk_get_wstr(IStream *stream, const struct chunk_entry *chunk, WCHAR *str,
41 ULONG size) DECLSPEC_HIDDEN;
43 static inline HRESULT stream_reset_chunk_data(IStream *stream, const struct chunk_entry *chunk)
45 LARGE_INTEGER offset;
47 offset.QuadPart = chunk->offset.QuadPart + sizeof(FOURCC) + sizeof(DWORD);
48 if (chunk->id == FOURCC_RIFF || chunk->id == FOURCC_LIST)
49 offset.QuadPart += sizeof(FOURCC);
51 return IStream_Seek(stream, offset, STREAM_SEEK_SET, NULL);
54 static inline HRESULT stream_reset_chunk_start(IStream *stream, const struct chunk_entry *chunk)
56 LARGE_INTEGER offset;
58 offset.QuadPart = chunk->offset.QuadPart;
60 return IStream_Seek(stream, offset, STREAM_SEEK_SET, NULL);
64 /* IDirectMusicObject base object */
65 struct dmobject {
66 IDirectMusicObject IDirectMusicObject_iface;
67 IPersistStream IPersistStream_iface;
68 IUnknown *outer_unk;
69 DMUS_OBJECTDESC desc;
72 void dmobject_init(struct dmobject *dmobj, const GUID *class, IUnknown *outer_unk) DECLSPEC_HIDDEN;
74 /* Generic IDirectMusicObject methods */
75 HRESULT WINAPI dmobj_IDirectMusicObject_QueryInterface(IDirectMusicObject *iface, REFIID riid,
76 void **ret_iface) DECLSPEC_HIDDEN;
77 ULONG WINAPI dmobj_IDirectMusicObject_AddRef(IDirectMusicObject *iface) DECLSPEC_HIDDEN;
78 ULONG WINAPI dmobj_IDirectMusicObject_Release(IDirectMusicObject *iface) DECLSPEC_HIDDEN;
79 HRESULT WINAPI dmobj_IDirectMusicObject_GetDescriptor(IDirectMusicObject *iface,
80 DMUS_OBJECTDESC *desc) DECLSPEC_HIDDEN;
81 HRESULT WINAPI dmobj_IDirectMusicObject_SetDescriptor(IDirectMusicObject *iface,
82 DMUS_OBJECTDESC *desc) DECLSPEC_HIDDEN;
84 /* Helper for IDirectMusicObject::ParseDescriptor */
85 HRESULT dmobj_parsedescriptor(IStream *stream, const struct chunk_entry *riff,
86 DMUS_OBJECTDESC *desc, DWORD supported) DECLSPEC_HIDDEN;
87 /* Additional supported flags for dmobj_parsedescriptor.
88 DMUS_OBJ_NAME is 'UNAM' chunk in UNFO list */
89 #define DMUS_OBJ_NAME_INAM 0x1000 /* 'INAM' chunk in UNFO list */
90 #define DMUS_OBJ_NAME_INFO 0x2000 /* 'INAM' chunk in INFO list */
92 /* Generic IPersistStream methods */
93 HRESULT WINAPI dmobj_IPersistStream_QueryInterface(IPersistStream *iface, REFIID riid,
94 void **ret_iface) DECLSPEC_HIDDEN;
95 ULONG WINAPI dmobj_IPersistStream_AddRef(IPersistStream *iface) DECLSPEC_HIDDEN;
96 ULONG WINAPI dmobj_IPersistStream_Release(IPersistStream *iface) DECLSPEC_HIDDEN;
97 HRESULT WINAPI dmobj_IPersistStream_GetClassID(IPersistStream *iface, CLSID *class) DECLSPEC_HIDDEN;
99 /* IPersistStream methods not implemented in native */
100 HRESULT WINAPI unimpl_IPersistStream_GetClassID(IPersistStream *iface,
101 CLSID *class) DECLSPEC_HIDDEN;
102 HRESULT WINAPI unimpl_IPersistStream_IsDirty(IPersistStream *iface) DECLSPEC_HIDDEN;
103 HRESULT WINAPI unimpl_IPersistStream_Save(IPersistStream *iface, IStream *stream,
104 BOOL clear_dirty) DECLSPEC_HIDDEN;
105 HRESULT WINAPI unimpl_IPersistStream_GetSizeMax(IPersistStream *iface,
106 ULARGE_INTEGER *size) DECLSPEC_HIDDEN;
108 /* Debugging helpers */
109 const char *debugstr_chunk(const struct chunk_entry *chunk) DECLSPEC_HIDDEN;
110 const char *debugstr_dmguid(const GUID *id) DECLSPEC_HIDDEN;
111 void dump_DMUS_OBJECTDESC(DMUS_OBJECTDESC *desc) DECLSPEC_HIDDEN;
113 static inline const char *debugstr_fourcc(DWORD fourcc)
115 if (!fourcc) return "''";
116 return wine_dbg_sprintf("'%c%c%c%c'", (char)(fourcc), (char)(fourcc >> 8),
117 (char)(fourcc >> 16), (char)(fourcc >> 24));