[PATCH 02/12] windowscodecs: Add IWICStream_InitializeFromMemory implementation
Tony Wasserka
tony.wasserka at freenet.de
Tue Aug 18 08:16:54 CDT 2009
---
dlls/windowscodecs/stream.c | 177 ++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 175 insertions(+), 2 deletions(-)
diff --git a/dlls/windowscodecs/stream.c b/dlls/windowscodecs/stream.c
index b496b31..5e0c40b 100644
--- a/dlls/windowscodecs/stream.c
+++ b/dlls/windowscodecs/stream.c
@@ -29,6 +29,150 @@
WINE_DEFAULT_DEBUG_CHANNEL(wincodecs);
/******************************************
+ * IStreamOnMemory implementation
+ *
+ * Used by IWICStream_InitializeFromMemory
+ * This interface is windowscodecs private only which
+ * is why we don't need to implement QueryInterface and AddRef
+ *
+ */
+typedef struct StreamOnMemory {
+ const IStreamVtbl *lpVtbl;
+ LONG ref;
+} StreamOnMemory;
+
+static HRESULT WINAPI StreamOnMemory_QueryInterface(IStream *iface,
+ REFIID iid, void **ppv)
+{
+ WARN("Should not have been called\n");
+ return E_NOTIMPL;
+}
+
+static ULONG WINAPI StreamOnMemory_AddRef(IStream *iface)
+{
+ WARN("Should not have been called\n");
+ return 0;
+}
+
+static ULONG WINAPI StreamOnMemory_Release(IStream *iface)
+{
+ StreamOnMemory *This = (StreamOnMemory*)iface;
+ ULONG ref = InterlockedDecrement(&This->ref);
+
+ TRACE("(%p) refcount=%u\n", iface, ref);
+
+ if (ref == 0) {
+ HeapFree(GetProcessHeap(), 0, This);
+ }
+ return ref;
+}
+
+static HRESULT WINAPI StreamOnMemory_Read(IStream *iface,
+ void *pv, ULONG cb, ULONG *pcbRead)
+{
+ FIXME("(%p): stub\n", iface);
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI StreamOnMemory_Write(IStream *iface,
+ void const *pv, ULONG cb, ULONG *pcbWritten)
+{
+ FIXME("(%p): stub\n", iface);
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI StreamOnMemory_Seek(IStream *iface,
+ LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
+{
+ FIXME("(%p): stub\n", iface);
+ return E_NOTIMPL;
+}
+
+/* SetSize isn't implemented in the native windowscodecs DLL either */
+static HRESULT WINAPI StreamOnMemory_SetSize(IStream *iface,
+ ULARGE_INTEGER libNewSize)
+{
+ TRACE("(%p)\n", iface);
+ return E_NOTIMPL;
+}
+
+/* CopyTo isn't implemented in the native windowscodecs DLL either */
+static HRESULT WINAPI StreamOnMemory_CopyTo(IStream *iface,
+ IStream *pstm, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
+{
+ TRACE("(%p)\n", iface);
+ return E_NOTIMPL;
+}
+
+/* Commit isn't implemented in the native windowscodecs DLL either */
+static HRESULT WINAPI StreamOnMemory_Commit(IStream *iface,
+ DWORD grfCommitFlags)
+{
+ TRACE("(%p)\n", iface);
+ return E_NOTIMPL;
+}
+
+/* Revert isn't implemented in the native windowscodecs DLL either */
+static HRESULT WINAPI StreamOnMemory_Revert(IStream *iface)
+{
+ TRACE("(%p)\n", iface);
+ return E_NOTIMPL;
+}
+
+/* LockRegion isn't implemented in the native windowscodecs DLL either */
+static HRESULT WINAPI StreamOnMemory_LockRegion(IStream *iface,
+ ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
+{
+ TRACE("(%p)\n", iface);
+ return E_NOTIMPL;
+}
+
+/* UnlockRegion isn't implemented in the native windowscodecs DLL either */
+static HRESULT WINAPI StreamOnMemory_UnlockRegion(IStream *iface,
+ ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
+{
+ TRACE("(%p)\n", iface);
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI StreamOnMemory_Stat(IStream *iface,
+ STATSTG *pstatstg, DWORD grfStatFlag)
+{
+ FIXME("(%p): stub\n", iface);
+ return E_NOTIMPL;
+}
+
+/* Clone isn't implemented in the native windowscodecs DLL either */
+static HRESULT WINAPI StreamOnMemory_Clone(IStream *iface,
+ IStream **ppstm)
+{
+ TRACE("(%p)\n", iface);
+ return E_NOTIMPL;
+}
+
+
+const IStreamVtbl StreamOnMemory_Vtbl =
+{
+ /*** IUnknown methods ***/
+ StreamOnMemory_QueryInterface,
+ StreamOnMemory_AddRef,
+ StreamOnMemory_Release,
+ /*** ISequentialStream methods ***/
+ StreamOnMemory_Read,
+ StreamOnMemory_Write,
+ /*** IStream methods ***/
+ StreamOnMemory_Seek,
+ StreamOnMemory_SetSize,
+ StreamOnMemory_CopyTo,
+ StreamOnMemory_Commit,
+ StreamOnMemory_Revert,
+ StreamOnMemory_LockRegion,
+ StreamOnMemory_UnlockRegion,
+ StreamOnMemory_Stat,
+ StreamOnMemory_Clone,
+};
+
+/******************************************
* IWICStream implementation
*
*/
@@ -209,11 +353,40 @@ static HRESULT WINAPI IWICStreamImpl_InitializeFromFilename(IWICStream *iface,
return E_NOTIMPL;
}
+/******************************************
+ * IWICStream_InitializeFromMemory
+ *
+ * Initializes the internal IStream object to retrieve its data from a memory chunk.
+ *
+ * PARAMS
+ * pbBuffer [I] pointer to the memory chunk
+ * cbBufferSize [I] number of bytes to use from the memory chunk
+ *
+ * RETURNS
+ * SUCCESS: S_OK
+ * FAILURE: E_INVALIDARG, if pbBuffer is NULL
+ * E_OUTOFMEMORY, if we run out of memory
+ * WINCODEC_ERR_WRONGSTATE, if the IStream object has already been initialized before
+ *
+ */
static HRESULT WINAPI IWICStreamImpl_InitializeFromMemory(IWICStream *iface,
BYTE *pbBuffer, DWORD cbBufferSize)
{
- FIXME("(%p): stub\n", iface);
- return E_NOTIMPL;
+ IWICStreamImpl *This = (IWICStreamImpl*)iface;
+ StreamOnMemory *pObject;
+ TRACE("(%p)\n", iface);
+
+ if (!pbBuffer) return E_INVALIDARG;
+ if (This->pStream) return WINCODEC_ERR_WRONGSTATE;
+
+ pObject = HeapAlloc(GetProcessHeap(), 0, sizeof(StreamOnMemory));
+ if (!pObject) return E_OUTOFMEMORY;
+
+ pObject->lpVtbl = &StreamOnMemory_Vtbl;
+ pObject->ref = 1;
+
+ This->pStream = (IStream*)pObject;
+ return S_OK;
}
static HRESULT WINAPI IWICStreamImpl_InitializeFromIStreamRegion(IWICStream *iface,
--
1.6.3.3
--------------060004050402000800050308--
More information about the wine-patches
mailing list