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
8143a575
Commit
8143a575
authored
Aug 22, 2023
by
Rémi Bernon
Committed by
Alexandre Julliard
Aug 23, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mf/scheme_handler: Implement http(s):// scheme handler using urlmon.
parent
70970429
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
83 additions
and
14 deletions
+83
-14
Makefile.in
dlls/mf/Makefile.in
+1
-1
main.c
dlls/mf/main.c
+2
-0
mf.idl
dlls/mf/mf.idl
+6
-0
mf.rgs
dlls/mf/mf.rgs
+8
-0
mf_private.h
dlls/mf/mf_private.h
+1
-0
scheme_handler.c
dlls/mf/scheme_handler.c
+64
-10
mf.c
dlls/mf/tests/mf.c
+1
-3
No files found.
dlls/mf/Makefile.in
View file @
8143a575
MODULE
=
mf.dll
IMPORTLIB
=
mf
IMPORTS
=
advapi32 mfplat ole32 uuid mfuuid strmiids
DELAYIMPORTS
=
evr user32
DELAYIMPORTS
=
evr u
rlmon u
ser32
EXTRADLLFLAGS
=
-Wb
,--prefer-native
...
...
dlls/mf/main.c
View file @
8143a575
...
...
@@ -549,6 +549,7 @@ static const IClassFactoryVtbl class_factory_vtbl =
};
static
struct
class_factory
file_scheme_handler_factory
=
{
{
&
class_factory_vtbl
},
file_scheme_handler_construct
};
static
struct
class_factory
urlmon_scheme_handler_factory
=
{
{
&
class_factory_vtbl
},
urlmon_scheme_handler_construct
};
static
const
struct
class_object
{
...
...
@@ -558,6 +559,7 @@ static const struct class_object
class_objects
[]
=
{
{
&
CLSID_FileSchemePlugin
,
&
file_scheme_handler_factory
.
IClassFactory_iface
},
{
&
CLSID_UrlmonSchemePlugin
,
&
urlmon_scheme_handler_factory
.
IClassFactory_iface
},
};
/*******************************************************************************
...
...
dlls/mf/mf.idl
View file @
8143a575
...
...
@@ -24,3 +24,9 @@
uuid
(
477
ec299
-
1421
-
4b
dd
-
971
f
-
7
ccb933f21ad
)
]
coclass
FileSchemePlugin
{
}
[
threading
(
both
),
uuid
(
9
ec4b4f9
-
3029
-
45
ad
-
947b
-
344
de2a249e2
)
]
coclass
UrlmonSchemePlugin
{}
dlls/mf/mf.rgs
View file @
8143a575
...
...
@@ -12,6 +12,14 @@ HKLM
{
val '{477ec299-1421-4bdd-971f-7ccb933f21ad}' = s 'File Scheme Handler'
}
'http:'
{
val '{9ec4b4f9-3029-45ad-947b-344de2a249e2}' = s 'Urlmon Scheme Handler'
}
'https:'
{
val '{9ec4b4f9-3029-45ad-947b-344de2a249e2}' = s 'Urlmon Scheme Handler'
}
}
}
}
...
...
dlls/mf/mf_private.h
View file @
8143a575
...
...
@@ -114,6 +114,7 @@ static inline const char *debugstr_propvar(const PROPVARIANT *v)
}
extern
HRESULT
file_scheme_handler_construct
(
REFIID
riid
,
void
**
obj
);
extern
HRESULT
urlmon_scheme_handler_construct
(
REFIID
riid
,
void
**
obj
);
extern
BOOL
mf_is_sample_copier_transform
(
IMFTransform
*
transform
);
extern
BOOL
mf_is_sar_sink
(
IMFMediaSink
*
sink
);
...
...
dlls/mf/scheme_handler.c
View file @
8143a575
...
...
@@ -32,6 +32,8 @@
WINE_DEFAULT_DEBUG_CHANNEL
(
mfplat
);
typedef
HRESULT
(
*
create_stream_cb
)(
const
WCHAR
*
url
,
DWORD
flags
,
IMFByteStream
**
out
);
struct
scheme_handler_result
{
struct
list
entry
;
...
...
@@ -48,6 +50,7 @@ struct scheme_handler
IMFSourceResolver
*
resolver
;
struct
list
results
;
CRITICAL_SECTION
cs
;
create_stream_cb
create_stream
;
};
static
struct
scheme_handler
*
impl_from_IMFSchemeHandler
(
IMFSchemeHandler
*
iface
)
...
...
@@ -374,7 +377,6 @@ static HRESULT scheme_handler_get_resolver(struct scheme_handler *handler, IMFSo
static
HRESULT
WINAPI
scheme_handler_callback_Invoke
(
IMFAsyncCallback
*
iface
,
IMFAsyncResult
*
result
)
{
static
const
WCHAR
schemeW
[]
=
{
'f'
,
'i'
,
'l'
,
'e'
,
':'
,
'/'
,
'/'
};
struct
scheme_handler
*
handler
=
impl_from_IMFAsyncCallback
(
iface
);
struct
scheme_handler_result
*
handler_result
;
MF_OBJECT_TYPE
obj_type
=
MF_OBJECT_INVALID
;
...
...
@@ -383,7 +385,6 @@ static HRESULT WINAPI scheme_handler_callback_Invoke(IMFAsyncCallback *iface, IM
IMFSourceResolver
*
resolver
;
IMFAsyncResult
*
caller
;
IMFByteStream
*
stream
;
const
WCHAR
*
url
;
HRESULT
hr
;
caller
=
(
IMFAsyncResult
*
)
IMFAsyncResult_GetStateNoAddRef
(
result
);
...
...
@@ -396,14 +397,7 @@ static HRESULT WINAPI scheme_handler_callback_Invoke(IMFAsyncCallback *iface, IM
context
=
impl_from_IUnknown
(
context_object
);
/* Strip from scheme, MFCreateFile() won't be expecting it. */
url
=
context
->
url
;
if
(
!
wcsnicmp
(
context
->
url
,
schemeW
,
ARRAY_SIZE
(
schemeW
)))
url
+=
ARRAY_SIZE
(
schemeW
);
hr
=
MFCreateFile
(
context
->
flags
&
MF_RESOLUTION_WRITE
?
MF_ACCESSMODE_READWRITE
:
MF_ACCESSMODE_READ
,
MF_OPENMODE_FAIL_IF_NOT_EXIST
,
MF_FILEFLAGS_NONE
,
url
,
&
stream
);
if
(
SUCCEEDED
(
hr
))
if
(
SUCCEEDED
(
hr
=
handler
->
create_stream
(
context
->
url
,
context
->
flags
,
&
stream
)))
{
if
(
context
->
flags
&
MF_RESOLUTION_MEDIASOURCE
)
{
...
...
@@ -458,6 +452,14 @@ static const IMFAsyncCallbackVtbl scheme_handler_callback_vtbl =
scheme_handler_callback_Invoke
,
};
static
HRESULT
file_stream_create
(
const
WCHAR
*
url
,
DWORD
flags
,
IMFByteStream
**
out
)
{
if
(
!
wcsnicmp
(
url
,
L"file://"
,
7
))
url
+=
7
;
return
MFCreateFile
(
flags
&
MF_RESOLUTION_WRITE
?
MF_ACCESSMODE_READWRITE
:
MF_ACCESSMODE_READ
,
MF_OPENMODE_FAIL_IF_NOT_EXIST
,
MF_FILEFLAGS_NONE
,
url
,
out
);
}
HRESULT
file_scheme_handler_construct
(
REFIID
riid
,
void
**
obj
)
{
struct
scheme_handler
*
handler
;
...
...
@@ -473,6 +475,58 @@ HRESULT file_scheme_handler_construct(REFIID riid, void **obj)
handler
->
refcount
=
1
;
list_init
(
&
handler
->
results
);
InitializeCriticalSection
(
&
handler
->
cs
);
handler
->
create_stream
=
file_stream_create
;
hr
=
IMFSchemeHandler_QueryInterface
(
&
handler
->
IMFSchemeHandler_iface
,
riid
,
obj
);
IMFSchemeHandler_Release
(
&
handler
->
IMFSchemeHandler_iface
);
return
hr
;
}
static
HRESULT
urlmon_stream_create
(
const
WCHAR
*
url
,
DWORD
flags
,
IMFByteStream
**
out
)
{
IMFAttributes
*
attributes
;
IStream
*
stream
;
HRESULT
hr
;
if
(
flags
&
MF_RESOLUTION_WRITE
)
return
E_INVALIDARG
;
if
(
FAILED
(
hr
=
URLOpenBlockingStreamW
(
NULL
,
url
,
&
stream
,
0
,
NULL
)))
{
WARN
(
"Failed to open url %s, hr %#lx
\n
"
,
debugstr_w
(
url
),
hr
);
return
hr
;
}
hr
=
MFCreateMFByteStreamOnStream
(
stream
,
out
);
IStream_Release
(
stream
);
if
(
FAILED
(
hr
))
return
hr
;
IMFByteStream_QueryInterface
(
*
out
,
&
IID_IMFAttributes
,
(
void
**
)
&
attributes
);
IMFAttributes_DeleteItem
(
attributes
,
&
MF_BYTESTREAM_ORIGIN_NAME
);
IMFAttributes_SetString
(
attributes
,
&
MF_BYTESTREAM_EFFECTIVE_URL
,
url
);
IMFAttributes_SetString
(
attributes
,
&
MF_BYTESTREAM_CONTENT_TYPE
,
L"application/octet-stream"
);
IMFAttributes_Release
(
attributes
);
return
hr
;
}
HRESULT
urlmon_scheme_handler_construct
(
REFIID
riid
,
void
**
obj
)
{
struct
scheme_handler
*
handler
;
HRESULT
hr
;
TRACE
(
"%s, %p.
\n
"
,
debugstr_guid
(
riid
),
obj
);
if
(
!
(
handler
=
calloc
(
1
,
sizeof
(
*
handler
))))
return
E_OUTOFMEMORY
;
handler
->
IMFSchemeHandler_iface
.
lpVtbl
=
&
scheme_handler_vtbl
;
handler
->
IMFAsyncCallback_iface
.
lpVtbl
=
&
scheme_handler_callback_vtbl
;
handler
->
refcount
=
1
;
list_init
(
&
handler
->
results
);
InitializeCriticalSection
(
&
handler
->
cs
);
handler
->
create_stream
=
urlmon_stream_create
;
hr
=
IMFSchemeHandler_QueryInterface
(
&
handler
->
IMFSchemeHandler_iface
,
riid
,
obj
);
IMFSchemeHandler_Release
(
&
handler
->
IMFSchemeHandler_iface
);
...
...
dlls/mf/tests/mf.c
View file @
8143a575
...
...
@@ -6472,7 +6472,7 @@ static void test_scheme_resolvers(void)
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
urls
);
i
++
)
{
hr
=
IMFSourceResolver_CreateObjectFromURL
(
resolver
,
urls
[
i
],
MF_RESOLUTION_BYTESTREAM
,
NULL
,
&
type
,
&
object
);
todo_wine
todo_wine
_if
(
i
>=
2
)
ok
(
hr
==
S_OK
,
"got hr %#lx
\n
"
,
hr
);
if
(
hr
!=
S_OK
)
continue
;
...
...
@@ -6485,7 +6485,6 @@ static void test_scheme_resolvers(void)
PropVariantInit
(
&
propvar
);
hr
=
IMFAttributes_GetItem
(
attributes
,
&
MF_BYTESTREAM_EFFECTIVE_URL
,
&
propvar
);
ok
(
hr
==
S_OK
||
broken
(
hr
==
MF_E_ATTRIBUTENOTFOUND
)
/* Win7 */
,
"got hr %#lx
\n
"
,
hr
);
todo_wine
ok
(
!
wcsncmp
(
expect_domain
[
i
],
propvar
.
pwszVal
,
wcslen
(
expect_domain
[
i
]))
||
broken
(
hr
==
MF_E_ATTRIBUTENOTFOUND
)
/* Win7 */
,
"got url %s
\n
"
,
debugstr_w
(
propvar
.
pwszVal
));
...
...
@@ -6493,7 +6492,6 @@ static void test_scheme_resolvers(void)
ok
(
hr
==
S_OK
,
"got hr %#lx
\n
"
,
hr
);
hr
=
IMFAttributes_GetItem
(
attributes
,
&
MF_BYTESTREAM_CONTENT_TYPE
,
NULL
);
todo_wine
ok
(
hr
==
S_OK
,
"got hr %#lx
\n
"
,
hr
);
hr
=
IMFAttributes_GetItem
(
attributes
,
&
MF_BYTESTREAM_LAST_MODIFIED_TIME
,
NULL
);
todo_wine
...
...
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