2006-01-30 15:01:28 +00:00
|
|
|
/* GStreamer
|
|
|
|
*
|
|
|
|
* unit test for vorbisenc
|
|
|
|
*
|
2006-01-30 17:01:54 +00:00
|
|
|
* Copyright (C) 2006 Andy Wingo <wingo at pobox.com>
|
2006-01-30 15:01:28 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library 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
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <gst/check/gstcheck.h>
|
2006-07-21 15:59:24 +00:00
|
|
|
#include <gst/check/gstbufferstraw.h>
|
2006-01-30 15:01:28 +00:00
|
|
|
|
2006-05-28 09:37:18 +00:00
|
|
|
#ifndef GST_DISABLE_PARSE
|
|
|
|
|
2006-01-31 16:26:57 +00:00
|
|
|
#define TIMESTAMP_OFFSET G_GINT64_CONSTANT(3249870963)
|
2006-01-30 15:01:28 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
check_buffer_timestamp (GstBuffer * buffer, GstClockTime timestamp)
|
|
|
|
{
|
|
|
|
fail_unless (GST_BUFFER_TIMESTAMP (buffer) == timestamp,
|
|
|
|
"expected timestamp %" GST_TIME_FORMAT
|
|
|
|
", but got timestamp %" GST_TIME_FORMAT,
|
|
|
|
GST_TIME_ARGS (timestamp), GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
check_buffer_duration (GstBuffer * buffer, GstClockTime duration)
|
|
|
|
{
|
|
|
|
fail_unless (GST_BUFFER_DURATION (buffer) == duration,
|
|
|
|
"expected duration %" GST_TIME_FORMAT
|
|
|
|
", but got duration %" GST_TIME_FORMAT,
|
|
|
|
GST_TIME_ARGS (duration), GST_TIME_ARGS (GST_BUFFER_DURATION (buffer)));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
ogg muxing of vorbis and theora now has pages ordered correctly again, even with delays.
Original commit message from CVS:
ogg muxing of vorbis and theora now has pages ordered correctly again,
even with delays.
* ext/ogg/README:
updated with some examples
* ext/theora/theoraenc.c: (granulepos_to_timestamp),
(granulepos_add), (theora_buffer_from_packet):
* ext/vorbis/vorbisenc.c: (granulepos_to_timestamp_offset),
(granulepos_to_timestamp), (gst_vorbisenc_buffer_from_packet),
(gst_vorbisenc_chain):
implement strategy from ext/ogg/README
* ext/ogg/gstoggmux.c: (gst_ogg_mux_buffer_from_page),
(gst_ogg_mux_push_buffer), (gst_ogg_mux_dequeue_page),
(gst_ogg_mux_pad_queue_page), (gst_ogg_mux_compare_pads),
(gst_ogg_mux_queue_pads), (gst_ogg_mux_collected):
Fix muxer so that oggz-validate is happy with all streams;
except for no eos mark, and the BOS page ordering
* tests/check/pipelines/theoraenc.c: (check_buffer_is_header),
(check_buffer_granulepos):
* tests/check/pipelines/vorbisenc.c: (check_buffer_granulepos):
update tests to check for OFFSET being set as requested
fixed type of granulepos, it's not a ClockTime
2006-03-05 22:57:58 +00:00
|
|
|
check_buffer_granulepos (GstBuffer * buffer, gint64 granulepos)
|
2006-01-30 15:01:28 +00:00
|
|
|
{
|
ogg muxing of vorbis and theora now has pages ordered correctly again, even with delays.
Original commit message from CVS:
ogg muxing of vorbis and theora now has pages ordered correctly again,
even with delays.
* ext/ogg/README:
updated with some examples
* ext/theora/theoraenc.c: (granulepos_to_timestamp),
(granulepos_add), (theora_buffer_from_packet):
* ext/vorbis/vorbisenc.c: (granulepos_to_timestamp_offset),
(granulepos_to_timestamp), (gst_vorbisenc_buffer_from_packet),
(gst_vorbisenc_chain):
implement strategy from ext/ogg/README
* ext/ogg/gstoggmux.c: (gst_ogg_mux_buffer_from_page),
(gst_ogg_mux_push_buffer), (gst_ogg_mux_dequeue_page),
(gst_ogg_mux_pad_queue_page), (gst_ogg_mux_compare_pads),
(gst_ogg_mux_queue_pads), (gst_ogg_mux_collected):
Fix muxer so that oggz-validate is happy with all streams;
except for no eos mark, and the BOS page ordering
* tests/check/pipelines/theoraenc.c: (check_buffer_is_header),
(check_buffer_granulepos):
* tests/check/pipelines/vorbisenc.c: (check_buffer_granulepos):
update tests to check for OFFSET being set as requested
fixed type of granulepos, it's not a ClockTime
2006-03-05 22:57:58 +00:00
|
|
|
GstClockTime clocktime;
|
|
|
|
|
2006-01-30 15:01:28 +00:00
|
|
|
fail_unless (GST_BUFFER_OFFSET_END (buffer) == granulepos,
|
|
|
|
"expected granulepos %" G_GUINT64_FORMAT
|
|
|
|
", but got granulepos %" G_GUINT64_FORMAT,
|
|
|
|
granulepos, GST_BUFFER_OFFSET_END (buffer));
|
ogg muxing of vorbis and theora now has pages ordered correctly again, even with delays.
Original commit message from CVS:
ogg muxing of vorbis and theora now has pages ordered correctly again,
even with delays.
* ext/ogg/README:
updated with some examples
* ext/theora/theoraenc.c: (granulepos_to_timestamp),
(granulepos_add), (theora_buffer_from_packet):
* ext/vorbis/vorbisenc.c: (granulepos_to_timestamp_offset),
(granulepos_to_timestamp), (gst_vorbisenc_buffer_from_packet),
(gst_vorbisenc_chain):
implement strategy from ext/ogg/README
* ext/ogg/gstoggmux.c: (gst_ogg_mux_buffer_from_page),
(gst_ogg_mux_push_buffer), (gst_ogg_mux_dequeue_page),
(gst_ogg_mux_pad_queue_page), (gst_ogg_mux_compare_pads),
(gst_ogg_mux_queue_pads), (gst_ogg_mux_collected):
Fix muxer so that oggz-validate is happy with all streams;
except for no eos mark, and the BOS page ordering
* tests/check/pipelines/theoraenc.c: (check_buffer_is_header),
(check_buffer_granulepos):
* tests/check/pipelines/vorbisenc.c: (check_buffer_granulepos):
update tests to check for OFFSET being set as requested
fixed type of granulepos, it's not a ClockTime
2006-03-05 22:57:58 +00:00
|
|
|
|
|
|
|
/* contrary to what we record as TIMESTAMP, we can use OFFSET to check
|
|
|
|
* the granulepos correctly here */
|
|
|
|
clocktime = gst_util_uint64_scale (GST_BUFFER_OFFSET_END (buffer), 44100,
|
|
|
|
GST_SECOND);
|
|
|
|
|
|
|
|
fail_unless (clocktime == GST_BUFFER_OFFSET (buffer),
|
|
|
|
"expected OFFSET set to clocktime %" GST_TIME_FORMAT
|
|
|
|
", but got %" GST_TIME_FORMAT,
|
|
|
|
GST_TIME_ARGS (clocktime), GST_TIME_ARGS (GST_BUFFER_OFFSET (buffer)));
|
2006-01-30 15:01:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* this check is here to check that the granulepos we derive from the timestamp
|
|
|
|
is about correct. This is "about correct" because you can't precisely go from
|
|
|
|
timestamp to granulepos due to the downward-rounding characteristics of
|
|
|
|
gst_util_uint64_scale, so you check if granulepos is equal to the number, or
|
|
|
|
the number plus one. */
|
|
|
|
static void
|
|
|
|
check_buffer_granulepos_from_endtime (GstBuffer * buffer, GstClockTime endtime)
|
|
|
|
{
|
ogg muxing of vorbis and theora now has pages ordered correctly again, even with delays.
Original commit message from CVS:
ogg muxing of vorbis and theora now has pages ordered correctly again,
even with delays.
* ext/ogg/README:
updated with some examples
* ext/theora/theoraenc.c: (granulepos_to_timestamp),
(granulepos_add), (theora_buffer_from_packet):
* ext/vorbis/vorbisenc.c: (granulepos_to_timestamp_offset),
(granulepos_to_timestamp), (gst_vorbisenc_buffer_from_packet),
(gst_vorbisenc_chain):
implement strategy from ext/ogg/README
* ext/ogg/gstoggmux.c: (gst_ogg_mux_buffer_from_page),
(gst_ogg_mux_push_buffer), (gst_ogg_mux_dequeue_page),
(gst_ogg_mux_pad_queue_page), (gst_ogg_mux_compare_pads),
(gst_ogg_mux_queue_pads), (gst_ogg_mux_collected):
Fix muxer so that oggz-validate is happy with all streams;
except for no eos mark, and the BOS page ordering
* tests/check/pipelines/theoraenc.c: (check_buffer_is_header),
(check_buffer_granulepos):
* tests/check/pipelines/vorbisenc.c: (check_buffer_granulepos):
update tests to check for OFFSET being set as requested
fixed type of granulepos, it's not a ClockTime
2006-03-05 22:57:58 +00:00
|
|
|
gint64 granulepos, expected;
|
2006-01-30 15:01:28 +00:00
|
|
|
|
|
|
|
granulepos = GST_BUFFER_OFFSET_END (buffer);
|
|
|
|
expected = gst_util_uint64_scale (endtime, 44100, GST_SECOND);
|
|
|
|
|
|
|
|
fail_unless (granulepos == expected || granulepos == expected + 1,
|
|
|
|
"expected granulepos %" G_GUINT64_FORMAT
|
|
|
|
" or %" G_GUINT64_FORMAT
|
|
|
|
", but got granulepos %" G_GUINT64_FORMAT,
|
|
|
|
expected, expected + 1, granulepos);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_START_TEST (test_granulepos_offset)
|
|
|
|
{
|
|
|
|
GstElement *bin;
|
|
|
|
GstPad *pad;
|
|
|
|
gchar *pipe_str;
|
|
|
|
GstBuffer *buffer;
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
pipe_str = g_strdup_printf ("audiotestsrc timestamp-offset=%" G_GUINT64_FORMAT
|
|
|
|
" ! audio/x-raw-int,rate=44100"
|
|
|
|
" ! audioconvert ! vorbisenc ! fakesink", TIMESTAMP_OFFSET);
|
|
|
|
|
|
|
|
bin = gst_parse_launch (pipe_str, &error);
|
|
|
|
fail_unless (bin != NULL, "Error parsing pipeline: %s",
|
|
|
|
error ? error->message : "(invalid error)");
|
|
|
|
g_free (pipe_str);
|
|
|
|
|
|
|
|
/* get the pad */
|
|
|
|
{
|
|
|
|
GstElement *sink = gst_bin_get_by_name (GST_BIN (bin), "fakesink0");
|
|
|
|
|
|
|
|
fail_unless (sink != NULL, "Could not get fakesink out of bin");
|
|
|
|
pad = gst_element_get_pad (sink, "sink");
|
|
|
|
fail_unless (pad != NULL, "Could not get pad out of fakesink");
|
|
|
|
gst_object_unref (sink);
|
|
|
|
}
|
|
|
|
|
2006-07-21 15:59:24 +00:00
|
|
|
gst_buffer_straw_start_pipeline (bin, pad);
|
2006-01-30 15:01:28 +00:00
|
|
|
|
|
|
|
/* header packets should have timestamp == NONE, granulepos 0 */
|
2006-07-21 15:59:24 +00:00
|
|
|
buffer = gst_buffer_straw_get_buffer (bin, pad);
|
2006-06-02 17:01:02 +00:00
|
|
|
GST_DEBUG ("Got buffer in test");
|
2006-01-30 15:01:28 +00:00
|
|
|
check_buffer_timestamp (buffer, GST_CLOCK_TIME_NONE);
|
|
|
|
check_buffer_duration (buffer, GST_CLOCK_TIME_NONE);
|
|
|
|
check_buffer_granulepos (buffer, 0);
|
|
|
|
gst_buffer_unref (buffer);
|
2006-06-02 17:01:02 +00:00
|
|
|
GST_DEBUG ("Unreffed buffer in test");
|
2006-01-30 15:01:28 +00:00
|
|
|
|
2006-07-21 15:59:24 +00:00
|
|
|
buffer = gst_buffer_straw_get_buffer (bin, pad);
|
2006-01-30 15:01:28 +00:00
|
|
|
check_buffer_timestamp (buffer, GST_CLOCK_TIME_NONE);
|
|
|
|
check_buffer_duration (buffer, GST_CLOCK_TIME_NONE);
|
|
|
|
check_buffer_granulepos (buffer, 0);
|
|
|
|
gst_buffer_unref (buffer);
|
|
|
|
|
2006-07-21 15:59:24 +00:00
|
|
|
buffer = gst_buffer_straw_get_buffer (bin, pad);
|
2006-01-30 15:01:28 +00:00
|
|
|
check_buffer_timestamp (buffer, GST_CLOCK_TIME_NONE);
|
|
|
|
check_buffer_duration (buffer, GST_CLOCK_TIME_NONE);
|
|
|
|
check_buffer_granulepos (buffer, 0);
|
|
|
|
gst_buffer_unref (buffer);
|
|
|
|
|
|
|
|
{
|
ogg muxing of vorbis and theora now has pages ordered correctly again, even with delays.
Original commit message from CVS:
ogg muxing of vorbis and theora now has pages ordered correctly again,
even with delays.
* ext/ogg/README:
updated with some examples
* ext/theora/theoraenc.c: (granulepos_to_timestamp),
(granulepos_add), (theora_buffer_from_packet):
* ext/vorbis/vorbisenc.c: (granulepos_to_timestamp_offset),
(granulepos_to_timestamp), (gst_vorbisenc_buffer_from_packet),
(gst_vorbisenc_chain):
implement strategy from ext/ogg/README
* ext/ogg/gstoggmux.c: (gst_ogg_mux_buffer_from_page),
(gst_ogg_mux_push_buffer), (gst_ogg_mux_dequeue_page),
(gst_ogg_mux_pad_queue_page), (gst_ogg_mux_compare_pads),
(gst_ogg_mux_queue_pads), (gst_ogg_mux_collected):
Fix muxer so that oggz-validate is happy with all streams;
except for no eos mark, and the BOS page ordering
* tests/check/pipelines/theoraenc.c: (check_buffer_is_header),
(check_buffer_granulepos):
* tests/check/pipelines/vorbisenc.c: (check_buffer_granulepos):
update tests to check for OFFSET being set as requested
fixed type of granulepos, it's not a ClockTime
2006-03-05 22:57:58 +00:00
|
|
|
GstClockTime next_timestamp;
|
2006-07-21 16:54:19 +00:00
|
|
|
gint64 last_granulepos = 0;
|
2006-01-30 15:01:28 +00:00
|
|
|
|
|
|
|
/* first buffer should have timestamp of TIMESTAMP_OFFSET, granulepos to
|
|
|
|
* match the timestamp of the end of the last sample in the output buffer.
|
|
|
|
* Note that one cannot go timestamp->granulepos->timestamp and get the same
|
|
|
|
* value due to loss of precision with granulepos. vorbisenc does take care
|
|
|
|
* to timestamp correctly based on the offset of the input data however, so
|
|
|
|
* it does do sub-granulepos timestamping. */
|
2006-07-21 15:59:24 +00:00
|
|
|
buffer = gst_buffer_straw_get_buffer (bin, pad);
|
2006-01-30 15:01:28 +00:00
|
|
|
last_granulepos = GST_BUFFER_OFFSET_END (buffer);
|
|
|
|
check_buffer_timestamp (buffer, TIMESTAMP_OFFSET);
|
|
|
|
/* don't really have a good way of checking duration... */
|
|
|
|
check_buffer_granulepos_from_endtime (buffer,
|
|
|
|
TIMESTAMP_OFFSET + GST_BUFFER_DURATION (buffer));
|
|
|
|
|
|
|
|
next_timestamp = TIMESTAMP_OFFSET + GST_BUFFER_DURATION (buffer);
|
|
|
|
|
|
|
|
gst_buffer_unref (buffer);
|
|
|
|
|
|
|
|
/* check continuity with the next buffer */
|
2006-07-21 15:59:24 +00:00
|
|
|
buffer = gst_buffer_straw_get_buffer (bin, pad);
|
2006-01-30 15:01:28 +00:00
|
|
|
check_buffer_timestamp (buffer, next_timestamp);
|
|
|
|
check_buffer_duration (buffer,
|
|
|
|
gst_util_uint64_scale (GST_BUFFER_OFFSET_END (buffer), GST_SECOND,
|
|
|
|
44100)
|
|
|
|
- gst_util_uint64_scale (last_granulepos, GST_SECOND, 44100));
|
|
|
|
check_buffer_granulepos_from_endtime (buffer,
|
|
|
|
next_timestamp + GST_BUFFER_DURATION (buffer));
|
|
|
|
|
|
|
|
gst_buffer_unref (buffer);
|
|
|
|
}
|
|
|
|
|
2006-07-21 15:59:24 +00:00
|
|
|
gst_buffer_straw_stop_pipeline (bin, pad);
|
2006-01-30 15:01:28 +00:00
|
|
|
|
|
|
|
gst_object_unref (pad);
|
|
|
|
gst_object_unref (bin);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_timestamps)
|
|
|
|
{
|
|
|
|
GstElement *bin;
|
|
|
|
GstPad *pad;
|
|
|
|
gchar *pipe_str;
|
|
|
|
GstBuffer *buffer;
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
pipe_str = g_strdup_printf ("audiotestsrc"
|
2007-03-26 20:56:35 +00:00
|
|
|
" ! audio/x-raw-int,rate=44100 ! audioconvert ! vorbisenc ! fakesink");
|
2006-01-30 15:01:28 +00:00
|
|
|
|
|
|
|
bin = gst_parse_launch (pipe_str, &error);
|
|
|
|
fail_unless (bin != NULL, "Error parsing pipeline: %s",
|
|
|
|
error ? error->message : "(invalid error)");
|
|
|
|
g_free (pipe_str);
|
|
|
|
|
|
|
|
/* get the pad */
|
|
|
|
{
|
|
|
|
GstElement *sink = gst_bin_get_by_name (GST_BIN (bin), "fakesink0");
|
|
|
|
|
|
|
|
fail_unless (sink != NULL, "Could not get fakesink out of bin");
|
|
|
|
pad = gst_element_get_pad (sink, "sink");
|
|
|
|
fail_unless (pad != NULL, "Could not get pad out of fakesink");
|
|
|
|
gst_object_unref (sink);
|
|
|
|
}
|
|
|
|
|
2006-07-21 15:59:24 +00:00
|
|
|
gst_buffer_straw_start_pipeline (bin, pad);
|
2006-01-30 15:01:28 +00:00
|
|
|
|
|
|
|
/* check header packets */
|
2006-07-21 15:59:24 +00:00
|
|
|
buffer = gst_buffer_straw_get_buffer (bin, pad);
|
2006-01-30 15:01:28 +00:00
|
|
|
check_buffer_timestamp (buffer, GST_CLOCK_TIME_NONE);
|
|
|
|
check_buffer_duration (buffer, GST_CLOCK_TIME_NONE);
|
|
|
|
check_buffer_granulepos (buffer, 0);
|
|
|
|
gst_buffer_unref (buffer);
|
|
|
|
|
2006-07-21 15:59:24 +00:00
|
|
|
buffer = gst_buffer_straw_get_buffer (bin, pad);
|
2006-01-30 15:01:28 +00:00
|
|
|
check_buffer_timestamp (buffer, GST_CLOCK_TIME_NONE);
|
|
|
|
check_buffer_duration (buffer, GST_CLOCK_TIME_NONE);
|
|
|
|
check_buffer_granulepos (buffer, 0);
|
|
|
|
gst_buffer_unref (buffer);
|
|
|
|
|
2006-07-21 15:59:24 +00:00
|
|
|
buffer = gst_buffer_straw_get_buffer (bin, pad);
|
2006-01-30 15:01:28 +00:00
|
|
|
check_buffer_timestamp (buffer, GST_CLOCK_TIME_NONE);
|
|
|
|
check_buffer_duration (buffer, GST_CLOCK_TIME_NONE);
|
|
|
|
check_buffer_granulepos (buffer, 0);
|
|
|
|
gst_buffer_unref (buffer);
|
|
|
|
|
|
|
|
{
|
ogg muxing of vorbis and theora now has pages ordered correctly again, even with delays.
Original commit message from CVS:
ogg muxing of vorbis and theora now has pages ordered correctly again,
even with delays.
* ext/ogg/README:
updated with some examples
* ext/theora/theoraenc.c: (granulepos_to_timestamp),
(granulepos_add), (theora_buffer_from_packet):
* ext/vorbis/vorbisenc.c: (granulepos_to_timestamp_offset),
(granulepos_to_timestamp), (gst_vorbisenc_buffer_from_packet),
(gst_vorbisenc_chain):
implement strategy from ext/ogg/README
* ext/ogg/gstoggmux.c: (gst_ogg_mux_buffer_from_page),
(gst_ogg_mux_push_buffer), (gst_ogg_mux_dequeue_page),
(gst_ogg_mux_pad_queue_page), (gst_ogg_mux_compare_pads),
(gst_ogg_mux_queue_pads), (gst_ogg_mux_collected):
Fix muxer so that oggz-validate is happy with all streams;
except for no eos mark, and the BOS page ordering
* tests/check/pipelines/theoraenc.c: (check_buffer_is_header),
(check_buffer_granulepos):
* tests/check/pipelines/vorbisenc.c: (check_buffer_granulepos):
update tests to check for OFFSET being set as requested
fixed type of granulepos, it's not a ClockTime
2006-03-05 22:57:58 +00:00
|
|
|
GstClockTime next_timestamp;
|
|
|
|
gint64 last_granulepos;
|
2006-01-30 15:01:28 +00:00
|
|
|
|
|
|
|
/* first buffer has timestamp 0 */
|
2006-07-21 15:59:24 +00:00
|
|
|
buffer = gst_buffer_straw_get_buffer (bin, pad);
|
2006-01-30 15:01:28 +00:00
|
|
|
last_granulepos = GST_BUFFER_OFFSET_END (buffer);
|
|
|
|
check_buffer_timestamp (buffer, 0);
|
|
|
|
/* don't really have a good way of checking duration... */
|
|
|
|
check_buffer_granulepos_from_endtime (buffer, GST_BUFFER_DURATION (buffer));
|
|
|
|
|
|
|
|
next_timestamp = GST_BUFFER_DURATION (buffer);
|
|
|
|
|
|
|
|
gst_buffer_unref (buffer);
|
|
|
|
|
|
|
|
/* check continuity with the next buffer */
|
2006-07-21 15:59:24 +00:00
|
|
|
buffer = gst_buffer_straw_get_buffer (bin, pad);
|
2006-01-30 15:01:28 +00:00
|
|
|
check_buffer_timestamp (buffer, next_timestamp);
|
|
|
|
check_buffer_duration (buffer,
|
|
|
|
gst_util_uint64_scale (GST_BUFFER_OFFSET_END (buffer), GST_SECOND,
|
|
|
|
44100)
|
|
|
|
- gst_util_uint64_scale (last_granulepos, GST_SECOND, 44100));
|
|
|
|
check_buffer_granulepos_from_endtime (buffer,
|
|
|
|
next_timestamp + GST_BUFFER_DURATION (buffer));
|
|
|
|
|
|
|
|
gst_buffer_unref (buffer);
|
|
|
|
}
|
|
|
|
|
2006-07-21 15:59:24 +00:00
|
|
|
gst_buffer_straw_stop_pipeline (bin, pad);
|
2006-01-30 15:01:28 +00:00
|
|
|
|
|
|
|
gst_object_unref (pad);
|
|
|
|
gst_object_unref (bin);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2006-07-21 16:54:19 +00:00
|
|
|
static gboolean
|
|
|
|
drop_second_data_buffer (GstPad * droppad, GstBuffer * buffer, gpointer unused)
|
|
|
|
{
|
|
|
|
return !(GST_BUFFER_OFFSET (buffer) == 1024);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_START_TEST (test_discontinuity)
|
|
|
|
{
|
|
|
|
GstElement *bin;
|
|
|
|
GstPad *pad, *droppad;
|
|
|
|
gchar *pipe_str;
|
|
|
|
GstBuffer *buffer;
|
|
|
|
GError *error = NULL;
|
|
|
|
guint drop_id;
|
|
|
|
|
|
|
|
pipe_str = g_strdup_printf ("audiotestsrc samplesperbuffer=1024"
|
|
|
|
" ! audio/x-raw-int,rate=44100" " ! audioconvert ! vorbisenc ! fakesink");
|
|
|
|
|
|
|
|
bin = gst_parse_launch (pipe_str, &error);
|
|
|
|
fail_unless (bin != NULL, "Error parsing pipeline: %s",
|
|
|
|
error ? error->message : "(invalid error)");
|
|
|
|
g_free (pipe_str);
|
|
|
|
|
|
|
|
/* the plan: same as test_timestamps, but dropping a buffer and seeing if
|
|
|
|
vorbisenc correctly notes the discontinuity */
|
|
|
|
|
|
|
|
/* get the pad to use to drop buffers */
|
|
|
|
{
|
|
|
|
GstElement *sink = gst_bin_get_by_name (GST_BIN (bin), "vorbisenc0");
|
|
|
|
|
|
|
|
fail_unless (sink != NULL, "Could not get vorbisenc out of bin");
|
|
|
|
droppad = gst_element_get_pad (sink, "sink");
|
|
|
|
fail_unless (droppad != NULL, "Could not get pad out of vorbisenc");
|
|
|
|
gst_object_unref (sink);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* get the pad */
|
|
|
|
{
|
|
|
|
GstElement *sink = gst_bin_get_by_name (GST_BIN (bin), "fakesink0");
|
|
|
|
|
|
|
|
fail_unless (sink != NULL, "Could not get fakesink out of bin");
|
|
|
|
pad = gst_element_get_pad (sink, "sink");
|
|
|
|
fail_unless (pad != NULL, "Could not get pad out of fakesink");
|
|
|
|
gst_object_unref (sink);
|
|
|
|
}
|
|
|
|
|
2006-09-16 22:30:50 +00:00
|
|
|
drop_id = gst_pad_add_buffer_probe (droppad,
|
|
|
|
G_CALLBACK (drop_second_data_buffer), NULL);
|
2006-07-21 16:54:19 +00:00
|
|
|
gst_buffer_straw_start_pipeline (bin, pad);
|
|
|
|
|
|
|
|
/* check header packets */
|
|
|
|
buffer = gst_buffer_straw_get_buffer (bin, pad);
|
|
|
|
check_buffer_timestamp (buffer, GST_CLOCK_TIME_NONE);
|
|
|
|
check_buffer_duration (buffer, GST_CLOCK_TIME_NONE);
|
|
|
|
check_buffer_granulepos (buffer, 0);
|
|
|
|
gst_buffer_unref (buffer);
|
|
|
|
|
|
|
|
buffer = gst_buffer_straw_get_buffer (bin, pad);
|
|
|
|
check_buffer_timestamp (buffer, GST_CLOCK_TIME_NONE);
|
|
|
|
check_buffer_duration (buffer, GST_CLOCK_TIME_NONE);
|
|
|
|
check_buffer_granulepos (buffer, 0);
|
|
|
|
gst_buffer_unref (buffer);
|
|
|
|
|
|
|
|
buffer = gst_buffer_straw_get_buffer (bin, pad);
|
|
|
|
check_buffer_timestamp (buffer, GST_CLOCK_TIME_NONE);
|
|
|
|
check_buffer_duration (buffer, GST_CLOCK_TIME_NONE);
|
|
|
|
check_buffer_granulepos (buffer, 0);
|
|
|
|
gst_buffer_unref (buffer);
|
|
|
|
|
|
|
|
/* two phases: continuous granulepos values up to 1024, then a first
|
|
|
|
discontinuous granulepos whose granulepos corresponds to a gap ending at
|
|
|
|
2048. */
|
|
|
|
{
|
|
|
|
GstClockTime next_timestamp = 0;
|
|
|
|
gint64 last_granulepos = 0;
|
|
|
|
|
|
|
|
while (last_granulepos < 1024) {
|
|
|
|
buffer = gst_buffer_straw_get_buffer (bin, pad);
|
|
|
|
last_granulepos = GST_BUFFER_OFFSET_END (buffer);
|
|
|
|
check_buffer_timestamp (buffer, next_timestamp);
|
|
|
|
fail_if (GST_BUFFER_IS_DISCONT (buffer), "expected continuous buffer");
|
|
|
|
next_timestamp += GST_BUFFER_DURATION (buffer);
|
|
|
|
gst_buffer_unref (buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
fail_unless (last_granulepos == 1024,
|
|
|
|
"unexpected granulepos: %" G_GUINT64_FORMAT, last_granulepos);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
buffer = gst_buffer_straw_get_buffer (bin, pad);
|
2006-07-28 13:42:48 +00:00
|
|
|
/* The first buffer after the discontinuity will produce zero output
|
|
|
|
* samples (because of the overlap/add), so it won't increment the
|
|
|
|
* granulepos, which should be 2048 after the discontinuity.
|
|
|
|
*/
|
|
|
|
fail_unless (GST_BUFFER_OFFSET_END (buffer) == 2048,
|
2006-07-21 16:54:19 +00:00
|
|
|
"expected granulepos after gap: %" G_GUINT64_FORMAT,
|
|
|
|
GST_BUFFER_OFFSET_END (buffer));
|
|
|
|
fail_unless (GST_BUFFER_IS_DISCONT (buffer),
|
|
|
|
"expected discontinuous buffer");
|
|
|
|
gst_buffer_unref (buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_buffer_straw_stop_pipeline (bin, pad);
|
|
|
|
gst_pad_remove_buffer_probe (droppad, drop_id);
|
|
|
|
|
|
|
|
gst_object_unref (droppad);
|
|
|
|
gst_object_unref (pad);
|
|
|
|
gst_object_unref (bin);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2006-05-28 09:37:18 +00:00
|
|
|
#endif /* #ifndef GST_DISABLE_PARSE */
|
|
|
|
|
2006-01-30 15:01:28 +00:00
|
|
|
Suite *
|
|
|
|
vorbisenc_suite (void)
|
|
|
|
{
|
|
|
|
Suite *s = suite_create ("vorbisenc");
|
|
|
|
TCase *tc_chain = tcase_create ("general");
|
|
|
|
|
|
|
|
suite_add_tcase (s, tc_chain);
|
2006-05-28 09:37:18 +00:00
|
|
|
#ifndef GST_DISABLE_PARSE
|
2006-01-30 15:01:28 +00:00
|
|
|
tcase_add_test (tc_chain, test_granulepos_offset);
|
|
|
|
tcase_add_test (tc_chain, test_timestamps);
|
2006-07-21 16:54:19 +00:00
|
|
|
tcase_add_test (tc_chain, test_discontinuity);
|
2006-05-28 09:37:18 +00:00
|
|
|
#endif
|
2006-01-30 15:01:28 +00:00
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main (int argc, char **argv)
|
|
|
|
{
|
|
|
|
int nf;
|
|
|
|
|
|
|
|
Suite *s = vorbisenc_suite ();
|
|
|
|
SRunner *sr = srunner_create (s);
|
|
|
|
|
|
|
|
gst_check_init (&argc, &argv);
|
|
|
|
|
|
|
|
srunner_run_all (sr, CK_NORMAL);
|
|
|
|
nf = srunner_ntests_failed (sr);
|
|
|
|
srunner_free (sr);
|
|
|
|
|
|
|
|
return nf;
|
|
|
|
}
|