Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force the Apple Video/Audio Toolbox in GStreamer transforms #4

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 45 additions & 12 deletions dlls/mfplat/h264_decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,21 +247,26 @@ static ULONG WINAPI h264_decoder_Release(IMFTransform *iface)
static HRESULT WINAPI h264_decoder_GetStreamLimits(IMFTransform *iface, DWORD *input_minimum, DWORD *input_maximum,
DWORD *output_minimum, DWORD *output_maximum)
{
FIXME("iface %p, input_minimum %p, input_maximum %p, output_minimum %p, output_maximum %p stub!\n",
TRACE("iface %p, input_minimum %p, input_maximum %p, output_minimum %p, output_maximum %p.!\n",
iface, input_minimum, input_maximum, output_minimum, output_maximum);
return E_NOTIMPL;
*input_minimum = *input_maximum = 1;
*output_minimum = *output_maximum = 1;
return S_OK;
}

static HRESULT WINAPI h264_decoder_GetStreamCount(IMFTransform *iface, DWORD *inputs, DWORD *outputs)
{
FIXME("iface %p, inputs %p, outputs %p stub!\n", iface, inputs, outputs);
return E_NOTIMPL;
TRACE("iface %p, inputs %p, outputs %p.\n", iface, inputs, outputs);
*inputs = 1;
*outputs = 1;
return S_OK;
}

static HRESULT WINAPI h264_decoder_GetStreamIDs(IMFTransform *iface, DWORD input_size, DWORD *inputs,
DWORD output_size, DWORD *outputs)
{
FIXME("iface %p, input_size %u, inputs %p, output_size %u, outputs %p stub!\n",
/* can return E_NOTIMPL without worry for fixed-size streams */
TRACE("iface %p, input_size %u, inputs %p, output_size %u, outputs %p.\n",
iface, input_size, inputs, output_size, outputs);
return E_NOTIMPL;
}
Expand Down Expand Up @@ -312,6 +317,7 @@ static HRESULT WINAPI h264_decoder_GetAttributes(IMFTransform *iface, IMFAttribu
return MFCreateAttributes(attributes, 0);
}

/* note: input/output attributes are not mandatory (and generally unused) */
static HRESULT WINAPI h264_decoder_GetInputStreamAttributes(IMFTransform *iface, DWORD id,
IMFAttributes **attributes)
{
Expand All @@ -328,13 +334,13 @@ static HRESULT WINAPI h264_decoder_GetOutputStreamAttributes(IMFTransform *iface

static HRESULT WINAPI h264_decoder_DeleteInputStream(IMFTransform *iface, DWORD id)
{
FIXME("iface %p, id %u stub!\n", iface, id);
TRACE("iface %p, id %u.\n", iface, id);
return E_NOTIMPL;
}

static HRESULT WINAPI h264_decoder_AddInputStreams(IMFTransform *iface, DWORD streams, DWORD *ids)
{
FIXME("iface %p, streams %u, ids %p stub!\n", iface, streams, ids);
TRACE("iface %p, streams %u, ids %p.\n", iface, streams, ids);
return E_NOTIMPL;
}

Expand Down Expand Up @@ -483,20 +489,47 @@ static HRESULT WINAPI h264_decoder_SetOutputType(IMFTransform *iface, DWORD id,

static HRESULT WINAPI h264_decoder_GetInputCurrentType(IMFTransform *iface, DWORD id, IMFMediaType **type)
{
FIXME("iface %p, id %u, type %p stub!\n", iface, id, type);
return E_NOTIMPL;
struct h264_decoder *decoder = impl_from_IMFTransform(iface);
HRESULT hr;

TRACE("iface %p, id %u, type %p.\n", iface, id, type);

if (!decoder->input_type)
return MF_E_TRANSFORM_TYPE_NOT_SET;

if (FAILED(hr = MFCreateMediaType(type)))
return hr;

if (FAILED(hr = IMFAttributes_CopyAllItems(decoder->input_type, *type)))
IMFMediaType_Release(*type);

return hr;
}

static HRESULT WINAPI h264_decoder_GetOutputCurrentType(IMFTransform *iface, DWORD id, IMFMediaType **type)
{
FIXME("iface %p, id %u, type %p stub!\n", iface, id, type);
return E_NOTIMPL;
struct h264_decoder *decoder = impl_from_IMFTransform(iface);
HRESULT hr;

TRACE("iface %p, id %u, type %p.\n", iface, id, type);

if (!decoder->output_type)
return MF_E_TRANSFORM_TYPE_NOT_SET;

if (FAILED(hr = MFCreateMediaType(type)))
return hr;

if (FAILED(hr = IMFAttributes_CopyAllItems(decoder->output_type, *type)))
IMFMediaType_Release(*type);

return hr;
}

static HRESULT WINAPI h264_decoder_GetInputStatus(IMFTransform *iface, DWORD id, DWORD *flags)
{
FIXME("iface %p, id %u, flags %p stub!\n", iface, id, flags);
return E_NOTIMPL;
*flags = MFT_INPUT_STATUS_ACCEPT_DATA;
return S_OK;
}

static HRESULT WINAPI h264_decoder_GetOutputStatus(IMFTransform *iface, DWORD *flags)
Expand Down
53 changes: 32 additions & 21 deletions dlls/mfplat/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1096,12 +1096,32 @@ static void mft_get_reg_flags(const WCHAR *clsidW, const WCHAR *nameW, DWORD *fl
RegCloseKey(hmft);
}

static HRESULT mft_get_name(HKEY hkey, WCHAR **name)
{
DWORD size;

if (!name)
return S_OK;

*name = NULL;

if (!RegQueryValueExW(hkey, NULL, NULL, NULL, NULL, &size))
{
if (!(*name = CoTaskMemAlloc(size)))
return E_OUTOFMEMORY;

RegQueryValueExW(hkey, NULL, NULL, NULL, (BYTE *)*name, &size);
}

return S_OK;
}

static HRESULT mft_collect_machine_reg(struct list *mfts, const GUID *category, UINT32 flags,
IMFPluginControl *plugin_control, const MFT_REGISTER_TYPE_INFO *input_type,
const MFT_REGISTER_TYPE_INFO *output_type)
{
struct mft_registration mft, *cur;
HKEY hcategory, hlist;
HKEY hcategory, hlist, htransform, hmft;
WCHAR clsidW[64];
DWORD ret, size;
int index = 0;
Expand All @@ -1123,6 +1143,17 @@ static HRESULT mft_collect_machine_reg(struct list *mfts, const GUID *category,
if (!GUIDFromString(clsidW, &mft.clsid))
goto next;

/* get name of MFT transform */
if (!RegOpenKeyW(HKEY_CLASSES_ROOT, transform_keyW, &htransform))
{
if (!RegOpenKeyW(htransform, clsidW, &hmft))
{
mft_get_name(hmft, &mft.name);
RegCloseKey(hmft);
}
RegCloseKey(htransform);
}

mft_get_reg_flags(clsidW, L"MFTFlags", &mft.flags);

if (output_type)
Expand Down Expand Up @@ -1442,26 +1473,6 @@ HRESULT WINAPI MFTUnregister(CLSID clsid)
return S_OK;
}

static HRESULT mft_get_name(HKEY hkey, WCHAR **name)
{
DWORD size;

if (!name)
return S_OK;

*name = NULL;

if (!RegQueryValueExW(hkey, NULL, NULL, NULL, NULL, &size))
{
if (!(*name = CoTaskMemAlloc(size)))
return E_OUTOFMEMORY;

RegQueryValueExW(hkey, NULL, NULL, NULL, (BYTE *)*name, &size);
}

return S_OK;
}

static HRESULT mft_get_reg_type_info(const WCHAR *clsid, const WCHAR *key, MFT_REGISTER_TYPE_INFO **ret_types,
UINT32 *ret_count)
{
Expand Down
35 changes: 33 additions & 2 deletions dlls/mfplat/wg_transform.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ NTSTATUS wg_transform_create(void *args)
struct wg_encoded_format input_format = *params->input_format;
struct wg_format output_format = *params->output_format;
GstElement *first = NULL, *last = NULL, *element;
GstCaps *raw_caps, *src_caps, *sink_caps;
GstCaps *raw_caps, *src_caps, *sink_caps, *interim_caps;
struct wg_transform *transform;
GstPadTemplate *template;
const gchar *media_type;
Expand All @@ -414,7 +414,37 @@ NTSTATUS wg_transform_create(void *args)
transform->container = gst_bin_new("wg_transform");
assert(transform->container);

if (!(element = try_create_transform(src_caps, raw_caps)) ||
#ifdef __APPLE__
/* transforms the codecs into a format tractable by Audio Toolbox/Video Toolbox */
switch (input_format.encoded_type)
{
case WG_ENCODED_TYPE_H264:
case WG_ENCODED_TYPE_AAC:
interim_caps = gst_caps_copy(src_caps);
if (input_format.encoded_type == WG_ENCODED_TYPE_H264)
{
// should invoke h264parse -> vtdec_hw
gst_caps_set_simple(interim_caps, "stream-format", G_TYPE_STRING, "avc", NULL);
gst_caps_set_simple(interim_caps, "alignment", G_TYPE_STRING, "au", NULL);
}
else if (input_format.encoded_type == WG_ENCODED_TYPE_AAC)
{
// should invoke aacparse -> atdec
gst_caps_set_simple(interim_caps, "framed", G_TYPE_BOOLEAN, TRUE, NULL);
}

if (!(element = try_create_transform(src_caps, interim_caps)) ||
!transform_append_element(transform, element, &first, &last))
goto failed;
break;
default:
interim_caps = gst_caps_ref(src_caps);
}
#else
interim_caps = gst_caps_ref(src_caps);
#endif

if (!(element = try_create_transform(interim_caps, raw_caps)) ||
!transform_append_element(transform, element, &first, &last))
goto failed;

Expand Down Expand Up @@ -524,6 +554,7 @@ NTSTATUS wg_transform_create(void *args)
gst_caps_unref(raw_caps);
gst_caps_unref(src_caps);
gst_caps_unref(sink_caps);
gst_caps_unref(interim_caps);

if (params->transform)
return S_OK;
Expand Down
57 changes: 45 additions & 12 deletions dlls/winegstreamer/h264_decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,21 +247,26 @@ static ULONG WINAPI h264_decoder_Release(IMFTransform *iface)
static HRESULT WINAPI h264_decoder_GetStreamLimits(IMFTransform *iface, DWORD *input_minimum, DWORD *input_maximum,
DWORD *output_minimum, DWORD *output_maximum)
{
FIXME("iface %p, input_minimum %p, input_maximum %p, output_minimum %p, output_maximum %p stub!\n",
TRACE("iface %p, input_minimum %p, input_maximum %p, output_minimum %p, output_maximum %p.!\n",
iface, input_minimum, input_maximum, output_minimum, output_maximum);
return E_NOTIMPL;
*input_minimum = *input_maximum = 1;
*output_minimum = *output_maximum = 1;
return S_OK;
}

static HRESULT WINAPI h264_decoder_GetStreamCount(IMFTransform *iface, DWORD *inputs, DWORD *outputs)
{
FIXME("iface %p, inputs %p, outputs %p stub!\n", iface, inputs, outputs);
return E_NOTIMPL;
TRACE("iface %p, inputs %p, outputs %p.\n", iface, inputs, outputs);
*inputs = 1;
*outputs = 1;
return S_OK;
}

static HRESULT WINAPI h264_decoder_GetStreamIDs(IMFTransform *iface, DWORD input_size, DWORD *inputs,
DWORD output_size, DWORD *outputs)
{
FIXME("iface %p, input_size %u, inputs %p, output_size %u, outputs %p stub!\n",
/* can return E_NOTIMPL without worry for fixed-size streams */
TRACE("iface %p, input_size %u, inputs %p, output_size %u, outputs %p.\n",
iface, input_size, inputs, output_size, outputs);
return E_NOTIMPL;
}
Expand Down Expand Up @@ -312,6 +317,7 @@ static HRESULT WINAPI h264_decoder_GetAttributes(IMFTransform *iface, IMFAttribu
return MFCreateAttributes(attributes, 0);
}

/* note: input/output attributes are not mandatory (and generally unused) */
static HRESULT WINAPI h264_decoder_GetInputStreamAttributes(IMFTransform *iface, DWORD id,
IMFAttributes **attributes)
{
Expand All @@ -328,13 +334,13 @@ static HRESULT WINAPI h264_decoder_GetOutputStreamAttributes(IMFTransform *iface

static HRESULT WINAPI h264_decoder_DeleteInputStream(IMFTransform *iface, DWORD id)
{
FIXME("iface %p, id %u stub!\n", iface, id);
TRACE("iface %p, id %u.\n", iface, id);
return E_NOTIMPL;
}

static HRESULT WINAPI h264_decoder_AddInputStreams(IMFTransform *iface, DWORD streams, DWORD *ids)
{
FIXME("iface %p, streams %u, ids %p stub!\n", iface, streams, ids);
TRACE("iface %p, streams %u, ids %p.\n", iface, streams, ids);
return E_NOTIMPL;
}

Expand Down Expand Up @@ -483,20 +489,47 @@ static HRESULT WINAPI h264_decoder_SetOutputType(IMFTransform *iface, DWORD id,

static HRESULT WINAPI h264_decoder_GetInputCurrentType(IMFTransform *iface, DWORD id, IMFMediaType **type)
{
FIXME("iface %p, id %u, type %p stub!\n", iface, id, type);
return E_NOTIMPL;
struct h264_decoder *decoder = impl_from_IMFTransform(iface);
HRESULT hr;

TRACE("iface %p, id %u, type %p.\n", iface, id, type);

if (!decoder->input_type)
return MF_E_TRANSFORM_TYPE_NOT_SET;

if (FAILED(hr = MFCreateMediaType(type)))
return hr;

if (FAILED(hr = IMFAttributes_CopyAllItems(decoder->input_type, *type)))
IMFMediaType_Release(*type);

return hr;
}

static HRESULT WINAPI h264_decoder_GetOutputCurrentType(IMFTransform *iface, DWORD id, IMFMediaType **type)
{
FIXME("iface %p, id %u, type %p stub!\n", iface, id, type);
return E_NOTIMPL;
struct h264_decoder *decoder = impl_from_IMFTransform(iface);
HRESULT hr;

TRACE("iface %p, id %u, type %p.\n", iface, id, type);

if (!decoder->output_type)
return MF_E_TRANSFORM_TYPE_NOT_SET;

if (FAILED(hr = MFCreateMediaType(type)))
return hr;

if (FAILED(hr = IMFAttributes_CopyAllItems(decoder->output_type, *type)))
IMFMediaType_Release(*type);

return hr;
}

static HRESULT WINAPI h264_decoder_GetInputStatus(IMFTransform *iface, DWORD id, DWORD *flags)
{
FIXME("iface %p, id %u, flags %p stub!\n", iface, id, flags);
return E_NOTIMPL;
*flags = MFT_INPUT_STATUS_ACCEPT_DATA;
return S_OK;
}

static HRESULT WINAPI h264_decoder_GetOutputStatus(IMFTransform *iface, DWORD *flags)
Expand Down
Loading
Loading