Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
mediastreamer2
Commits
c45dca7b
Commit
c45dca7b
authored
Oct 15, 2014
by
François Grisez
Browse files
Implement seeking in the mkv filter
parent
8ae28e84
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
12 deletions
+32
-12
src/videofilters/mkv.c
src/videofilters/mkv.c
+17
-1
tester/mediastreamer2_player_tester.c
tester/mediastreamer2_player_tester.c
+15
-11
No files found.
src/videofilters/mkv.c
View file @
c45dca7b
...
...
@@ -2365,7 +2365,23 @@ static int player_close(MSFilter *f, void *arg) {
}
static
int
player_seek_ms
(
MSFilter
*
f
,
void
*
arg
)
{
ms_error
(
"Seeking is not implemented for the MKV player yet"
);
MKVPlayer
*
obj
=
(
MKVPlayer
*
)
f
->
data
;
timecode_t
target_position
=
*
((
int
*
)
arg
);
ms_bool_t
eof
;
ms_filter_lock
(
f
);
if
(
target_position
<
0
||
target_position
>
matroska_get_duration
(
&
obj
->
file
))
{
ms_error
(
"MKVPlayer: cannot seek to %ld ms. Poisition out of bounds"
,
target_position
);
goto
fail
;
}
matroska_block_go_first
(
&
obj
->
file
);
while
(
matroska_block_get_timestamp
(
&
obj
->
file
)
<
target_position
)
{
matroska_block_go_next
(
&
obj
->
file
,
&
eof
);
}
ms_filter_unlock
(
f
);
return
0
;
fail:
ms_filter_unlock
(
f
);
return
-
1
;
}
...
...
tester/mediastreamer2_player_tester.c
View file @
c45dca7b
...
...
@@ -42,7 +42,7 @@ static void wait_for_eof(Eof *obj, int refresh_time_ms, int timeout_ms) {
ms_mutex_unlock
(
&
obj
->
mutex
);
}
static
void
play_file
(
const
char
*
filepath
,
bool_t
unsupported_format
)
{
static
void
play_file
(
const
char
*
filepath
,
bool_t
unsupported_format
,
bool_t
seeking_test
,
int
timeout
)
{
bool_t
succeed
;
Eof
eof
;
MSFilePlayer
*
file_player
=
NULL
;
...
...
@@ -71,8 +71,12 @@ static void play_file(const char *filepath, bool_t unsupported_format) {
succeed
=
ms_file_player_start
(
file_player
);
CU_ASSERT_TRUE
(
succeed
);
if
(
seeking_test
)
{
CU_ASSERT_TRUE
(
ms_file_player_seek
(
file_player
,
5000
));
}
if
(
succeed
)
{
wait_for_eof
(
&
eof
,
100
,
20000
);
wait_for_eof
(
&
eof
,
100
,
timeout
);
}
ms_file_player_close
(
file_player
);
...
...
@@ -81,31 +85,31 @@ static void play_file(const char *filepath, bool_t unsupported_format) {
}
static
void
play_hello_8000_wav
(
void
)
{
play_file
(
"./sounds/hello8000.wav"
,
FALSE
);
play_file
(
"./sounds/hello8000.wav"
,
FALSE
,
FALSE
,
20000
);
}
static
void
play_hello_16000_wav
(
void
)
{
play_file
(
"./sounds/hello16000.wav"
,
FALSE
);
play_file
(
"./sounds/hello16000.wav"
,
FALSE
,
FALSE
,
20000
);
}
static
void
play_hello_pcmu_mka
(
void
)
{
play_file
(
"./sounds/hello_pcmu.mka"
,
!
ms_file_player_matroska_supported
());
play_file
(
"./sounds/hello_pcmu.mka"
,
!
ms_file_player_matroska_supported
()
,
FALSE
,
20000
);
}
static
void
play_hello_opus_mka
(
void
)
{
play_file
(
"./sounds/hello_opus.mka"
,
!
ms_file_player_matroska_supported
());
play_file
(
"./sounds/hello_opus.mka"
,
!
ms_file_player_matroska_supported
()
,
FALSE
,
20000
);
}
static
void
play_hello_pcmu_h264_mkv
(
void
)
{
play_file
(
"./sounds/hello_pcmu_h264.mkv"
,
!
ms_file_player_matroska_supported
());
play_file
(
"./sounds/hello_pcmu_h264.mkv"
,
!
ms_file_player_matroska_supported
()
,
FALSE
,
20000
);
}
static
void
play_hello_opus_h264_mkv
(
void
)
{
play_file
(
"./sounds/hello_opus_h264.mkv"
,
!
ms_file_player_matroska_supported
());
play_file
(
"./sounds/hello_opus_h264.mkv"
,
!
ms_file_player_matroska_supported
()
,
FALSE
,
20000
);
}
static
void
play_sintel
(
void
)
{
play_file
(
"./sounds/
sintel
.mkv"
,
!
ms_file_player_matroska_supported
());
static
void
seeking_test
(
void
)
{
play_file
(
"./sounds/
hello_opus_h264
.mkv"
,
!
ms_file_player_matroska_supported
()
,
TRUE
,
15000
);
}
static
test_t
tests
[]
=
{
...
...
@@ -115,7 +119,7 @@ static test_t tests[] = {
{
"Play hello_opus.mka"
,
play_hello_opus_mka
},
{
"Play hello_pcmu_h264.mkv"
,
play_hello_pcmu_h264_mkv
},
{
"Play hello_opus_h264.mkv"
,
play_hello_opus_h264_mkv
},
{
"
Play sintel"
,
play_sintel
}
{
"
Seeking"
,
seeking_test
}
};
test_suite_t
player_test_suite
=
{
...
...
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