summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim@centricular.com>2015-12-05 11:12:33 +0000
committerJan Schmidt <jan@centricular.com>2016-08-03 23:49:54 +1000
commit4df6f1ee930af0ec7961ade57e21bd904f199fa9 (patch)
tree42493574a75aa8b8db886b712e4bcbb0029c5892 /tests
parentf0fcf1d71895a1defa545bc844dcd603d1cafdb5 (diff)
hlsdemux: move variant list handling over to new master playlist code
Adapt hlsdemux for the m3u8 playlist changes.
Diffstat (limited to 'tests')
-rw-r--r--tests/check/elements/hlsdemux_m3u8.c378
1 files changed, 196 insertions, 182 deletions
diff --git a/tests/check/elements/hlsdemux_m3u8.c b/tests/check/elements/hlsdemux_m3u8.c
index f49e90184..02f50f1a6 100644
--- a/tests/check/elements/hlsdemux_m3u8.c
+++ b/tests/check/elements/hlsdemux_m3u8.c
@@ -322,44 +322,41 @@ http://example.com/hi.m3u8\r\n\
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=65000,CODECS=\"mp4a.40.5\"\r\n\
http://example.com/audio-only.m3u8";
-static GstM3U8Client *
+static GstHLSMasterPlaylist *
load_playlist (const gchar * data)
{
- gboolean ret;
- GstM3U8Client *client;
+ GstHLSMasterPlaylist *master;
- client = gst_m3u8_client_new ("http://localhost/test.m3u8", NULL);
- ret = gst_m3u8_client_update (client, g_strdup (data));
- assert_equals_int (ret, TRUE);
+ master = gst_hls_master_playlist_new_from_data (g_strdup (data),
+ "http://localhost/test.m3u8");
+ fail_unless (master != NULL);
- return client;
+ return master;
}
GST_START_TEST (test_load_main_playlist_invalid)
{
- gboolean ret;
- GstM3U8Client *client =
- gst_m3u8_client_new ("http://localhost/test.m3u8", NULL);
-
- ret = gst_m3u8_client_update (client, g_strdup (INVALID_PLAYLIST));
- assert_equals_int (ret, FALSE);
+ GstHLSMasterPlaylist *master;
- gst_m3u8_client_free (client);
+ master =
+ gst_hls_master_playlist_new_from_data (g_strdup (INVALID_PLAYLIST), NULL);
+ fail_unless (master == NULL);
}
GST_END_TEST;
GST_START_TEST (test_load_main_playlist_rendition)
{
- GstM3U8Client *client;
+ GstHLSMasterPlaylist *master;
+ GstHLSVariantStream *variant;
- client = load_playlist (ON_DEMAND_PLAYLIST);
+ master = load_playlist (ON_DEMAND_PLAYLIST);
+ variant = master->default_variant;
- assert_equals_int (g_list_length (client->main->files), 4);
- assert_equals_int (g_list_length (client->current->files), 4);
- assert_equals_int (client->sequence, 0);
+ assert_equals_int (g_list_length (variant->m3u8->files), 4);
+ assert_equals_int (master->version, 0);
- gst_m3u8_client_free (client);
+ gst_hls_master_playlist_unref (master);
}
GST_END_TEST;
@@ -367,17 +364,18 @@ GST_END_TEST;
static void
do_test_load_main_playlist_variant (const gchar * playlist)
{
- GstM3U8Client *client;
- GstM3U8 *stream;
+ GstHLSMasterPlaylist *master;
+ GstHLSVariantStream *stream;
GList *tmp;
- client = load_playlist (playlist);
+ master = gst_hls_master_playlist_new_from_data (g_strdup (playlist), NULL);
+ fail_unless (master != NULL);
- assert_equals_int (g_list_length (client->main->lists), 4);
+ assert_equals_int (g_list_length (master->variants), 4);
/* Audio-Only */
- tmp = g_list_first (client->main->lists);
- stream = GST_M3U8 (tmp->data);
+ tmp = g_list_first (master->variants);
+ stream = tmp->data;
assert_equals_int (stream->bandwidth, 65000);
assert_equals_int (stream->program_id, 1);
assert_equals_string (stream->uri, "http://example.com/audio-only.m3u8");
@@ -385,30 +383,30 @@ do_test_load_main_playlist_variant (const gchar * playlist)
/* Low */
tmp = g_list_next (tmp);
- stream = GST_M3U8 (tmp->data);
+ stream = tmp->data;
assert_equals_int (stream->bandwidth, 128000);
assert_equals_int (stream->program_id, 1);
assert_equals_string (stream->uri, "http://example.com/low.m3u8");
/* Mid */
tmp = g_list_next (tmp);
- stream = GST_M3U8 (tmp->data);
+ stream = tmp->data;
assert_equals_int (stream->bandwidth, 256000);
assert_equals_int (stream->program_id, 1);
assert_equals_string (stream->uri, "http://example.com/mid.m3u8");
/* High */
tmp = g_list_next (tmp);
- stream = GST_M3U8 (tmp->data);
+ stream = tmp->data;
assert_equals_int (stream->bandwidth, 768000);
assert_equals_int (stream->program_id, 1);
assert_equals_string (stream->uri, "http://example.com/hi.m3u8");
/* Check the first playlist is selected */
- assert_equals_int (client->current != NULL, TRUE);
- assert_equals_int (client->current->bandwidth, 128000);
+ assert_equals_int (master->default_variant != NULL, TRUE);
+ assert_equals_int (master->default_variant->bandwidth, 128000);
- gst_m3u8_client_free (client);
+ gst_hls_master_playlist_unref (master);
}
GST_START_TEST (test_load_main_playlist_variant)
@@ -420,11 +418,11 @@ GST_END_TEST;
GST_START_TEST (test_load_main_playlist_variant_with_missing_uri)
{
- GstM3U8Client *client;
+ GstHLSMasterPlaylist *master;
- client = load_playlist (VARIANT_PLAYLIST_WITH_URI_MISSING);
- assert_equals_int (g_list_length (client->main->lists), 3);
- gst_m3u8_client_free (client);
+ master = load_playlist (VARIANT_PLAYLIST_WITH_URI_MISSING);
+ assert_equals_int (g_list_length (master->variants), 3);
+ gst_hls_master_playlist_unref (master);
}
GST_END_TEST;
@@ -453,17 +451,17 @@ GST_END_TEST;
static void
check_on_demand_playlist (const gchar * data)
{
- GstM3U8Client *client;
+ GstHLSMasterPlaylist *master;
GstM3U8 *pl;
GstM3U8MediaFile *file;
- client = load_playlist (data);
- pl = client->current;
+ master = load_playlist (data);
+ pl = master->default_variant->m3u8;
/* Sequence should be 0 as it's an ondemand playlist */
- assert_equals_int (client->sequence, 0);
+ assert_equals_int (pl->sequence, 0);
/* Check that we are not live */
- assert_equals_int (gst_m3u8_client_is_live (client), FALSE);
+ assert_equals_int (gst_m3u8_is_live (pl), FALSE);
/* Check number of entries */
assert_equals_int (g_list_length (pl->files), 4);
/* Check first media segments */
@@ -475,7 +473,7 @@ check_on_demand_playlist (const gchar * data)
assert_equals_string (file->uri, "http://media.example.com/004.ts");
assert_equals_int (file->sequence, 3);
- gst_m3u8_client_free (client);
+ gst_hls_master_playlist_unref (master);
}
GST_START_TEST (test_on_demand_playlist)
@@ -508,18 +506,18 @@ GST_END_TEST;
GST_START_TEST (test_live_playlist)
{
- GstM3U8Client *client;
+ GstHLSMasterPlaylist *master;
GstM3U8 *pl;
GstM3U8MediaFile *file;
gint64 start = -1;
gint64 stop = -1;
- client = load_playlist (LIVE_PLAYLIST);
+ master = load_playlist (LIVE_PLAYLIST);
- pl = client->current;
+ pl = master->default_variant->m3u8;
/* Check that we are live */
- assert_equals_int (gst_m3u8_client_is_live (client), TRUE);
- assert_equals_int (client->sequence, 2681);
+ assert_equals_int (gst_m3u8_is_live (pl), TRUE);
+ assert_equals_int (pl->sequence, 2681);
/* Check number of entries */
assert_equals_int (g_list_length (pl->files), 4);
/* Check first media segments */
@@ -532,11 +530,11 @@ GST_START_TEST (test_live_playlist)
assert_equals_string (file->uri,
"https://priv.example.com/fileSequence2683.ts");
assert_equals_int (file->sequence, 2683);
- fail_unless (gst_m3u8_client_get_seek_range (client, &start, &stop));
+ fail_unless (gst_m3u8_get_seek_range (pl, &start, &stop));
assert_equals_int64 (start, 0);
assert_equals_float (stop / (double) GST_SECOND, 16.0);
- gst_m3u8_client_free (client);
+ gst_hls_master_playlist_unref (master);
}
GST_END_TEST;
@@ -546,44 +544,45 @@ GST_END_TEST;
* there is a jump in the media sequence that must be handled correctly. */
GST_START_TEST (test_live_playlist_rotated)
{
- GstM3U8Client *client;
+ GstHLSMasterPlaylist *master;
GstM3U8 *pl;
GstM3U8MediaFile *file;
gboolean ret;
- client = load_playlist (LIVE_PLAYLIST);
- pl = client->current;
- assert_equals_int (client->sequence, 2681);
+ master = load_playlist (LIVE_PLAYLIST);
+ pl = master->default_variant->m3u8;
+
+ assert_equals_int (pl->sequence, 2681);
/* Check first media segments */
file = GST_M3U8_MEDIA_FILE (g_list_first (pl->files)->data);
assert_equals_int (file->sequence, 2680);
- ret = gst_m3u8_client_update (client, g_strdup (LIVE_ROTATED_PLAYLIST));
+ ret = gst_m3u8_update (pl, g_strdup (LIVE_ROTATED_PLAYLIST));
assert_equals_int (ret, TRUE);
- gst_m3u8_client_get_next_fragment (client, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, TRUE);
+ gst_m3u8_get_next_fragment (pl, TRUE, NULL, NULL);
+
/* FIXME: Sequence should last - 3. Should it? */
- assert_equals_int (client->sequence, 3001);
+ assert_equals_int (pl->sequence, 3001);
/* Check first media segments */
file = GST_M3U8_MEDIA_FILE (g_list_first (pl->files)->data);
assert_equals_int (file->sequence, 3001);
- gst_m3u8_client_free (client);
+ gst_hls_master_playlist_unref (master);
}
GST_END_TEST;
GST_START_TEST (test_playlist_with_doubles_duration)
{
- GstM3U8Client *client;
+ GstHLSMasterPlaylist *master;
GstM3U8 *pl;
GstM3U8MediaFile *file;
gint64 start = -1;
gint64 stop = -1;
- client = load_playlist (DOUBLES_PLAYLIST);
+ master = load_playlist (DOUBLES_PLAYLIST);
+ pl = master->default_variant->m3u8;
- pl = client->current;
/* Check first media segments */
file = GST_M3U8_MEDIA_FILE (g_list_nth_data (pl->files, 0));
assert_equals_float (file->duration / (double) GST_SECOND, 10.321);
@@ -593,18 +592,19 @@ GST_START_TEST (test_playlist_with_doubles_duration)
assert_equals_float (file->duration / (double) GST_SECOND, 10.2344);
file = GST_M3U8_MEDIA_FILE (g_list_nth_data (pl->files, 3));
assert_equals_float (file->duration / (double) GST_SECOND, 9.92);
- fail_unless (gst_m3u8_client_get_seek_range (client, &start, &stop));
+ fail_unless (gst_m3u8_get_seek_range (pl, &start, &stop));
assert_equals_int64 (start, 0);
assert_equals_float (stop / (double) GST_SECOND,
10.321 + 9.6789 + 10.2344 + 9.92);
- gst_m3u8_client_free (client);
+
+ gst_hls_master_playlist_unref (master);
}
GST_END_TEST;
GST_START_TEST (test_playlist_with_encryption)
{
- GstM3U8Client *client;
+ GstHLSMasterPlaylist *master;
GstM3U8 *pl;
GstM3U8MediaFile *file;
guint8 iv1[16] = { 0, };
@@ -613,9 +613,9 @@ GST_START_TEST (test_playlist_with_encryption)
iv1[15] = 1;
iv2[15] = 2;
- client = load_playlist (AES_128_ENCRYPTED_PLAYLIST);
+ master = load_playlist (AES_128_ENCRYPTED_PLAYLIST);
+ pl = master->default_variant->m3u8;
- pl = client->current;
assert_equals_int (g_list_length (pl->files), 5);
/* Check all media segments */
@@ -640,72 +640,73 @@ GST_START_TEST (test_playlist_with_encryption)
assert_equals_string (file->key, "https://priv.example.com/key2.bin");
fail_unless (memcmp (&file->iv, iv1, 16) == 0);
- gst_m3u8_client_free (client);
+ gst_hls_master_playlist_unref (master);
}
GST_END_TEST;
+
GST_START_TEST (test_update_invalid_playlist)
{
- GstM3U8Client *client;
+ GstHLSMasterPlaylist *master;
GstM3U8 *pl;
gboolean ret;
/* Test updates in on-demand playlists */
- client = load_playlist (ON_DEMAND_PLAYLIST);
- pl = client->current;
+ master = load_playlist (ON_DEMAND_PLAYLIST);
+ pl = master->default_variant->m3u8;
assert_equals_int (g_list_length (pl->files), 4);
- ret = gst_m3u8_client_update (client, g_strdup ("#INVALID"));
+ ret = gst_m3u8_update (pl, g_strdup ("#INVALID"));
assert_equals_int (ret, FALSE);
- gst_m3u8_client_free (client);
+ gst_hls_master_playlist_unref (master);
}
GST_END_TEST;
GST_START_TEST (test_update_playlist)
{
- GstM3U8Client *client;
+ GstHLSMasterPlaylist *master;
GstM3U8 *pl;
gchar *live_pl;
gboolean ret;
/* Test updates in on-demand playlists */
- client = load_playlist (ON_DEMAND_PLAYLIST);
- pl = client->current;
+ master = load_playlist (ON_DEMAND_PLAYLIST);
+ pl = master->default_variant->m3u8;
assert_equals_int (g_list_length (pl->files), 4);
- ret = gst_m3u8_client_update (client, g_strdup (ON_DEMAND_PLAYLIST));
+ ret = gst_m3u8_update (pl, g_strdup (ON_DEMAND_PLAYLIST));
assert_equals_int (ret, TRUE);
assert_equals_int (g_list_length (pl->files), 4);
- gst_m3u8_client_free (client);
+ gst_hls_master_playlist_unref (master);
/* Test updates in live playlists */
- client = load_playlist (LIVE_PLAYLIST);
- pl = client->current;
+ master = load_playlist (LIVE_PLAYLIST);
+ pl = master->default_variant->m3u8;
assert_equals_int (g_list_length (pl->files), 4);
/* Add a new entry to the playlist and check the update */
live_pl = g_strdup_printf ("%s\n%s\n%s", LIVE_PLAYLIST, "#EXTINF:8",
"https://priv.example.com/fileSequence2683.ts");
- ret = gst_m3u8_client_update (client, live_pl);
+ ret = gst_m3u8_update (pl, live_pl);
assert_equals_int (ret, TRUE);
assert_equals_int (g_list_length (pl->files), 5);
/* Test sliding window */
- ret = gst_m3u8_client_update (client, g_strdup (LIVE_PLAYLIST));
+ ret = gst_m3u8_update (pl, g_strdup (LIVE_PLAYLIST));
assert_equals_int (ret, TRUE);
assert_equals_int (g_list_length (pl->files), 4);
- gst_m3u8_client_free (client);
+ gst_hls_master_playlist_unref (master);
}
GST_END_TEST;
GST_START_TEST (test_playlist_media_files)
{
- GstM3U8Client *client;
+ GstHLSMasterPlaylist *master;
GstM3U8 *pl;
GstM3U8MediaFile *file;
- client = load_playlist (ON_DEMAND_PLAYLIST);
- pl = client->current;
+ master = load_playlist (ON_DEMAND_PLAYLIST);
+ pl = master->default_variant->m3u8;
/* Check number of entries */
assert_equals_int (g_list_length (pl->files), 4);
@@ -718,19 +719,19 @@ GST_START_TEST (test_playlist_media_files)
assert_equals_int (file->size, -1);
assert_equals_string (file->title, "Test");
- gst_m3u8_client_free (client);
+ gst_hls_master_playlist_unref (master);
}
GST_END_TEST;
GST_START_TEST (test_playlist_byte_range_media_files)
{
- GstM3U8Client *client;
+ GstHLSMasterPlaylist *master;
GstM3U8 *pl;
GstM3U8MediaFile *file;
- client = load_playlist (BYTE_RANGES_PLAYLIST);
- pl = client->current;
+ master = load_playlist (BYTE_RANGES_PLAYLIST);
+ pl = master->default_variant->m3u8;
/* Check number of entries */
assert_equals_int (g_list_length (pl->files), 4);
@@ -749,11 +750,11 @@ GST_START_TEST (test_playlist_byte_range_media_files)
assert_equals_int (file->offset, 3000);
assert_equals_int (file->size, 1000);
- gst_m3u8_client_free (client);
+ gst_hls_master_playlist_unref (master);
- client = load_playlist (BYTE_RANGES_ACC_OFFSET_PLAYLIST);
- pl = client->current;
+ master = load_playlist (BYTE_RANGES_ACC_OFFSET_PLAYLIST);
+ pl = master->default_variant->m3u8;
/* Check number of entries */
assert_equals_int (g_list_length (pl->files), 4);
@@ -772,90 +773,93 @@ GST_START_TEST (test_playlist_byte_range_media_files)
assert_equals_int (file->offset, 3000);
assert_equals_int (file->size, 1000);
- gst_m3u8_client_free (client);
+ gst_hls_master_playlist_unref (master);
}
GST_END_TEST;
GST_START_TEST (test_get_next_fragment)
{
- GstM3U8Client *client;
+ GstHLSMasterPlaylist *master;
+ GstM3U8 *pl;
+ GstM3U8MediaFile *mf;
gboolean discontinous;
- gchar *uri;
- GstClockTime duration, timestamp;
- gint64 range_start, range_end;
+ GstClockTime timestamp;
- client = load_playlist (BYTE_RANGES_PLAYLIST);
+ master = load_playlist (BYTE_RANGES_PLAYLIST);
+ pl = master->default_variant->m3u8;
/* Check the next fragment */
- gst_m3u8_client_get_next_fragment (client, &discontinous, &uri, &duration,
- &timestamp, &range_start, &range_end, NULL, NULL, TRUE);
+ mf = gst_m3u8_get_next_fragment (pl, TRUE, &timestamp, &discontinous);
+ fail_unless (mf != NULL);
assert_equals_int (discontinous, FALSE);
- assert_equals_string (uri, "http://media.example.com/all.ts");
+ assert_equals_string (mf->uri, "http://media.example.com/all.ts");
assert_equals_uint64 (timestamp, 0);
- assert_equals_uint64 (duration, 10 * GST_SECOND);
- assert_equals_uint64 (range_start, 100);
- assert_equals_uint64 (range_end, 1099);
- g_free (uri);
+ assert_equals_uint64 (mf->duration, 10 * GST_SECOND);
+ assert_equals_uint64 (mf->offset, 100);
+ assert_equals_uint64 (mf->offset + mf->size, 1100);
- gst_m3u8_client_advance_fragment (client, TRUE);
+ gst_m3u8_advance_fragment (pl, TRUE);
/* Check next media segments */
- gst_m3u8_client_get_next_fragment (client, &discontinous, &uri, &duration,
- &timestamp, &range_start, &range_end, NULL, NULL, TRUE);
+ mf = gst_m3u8_get_next_fragment (pl, TRUE, &timestamp, &discontinous);
+ fail_unless (mf != NULL);
assert_equals_int (discontinous, FALSE);
- assert_equals_string (uri, "http://media.example.com/all.ts");
+ assert_equals_string (mf->uri, "http://media.example.com/all.ts");
assert_equals_uint64 (timestamp, 10 * GST_SECOND);
- assert_equals_uint64 (duration, 10 * GST_SECOND);
- assert_equals_uint64 (range_start, 1000);
- assert_equals_uint64 (range_end, 1999);
- g_free (uri);
+ assert_equals_uint64 (mf->duration, 10 * GST_SECOND);
+ assert_equals_uint64 (mf->offset, 1000);
+ assert_equals_uint64 (mf->offset + mf->size, 2000);
- gst_m3u8_client_advance_fragment (client, TRUE);
+ gst_m3u8_advance_fragment (pl, TRUE);
/* Check next media segments */
- gst_m3u8_client_get_next_fragment (client, &discontinous, &uri, &duration,
- &timestamp, &range_start, &range_end, NULL, NULL, TRUE);
+ mf = gst_m3u8_get_next_fragment (pl, TRUE, &timestamp, &discontinous);
assert_equals_int (discontinous, FALSE);
- assert_equals_string (uri, "http://media.example.com/all.ts");
+ assert_equals_string (mf->uri, "http://media.example.com/all.ts");
assert_equals_uint64 (timestamp, 20 * GST_SECOND);
- assert_equals_uint64 (duration, 10 * GST_SECOND);
- assert_equals_uint64 (range_start, 2000);
- assert_equals_uint64 (range_end, 2999);
- g_free (uri);
+ assert_equals_uint64 (mf->duration, 10 * GST_SECOND);
+ assert_equals_uint64 (mf->offset, 2000);
+ assert_equals_uint64 (mf->offset + mf->size, 3000);
- gst_m3u8_client_free (client);
+ gst_hls_master_playlist_unref (master);
}
GST_END_TEST;
GST_START_TEST (test_get_duration)
{
- GstM3U8Client *client;
+ GstHLSMasterPlaylist *master;
+ GstM3U8 *pl;
/* Test duration for on-demand playlists */
- client = load_playlist (ON_DEMAND_PLAYLIST);
- assert_equals_uint64 (gst_m3u8_client_get_duration (client), 40 * GST_SECOND);
- gst_m3u8_client_free (client);
+ master = load_playlist (ON_DEMAND_PLAYLIST);
+ pl = master->default_variant->m3u8;
+
+ assert_equals_uint64 (gst_m3u8_get_duration (pl), 40 * GST_SECOND);
+ gst_hls_master_playlist_unref (master);
/* Test duration for live playlists */
- client = load_playlist (LIVE_PLAYLIST);
- assert_equals_uint64 (gst_m3u8_client_get_duration (client),
- GST_CLOCK_TIME_NONE);
- gst_m3u8_client_free (client);
+ master = load_playlist (LIVE_PLAYLIST);
+ pl = master->default_variant->m3u8;
+ assert_equals_uint64 (gst_m3u8_get_duration (pl), GST_CLOCK_TIME_NONE);
+
+ gst_hls_master_playlist_unref (master);
}
GST_END_TEST;
GST_START_TEST (test_get_target_duration)
{
- GstM3U8Client *client;
+ GstHLSMasterPlaylist *master;
+ GstM3U8 *pl;
+
+ master = load_playlist (ON_DEMAND_PLAYLIST);
+ pl = master->default_variant->m3u8;
- client = load_playlist (ON_DEMAND_PLAYLIST);
- assert_equals_uint64 (gst_m3u8_client_get_target_duration (client),
- 10 * GST_SECOND);
+ assert_equals_uint64 (gst_m3u8_get_target_duration (pl), 10 * GST_SECOND);
- gst_m3u8_client_free (client);
+ gst_hls_master_playlist_unref (master);
}
GST_END_TEST;
@@ -863,23 +867,29 @@ GST_END_TEST;
GST_START_TEST (test_get_stream_for_bitrate)
{
- GstM3U8Client *client;
- GstM3U8 *stream;
+ GstHLSMasterPlaylist *master;
+ GstHLSVariantStream *stream;
+
+ master = load_playlist (VARIANT_PLAYLIST);
+ stream = gst_hls_master_playlist_get_variant_for_bitrate (master, NULL, 0);
- client = load_playlist (VARIANT_PLAYLIST);
- stream = gst_m3u8_client_get_playlist_for_bitrate (client, 0)->data;
assert_equals_int (stream->bandwidth, 65000);
- stream = gst_m3u8_client_get_playlist_for_bitrate (client, G_MAXINT32)->data;
+
+ stream =
+ gst_hls_master_playlist_get_variant_for_bitrate (master, NULL,
+ G_MAXINT32);
assert_equals_int (stream->bandwidth, 768000);
- stream = gst_m3u8_client_get_playlist_for_bitrate (client, 300000)->data;
+ stream =
+ gst_hls_master_playlist_get_variant_for_bitrate (master, NULL, 300000);
assert_equals_int (stream->bandwidth, 256000);
- stream = gst_m3u8_client_get_playlist_for_bitrate (client, 500000)->data;
+ stream =
+ gst_hls_master_playlist_get_variant_for_bitrate (master, NULL, 500000);
assert_equals_int (stream->bandwidth, 256000);
- stream = gst_m3u8_client_get_playlist_for_bitrate (client, 255000)->data;
+ stream =
+ gst_hls_master_playlist_get_variant_for_bitrate (master, NULL, 255000);
assert_equals_int (stream->bandwidth, 128000);
-
- gst_m3u8_client_free (client);
+ gst_hls_master_playlist_unref (master);
}
GST_END_TEST;
@@ -905,7 +915,7 @@ GST_START_TEST (test_seek)
{
GstM3U8Client *client;
- client = load_playlist (ON_DEMAND_PLAYLIST);
+ master = load_playlist (ON_DEMAND_PLAYLIST);
/* Test seek in the middle of a fragment */
do_test_seek (client, 1, 0);
@@ -922,10 +932,10 @@ GST_START_TEST (test_seek)
/* Test invalid seeks (end if list should be 30 + 10) */
do_test_seek (client, 39, 30);
do_test_seek (client, 40, -1);
- gst_m3u8_client_free (client);
+ gst_hls_master_playlist_unref (master);
/* Test seeks on a live playlist */
- client = load_playlist (LIVE_PLAYLIST);
+ master = load_playlist (LIVE_PLAYLIST);
do_test_seek (client, 0, 0);
do_test_seek (client, 8, 8);
@@ -933,7 +943,7 @@ GST_START_TEST (test_seek)
do_test_seek (client, 30, 24);
do_test_seek (client, 3000, -1);
- gst_m3u8_client_free (client);
+ gst_hls_master_playlist_unref (master);
}
GST_END_TEST;
@@ -944,7 +954,7 @@ GST_START_TEST (test_alternate_audio_playlist)
GstM3U8Media *media;
GList *alternates;
- client = load_playlist (ALTERNATE_AUDIO_PLAYLIST);
+ master = load_playlist (ALTERNATE_AUDIO_PLAYLIST);
assert_equals_int (g_list_length (client->main->streams), 4);
assert_equals_int (g_hash_table_size (client->main->video_rendition_groups),
@@ -980,7 +990,7 @@ GST_START_TEST (test_alternate_audio_playlist)
assert_equals_string (g_list_nth_data (alternates, 1), "Commentary");
assert_equals_string (g_list_nth_data (alternates, 2), "Deutsche");
- gst_m3u8_client_free (client);
+ gst_hls_master_playlist_unref (master);
}
GST_END_TEST;
@@ -991,7 +1001,7 @@ GST_START_TEST (test_subtitles_playlist)
GstM3U8Media *media;
GList *alternates;
- client = load_playlist (SUBTITLES_PLAYLIST);
+ master = load_playlist (SUBTITLES_PLAYLIST);
assert_equals_int (g_list_length (client->main->streams), 3);
assert_equals_int (g_hash_table_size (client->main->video_rendition_groups),
@@ -1028,7 +1038,7 @@ GST_START_TEST (test_subtitles_playlist)
assert_equals_string (g_list_nth_data (alternates, 1), "Spanish");
assert_equals_string (g_list_nth_data (alternates, 2), "English");
- gst_m3u8_client_free (client);
+ gst_hls_master_playlist_unref (master);
}
GST_END_TEST;
@@ -1041,7 +1051,7 @@ GST_START_TEST (test_select_subs_alternate)
/* Check with a playlist with alternative audio renditions where the video
* stream is video-only and therefor we always have 2 playlists, one for
* video and another one for audio */
- client = load_playlist (SUBTITLES_PLAYLIST);
+ master = load_playlist (SUBTITLES_PLAYLIST);
gst_m3u8_client_get_current_uri (client, &v_uri, &a_uri, &s_uri);
assert_equals_int (a_uri == NULL, TRUE);
assert_equals_int (s_uri != NULL, TRUE);
@@ -1081,7 +1091,7 @@ GST_START_TEST (test_select_subs_alternate)
assert_equals_string (v_uri, "http://localhost/low/video-audio.m3u8");
assert_equals_int (s_uri == NULL, TRUE);
- gst_m3u8_client_free (client);
+ gst_hls_master_playlist_unref (master);
}
GST_END_TEST;
@@ -1094,7 +1104,7 @@ GST_START_TEST (test_select_alternate)
/* Check with a playlist with alternative audio renditions where the video
* stream is video-only and therefor we always have 2 playlists, one for
* video and another one for audio */
- client = load_playlist (ALTERNATE_AUDIO_PLAYLIST);
+ master = load_playlist (ALTERNATE_AUDIO_PLAYLIST);
gst_m3u8_client_get_current_uri (client, &v_uri, &a_uri, &s_uri);
assert_equals_int (a_uri != NULL, TRUE);
assert_equals_string (a_uri, "http://localhost/main/english-audio.m3u8");
@@ -1123,13 +1133,13 @@ GST_START_TEST (test_select_alternate)
assert_equals_int (v_uri == NULL, TRUE);
assert_equals_int (s_uri == NULL, TRUE);
- gst_m3u8_client_free (client);
+ gst_hls_master_playlist_unref (master);
/* Now check with a playlist with alternative audio renditions where the
* video * stream has the default audio rendition muxed and therefore we
* only have 2 playlists when the audio alternative rendition is not the
* default one */
- client = load_playlist (ALT_AUDIO_PLAYLIST_WITH_VIDEO_AUDIO);
+ master = load_playlist (ALT_AUDIO_PLAYLIST_WITH_VIDEO_AUDIO);
gst_m3u8_client_get_current_uri (client, &v_uri, &a_uri, &s_uri);
assert_equals_int (a_uri == NULL, TRUE);
assert_equals_int (v_uri != NULL, TRUE);
@@ -1161,7 +1171,7 @@ GST_START_TEST (test_select_alternate)
assert_equals_string (v_uri, "http://localhost/low/video-audio.m3u8");
assert_equals_int (s_uri == NULL, TRUE);
- gst_m3u8_client_free (client);
+ gst_hls_master_playlist_unref (master);
}
GST_END_TEST;
@@ -1173,7 +1183,7 @@ GST_START_TEST (test_simulation)
GstFragment *a_frag, *v_frag, *s_frag;
gboolean ret;
- client = load_playlist (ALTERNATE_AUDIO_PLAYLIST);
+ master = load_playlist (ALTERNATE_AUDIO_PLAYLIST);
/* The default selection should be audio-only, which only has audio and not
* video */
gst_m3u8_client_get_current_uri (client, &v_uri, &a_uri, &s_uri);
@@ -1184,7 +1194,7 @@ GST_START_TEST (test_simulation)
assert_equals_int (s_uri == NULL, TRUE);
/* Update the playlists */
- ret = gst_m3u8_client_update (client,
+ ret = gst_m3u8_update (client,
g_strdup (ON_DEMAND_LOW_VIDEO_ONLY_PLAYLIST),
g_strdup (ON_DEMAND_ENGLISH_PLAYLIST), NULL);
assert_equals_int (ret, TRUE);
@@ -1229,7 +1239,7 @@ GST_START_TEST (test_simulation)
assert_equals_int (s_uri == NULL, TRUE);
/* Update the new uri's */
ret =
- gst_m3u8_client_update (client,
+ gst_m3u8_update (client,
g_strdup (ON_DEMAND_LOW_VIDEO_ONLY_PLAYLIST),
g_strdup (ON_DEMAND_GERMAN_PLAYLIST), NULL);
assert_equals_int (ret, TRUE);
@@ -1254,7 +1264,7 @@ GST_START_TEST (test_simulation)
assert_equals_string (v_uri, "http://localhost/mid/video-only.m3u8");
assert_equals_int (s_uri == NULL, TRUE);
ret =
- gst_m3u8_client_update (client,
+ gst_m3u8_update (client,
g_strdup (ON_DEMAND_MID_VIDEO_ONLY_PLAYLIST),
g_strdup (ON_DEMAND_GERMAN_PLAYLIST), NULL);
assert_equals_int (ret, TRUE);
@@ -1327,7 +1337,7 @@ GST_START_TEST (test_simulation)
ret = gst_m3u8_client_get_next_fragment (client, &v_frag, &a_frag, &s_frag);
assert_equals_int (ret, FALSE);
- gst_m3u8_client_free (client);
+ gst_hls_master_playlist_unref (master);
}
GST_END_TEST;
@@ -1339,16 +1349,19 @@ GST_START_TEST (test_url_with_slash_query_param)
"#EXT-X-VERSION:4\n"
"#EXT-X-STREAM-INF:PROGRAM-ID=1, BANDWIDTH=1251135, CODECS=\"avc1.42001f, mp4a.40.2\", RESOLUTION=640x352\n"
"1251/media.m3u8?acl=/*1054559_h264_1500k.mp4\n";
- GstM3U8Client *client;
+ GstHLSMasterPlaylist *master;
+ GstHLSVariantStream *stream;
GstM3U8 *media;
- client = load_playlist (MASTER_PLAYLIST);
+ master = load_playlist (MASTER_PLAYLIST);
+
+ assert_equals_int (g_list_length (master->variants), 1);
+ stream = g_list_nth_data (master->variants, 0);
+ media = stream->m3u8;
- assert_equals_int (g_list_length (client->main->lists), 1);
- media = g_list_nth_data (client->main->lists, 0);
assert_equals_string (media->uri,
"http://localhost/1251/media.m3u8?acl=/*1054559_h264_1500k.mp4");
- gst_m3u8_client_free (client);
+ gst_hls_master_playlist_unref (master);
}
GST_END_TEST;
@@ -1359,19 +1372,20 @@ GST_START_TEST (test_stream_inf_tag)
"#EXT-X-VERSION:4\n"
"#EXT-X-STREAM-INF:PROGRAM-ID=1, BANDWIDTH=1251135, CODECS=\"avc1.42001f, mp4a.40.2\", RESOLUTION=640x352\n"
"media.m3u8\n";
- GstM3U8Client *client;
- GstM3U8 *media;
+ GstHLSMasterPlaylist *master;
+ GstHLSVariantStream *stream;
- client = load_playlist (MASTER_PLAYLIST);
+ master = load_playlist (MASTER_PLAYLIST);
- assert_equals_int (g_list_length (client->main->lists), 1);
- media = g_list_nth_data (client->main->lists, 0);
- assert_equals_int64 (media->program_id, 1);
- assert_equals_int64 (media->width, 640);
- assert_equals_int64 (media->height, 352);
- assert_equals_int64 (media->bandwidth, 1251135);
- assert_equals_string (media->codecs, "avc1.42001f, mp4a.40.2");
- gst_m3u8_client_free (client);
+ assert_equals_int (g_list_length (master->variants), 1);
+ stream = g_list_nth_data (master->variants, 0);
+
+ assert_equals_int64 (stream->program_id, 1);
+ assert_equals_int64 (stream->width, 640);
+ assert_equals_int64 (stream->height, 352);
+ assert_equals_int64 (stream->bandwidth, 1251135);
+ assert_equals_string (stream->codecs, "avc1.42001f, mp4a.40.2");
+ gst_hls_master_playlist_unref (master);
}
GST_END_TEST;
@@ -1398,6 +1412,8 @@ hlsdemux_suite (void)
tcase_add_test (tc_m3u8, test_empty_lines_playlist);
tcase_add_test (tc_m3u8, test_live_playlist);
tcase_add_test (tc_m3u8, test_live_playlist_rotated);
+ tcase_add_test (tc_m3u8, test_playlist_with_doubles_duration);
+ tcase_add_test (tc_m3u8, test_playlist_with_encryption);
tcase_add_test (tc_m3u8, test_update_invalid_playlist);
tcase_add_test (tc_m3u8, test_update_playlist);
tcase_add_test (tc_m3u8, test_playlist_media_files);
@@ -1414,8 +1430,6 @@ hlsdemux_suite (void)
tcase_add_test (tc_m3u8, test_select_subs_alternate);
tcase_add_test (tc_m3u8, test_simulation);
#endif
- tcase_add_test (tc_m3u8, test_playlist_with_doubles_duration);
- tcase_add_test (tc_m3u8, test_playlist_with_encryption);
tcase_add_test (tc_m3u8, test_url_with_slash_query_param);
tcase_add_test (tc_m3u8, test_stream_inf_tag);
return s;