Commit 4244b4b1 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

mfreadwrite/writer: Create output stream if it wasn't provided.

parent aaebf839
......@@ -1291,6 +1291,18 @@ done:
DestroyWindow(window);
}
static void test_sink_writer(void)
{
IMFSinkWriter *writer;
HRESULT hr;
hr = MFCreateSinkWriterFromURL(NULL, NULL, NULL, NULL);
ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
hr = MFCreateSinkWriterFromURL(NULL, NULL, NULL, &writer);
ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
}
START_TEST(mfplat)
{
HRESULT hr;
......@@ -1304,6 +1316,7 @@ START_TEST(mfplat)
test_source_reader();
test_source_reader_from_media_source();
test_reader_d3d9();
test_sink_writer();
hr = MFShutdown();
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
......
......@@ -289,6 +289,9 @@ HRESULT create_sink_writer_from_url(const WCHAR *url, IMFByteStream *bytestream,
CLSID clsid;
HRESULT hr;
if (!url && !bytestream)
return E_INVALIDARG;
if (FAILED(hr = sink_writer_get_sink_factory_class(url, attributes, &clsid))) return hr;
if (FAILED(hr = CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_SERVER, &IID_IMFSinkClassFactory, (void **)&factory)))
......@@ -297,8 +300,18 @@ HRESULT create_sink_writer_from_url(const WCHAR *url, IMFByteStream *bytestream,
return hr;
}
if (bytestream)
IMFByteStream_AddRef(bytestream);
else if (FAILED(hr = MFCreateFile(MF_ACCESSMODE_WRITE, MF_OPENMODE_DELETE_IF_EXIST, 0, url, &bytestream)))
{
WARN("Failed to create output file stream, hr %#lx.\n", hr);
IMFSinkClassFactory_Release(factory);
return hr;
}
hr = IMFSinkClassFactory_CreateMediaSink(factory, bytestream, NULL, NULL, &sink);
IMFSinkClassFactory_Release(factory);
IMFByteStream_Release(bytestream);
if (FAILED(hr))
{
WARN("Failed to create a sink, hr %#lx.\n", hr);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment