2014-12-09 02:36:19 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2014 Austin English
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
2017-05-09 00:50:50 +02:00
|
|
|
#include <string.h>
|
2014-12-09 02:36:19 +01:00
|
|
|
|
2015-08-07 12:31:03 +02:00
|
|
|
#define COBJMACROS
|
2019-03-14 09:03:11 +01:00
|
|
|
#define NONAMELESSUNION
|
2015-08-07 12:31:03 +02:00
|
|
|
|
2014-12-09 02:36:19 +01:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
2017-05-09 00:50:26 +02:00
|
|
|
#include "winuser.h"
|
|
|
|
#include "winreg.h"
|
2015-08-07 12:31:03 +02:00
|
|
|
|
|
|
|
#include "initguid.h"
|
2019-03-11 11:28:08 +01:00
|
|
|
#include "ole2.h"
|
2014-12-12 00:56:54 +01:00
|
|
|
|
|
|
|
#include "wine/debug.h"
|
2017-05-09 00:50:26 +02:00
|
|
|
#include "wine/unicode.h"
|
2019-03-04 11:33:43 +01:00
|
|
|
#include "wine/list.h"
|
2014-12-12 00:56:54 +01:00
|
|
|
|
2019-03-01 09:03:07 +01:00
|
|
|
#include "mfplat_private.h"
|
2019-03-14 09:03:06 +01:00
|
|
|
#include "mfreadwrite.h"
|
2019-03-14 09:03:11 +01:00
|
|
|
#include "propvarutil.h"
|
2019-03-01 09:03:07 +01:00
|
|
|
|
2014-12-12 00:56:54 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(mfplat);
|
2014-12-09 02:36:19 +01:00
|
|
|
|
2019-02-19 14:20:04 +01:00
|
|
|
static LONG platform_lock;
|
|
|
|
|
2019-03-06 10:42:13 +01:00
|
|
|
struct system_time_source
|
|
|
|
{
|
|
|
|
IMFPresentationTimeSource IMFPresentationTimeSource_iface;
|
|
|
|
IMFClockStateSink IMFClockStateSink_iface;
|
|
|
|
LONG refcount;
|
2019-03-06 10:42:14 +01:00
|
|
|
MFCLOCK_STATE state;
|
|
|
|
CRITICAL_SECTION cs;
|
2019-03-06 10:42:13 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct system_time_source *impl_from_IMFPresentationTimeSource(IMFPresentationTimeSource *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct system_time_source, IMFPresentationTimeSource_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct system_time_source *impl_from_IMFClockStateSink(IMFClockStateSink *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct system_time_source, IMFClockStateSink_iface);
|
|
|
|
}
|
|
|
|
|
2017-05-09 00:50:26 +02:00
|
|
|
static const WCHAR transform_keyW[] = {'M','e','d','i','a','F','o','u','n','d','a','t','i','o','n','\\',
|
|
|
|
'T','r','a','n','s','f','o','r','m','s',0};
|
|
|
|
static const WCHAR categories_keyW[] = {'M','e','d','i','a','F','o','u','n','d','a','t','i','o','n','\\',
|
|
|
|
'T','r','a','n','s','f','o','r','m','s','\\',
|
|
|
|
'C','a','t','e','g','o','r','i','e','s',0};
|
|
|
|
static const WCHAR inputtypesW[] = {'I','n','p','u','t','T','y','p','e','s',0};
|
|
|
|
static const WCHAR outputtypesW[] = {'O','u','t','p','u','t','T','y','p','e','s',0};
|
|
|
|
static const WCHAR szGUIDFmt[] =
|
|
|
|
{
|
|
|
|
'%','0','8','x','-','%','0','4','x','-','%','0','4','x','-','%','0',
|
|
|
|
'2','x','%','0','2','x','-','%','0','2','x','%','0','2','x','%','0','2',
|
|
|
|
'x','%','0','2','x','%','0','2','x','%','0','2','x',0
|
|
|
|
};
|
|
|
|
|
2017-05-09 00:50:50 +02:00
|
|
|
static const BYTE guid_conv_table[256] =
|
|
|
|
{
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x00 */
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x10 */
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x20 */
|
|
|
|
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, /* 0x30 */
|
|
|
|
0, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x40 */
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x50 */
|
|
|
|
0, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf /* 0x60 */
|
|
|
|
};
|
|
|
|
|
2017-05-09 00:50:26 +02:00
|
|
|
static WCHAR* GUIDToString(WCHAR *str, REFGUID guid)
|
|
|
|
{
|
|
|
|
sprintfW(str, szGUIDFmt, guid->Data1, guid->Data2,
|
|
|
|
guid->Data3, guid->Data4[0], guid->Data4[1],
|
|
|
|
guid->Data4[2], guid->Data4[3], guid->Data4[4],
|
|
|
|
guid->Data4[5], guid->Data4[6], guid->Data4[7]);
|
|
|
|
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
2017-05-09 00:50:50 +02:00
|
|
|
static inline BOOL is_valid_hex(WCHAR c)
|
|
|
|
{
|
|
|
|
if (!(((c >= '0') && (c <= '9')) ||
|
|
|
|
((c >= 'a') && (c <= 'f')) ||
|
|
|
|
((c >= 'A') && (c <= 'F'))))
|
|
|
|
return FALSE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL GUIDFromString(LPCWSTR s, GUID *id)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* in form XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX */
|
|
|
|
|
|
|
|
id->Data1 = 0;
|
|
|
|
for (i = 0; i < 8; i++)
|
|
|
|
{
|
|
|
|
if (!is_valid_hex(s[i])) return FALSE;
|
|
|
|
id->Data1 = (id->Data1 << 4) | guid_conv_table[s[i]];
|
|
|
|
}
|
|
|
|
if (s[8]!='-') return FALSE;
|
|
|
|
|
|
|
|
id->Data2 = 0;
|
|
|
|
for (i = 9; i < 13; i++)
|
|
|
|
{
|
|
|
|
if (!is_valid_hex(s[i])) return FALSE;
|
|
|
|
id->Data2 = (id->Data2 << 4) | guid_conv_table[s[i]];
|
|
|
|
}
|
|
|
|
if (s[13]!='-') return FALSE;
|
|
|
|
|
|
|
|
id->Data3 = 0;
|
|
|
|
for (i = 14; i < 18; i++)
|
|
|
|
{
|
|
|
|
if (!is_valid_hex(s[i])) return FALSE;
|
|
|
|
id->Data3 = (id->Data3 << 4) | guid_conv_table[s[i]];
|
|
|
|
}
|
|
|
|
if (s[18]!='-') return FALSE;
|
|
|
|
|
|
|
|
for (i = 19; i < 36; i+=2)
|
|
|
|
{
|
|
|
|
if (i == 23)
|
|
|
|
{
|
|
|
|
if (s[i]!='-') return FALSE;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
if (!is_valid_hex(s[i]) || !is_valid_hex(s[i+1])) return FALSE;
|
|
|
|
id->Data4[(i-19)/2] = guid_conv_table[s[i]] << 4 | guid_conv_table[s[i+1]];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!s[37]) return TRUE;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2014-12-09 02:36:19 +01:00
|
|
|
BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved)
|
|
|
|
{
|
|
|
|
switch (reason)
|
|
|
|
{
|
|
|
|
case DLL_WINE_PREATTACH:
|
|
|
|
return FALSE; /* prefer native version */
|
|
|
|
case DLL_PROCESS_ATTACH:
|
|
|
|
DisableThreadLibraryCalls(instance);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2014-12-12 00:56:54 +01:00
|
|
|
|
2017-05-09 00:50:26 +02:00
|
|
|
static HRESULT register_transform(CLSID *clsid, WCHAR *name,
|
|
|
|
UINT32 cinput, MFT_REGISTER_TYPE_INFO *input_types,
|
|
|
|
UINT32 coutput, MFT_REGISTER_TYPE_INFO *output_types)
|
|
|
|
{
|
|
|
|
static const WCHAR reg_format[] = {'%','s','\\','%','s',0};
|
|
|
|
HKEY hclsid = 0;
|
|
|
|
WCHAR buffer[64];
|
|
|
|
DWORD size;
|
|
|
|
WCHAR str[250];
|
|
|
|
|
|
|
|
GUIDToString(buffer, clsid);
|
|
|
|
sprintfW(str, reg_format, transform_keyW, buffer);
|
|
|
|
|
|
|
|
if (RegCreateKeyW(HKEY_CLASSES_ROOT, str, &hclsid))
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
size = (strlenW(name) + 1) * sizeof(WCHAR);
|
|
|
|
if (RegSetValueExW(hclsid, NULL, 0, REG_SZ, (BYTE *)name, size))
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
if (cinput && input_types)
|
|
|
|
{
|
|
|
|
size = cinput * sizeof(MFT_REGISTER_TYPE_INFO);
|
|
|
|
if (RegSetValueExW(hclsid, inputtypesW, 0, REG_BINARY, (BYTE *)input_types, size))
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (coutput && output_types)
|
|
|
|
{
|
|
|
|
size = coutput * sizeof(MFT_REGISTER_TYPE_INFO);
|
|
|
|
if (RegSetValueExW(hclsid, outputtypesW, 0, REG_BINARY, (BYTE *)output_types, size))
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
RegCloseKey(hclsid);
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
err:
|
|
|
|
RegCloseKey(hclsid);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT register_category(CLSID *clsid, GUID *category)
|
|
|
|
{
|
|
|
|
static const WCHAR reg_format[] = {'%','s','\\','%','s','\\','%','s',0};
|
|
|
|
HKEY htmp1;
|
|
|
|
WCHAR guid1[64], guid2[64];
|
|
|
|
WCHAR str[350];
|
|
|
|
|
|
|
|
GUIDToString(guid1, category);
|
|
|
|
GUIDToString(guid2, clsid);
|
|
|
|
|
|
|
|
sprintfW(str, reg_format, categories_keyW, guid1, guid2);
|
|
|
|
|
|
|
|
if (RegCreateKeyW(HKEY_CLASSES_ROOT, str, &htmp1))
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
RegCloseKey(htmp1);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MFTRegister (mfplat.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI MFTRegister(CLSID clsid, GUID category, LPWSTR name, UINT32 flags, UINT32 cinput,
|
|
|
|
MFT_REGISTER_TYPE_INFO *input_types, UINT32 coutput,
|
|
|
|
MFT_REGISTER_TYPE_INFO *output_types, IMFAttributes *attributes)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%s, %s, %s, %x, %u, %p, %u, %p, %p)\n", debugstr_guid(&clsid), debugstr_guid(&category),
|
|
|
|
debugstr_w(name), flags, cinput, input_types,
|
|
|
|
coutput, output_types, attributes);
|
|
|
|
|
|
|
|
if (attributes)
|
|
|
|
FIXME("attributes not yet supported.\n");
|
|
|
|
|
|
|
|
if (flags)
|
|
|
|
FIXME("flags not yet supported.\n");
|
|
|
|
|
|
|
|
hr = register_transform(&clsid, name, cinput, input_types, coutput, output_types);
|
|
|
|
if(FAILED(hr))
|
|
|
|
ERR("Failed to write register transform\n");
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
hr = register_category(&clsid, &category);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2018-09-07 02:58:37 +02:00
|
|
|
HRESULT WINAPI MFTRegisterLocal(IClassFactory *factory, REFGUID category, LPCWSTR name,
|
|
|
|
UINT32 flags, UINT32 cinput, const MFT_REGISTER_TYPE_INFO *input_types,
|
|
|
|
UINT32 coutput, const MFT_REGISTER_TYPE_INFO* output_types)
|
|
|
|
{
|
|
|
|
FIXME("(%p, %s, %s, %x, %u, %p, %u, %p)\n", factory, debugstr_guid(category), debugstr_w(name),
|
|
|
|
flags, cinput, input_types, coutput, output_types);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2018-09-07 02:58:38 +02:00
|
|
|
HRESULT WINAPI MFTUnregisterLocal(IClassFactory *factory)
|
|
|
|
{
|
|
|
|
FIXME("(%p)\n", factory);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-02-12 05:00:08 +01:00
|
|
|
MFTIME WINAPI MFGetSystemTime(void)
|
|
|
|
{
|
|
|
|
MFTIME mf;
|
|
|
|
|
|
|
|
TRACE("()\n");
|
|
|
|
|
|
|
|
GetSystemTimeAsFileTime( (FILETIME*)&mf );
|
|
|
|
|
|
|
|
return mf;
|
|
|
|
}
|
|
|
|
|
2017-05-09 00:50:50 +02:00
|
|
|
static BOOL match_type(const WCHAR *clsid_str, const WCHAR *type_str, MFT_REGISTER_TYPE_INFO *type)
|
|
|
|
{
|
|
|
|
HKEY htransform, hfilter;
|
|
|
|
DWORD reg_type, size;
|
|
|
|
LONG ret = FALSE;
|
|
|
|
MFT_REGISTER_TYPE_INFO *info = NULL;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (RegOpenKeyW(HKEY_CLASSES_ROOT, transform_keyW, &htransform))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (RegOpenKeyW(htransform, clsid_str, &hfilter))
|
|
|
|
{
|
|
|
|
RegCloseKey(htransform);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (RegQueryValueExW(hfilter, type_str, NULL, ®_type, NULL, &size) != ERROR_SUCCESS)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
if (reg_type != REG_BINARY)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
if (!size || size % (sizeof(MFT_REGISTER_TYPE_INFO)) != 0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
info = HeapAlloc(GetProcessHeap(), 0, size);
|
|
|
|
if (!info)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
if (RegQueryValueExW(hfilter, type_str, NULL, ®_type, (LPBYTE)info, &size) != ERROR_SUCCESS)
|
|
|
|
goto out;
|
|
|
|
|
2017-05-10 17:45:20 +02:00
|
|
|
for (i = 0; i < size / sizeof(MFT_REGISTER_TYPE_INFO); i++)
|
2017-05-09 00:50:50 +02:00
|
|
|
{
|
|
|
|
if (IsEqualGUID(&info[i].guidMajorType, &type->guidMajorType) &&
|
|
|
|
IsEqualGUID(&info[i].guidSubtype, &type->guidSubtype))
|
|
|
|
{
|
|
|
|
ret = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
|
|
|
HeapFree(GetProcessHeap(), 0, info);
|
|
|
|
RegCloseKey(hfilter);
|
|
|
|
RegCloseKey(htransform);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MFTEnum (mfplat.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI MFTEnum(GUID category, UINT32 flags, MFT_REGISTER_TYPE_INFO *input_type,
|
|
|
|
MFT_REGISTER_TYPE_INFO *output_type, IMFAttributes *attributes,
|
|
|
|
CLSID **pclsids, UINT32 *pcount)
|
|
|
|
{
|
|
|
|
WCHAR buffer[64], clsid_str[MAX_PATH] = {0};
|
|
|
|
HKEY hcategory, hlist;
|
|
|
|
DWORD index = 0;
|
|
|
|
DWORD size = MAX_PATH;
|
|
|
|
CLSID *clsids = NULL;
|
|
|
|
UINT32 count = 0;
|
|
|
|
LONG ret;
|
|
|
|
|
|
|
|
TRACE("(%s, %x, %p, %p, %p, %p, %p)\n", debugstr_guid(&category), flags, input_type,
|
|
|
|
output_type, attributes, pclsids, pcount);
|
|
|
|
|
|
|
|
if (!pclsids || !pcount)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
if (RegOpenKeyW(HKEY_CLASSES_ROOT, categories_keyW, &hcategory))
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
GUIDToString(buffer, &category);
|
|
|
|
|
|
|
|
ret = RegOpenKeyW(hcategory, buffer, &hlist);
|
|
|
|
RegCloseKey(hcategory);
|
|
|
|
if (ret) return E_FAIL;
|
|
|
|
|
|
|
|
while (RegEnumKeyExW(hlist, index, clsid_str, &size, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
GUID clsid;
|
|
|
|
void *tmp;
|
|
|
|
|
|
|
|
if (!GUIDFromString(clsid_str, &clsid))
|
|
|
|
goto next;
|
|
|
|
|
|
|
|
if (output_type && !match_type(clsid_str, outputtypesW, output_type))
|
|
|
|
goto next;
|
|
|
|
|
|
|
|
if (input_type && !match_type(clsid_str, inputtypesW, input_type))
|
|
|
|
goto next;
|
|
|
|
|
|
|
|
tmp = CoTaskMemRealloc(clsids, (count + 1) * sizeof(GUID));
|
|
|
|
if (!tmp)
|
|
|
|
{
|
|
|
|
CoTaskMemFree(clsids);
|
|
|
|
RegCloseKey(hlist);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
clsids = tmp;
|
|
|
|
clsids[count++] = clsid;
|
|
|
|
|
|
|
|
next:
|
|
|
|
size = MAX_PATH;
|
|
|
|
index++;
|
|
|
|
}
|
|
|
|
|
|
|
|
*pclsids = clsids;
|
|
|
|
*pcount = count;
|
|
|
|
|
|
|
|
RegCloseKey(hlist);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2017-08-14 14:12:23 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* MFTEnumEx (mfplat.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI MFTEnumEx(GUID category, UINT32 flags, const MFT_REGISTER_TYPE_INFO *input_type,
|
|
|
|
const MFT_REGISTER_TYPE_INFO *output_type, IMFActivate ***activate,
|
|
|
|
UINT32 *pcount)
|
|
|
|
{
|
|
|
|
FIXME("(%s, %x, %p, %p, %p, %p): stub\n", debugstr_guid(&category), flags, input_type,
|
|
|
|
output_type, activate, pcount);
|
|
|
|
|
|
|
|
*pcount = 0;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2017-05-09 00:50:38 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* MFTUnregister (mfplat.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI MFTUnregister(CLSID clsid)
|
|
|
|
{
|
|
|
|
WCHAR buffer[64], category[MAX_PATH];
|
|
|
|
HKEY htransform, hcategory, htmp;
|
|
|
|
DWORD size = MAX_PATH;
|
|
|
|
DWORD index = 0;
|
|
|
|
|
|
|
|
TRACE("(%s)\n", debugstr_guid(&clsid));
|
|
|
|
|
|
|
|
GUIDToString(buffer, &clsid);
|
|
|
|
|
|
|
|
if (!RegOpenKeyW(HKEY_CLASSES_ROOT, transform_keyW, &htransform))
|
|
|
|
{
|
|
|
|
RegDeleteKeyW(htransform, buffer);
|
|
|
|
RegCloseKey(htransform);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!RegOpenKeyW(HKEY_CLASSES_ROOT, categories_keyW, &hcategory))
|
|
|
|
{
|
|
|
|
while (RegEnumKeyExW(hcategory, index, category, &size, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
if (!RegOpenKeyW(hcategory, category, &htmp))
|
|
|
|
{
|
|
|
|
RegDeleteKeyW(htmp, buffer);
|
|
|
|
RegCloseKey(htmp);
|
|
|
|
}
|
|
|
|
size = MAX_PATH;
|
|
|
|
index++;
|
|
|
|
}
|
|
|
|
RegCloseKey(hcategory);
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2014-12-12 00:56:54 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* MFStartup (mfplat.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI MFStartup(ULONG version, DWORD flags)
|
|
|
|
{
|
2018-04-30 02:47:18 +02:00
|
|
|
#define MF_VERSION_XP MAKELONG( MF_API_VERSION, 1 )
|
|
|
|
#define MF_VERSION_WIN7 MAKELONG( MF_API_VERSION, 2 )
|
|
|
|
|
2019-03-01 09:03:07 +01:00
|
|
|
TRACE("%#x, %#x.\n", version, flags);
|
2018-04-30 02:47:18 +02:00
|
|
|
|
2019-03-01 09:03:07 +01:00
|
|
|
if (version != MF_VERSION_XP && version != MF_VERSION_WIN7)
|
2018-04-30 02:47:18 +02:00
|
|
|
return MF_E_BAD_STARTUP_VERSION;
|
|
|
|
|
2019-03-01 09:03:07 +01:00
|
|
|
if (InterlockedIncrement(&platform_lock) == 1)
|
|
|
|
{
|
|
|
|
init_system_queues();
|
|
|
|
}
|
|
|
|
|
2018-04-30 02:47:18 +02:00
|
|
|
return S_OK;
|
2014-12-12 00:56:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MFShutdown (mfplat.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI MFShutdown(void)
|
|
|
|
{
|
2019-03-01 09:03:07 +01:00
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
if (platform_lock <= 0)
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
if (InterlockedExchangeAdd(&platform_lock, -1) == 1)
|
|
|
|
{
|
|
|
|
shutdown_system_queues();
|
|
|
|
}
|
2019-02-19 14:20:04 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MFLockPlatform (mfplat.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI MFLockPlatform(void)
|
|
|
|
{
|
|
|
|
InterlockedIncrement(&platform_lock);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MFUnlockPlatform (mfplat.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI MFUnlockPlatform(void)
|
|
|
|
{
|
2019-03-01 09:03:07 +01:00
|
|
|
if (InterlockedDecrement(&platform_lock) == 0)
|
|
|
|
{
|
|
|
|
shutdown_system_queues();
|
|
|
|
}
|
2019-02-19 14:20:04 +01:00
|
|
|
|
2014-12-12 00:56:54 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
2015-08-07 12:31:03 +02:00
|
|
|
|
2019-03-01 09:03:15 +01:00
|
|
|
BOOL is_platform_locked(void)
|
|
|
|
{
|
|
|
|
return platform_lock > 0;
|
|
|
|
}
|
|
|
|
|
2019-02-19 14:20:06 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* MFCopyImage (mfplat.@)
|
|
|
|
*/
|
2018-09-17 02:50:05 +02:00
|
|
|
HRESULT WINAPI MFCopyImage(BYTE *dest, LONG deststride, const BYTE *src, LONG srcstride, DWORD width, DWORD lines)
|
|
|
|
{
|
2019-02-19 14:20:06 +01:00
|
|
|
TRACE("(%p, %d, %p, %d, %u, %u)\n", dest, deststride, src, srcstride, width, lines);
|
|
|
|
|
|
|
|
while (lines--)
|
|
|
|
{
|
|
|
|
memcpy(dest, src, width);
|
|
|
|
dest += deststride;
|
|
|
|
src += srcstride;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2018-09-17 02:50:05 +02:00
|
|
|
}
|
2018-09-07 02:58:39 +02:00
|
|
|
|
2019-03-14 09:03:06 +01:00
|
|
|
struct guid_def
|
|
|
|
{
|
|
|
|
const GUID *guid;
|
|
|
|
const char *name;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int debug_compare_guid(const void *a, const void *b)
|
|
|
|
{
|
|
|
|
const GUID *guid = a;
|
|
|
|
const struct guid_def *guid_def = b;
|
|
|
|
return memcmp(guid, guid_def->guid, sizeof(*guid));
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *debugstr_attr(const GUID *guid)
|
|
|
|
{
|
|
|
|
static const struct guid_def guid_defs[] =
|
|
|
|
{
|
|
|
|
#define X(g) { &(g), #g }
|
|
|
|
X(MF_READWRITE_MMCSS_CLASS),
|
|
|
|
X(MF_SINK_WRITER_ENCODER_CONFIG),
|
|
|
|
X(MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS),
|
|
|
|
X(MF_MT_PIXEL_ASPECT_RATIO),
|
|
|
|
X(MF_MT_AVG_BITRATE),
|
2019-03-15 11:56:44 +01:00
|
|
|
X(MF_PD_PMPHOST_CONTEXT),
|
|
|
|
X(MF_PD_APP_CONTEXT),
|
|
|
|
X(MF_PD_TOTAL_FILE_SIZE),
|
|
|
|
X(MF_PD_AUDIO_ENCODING_BITRATE),
|
|
|
|
X(MF_PD_VIDEO_ENCODING_BITRATE),
|
|
|
|
X(MF_PD_MIME_TYPE),
|
|
|
|
X(MF_PD_LAST_MODIFIED_TIME),
|
|
|
|
X(MF_PD_PLAYBACK_ELEMENT_ID),
|
2019-03-14 09:03:06 +01:00
|
|
|
X(MF_MT_ALL_SAMPLES_INDEPENDENT),
|
2019-03-15 11:56:44 +01:00
|
|
|
X(MF_PD_PREFERRED_LANGUAGE),
|
|
|
|
X(MF_PD_PLAYBACK_BOUNDARY_TIME),
|
2019-03-14 09:03:06 +01:00
|
|
|
X(MF_MT_FRAME_SIZE),
|
|
|
|
X(MF_SINK_WRITER_ASYNC_CALLBACK),
|
|
|
|
X(MF_MT_FRAME_RATE_RANGE_MAX),
|
|
|
|
X(MF_MT_USER_DATA),
|
|
|
|
X(MF_READWRITE_DISABLE_CONVERTERS),
|
2019-03-15 11:56:44 +01:00
|
|
|
X(MF_PD_SAMI_STYLELIST),
|
|
|
|
X(MF_SD_LANGUAGE),
|
|
|
|
X(MF_SD_PROTECTED),
|
2019-03-14 09:03:06 +01:00
|
|
|
X(MF_READWRITE_MMCSS_PRIORITY_AUDIO),
|
|
|
|
X(MF_BYTESTREAM_ORIGIN_NAME),
|
|
|
|
X(MF_BYTESTREAM_CONTENT_TYPE),
|
|
|
|
X(MF_BYTESTREAM_DURATION),
|
2019-03-15 11:56:44 +01:00
|
|
|
X(MF_SD_SAMI_LANGUAGE),
|
2019-03-14 09:03:06 +01:00
|
|
|
X(MF_BYTESTREAM_LAST_MODIFIED_TIME),
|
|
|
|
X(MF_MT_FRAME_RATE_RANGE_MIN),
|
|
|
|
X(MF_BYTESTREAM_IFO_FILE_URI),
|
|
|
|
X(MF_BYTESTREAM_DLNA_PROFILE_ID),
|
|
|
|
X(MF_MT_MAJOR_TYPE),
|
2019-03-15 11:56:44 +01:00
|
|
|
X(MF_PD_ADAPTIVE_STREAMING),
|
2019-03-14 09:03:06 +01:00
|
|
|
X(MF_MT_SUBTYPE),
|
2019-03-15 11:56:44 +01:00
|
|
|
X(MF_SD_MUTUALLY_EXCLUSIVE),
|
|
|
|
X(MF_SD_STREAM_NAME),
|
2019-03-14 09:03:06 +01:00
|
|
|
X(MF_SINK_WRITER_D3D_MANAGER),
|
|
|
|
X(MF_MT_INTERLACE_MODE),
|
|
|
|
X(MF_READWRITE_MMCSS_PRIORITY),
|
|
|
|
X(MF_SINK_WRITER_DISABLE_THROTTLING),
|
|
|
|
X(MF_READWRITE_D3D_OPTIONAL),
|
|
|
|
X(MF_READWRITE_MMCSS_CLASS_AUDIO),
|
2019-03-15 11:56:44 +01:00
|
|
|
X(MF_PD_AUDIO_ISVARIABLEBITRATE),
|
2019-03-14 09:03:06 +01:00
|
|
|
X(MF_MT_FRAME_RATE),
|
|
|
|
#undef X
|
|
|
|
};
|
|
|
|
struct guid_def *ret = NULL;
|
|
|
|
|
|
|
|
if (guid)
|
|
|
|
ret = bsearch(guid, guid_defs, ARRAY_SIZE(guid_defs), sizeof(*guid_defs), debug_compare_guid);
|
|
|
|
|
|
|
|
return ret ? wine_dbg_sprintf("%s", ret->name) : wine_dbgstr_guid(guid);
|
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static inline mfattributes *impl_from_IMFAttributes(IMFAttributes *iface)
|
2018-09-07 02:58:39 +02:00
|
|
|
{
|
2018-11-03 22:25:06 +01:00
|
|
|
return CONTAINING_RECORD(iface, mfattributes, IMFAttributes_iface);
|
2018-09-07 02:58:39 +02:00
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static HRESULT WINAPI mfattributes_QueryInterface(IMFAttributes *iface, REFIID riid, void **out)
|
2018-09-07 02:58:39 +02:00
|
|
|
{
|
2018-11-03 22:25:06 +01:00
|
|
|
mfattributes *This = impl_from_IMFAttributes(iface);
|
2018-09-07 02:58:39 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), out);
|
|
|
|
|
|
|
|
if(IsEqualGUID(riid, &IID_IUnknown) ||
|
2018-11-03 22:25:06 +01:00
|
|
|
IsEqualGUID(riid, &IID_IMFAttributes))
|
2018-09-07 02:58:39 +02:00
|
|
|
{
|
2018-11-03 22:25:06 +01:00
|
|
|
*out = &This->IMFAttributes_iface;
|
2018-09-07 02:58:39 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("(%s, %p)\n", debugstr_guid(riid), out);
|
|
|
|
*out = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
IUnknown_AddRef((IUnknown*)*out);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static ULONG WINAPI mfattributes_AddRef(IMFAttributes *iface)
|
2018-09-07 02:58:39 +02:00
|
|
|
{
|
2018-11-03 22:25:06 +01:00
|
|
|
mfattributes *This = impl_from_IMFAttributes(iface);
|
2018-09-07 02:58:39 +02:00
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%u\n", This, ref);
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static ULONG WINAPI mfattributes_Release(IMFAttributes *iface)
|
2018-09-07 02:58:39 +02:00
|
|
|
{
|
2019-03-14 09:03:07 +01:00
|
|
|
struct attributes *attributes = impl_from_IMFAttributes(iface);
|
|
|
|
ULONG refcount = InterlockedDecrement(&attributes->ref);
|
2018-09-07 02:58:39 +02:00
|
|
|
|
2019-03-14 09:03:07 +01:00
|
|
|
TRACE("%p, refcount %d.\n", iface, refcount);
|
2018-09-07 02:58:39 +02:00
|
|
|
|
2019-03-14 09:03:07 +01:00
|
|
|
if (!refcount)
|
2018-09-07 02:58:39 +02:00
|
|
|
{
|
2019-03-14 09:03:07 +01:00
|
|
|
clear_attributes_object(attributes);
|
|
|
|
heap_free(attributes);
|
2018-09-07 02:58:39 +02:00
|
|
|
}
|
|
|
|
|
2019-03-14 09:03:07 +01:00
|
|
|
return refcount;
|
2018-09-07 02:58:39 +02:00
|
|
|
}
|
|
|
|
|
2019-03-14 09:03:08 +01:00
|
|
|
static struct attribute *attributes_find_item(struct attributes *attributes, REFGUID key, size_t *index)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
for (i = 0; i < attributes->count; ++i)
|
|
|
|
{
|
|
|
|
if (IsEqualGUID(key, &attributes->attributes[i].key))
|
|
|
|
{
|
|
|
|
if (index)
|
|
|
|
*index = i;
|
|
|
|
return &attributes->attributes[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2019-03-14 09:03:11 +01:00
|
|
|
static HRESULT attributes_get_item(struct attributes *attributes, const GUID *key, PROPVARIANT *value)
|
|
|
|
{
|
|
|
|
struct attribute *attribute;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
EnterCriticalSection(&attributes->cs);
|
|
|
|
|
|
|
|
attribute = attributes_find_item(attributes, key, NULL);
|
|
|
|
if (attribute)
|
|
|
|
{
|
2019-03-14 09:03:15 +01:00
|
|
|
if (attribute->value.vt == value->vt && !(value->vt == VT_UNKNOWN && !attribute->value.u.punkVal))
|
2019-03-14 09:03:11 +01:00
|
|
|
hr = PropVariantCopy(value, &attribute->value);
|
|
|
|
else
|
|
|
|
hr = MF_E_INVALIDTYPE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
hr = MF_E_ATTRIBUTENOTFOUND;
|
|
|
|
|
|
|
|
LeaveCriticalSection(&attributes->cs);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static HRESULT WINAPI mfattributes_GetItem(IMFAttributes *iface, REFGUID key, PROPVARIANT *value)
|
2018-09-07 02:58:39 +02:00
|
|
|
{
|
2019-03-14 09:03:08 +01:00
|
|
|
struct attributes *attributes = impl_from_IMFAttributes(iface);
|
|
|
|
struct attribute *attribute;
|
|
|
|
HRESULT hr;
|
2018-09-07 02:58:39 +02:00
|
|
|
|
2019-03-14 09:03:08 +01:00
|
|
|
TRACE("%p, %s, %p.\n", iface, debugstr_attr(key), value);
|
|
|
|
|
|
|
|
EnterCriticalSection(&attributes->cs);
|
|
|
|
|
|
|
|
if ((attribute = attributes_find_item(attributes, key, NULL)))
|
|
|
|
hr = PropVariantCopy(value, &attribute->value);
|
|
|
|
else
|
|
|
|
hr = MF_E_ATTRIBUTENOTFOUND;
|
|
|
|
|
|
|
|
LeaveCriticalSection(&attributes->cs);
|
|
|
|
|
|
|
|
return hr;
|
2018-09-07 02:58:39 +02:00
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static HRESULT WINAPI mfattributes_GetItemType(IMFAttributes *iface, REFGUID key, MF_ATTRIBUTE_TYPE *type)
|
2018-09-07 02:58:39 +02:00
|
|
|
{
|
2019-03-14 09:03:06 +01:00
|
|
|
FIXME("%p, %s, %p.\n", iface, debugstr_attr(key), type);
|
2018-09-07 02:58:39 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static HRESULT WINAPI mfattributes_CompareItem(IMFAttributes *iface, REFGUID key, REFPROPVARIANT value, BOOL *result)
|
2018-09-07 02:58:39 +02:00
|
|
|
{
|
2019-03-15 11:56:49 +01:00
|
|
|
struct attributes *attributes = impl_from_IMFAttributes(iface);
|
|
|
|
struct attribute *attribute;
|
2018-09-07 02:58:39 +02:00
|
|
|
|
2019-03-15 11:56:49 +01:00
|
|
|
TRACE("%p, %s, %p, %p.\n", iface, debugstr_attr(key), value, result);
|
|
|
|
|
|
|
|
*result = FALSE;
|
|
|
|
|
|
|
|
EnterCriticalSection(&attributes->cs);
|
|
|
|
|
|
|
|
if ((attribute = attributes_find_item(attributes, key, NULL)))
|
|
|
|
*result = !PropVariantCompareEx(&attribute->value, value, PVCU_DEFAULT, PVCF_DEFAULT);
|
|
|
|
|
|
|
|
LeaveCriticalSection(&attributes->cs);
|
|
|
|
|
|
|
|
return S_OK;
|
2018-09-07 02:58:39 +02:00
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static HRESULT WINAPI mfattributes_Compare(IMFAttributes *iface, IMFAttributes *theirs, MF_ATTRIBUTES_MATCH_TYPE type,
|
|
|
|
BOOL *result)
|
2018-09-07 02:58:39 +02:00
|
|
|
{
|
2018-11-03 22:25:06 +01:00
|
|
|
mfattributes *This = impl_from_IMFAttributes(iface);
|
2018-09-07 02:58:39 +02:00
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
FIXME("%p, %p, %d, %p\n", This, theirs, type, result);
|
2018-09-07 02:58:39 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static HRESULT WINAPI mfattributes_GetUINT32(IMFAttributes *iface, REFGUID key, UINT32 *value)
|
2018-09-07 02:58:39 +02:00
|
|
|
{
|
2019-03-14 09:03:11 +01:00
|
|
|
struct attributes *attributes = impl_from_IMFAttributes(iface);
|
|
|
|
PROPVARIANT attrval;
|
|
|
|
HRESULT hr;
|
2018-09-07 02:58:39 +02:00
|
|
|
|
2019-03-14 09:03:11 +01:00
|
|
|
TRACE("%p, %s, %p.\n", iface, debugstr_attr(key), value);
|
|
|
|
|
|
|
|
PropVariantInit(&attrval);
|
|
|
|
attrval.vt = VT_UI4;
|
|
|
|
hr = attributes_get_item(attributes, key, &attrval);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
hr = PropVariantToUInt32(&attrval, value);
|
|
|
|
return hr;
|
2018-09-07 02:58:39 +02:00
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static HRESULT WINAPI mfattributes_GetUINT64(IMFAttributes *iface, REFGUID key, UINT64 *value)
|
2018-09-07 02:58:39 +02:00
|
|
|
{
|
2019-03-14 09:03:11 +01:00
|
|
|
struct attributes *attributes = impl_from_IMFAttributes(iface);
|
|
|
|
PROPVARIANT attrval;
|
|
|
|
HRESULT hr;
|
2018-09-07 02:58:39 +02:00
|
|
|
|
2019-03-14 09:03:11 +01:00
|
|
|
TRACE("%p, %s, %p.\n", iface, debugstr_attr(key), value);
|
|
|
|
|
|
|
|
PropVariantInit(&attrval);
|
|
|
|
attrval.vt = VT_UI8;
|
|
|
|
hr = attributes_get_item(attributes, key, &attrval);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
hr = PropVariantToUInt64(&attrval, value);
|
|
|
|
return hr;
|
2018-09-07 02:58:39 +02:00
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static HRESULT WINAPI mfattributes_GetDouble(IMFAttributes *iface, REFGUID key, double *value)
|
2018-09-07 02:58:39 +02:00
|
|
|
{
|
2019-03-14 09:03:13 +01:00
|
|
|
struct attributes *attributes = impl_from_IMFAttributes(iface);
|
|
|
|
PROPVARIANT attrval;
|
|
|
|
HRESULT hr;
|
2018-09-07 02:58:39 +02:00
|
|
|
|
2019-03-14 09:03:13 +01:00
|
|
|
TRACE("%p, %s, %p.\n", iface, debugstr_attr(key), value);
|
|
|
|
|
|
|
|
PropVariantInit(&attrval);
|
|
|
|
attrval.vt = VT_R8;
|
|
|
|
hr = attributes_get_item(attributes, key, &attrval);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
hr = PropVariantToDouble(&attrval, value);
|
|
|
|
return hr;
|
2018-09-07 02:58:39 +02:00
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static HRESULT WINAPI mfattributes_GetGUID(IMFAttributes *iface, REFGUID key, GUID *value)
|
2018-09-07 02:58:39 +02:00
|
|
|
{
|
2019-03-15 11:56:47 +01:00
|
|
|
struct attributes *attributes = impl_from_IMFAttributes(iface);
|
|
|
|
PROPVARIANT attrval;
|
|
|
|
HRESULT hr;
|
2018-09-07 02:58:39 +02:00
|
|
|
|
2019-03-15 11:56:47 +01:00
|
|
|
TRACE("%p, %s, %p.\n", iface, debugstr_attr(key), value);
|
|
|
|
|
|
|
|
PropVariantInit(&attrval);
|
|
|
|
attrval.vt = VT_CLSID;
|
|
|
|
hr = attributes_get_item(attributes, key, &attrval);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
hr = PropVariantToGUID(&attrval, value);
|
|
|
|
|
|
|
|
return hr;
|
2018-09-07 02:58:39 +02:00
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static HRESULT WINAPI mfattributes_GetStringLength(IMFAttributes *iface, REFGUID key, UINT32 *length)
|
2018-09-07 02:58:39 +02:00
|
|
|
{
|
2019-03-14 09:03:14 +01:00
|
|
|
struct attributes *attributes = impl_from_IMFAttributes(iface);
|
|
|
|
PROPVARIANT attrval;
|
|
|
|
HRESULT hr;
|
2018-09-07 02:58:39 +02:00
|
|
|
|
2019-03-14 09:03:14 +01:00
|
|
|
TRACE("%p, %s, %p.\n", iface, debugstr_attr(key), length);
|
|
|
|
|
|
|
|
PropVariantInit(&attrval);
|
|
|
|
attrval.vt = VT_LPWSTR;
|
|
|
|
hr = attributes_get_item(attributes, key, &attrval);
|
|
|
|
if (SUCCEEDED(hr) && length)
|
|
|
|
*length = lstrlenW(attrval.u.pwszVal);
|
|
|
|
PropVariantClear(&attrval);
|
|
|
|
|
|
|
|
return hr;
|
2018-09-07 02:58:39 +02:00
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static HRESULT WINAPI mfattributes_GetString(IMFAttributes *iface, REFGUID key, WCHAR *value,
|
2019-03-14 09:03:14 +01:00
|
|
|
UINT32 size, UINT32 *length)
|
2018-09-07 02:58:39 +02:00
|
|
|
{
|
2019-03-14 09:03:14 +01:00
|
|
|
struct attributes *attributes = impl_from_IMFAttributes(iface);
|
|
|
|
PROPVARIANT attrval;
|
|
|
|
HRESULT hr;
|
2018-09-07 02:58:39 +02:00
|
|
|
|
2019-03-14 09:03:14 +01:00
|
|
|
TRACE("%p, %s, %p, %d, %p.\n", iface, debugstr_attr(key), value, size, length);
|
|
|
|
|
|
|
|
PropVariantInit(&attrval);
|
|
|
|
attrval.vt = VT_LPWSTR;
|
|
|
|
hr = attributes_get_item(attributes, key, &attrval);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
hr = PropVariantToString(&attrval, value, size);
|
|
|
|
if (SUCCEEDED(hr) && length)
|
|
|
|
*length = lstrlenW(value);
|
|
|
|
PropVariantClear(&attrval);
|
|
|
|
|
|
|
|
return hr;
|
2018-09-07 02:58:39 +02:00
|
|
|
}
|
|
|
|
|
2019-03-14 09:03:14 +01:00
|
|
|
static HRESULT WINAPI mfattributes_GetAllocatedString(IMFAttributes *iface, REFGUID key, WCHAR **value, UINT32 *length)
|
2018-09-07 02:58:39 +02:00
|
|
|
{
|
2019-03-14 09:03:14 +01:00
|
|
|
struct attributes *attributes = impl_from_IMFAttributes(iface);
|
|
|
|
PROPVARIANT attrval;
|
|
|
|
HRESULT hr;
|
2018-09-07 02:58:39 +02:00
|
|
|
|
2019-03-14 09:03:14 +01:00
|
|
|
TRACE("%p, %s, %p, %p.\n", iface, debugstr_attr(key), value, length);
|
|
|
|
|
|
|
|
PropVariantInit(&attrval);
|
|
|
|
attrval.vt = VT_LPWSTR;
|
|
|
|
hr = attributes_get_item(attributes, key, &attrval);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
*value = attrval.u.pwszVal;
|
|
|
|
*length = lstrlenW(*value);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
2018-09-07 02:58:39 +02:00
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static HRESULT WINAPI mfattributes_GetBlobSize(IMFAttributes *iface, REFGUID key, UINT32 *size)
|
2018-09-07 02:58:39 +02:00
|
|
|
{
|
2019-03-15 11:56:48 +01:00
|
|
|
struct attributes *attributes = impl_from_IMFAttributes(iface);
|
|
|
|
struct attribute *attribute;
|
|
|
|
HRESULT hr = S_OK;
|
2018-09-07 02:58:39 +02:00
|
|
|
|
2019-03-15 11:56:48 +01:00
|
|
|
TRACE("%p, %s, %p.\n", iface, debugstr_attr(key), size);
|
|
|
|
|
|
|
|
EnterCriticalSection(&attributes->cs);
|
|
|
|
|
|
|
|
attribute = attributes_find_item(attributes, key, NULL);
|
|
|
|
if (attribute)
|
|
|
|
{
|
|
|
|
if (attribute->value.vt == MF_ATTRIBUTE_BLOB)
|
|
|
|
*size = attribute->value.u.caub.cElems;
|
|
|
|
else
|
|
|
|
hr = MF_E_INVALIDTYPE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
hr = MF_E_ATTRIBUTENOTFOUND;
|
|
|
|
|
|
|
|
LeaveCriticalSection(&attributes->cs);
|
|
|
|
|
|
|
|
return hr;
|
2018-09-07 02:58:39 +02:00
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static HRESULT WINAPI mfattributes_GetBlob(IMFAttributes *iface, REFGUID key, UINT8 *buf,
|
|
|
|
UINT32 bufsize, UINT32 *blobsize)
|
2018-09-07 02:58:39 +02:00
|
|
|
{
|
2019-03-15 11:56:48 +01:00
|
|
|
struct attributes *attributes = impl_from_IMFAttributes(iface);
|
|
|
|
struct attribute *attribute;
|
|
|
|
HRESULT hr;
|
2018-09-07 02:58:39 +02:00
|
|
|
|
2019-03-15 11:56:48 +01:00
|
|
|
TRACE("%p, %s, %p, %d, %p.\n", iface, debugstr_attr(key), buf, bufsize, blobsize);
|
|
|
|
|
|
|
|
EnterCriticalSection(&attributes->cs);
|
|
|
|
|
|
|
|
attribute = attributes_find_item(attributes, key, NULL);
|
|
|
|
if (attribute)
|
|
|
|
{
|
|
|
|
if (attribute->value.vt == MF_ATTRIBUTE_BLOB)
|
|
|
|
{
|
|
|
|
UINT32 size = attribute->value.u.caub.cElems;
|
|
|
|
|
|
|
|
if (bufsize >= size)
|
|
|
|
hr = PropVariantToBuffer(&attribute->value, buf, size);
|
|
|
|
else
|
|
|
|
hr = E_NOT_SUFFICIENT_BUFFER;
|
|
|
|
|
|
|
|
if (blobsize)
|
|
|
|
*blobsize = size;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
hr = MF_E_INVALIDTYPE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
hr = MF_E_ATTRIBUTENOTFOUND;
|
|
|
|
|
|
|
|
LeaveCriticalSection(&attributes->cs);
|
|
|
|
|
|
|
|
return hr;
|
2018-09-07 02:58:39 +02:00
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static HRESULT WINAPI mfattributes_GetAllocatedBlob(IMFAttributes *iface, REFGUID key, UINT8 **buf, UINT32 *size)
|
2018-09-07 02:58:39 +02:00
|
|
|
{
|
2019-03-15 11:56:48 +01:00
|
|
|
struct attributes *attributes = impl_from_IMFAttributes(iface);
|
|
|
|
PROPVARIANT attrval;
|
|
|
|
HRESULT hr;
|
2018-09-07 02:58:39 +02:00
|
|
|
|
2019-03-15 11:56:48 +01:00
|
|
|
TRACE("%p, %s, %p, %p.\n", iface, debugstr_attr(key), buf, size);
|
|
|
|
|
|
|
|
attrval.vt = VT_VECTOR | VT_UI1;
|
|
|
|
hr = attributes_get_item(attributes, key, &attrval);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
*buf = attrval.u.caub.pElems;
|
|
|
|
*size = attrval.u.caub.cElems;
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
2018-09-07 02:58:39 +02:00
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static HRESULT WINAPI mfattributes_GetUnknown(IMFAttributes *iface, REFGUID key, REFIID riid, void **ppv)
|
2018-09-07 02:58:39 +02:00
|
|
|
{
|
2019-03-14 09:03:15 +01:00
|
|
|
struct attributes *attributes = impl_from_IMFAttributes(iface);
|
|
|
|
PROPVARIANT attrval;
|
|
|
|
HRESULT hr;
|
2018-09-07 02:58:39 +02:00
|
|
|
|
2019-03-14 09:03:15 +01:00
|
|
|
TRACE("%p, %s, %s, %p.\n", iface, debugstr_attr(key), debugstr_guid(riid), ppv);
|
|
|
|
|
|
|
|
PropVariantInit(&attrval);
|
|
|
|
attrval.vt = VT_UNKNOWN;
|
|
|
|
hr = attributes_get_item(attributes, key, &attrval);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
hr = IUnknown_QueryInterface(attrval.u.punkVal, riid, ppv);
|
|
|
|
PropVariantClear(&attrval);
|
|
|
|
return hr;
|
2018-09-07 02:58:39 +02:00
|
|
|
}
|
|
|
|
|
2019-03-14 09:03:08 +01:00
|
|
|
static HRESULT attributes_set_item(struct attributes *attributes, REFGUID key, REFPROPVARIANT value)
|
2018-09-07 02:58:39 +02:00
|
|
|
{
|
2019-03-14 09:03:08 +01:00
|
|
|
struct attribute *attribute;
|
2018-09-07 02:58:39 +02:00
|
|
|
|
2019-03-14 09:03:08 +01:00
|
|
|
EnterCriticalSection(&attributes->cs);
|
|
|
|
|
|
|
|
attribute = attributes_find_item(attributes, key, NULL);
|
|
|
|
if (!attribute)
|
|
|
|
{
|
|
|
|
if (!mf_array_reserve((void **)&attributes->attributes, &attributes->capacity, attributes->count + 1,
|
|
|
|
sizeof(*attributes->attributes)))
|
|
|
|
{
|
|
|
|
LeaveCriticalSection(&attributes->cs);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
attributes->attributes[attributes->count].key = *key;
|
|
|
|
attribute = &attributes->attributes[attributes->count++];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
PropVariantClear(&attribute->value);
|
|
|
|
|
|
|
|
PropVariantCopy(&attribute->value, value);
|
|
|
|
|
|
|
|
LeaveCriticalSection(&attributes->cs);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfattributes_SetItem(IMFAttributes *iface, REFGUID key, REFPROPVARIANT value)
|
|
|
|
{
|
|
|
|
struct attributes *attributes = impl_from_IMFAttributes(iface);
|
|
|
|
PROPVARIANT empty;
|
|
|
|
|
|
|
|
TRACE("%p, %s, %p.\n", iface, debugstr_attr(key), value);
|
|
|
|
|
|
|
|
switch (value->vt)
|
|
|
|
{
|
|
|
|
case MF_ATTRIBUTE_UINT32:
|
|
|
|
case MF_ATTRIBUTE_UINT64:
|
|
|
|
case MF_ATTRIBUTE_DOUBLE:
|
|
|
|
case MF_ATTRIBUTE_GUID:
|
|
|
|
case MF_ATTRIBUTE_STRING:
|
|
|
|
case MF_ATTRIBUTE_BLOB:
|
|
|
|
case MF_ATTRIBUTE_IUNKNOWN:
|
|
|
|
return attributes_set_item(attributes, key, value);
|
|
|
|
default:
|
|
|
|
PropVariantInit(&empty);
|
|
|
|
attributes_set_item(attributes, key, &empty);
|
|
|
|
return MF_E_INVALIDTYPE;
|
|
|
|
}
|
2018-11-03 22:25:06 +01:00
|
|
|
}
|
2018-09-07 02:58:39 +02:00
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static HRESULT WINAPI mfattributes_DeleteItem(IMFAttributes *iface, REFGUID key)
|
|
|
|
{
|
2019-03-14 09:03:09 +01:00
|
|
|
struct attributes *attributes = impl_from_IMFAttributes(iface);
|
|
|
|
struct attribute *attribute;
|
|
|
|
size_t index = 0;
|
2018-09-07 02:58:39 +02:00
|
|
|
|
2019-03-14 09:03:09 +01:00
|
|
|
TRACE("%p, %s.\n", iface, debugstr_attr(key));
|
|
|
|
|
|
|
|
EnterCriticalSection(&attributes->cs);
|
|
|
|
|
|
|
|
if ((attribute = attributes_find_item(attributes, key, &index)))
|
|
|
|
{
|
|
|
|
size_t count;
|
|
|
|
|
|
|
|
PropVariantClear(&attribute->value);
|
|
|
|
|
|
|
|
attributes->count--;
|
|
|
|
count = attributes->count - index;
|
|
|
|
if (count)
|
|
|
|
memmove(&attributes->attributes[index], &attributes->attributes[index + 1], count * sizeof(*attributes->attributes));
|
|
|
|
}
|
|
|
|
|
|
|
|
LeaveCriticalSection(&attributes->cs);
|
|
|
|
|
|
|
|
return S_OK;
|
2018-09-07 02:58:39 +02:00
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static HRESULT WINAPI mfattributes_DeleteAllItems(IMFAttributes *iface)
|
2015-08-07 12:31:03 +02:00
|
|
|
{
|
2019-03-14 09:03:16 +01:00
|
|
|
struct attributes *attributes = impl_from_IMFAttributes(iface);
|
2015-08-07 12:31:03 +02:00
|
|
|
|
2019-03-14 09:03:16 +01:00
|
|
|
TRACE("%p.\n", iface);
|
2018-11-03 22:25:06 +01:00
|
|
|
|
2019-03-14 09:03:16 +01:00
|
|
|
EnterCriticalSection(&attributes->cs);
|
|
|
|
|
|
|
|
while (attributes->count)
|
|
|
|
{
|
|
|
|
PropVariantClear(&attributes->attributes[--attributes->count].value);
|
|
|
|
}
|
|
|
|
heap_free(attributes->attributes);
|
|
|
|
attributes->attributes = NULL;
|
|
|
|
attributes->capacity = 0;
|
|
|
|
|
|
|
|
LeaveCriticalSection(&attributes->cs);
|
|
|
|
|
|
|
|
return S_OK;
|
2015-08-07 12:31:03 +02:00
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static HRESULT WINAPI mfattributes_SetUINT32(IMFAttributes *iface, REFGUID key, UINT32 value)
|
2015-08-07 12:31:03 +02:00
|
|
|
{
|
2019-03-14 09:03:11 +01:00
|
|
|
struct attributes *attributes = impl_from_IMFAttributes(iface);
|
|
|
|
PROPVARIANT attrval;
|
2018-11-03 22:25:06 +01:00
|
|
|
|
2019-03-14 09:03:11 +01:00
|
|
|
TRACE("%p, %s, %d.\n", iface, debugstr_attr(key), value);
|
|
|
|
|
|
|
|
attrval.vt = VT_UI4;
|
|
|
|
attrval.u.ulVal = value;
|
|
|
|
return attributes_set_item(attributes, key, &attrval);
|
2015-08-07 12:31:03 +02:00
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static HRESULT WINAPI mfattributes_SetUINT64(IMFAttributes *iface, REFGUID key, UINT64 value)
|
2015-08-07 12:31:03 +02:00
|
|
|
{
|
2019-03-14 09:03:11 +01:00
|
|
|
struct attributes *attributes = impl_from_IMFAttributes(iface);
|
|
|
|
PROPVARIANT attrval;
|
2018-11-03 22:25:06 +01:00
|
|
|
|
2019-03-14 09:03:11 +01:00
|
|
|
TRACE("%p, %s, %s.\n", iface, debugstr_attr(key), wine_dbgstr_longlong(value));
|
|
|
|
|
|
|
|
attrval.vt = VT_UI8;
|
|
|
|
attrval.u.uhVal.QuadPart = value;
|
|
|
|
return attributes_set_item(attributes, key, &attrval);
|
2015-08-07 12:31:03 +02:00
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static HRESULT WINAPI mfattributes_SetDouble(IMFAttributes *iface, REFGUID key, double value)
|
2015-08-07 12:31:03 +02:00
|
|
|
{
|
2019-03-14 09:03:13 +01:00
|
|
|
struct attributes *attributes = impl_from_IMFAttributes(iface);
|
|
|
|
PROPVARIANT attrval;
|
2018-11-03 22:25:06 +01:00
|
|
|
|
2019-03-14 09:03:13 +01:00
|
|
|
TRACE("%p, %s, %f.\n", iface, debugstr_attr(key), value);
|
|
|
|
|
|
|
|
attrval.vt = VT_R8;
|
|
|
|
attrval.u.dblVal = value;
|
|
|
|
return attributes_set_item(attributes, key, &attrval);
|
2015-08-07 12:31:03 +02:00
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static HRESULT WINAPI mfattributes_SetGUID(IMFAttributes *iface, REFGUID key, REFGUID value)
|
2015-08-07 12:31:03 +02:00
|
|
|
{
|
2019-03-15 11:56:47 +01:00
|
|
|
struct attributes *attributes = impl_from_IMFAttributes(iface);
|
|
|
|
PROPVARIANT attrval;
|
2018-11-03 22:25:06 +01:00
|
|
|
|
2019-03-15 11:56:47 +01:00
|
|
|
TRACE("%p, %s, %s.\n", iface, debugstr_attr(key), debugstr_guid(value));
|
|
|
|
|
|
|
|
InitPropVariantFromCLSID(value, &attrval);
|
|
|
|
return attributes_set_item(attributes, key, &attrval);
|
2015-08-07 12:31:03 +02:00
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static HRESULT WINAPI mfattributes_SetString(IMFAttributes *iface, REFGUID key, const WCHAR *value)
|
2015-08-07 12:31:03 +02:00
|
|
|
{
|
2019-03-14 09:03:14 +01:00
|
|
|
struct attributes *attributes = impl_from_IMFAttributes(iface);
|
|
|
|
PROPVARIANT attrval;
|
2018-11-03 22:25:06 +01:00
|
|
|
|
2019-03-14 09:03:14 +01:00
|
|
|
TRACE("%p, %s, %s.\n", iface, debugstr_attr(key), debugstr_w(value));
|
|
|
|
|
|
|
|
attrval.vt = VT_LPWSTR;
|
|
|
|
attrval.u.pwszVal = (WCHAR *)value;
|
|
|
|
return attributes_set_item(attributes, key, &attrval);
|
2015-08-07 12:31:03 +02:00
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static HRESULT WINAPI mfattributes_SetBlob(IMFAttributes *iface, REFGUID key, const UINT8 *buf, UINT32 size)
|
2015-08-07 12:31:03 +02:00
|
|
|
{
|
2019-03-15 11:56:48 +01:00
|
|
|
struct attributes *attributes = impl_from_IMFAttributes(iface);
|
|
|
|
PROPVARIANT attrval;
|
2018-11-03 22:25:06 +01:00
|
|
|
|
2019-03-15 11:56:48 +01:00
|
|
|
TRACE("%p, %s, %p, %u.\n", iface, debugstr_attr(key), buf, size);
|
|
|
|
|
|
|
|
attrval.vt = VT_VECTOR | VT_UI1;
|
|
|
|
attrval.u.caub.cElems = size;
|
|
|
|
attrval.u.caub.pElems = (UINT8 *)buf;
|
|
|
|
return attributes_set_item(attributes, key, &attrval);
|
2015-08-07 12:31:03 +02:00
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static HRESULT WINAPI mfattributes_SetUnknown(IMFAttributes *iface, REFGUID key, IUnknown *unknown)
|
2015-08-07 12:31:03 +02:00
|
|
|
{
|
2019-03-14 09:03:15 +01:00
|
|
|
struct attributes *attributes = impl_from_IMFAttributes(iface);
|
|
|
|
PROPVARIANT attrval;
|
2018-11-03 22:25:06 +01:00
|
|
|
|
2019-03-14 09:03:15 +01:00
|
|
|
TRACE("%p, %s, %p.\n", iface, debugstr_attr(key), unknown);
|
|
|
|
|
|
|
|
attrval.vt = VT_UNKNOWN;
|
|
|
|
attrval.u.punkVal = unknown;
|
|
|
|
return attributes_set_item(attributes, key, &attrval);
|
2015-08-07 12:31:03 +02:00
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static HRESULT WINAPI mfattributes_LockStore(IMFAttributes *iface)
|
2015-08-07 12:31:03 +02:00
|
|
|
{
|
2019-03-15 11:56:45 +01:00
|
|
|
struct attributes *attributes = impl_from_IMFAttributes(iface);
|
2018-11-03 22:25:06 +01:00
|
|
|
|
2019-03-15 11:56:45 +01:00
|
|
|
TRACE("%p.\n", iface);
|
2018-11-03 22:25:06 +01:00
|
|
|
|
2019-03-15 11:56:45 +01:00
|
|
|
EnterCriticalSection(&attributes->cs);
|
|
|
|
|
|
|
|
return S_OK;
|
2015-08-07 12:31:03 +02:00
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static HRESULT WINAPI mfattributes_UnlockStore(IMFAttributes *iface)
|
|
|
|
{
|
2019-03-15 11:56:45 +01:00
|
|
|
struct attributes *attributes = impl_from_IMFAttributes(iface);
|
2018-11-03 22:25:06 +01:00
|
|
|
|
2019-03-15 11:56:45 +01:00
|
|
|
TRACE("%p.\n", iface);
|
2018-11-03 22:25:06 +01:00
|
|
|
|
2019-03-15 11:56:45 +01:00
|
|
|
LeaveCriticalSection(&attributes->cs);
|
|
|
|
|
|
|
|
return S_OK;
|
2018-11-03 22:25:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfattributes_GetCount(IMFAttributes *iface, UINT32 *items)
|
|
|
|
{
|
2019-03-14 09:03:12 +01:00
|
|
|
struct attributes *attributes = impl_from_IMFAttributes(iface);
|
2018-11-03 22:25:06 +01:00
|
|
|
|
2019-03-14 09:03:12 +01:00
|
|
|
TRACE("%p, %p.\n", iface, items);
|
2018-11-03 22:25:06 +01:00
|
|
|
|
2019-03-14 09:03:12 +01:00
|
|
|
EnterCriticalSection(&attributes->cs);
|
|
|
|
*items = attributes->count;
|
|
|
|
LeaveCriticalSection(&attributes->cs);
|
2018-11-03 22:25:06 +01:00
|
|
|
|
2019-03-14 09:03:12 +01:00
|
|
|
return S_OK;
|
2018-11-03 22:25:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfattributes_GetItemByIndex(IMFAttributes *iface, UINT32 index, GUID *key, PROPVARIANT *value)
|
|
|
|
{
|
2019-03-14 09:03:10 +01:00
|
|
|
struct attributes *attributes = impl_from_IMFAttributes(iface);
|
|
|
|
HRESULT hr = S_OK;
|
2018-11-03 22:25:06 +01:00
|
|
|
|
2019-03-14 09:03:10 +01:00
|
|
|
TRACE("%p, %u, %p, %p.\n", iface, index, key, value);
|
2018-11-03 22:25:06 +01:00
|
|
|
|
2019-03-14 09:03:10 +01:00
|
|
|
EnterCriticalSection(&attributes->cs);
|
|
|
|
|
|
|
|
if (index < attributes->count)
|
|
|
|
{
|
|
|
|
*key = attributes->attributes[index].key;
|
|
|
|
PropVariantCopy(value, &attributes->attributes[index].value);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
hr = E_INVALIDARG;
|
|
|
|
|
|
|
|
LeaveCriticalSection(&attributes->cs);
|
|
|
|
|
|
|
|
return hr;
|
2018-11-03 22:25:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfattributes_CopyAllItems(IMFAttributes *iface, IMFAttributes *dest)
|
|
|
|
{
|
2019-03-15 11:56:46 +01:00
|
|
|
struct attributes *attributes = impl_from_IMFAttributes(iface);
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
size_t i;
|
2018-11-03 22:25:06 +01:00
|
|
|
|
2019-03-15 11:56:46 +01:00
|
|
|
TRACE("%p, %p.\n", iface, dest);
|
2018-11-03 22:25:06 +01:00
|
|
|
|
2019-03-15 11:56:46 +01:00
|
|
|
EnterCriticalSection(&attributes->cs);
|
|
|
|
|
|
|
|
IMFAttributes_LockStore(dest);
|
|
|
|
|
|
|
|
IMFAttributes_DeleteAllItems(dest);
|
|
|
|
|
|
|
|
for (i = 0; i < attributes->count; ++i)
|
|
|
|
{
|
|
|
|
hr = IMFAttributes_SetItem(dest, &attributes->attributes[i].key, &attributes->attributes[i].value);
|
|
|
|
if (FAILED(hr))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
IMFAttributes_UnlockStore(dest);
|
|
|
|
|
|
|
|
LeaveCriticalSection(&attributes->cs);
|
|
|
|
|
|
|
|
return hr;
|
2018-11-03 22:25:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static const IMFAttributesVtbl mfattributes_vtbl =
|
|
|
|
{
|
|
|
|
mfattributes_QueryInterface,
|
|
|
|
mfattributes_AddRef,
|
|
|
|
mfattributes_Release,
|
|
|
|
mfattributes_GetItem,
|
|
|
|
mfattributes_GetItemType,
|
|
|
|
mfattributes_CompareItem,
|
|
|
|
mfattributes_Compare,
|
|
|
|
mfattributes_GetUINT32,
|
|
|
|
mfattributes_GetUINT64,
|
|
|
|
mfattributes_GetDouble,
|
|
|
|
mfattributes_GetGUID,
|
|
|
|
mfattributes_GetStringLength,
|
|
|
|
mfattributes_GetString,
|
|
|
|
mfattributes_GetAllocatedString,
|
|
|
|
mfattributes_GetBlobSize,
|
|
|
|
mfattributes_GetBlob,
|
|
|
|
mfattributes_GetAllocatedBlob,
|
|
|
|
mfattributes_GetUnknown,
|
|
|
|
mfattributes_SetItem,
|
|
|
|
mfattributes_DeleteItem,
|
|
|
|
mfattributes_DeleteAllItems,
|
|
|
|
mfattributes_SetUINT32,
|
|
|
|
mfattributes_SetUINT64,
|
|
|
|
mfattributes_SetDouble,
|
|
|
|
mfattributes_SetGUID,
|
|
|
|
mfattributes_SetString,
|
|
|
|
mfattributes_SetBlob,
|
|
|
|
mfattributes_SetUnknown,
|
|
|
|
mfattributes_LockStore,
|
|
|
|
mfattributes_UnlockStore,
|
|
|
|
mfattributes_GetCount,
|
|
|
|
mfattributes_GetItemByIndex,
|
|
|
|
mfattributes_CopyAllItems
|
2015-08-07 12:31:03 +02:00
|
|
|
};
|
|
|
|
|
2019-03-14 09:03:07 +01:00
|
|
|
HRESULT init_attributes_object(struct attributes *object, UINT32 size)
|
2018-11-03 22:25:06 +01:00
|
|
|
{
|
|
|
|
object->IMFAttributes_iface.lpVtbl = &mfattributes_vtbl;
|
2019-03-14 09:03:07 +01:00
|
|
|
object->ref = 1;
|
|
|
|
InitializeCriticalSection(&object->cs);
|
|
|
|
|
|
|
|
object->attributes = NULL;
|
|
|
|
object->count = 0;
|
|
|
|
object->capacity = 0;
|
|
|
|
if (!mf_array_reserve((void **)&object->attributes, &object->capacity, size,
|
|
|
|
sizeof(*object->attributes)))
|
|
|
|
{
|
|
|
|
DeleteCriticalSection(&object->cs);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void clear_attributes_object(struct attributes *object)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
for (i = 0; i < object->count; i++)
|
|
|
|
PropVariantClear(&object->attributes[i].value);
|
|
|
|
heap_free(object->attributes);
|
|
|
|
|
|
|
|
DeleteCriticalSection(&object->cs);
|
2018-11-03 22:25:06 +01:00
|
|
|
}
|
2015-08-07 12:31:03 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
2018-11-03 22:25:06 +01:00
|
|
|
* MFCreateAttributes (mfplat.@)
|
2015-08-07 12:31:03 +02:00
|
|
|
*/
|
2018-11-03 22:25:06 +01:00
|
|
|
HRESULT WINAPI MFCreateAttributes(IMFAttributes **attributes, UINT32 size)
|
2015-08-07 12:31:03 +02:00
|
|
|
{
|
2019-03-14 09:03:07 +01:00
|
|
|
struct attributes *object;
|
|
|
|
HRESULT hr;
|
2018-11-03 22:25:06 +01:00
|
|
|
|
|
|
|
TRACE("%p, %d\n", attributes, size);
|
|
|
|
|
2019-03-14 09:03:07 +01:00
|
|
|
object = heap_alloc_zero(sizeof(*object));
|
|
|
|
if (!object)
|
2018-11-03 22:25:06 +01:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2019-03-14 09:03:07 +01:00
|
|
|
if (FAILED(hr = init_attributes_object(object, size)))
|
|
|
|
{
|
|
|
|
heap_free(object);
|
|
|
|
return hr;
|
|
|
|
}
|
2018-11-03 22:25:06 +01:00
|
|
|
*attributes = &object->IMFAttributes_iface;
|
2015-08-07 12:31:03 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
2017-04-21 03:48:12 +02:00
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
typedef struct _mfbytestream
|
2017-04-21 03:48:12 +02:00
|
|
|
{
|
2018-11-03 22:25:07 +01:00
|
|
|
mfattributes attributes;
|
2018-11-03 22:25:06 +01:00
|
|
|
IMFByteStream IMFByteStream_iface;
|
|
|
|
} mfbytestream;
|
2017-04-21 03:48:12 +02:00
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static inline mfbytestream *impl_from_IMFByteStream(IMFByteStream *iface)
|
2017-04-21 03:48:12 +02:00
|
|
|
{
|
2018-11-03 22:25:06 +01:00
|
|
|
return CONTAINING_RECORD(iface, mfbytestream, IMFByteStream_iface);
|
2017-04-21 03:48:12 +02:00
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static HRESULT WINAPI mfbytestream_QueryInterface(IMFByteStream *iface, REFIID riid, void **out)
|
2017-04-21 03:48:12 +02:00
|
|
|
{
|
2018-11-03 22:25:06 +01:00
|
|
|
mfbytestream *This = impl_from_IMFByteStream(iface);
|
2017-04-21 03:48:12 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), out);
|
|
|
|
|
|
|
|
if(IsEqualGUID(riid, &IID_IUnknown) ||
|
2018-11-03 22:25:06 +01:00
|
|
|
IsEqualGUID(riid, &IID_IMFByteStream))
|
2017-04-21 03:48:12 +02:00
|
|
|
{
|
2018-11-03 22:25:06 +01:00
|
|
|
*out = &This->IMFByteStream_iface;
|
2017-04-21 03:48:12 +02:00
|
|
|
}
|
2018-11-03 22:25:07 +01:00
|
|
|
else if(IsEqualGUID(riid, &IID_IMFAttributes))
|
|
|
|
{
|
|
|
|
*out = &This->attributes.IMFAttributes_iface;
|
|
|
|
}
|
2017-04-21 03:48:12 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("(%s, %p)\n", debugstr_guid(riid), out);
|
|
|
|
*out = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
IUnknown_AddRef((IUnknown*)*out);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static ULONG WINAPI mfbytestream_AddRef(IMFByteStream *iface)
|
2017-04-21 03:48:12 +02:00
|
|
|
{
|
2018-11-03 22:25:06 +01:00
|
|
|
mfbytestream *This = impl_from_IMFByteStream(iface);
|
2018-11-03 22:25:07 +01:00
|
|
|
ULONG ref = InterlockedIncrement(&This->attributes.ref);
|
2017-04-21 03:48:12 +02:00
|
|
|
|
|
|
|
TRACE("(%p) ref=%u\n", This, ref);
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:07 +01:00
|
|
|
static ULONG WINAPI mfbytestream_Release(IMFByteStream *iface)
|
2017-04-21 03:48:12 +02:00
|
|
|
{
|
2018-11-03 22:25:06 +01:00
|
|
|
mfbytestream *This = impl_from_IMFByteStream(iface);
|
2018-11-03 22:25:07 +01:00
|
|
|
ULONG ref = InterlockedDecrement(&This->attributes.ref);
|
2017-04-21 03:48:12 +02:00
|
|
|
|
|
|
|
TRACE("(%p) ref=%u\n", This, ref);
|
|
|
|
|
|
|
|
if (!ref)
|
|
|
|
{
|
2019-03-14 09:03:07 +01:00
|
|
|
clear_attributes_object(&This->attributes);
|
2017-04-21 03:48:12 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static HRESULT WINAPI mfbytestream_GetCapabilities(IMFByteStream *iface, DWORD *capabilities)
|
2017-04-21 03:48:12 +02:00
|
|
|
{
|
2018-11-03 22:25:06 +01:00
|
|
|
mfbytestream *This = impl_from_IMFByteStream(iface);
|
2017-04-21 03:48:12 +02:00
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
FIXME("%p, %p\n", This, capabilities);
|
2017-04-21 03:48:12 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static HRESULT WINAPI mfbytestream_GetLength(IMFByteStream *iface, QWORD *length)
|
2017-04-21 03:48:12 +02:00
|
|
|
{
|
2018-11-03 22:25:06 +01:00
|
|
|
mfbytestream *This = impl_from_IMFByteStream(iface);
|
2017-04-21 03:48:12 +02:00
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
FIXME("%p, %p\n", This, length);
|
2017-04-21 03:48:12 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static HRESULT WINAPI mfbytestream_SetLength(IMFByteStream *iface, QWORD length)
|
2017-04-21 03:48:12 +02:00
|
|
|
{
|
2018-11-03 22:25:06 +01:00
|
|
|
mfbytestream *This = impl_from_IMFByteStream(iface);
|
2017-04-21 03:48:12 +02:00
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
FIXME("%p, %s\n", This, wine_dbgstr_longlong(length));
|
2017-04-21 03:48:12 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static HRESULT WINAPI mfbytestream_GetCurrentPosition(IMFByteStream *iface, QWORD *position)
|
2017-04-21 03:48:12 +02:00
|
|
|
{
|
2018-11-03 22:25:06 +01:00
|
|
|
mfbytestream *This = impl_from_IMFByteStream(iface);
|
2017-04-21 03:48:12 +02:00
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
FIXME("%p, %p\n", This, position);
|
2017-04-21 03:48:12 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static HRESULT WINAPI mfbytestream_SetCurrentPosition(IMFByteStream *iface, QWORD position)
|
2017-04-21 03:48:12 +02:00
|
|
|
{
|
2018-11-03 22:25:06 +01:00
|
|
|
mfbytestream *This = impl_from_IMFByteStream(iface);
|
2017-04-21 03:48:12 +02:00
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
FIXME("%p, %s\n", This, wine_dbgstr_longlong(position));
|
2017-04-21 03:48:12 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static HRESULT WINAPI mfbytestream_IsEndOfStream(IMFByteStream *iface, BOOL *endstream)
|
2017-04-21 03:48:12 +02:00
|
|
|
{
|
2018-11-03 22:25:06 +01:00
|
|
|
mfbytestream *This = impl_from_IMFByteStream(iface);
|
2017-04-21 03:48:12 +02:00
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
FIXME("%p, %p\n", This, endstream);
|
2017-04-21 03:48:12 +02:00
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
if(endstream)
|
|
|
|
*endstream = TRUE;
|
2017-04-21 03:48:12 +02:00
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
return S_OK;
|
2017-04-21 03:48:12 +02:00
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static HRESULT WINAPI mfbytestream_Read(IMFByteStream *iface, BYTE *data, ULONG count, ULONG *byte_read)
|
2017-04-21 03:48:12 +02:00
|
|
|
{
|
2018-11-03 22:25:06 +01:00
|
|
|
mfbytestream *This = impl_from_IMFByteStream(iface);
|
2017-04-21 03:48:12 +02:00
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
FIXME("%p, %p, %u, %p\n", This, data, count, byte_read);
|
2017-04-21 03:48:12 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static HRESULT WINAPI mfbytestream_BeginRead(IMFByteStream *iface, BYTE *data, ULONG count,
|
|
|
|
IMFAsyncCallback *callback, IUnknown *state)
|
2017-04-21 03:48:12 +02:00
|
|
|
{
|
2018-11-03 22:25:06 +01:00
|
|
|
mfbytestream *This = impl_from_IMFByteStream(iface);
|
2017-04-21 03:48:12 +02:00
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
FIXME("%p, %p, %u, %p, %p\n", This, data, count, callback, state);
|
2017-04-21 03:48:12 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static HRESULT WINAPI mfbytestream_EndRead(IMFByteStream *iface, IMFAsyncResult *result, ULONG *byte_read)
|
2017-04-21 03:48:12 +02:00
|
|
|
{
|
2018-11-03 22:25:06 +01:00
|
|
|
mfbytestream *This = impl_from_IMFByteStream(iface);
|
2017-04-21 03:48:12 +02:00
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
FIXME("%p, %p, %p\n", This, result, byte_read);
|
2017-04-21 03:48:12 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static HRESULT WINAPI mfbytestream_Write(IMFByteStream *iface, const BYTE *data, ULONG count, ULONG *written)
|
2017-04-21 03:48:12 +02:00
|
|
|
{
|
2018-11-03 22:25:06 +01:00
|
|
|
mfbytestream *This = impl_from_IMFByteStream(iface);
|
2017-04-21 03:48:12 +02:00
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
FIXME("%p, %p, %u, %p\n", This, data, count, written);
|
2017-04-21 03:48:12 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static HRESULT WINAPI mfbytestream_BeginWrite(IMFByteStream *iface, const BYTE *data, ULONG count,
|
|
|
|
IMFAsyncCallback *callback, IUnknown *state)
|
2017-04-21 03:48:12 +02:00
|
|
|
{
|
2018-11-03 22:25:06 +01:00
|
|
|
mfbytestream *This = impl_from_IMFByteStream(iface);
|
2017-04-21 03:48:12 +02:00
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
FIXME("%p, %p, %u, %p, %p\n", This, data, count, callback, state);
|
2017-04-21 03:48:12 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static HRESULT WINAPI mfbytestream_EndWrite(IMFByteStream *iface, IMFAsyncResult *result, ULONG *written)
|
2017-04-21 03:48:12 +02:00
|
|
|
{
|
2018-11-03 22:25:06 +01:00
|
|
|
mfbytestream *This = impl_from_IMFByteStream(iface);
|
2017-04-21 03:48:12 +02:00
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
FIXME("%p, %p, %p\n", This, result, written);
|
2017-04-21 03:48:12 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static HRESULT WINAPI mfbytestream_Seek(IMFByteStream *iface, MFBYTESTREAM_SEEK_ORIGIN seek, LONGLONG offset,
|
|
|
|
DWORD flags, QWORD *current)
|
2017-04-21 03:48:12 +02:00
|
|
|
{
|
2018-11-03 22:25:06 +01:00
|
|
|
mfbytestream *This = impl_from_IMFByteStream(iface);
|
2017-04-21 03:48:12 +02:00
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
FIXME("%p, %u, %s, 0x%08x, %p\n", This, seek, wine_dbgstr_longlong(offset), flags, current);
|
2017-04-21 03:48:12 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static HRESULT WINAPI mfbytestream_Flush(IMFByteStream *iface)
|
2017-04-21 03:48:12 +02:00
|
|
|
{
|
2018-11-03 22:25:06 +01:00
|
|
|
mfbytestream *This = impl_from_IMFByteStream(iface);
|
2017-04-21 03:48:12 +02:00
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
FIXME("%p\n", This);
|
2017-04-21 03:48:12 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static HRESULT WINAPI mfbytestream_Close(IMFByteStream *iface)
|
2017-04-21 03:48:12 +02:00
|
|
|
{
|
2018-11-03 22:25:06 +01:00
|
|
|
mfbytestream *This = impl_from_IMFByteStream(iface);
|
2017-04-21 03:48:12 +02:00
|
|
|
|
|
|
|
FIXME("%p\n", This);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:07 +01:00
|
|
|
static const IMFByteStreamVtbl mfbytestream_vtbl =
|
2017-04-21 03:48:12 +02:00
|
|
|
{
|
2018-11-03 22:25:06 +01:00
|
|
|
mfbytestream_QueryInterface,
|
|
|
|
mfbytestream_AddRef,
|
|
|
|
mfbytestream_Release,
|
|
|
|
mfbytestream_GetCapabilities,
|
|
|
|
mfbytestream_GetLength,
|
|
|
|
mfbytestream_SetLength,
|
|
|
|
mfbytestream_GetCurrentPosition,
|
|
|
|
mfbytestream_SetCurrentPosition,
|
|
|
|
mfbytestream_IsEndOfStream,
|
|
|
|
mfbytestream_Read,
|
|
|
|
mfbytestream_BeginRead,
|
|
|
|
mfbytestream_EndRead,
|
|
|
|
mfbytestream_Write,
|
|
|
|
mfbytestream_BeginWrite,
|
|
|
|
mfbytestream_EndWrite,
|
|
|
|
mfbytestream_Seek,
|
|
|
|
mfbytestream_Flush,
|
|
|
|
mfbytestream_Close
|
|
|
|
};
|
2017-04-21 03:48:12 +02:00
|
|
|
|
2018-11-03 22:25:07 +01:00
|
|
|
static inline mfbytestream *impl_from_IMFByteStream_IMFAttributes(IMFAttributes *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, mfbytestream, attributes.IMFAttributes_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfbytestream_attributes_QueryInterface(
|
|
|
|
IMFAttributes *iface, REFIID riid, void **out)
|
|
|
|
{
|
|
|
|
mfbytestream *This = impl_from_IMFByteStream_IMFAttributes(iface);
|
|
|
|
return IMFByteStream_QueryInterface(&This->IMFByteStream_iface, riid, out);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI mfbytestream_attributes_AddRef(IMFAttributes *iface)
|
|
|
|
{
|
|
|
|
mfbytestream *This = impl_from_IMFByteStream_IMFAttributes(iface);
|
|
|
|
return IMFByteStream_AddRef(&This->IMFByteStream_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI mfbytestream_attributes_Release(IMFAttributes *iface)
|
|
|
|
{
|
|
|
|
mfbytestream *This = impl_from_IMFByteStream_IMFAttributes(iface);
|
|
|
|
return IMFByteStream_Release(&This->IMFByteStream_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IMFAttributesVtbl mfbytestream_attributes_vtbl =
|
|
|
|
{
|
|
|
|
mfbytestream_attributes_QueryInterface,
|
|
|
|
mfbytestream_attributes_AddRef,
|
|
|
|
mfbytestream_attributes_Release,
|
|
|
|
mfattributes_GetItem,
|
|
|
|
mfattributes_GetItemType,
|
|
|
|
mfattributes_CompareItem,
|
|
|
|
mfattributes_Compare,
|
|
|
|
mfattributes_GetUINT32,
|
|
|
|
mfattributes_GetUINT64,
|
|
|
|
mfattributes_GetDouble,
|
|
|
|
mfattributes_GetGUID,
|
|
|
|
mfattributes_GetStringLength,
|
|
|
|
mfattributes_GetString,
|
|
|
|
mfattributes_GetAllocatedString,
|
|
|
|
mfattributes_GetBlobSize,
|
|
|
|
mfattributes_GetBlob,
|
|
|
|
mfattributes_GetAllocatedBlob,
|
|
|
|
mfattributes_GetUnknown,
|
|
|
|
mfattributes_SetItem,
|
|
|
|
mfattributes_DeleteItem,
|
|
|
|
mfattributes_DeleteAllItems,
|
|
|
|
mfattributes_SetUINT32,
|
|
|
|
mfattributes_SetUINT64,
|
|
|
|
mfattributes_SetDouble,
|
|
|
|
mfattributes_SetGUID,
|
|
|
|
mfattributes_SetString,
|
|
|
|
mfattributes_SetBlob,
|
|
|
|
mfattributes_SetUnknown,
|
|
|
|
mfattributes_LockStore,
|
|
|
|
mfattributes_UnlockStore,
|
|
|
|
mfattributes_GetCount,
|
|
|
|
mfattributes_GetItemByIndex,
|
|
|
|
mfattributes_CopyAllItems
|
|
|
|
};
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
HRESULT WINAPI MFCreateMFByteStreamOnStream(IStream *stream, IMFByteStream **bytestream)
|
2017-04-21 03:48:12 +02:00
|
|
|
{
|
2018-11-03 22:25:06 +01:00
|
|
|
mfbytestream *object;
|
2019-03-14 09:03:07 +01:00
|
|
|
HRESULT hr;
|
2017-04-21 03:48:12 +02:00
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
TRACE("(%p, %p): stub\n", stream, bytestream);
|
2017-04-21 03:48:12 +02:00
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
object = heap_alloc( sizeof(*object) );
|
|
|
|
if(!object)
|
|
|
|
return E_OUTOFMEMORY;
|
2017-04-21 03:48:12 +02:00
|
|
|
|
2019-03-14 09:03:07 +01:00
|
|
|
if (FAILED(hr = init_attributes_object(&object->attributes, 0)))
|
|
|
|
{
|
|
|
|
heap_free(object);
|
|
|
|
return hr;
|
|
|
|
}
|
2018-11-03 22:25:07 +01:00
|
|
|
object->IMFByteStream_iface.lpVtbl = &mfbytestream_vtbl;
|
|
|
|
object->attributes.IMFAttributes_iface.lpVtbl = &mfbytestream_attributes_vtbl;
|
2017-04-21 03:48:12 +02:00
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
*bytestream = &object->IMFByteStream_iface;
|
2017-04-21 03:48:12 +02:00
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
return S_OK;
|
2017-04-21 03:48:12 +02:00
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:08 +01:00
|
|
|
HRESULT WINAPI MFCreateFile(MF_FILE_ACCESSMODE accessmode, MF_FILE_OPENMODE openmode, MF_FILE_FLAGS flags,
|
|
|
|
LPCWSTR url, IMFByteStream **bytestream)
|
|
|
|
{
|
|
|
|
mfbytestream *object;
|
|
|
|
DWORD fileaccessmode = 0;
|
|
|
|
DWORD filesharemode = FILE_SHARE_READ;
|
|
|
|
DWORD filecreation_disposition = 0;
|
|
|
|
DWORD fileattributes = 0;
|
|
|
|
HANDLE file;
|
2019-03-14 09:03:07 +01:00
|
|
|
HRESULT hr;
|
2018-11-03 22:25:08 +01:00
|
|
|
|
|
|
|
FIXME("(%d, %d, %d, %s, %p): stub\n", accessmode, openmode, flags, debugstr_w(url), bytestream);
|
|
|
|
|
|
|
|
switch (accessmode)
|
|
|
|
{
|
|
|
|
case MF_ACCESSMODE_READ:
|
|
|
|
fileaccessmode = GENERIC_READ;
|
|
|
|
break;
|
|
|
|
case MF_ACCESSMODE_WRITE:
|
|
|
|
fileaccessmode = GENERIC_WRITE;
|
|
|
|
break;
|
|
|
|
case MF_ACCESSMODE_READWRITE:
|
|
|
|
fileaccessmode = GENERIC_READ | GENERIC_WRITE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (openmode)
|
|
|
|
{
|
|
|
|
case MF_OPENMODE_FAIL_IF_NOT_EXIST:
|
|
|
|
filecreation_disposition = OPEN_EXISTING;
|
|
|
|
break;
|
|
|
|
case MF_OPENMODE_FAIL_IF_EXIST:
|
|
|
|
filecreation_disposition = CREATE_NEW;
|
|
|
|
break;
|
|
|
|
case MF_OPENMODE_RESET_IF_EXIST:
|
|
|
|
filecreation_disposition = TRUNCATE_EXISTING;
|
|
|
|
break;
|
|
|
|
case MF_OPENMODE_APPEND_IF_EXIST:
|
|
|
|
filecreation_disposition = OPEN_ALWAYS;
|
|
|
|
fileaccessmode |= FILE_APPEND_DATA;
|
|
|
|
break;
|
|
|
|
case MF_OPENMODE_DELETE_IF_EXIST:
|
|
|
|
filecreation_disposition = CREATE_ALWAYS;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags & MF_FILEFLAGS_NOBUFFERING)
|
|
|
|
fileattributes |= FILE_FLAG_NO_BUFFERING;
|
|
|
|
|
|
|
|
/* Open HANDLE to file */
|
|
|
|
file = CreateFileW(url, fileaccessmode, filesharemode, NULL,
|
|
|
|
filecreation_disposition, fileattributes, 0);
|
|
|
|
|
|
|
|
if(file == INVALID_HANDLE_VALUE)
|
|
|
|
return HRESULT_FROM_WIN32(GetLastError());
|
|
|
|
|
|
|
|
/* Close the file again, since we don't do anything with it yet */
|
|
|
|
CloseHandle(file);
|
|
|
|
|
|
|
|
object = heap_alloc( sizeof(*object) );
|
|
|
|
if(!object)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2019-03-14 09:03:07 +01:00
|
|
|
if (FAILED(hr = init_attributes_object(&object->attributes, 0)))
|
|
|
|
{
|
|
|
|
heap_free(object);
|
|
|
|
return hr;
|
|
|
|
}
|
2018-11-03 22:25:08 +01:00
|
|
|
object->IMFByteStream_iface.lpVtbl = &mfbytestream_vtbl;
|
|
|
|
object->attributes.IMFAttributes_iface.lpVtbl = &mfbytestream_attributes_vtbl;
|
|
|
|
|
|
|
|
*bytestream = &object->IMFByteStream_iface;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static HRESULT WINAPI MFPluginControl_QueryInterface(IMFPluginControl *iface, REFIID riid, void **ppv)
|
2017-04-21 03:48:12 +02:00
|
|
|
{
|
2018-11-03 22:25:06 +01:00
|
|
|
if(IsEqualGUID(riid, &IID_IUnknown)) {
|
|
|
|
TRACE("(IID_IUnknown %p)\n", ppv);
|
|
|
|
*ppv = iface;
|
|
|
|
}else if(IsEqualGUID(riid, &IID_IMFPluginControl)) {
|
|
|
|
TRACE("(IID_IMFPluginControl %p)\n", ppv);
|
|
|
|
*ppv = iface;
|
|
|
|
}else {
|
|
|
|
FIXME("(%s %p)\n", debugstr_guid(riid), ppv);
|
|
|
|
*ppv = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
2017-04-21 03:48:12 +02:00
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
IUnknown_AddRef((IUnknown*)*ppv);
|
|
|
|
return S_OK;
|
2017-04-21 03:48:12 +02:00
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static ULONG WINAPI MFPluginControl_AddRef(IMFPluginControl *iface)
|
2017-04-21 03:48:12 +02:00
|
|
|
{
|
2018-11-03 22:25:06 +01:00
|
|
|
TRACE("\n");
|
|
|
|
return 2;
|
2017-04-21 03:48:12 +02:00
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static ULONG WINAPI MFPluginControl_Release(IMFPluginControl *iface)
|
2017-04-21 03:48:12 +02:00
|
|
|
{
|
2018-11-03 22:25:06 +01:00
|
|
|
TRACE("\n");
|
|
|
|
return 1;
|
2017-04-21 03:48:12 +02:00
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static HRESULT WINAPI MFPluginControl_GetPreferredClsid(IMFPluginControl *iface, DWORD plugin_type,
|
|
|
|
const WCHAR *selector, CLSID *clsid)
|
2017-04-21 03:48:12 +02:00
|
|
|
{
|
2018-11-03 22:25:06 +01:00
|
|
|
FIXME("(%d %s %p)\n", plugin_type, debugstr_w(selector), clsid);
|
2017-04-21 03:48:12 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static HRESULT WINAPI MFPluginControl_GetPreferredClsidByIndex(IMFPluginControl *iface, DWORD plugin_type,
|
|
|
|
DWORD index, WCHAR **selector, CLSID *clsid)
|
2017-04-21 03:48:12 +02:00
|
|
|
{
|
2018-11-03 22:25:06 +01:00
|
|
|
FIXME("(%d %d %p %p)\n", plugin_type, index, selector, clsid);
|
2017-04-21 03:48:12 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static HRESULT WINAPI MFPluginControl_SetPreferredClsid(IMFPluginControl *iface, DWORD plugin_type,
|
|
|
|
const WCHAR *selector, const CLSID *clsid)
|
2017-04-21 03:48:12 +02:00
|
|
|
{
|
2018-11-03 22:25:06 +01:00
|
|
|
FIXME("(%d %s %s)\n", plugin_type, debugstr_w(selector), debugstr_guid(clsid));
|
2017-04-21 03:48:12 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static HRESULT WINAPI MFPluginControl_IsDisabled(IMFPluginControl *iface, DWORD plugin_type, REFCLSID clsid)
|
2017-04-21 03:48:12 +02:00
|
|
|
{
|
2018-11-03 22:25:06 +01:00
|
|
|
FIXME("(%d %s)\n", plugin_type, debugstr_guid(clsid));
|
2017-04-21 03:48:12 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static HRESULT WINAPI MFPluginControl_GetDisabledByIndex(IMFPluginControl *iface, DWORD plugin_type, DWORD index, CLSID *clsid)
|
2017-04-21 03:48:12 +02:00
|
|
|
{
|
2018-11-03 22:25:06 +01:00
|
|
|
FIXME("(%d %d %p)\n", plugin_type, index, clsid);
|
2017-04-21 03:48:12 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static HRESULT WINAPI MFPluginControl_SetDisabled(IMFPluginControl *iface, DWORD plugin_type, REFCLSID clsid, BOOL disabled)
|
2017-04-21 03:48:12 +02:00
|
|
|
{
|
2018-11-03 22:25:06 +01:00
|
|
|
FIXME("(%d %s %x)\n", plugin_type, debugstr_guid(clsid), disabled);
|
2017-04-21 03:48:12 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static const IMFPluginControlVtbl MFPluginControlVtbl = {
|
|
|
|
MFPluginControl_QueryInterface,
|
|
|
|
MFPluginControl_AddRef,
|
|
|
|
MFPluginControl_Release,
|
|
|
|
MFPluginControl_GetPreferredClsid,
|
|
|
|
MFPluginControl_GetPreferredClsidByIndex,
|
|
|
|
MFPluginControl_SetPreferredClsid,
|
|
|
|
MFPluginControl_IsDisabled,
|
|
|
|
MFPluginControl_GetDisabledByIndex,
|
|
|
|
MFPluginControl_SetDisabled
|
2017-04-21 03:48:12 +02:00
|
|
|
};
|
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
static IMFPluginControl plugin_control = { &MFPluginControlVtbl };
|
2018-09-12 02:19:07 +02:00
|
|
|
|
2017-04-21 03:48:12 +02:00
|
|
|
/***********************************************************************
|
2018-11-03 22:25:06 +01:00
|
|
|
* MFGetPluginControl (mfplat.@)
|
2017-04-21 03:48:12 +02:00
|
|
|
*/
|
2018-11-03 22:25:06 +01:00
|
|
|
HRESULT WINAPI MFGetPluginControl(IMFPluginControl **ret)
|
2017-04-21 03:48:12 +02:00
|
|
|
{
|
2018-11-03 22:25:06 +01:00
|
|
|
TRACE("(%p)\n", ret);
|
2018-09-12 02:19:07 +02:00
|
|
|
|
2018-11-03 22:25:06 +01:00
|
|
|
*ret = &plugin_control;
|
2017-04-21 03:48:12 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
2017-05-28 13:42:48 +02:00
|
|
|
|
2018-11-25 20:45:05 +01:00
|
|
|
typedef struct _mfpresentationdescriptor
|
|
|
|
{
|
|
|
|
mfattributes attributes;
|
|
|
|
IMFPresentationDescriptor IMFPresentationDescriptor_iface;
|
|
|
|
} mfpresentationdescriptor;
|
|
|
|
|
|
|
|
static inline mfpresentationdescriptor *impl_from_IMFPresentationDescriptor(IMFPresentationDescriptor *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, mfpresentationdescriptor, IMFPresentationDescriptor_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfpresentationdescriptor_QueryInterface(IMFPresentationDescriptor *iface, REFIID riid, void **out)
|
|
|
|
{
|
|
|
|
mfpresentationdescriptor *This = impl_from_IMFPresentationDescriptor(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), out);
|
|
|
|
|
|
|
|
if(IsEqualGUID(riid, &IID_IUnknown) ||
|
|
|
|
IsEqualGUID(riid, &IID_IMFAttributes) ||
|
|
|
|
IsEqualGUID(riid, &IID_IMFPresentationDescriptor))
|
|
|
|
{
|
|
|
|
*out = &This->IMFPresentationDescriptor_iface;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("(%s, %p)\n", debugstr_guid(riid), out);
|
|
|
|
*out = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
IUnknown_AddRef((IUnknown*)*out);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI mfpresentationdescriptor_AddRef(IMFPresentationDescriptor *iface)
|
|
|
|
{
|
|
|
|
mfpresentationdescriptor *This = impl_from_IMFPresentationDescriptor(iface);
|
|
|
|
ULONG ref = InterlockedIncrement(&This->attributes.ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%u\n", This, ref);
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI mfpresentationdescriptor_Release(IMFPresentationDescriptor *iface)
|
|
|
|
{
|
|
|
|
mfpresentationdescriptor *This = impl_from_IMFPresentationDescriptor(iface);
|
|
|
|
ULONG ref = InterlockedDecrement(&This->attributes.ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%u\n", This, ref);
|
|
|
|
|
|
|
|
if (!ref)
|
|
|
|
{
|
2019-03-14 09:03:07 +01:00
|
|
|
clear_attributes_object(&This->attributes);
|
2018-11-25 20:45:05 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfpresentationdescriptor_GetItem(IMFPresentationDescriptor *iface, REFGUID key, PROPVARIANT *value)
|
|
|
|
{
|
|
|
|
mfpresentationdescriptor *This = impl_from_IMFPresentationDescriptor(iface);
|
|
|
|
return IMFAttributes_GetItem(&This->attributes.IMFAttributes_iface, key, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfpresentationdescriptor_GetItemType(IMFPresentationDescriptor *iface, REFGUID key, MF_ATTRIBUTE_TYPE *type)
|
|
|
|
{
|
|
|
|
mfpresentationdescriptor *This = impl_from_IMFPresentationDescriptor(iface);
|
|
|
|
return IMFAttributes_GetItemType(&This->attributes.IMFAttributes_iface, key, type);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfpresentationdescriptor_CompareItem(IMFPresentationDescriptor *iface, REFGUID key, REFPROPVARIANT value, BOOL *result)
|
|
|
|
{
|
|
|
|
mfpresentationdescriptor *This = impl_from_IMFPresentationDescriptor(iface);
|
|
|
|
return IMFAttributes_CompareItem(&This->attributes.IMFAttributes_iface, key, value, result);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfpresentationdescriptor_Compare(IMFPresentationDescriptor *iface, IMFAttributes *attrs, MF_ATTRIBUTES_MATCH_TYPE type,
|
|
|
|
BOOL *result)
|
|
|
|
{
|
|
|
|
mfpresentationdescriptor *This = impl_from_IMFPresentationDescriptor(iface);
|
|
|
|
return IMFAttributes_Compare(&This->attributes.IMFAttributes_iface, attrs, type, result);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfpresentationdescriptor_GetUINT32(IMFPresentationDescriptor *iface, REFGUID key, UINT32 *value)
|
|
|
|
{
|
|
|
|
mfpresentationdescriptor *This = impl_from_IMFPresentationDescriptor(iface);
|
|
|
|
return IMFAttributes_GetUINT32(&This->attributes.IMFAttributes_iface, key, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfpresentationdescriptor_GetUINT64(IMFPresentationDescriptor *iface, REFGUID key, UINT64 *value)
|
|
|
|
{
|
|
|
|
mfpresentationdescriptor *This = impl_from_IMFPresentationDescriptor(iface);
|
|
|
|
return IMFAttributes_GetUINT64(&This->attributes.IMFAttributes_iface, key, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfpresentationdescriptor_GetDouble(IMFPresentationDescriptor *iface, REFGUID key, double *value)
|
|
|
|
{
|
|
|
|
mfpresentationdescriptor *This = impl_from_IMFPresentationDescriptor(iface);
|
|
|
|
return IMFAttributes_GetDouble(&This->attributes.IMFAttributes_iface, key, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfpresentationdescriptor_GetGUID(IMFPresentationDescriptor *iface, REFGUID key, GUID *value)
|
|
|
|
{
|
|
|
|
mfpresentationdescriptor *This = impl_from_IMFPresentationDescriptor(iface);
|
|
|
|
return IMFAttributes_GetGUID(&This->attributes.IMFAttributes_iface, key, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfpresentationdescriptor_GetStringLength(IMFPresentationDescriptor *iface, REFGUID key, UINT32 *length)
|
|
|
|
{
|
|
|
|
mfpresentationdescriptor *This = impl_from_IMFPresentationDescriptor(iface);
|
|
|
|
return IMFAttributes_GetStringLength(&This->attributes.IMFAttributes_iface, key, length);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfpresentationdescriptor_GetString(IMFPresentationDescriptor *iface, REFGUID key, WCHAR *value,
|
|
|
|
UINT32 size, UINT32 *length)
|
|
|
|
{
|
|
|
|
mfpresentationdescriptor *This = impl_from_IMFPresentationDescriptor(iface);
|
|
|
|
return IMFAttributes_GetString(&This->attributes.IMFAttributes_iface, key, value, size, length);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfpresentationdescriptor_GetAllocatedString(IMFPresentationDescriptor *iface, REFGUID key,
|
|
|
|
WCHAR **value, UINT32 *length)
|
|
|
|
{
|
|
|
|
mfpresentationdescriptor *This = impl_from_IMFPresentationDescriptor(iface);
|
|
|
|
return IMFAttributes_GetAllocatedString(&This->attributes.IMFAttributes_iface, key, value, length);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfpresentationdescriptor_GetBlobSize(IMFPresentationDescriptor *iface, REFGUID key, UINT32 *size)
|
|
|
|
{
|
|
|
|
mfpresentationdescriptor *This = impl_from_IMFPresentationDescriptor(iface);
|
|
|
|
return IMFAttributes_GetBlobSize(&This->attributes.IMFAttributes_iface, key, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfpresentationdescriptor_GetBlob(IMFPresentationDescriptor *iface, REFGUID key, UINT8 *buf,
|
|
|
|
UINT32 bufsize, UINT32 *blobsize)
|
|
|
|
{
|
|
|
|
mfpresentationdescriptor *This = impl_from_IMFPresentationDescriptor(iface);
|
|
|
|
return IMFAttributes_GetBlob(&This->attributes.IMFAttributes_iface, key, buf, bufsize, blobsize);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfpresentationdescriptor_GetAllocatedBlob(IMFPresentationDescriptor *iface, REFGUID key, UINT8 **buf, UINT32 *size)
|
|
|
|
{
|
|
|
|
mfpresentationdescriptor *This = impl_from_IMFPresentationDescriptor(iface);
|
|
|
|
return IMFAttributes_GetAllocatedBlob(&This->attributes.IMFAttributes_iface, key, buf, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfpresentationdescriptor_GetUnknown(IMFPresentationDescriptor *iface, REFGUID key, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
mfpresentationdescriptor *This = impl_from_IMFPresentationDescriptor(iface);
|
|
|
|
return IMFAttributes_GetUnknown(&This->attributes.IMFAttributes_iface, key, riid, ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfpresentationdescriptor_SetItem(IMFPresentationDescriptor *iface, REFGUID key, REFPROPVARIANT value)
|
|
|
|
{
|
|
|
|
mfpresentationdescriptor *This = impl_from_IMFPresentationDescriptor(iface);
|
|
|
|
return IMFAttributes_SetItem(&This->attributes.IMFAttributes_iface, key, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfpresentationdescriptor_DeleteItem(IMFPresentationDescriptor *iface, REFGUID key)
|
|
|
|
{
|
|
|
|
mfpresentationdescriptor *This = impl_from_IMFPresentationDescriptor(iface);
|
|
|
|
return IMFAttributes_DeleteItem(&This->attributes.IMFAttributes_iface, key);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfpresentationdescriptor_DeleteAllItems(IMFPresentationDescriptor *iface)
|
|
|
|
{
|
|
|
|
mfpresentationdescriptor *This = impl_from_IMFPresentationDescriptor(iface);
|
|
|
|
return IMFAttributes_DeleteAllItems(&This->attributes.IMFAttributes_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfpresentationdescriptor_SetUINT32(IMFPresentationDescriptor *iface, REFGUID key, UINT32 value)
|
|
|
|
{
|
|
|
|
mfpresentationdescriptor *This = impl_from_IMFPresentationDescriptor(iface);
|
|
|
|
return IMFAttributes_SetUINT32(&This->attributes.IMFAttributes_iface, key, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfpresentationdescriptor_SetUINT64(IMFPresentationDescriptor *iface, REFGUID key, UINT64 value)
|
|
|
|
{
|
|
|
|
mfpresentationdescriptor *This = impl_from_IMFPresentationDescriptor(iface);
|
|
|
|
return IMFAttributes_SetUINT64(&This->attributes.IMFAttributes_iface, key, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfpresentationdescriptor_SetDouble(IMFPresentationDescriptor *iface, REFGUID key, double value)
|
|
|
|
{
|
|
|
|
mfpresentationdescriptor *This = impl_from_IMFPresentationDescriptor(iface);
|
|
|
|
return IMFAttributes_SetDouble(&This->attributes.IMFAttributes_iface, key, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfpresentationdescriptor_SetGUID(IMFPresentationDescriptor *iface, REFGUID key, REFGUID value)
|
|
|
|
{
|
|
|
|
mfpresentationdescriptor *This = impl_from_IMFPresentationDescriptor(iface);
|
|
|
|
return IMFAttributes_SetGUID(&This->attributes.IMFAttributes_iface, key, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfpresentationdescriptor_SetString(IMFPresentationDescriptor *iface, REFGUID key, const WCHAR *value)
|
|
|
|
{
|
|
|
|
mfpresentationdescriptor *This = impl_from_IMFPresentationDescriptor(iface);
|
|
|
|
return IMFAttributes_SetString(&This->attributes.IMFAttributes_iface, key, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfpresentationdescriptor_SetBlob(IMFPresentationDescriptor *iface, REFGUID key, const UINT8 *buf, UINT32 size)
|
|
|
|
{
|
|
|
|
mfpresentationdescriptor *This = impl_from_IMFPresentationDescriptor(iface);
|
|
|
|
return IMFAttributes_SetBlob(&This->attributes.IMFAttributes_iface, key, buf, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfpresentationdescriptor_SetUnknown(IMFPresentationDescriptor *iface, REFGUID key, IUnknown *unknown)
|
|
|
|
{
|
|
|
|
mfpresentationdescriptor *This = impl_from_IMFPresentationDescriptor(iface);
|
|
|
|
return IMFAttributes_SetUnknown(&This->attributes.IMFAttributes_iface, key, unknown);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfpresentationdescriptor_LockStore(IMFPresentationDescriptor *iface)
|
|
|
|
{
|
|
|
|
mfpresentationdescriptor *This = impl_from_IMFPresentationDescriptor(iface);
|
|
|
|
return IMFAttributes_LockStore(&This->attributes.IMFAttributes_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfpresentationdescriptor_UnlockStore(IMFPresentationDescriptor *iface)
|
|
|
|
{
|
|
|
|
mfpresentationdescriptor *This = impl_from_IMFPresentationDescriptor(iface);
|
|
|
|
return IMFAttributes_UnlockStore(&This->attributes.IMFAttributes_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfpresentationdescriptor_GetCount(IMFPresentationDescriptor *iface, UINT32 *items)
|
|
|
|
{
|
|
|
|
mfpresentationdescriptor *This = impl_from_IMFPresentationDescriptor(iface);
|
|
|
|
return IMFAttributes_GetCount(&This->attributes.IMFAttributes_iface, items);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfpresentationdescriptor_GetItemByIndex(IMFPresentationDescriptor *iface, UINT32 index, GUID *key, PROPVARIANT *value)
|
|
|
|
{
|
|
|
|
mfpresentationdescriptor *This = impl_from_IMFPresentationDescriptor(iface);
|
|
|
|
return IMFAttributes_GetItemByIndex(&This->attributes.IMFAttributes_iface, index, key, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfpresentationdescriptor_CopyAllItems(IMFPresentationDescriptor *iface, IMFAttributes *dest)
|
|
|
|
{
|
|
|
|
mfpresentationdescriptor *This = impl_from_IMFPresentationDescriptor(iface);
|
|
|
|
|
|
|
|
FIXME("%p, %p\n", This, dest);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfpresentationdescriptor_GetStreamDescriptorCount(IMFPresentationDescriptor *iface, DWORD *descriptor_count)
|
|
|
|
{
|
|
|
|
mfpresentationdescriptor *This = impl_from_IMFPresentationDescriptor(iface);
|
|
|
|
|
|
|
|
FIXME("%p, %p\n", This, descriptor_count);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfpresentationdescriptor_GetStreamDescriptorByIndex(IMFPresentationDescriptor *iface, DWORD index,
|
|
|
|
BOOL *selected, IMFStreamDescriptor **descriptor)
|
|
|
|
{
|
|
|
|
mfpresentationdescriptor *This = impl_from_IMFPresentationDescriptor(iface);
|
|
|
|
|
|
|
|
FIXME("%p, %#x, %p, %p\n", This, index, selected, descriptor);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfpresentationdescriptor_SelectStream(IMFPresentationDescriptor *iface, DWORD index)
|
|
|
|
{
|
|
|
|
mfpresentationdescriptor *This = impl_from_IMFPresentationDescriptor(iface);
|
|
|
|
|
|
|
|
FIXME("%p, %#x\n", This, index);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfpresentationdescriptor_DeselectStream(IMFPresentationDescriptor *iface, DWORD index)
|
|
|
|
{
|
|
|
|
mfpresentationdescriptor *This = impl_from_IMFPresentationDescriptor(iface);
|
|
|
|
|
|
|
|
FIXME("%p, %#x\n", This, index);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfpresentationdescriptor_Clone(IMFPresentationDescriptor *iface, IMFPresentationDescriptor **descriptor)
|
|
|
|
{
|
|
|
|
mfpresentationdescriptor *This = impl_from_IMFPresentationDescriptor(iface);
|
|
|
|
|
|
|
|
FIXME("%p, %p\n", This, descriptor);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IMFPresentationDescriptorVtbl mfpresentationdescriptor_vtbl =
|
|
|
|
{
|
|
|
|
mfpresentationdescriptor_QueryInterface,
|
|
|
|
mfpresentationdescriptor_AddRef,
|
|
|
|
mfpresentationdescriptor_Release,
|
|
|
|
mfpresentationdescriptor_GetItem,
|
|
|
|
mfpresentationdescriptor_GetItemType,
|
|
|
|
mfpresentationdescriptor_CompareItem,
|
|
|
|
mfpresentationdescriptor_Compare,
|
|
|
|
mfpresentationdescriptor_GetUINT32,
|
|
|
|
mfpresentationdescriptor_GetUINT64,
|
|
|
|
mfpresentationdescriptor_GetDouble,
|
|
|
|
mfpresentationdescriptor_GetGUID,
|
|
|
|
mfpresentationdescriptor_GetStringLength,
|
|
|
|
mfpresentationdescriptor_GetString,
|
|
|
|
mfpresentationdescriptor_GetAllocatedString,
|
|
|
|
mfpresentationdescriptor_GetBlobSize,
|
|
|
|
mfpresentationdescriptor_GetBlob,
|
|
|
|
mfpresentationdescriptor_GetAllocatedBlob,
|
|
|
|
mfpresentationdescriptor_GetUnknown,
|
|
|
|
mfpresentationdescriptor_SetItem,
|
|
|
|
mfpresentationdescriptor_DeleteItem,
|
|
|
|
mfpresentationdescriptor_DeleteAllItems,
|
|
|
|
mfpresentationdescriptor_SetUINT32,
|
|
|
|
mfpresentationdescriptor_SetUINT64,
|
|
|
|
mfpresentationdescriptor_SetDouble,
|
|
|
|
mfpresentationdescriptor_SetGUID,
|
|
|
|
mfpresentationdescriptor_SetString,
|
|
|
|
mfpresentationdescriptor_SetBlob,
|
|
|
|
mfpresentationdescriptor_SetUnknown,
|
|
|
|
mfpresentationdescriptor_LockStore,
|
|
|
|
mfpresentationdescriptor_UnlockStore,
|
|
|
|
mfpresentationdescriptor_GetCount,
|
|
|
|
mfpresentationdescriptor_GetItemByIndex,
|
|
|
|
mfpresentationdescriptor_CopyAllItems,
|
|
|
|
mfpresentationdescriptor_GetStreamDescriptorCount,
|
|
|
|
mfpresentationdescriptor_GetStreamDescriptorByIndex,
|
|
|
|
mfpresentationdescriptor_SelectStream,
|
|
|
|
mfpresentationdescriptor_DeselectStream,
|
|
|
|
mfpresentationdescriptor_Clone,
|
|
|
|
};
|
|
|
|
|
2018-11-22 21:00:45 +01:00
|
|
|
typedef struct _mfsource
|
|
|
|
{
|
|
|
|
IMFMediaSource IMFMediaSource_iface;
|
|
|
|
LONG ref;
|
|
|
|
} mfsource;
|
|
|
|
|
|
|
|
static inline mfsource *impl_from_IMFMediaSource(IMFMediaSource *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, mfsource, IMFMediaSource_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfsource_QueryInterface(IMFMediaSource *iface, REFIID riid, void **out)
|
|
|
|
{
|
|
|
|
mfsource *This = impl_from_IMFMediaSource(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), out);
|
|
|
|
|
|
|
|
if (IsEqualIID(riid, &IID_IMFMediaSource) ||
|
|
|
|
IsEqualIID(riid, &IID_IMFMediaEventGenerator) ||
|
|
|
|
IsEqualIID(riid, &IID_IUnknown))
|
|
|
|
{
|
|
|
|
*out = &This->IMFMediaSource_iface;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("(%s, %p)\n", debugstr_guid(riid), out);
|
|
|
|
*out = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
IUnknown_AddRef((IUnknown*)*out);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI mfsource_AddRef(IMFMediaSource *iface)
|
|
|
|
{
|
|
|
|
mfsource *This = impl_from_IMFMediaSource(iface);
|
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%u\n", This, ref);
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI mfsource_Release(IMFMediaSource *iface)
|
|
|
|
{
|
|
|
|
mfsource *This = impl_from_IMFMediaSource(iface);
|
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%u\n", This, ref);
|
|
|
|
|
|
|
|
if (!ref)
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfsource_GetEvent(IMFMediaSource *iface, DWORD flags, IMFMediaEvent **event)
|
|
|
|
{
|
|
|
|
mfsource *This = impl_from_IMFMediaSource(iface);
|
|
|
|
|
|
|
|
FIXME("(%p)->(%#x, %p)\n", This, flags, event);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfsource_BeginGetEvent(IMFMediaSource *iface, IMFAsyncCallback *callback, IUnknown *state)
|
|
|
|
{
|
|
|
|
mfsource *This = impl_from_IMFMediaSource(iface);
|
|
|
|
|
|
|
|
FIXME("(%p)->(%p, %p)\n", This, callback, state);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfsource_EndGetEvent(IMFMediaSource *iface, IMFAsyncResult *result, IMFMediaEvent **event)
|
|
|
|
{
|
|
|
|
mfsource *This = impl_from_IMFMediaSource(iface);
|
|
|
|
|
|
|
|
FIXME("(%p)->(%p, %p)\n", This, result, event);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfsource_QueueEvent(IMFMediaSource *iface, MediaEventType event_type, REFGUID ext_type,
|
|
|
|
HRESULT hr, const PROPVARIANT *value)
|
|
|
|
{
|
|
|
|
mfsource *This = impl_from_IMFMediaSource(iface);
|
|
|
|
|
|
|
|
FIXME("(%p)->(%d, %s, %#x, %p)\n", This, event_type, debugstr_guid(ext_type), hr, value);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfsource_GetCharacteristics(IMFMediaSource *iface, DWORD *characteristics)
|
|
|
|
{
|
|
|
|
mfsource *This = impl_from_IMFMediaSource(iface);
|
|
|
|
|
|
|
|
FIXME("(%p)->(%p): stub\n", This, characteristics);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfsource_CreatePresentationDescriptor(IMFMediaSource *iface, IMFPresentationDescriptor **descriptor)
|
|
|
|
{
|
|
|
|
mfsource *This = impl_from_IMFMediaSource(iface);
|
|
|
|
|
2018-11-25 20:45:05 +01:00
|
|
|
mfpresentationdescriptor *object;
|
|
|
|
|
2018-11-22 21:00:45 +01:00
|
|
|
FIXME("(%p)->(%p): stub\n", This, descriptor);
|
|
|
|
|
2018-11-25 20:45:05 +01:00
|
|
|
object = HeapAlloc( GetProcessHeap(), 0, sizeof(*object) );
|
|
|
|
if (!object)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2019-03-14 09:03:07 +01:00
|
|
|
init_attributes_object(&object->attributes, 0);
|
2018-11-25 20:45:05 +01:00
|
|
|
object->IMFPresentationDescriptor_iface.lpVtbl = &mfpresentationdescriptor_vtbl;
|
|
|
|
|
|
|
|
*descriptor = &object->IMFPresentationDescriptor_iface;
|
|
|
|
return S_OK;
|
2018-11-22 21:00:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfsource_Start(IMFMediaSource *iface, IMFPresentationDescriptor *descriptor,
|
|
|
|
const GUID *time_format, const PROPVARIANT *start_position)
|
|
|
|
{
|
|
|
|
mfsource *This = impl_from_IMFMediaSource(iface);
|
|
|
|
|
|
|
|
FIXME("(%p)->(%p, %p, %p): stub\n", This, descriptor, time_format, start_position);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfsource_Stop(IMFMediaSource *iface)
|
|
|
|
{
|
|
|
|
mfsource *This = impl_from_IMFMediaSource(iface);
|
|
|
|
|
|
|
|
FIXME("(%p): stub\n", This);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfsource_Pause(IMFMediaSource *iface)
|
|
|
|
{
|
|
|
|
mfsource *This = impl_from_IMFMediaSource(iface);
|
|
|
|
|
|
|
|
FIXME("(%p): stub\n", This);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfsource_Shutdown(IMFMediaSource *iface)
|
|
|
|
{
|
|
|
|
mfsource *This = impl_from_IMFMediaSource(iface);
|
|
|
|
|
|
|
|
FIXME("(%p): stub\n", This);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IMFMediaSourceVtbl mfsourcevtbl =
|
|
|
|
{
|
|
|
|
mfsource_QueryInterface,
|
|
|
|
mfsource_AddRef,
|
|
|
|
mfsource_Release,
|
|
|
|
mfsource_GetEvent,
|
|
|
|
mfsource_BeginGetEvent,
|
|
|
|
mfsource_EndGetEvent,
|
|
|
|
mfsource_QueueEvent,
|
|
|
|
mfsource_GetCharacteristics,
|
|
|
|
mfsource_CreatePresentationDescriptor,
|
|
|
|
mfsource_Start,
|
|
|
|
mfsource_Stop,
|
|
|
|
mfsource_Pause,
|
|
|
|
mfsource_Shutdown,
|
|
|
|
};
|
|
|
|
|
2019-03-11 11:28:09 +01:00
|
|
|
enum resolved_object_origin
|
|
|
|
{
|
|
|
|
OBJECT_FROM_BYTESTREAM,
|
2019-03-12 07:07:42 +01:00
|
|
|
OBJECT_FROM_URL,
|
2019-03-11 11:28:09 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct resolver_queued_result
|
|
|
|
{
|
|
|
|
struct list entry;
|
|
|
|
IUnknown *object;
|
|
|
|
MF_OBJECT_TYPE obj_type;
|
|
|
|
HRESULT hr;
|
|
|
|
enum resolved_object_origin origin;
|
|
|
|
};
|
|
|
|
|
2019-03-11 11:28:10 +01:00
|
|
|
struct resolver_cancel_object
|
|
|
|
{
|
|
|
|
IUnknown IUnknown_iface;
|
|
|
|
LONG refcount;
|
|
|
|
union
|
|
|
|
{
|
|
|
|
IUnknown *handler;
|
|
|
|
IMFByteStreamHandler *stream_handler;
|
2019-03-12 07:07:43 +01:00
|
|
|
IMFSchemeHandler *scheme_handler;
|
2019-03-11 11:28:10 +01:00
|
|
|
} u;
|
|
|
|
IUnknown *cancel_cookie;
|
|
|
|
enum resolved_object_origin origin;
|
|
|
|
};
|
|
|
|
|
2019-03-11 11:28:09 +01:00
|
|
|
typedef struct source_resolver
|
2017-05-28 13:42:48 +02:00
|
|
|
{
|
|
|
|
IMFSourceResolver IMFSourceResolver_iface;
|
2019-03-11 11:28:09 +01:00
|
|
|
LONG refcount;
|
|
|
|
IMFAsyncCallback stream_callback;
|
2019-03-12 07:07:42 +01:00
|
|
|
IMFAsyncCallback url_callback;
|
2019-03-11 11:28:09 +01:00
|
|
|
CRITICAL_SECTION cs;
|
|
|
|
struct list pending;
|
2017-05-28 13:42:48 +02:00
|
|
|
} mfsourceresolver;
|
|
|
|
|
2019-03-11 11:28:09 +01:00
|
|
|
static struct source_resolver *impl_from_IMFSourceResolver(IMFSourceResolver *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct source_resolver, IMFSourceResolver_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct source_resolver *impl_from_stream_IMFAsyncCallback(IMFAsyncCallback *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct source_resolver, stream_callback);
|
|
|
|
}
|
|
|
|
|
2019-03-12 07:07:42 +01:00
|
|
|
static struct source_resolver *impl_from_url_IMFAsyncCallback(IMFAsyncCallback *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct source_resolver, url_callback);
|
|
|
|
}
|
|
|
|
|
2019-03-11 11:28:09 +01:00
|
|
|
static HRESULT resolver_handler_end_create(struct source_resolver *resolver, enum resolved_object_origin origin,
|
|
|
|
IMFAsyncResult *result)
|
|
|
|
{
|
|
|
|
IMFAsyncResult *inner_result = (IMFAsyncResult *)IMFAsyncResult_GetStateNoAddRef(result);
|
|
|
|
struct resolver_queued_result *queued_result;
|
|
|
|
union
|
|
|
|
{
|
|
|
|
IUnknown *handler;
|
|
|
|
IMFByteStreamHandler *stream_handler;
|
2019-03-12 07:07:42 +01:00
|
|
|
IMFSchemeHandler *scheme_handler;
|
2019-03-11 11:28:09 +01:00
|
|
|
} handler;
|
|
|
|
|
|
|
|
queued_result = heap_alloc(sizeof(*queued_result));
|
|
|
|
|
|
|
|
IMFAsyncResult_GetObject(inner_result, &handler.handler);
|
|
|
|
|
|
|
|
switch (origin)
|
|
|
|
{
|
|
|
|
case OBJECT_FROM_BYTESTREAM:
|
2019-03-12 07:07:43 +01:00
|
|
|
queued_result->hr = IMFByteStreamHandler_EndCreateObject(handler.stream_handler, result,
|
|
|
|
&queued_result->obj_type, &queued_result->object);
|
2019-03-11 11:28:09 +01:00
|
|
|
break;
|
2019-03-12 07:07:42 +01:00
|
|
|
case OBJECT_FROM_URL:
|
2019-03-12 07:07:43 +01:00
|
|
|
queued_result->hr = IMFSchemeHandler_EndCreateObject(handler.scheme_handler, result,
|
|
|
|
&queued_result->obj_type, &queued_result->object);
|
2019-03-12 07:07:42 +01:00
|
|
|
break;
|
2019-03-11 11:28:09 +01:00
|
|
|
default:
|
|
|
|
queued_result->hr = E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
IUnknown_Release(handler.handler);
|
|
|
|
|
|
|
|
if (SUCCEEDED(queued_result->hr))
|
|
|
|
{
|
|
|
|
MFASYNCRESULT *data = (MFASYNCRESULT *)inner_result;
|
|
|
|
|
|
|
|
/* Push resolved object type and created object, so we don't have to guess on End*() call. */
|
|
|
|
EnterCriticalSection(&resolver->cs);
|
|
|
|
list_add_tail(&resolver->pending, &queued_result->entry);
|
|
|
|
LeaveCriticalSection(&resolver->cs);
|
|
|
|
|
|
|
|
if (data->hEvent)
|
|
|
|
SetEvent(data->hEvent);
|
2019-03-11 11:28:10 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
IUnknown *caller_state = IMFAsyncResult_GetStateNoAddRef(inner_result);
|
|
|
|
IMFAsyncResult *caller_result;
|
|
|
|
|
|
|
|
if (SUCCEEDED(MFCreateAsyncResult(queued_result->object, data->pCallback, caller_state, &caller_result)))
|
|
|
|
{
|
|
|
|
MFInvokeCallback(caller_result);
|
|
|
|
IMFAsyncResult_Release(caller_result);
|
|
|
|
}
|
|
|
|
}
|
2019-03-11 11:28:09 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
heap_free(queued_result);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-03-11 11:28:10 +01:00
|
|
|
static struct resolver_cancel_object *impl_cancel_obj_from_IUnknown(IUnknown *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct resolver_cancel_object, IUnknown_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI resolver_cancel_object_QueryInterface(IUnknown *iface, REFIID riid, void **obj)
|
|
|
|
{
|
|
|
|
if (IsEqualIID(riid, &IID_IUnknown))
|
|
|
|
{
|
|
|
|
*obj = iface;
|
|
|
|
IUnknown_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
*obj = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI resolver_cancel_object_AddRef(IUnknown *iface)
|
|
|
|
{
|
|
|
|
struct resolver_cancel_object *object = impl_cancel_obj_from_IUnknown(iface);
|
|
|
|
return InterlockedIncrement(&object->refcount);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI resolver_cancel_object_Release(IUnknown *iface)
|
|
|
|
{
|
|
|
|
struct resolver_cancel_object *object = impl_cancel_obj_from_IUnknown(iface);
|
|
|
|
ULONG refcount = InterlockedDecrement(&object->refcount);
|
|
|
|
|
|
|
|
if (!refcount)
|
|
|
|
{
|
|
|
|
if (object->cancel_cookie)
|
|
|
|
IUnknown_Release(object->cancel_cookie);
|
|
|
|
IUnknown_Release(object->u.handler);
|
|
|
|
heap_free(object);
|
|
|
|
}
|
|
|
|
|
|
|
|
return refcount;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IUnknownVtbl resolver_cancel_object_vtbl =
|
|
|
|
{
|
|
|
|
resolver_cancel_object_QueryInterface,
|
|
|
|
resolver_cancel_object_AddRef,
|
|
|
|
resolver_cancel_object_Release,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct resolver_cancel_object *unsafe_impl_cancel_obj_from_IUnknown(IUnknown *iface)
|
|
|
|
{
|
|
|
|
if (!iface)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return (iface->lpVtbl == &resolver_cancel_object_vtbl) ?
|
|
|
|
CONTAINING_RECORD(iface, struct resolver_cancel_object, IUnknown_iface) : NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT resolver_create_cancel_object(IUnknown *handler, enum resolved_object_origin origin,
|
|
|
|
IUnknown *cancel_cookie, IUnknown **cancel_object)
|
|
|
|
{
|
|
|
|
struct resolver_cancel_object *object;
|
|
|
|
|
|
|
|
object = heap_alloc_zero(sizeof(*object));
|
|
|
|
if (!object)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
object->IUnknown_iface.lpVtbl = &resolver_cancel_object_vtbl;
|
|
|
|
object->refcount = 1;
|
|
|
|
object->u.handler = handler;
|
|
|
|
IUnknown_AddRef(object->u.handler);
|
|
|
|
object->cancel_cookie = cancel_cookie;
|
|
|
|
IUnknown_AddRef(object->cancel_cookie);
|
|
|
|
object->origin = origin;
|
|
|
|
|
|
|
|
*cancel_object = &object->IUnknown_iface;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-03-11 11:28:09 +01:00
|
|
|
static HRESULT WINAPI source_resolver_callback_QueryInterface(IMFAsyncCallback *iface, REFIID riid, void **obj)
|
|
|
|
{
|
|
|
|
if (IsEqualIID(riid, &IID_IMFAsyncCallback) ||
|
|
|
|
IsEqualIID(riid, &IID_IUnknown))
|
|
|
|
{
|
|
|
|
*obj = iface;
|
|
|
|
IMFAsyncCallback_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
*obj = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI source_resolver_callback_stream_AddRef(IMFAsyncCallback *iface)
|
|
|
|
{
|
|
|
|
struct source_resolver *resolver = impl_from_stream_IMFAsyncCallback(iface);
|
|
|
|
return IMFSourceResolver_AddRef(&resolver->IMFSourceResolver_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI source_resolver_callback_stream_Release(IMFAsyncCallback *iface)
|
|
|
|
{
|
|
|
|
struct source_resolver *resolver = impl_from_stream_IMFAsyncCallback(iface);
|
|
|
|
return IMFSourceResolver_Release(&resolver->IMFSourceResolver_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI source_resolver_callback_GetParameters(IMFAsyncCallback *iface, DWORD *flags, DWORD *queue)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI source_resolver_callback_stream_Invoke(IMFAsyncCallback *iface, IMFAsyncResult *result)
|
|
|
|
{
|
|
|
|
struct source_resolver *resolver = impl_from_stream_IMFAsyncCallback(iface);
|
|
|
|
|
|
|
|
return resolver_handler_end_create(resolver, OBJECT_FROM_BYTESTREAM, result);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IMFAsyncCallbackVtbl source_resolver_callback_stream_vtbl =
|
|
|
|
{
|
|
|
|
source_resolver_callback_QueryInterface,
|
|
|
|
source_resolver_callback_stream_AddRef,
|
|
|
|
source_resolver_callback_stream_Release,
|
|
|
|
source_resolver_callback_GetParameters,
|
|
|
|
source_resolver_callback_stream_Invoke,
|
|
|
|
};
|
|
|
|
|
2019-03-12 07:07:42 +01:00
|
|
|
static ULONG WINAPI source_resolver_callback_url_AddRef(IMFAsyncCallback *iface)
|
|
|
|
{
|
|
|
|
struct source_resolver *resolver = impl_from_url_IMFAsyncCallback(iface);
|
|
|
|
return IMFSourceResolver_AddRef(&resolver->IMFSourceResolver_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI source_resolver_callback_url_Release(IMFAsyncCallback *iface)
|
|
|
|
{
|
|
|
|
struct source_resolver *resolver = impl_from_url_IMFAsyncCallback(iface);
|
|
|
|
return IMFSourceResolver_Release(&resolver->IMFSourceResolver_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI source_resolver_callback_url_Invoke(IMFAsyncCallback *iface, IMFAsyncResult *result)
|
|
|
|
{
|
|
|
|
struct source_resolver *resolver = impl_from_url_IMFAsyncCallback(iface);
|
|
|
|
|
|
|
|
return resolver_handler_end_create(resolver, OBJECT_FROM_URL, result);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IMFAsyncCallbackVtbl source_resolver_callback_url_vtbl =
|
|
|
|
{
|
|
|
|
source_resolver_callback_QueryInterface,
|
|
|
|
source_resolver_callback_url_AddRef,
|
|
|
|
source_resolver_callback_url_Release,
|
|
|
|
source_resolver_callback_GetParameters,
|
|
|
|
source_resolver_callback_url_Invoke,
|
|
|
|
};
|
|
|
|
|
2019-03-11 11:28:09 +01:00
|
|
|
static HRESULT resolver_create_registered_handler(HKEY hkey, REFIID riid, void **handler)
|
|
|
|
{
|
|
|
|
unsigned int j = 0, name_length, type;
|
|
|
|
HRESULT hr = E_FAIL;
|
|
|
|
WCHAR clsidW[39];
|
|
|
|
CLSID clsid;
|
|
|
|
|
|
|
|
name_length = ARRAY_SIZE(clsidW);
|
|
|
|
while (!RegEnumValueW(hkey, j++, clsidW, &name_length, NULL, &type, NULL, NULL))
|
|
|
|
{
|
|
|
|
if (type == REG_SZ)
|
|
|
|
{
|
|
|
|
if (SUCCEEDED(CLSIDFromString(clsidW, &clsid)))
|
|
|
|
{
|
|
|
|
hr = CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_SERVER, riid, handler);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
name_length = ARRAY_SIZE(clsidW);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT resolver_get_bytestream_handler(IMFByteStream *stream, const WCHAR *url, DWORD flags,
|
|
|
|
IMFByteStreamHandler **handler)
|
2017-05-28 13:42:48 +02:00
|
|
|
{
|
2019-03-11 11:28:09 +01:00
|
|
|
static const char streamhandlerspath[] = "Software\\Microsoft\\Windows Media Foundation\\ByteStreamHandlers";
|
|
|
|
static const HKEY hkey_roots[2] = { HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE };
|
|
|
|
IMFAttributes *attributes;
|
|
|
|
const WCHAR *url_ext;
|
|
|
|
WCHAR *mimeW = NULL;
|
|
|
|
unsigned int i, j;
|
|
|
|
UINT32 length;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
*handler = NULL;
|
|
|
|
|
|
|
|
/* MIME type */
|
|
|
|
if (SUCCEEDED(IMFByteStream_QueryInterface(stream, &IID_IMFAttributes, (void **)&attributes)))
|
|
|
|
{
|
|
|
|
IMFAttributes_GetAllocatedString(attributes, &MF_BYTESTREAM_CONTENT_TYPE, &mimeW, &length);
|
|
|
|
IMFAttributes_Release(attributes);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Extension */
|
|
|
|
url_ext = url ? strrchrW(url, '.') : NULL;
|
|
|
|
|
|
|
|
if (!url_ext && !mimeW)
|
|
|
|
{
|
|
|
|
CoTaskMemFree(mimeW);
|
|
|
|
return MF_E_UNSUPPORTED_BYTESTREAM_TYPE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: check local handlers first */
|
|
|
|
|
|
|
|
for (i = 0, hr = E_FAIL; i < ARRAY_SIZE(hkey_roots); ++i)
|
|
|
|
{
|
|
|
|
const WCHAR *namesW[2] = { mimeW, url_ext };
|
|
|
|
HKEY hkey, hkey_handler;
|
|
|
|
|
|
|
|
if (RegOpenKeyA(hkey_roots[i], streamhandlerspath, &hkey))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for (j = 0; j < ARRAY_SIZE(namesW); ++j)
|
|
|
|
{
|
|
|
|
if (!namesW[j])
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!RegOpenKeyW(hkey, namesW[j], &hkey_handler))
|
|
|
|
{
|
|
|
|
hr = resolver_create_registered_handler(hkey_handler, &IID_IMFByteStreamHandler, (void **)handler);
|
|
|
|
RegCloseKey(hkey_handler);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
CoTaskMemFree(mimeW);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2019-03-12 07:07:42 +01:00
|
|
|
static HRESULT resolver_get_scheme_handler(const WCHAR *url, DWORD flags, IMFSchemeHandler **handler)
|
|
|
|
{
|
|
|
|
static const char schemehandlerspath[] = "Software\\Microsoft\\Windows Media Foundation\\SchemeHandlers";
|
|
|
|
static const HKEY hkey_roots[2] = { HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE };
|
|
|
|
const WCHAR *ptr = url;
|
|
|
|
unsigned int len, i;
|
|
|
|
WCHAR *scheme;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
/* RFC 3986: scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ) */
|
|
|
|
while (*ptr)
|
|
|
|
{
|
|
|
|
WCHAR ch = tolowerW(*ptr);
|
|
|
|
|
|
|
|
if (*ptr == '*' && ptr == url)
|
|
|
|
{
|
|
|
|
ptr++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (!(*ptr >= '0' && *ptr <= '9') &&
|
|
|
|
!(ch >= 'a' && ch <= 'z') &&
|
|
|
|
*ptr != '+' && *ptr != '-' && *ptr != '.')
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ptr++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Schemes must end with a ':' */
|
|
|
|
if (ptr == url || *ptr != ':')
|
|
|
|
return MF_E_UNSUPPORTED_SCHEME;
|
|
|
|
|
|
|
|
len = ptr - url;
|
|
|
|
scheme = heap_alloc((len + 1) * sizeof(WCHAR));
|
|
|
|
if (!scheme)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
memcpy(scheme, url, len * sizeof(WCHAR));
|
|
|
|
scheme[len] = 0;
|
|
|
|
|
|
|
|
/* FIXME: check local handlers first */
|
|
|
|
|
|
|
|
for (i = 0, hr = E_FAIL; i < ARRAY_SIZE(hkey_roots); ++i)
|
|
|
|
{
|
|
|
|
HKEY hkey, hkey_handler;
|
|
|
|
|
|
|
|
if (RegOpenKeyA(hkey_roots[i], schemehandlerspath, &hkey))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!RegOpenKeyW(hkey, scheme, &hkey_handler))
|
|
|
|
{
|
|
|
|
hr = resolver_create_registered_handler(hkey_handler, &IID_IMFSchemeHandler, (void **)handler);
|
|
|
|
RegCloseKey(hkey_handler);
|
|
|
|
}
|
|
|
|
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
heap_free(scheme);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2019-03-11 11:28:09 +01:00
|
|
|
static HRESULT resolver_end_create_object(struct source_resolver *resolver, enum resolved_object_origin origin,
|
|
|
|
IMFAsyncResult *result, MF_OBJECT_TYPE *obj_type, IUnknown **out)
|
|
|
|
{
|
|
|
|
struct resolver_queued_result *queued_result = NULL, *iter;
|
|
|
|
IUnknown *object;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if (FAILED(hr = IMFAsyncResult_GetObject(result, &object)))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
EnterCriticalSection(&resolver->cs);
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY(iter, &resolver->pending, struct resolver_queued_result, entry)
|
|
|
|
{
|
|
|
|
if (iter->object == object && iter->origin == origin)
|
|
|
|
{
|
|
|
|
list_remove(&iter->entry);
|
|
|
|
queued_result = iter;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
LeaveCriticalSection(&resolver->cs);
|
|
|
|
|
|
|
|
IUnknown_Release(object);
|
|
|
|
|
|
|
|
if (queued_result)
|
|
|
|
{
|
|
|
|
*out = queued_result->object;
|
|
|
|
*obj_type = queued_result->obj_type;
|
|
|
|
hr = queued_result->hr;
|
|
|
|
heap_free(queued_result);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
hr = E_UNEXPECTED;
|
|
|
|
|
|
|
|
return hr;
|
2017-05-28 13:42:48 +02:00
|
|
|
}
|
|
|
|
|
2019-03-11 11:28:10 +01:00
|
|
|
static HRESULT WINAPI source_resolver_QueryInterface(IMFSourceResolver *iface, REFIID riid, void **obj)
|
2017-05-28 13:42:48 +02:00
|
|
|
{
|
|
|
|
mfsourceresolver *This = impl_from_IMFSourceResolver(iface);
|
|
|
|
|
|
|
|
TRACE("(%p->(%s, %p)\n", This, debugstr_guid(riid), obj);
|
|
|
|
|
|
|
|
if (IsEqualIID(riid, &IID_IMFSourceResolver) ||
|
|
|
|
IsEqualIID(riid, &IID_IUnknown))
|
|
|
|
{
|
|
|
|
*obj = &This->IMFSourceResolver_iface;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*obj = NULL;
|
|
|
|
FIXME("unsupported interface %s\n", debugstr_guid(riid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
IUnknown_AddRef((IUnknown *)*obj);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-03-11 11:28:09 +01:00
|
|
|
static ULONG WINAPI source_resolver_AddRef(IMFSourceResolver *iface)
|
2017-05-28 13:42:48 +02:00
|
|
|
{
|
2019-03-11 11:28:09 +01:00
|
|
|
struct source_resolver *resolver = impl_from_IMFSourceResolver(iface);
|
|
|
|
ULONG refcount = InterlockedIncrement(&resolver->refcount);
|
2017-05-28 13:42:48 +02:00
|
|
|
|
2019-03-11 11:28:09 +01:00
|
|
|
TRACE("%p, refcount %d.\n", iface, refcount);
|
2017-05-28 13:42:48 +02:00
|
|
|
|
2019-03-11 11:28:09 +01:00
|
|
|
return refcount;
|
2017-05-28 13:42:48 +02:00
|
|
|
}
|
|
|
|
|
2019-03-11 11:28:09 +01:00
|
|
|
static ULONG WINAPI source_resolver_Release(IMFSourceResolver *iface)
|
2017-05-28 13:42:48 +02:00
|
|
|
{
|
2019-03-11 11:28:09 +01:00
|
|
|
struct source_resolver *resolver = impl_from_IMFSourceResolver(iface);
|
|
|
|
ULONG refcount = InterlockedDecrement(&resolver->refcount);
|
|
|
|
struct resolver_queued_result *result, *result2;
|
2017-05-28 13:42:48 +02:00
|
|
|
|
2019-03-11 11:28:09 +01:00
|
|
|
TRACE("%p, refcount %d.\n", iface, refcount);
|
2017-05-28 13:42:48 +02:00
|
|
|
|
2019-03-11 11:28:09 +01:00
|
|
|
if (!refcount)
|
|
|
|
{
|
|
|
|
LIST_FOR_EACH_ENTRY_SAFE(result, result2, &resolver->pending, struct resolver_queued_result, entry)
|
|
|
|
{
|
|
|
|
if (result->object)
|
|
|
|
IUnknown_Release(result->object);
|
|
|
|
list_remove(&result->entry);
|
|
|
|
heap_free(result);
|
|
|
|
}
|
|
|
|
DeleteCriticalSection(&resolver->cs);
|
|
|
|
heap_free(resolver);
|
|
|
|
}
|
2017-05-28 13:42:48 +02:00
|
|
|
|
2019-03-11 11:28:09 +01:00
|
|
|
return refcount;
|
2017-05-28 13:42:48 +02:00
|
|
|
}
|
|
|
|
|
2019-03-12 07:07:42 +01:00
|
|
|
static HRESULT WINAPI source_resolver_CreateObjectFromURL(IMFSourceResolver *iface, const WCHAR *url,
|
|
|
|
DWORD flags, IPropertyStore *props, MF_OBJECT_TYPE *obj_type, IUnknown **object)
|
2017-05-28 13:42:48 +02:00
|
|
|
{
|
2019-03-12 07:07:42 +01:00
|
|
|
struct source_resolver *resolver = impl_from_IMFSourceResolver(iface);
|
|
|
|
IMFSchemeHandler *handler;
|
|
|
|
IMFAsyncResult *result;
|
|
|
|
MFASYNCRESULT *data;
|
|
|
|
HRESULT hr;
|
2017-05-28 13:42:48 +02:00
|
|
|
|
2019-03-12 07:07:42 +01:00
|
|
|
TRACE("%p, %s, %#x, %p, %p, %p\n", iface, debugstr_w(url), flags, props, obj_type, object);
|
2017-05-28 13:42:48 +02:00
|
|
|
|
2019-03-12 07:07:42 +01:00
|
|
|
if (!url || !obj_type || !object)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
if (FAILED(hr = resolver_get_scheme_handler(url, flags, &handler)))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
hr = MFCreateAsyncResult((IUnknown *)handler, NULL, NULL, &result);
|
|
|
|
IMFSchemeHandler_Release(handler);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
data = (MFASYNCRESULT *)result;
|
|
|
|
data->hEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
|
|
|
|
|
|
|
|
hr = IMFSchemeHandler_BeginCreateObject(handler, url, flags, props, NULL, &resolver->stream_callback,
|
|
|
|
(IUnknown *)result);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
IMFAsyncResult_Release(result);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
WaitForSingleObject(data->hEvent, INFINITE);
|
|
|
|
|
|
|
|
hr = resolver_end_create_object(resolver, OBJECT_FROM_URL, result, obj_type, object);
|
|
|
|
IMFAsyncResult_Release(result);
|
|
|
|
|
|
|
|
return hr;
|
2017-05-28 13:42:48 +02:00
|
|
|
}
|
|
|
|
|
2019-03-11 11:28:09 +01:00
|
|
|
static HRESULT WINAPI source_resolver_CreateObjectFromByteStream(IMFSourceResolver *iface, IMFByteStream *stream,
|
2017-05-28 13:42:48 +02:00
|
|
|
const WCHAR *url, DWORD flags, IPropertyStore *props, MF_OBJECT_TYPE *obj_type, IUnknown **object)
|
|
|
|
{
|
2019-03-11 11:28:09 +01:00
|
|
|
struct source_resolver *resolver = impl_from_IMFSourceResolver(iface);
|
|
|
|
IMFByteStreamHandler *handler;
|
|
|
|
IMFAsyncResult *result;
|
|
|
|
MFASYNCRESULT *data;
|
|
|
|
HRESULT hr;
|
2017-05-28 13:42:48 +02:00
|
|
|
|
2019-03-11 11:28:09 +01:00
|
|
|
TRACE("%p, %p, %s, %#x, %p, %p, %p.\n", iface, stream, debugstr_w(url), flags, props, obj_type, object);
|
2017-05-28 13:42:48 +02:00
|
|
|
|
2018-11-22 21:00:45 +01:00
|
|
|
if (!stream || !obj_type || !object)
|
|
|
|
return E_POINTER;
|
|
|
|
|
2019-03-11 11:28:09 +01:00
|
|
|
if (FAILED(hr = resolver_get_bytestream_handler(stream, url, flags, &handler)))
|
|
|
|
goto fallback;
|
|
|
|
|
|
|
|
hr = MFCreateAsyncResult((IUnknown *)handler, NULL, NULL, &result);
|
|
|
|
IMFByteStreamHandler_Release(handler);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
data = (MFASYNCRESULT *)result;
|
|
|
|
data->hEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
|
|
|
|
|
|
|
|
hr = IMFByteStreamHandler_BeginCreateObject(handler, stream, url, flags, props, NULL, &resolver->stream_callback,
|
|
|
|
(IUnknown *)result);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
IMFAsyncResult_Release(result);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
WaitForSingleObject(data->hEvent, INFINITE);
|
|
|
|
|
|
|
|
hr = resolver_end_create_object(resolver, OBJECT_FROM_BYTESTREAM, result, obj_type, object);
|
|
|
|
IMFAsyncResult_Release(result);
|
|
|
|
|
|
|
|
/* TODO: following stub is left intentionally until real source plugins are implemented. */
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
fallback:
|
2018-11-22 21:00:45 +01:00
|
|
|
if (flags & MF_RESOLUTION_MEDIASOURCE)
|
|
|
|
{
|
|
|
|
mfsource *new_object;
|
|
|
|
|
2018-11-30 11:19:51 +01:00
|
|
|
new_object = HeapAlloc( GetProcessHeap(), 0, sizeof(*new_object) );
|
2018-11-22 21:00:45 +01:00
|
|
|
if (!new_object)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
new_object->IMFMediaSource_iface.lpVtbl = &mfsourcevtbl;
|
|
|
|
new_object->ref = 1;
|
|
|
|
|
|
|
|
*object = (IUnknown *)&new_object->IMFMediaSource_iface;
|
|
|
|
*obj_type = MF_OBJECT_MEDIASOURCE;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2017-05-28 13:42:48 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-03-12 07:07:43 +01:00
|
|
|
static HRESULT WINAPI source_resolver_BeginCreateObjectFromURL(IMFSourceResolver *iface, const WCHAR *url,
|
|
|
|
DWORD flags, IPropertyStore *props, IUnknown **cancel_cookie, IMFAsyncCallback *callback, IUnknown *state)
|
2017-05-28 13:42:48 +02:00
|
|
|
{
|
2019-03-12 07:07:43 +01:00
|
|
|
struct source_resolver *resolver = impl_from_IMFSourceResolver(iface);
|
|
|
|
IMFSchemeHandler *handler;
|
|
|
|
IUnknown *inner_cookie = NULL;
|
|
|
|
IMFAsyncResult *result;
|
|
|
|
HRESULT hr;
|
2017-05-28 13:42:48 +02:00
|
|
|
|
2019-03-12 07:07:43 +01:00
|
|
|
TRACE("%p, %s, %#x, %p, %p, %p, %p.\n", iface, debugstr_w(url), flags, props, cancel_cookie, callback, state);
|
2017-05-28 13:42:48 +02:00
|
|
|
|
2019-03-12 07:07:43 +01:00
|
|
|
if (FAILED(hr = resolver_get_scheme_handler(url, flags, &handler)))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
if (cancel_cookie)
|
|
|
|
*cancel_cookie = NULL;
|
|
|
|
|
|
|
|
hr = MFCreateAsyncResult((IUnknown *)handler, callback, state, &result);
|
|
|
|
IMFSchemeHandler_Release(handler);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
hr = IMFSchemeHandler_BeginCreateObject(handler, url, flags, props, cancel_cookie ? &inner_cookie : NULL,
|
|
|
|
&resolver->url_callback, (IUnknown *)result);
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr) && inner_cookie)
|
|
|
|
resolver_create_cancel_object((IUnknown *)handler, OBJECT_FROM_URL, inner_cookie, cancel_cookie);
|
|
|
|
|
|
|
|
IMFAsyncResult_Release(result);
|
|
|
|
|
|
|
|
return hr;
|
2017-05-28 13:42:48 +02:00
|
|
|
}
|
|
|
|
|
2019-03-12 07:07:43 +01:00
|
|
|
static HRESULT WINAPI source_resolver_EndCreateObjectFromURL(IMFSourceResolver *iface, IMFAsyncResult *result,
|
|
|
|
MF_OBJECT_TYPE *obj_type, IUnknown **object)
|
2017-05-28 13:42:48 +02:00
|
|
|
{
|
2019-03-12 07:07:43 +01:00
|
|
|
struct source_resolver *resolver = impl_from_IMFSourceResolver(iface);
|
2017-05-28 13:42:48 +02:00
|
|
|
|
2019-03-12 07:07:43 +01:00
|
|
|
TRACE("%p, %p, %p, %p.\n", iface, result, obj_type, object);
|
2017-05-28 13:42:48 +02:00
|
|
|
|
2019-03-12 07:07:43 +01:00
|
|
|
return resolver_end_create_object(resolver, OBJECT_FROM_URL, result, obj_type, object);
|
2017-05-28 13:42:48 +02:00
|
|
|
}
|
|
|
|
|
2019-03-11 11:28:10 +01:00
|
|
|
static HRESULT WINAPI source_resolver_BeginCreateObjectFromByteStream(IMFSourceResolver *iface, IMFByteStream *stream,
|
|
|
|
const WCHAR *url, DWORD flags, IPropertyStore *props, IUnknown **cancel_cookie, IMFAsyncCallback *callback,
|
|
|
|
IUnknown *state)
|
2017-05-28 13:42:48 +02:00
|
|
|
{
|
2019-03-11 11:28:10 +01:00
|
|
|
struct source_resolver *resolver = impl_from_IMFSourceResolver(iface);
|
|
|
|
IMFByteStreamHandler *handler;
|
|
|
|
IUnknown *inner_cookie = NULL;
|
|
|
|
IMFAsyncResult *result;
|
|
|
|
HRESULT hr;
|
2017-05-28 13:42:48 +02:00
|
|
|
|
2019-03-11 11:28:10 +01:00
|
|
|
TRACE("%p, %p, %s, %#x, %p, %p, %p, %p.\n", iface, stream, debugstr_w(url), flags, props, cancel_cookie,
|
|
|
|
callback, state);
|
2017-05-28 13:42:48 +02:00
|
|
|
|
2019-03-11 11:28:10 +01:00
|
|
|
if (FAILED(hr = resolver_get_bytestream_handler(stream, url, flags, &handler)))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
if (cancel_cookie)
|
|
|
|
*cancel_cookie = NULL;
|
|
|
|
|
|
|
|
hr = MFCreateAsyncResult((IUnknown *)handler, callback, state, &result);
|
|
|
|
IMFByteStreamHandler_Release(handler);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
hr = IMFByteStreamHandler_BeginCreateObject(handler, stream, url, flags, props,
|
|
|
|
cancel_cookie ? &inner_cookie : NULL, &resolver->stream_callback, (IUnknown *)result);
|
|
|
|
|
|
|
|
/* Cancel object wraps underlying handler cancel cookie with context necessary to call CancelObjectCreate(). */
|
|
|
|
if (SUCCEEDED(hr) && inner_cookie)
|
|
|
|
resolver_create_cancel_object((IUnknown *)handler, OBJECT_FROM_BYTESTREAM, inner_cookie, cancel_cookie);
|
|
|
|
|
|
|
|
IMFAsyncResult_Release(result);
|
|
|
|
|
|
|
|
return hr;
|
2017-05-28 13:42:48 +02:00
|
|
|
}
|
|
|
|
|
2019-03-11 11:28:10 +01:00
|
|
|
static HRESULT WINAPI source_resolver_EndCreateObjectFromByteStream(IMFSourceResolver *iface, IMFAsyncResult *result,
|
|
|
|
MF_OBJECT_TYPE *obj_type, IUnknown **object)
|
2017-05-28 13:42:48 +02:00
|
|
|
{
|
2019-03-11 11:28:10 +01:00
|
|
|
struct source_resolver *resolver = impl_from_IMFSourceResolver(iface);
|
2017-05-28 13:42:48 +02:00
|
|
|
|
2019-03-11 11:28:10 +01:00
|
|
|
TRACE("%p, %p, %p, %p.\n", iface, result, obj_type, object);
|
2017-05-28 13:42:48 +02:00
|
|
|
|
2019-03-11 11:28:10 +01:00
|
|
|
return resolver_end_create_object(resolver, OBJECT_FROM_BYTESTREAM, result, obj_type, object);
|
2017-05-28 13:42:48 +02:00
|
|
|
}
|
|
|
|
|
2019-03-11 11:28:10 +01:00
|
|
|
static HRESULT WINAPI source_resolver_CancelObjectCreation(IMFSourceResolver *iface, IUnknown *cancel_cookie)
|
2017-05-28 13:42:48 +02:00
|
|
|
{
|
2019-03-11 11:28:10 +01:00
|
|
|
struct resolver_cancel_object *object;
|
|
|
|
HRESULT hr;
|
2017-05-28 13:42:48 +02:00
|
|
|
|
2019-03-11 11:28:10 +01:00
|
|
|
TRACE("%p, %p.\n", iface, cancel_cookie);
|
2017-05-28 13:42:48 +02:00
|
|
|
|
2019-03-11 11:28:10 +01:00
|
|
|
if (!(object = unsafe_impl_cancel_obj_from_IUnknown(cancel_cookie)))
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
|
|
|
|
switch (object->origin)
|
|
|
|
{
|
|
|
|
case OBJECT_FROM_BYTESTREAM:
|
|
|
|
hr = IMFByteStreamHandler_CancelObjectCreation(object->u.stream_handler, object->cancel_cookie);
|
|
|
|
break;
|
2019-03-12 07:07:43 +01:00
|
|
|
case OBJECT_FROM_URL:
|
|
|
|
hr = IMFSchemeHandler_CancelObjectCreation(object->u.scheme_handler, object->cancel_cookie);
|
|
|
|
break;
|
2019-03-11 11:28:10 +01:00
|
|
|
default:
|
|
|
|
hr = E_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
2017-05-28 13:42:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const IMFSourceResolverVtbl mfsourceresolvervtbl =
|
|
|
|
{
|
2019-03-11 11:28:10 +01:00
|
|
|
source_resolver_QueryInterface,
|
|
|
|
source_resolver_AddRef,
|
|
|
|
source_resolver_Release,
|
2019-03-12 07:07:42 +01:00
|
|
|
source_resolver_CreateObjectFromURL,
|
2019-03-11 11:28:10 +01:00
|
|
|
source_resolver_CreateObjectFromByteStream,
|
2019-03-12 07:07:43 +01:00
|
|
|
source_resolver_BeginCreateObjectFromURL,
|
|
|
|
source_resolver_EndCreateObjectFromURL,
|
2019-03-11 11:28:10 +01:00
|
|
|
source_resolver_BeginCreateObjectFromByteStream,
|
|
|
|
source_resolver_EndCreateObjectFromByteStream,
|
|
|
|
source_resolver_CancelObjectCreation,
|
2017-05-28 13:42:48 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MFCreateSourceResolver (mfplat.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI MFCreateSourceResolver(IMFSourceResolver **resolver)
|
|
|
|
{
|
2019-03-11 11:28:09 +01:00
|
|
|
struct source_resolver *object;
|
2017-05-28 13:42:48 +02:00
|
|
|
|
|
|
|
TRACE("%p\n", resolver);
|
|
|
|
|
|
|
|
if (!resolver)
|
|
|
|
return E_POINTER;
|
|
|
|
|
2019-03-11 11:28:09 +01:00
|
|
|
object = heap_alloc_zero(sizeof(*object));
|
2017-05-28 13:42:48 +02:00
|
|
|
if (!object)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
object->IMFSourceResolver_iface.lpVtbl = &mfsourceresolvervtbl;
|
2019-03-11 11:28:09 +01:00
|
|
|
object->stream_callback.lpVtbl = &source_resolver_callback_stream_vtbl;
|
2019-03-12 07:07:42 +01:00
|
|
|
object->url_callback.lpVtbl = &source_resolver_callback_url_vtbl;
|
2019-03-11 11:28:09 +01:00
|
|
|
object->refcount = 1;
|
|
|
|
list_init(&object->pending);
|
|
|
|
InitializeCriticalSection(&object->cs);
|
2017-05-28 13:42:48 +02:00
|
|
|
|
|
|
|
*resolver = &object->IMFSourceResolver_iface;
|
2019-03-11 11:28:09 +01:00
|
|
|
|
2017-05-28 13:42:48 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
2017-06-27 03:46:28 +02:00
|
|
|
|
2019-03-11 11:28:05 +01:00
|
|
|
typedef struct media_event
|
2018-11-13 23:20:45 +01:00
|
|
|
{
|
|
|
|
mfattributes attributes;
|
|
|
|
IMFMediaEvent IMFMediaEvent_iface;
|
|
|
|
|
|
|
|
MediaEventType type;
|
|
|
|
GUID extended_type;
|
|
|
|
HRESULT status;
|
|
|
|
PROPVARIANT value;
|
|
|
|
} mfmediaevent;
|
|
|
|
|
|
|
|
static inline mfmediaevent *impl_from_IMFMediaEvent(IMFMediaEvent *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, mfmediaevent, IMFMediaEvent_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfmediaevent_QueryInterface(IMFMediaEvent *iface, REFIID riid, void **out)
|
|
|
|
{
|
|
|
|
mfmediaevent *This = impl_from_IMFMediaEvent(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), out);
|
|
|
|
|
|
|
|
if(IsEqualGUID(riid, &IID_IUnknown) ||
|
|
|
|
IsEqualGUID(riid, &IID_IMFAttributes) ||
|
|
|
|
IsEqualGUID(riid, &IID_IMFMediaEvent))
|
|
|
|
{
|
|
|
|
*out = &This->IMFMediaEvent_iface;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("(%s, %p)\n", debugstr_guid(riid), out);
|
|
|
|
*out = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
IUnknown_AddRef((IUnknown*)*out);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI mfmediaevent_AddRef(IMFMediaEvent *iface)
|
|
|
|
{
|
|
|
|
mfmediaevent *This = impl_from_IMFMediaEvent(iface);
|
|
|
|
ULONG ref = InterlockedIncrement(&This->attributes.ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%u\n", This, ref);
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI mfmediaevent_Release(IMFMediaEvent *iface)
|
|
|
|
{
|
2019-03-11 11:28:05 +01:00
|
|
|
struct media_event *event = impl_from_IMFMediaEvent(iface);
|
|
|
|
ULONG ref = InterlockedDecrement(&event->attributes.ref);
|
2018-11-13 23:20:45 +01:00
|
|
|
|
2019-03-11 11:28:05 +01:00
|
|
|
TRACE("(%p) ref=%u\n", iface, ref);
|
2018-11-13 23:20:45 +01:00
|
|
|
|
|
|
|
if (!ref)
|
|
|
|
{
|
2019-03-14 09:03:07 +01:00
|
|
|
clear_attributes_object(&event->attributes);
|
2019-03-11 11:28:05 +01:00
|
|
|
PropVariantClear(&event->value);
|
|
|
|
heap_free(event);
|
2018-11-13 23:20:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfmediaevent_GetItem(IMFMediaEvent *iface, REFGUID key, PROPVARIANT *value)
|
|
|
|
{
|
|
|
|
mfmediaevent *This = impl_from_IMFMediaEvent(iface);
|
|
|
|
return IMFAttributes_GetItem(&This->attributes.IMFAttributes_iface, key, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfmediaevent_GetItemType(IMFMediaEvent *iface, REFGUID key, MF_ATTRIBUTE_TYPE *type)
|
|
|
|
{
|
|
|
|
mfmediaevent *This = impl_from_IMFMediaEvent(iface);
|
|
|
|
return IMFAttributes_GetItemType(&This->attributes.IMFAttributes_iface, key, type);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfmediaevent_CompareItem(IMFMediaEvent *iface, REFGUID key, REFPROPVARIANT value, BOOL *result)
|
|
|
|
{
|
|
|
|
mfmediaevent *This = impl_from_IMFMediaEvent(iface);
|
|
|
|
return IMFAttributes_CompareItem(&This->attributes.IMFAttributes_iface, key, value, result);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfmediaevent_Compare(IMFMediaEvent *iface, IMFAttributes *attrs, MF_ATTRIBUTES_MATCH_TYPE type,
|
|
|
|
BOOL *result)
|
|
|
|
{
|
|
|
|
mfmediaevent *This = impl_from_IMFMediaEvent(iface);
|
|
|
|
return IMFAttributes_Compare(&This->attributes.IMFAttributes_iface, attrs, type, result);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfmediaevent_GetUINT32(IMFMediaEvent *iface, REFGUID key, UINT32 *value)
|
|
|
|
{
|
|
|
|
mfmediaevent *This = impl_from_IMFMediaEvent(iface);
|
|
|
|
return IMFAttributes_GetUINT32(&This->attributes.IMFAttributes_iface, key, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfmediaevent_GetUINT64(IMFMediaEvent *iface, REFGUID key, UINT64 *value)
|
|
|
|
{
|
|
|
|
mfmediaevent *This = impl_from_IMFMediaEvent(iface);
|
|
|
|
return IMFAttributes_GetUINT64(&This->attributes.IMFAttributes_iface, key, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfmediaevent_GetDouble(IMFMediaEvent *iface, REFGUID key, double *value)
|
|
|
|
{
|
|
|
|
mfmediaevent *This = impl_from_IMFMediaEvent(iface);
|
|
|
|
return IMFAttributes_GetDouble(&This->attributes.IMFAttributes_iface, key, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfmediaevent_GetGUID(IMFMediaEvent *iface, REFGUID key, GUID *value)
|
|
|
|
{
|
|
|
|
mfmediaevent *This = impl_from_IMFMediaEvent(iface);
|
|
|
|
return IMFAttributes_GetGUID(&This->attributes.IMFAttributes_iface, key, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfmediaevent_GetStringLength(IMFMediaEvent *iface, REFGUID key, UINT32 *length)
|
|
|
|
{
|
|
|
|
mfmediaevent *This = impl_from_IMFMediaEvent(iface);
|
|
|
|
return IMFAttributes_GetStringLength(&This->attributes.IMFAttributes_iface, key, length);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfmediaevent_GetString(IMFMediaEvent *iface, REFGUID key, WCHAR *value,
|
|
|
|
UINT32 size, UINT32 *length)
|
|
|
|
{
|
|
|
|
mfmediaevent *This = impl_from_IMFMediaEvent(iface);
|
|
|
|
return IMFAttributes_GetString(&This->attributes.IMFAttributes_iface, key, value, size, length);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfmediaevent_GetAllocatedString(IMFMediaEvent *iface, REFGUID key,
|
|
|
|
WCHAR **value, UINT32 *length)
|
|
|
|
{
|
|
|
|
mfmediaevent *This = impl_from_IMFMediaEvent(iface);
|
|
|
|
return IMFAttributes_GetAllocatedString(&This->attributes.IMFAttributes_iface, key, value, length);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfmediaevent_GetBlobSize(IMFMediaEvent *iface, REFGUID key, UINT32 *size)
|
|
|
|
{
|
|
|
|
mfmediaevent *This = impl_from_IMFMediaEvent(iface);
|
|
|
|
return IMFAttributes_GetBlobSize(&This->attributes.IMFAttributes_iface, key, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfmediaevent_GetBlob(IMFMediaEvent *iface, REFGUID key, UINT8 *buf,
|
|
|
|
UINT32 bufsize, UINT32 *blobsize)
|
|
|
|
{
|
|
|
|
mfmediaevent *This = impl_from_IMFMediaEvent(iface);
|
|
|
|
return IMFAttributes_GetBlob(&This->attributes.IMFAttributes_iface, key, buf, bufsize, blobsize);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfmediaevent_GetAllocatedBlob(IMFMediaEvent *iface, REFGUID key, UINT8 **buf, UINT32 *size)
|
|
|
|
{
|
|
|
|
mfmediaevent *This = impl_from_IMFMediaEvent(iface);
|
|
|
|
return IMFAttributes_GetAllocatedBlob(&This->attributes.IMFAttributes_iface, key, buf, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfmediaevent_GetUnknown(IMFMediaEvent *iface, REFGUID key, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
mfmediaevent *This = impl_from_IMFMediaEvent(iface);
|
|
|
|
return IMFAttributes_GetUnknown(&This->attributes.IMFAttributes_iface, key, riid, ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfmediaevent_SetItem(IMFMediaEvent *iface, REFGUID key, REFPROPVARIANT value)
|
|
|
|
{
|
|
|
|
mfmediaevent *This = impl_from_IMFMediaEvent(iface);
|
|
|
|
return IMFAttributes_SetItem(&This->attributes.IMFAttributes_iface, key, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfmediaevent_DeleteItem(IMFMediaEvent *iface, REFGUID key)
|
|
|
|
{
|
|
|
|
mfmediaevent *This = impl_from_IMFMediaEvent(iface);
|
|
|
|
return IMFAttributes_DeleteItem(&This->attributes.IMFAttributes_iface, key);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfmediaevent_DeleteAllItems(IMFMediaEvent *iface)
|
|
|
|
{
|
|
|
|
mfmediaevent *This = impl_from_IMFMediaEvent(iface);
|
|
|
|
return IMFAttributes_DeleteAllItems(&This->attributes.IMFAttributes_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfmediaevent_SetUINT32(IMFMediaEvent *iface, REFGUID key, UINT32 value)
|
|
|
|
{
|
|
|
|
mfmediaevent *This = impl_from_IMFMediaEvent(iface);
|
|
|
|
return IMFAttributes_SetUINT32(&This->attributes.IMFAttributes_iface, key, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfmediaevent_SetUINT64(IMFMediaEvent *iface, REFGUID key, UINT64 value)
|
|
|
|
{
|
|
|
|
mfmediaevent *This = impl_from_IMFMediaEvent(iface);
|
|
|
|
return IMFAttributes_SetUINT64(&This->attributes.IMFAttributes_iface, key, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfmediaevent_SetDouble(IMFMediaEvent *iface, REFGUID key, double value)
|
|
|
|
{
|
|
|
|
mfmediaevent *This = impl_from_IMFMediaEvent(iface);
|
|
|
|
return IMFAttributes_SetDouble(&This->attributes.IMFAttributes_iface, key, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfmediaevent_SetGUID(IMFMediaEvent *iface, REFGUID key, REFGUID value)
|
|
|
|
{
|
|
|
|
mfmediaevent *This = impl_from_IMFMediaEvent(iface);
|
|
|
|
return IMFAttributes_SetGUID(&This->attributes.IMFAttributes_iface, key, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfmediaevent_SetString(IMFMediaEvent *iface, REFGUID key, const WCHAR *value)
|
|
|
|
{
|
|
|
|
mfmediaevent *This = impl_from_IMFMediaEvent(iface);
|
|
|
|
return IMFAttributes_SetString(&This->attributes.IMFAttributes_iface, key, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfmediaevent_SetBlob(IMFMediaEvent *iface, REFGUID key, const UINT8 *buf, UINT32 size)
|
|
|
|
{
|
|
|
|
mfmediaevent *This = impl_from_IMFMediaEvent(iface);
|
|
|
|
return IMFAttributes_SetBlob(&This->attributes.IMFAttributes_iface, key, buf, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfmediaevent_SetUnknown(IMFMediaEvent *iface, REFGUID key, IUnknown *unknown)
|
|
|
|
{
|
|
|
|
mfmediaevent *This = impl_from_IMFMediaEvent(iface);
|
|
|
|
return IMFAttributes_SetUnknown(&This->attributes.IMFAttributes_iface, key, unknown);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfmediaevent_LockStore(IMFMediaEvent *iface)
|
|
|
|
{
|
|
|
|
mfmediaevent *This = impl_from_IMFMediaEvent(iface);
|
|
|
|
return IMFAttributes_LockStore(&This->attributes.IMFAttributes_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfmediaevent_UnlockStore(IMFMediaEvent *iface)
|
|
|
|
{
|
|
|
|
mfmediaevent *This = impl_from_IMFMediaEvent(iface);
|
|
|
|
return IMFAttributes_UnlockStore(&This->attributes.IMFAttributes_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfmediaevent_GetCount(IMFMediaEvent *iface, UINT32 *items)
|
|
|
|
{
|
|
|
|
mfmediaevent *This = impl_from_IMFMediaEvent(iface);
|
|
|
|
return IMFAttributes_GetCount(&This->attributes.IMFAttributes_iface, items);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfmediaevent_GetItemByIndex(IMFMediaEvent *iface, UINT32 index, GUID *key, PROPVARIANT *value)
|
|
|
|
{
|
|
|
|
mfmediaevent *This = impl_from_IMFMediaEvent(iface);
|
|
|
|
return IMFAttributes_GetItemByIndex(&This->attributes.IMFAttributes_iface, index, key, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfmediaevent_CopyAllItems(IMFMediaEvent *iface, IMFAttributes *dest)
|
|
|
|
{
|
2019-03-13 07:29:36 +01:00
|
|
|
struct media_event *event = impl_from_IMFMediaEvent(iface);
|
|
|
|
return IMFAttributes_CopyAllItems(&event->attributes.IMFAttributes_iface, dest);
|
2018-11-13 23:20:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfmediaevent_GetType(IMFMediaEvent *iface, MediaEventType *type)
|
|
|
|
{
|
|
|
|
mfmediaevent *This = impl_from_IMFMediaEvent(iface);
|
|
|
|
|
|
|
|
TRACE("%p, %p\n", This, type);
|
|
|
|
|
|
|
|
*type = This->type;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfmediaevent_GetExtendedType(IMFMediaEvent *iface, GUID *extended_type)
|
|
|
|
{
|
|
|
|
mfmediaevent *This = impl_from_IMFMediaEvent(iface);
|
|
|
|
|
|
|
|
TRACE("%p, %p\n", This, extended_type);
|
|
|
|
|
|
|
|
*extended_type = This->extended_type;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfmediaevent_GetStatus(IMFMediaEvent *iface, HRESULT *status)
|
|
|
|
{
|
|
|
|
mfmediaevent *This = impl_from_IMFMediaEvent(iface);
|
|
|
|
|
|
|
|
TRACE("%p, %p\n", This, status);
|
|
|
|
|
|
|
|
*status = This->status;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mfmediaevent_GetValue(IMFMediaEvent *iface, PROPVARIANT *value)
|
|
|
|
{
|
|
|
|
mfmediaevent *This = impl_from_IMFMediaEvent(iface);
|
|
|
|
|
|
|
|
PropVariantCopy(value, &This->value);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IMFMediaEventVtbl mfmediaevent_vtbl =
|
|
|
|
{
|
|
|
|
mfmediaevent_QueryInterface,
|
|
|
|
mfmediaevent_AddRef,
|
|
|
|
mfmediaevent_Release,
|
|
|
|
mfmediaevent_GetItem,
|
|
|
|
mfmediaevent_GetItemType,
|
|
|
|
mfmediaevent_CompareItem,
|
|
|
|
mfmediaevent_Compare,
|
|
|
|
mfmediaevent_GetUINT32,
|
|
|
|
mfmediaevent_GetUINT64,
|
|
|
|
mfmediaevent_GetDouble,
|
|
|
|
mfmediaevent_GetGUID,
|
|
|
|
mfmediaevent_GetStringLength,
|
|
|
|
mfmediaevent_GetString,
|
|
|
|
mfmediaevent_GetAllocatedString,
|
|
|
|
mfmediaevent_GetBlobSize,
|
|
|
|
mfmediaevent_GetBlob,
|
|
|
|
mfmediaevent_GetAllocatedBlob,
|
|
|
|
mfmediaevent_GetUnknown,
|
|
|
|
mfmediaevent_SetItem,
|
|
|
|
mfmediaevent_DeleteItem,
|
|
|
|
mfmediaevent_DeleteAllItems,
|
|
|
|
mfmediaevent_SetUINT32,
|
|
|
|
mfmediaevent_SetUINT64,
|
|
|
|
mfmediaevent_SetDouble,
|
|
|
|
mfmediaevent_SetGUID,
|
|
|
|
mfmediaevent_SetString,
|
|
|
|
mfmediaevent_SetBlob,
|
|
|
|
mfmediaevent_SetUnknown,
|
|
|
|
mfmediaevent_LockStore,
|
|
|
|
mfmediaevent_UnlockStore,
|
|
|
|
mfmediaevent_GetCount,
|
|
|
|
mfmediaevent_GetItemByIndex,
|
|
|
|
mfmediaevent_CopyAllItems,
|
|
|
|
mfmediaevent_GetType,
|
|
|
|
mfmediaevent_GetExtendedType,
|
|
|
|
mfmediaevent_GetStatus,
|
|
|
|
mfmediaevent_GetValue,
|
|
|
|
};
|
|
|
|
|
2019-03-04 11:33:43 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* MFCreateMediaEvent (mfplat.@)
|
|
|
|
*/
|
2018-11-13 23:20:45 +01:00
|
|
|
HRESULT WINAPI MFCreateMediaEvent(MediaEventType type, REFGUID extended_type, HRESULT status,
|
|
|
|
const PROPVARIANT *value, IMFMediaEvent **event)
|
|
|
|
{
|
|
|
|
mfmediaevent *object;
|
2019-03-14 09:03:07 +01:00
|
|
|
HRESULT hr;
|
2018-11-13 23:20:45 +01:00
|
|
|
|
|
|
|
TRACE("%#x, %s, %08x, %p, %p\n", type, debugstr_guid(extended_type), status, value, event);
|
|
|
|
|
|
|
|
object = HeapAlloc( GetProcessHeap(), 0, sizeof(*object) );
|
|
|
|
if(!object)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2019-03-14 09:03:07 +01:00
|
|
|
if (FAILED(hr = init_attributes_object(&object->attributes, 0)))
|
|
|
|
{
|
|
|
|
heap_free(object);
|
|
|
|
return hr;
|
|
|
|
}
|
2018-11-13 23:20:45 +01:00
|
|
|
object->IMFMediaEvent_iface.lpVtbl = &mfmediaevent_vtbl;
|
|
|
|
|
|
|
|
object->type = type;
|
|
|
|
object->extended_type = *extended_type;
|
|
|
|
object->status = status;
|
|
|
|
|
|
|
|
PropVariantInit(&object->value);
|
|
|
|
if (value)
|
|
|
|
PropVariantCopy(&object->value, value);
|
|
|
|
|
|
|
|
*event = &object->IMFMediaEvent_iface;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-03-04 11:33:43 +01:00
|
|
|
struct event_queue
|
2017-09-08 13:00:20 +02:00
|
|
|
{
|
|
|
|
IMFMediaEventQueue IMFMediaEventQueue_iface;
|
2019-03-04 11:33:43 +01:00
|
|
|
LONG refcount;
|
|
|
|
|
|
|
|
CRITICAL_SECTION cs;
|
|
|
|
CONDITION_VARIABLE update_event;
|
|
|
|
struct list events;
|
|
|
|
BOOL is_shut_down;
|
|
|
|
IMFAsyncResult *subscriber;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct queued_event
|
|
|
|
{
|
|
|
|
struct list entry;
|
|
|
|
IMFMediaEvent *event;
|
|
|
|
};
|
2017-09-08 13:00:20 +02:00
|
|
|
|
2019-03-04 11:33:43 +01:00
|
|
|
static inline struct event_queue *impl_from_IMFMediaEventQueue(IMFMediaEventQueue *iface)
|
2017-09-08 13:00:20 +02:00
|
|
|
{
|
2019-03-04 11:33:43 +01:00
|
|
|
return CONTAINING_RECORD(iface, struct event_queue, IMFMediaEventQueue_iface);
|
2017-09-08 13:00:20 +02:00
|
|
|
}
|
|
|
|
|
2019-03-04 11:33:43 +01:00
|
|
|
static IMFMediaEvent *queue_pop_event(struct event_queue *queue)
|
2017-09-08 13:00:20 +02:00
|
|
|
{
|
2019-03-04 11:33:43 +01:00
|
|
|
struct list *head = list_head(&queue->events);
|
|
|
|
struct queued_event *queued_event;
|
|
|
|
IMFMediaEvent *event;
|
2017-09-08 13:00:20 +02:00
|
|
|
|
2019-03-04 11:33:43 +01:00
|
|
|
if (!head)
|
|
|
|
return NULL;
|
2017-09-08 13:00:20 +02:00
|
|
|
|
2019-03-04 11:33:43 +01:00
|
|
|
queued_event = LIST_ENTRY(head, struct queued_event, entry);
|
|
|
|
event = queued_event->event;
|
|
|
|
list_remove(&queued_event->entry);
|
|
|
|
heap_free(queued_event);
|
|
|
|
return event;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void event_queue_cleanup(struct event_queue *queue)
|
|
|
|
{
|
|
|
|
IMFMediaEvent *event;
|
|
|
|
|
|
|
|
while ((event = queue_pop_event(queue)))
|
|
|
|
IMFMediaEvent_Release(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI eventqueue_QueryInterface(IMFMediaEventQueue *iface, REFIID riid, void **out)
|
|
|
|
{
|
|
|
|
struct event_queue *queue = impl_from_IMFMediaEventQueue(iface);
|
|
|
|
|
|
|
|
TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), out);
|
|
|
|
|
|
|
|
if (IsEqualIID(riid, &IID_IMFMediaEventQueue) ||
|
|
|
|
IsEqualIID(riid, &IID_IUnknown))
|
2017-09-08 13:00:20 +02:00
|
|
|
{
|
2019-03-04 11:33:43 +01:00
|
|
|
*out = &queue->IMFMediaEventQueue_iface;
|
|
|
|
IMFMediaEventQueue_AddRef(iface);
|
|
|
|
return S_OK;
|
2017-09-08 13:00:20 +02:00
|
|
|
}
|
|
|
|
|
2019-03-04 11:33:43 +01:00
|
|
|
WARN("Unsupported %s.\n", debugstr_guid(riid));
|
|
|
|
*out = NULL;
|
|
|
|
return E_NOINTERFACE;
|
2017-09-08 13:00:20 +02:00
|
|
|
}
|
|
|
|
|
2019-03-04 11:33:43 +01:00
|
|
|
static ULONG WINAPI eventqueue_AddRef(IMFMediaEventQueue *iface)
|
2017-09-08 13:00:20 +02:00
|
|
|
{
|
2019-03-04 11:33:43 +01:00
|
|
|
struct event_queue *queue = impl_from_IMFMediaEventQueue(iface);
|
|
|
|
ULONG refcount = InterlockedIncrement(&queue->refcount);
|
2017-09-08 13:00:20 +02:00
|
|
|
|
2019-03-04 11:33:43 +01:00
|
|
|
TRACE("%p, refcount %u.\n", iface, refcount);
|
2017-09-08 13:00:20 +02:00
|
|
|
|
2019-03-04 11:33:43 +01:00
|
|
|
return refcount;
|
2017-09-08 13:00:20 +02:00
|
|
|
}
|
|
|
|
|
2019-03-04 11:33:43 +01:00
|
|
|
static ULONG WINAPI eventqueue_Release(IMFMediaEventQueue *iface)
|
2017-09-08 13:00:20 +02:00
|
|
|
{
|
2019-03-04 11:33:43 +01:00
|
|
|
struct event_queue *queue = impl_from_IMFMediaEventQueue(iface);
|
|
|
|
ULONG refcount = InterlockedDecrement(&queue->refcount);
|
2017-09-08 13:00:20 +02:00
|
|
|
|
2019-03-04 11:33:43 +01:00
|
|
|
TRACE("%p, refcount %u.\n", queue, refcount);
|
2017-09-08 13:00:20 +02:00
|
|
|
|
2019-03-04 11:33:43 +01:00
|
|
|
if (!refcount)
|
2017-09-08 13:00:20 +02:00
|
|
|
{
|
2019-03-04 11:33:43 +01:00
|
|
|
event_queue_cleanup(queue);
|
|
|
|
DeleteCriticalSection(&queue->cs);
|
|
|
|
heap_free(queue);
|
2017-09-08 13:00:20 +02:00
|
|
|
}
|
|
|
|
|
2019-03-04 11:33:43 +01:00
|
|
|
return refcount;
|
2017-09-08 13:00:20 +02:00
|
|
|
}
|
|
|
|
|
2019-03-04 11:33:43 +01:00
|
|
|
static HRESULT WINAPI eventqueue_GetEvent(IMFMediaEventQueue *iface, DWORD flags, IMFMediaEvent **event)
|
2017-09-08 13:00:20 +02:00
|
|
|
{
|
2019-03-04 11:33:43 +01:00
|
|
|
struct event_queue *queue = impl_from_IMFMediaEventQueue(iface);
|
|
|
|
HRESULT hr = S_OK;
|
2017-09-08 13:00:20 +02:00
|
|
|
|
2019-03-04 11:33:43 +01:00
|
|
|
TRACE("%p, %p.\n", iface, event);
|
2017-09-08 13:00:20 +02:00
|
|
|
|
2019-03-04 11:33:43 +01:00
|
|
|
EnterCriticalSection(&queue->cs);
|
|
|
|
|
|
|
|
if (queue->is_shut_down)
|
|
|
|
hr = MF_E_SHUTDOWN;
|
|
|
|
else if (queue->subscriber)
|
|
|
|
hr = MF_E_MULTIPLE_SUBSCRIBERS;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (flags & MF_EVENT_FLAG_NO_WAIT)
|
|
|
|
{
|
|
|
|
if (!(*event = queue_pop_event(queue)))
|
|
|
|
hr = MF_E_NO_EVENTS_AVAILABLE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
while (list_empty(&queue->events) && !queue->is_shut_down)
|
|
|
|
{
|
|
|
|
SleepConditionVariableCS(&queue->update_event, &queue->cs, INFINITE);
|
|
|
|
}
|
|
|
|
*event = queue_pop_event(queue);
|
|
|
|
if (queue->is_shut_down)
|
|
|
|
hr = MF_E_SHUTDOWN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
LeaveCriticalSection(&queue->cs);
|
|
|
|
|
|
|
|
return hr;
|
2017-09-08 13:00:20 +02:00
|
|
|
}
|
|
|
|
|
2019-03-04 11:33:43 +01:00
|
|
|
static void queue_notify_subscriber(struct event_queue *queue)
|
2017-09-08 13:00:20 +02:00
|
|
|
{
|
2019-03-04 11:33:43 +01:00
|
|
|
if (list_empty(&queue->events) || !queue->subscriber)
|
|
|
|
return;
|
2017-09-08 13:00:20 +02:00
|
|
|
|
2019-03-04 11:33:43 +01:00
|
|
|
MFPutWorkItemEx(MFASYNC_CALLBACK_QUEUE_STANDARD, queue->subscriber);
|
|
|
|
}
|
2017-09-08 13:00:20 +02:00
|
|
|
|
2019-03-04 11:33:43 +01:00
|
|
|
static HRESULT WINAPI eventqueue_BeginGetEvent(IMFMediaEventQueue *iface, IMFAsyncCallback *callback, IUnknown *state)
|
|
|
|
{
|
|
|
|
struct event_queue *queue = impl_from_IMFMediaEventQueue(iface);
|
|
|
|
MFASYNCRESULT *result_data = (MFASYNCRESULT *)queue->subscriber;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("%p, %p, %p.\n", iface, callback, state);
|
|
|
|
|
|
|
|
if (!callback)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
EnterCriticalSection(&queue->cs);
|
|
|
|
|
|
|
|
if (queue->is_shut_down)
|
|
|
|
hr = MF_E_SHUTDOWN;
|
|
|
|
else if (result_data)
|
|
|
|
{
|
|
|
|
if (result_data->pCallback == callback)
|
|
|
|
hr = IMFAsyncResult_GetStateNoAddRef(queue->subscriber) == state ?
|
|
|
|
MF_S_MULTIPLE_BEGIN : MF_E_MULTIPLE_BEGIN;
|
|
|
|
else
|
|
|
|
hr = MF_E_MULTIPLE_SUBSCRIBERS;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hr = MFCreateAsyncResult(NULL, callback, state, &queue->subscriber);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
queue_notify_subscriber(queue);
|
|
|
|
}
|
|
|
|
|
|
|
|
LeaveCriticalSection(&queue->cs);
|
|
|
|
|
|
|
|
return hr;
|
2017-09-08 13:00:20 +02:00
|
|
|
}
|
|
|
|
|
2019-03-04 11:33:43 +01:00
|
|
|
static HRESULT WINAPI eventqueue_EndGetEvent(IMFMediaEventQueue *iface, IMFAsyncResult *result, IMFMediaEvent **event)
|
2017-09-08 13:00:20 +02:00
|
|
|
{
|
2019-03-04 11:33:43 +01:00
|
|
|
struct event_queue *queue = impl_from_IMFMediaEventQueue(iface);
|
|
|
|
HRESULT hr = E_FAIL;
|
2017-09-08 13:00:20 +02:00
|
|
|
|
2019-03-04 11:33:43 +01:00
|
|
|
TRACE("%p, %p, %p.\n", iface, result, event);
|
2017-09-08 13:00:20 +02:00
|
|
|
|
2019-03-04 11:33:43 +01:00
|
|
|
EnterCriticalSection(&queue->cs);
|
|
|
|
|
|
|
|
if (queue->is_shut_down)
|
|
|
|
hr = MF_E_SHUTDOWN;
|
|
|
|
else if (queue->subscriber == result)
|
|
|
|
{
|
|
|
|
*event = queue_pop_event(queue);
|
|
|
|
if (queue->subscriber)
|
|
|
|
IMFAsyncResult_Release(queue->subscriber);
|
|
|
|
queue->subscriber = NULL;
|
|
|
|
hr = *event ? S_OK : E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
LeaveCriticalSection(&queue->cs);
|
|
|
|
|
|
|
|
return hr;
|
2017-09-08 13:00:20 +02:00
|
|
|
}
|
|
|
|
|
2019-03-04 11:33:43 +01:00
|
|
|
static HRESULT eventqueue_queue_event(struct event_queue *queue, IMFMediaEvent *event)
|
2017-09-08 13:00:20 +02:00
|
|
|
{
|
2019-03-04 11:33:43 +01:00
|
|
|
struct queued_event *queued_event;
|
|
|
|
HRESULT hr = S_OK;
|
2017-09-08 13:00:20 +02:00
|
|
|
|
2019-03-04 11:33:43 +01:00
|
|
|
queued_event = heap_alloc(sizeof(*queued_event));
|
|
|
|
if (!queued_event)
|
|
|
|
return E_OUTOFMEMORY;
|
2017-09-08 13:00:20 +02:00
|
|
|
|
2019-03-04 11:33:43 +01:00
|
|
|
queued_event->event = event;
|
|
|
|
|
|
|
|
EnterCriticalSection(&queue->cs);
|
|
|
|
|
|
|
|
if (queue->is_shut_down)
|
|
|
|
hr = MF_E_SHUTDOWN;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
IMFMediaEvent_AddRef(queued_event->event);
|
|
|
|
list_add_tail(&queue->events, &queued_event->entry);
|
|
|
|
queue_notify_subscriber(queue);
|
|
|
|
}
|
|
|
|
|
|
|
|
LeaveCriticalSection(&queue->cs);
|
|
|
|
|
|
|
|
if (FAILED(hr))
|
|
|
|
heap_free(queued_event);
|
|
|
|
|
|
|
|
WakeAllConditionVariable(&queue->update_event);
|
|
|
|
|
|
|
|
return hr;
|
2017-09-08 13:00:20 +02:00
|
|
|
}
|
|
|
|
|
2019-03-04 11:33:43 +01:00
|
|
|
static HRESULT WINAPI eventqueue_QueueEvent(IMFMediaEventQueue *iface, IMFMediaEvent *event)
|
2017-09-08 13:00:20 +02:00
|
|
|
{
|
2019-03-04 11:33:43 +01:00
|
|
|
struct event_queue *queue = impl_from_IMFMediaEventQueue(iface);
|
2017-09-08 13:00:20 +02:00
|
|
|
|
2019-03-04 11:33:43 +01:00
|
|
|
TRACE("%p, %p.\n", iface, event);
|
2017-09-08 13:00:20 +02:00
|
|
|
|
2019-03-04 11:33:43 +01:00
|
|
|
return eventqueue_queue_event(queue, event);
|
2017-09-08 13:00:20 +02:00
|
|
|
}
|
|
|
|
|
2019-03-04 11:33:43 +01:00
|
|
|
static HRESULT WINAPI eventqueue_QueueEventParamVar(IMFMediaEventQueue *iface, MediaEventType event_type,
|
|
|
|
REFGUID extended_type, HRESULT status, const PROPVARIANT *value)
|
2017-09-08 13:00:20 +02:00
|
|
|
{
|
2019-03-04 11:33:43 +01:00
|
|
|
struct event_queue *queue = impl_from_IMFMediaEventQueue(iface);
|
|
|
|
IMFMediaEvent *event;
|
|
|
|
HRESULT hr;
|
2017-09-08 13:00:20 +02:00
|
|
|
|
2019-03-04 11:33:43 +01:00
|
|
|
TRACE("%p, %d, %s, %#x, %p\n", iface, event_type, debugstr_guid(extended_type), status, value);
|
2017-09-08 13:00:20 +02:00
|
|
|
|
2019-03-04 11:33:43 +01:00
|
|
|
if (FAILED(hr = MFCreateMediaEvent(event_type, extended_type, status, value, &event)))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
hr = eventqueue_queue_event(queue, event);
|
|
|
|
IMFMediaEvent_Release(event);
|
|
|
|
return hr;
|
2017-09-08 13:00:20 +02:00
|
|
|
}
|
|
|
|
|
2019-03-04 11:33:43 +01:00
|
|
|
static HRESULT WINAPI eventqueue_QueueEventParamUnk(IMFMediaEventQueue *iface, MediaEventType event_type,
|
|
|
|
REFGUID extended_type, HRESULT status, IUnknown *unk)
|
2017-09-08 13:00:20 +02:00
|
|
|
{
|
2019-03-04 11:33:43 +01:00
|
|
|
struct event_queue *queue = impl_from_IMFMediaEventQueue(iface);
|
|
|
|
IMFMediaEvent *event;
|
|
|
|
PROPVARIANT value;
|
|
|
|
HRESULT hr;
|
2017-09-08 13:00:20 +02:00
|
|
|
|
2019-03-04 11:33:43 +01:00
|
|
|
TRACE("%p, %d, %s, %#x, %p.\n", iface, event_type, debugstr_guid(extended_type), status, unk);
|
2017-09-08 13:00:20 +02:00
|
|
|
|
2019-03-04 11:33:43 +01:00
|
|
|
value.vt = VT_UNKNOWN;
|
2019-03-14 09:03:11 +01:00
|
|
|
value.u.punkVal = unk;
|
2019-03-04 11:33:43 +01:00
|
|
|
|
|
|
|
if (FAILED(hr = MFCreateMediaEvent(event_type, extended_type, status, &value, &event)))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
hr = eventqueue_queue_event(queue, event);
|
|
|
|
IMFMediaEvent_Release(event);
|
|
|
|
return hr;
|
2017-09-08 13:00:20 +02:00
|
|
|
}
|
|
|
|
|
2019-03-04 11:33:43 +01:00
|
|
|
static HRESULT WINAPI eventqueue_Shutdown(IMFMediaEventQueue *iface)
|
2017-09-08 13:00:20 +02:00
|
|
|
{
|
2019-03-04 11:33:43 +01:00
|
|
|
struct event_queue *queue = impl_from_IMFMediaEventQueue(iface);
|
|
|
|
|
|
|
|
TRACE("%p\n", queue);
|
|
|
|
|
|
|
|
EnterCriticalSection(&queue->cs);
|
|
|
|
|
|
|
|
if (!queue->is_shut_down)
|
|
|
|
{
|
|
|
|
event_queue_cleanup(queue);
|
|
|
|
queue->is_shut_down = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
LeaveCriticalSection(&queue->cs);
|
|
|
|
|
|
|
|
WakeAllConditionVariable(&queue->update_event);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IMFMediaEventQueueVtbl eventqueuevtbl =
|
|
|
|
{
|
|
|
|
eventqueue_QueryInterface,
|
|
|
|
eventqueue_AddRef,
|
|
|
|
eventqueue_Release,
|
|
|
|
eventqueue_GetEvent,
|
|
|
|
eventqueue_BeginGetEvent,
|
|
|
|
eventqueue_EndGetEvent,
|
|
|
|
eventqueue_QueueEvent,
|
|
|
|
eventqueue_QueueEventParamVar,
|
|
|
|
eventqueue_QueueEventParamUnk,
|
|
|
|
eventqueue_Shutdown
|
2017-09-08 13:00:20 +02:00
|
|
|
};
|
|
|
|
|
2017-09-06 09:38:58 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* MFCreateEventQueue (mfplat.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI MFCreateEventQueue(IMFMediaEventQueue **queue)
|
|
|
|
{
|
2019-03-04 11:33:43 +01:00
|
|
|
struct event_queue *object;
|
2017-09-06 09:38:58 +02:00
|
|
|
|
2017-09-08 13:00:20 +02:00
|
|
|
TRACE("%p\n", queue);
|
2017-09-06 09:38:58 +02:00
|
|
|
|
2019-03-04 11:33:43 +01:00
|
|
|
object = heap_alloc_zero(sizeof(*object));
|
|
|
|
if (!object)
|
2017-09-08 13:00:20 +02:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2019-03-04 11:33:43 +01:00
|
|
|
object->IMFMediaEventQueue_iface.lpVtbl = &eventqueuevtbl;
|
|
|
|
object->refcount = 1;
|
|
|
|
list_init(&object->events);
|
|
|
|
InitializeCriticalSection(&object->cs);
|
|
|
|
InitializeConditionVariable(&object->update_event);
|
2017-09-08 13:00:20 +02:00
|
|
|
|
|
|
|
*queue = &object->IMFMediaEventQueue_iface;
|
|
|
|
|
|
|
|
return S_OK;
|
2017-09-06 09:38:58 +02:00
|
|
|
}
|
2017-09-08 13:00:12 +02:00
|
|
|
|
2019-02-22 08:36:52 +01:00
|
|
|
struct collection
|
|
|
|
{
|
|
|
|
IMFCollection IMFCollection_iface;
|
|
|
|
LONG refcount;
|
|
|
|
IUnknown **elements;
|
|
|
|
size_t capacity;
|
|
|
|
size_t count;
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct collection *impl_from_IMFCollection(IMFCollection *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct collection, IMFCollection_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void collection_clear(struct collection *collection)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
for (i = 0; i < collection->count; ++i)
|
|
|
|
{
|
|
|
|
if (collection->elements[i])
|
|
|
|
IUnknown_Release(collection->elements[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
heap_free(collection->elements);
|
|
|
|
collection->elements = NULL;
|
|
|
|
collection->count = 0;
|
|
|
|
collection->capacity = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI collection_QueryInterface(IMFCollection *iface, REFIID riid, void **out)
|
|
|
|
{
|
|
|
|
TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), out);
|
|
|
|
|
|
|
|
if (IsEqualIID(riid, &IID_IMFCollection) ||
|
|
|
|
IsEqualIID(riid, &IID_IUnknown))
|
|
|
|
{
|
|
|
|
*out = iface;
|
|
|
|
IMFCollection_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("Unsupported interface %s.\n", debugstr_guid(riid));
|
|
|
|
*out = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI collection_AddRef(IMFCollection *iface)
|
|
|
|
{
|
|
|
|
struct collection *collection = impl_from_IMFCollection(iface);
|
|
|
|
ULONG refcount = InterlockedIncrement(&collection->refcount);
|
|
|
|
|
|
|
|
TRACE("%p, %d.\n", collection, refcount);
|
|
|
|
|
|
|
|
return refcount;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI collection_Release(IMFCollection *iface)
|
|
|
|
{
|
|
|
|
struct collection *collection = impl_from_IMFCollection(iface);
|
|
|
|
ULONG refcount = InterlockedDecrement(&collection->refcount);
|
|
|
|
|
|
|
|
TRACE("%p, %d.\n", collection, refcount);
|
|
|
|
|
|
|
|
if (!refcount)
|
|
|
|
{
|
|
|
|
collection_clear(collection);
|
|
|
|
heap_free(collection->elements);
|
|
|
|
heap_free(collection);
|
|
|
|
}
|
|
|
|
|
|
|
|
return refcount;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI collection_GetElementCount(IMFCollection *iface, DWORD *count)
|
|
|
|
{
|
|
|
|
struct collection *collection = impl_from_IMFCollection(iface);
|
|
|
|
|
|
|
|
TRACE("%p, %p.\n", iface, count);
|
|
|
|
|
|
|
|
if (!count)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
*count = collection->count;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI collection_GetElement(IMFCollection *iface, DWORD idx, IUnknown **element)
|
|
|
|
{
|
|
|
|
struct collection *collection = impl_from_IMFCollection(iface);
|
|
|
|
|
|
|
|
TRACE("%p, %u, %p.\n", iface, idx, element);
|
|
|
|
|
|
|
|
if (!element)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
if (idx >= collection->count)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
*element = collection->elements[idx];
|
|
|
|
if (*element)
|
|
|
|
IUnknown_AddRef(*element);
|
|
|
|
|
|
|
|
return *element ? S_OK : E_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI collection_AddElement(IMFCollection *iface, IUnknown *element)
|
|
|
|
{
|
|
|
|
struct collection *collection = impl_from_IMFCollection(iface);
|
|
|
|
|
|
|
|
TRACE("%p, %p.\n", iface, element);
|
|
|
|
|
|
|
|
if (!mf_array_reserve((void **)&collection->elements, &collection->capacity, collection->count + 1,
|
|
|
|
sizeof(*collection->elements)))
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
collection->elements[collection->count++] = element;
|
|
|
|
if (element)
|
|
|
|
IUnknown_AddRef(element);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI collection_RemoveElement(IMFCollection *iface, DWORD idx, IUnknown **element)
|
|
|
|
{
|
|
|
|
struct collection *collection = impl_from_IMFCollection(iface);
|
|
|
|
size_t count;
|
|
|
|
|
|
|
|
TRACE("%p, %u, %p.\n", iface, idx, element);
|
|
|
|
|
|
|
|
if (!element)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
if (idx >= collection->count)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
*element = collection->elements[idx];
|
|
|
|
|
|
|
|
count = collection->count - idx - 1;
|
|
|
|
if (count)
|
|
|
|
memmove(&collection->elements[idx], &collection->elements[idx + 1], count * sizeof(*collection->elements));
|
|
|
|
collection->count--;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI collection_InsertElementAt(IMFCollection *iface, DWORD idx, IUnknown *element)
|
|
|
|
{
|
|
|
|
struct collection *collection = impl_from_IMFCollection(iface);
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
TRACE("%p, %u, %p.\n", iface, idx, element);
|
|
|
|
|
|
|
|
if (!mf_array_reserve((void **)&collection->elements, &collection->capacity, idx + 1,
|
|
|
|
sizeof(*collection->elements)))
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
if (idx < collection->count)
|
|
|
|
{
|
|
|
|
memmove(&collection->elements[idx + 1], &collection->elements[idx],
|
|
|
|
(collection->count - idx) * sizeof(*collection->elements));
|
|
|
|
collection->count++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (i = collection->count; i < idx; ++i)
|
|
|
|
collection->elements[i] = NULL;
|
|
|
|
collection->count = idx + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
collection->elements[idx] = element;
|
|
|
|
if (collection->elements[idx])
|
|
|
|
IUnknown_AddRef(collection->elements[idx]);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI collection_RemoveAllElements(IMFCollection *iface)
|
|
|
|
{
|
|
|
|
struct collection *collection = impl_from_IMFCollection(iface);
|
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
collection_clear(collection);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IMFCollectionVtbl mfcollectionvtbl =
|
|
|
|
{
|
|
|
|
collection_QueryInterface,
|
|
|
|
collection_AddRef,
|
|
|
|
collection_Release,
|
|
|
|
collection_GetElementCount,
|
|
|
|
collection_GetElement,
|
|
|
|
collection_AddElement,
|
|
|
|
collection_RemoveElement,
|
|
|
|
collection_InsertElementAt,
|
|
|
|
collection_RemoveAllElements,
|
|
|
|
};
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MFCreateCollection (mfplat.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI MFCreateCollection(IMFCollection **collection)
|
|
|
|
{
|
|
|
|
struct collection *object;
|
|
|
|
|
|
|
|
TRACE("%p\n", collection);
|
|
|
|
|
|
|
|
if (!collection)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
object = heap_alloc_zero(sizeof(*object));
|
|
|
|
if (!object)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
object->IMFCollection_iface.lpVtbl = &mfcollectionvtbl;
|
|
|
|
object->refcount = 1;
|
|
|
|
|
|
|
|
*collection = &object->IMFCollection_iface;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
2019-02-22 08:36:54 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MFHeapAlloc (mfplat.@)
|
|
|
|
*/
|
|
|
|
void *WINAPI MFHeapAlloc(SIZE_T size, ULONG flags, char *file, int line, EAllocationType type)
|
|
|
|
{
|
|
|
|
TRACE("%lu, %#x, %s, %d, %#x.\n", size, flags, debugstr_a(file), line, type);
|
|
|
|
return HeapAlloc(GetProcessHeap(), flags, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MFHeapFree (mfplat.@)
|
|
|
|
*/
|
|
|
|
void WINAPI MFHeapFree(void *p)
|
|
|
|
{
|
|
|
|
TRACE("%p\n", p);
|
|
|
|
HeapFree(GetProcessHeap(), 0, p);
|
|
|
|
}
|
2019-02-27 16:10:51 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MFCreateMFByteStreamOnStreamEx (mfplat.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI MFCreateMFByteStreamOnStreamEx(IUnknown *stream, IMFByteStream **bytestream)
|
|
|
|
{
|
|
|
|
FIXME("(%p, %p): stub\n", stream, bytestream);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
2019-03-06 10:42:13 +01:00
|
|
|
|
|
|
|
static HRESULT WINAPI system_time_source_QueryInterface(IMFPresentationTimeSource *iface, REFIID riid, void **obj)
|
|
|
|
{
|
|
|
|
struct system_time_source *source = impl_from_IMFPresentationTimeSource(iface);
|
|
|
|
|
|
|
|
TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), obj);
|
|
|
|
|
|
|
|
if (IsEqualIID(riid, &IID_IMFPresentationTimeSource) ||
|
|
|
|
IsEqualIID(riid, &IID_IUnknown))
|
|
|
|
{
|
|
|
|
*obj = &source->IMFPresentationTimeSource_iface;
|
|
|
|
}
|
|
|
|
else if (IsEqualIID(riid, &IID_IMFClockStateSink))
|
|
|
|
{
|
|
|
|
*obj = &source->IMFClockStateSink_iface;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WARN("Unsupported %s.\n", debugstr_guid(riid));
|
|
|
|
*obj = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
IUnknown_AddRef((IUnknown *)*obj);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI system_time_source_AddRef(IMFPresentationTimeSource *iface)
|
|
|
|
{
|
|
|
|
struct system_time_source *source = impl_from_IMFPresentationTimeSource(iface);
|
|
|
|
ULONG refcount = InterlockedIncrement(&source->refcount);
|
|
|
|
|
|
|
|
TRACE("%p, refcount %u.\n", iface, refcount);
|
|
|
|
|
|
|
|
return refcount;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI system_time_source_Release(IMFPresentationTimeSource *iface)
|
|
|
|
{
|
|
|
|
struct system_time_source *source = impl_from_IMFPresentationTimeSource(iface);
|
|
|
|
ULONG refcount = InterlockedDecrement(&source->refcount);
|
|
|
|
|
|
|
|
TRACE("%p, refcount %u.\n", iface, refcount);
|
|
|
|
|
|
|
|
if (!refcount)
|
2019-03-06 10:42:14 +01:00
|
|
|
{
|
|
|
|
DeleteCriticalSection(&source->cs);
|
2019-03-06 10:42:13 +01:00
|
|
|
heap_free(source);
|
2019-03-06 10:42:14 +01:00
|
|
|
}
|
2019-03-06 10:42:13 +01:00
|
|
|
|
|
|
|
return refcount;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI system_time_source_GetClockCharacteristics(IMFPresentationTimeSource *iface, DWORD *flags)
|
|
|
|
{
|
|
|
|
TRACE("%p, %p.\n", iface, flags);
|
|
|
|
|
|
|
|
*flags = MFCLOCK_CHARACTERISTICS_FLAG_FREQUENCY_10MHZ | MFCLOCK_CHARACTERISTICS_FLAG_IS_SYSTEM_CLOCK;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI system_time_source_GetCorrelatedTime(IMFPresentationTimeSource *iface, DWORD reserved,
|
|
|
|
LONGLONG *clock_time, MFTIME *system_time)
|
|
|
|
{
|
|
|
|
FIXME("%p, %#x, %p, %p.\n", iface, reserved, clock_time, system_time);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI system_time_source_GetContinuityKey(IMFPresentationTimeSource *iface, DWORD *key)
|
|
|
|
{
|
|
|
|
TRACE("%p, %p.\n", iface, key);
|
|
|
|
|
|
|
|
*key = 0;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI system_time_source_GetState(IMFPresentationTimeSource *iface, DWORD reserved,
|
|
|
|
MFCLOCK_STATE *state)
|
|
|
|
{
|
2019-03-06 10:42:14 +01:00
|
|
|
struct system_time_source *source = impl_from_IMFPresentationTimeSource(iface);
|
2019-03-06 10:42:13 +01:00
|
|
|
|
2019-03-06 10:42:14 +01:00
|
|
|
TRACE("%p, %#x, %p.\n", iface, reserved, state);
|
|
|
|
|
|
|
|
EnterCriticalSection(&source->cs);
|
|
|
|
*state = source->state;
|
|
|
|
LeaveCriticalSection(&source->cs);
|
|
|
|
|
|
|
|
return S_OK;
|
2019-03-06 10:42:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI system_time_source_GetProperties(IMFPresentationTimeSource *iface, MFCLOCK_PROPERTIES *props)
|
|
|
|
{
|
|
|
|
FIXME("%p, %p.\n", iface, props);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI system_time_source_GetUnderlyingClock(IMFPresentationTimeSource *iface, IMFClock **clock)
|
|
|
|
{
|
|
|
|
FIXME("%p, %p.\n", iface, clock);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IMFPresentationTimeSourceVtbl systemtimesourcevtbl =
|
|
|
|
{
|
|
|
|
system_time_source_QueryInterface,
|
|
|
|
system_time_source_AddRef,
|
|
|
|
system_time_source_Release,
|
|
|
|
system_time_source_GetClockCharacteristics,
|
|
|
|
system_time_source_GetCorrelatedTime,
|
|
|
|
system_time_source_GetContinuityKey,
|
|
|
|
system_time_source_GetState,
|
|
|
|
system_time_source_GetProperties,
|
|
|
|
system_time_source_GetUnderlyingClock,
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT WINAPI system_time_source_sink_QueryInterface(IMFClockStateSink *iface, REFIID riid, void **out)
|
|
|
|
{
|
|
|
|
struct system_time_source *source = impl_from_IMFClockStateSink(iface);
|
|
|
|
return IMFPresentationTimeSource_QueryInterface(&source->IMFPresentationTimeSource_iface, riid, out);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI system_time_source_sink_AddRef(IMFClockStateSink *iface)
|
|
|
|
{
|
|
|
|
struct system_time_source *source = impl_from_IMFClockStateSink(iface);
|
|
|
|
return IMFPresentationTimeSource_AddRef(&source->IMFPresentationTimeSource_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI system_time_source_sink_Release(IMFClockStateSink *iface)
|
|
|
|
{
|
|
|
|
struct system_time_source *source = impl_from_IMFClockStateSink(iface);
|
|
|
|
return IMFPresentationTimeSource_Release(&source->IMFPresentationTimeSource_iface);
|
|
|
|
}
|
|
|
|
|
2019-03-06 10:42:14 +01:00
|
|
|
enum clock_command
|
2019-03-06 10:42:13 +01:00
|
|
|
{
|
2019-03-06 10:42:14 +01:00
|
|
|
CLOCK_CMD_START = 0,
|
|
|
|
CLOCK_CMD_STOP,
|
|
|
|
CLOCK_CMD_PAUSE,
|
|
|
|
CLOCK_CMD_RESTART,
|
|
|
|
CLOCK_CMD_MAX,
|
|
|
|
};
|
2019-03-06 10:42:13 +01:00
|
|
|
|
2019-03-06 10:42:14 +01:00
|
|
|
static HRESULT system_time_source_change_state(struct system_time_source *source, enum clock_command command)
|
|
|
|
{
|
|
|
|
static const BYTE state_change_is_allowed[MFCLOCK_STATE_PAUSED+1][CLOCK_CMD_MAX] =
|
|
|
|
{ /* S S* P R */
|
|
|
|
/* INVALID */ { 1, 0, 1, 0 },
|
|
|
|
/* RUNNING */ { 1, 1, 1, 0 },
|
|
|
|
/* STOPPED */ { 1, 1, 0, 0 },
|
|
|
|
/* PAUSED */ { 1, 1, 0, 1 },
|
|
|
|
};
|
|
|
|
static const MFCLOCK_STATE states[CLOCK_CMD_MAX] =
|
|
|
|
{
|
|
|
|
/* CLOCK_CMD_START */ MFCLOCK_STATE_RUNNING,
|
|
|
|
/* CLOCK_CMD_STOP */ MFCLOCK_STATE_STOPPED,
|
|
|
|
/* CLOCK_CMD_PAUSE */ MFCLOCK_STATE_PAUSED,
|
|
|
|
/* CLOCK_CMD_RESTART */ MFCLOCK_STATE_RUNNING,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Special case that go against usual state change vs return value behavior. */
|
|
|
|
if (source->state == MFCLOCK_STATE_INVALID && command == CLOCK_CMD_STOP)
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
if (!state_change_is_allowed[source->state][command])
|
|
|
|
return MF_E_INVALIDREQUEST;
|
|
|
|
|
|
|
|
source->state = states[command];
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI system_time_source_sink_OnClockStart(IMFClockStateSink *iface, MFTIME system_time,
|
|
|
|
LONGLONG start_offset)
|
|
|
|
{
|
|
|
|
struct system_time_source *source = impl_from_IMFClockStateSink(iface);
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("%p, %s, %s.\n", iface, wine_dbgstr_longlong(system_time), wine_dbgstr_longlong(start_offset));
|
|
|
|
|
|
|
|
EnterCriticalSection(&source->cs);
|
|
|
|
hr = system_time_source_change_state(source, CLOCK_CMD_START);
|
|
|
|
LeaveCriticalSection(&source->cs);
|
|
|
|
|
|
|
|
/* FIXME: update timestamps */
|
|
|
|
|
|
|
|
return hr;
|
2019-03-06 10:42:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI system_time_source_sink_OnClockStop(IMFClockStateSink *iface, MFTIME system_time)
|
|
|
|
{
|
2019-03-06 10:42:14 +01:00
|
|
|
struct system_time_source *source = impl_from_IMFClockStateSink(iface);
|
|
|
|
HRESULT hr;
|
2019-03-06 10:42:13 +01:00
|
|
|
|
2019-03-06 10:42:14 +01:00
|
|
|
TRACE("%p, %s.\n", iface, wine_dbgstr_longlong(system_time));
|
|
|
|
|
|
|
|
EnterCriticalSection(&source->cs);
|
|
|
|
hr = system_time_source_change_state(source, CLOCK_CMD_STOP);
|
|
|
|
LeaveCriticalSection(&source->cs);
|
|
|
|
|
|
|
|
/* FIXME: update timestamps */
|
|
|
|
|
|
|
|
return hr;
|
2019-03-06 10:42:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI system_time_source_sink_OnClockPause(IMFClockStateSink *iface, MFTIME system_time)
|
|
|
|
{
|
2019-03-06 10:42:14 +01:00
|
|
|
struct system_time_source *source = impl_from_IMFClockStateSink(iface);
|
|
|
|
HRESULT hr;
|
2019-03-06 10:42:13 +01:00
|
|
|
|
2019-03-06 10:42:14 +01:00
|
|
|
TRACE("%p, %s.\n", iface, wine_dbgstr_longlong(system_time));
|
|
|
|
|
|
|
|
EnterCriticalSection(&source->cs);
|
|
|
|
hr = system_time_source_change_state(source, CLOCK_CMD_PAUSE);
|
|
|
|
LeaveCriticalSection(&source->cs);
|
|
|
|
|
|
|
|
/* FIXME: update timestamps */
|
|
|
|
|
|
|
|
return hr;
|
2019-03-06 10:42:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI system_time_source_sink_OnClockRestart(IMFClockStateSink *iface, MFTIME system_time)
|
|
|
|
{
|
2019-03-06 10:42:14 +01:00
|
|
|
struct system_time_source *source = impl_from_IMFClockStateSink(iface);
|
|
|
|
HRESULT hr;
|
2019-03-06 10:42:13 +01:00
|
|
|
|
2019-03-06 10:42:14 +01:00
|
|
|
TRACE("%p, %s.\n", iface, wine_dbgstr_longlong(system_time));
|
|
|
|
|
|
|
|
EnterCriticalSection(&source->cs);
|
|
|
|
hr = system_time_source_change_state(source, CLOCK_CMD_RESTART);
|
|
|
|
LeaveCriticalSection(&source->cs);
|
|
|
|
|
|
|
|
/* FIXME: update timestamps */
|
|
|
|
|
|
|
|
return hr;
|
2019-03-06 10:42:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI system_time_source_sink_OnClockSetRate(IMFClockStateSink *iface, MFTIME system_time, float rate)
|
|
|
|
{
|
|
|
|
FIXME("%p, %s, %f.\n", iface, wine_dbgstr_longlong(system_time), rate);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IMFClockStateSinkVtbl systemtimesourcesinkvtbl =
|
|
|
|
{
|
|
|
|
system_time_source_sink_QueryInterface,
|
|
|
|
system_time_source_sink_AddRef,
|
|
|
|
system_time_source_sink_Release,
|
|
|
|
system_time_source_sink_OnClockStart,
|
|
|
|
system_time_source_sink_OnClockStop,
|
|
|
|
system_time_source_sink_OnClockPause,
|
|
|
|
system_time_source_sink_OnClockRestart,
|
|
|
|
system_time_source_sink_OnClockSetRate,
|
|
|
|
};
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MFCreateSystemTimeSource (mfplat.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI MFCreateSystemTimeSource(IMFPresentationTimeSource **time_source)
|
|
|
|
{
|
|
|
|
struct system_time_source *object;
|
|
|
|
|
|
|
|
TRACE("%p.\n", time_source);
|
|
|
|
|
2019-03-06 10:42:14 +01:00
|
|
|
object = heap_alloc_zero(sizeof(*object));
|
2019-03-06 10:42:13 +01:00
|
|
|
if (!object)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
object->IMFPresentationTimeSource_iface.lpVtbl = &systemtimesourcevtbl;
|
|
|
|
object->IMFClockStateSink_iface.lpVtbl = &systemtimesourcesinkvtbl;
|
|
|
|
object->refcount = 1;
|
2019-03-06 10:42:14 +01:00
|
|
|
InitializeCriticalSection(&object->cs);
|
2019-03-06 10:42:13 +01:00
|
|
|
|
|
|
|
*time_source = &object->IMFPresentationTimeSource_iface;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|