Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
aaebf839
Commit
aaebf839
authored
Aug 11, 2022
by
Nikolay Sivov
Committed by
Alexandre Julliard
Aug 11, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mfreadwrite/writer: Create archive sink automatically when writer is created from url/bytestream.
Signed-off-by:
Nikolay Sivov
<
nsivov@codeweavers.com
>
parent
8aca3799
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
114 additions
and
23 deletions
+114
-23
Makefile.in
dlls/mfreadwrite/Makefile.in
+1
-1
mf_private.h
dlls/mfreadwrite/mf_private.h
+2
-2
reader.c
dlls/mfreadwrite/reader.c
+5
-1
writer.c
dlls/mfreadwrite/writer.c
+106
-19
No files found.
dlls/mfreadwrite/Makefile.in
View file @
aaebf839
MODULE
=
mfreadwrite.dll
IMPORTLIB
=
mfreadwrite
IMPORTS
=
mfuuid uuid mfplat ole32
IMPORTS
=
mfuuid uuid mfplat ole32
kernelbase
EXTRADLLFLAGS
=
-Wb
,--prefer-native
...
...
dlls/mfreadwrite/mf_private.h
View file @
aaebf839
...
...
@@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
extern
HRESULT
create_sink_writer_from_
stream
(
IMFByteStream
*
stream
,
IMFAttributes
*
attributes
,
REFIID
riid
,
void
**
out
)
DECLSPEC_HIDDEN
;
extern
HRESULT
create_sink_writer_from_
url
(
const
WCHAR
*
url
,
IMFByteStream
*
stream
,
IMFAttributes
*
attributes
,
REFIID
riid
,
void
**
out
)
DECLSPEC_HIDDEN
;
extern
HRESULT
create_sink_writer_from_sink
(
IMFMediaSink
*
sink
,
IMFAttributes
*
attributes
,
REFIID
riid
,
void
**
out
)
DECLSPEC_HIDDEN
;
dlls/mfreadwrite/reader.c
View file @
aaebf839
...
...
@@ -2594,6 +2594,10 @@ static HRESULT WINAPI readwrite_factory_CreateInstanceFromURL(IMFReadWriteClassF
{
return
create_source_reader_from_url
(
url
,
attributes
,
&
IID_IMFSourceReader
,
out
);
}
else
if
(
IsEqualGUID
(
clsid
,
&
CLSID_MFSinkWriter
))
{
return
create_sink_writer_from_url
(
url
,
NULL
,
attributes
,
riid
,
out
);
}
FIXME
(
"Unsupported %s.
\n
"
,
debugstr_guid
(
clsid
));
...
...
@@ -2621,7 +2625,7 @@ static HRESULT WINAPI readwrite_factory_CreateInstanceFromObject(IMFReadWriteCla
hr
=
IUnknown_QueryInterface
(
unk
,
&
IID_IMFMediaSink
,
(
void
**
)
&
sink
);
if
(
stream
)
hr
=
create_sink_writer_from_
stream
(
stream
,
attributes
,
riid
,
out
);
hr
=
create_sink_writer_from_
url
(
NULL
,
stream
,
attributes
,
riid
,
out
);
else
if
(
sink
)
hr
=
create_sink_writer_from_sink
(
sink
,
attributes
,
riid
,
out
);
...
...
dlls/mfreadwrite/writer.c
View file @
aaebf839
...
...
@@ -22,6 +22,8 @@
#include "mfapi.h"
#include "mfidl.h"
#include "mfreadwrite.h"
#include "pathcch.h"
#include "wine/mfinternal.h"
#include "mf_private.h"
#include "wine/debug.h"
...
...
@@ -196,32 +198,117 @@ HRESULT create_sink_writer_from_sink(IMFMediaSink *sink, IMFAttributes *attribut
return
hr
;
}
HRESULT
create_sink_writer_from_stream
(
IMFByteStream
*
stream
,
IMFAttributes
*
attributes
,
/***********************************************************************
* MFCreateSinkWriterFromMediaSink (mfreadwrite.@)
*/
HRESULT
WINAPI
MFCreateSinkWriterFromMediaSink
(
IMFMediaSink
*
sink
,
IMFAttributes
*
attributes
,
IMFSinkWriter
**
writer
)
{
TRACE
(
"%p, %p, %p.
\n
"
,
sink
,
attributes
,
writer
);
return
create_sink_writer_from_sink
(
sink
,
attributes
,
&
IID_IMFSinkWriter
,
(
void
**
)
writer
);
}
static
HRESULT
sink_writer_get_sink_factory_class
(
const
WCHAR
*
url
,
IMFAttributes
*
attributes
,
CLSID
*
clsid
)
{
static
const
struct
extension_map
{
const
WCHAR
*
ext
;
const
GUID
*
guid
;
}
ext_map
[]
=
{
{
L".mp4"
,
&
MFTranscodeContainerType_MPEG4
},
{
L".mp3"
,
&
MFTranscodeContainerType_MP3
},
{
L".wav"
,
&
MFTranscodeContainerType_WAVE
},
{
L".avi"
,
&
MFTranscodeContainerType_AVI
},
};
static
const
struct
{
const
GUID
*
container
;
const
CLSID
*
clsid
;
}
class_map
[]
=
{
{
&
MFTranscodeContainerType_MPEG4
,
&
CLSID_MFMPEG4SinkClassFactory
},
{
&
MFTranscodeContainerType_MP3
,
&
CLSID_MFMP3SinkClassFactory
},
{
&
MFTranscodeContainerType_WAVE
,
&
CLSID_MFWAVESinkClassFactory
},
{
&
MFTranscodeContainerType_AVI
,
&
CLSID_MFAVISinkClassFactory
},
};
const
WCHAR
*
extension
;
GUID
container
;
unsigned
int
i
;
if
(
url
)
{
if
(
!
attributes
||
FAILED
(
IMFAttributes_GetGUID
(
attributes
,
&
MF_TRANSCODE_CONTAINERTYPE
,
&
container
)))
{
const
struct
extension_map
*
map
=
NULL
;
if
(
FAILED
(
PathCchFindExtension
(
url
,
PATHCCH_MAX_CCH
,
&
extension
)))
return
E_INVALIDARG
;
if
(
!
extension
||
!*
extension
)
return
E_INVALIDARG
;
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
ext_map
);
++
i
)
{
map
=
&
ext_map
[
i
];
if
(
!
wcsicmp
(
map
->
ext
,
extension
))
break
;
}
if
(
!
map
)
{
WARN
(
"Couldn't find container type for extension %s.
\n
"
,
debugstr_w
(
extension
));
return
E_INVALIDARG
;
}
container
=
*
map
->
guid
;
}
}
else
{
if
(
!
attributes
)
return
E_INVALIDARG
;
if
(
FAILED
(
IMFAttributes_GetGUID
(
attributes
,
&
MF_TRANSCODE_CONTAINERTYPE
,
&
container
)))
return
E_INVALIDARG
;
}
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
class_map
);
++
i
)
{
if
(
IsEqualGUID
(
&
container
,
&
class_map
[
i
].
container
))
{
*
clsid
=
*
class_map
[
i
].
clsid
;
return
S_OK
;
}
}
WARN
(
"Couldn't find factory class for container %s.
\n
"
,
debugstr_guid
(
&
container
));
return
E_INVALIDARG
;
}
HRESULT
create_sink_writer_from_url
(
const
WCHAR
*
url
,
IMFByteStream
*
bytestream
,
IMFAttributes
*
attributes
,
REFIID
riid
,
void
**
out
)
{
struct
sink_writer
*
object
;
IMFSinkClassFactory
*
factory
;
IMFMediaSink
*
sink
;
CLSID
clsid
;
HRESULT
hr
;
object
=
malloc
(
sizeof
(
*
object
));
if
(
!
object
)
return
E_OUTOFMEMORY
;
if
(
FAILED
(
hr
=
sink_writer_get_sink_factory_class
(
url
,
attributes
,
&
clsid
)))
return
hr
;
object
->
IMFSinkWriter_iface
.
lpVtbl
=
&
sink_writer_vtbl
;
object
->
refcount
=
1
;
if
(
FAILED
(
hr
=
CoCreateInstance
(
&
clsid
,
NULL
,
CLSCTX_INPROC_SERVER
,
&
IID_IMFSinkClassFactory
,
(
void
**
)
&
factory
)))
{
WARN
(
"Failed to create a sink factory, hr %#lx.
\n
"
,
hr
);
return
hr
;
}
hr
=
IMFSinkWriter_QueryInterface
(
&
object
->
IMFSinkWriter_iface
,
riid
,
out
);
IMFSinkWriter_Release
(
&
object
->
IMFSinkWriter_iface
);
hr
=
IMFSinkClassFactory_CreateMediaSink
(
factory
,
bytestream
,
NULL
,
NULL
,
&
sink
);
IMFSinkClassFactory_Release
(
factory
);
if
(
FAILED
(
hr
))
{
WARN
(
"Failed to create a sink, hr %#lx.
\n
"
,
hr
);
return
hr
;
}
}
/***********************************************************************
* MFCreateSinkWriterFromMediaSink (mfreadwrite.@)
*/
HRESULT
WINAPI
MFCreateSinkWriterFromMediaSink
(
IMFMediaSink
*
sink
,
IMFAttributes
*
attributes
,
IMFSinkWriter
**
writer
)
{
TRACE
(
"%p, %p, %p.
\n
"
,
sink
,
attributes
,
writer
);
hr
=
create_sink_writer_from_sink
(
sink
,
attributes
,
riid
,
out
);
IMFMediaSink_Release
(
sink
);
return
create_sink_writer_from_sink
(
sink
,
attributes
,
&
IID_IMFSinkWriter
,
(
void
**
)
writer
)
;
return
hr
;
}
/***********************************************************************
...
...
@@ -230,7 +317,7 @@ HRESULT WINAPI MFCreateSinkWriterFromMediaSink(IMFMediaSink *sink, IMFAttributes
HRESULT
WINAPI
MFCreateSinkWriterFromURL
(
const
WCHAR
*
url
,
IMFByteStream
*
bytestream
,
IMFAttributes
*
attributes
,
IMFSinkWriter
**
writer
)
{
FIXM
E
(
"%s, %p, %p, %p.
\n
"
,
debugstr_w
(
url
),
bytestream
,
attributes
,
writer
);
TRAC
E
(
"%s, %p, %p, %p.
\n
"
,
debugstr_w
(
url
),
bytestream
,
attributes
,
writer
);
return
E_NOTIMPL
;
return
create_sink_writer_from_url
(
url
,
bytestream
,
attributes
,
&
IID_IMFSinkWriter
,
(
void
**
)
writer
)
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment