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
28f17d8e
Commit
28f17d8e
authored
Apr 23, 2020
by
Zebediah Figura
Committed by
Alexandre Julliard
Apr 24, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
qcap/filewriter: Implement sample processing.
Signed-off-by:
Zebediah Figura
<
z.figura12@gmail.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
439458af
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
90 additions
and
1 deletion
+90
-1
filewriter.c
dlls/qcap/filewriter.c
+26
-0
filewriter.c
dlls/qcap/tests/filewriter.c
+64
-1
No files found.
dlls/qcap/filewriter.c
View file @
28f17d8e
...
...
@@ -64,10 +64,36 @@ static HRESULT file_writer_sink_query_accept(struct strmbase_pin *iface, const A
return
S_OK
;
}
static
HRESULT
WINAPI
file_writer_sink_receive
(
struct
strmbase_sink
*
iface
,
IMediaSample
*
sample
)
{
struct
file_writer
*
filter
=
impl_from_strmbase_pin
(
&
iface
->
pin
);
REFERENCE_TIME
start
,
stop
;
LARGE_INTEGER
offset
;
HRESULT
hr
;
DWORD
size
;
BYTE
*
data
;
if
((
hr
=
IMediaSample_GetTime
(
sample
,
&
start
,
&
stop
))
!=
S_OK
)
ERR
(
"Failed to get sample time, hr %#x.
\n
"
,
hr
);
if
((
hr
=
IMediaSample_GetPointer
(
sample
,
&
data
))
!=
S_OK
)
ERR
(
"Failed to get sample pointer, hr %#x.
\n
"
,
hr
);
offset
.
QuadPart
=
start
;
if
(
!
SetFilePointerEx
(
filter
->
file
,
offset
,
NULL
,
FILE_BEGIN
)
||
!
WriteFile
(
filter
->
file
,
data
,
stop
-
start
,
&
size
,
NULL
))
ERR
(
"Failed to write file, error %u.
\n
"
,
GetLastError
());
if
(
size
!=
stop
-
start
)
ERR
(
"Short write, %u/%u.
\n
"
,
size
,
(
DWORD
)(
stop
-
start
));
return
S_OK
;
}
static
const
struct
strmbase_sink_ops
sink_ops
=
{
.
base
.
pin_query_interface
=
file_writer_sink_query_interface
,
.
base
.
pin_query_accept
=
file_writer_sink_query_accept
,
.
pfnReceive
=
file_writer_sink_receive
,
};
static
inline
struct
file_writer
*
impl_from_strmbase_filter
(
struct
strmbase_filter
*
iface
)
...
...
dlls/qcap/tests/filewriter.c
View file @
28f17d8e
...
...
@@ -549,7 +549,7 @@ static void test_allocator(IMemInputPin *input, IMemAllocator *allocator)
ok
(
hr
==
E_POINTER
,
"Got hr %#x.
\n
"
,
hr
);
props
.
cBuffers
=
1
;
props
.
cbBuffer
=
256
;
props
.
cbBuffer
=
512
;
props
.
cbAlign
=
512
;
props
.
cbPrefix
=
0
;
hr
=
IMemAllocator_SetProperties
(
allocator
,
&
props
,
&
ret_props
);
...
...
@@ -616,6 +616,68 @@ static void test_filter_state(IMediaControl *control)
ok
(
state
==
State_Stopped
,
"Got state %u.
\n
"
,
state
);
}
static
void
test_sample_processing
(
IMediaControl
*
control
,
IMemInputPin
*
input
,
IMemAllocator
*
allocator
,
const
WCHAR
*
filename
)
{
REFERENCE_TIME
start
,
stop
;
IMediaSample
*
sample
;
BYTE
buffer
[
600
];
FILE
*
file
;
HRESULT
hr
;
BYTE
*
data
;
LONG
size
;
hr
=
IMemInputPin_ReceiveCanBlock
(
input
);
ok
(
hr
==
S_OK
,
"Got hr %#x.
\n
"
,
hr
);
hr
=
IMediaControl_Pause
(
control
);
ok
(
hr
==
S_OK
,
"Got hr %#x.
\n
"
,
hr
);
hr
=
IMemAllocator_GetBuffer
(
allocator
,
&
sample
,
NULL
,
NULL
,
0
);
ok
(
hr
==
VFW_E_NOT_COMMITTED
,
"Got hr %#x.
\n
"
,
hr
);
hr
=
IMemAllocator_Commit
(
allocator
);
ok
(
hr
==
S_OK
,
"Got hr %#x.
\n
"
,
hr
);
hr
=
IMemAllocator_GetBuffer
(
allocator
,
&
sample
,
NULL
,
NULL
,
0
);
ok
(
hr
==
S_OK
,
"Got hr %#x.
\n
"
,
hr
);
hr
=
IMediaSample_GetPointer
(
sample
,
&
data
);
ok
(
hr
==
S_OK
,
"Got hr %#x.
\n
"
,
hr
);
size
=
IMediaSample_GetSize
(
sample
);
ok
(
size
==
512
,
"Got size %d.
\n
"
,
size
);
memset
(
data
,
0xcc
,
size
);
start
=
0
;
stop
=
512
;
hr
=
IMediaSample_SetTime
(
sample
,
&
start
,
&
stop
);
ok
(
hr
==
S_OK
,
"Got hr %#x.
\n
"
,
hr
);
strcpy
((
char
*
)
data
,
"abcdefghi"
);
hr
=
IMediaSample_SetActualDataLength
(
sample
,
9
);
ok
(
hr
==
S_OK
,
"Got hr %#x.
\n
"
,
hr
);
hr
=
IMemInputPin_Receive
(
input
,
sample
);
ok
(
hr
==
S_OK
,
"Got hr %#x.
\n
"
,
hr
);
memset
(
data
,
0xcc
,
size
);
strcpy
((
char
*
)
data
,
"123456"
);
hr
=
IMediaSample_SetActualDataLength
(
sample
,
6
);
ok
(
hr
==
S_OK
,
"Got hr %#x.
\n
"
,
hr
);
hr
=
IMemInputPin_Receive
(
input
,
sample
);
ok
(
hr
==
S_OK
,
"Got hr %#x.
\n
"
,
hr
);
file
=
_wfopen
(
filename
,
L"rb"
);
ok
(
!!
file
,
"Failed to open file: %s.
\n
"
,
strerror
(
errno
));
size
=
fread
(
buffer
,
1
,
sizeof
(
buffer
),
file
);
ok
(
size
==
512
,
"Got size %d.
\n
"
,
size
);
ok
(
!
memcmp
(
buffer
,
"123456
\0\xcc\xcc\xcc
"
,
10
),
"Got data %s.
\n
"
,
debugstr_an
((
char
*
)
buffer
,
size
));
fclose
(
file
);
hr
=
IMediaControl_Stop
(
control
);
ok
(
hr
==
S_OK
,
"Got hr %#x.
\n
"
,
hr
);
IMediaSample_Release
(
sample
);
}
static
void
test_connect_pin
(
void
)
{
AM_MEDIA_TYPE
req_mt
=
...
...
@@ -675,6 +737,7 @@ static void test_connect_pin(void)
test_allocator
(
meminput
,
allocator
);
test_filter_state
(
control
);
test_sample_processing
(
control
,
meminput
,
allocator
,
filename
);
hr
=
IFilterGraph2_Disconnect
(
graph
,
pin
);
ok
(
hr
==
S_OK
,
"Got hr %#x.
\n
"
,
hr
);
...
...
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