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
a5fe3d65
Commit
a5fe3d65
authored
Mar 25, 2019
by
Nikolay Sivov
Committed by
Alexandre Julliard
Mar 25, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mfreadwrite: Set url hint from stream content.
Signed-off-by:
Nikolay Sivov
<
nsivov@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
0319a2dd
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
71 additions
and
1 deletion
+71
-1
main.c
dlls/mfreadwrite/main.c
+71
-1
No files found.
dlls/mfreadwrite/main.c
View file @
a5fe3d65
...
@@ -576,6 +576,71 @@ failed:
...
@@ -576,6 +576,71 @@ failed:
return
hr
;
return
hr
;
}
}
static
HRESULT
bytestream_get_url_hint
(
IMFByteStream
*
stream
,
WCHAR
const
**
url
)
{
static
const
UINT8
asfmagic
[]
=
{
0x30
,
0x26
,
0xb2
,
0x75
,
0x8e
,
0x66
,
0xcf
,
0x11
,
0xa6
,
0xd9
,
0x00
,
0xaa
,
0x00
,
0x62
,
0xce
,
0x6c
};
static
const
WCHAR
asfW
[]
=
{
'.'
,
'a'
,
's'
,
'f'
,
0
};
static
const
struct
stream_content_url_hint
{
const
UINT8
*
magic
;
UINT32
magic_len
;
const
WCHAR
*
url
;
}
url_hints
[]
=
{
{
asfmagic
,
sizeof
(
asfmagic
),
asfW
},
};
IMFAttributes
*
attributes
;
UINT32
length
=
0
;
UINT8
buffer
[
16
];
DWORD
caps
=
0
;
QWORD
position
;
unsigned
int
i
;
HRESULT
hr
;
*
url
=
NULL
;
if
(
SUCCEEDED
(
IMFByteStream_QueryInterface
(
stream
,
&
IID_IMFAttributes
,
(
void
**
)
&
attributes
)))
{
IMFAttributes_GetStringLength
(
attributes
,
&
MF_BYTESTREAM_CONTENT_TYPE
,
&
length
);
IMFAttributes_Release
(
attributes
);
}
if
(
length
)
return
S_OK
;
if
(
FAILED
(
hr
=
IMFByteStream_GetCapabilities
(
stream
,
&
caps
)))
return
hr
;
if
(
!
(
caps
&
MFBYTESTREAM_IS_SEEKABLE
))
return
S_OK
;
if
(
FAILED
(
hr
=
IMFByteStream_GetCurrentPosition
(
stream
,
&
position
)))
return
hr
;
hr
=
IMFByteStream_Read
(
stream
,
buffer
,
sizeof
(
buffer
),
&
length
);
IMFByteStream_SetCurrentPosition
(
stream
,
position
);
if
(
FAILED
(
hr
))
return
hr
;
if
(
length
<
sizeof
(
buffer
))
return
S_OK
;
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
url_hints
);
++
i
)
{
if
(
!
memcmp
(
buffer
,
url_hints
[
i
].
magic
,
min
(
url_hints
[
i
].
magic_len
,
length
)))
{
*
url
=
url_hints
[
i
].
url
;
break
;
}
}
if
(
!*
url
)
WARN
(
"Unrecognized content type %s.
\n
"
,
debugstr_an
((
char
*
)
buffer
,
length
));
return
S_OK
;
}
static
HRESULT
create_source_reader_from_stream
(
IMFByteStream
*
stream
,
IMFAttributes
*
attributes
,
static
HRESULT
create_source_reader_from_stream
(
IMFByteStream
*
stream
,
IMFAttributes
*
attributes
,
REFIID
riid
,
void
**
out
)
REFIID
riid
,
void
**
out
)
{
{
...
@@ -583,8 +648,13 @@ static HRESULT create_source_reader_from_stream(IMFByteStream *stream, IMFAttrib
...
@@ -583,8 +648,13 @@ static HRESULT create_source_reader_from_stream(IMFByteStream *stream, IMFAttrib
IMFSourceResolver
*
resolver
;
IMFSourceResolver
*
resolver
;
MF_OBJECT_TYPE
obj_type
;
MF_OBJECT_TYPE
obj_type
;
IMFMediaSource
*
source
;
IMFMediaSource
*
source
;
const
WCHAR
*
url
;
HRESULT
hr
;
HRESULT
hr
;
/* If stream does not have content type set, try to guess from starting byte sequence. */
if
(
FAILED
(
hr
=
bytestream_get_url_hint
(
stream
,
&
url
)))
return
hr
;
if
(
FAILED
(
hr
=
MFCreateSourceResolver
(
&
resolver
)))
if
(
FAILED
(
hr
=
MFCreateSourceResolver
(
&
resolver
)))
return
hr
;
return
hr
;
...
@@ -592,7 +662,7 @@ static HRESULT create_source_reader_from_stream(IMFByteStream *stream, IMFAttrib
...
@@ -592,7 +662,7 @@ static HRESULT create_source_reader_from_stream(IMFByteStream *stream, IMFAttrib
IMFAttributes_GetUnknown
(
attributes
,
&
MF_SOURCE_READER_MEDIASOURCE_CONFIG
,
&
IID_IPropertyStore
,
IMFAttributes_GetUnknown
(
attributes
,
&
MF_SOURCE_READER_MEDIASOURCE_CONFIG
,
&
IID_IPropertyStore
,
(
void
**
)
&
props
);
(
void
**
)
&
props
);
hr
=
IMFSourceResolver_CreateObjectFromByteStream
(
resolver
,
stream
,
NULL
,
MF_RESOLUTION_MEDIASOURCE
,
props
,
hr
=
IMFSourceResolver_CreateObjectFromByteStream
(
resolver
,
stream
,
url
,
MF_RESOLUTION_MEDIASOURCE
,
props
,
&
obj_type
,
(
IUnknown
**
)
&
source
);
&
obj_type
,
(
IUnknown
**
)
&
source
);
IMFSourceResolver_Release
(
resolver
);
IMFSourceResolver_Release
(
resolver
);
if
(
props
)
if
(
props
)
...
...
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