Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
53f6d534
Commit
53f6d534
authored
Aug 24, 2009
by
Pierre d'Herbemont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test: Expanded and passing media_list_player queue item tests.
parent
bd90c7fd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
132 additions
and
31 deletions
+132
-31
test/Makefile.am
test/Makefile.am
+6
-1
test/libvlc/libvlc_additions.h
test/libvlc/libvlc_additions.h
+54
-0
test/libvlc/media_list_player.c
test/libvlc/media_list_player.c
+72
-30
No files found.
test/Makefile.am
View file @
53f6d534
...
...
@@ -4,6 +4,11 @@
AUTOMAKE_OPTIONS
=
subdir-objects
extra_check_verbose
=
$
(
extra_check_verbose_
$(V)
)
extra_check_verbose_
=
$
(
extra_check_flags__
$(AM_DEFAULT_VERBOSITY)
)
extra_check_verbose_0
=
@echo TEST
$@
extra_check_verbose__0
=
$(extra_check_verbose_0)
###############################################################################
# Unit/regression test
###############################################################################
...
...
@@ -26,7 +31,7 @@ EXTRA_PROGRAMS = \
#check_DATA = samples/test.sample samples/meta.sample
EXTRA_DIST
=
samples/empty.voc
check_HEADERS
=
libvlc/test.h
check_HEADERS
=
libvlc/test.h
libvlc/libvlc_additions.h
TESTS
=
$(check_PROGRAMS)
...
...
test/libvlc/libvlc_additions.h
0 → 100644
View file @
53f6d534
/*
* libvlc_additions.c - Some helper method that should probably go into libvlc
*/
/**********************************************************************
* Copyright (C) 2007 Rémi Denis-Courmont. *
* This program is free software; you can redistribute and/or modify *
* it under the terms of the GNU General Public License as published *
* by the Free Software Foundation; version 2 of the license, or (at *
* your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, you can get it from: *
* http://www.gnu.org/copyleft/gpl.html *
**********************************************************************/
static
void
*
media_list_add_file_path
(
libvlc_instance_t
*
vlc
,
libvlc_media_list_t
*
ml
,
const
char
*
file_path
)
{
libvlc_media_t
*
md
=
libvlc_media_new
(
vlc
,
file_path
,
&
ex
);
catch
();
libvlc_media_list_add_media
(
ml
,
md
,
&
ex
);
catch
();
libvlc_media_release
(
md
);
return
md
;
}
static
libvlc_media_list_player_t
*
media_list_player_with_root_media
(
libvlc_instance_t
*
vlc
,
libvlc_media_t
*
m
)
{
libvlc_media_list_t
*
ml
;
libvlc_media_list_player_t
*
mlp
;
libvlc_exception_init
(
&
ex
);
ml
=
libvlc_media_list_new
(
vlc
,
&
ex
);
catch
();
mlp
=
libvlc_media_list_player_new
(
vlc
,
&
ex
);
libvlc_media_list_add_media
(
ml
,
m
,
&
ex
);
catch
();
libvlc_media_list_player_set_media_list
(
mlp
,
ml
,
&
ex
);
catch
();
return
mlp
;
}
test/libvlc/media_list_player.c
View file @
53f6d534
...
...
@@ -27,33 +27,59 @@
#include <vlc_common.h>
#include <vlc_mtime.h>
static
void
*
media_list_add_file_path
(
libvlc_instance_t
*
vlc
,
libvlc_media_list_t
*
ml
,
const
char
*
file_path
)
{
libvlc_media_t
*
md
=
libvlc_media_new
(
vlc
,
file_path
,
&
ex
);
catch
();
#include "libvlc_additions.h"
libvlc_media_list_add_media
(
ml
,
md
,
&
ex
);
catch
();
struct
check_items_order_data
{
bool
done_playing
;
unsigned
count
;
unsigned
index
;
void
*
items
[
16
];
};
libvlc_media_release
(
md
);
return
md
;
static
inline
void
check_data_init
(
struct
check_items_order_data
*
check
)
{
check
->
index
=
0
;
check
->
count
=
0
;
check
->
done_playing
=
false
;
}
static
inline
void
queue_expected_item
(
struct
check_items_order_data
*
check
,
void
*
item
)
{
assert
(
check
->
count
<
16
);
check
->
items
[
check
->
count
]
=
item
;
check
->
count
++
;
}
static
bool
done_playing
=
false
;
static
const
unsigned
items_count
=
4
;
static
void
*
items
[
4
];
static
unsigned
current_index
=
0
;
static
inline
void
wait_queued_items
(
struct
check_items_order_data
*
check
)
{
// Wait dummily for check_items_order_callback() to flag 'done_playing':
while
(
!
check
->
done_playing
)
msleep
(
100000
);
}
static
void
next_item
_callback
(
const
libvlc_event_t
*
p_event
,
void
*
user_data
)
static
void
check_items_order
_callback
(
const
libvlc_event_t
*
p_event
,
void
*
user_data
)
{
(
void
)
user_data
;
struct
check_items_order_data
*
checks
=
user_data
;
libvlc_media_t
*
md
=
p_event
->
u
.
media_list_player_next_item_set
.
item
;
current_index
++
;
assert
(
current_index
<
items_count
);
assert
(
items
[
current_index
]
==
md
);
log
(
"Item %d was correctly queued
\n
"
,
current_index
);
if
(
current_index
==
(
items_count
-
1
))
done_playing
=
true
;
assert
(
checks
->
index
<
checks
->
count
);
if
(
checks
->
items
[
checks
->
index
]
!=
md
)
{
char
*
title
=
libvlc_media_get_meta
(
md
,
libvlc_meta_Title
,
NULL
);
log
(
"Got items %s
\n
"
,
title
);
free
(
title
);
}
assert
(
checks
->
items
[
checks
->
index
]
==
md
);
char
*
title
=
libvlc_media_get_meta
(
md
,
libvlc_meta_Title
,
NULL
);
log
(
"Item %d '%s' was correctly queued
\n
"
,
checks
->
index
,
title
);
free
(
title
);
if
(
checks
->
index
==
(
checks
->
count
-
1
))
{
log
(
"Done playing with success
\n
"
);
checks
->
done_playing
=
true
;
}
checks
->
index
++
;
}
static
void
test_media_list_player_items_queue
(
const
char
**
argv
,
int
argc
)
...
...
@@ -82,26 +108,42 @@ static void test_media_list_player_items_queue(const char** argv, int argc)
libvlc_media_list_add_media
(
ml
,
md
,
&
ex
);
catch
();
items
[
0
]
=
md
;
static
struct
check_items_order_data
check
;
check_data_init
(
&
check
);
queue_expected_item
(
&
check
,
md
);
// Add three more media
items
[
1
]
=
media_list_add_file_path
(
vlc
,
ml
,
file
);
items
[
2
]
=
media_list_add_file_path
(
vlc
,
ml
,
file
);
items
[
3
]
=
media_list_add_file_path
(
vlc
,
ml
,
file
);
queue_expected_item
(
&
check
,
media_list_add_file_path
(
vlc
,
ml
,
file
));
queue_expected_item
(
&
check
,
media_list_add_file_path
(
vlc
,
ml
,
file
));
queue_expected_item
(
&
check
,
media_list_add_file_path
(
vlc
,
ml
,
file
));
// Add a node
libvlc_media_t
*
node
=
libvlc_media_new_as_node
(
vlc
,
"node"
,
&
ex
);
catch
();
libvlc_media_list_add_media
(
ml
,
node
,
&
ex
);
catch
();
queue_expected_item
(
&
check
,
node
);
// Add items to that node
libvlc_media_list_t
*
subitems
=
libvlc_media_subitems
(
node
,
&
ex
);
catch
();
queue_expected_item
(
&
check
,
media_list_add_file_path
(
vlc
,
subitems
,
file
));
queue_expected_item
(
&
check
,
media_list_add_file_path
(
vlc
,
subitems
,
file
));
queue_expected_item
(
&
check
,
media_list_add_file_path
(
vlc
,
subitems
,
file
));
libvlc_media_list_release
(
subitems
);
libvlc_media_list_player_set_media_list
(
mlp
,
ml
,
&
ex
);
libvlc_event_manager_t
*
em
=
libvlc_media_list_player_event_manager
(
mlp
);
libvlc_event_attach
(
em
,
libvlc_MediaListPlayerNextItemSet
,
next_item_callback
,
NULL
,
&
ex
);
libvlc_event_attach
(
em
,
libvlc_MediaListPlayerNextItemSet
,
check_items_order_callback
,
&
check
,
&
ex
);
catch
();
libvlc_media_list_player_play
_item
(
mlp
,
md
,
&
ex
);
libvlc_media_list_player_play
(
mlp
,
&
ex
);
catch
();
// Wait dummily for next_item_callback() to flag 'done_playing':
while
(
!
done_playing
)
msleep
(
100000
);
// Wait until all item are read
wait_queued_items
(
&
check
);
libvlc_media_list_player_stop
(
mlp
,
&
ex
);
catch
();
...
...
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