2007-05-22 15:45:19 +00:00
|
|
|
/* GStreamer unit test for the gnomevfssink element
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 Thomas Vander Stichele <thomas at apestaart dot org>
|
|
|
|
* Copyright (C) 2007 Tim-Philipp Müller <tim centricular net>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
#include <glib/gstdio.h>
|
|
|
|
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h> /* for close() */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <gst/check/gstcheck.h>
|
|
|
|
|
Correct all relevant warnings found by the sparse semantic code analyzer. This include marking several symbols static...
Original commit message from CVS:
* ext/alsa/gstalsamixertrack.c: (gst_alsa_mixer_track_get_type):
* ext/alsa/gstalsasink.c: (set_hwparams):
* ext/alsa/gstalsasrc.c: (set_hwparams):
* ext/gio/gstgio.c: (gst_gio_uri_handler_get_uri):
* ext/ogg/gstoggmux.h:
* ext/ogg/gstogmparse.c:
* gst-libs/gst/audio/audio.c:
* gst-libs/gst/fft/kiss_fft_f64.c: (kiss_fft_f64_alloc):
* gst-libs/gst/pbutils/missing-plugins.c:
(gst_missing_uri_sink_message_new),
(gst_missing_element_message_new),
(gst_missing_decoder_message_new),
(gst_missing_encoder_message_new):
* gst-libs/gst/rtp/gstbasertppayload.c:
* gst-libs/gst/rtp/gstrtcpbuffer.c:
(gst_rtcp_packet_bye_get_reason):
* gst/audioconvert/gstaudioconvert.c:
* gst/audioresample/gstaudioresample.c:
* gst/ffmpegcolorspace/imgconvert.c:
* gst/playback/test.c: (gen_video_element), (gen_audio_element):
* gst/typefind/gsttypefindfunctions.c:
* gst/videoscale/vs_4tap.c:
* gst/videoscale/vs_4tap.h:
* sys/v4l/gstv4lelement.c:
* sys/v4l/gstv4lsrc.c: (gst_v4lsrc_get_any_caps):
* sys/v4l/v4l_calls.c:
* sys/v4l/v4lsrc_calls.c: (gst_v4lsrc_capture_init),
(gst_v4lsrc_try_capture):
* sys/ximage/ximagesink.c: (gst_ximagesink_check_xshm_calls),
(gst_ximagesink_ximage_new):
* sys/xvimage/xvimagesink.c: (gst_xvimagesink_check_xshm_calls),
(gst_xvimagesink_xvimage_new):
* tests/check/elements/audioconvert.c:
* tests/check/elements/audioresample.c:
(fail_unless_perfect_stream):
* tests/check/elements/audiotestsrc.c: (setup_audiotestsrc):
* tests/check/elements/decodebin.c:
* tests/check/elements/gdpdepay.c: (setup_gdpdepay),
(setup_gdpdepay_streamheader):
* tests/check/elements/gdppay.c: (setup_gdppay), (GST_START_TEST),
(setup_gdppay_streamheader):
* tests/check/elements/gnomevfssink.c: (setup_gnomevfssink):
* tests/check/elements/multifdsink.c: (setup_multifdsink):
* tests/check/elements/textoverlay.c:
* tests/check/elements/videorate.c: (setup_videorate):
* tests/check/elements/videotestsrc.c: (setup_videotestsrc):
* tests/check/elements/volume.c: (setup_volume):
* tests/check/elements/vorbisdec.c: (setup_vorbisdec):
* tests/check/elements/vorbistag.c:
* tests/check/generic/clock-selection.c:
* tests/check/generic/states.c: (setup), (teardown):
* tests/check/libs/cddabasesrc.c:
* tests/check/libs/video.c:
* tests/check/pipelines/gio.c:
* tests/check/pipelines/oggmux.c:
* tests/check/pipelines/simple-launch-lines.c:
(simple_launch_lines_suite):
* tests/check/pipelines/streamheader.c:
* tests/check/pipelines/theoraenc.c:
* tests/check/pipelines/vorbisdec.c:
* tests/check/pipelines/vorbisenc.c:
* tests/examples/seek/scrubby.c:
* tests/examples/seek/seek.c: (query_positions_elems),
(query_positions_pads):
* tests/icles/stress-xoverlay.c: (myclock):
Correct all relevant warnings found by the sparse semantic code
analyzer. This include marking several symbols static, using
NULL instead of 0 for pointers and using "foo (void)" instead
of "foo ()" for declarations.
* win32/common/libgstrtp.def:
Add gst_rtp_buffer_set_extension_data to the symbol definition file.
2008-03-03 06:04:31 +00:00
|
|
|
static GstPad *mysrcpad;
|
2007-05-22 15:45:19 +00:00
|
|
|
|
|
|
|
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
|
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS_ANY);
|
|
|
|
|
|
|
|
static GstElement *
|
Correct all relevant warnings found by the sparse semantic code analyzer. This include marking several symbols static...
Original commit message from CVS:
* ext/alsa/gstalsamixertrack.c: (gst_alsa_mixer_track_get_type):
* ext/alsa/gstalsasink.c: (set_hwparams):
* ext/alsa/gstalsasrc.c: (set_hwparams):
* ext/gio/gstgio.c: (gst_gio_uri_handler_get_uri):
* ext/ogg/gstoggmux.h:
* ext/ogg/gstogmparse.c:
* gst-libs/gst/audio/audio.c:
* gst-libs/gst/fft/kiss_fft_f64.c: (kiss_fft_f64_alloc):
* gst-libs/gst/pbutils/missing-plugins.c:
(gst_missing_uri_sink_message_new),
(gst_missing_element_message_new),
(gst_missing_decoder_message_new),
(gst_missing_encoder_message_new):
* gst-libs/gst/rtp/gstbasertppayload.c:
* gst-libs/gst/rtp/gstrtcpbuffer.c:
(gst_rtcp_packet_bye_get_reason):
* gst/audioconvert/gstaudioconvert.c:
* gst/audioresample/gstaudioresample.c:
* gst/ffmpegcolorspace/imgconvert.c:
* gst/playback/test.c: (gen_video_element), (gen_audio_element):
* gst/typefind/gsttypefindfunctions.c:
* gst/videoscale/vs_4tap.c:
* gst/videoscale/vs_4tap.h:
* sys/v4l/gstv4lelement.c:
* sys/v4l/gstv4lsrc.c: (gst_v4lsrc_get_any_caps):
* sys/v4l/v4l_calls.c:
* sys/v4l/v4lsrc_calls.c: (gst_v4lsrc_capture_init),
(gst_v4lsrc_try_capture):
* sys/ximage/ximagesink.c: (gst_ximagesink_check_xshm_calls),
(gst_ximagesink_ximage_new):
* sys/xvimage/xvimagesink.c: (gst_xvimagesink_check_xshm_calls),
(gst_xvimagesink_xvimage_new):
* tests/check/elements/audioconvert.c:
* tests/check/elements/audioresample.c:
(fail_unless_perfect_stream):
* tests/check/elements/audiotestsrc.c: (setup_audiotestsrc):
* tests/check/elements/decodebin.c:
* tests/check/elements/gdpdepay.c: (setup_gdpdepay),
(setup_gdpdepay_streamheader):
* tests/check/elements/gdppay.c: (setup_gdppay), (GST_START_TEST),
(setup_gdppay_streamheader):
* tests/check/elements/gnomevfssink.c: (setup_gnomevfssink):
* tests/check/elements/multifdsink.c: (setup_multifdsink):
* tests/check/elements/textoverlay.c:
* tests/check/elements/videorate.c: (setup_videorate):
* tests/check/elements/videotestsrc.c: (setup_videotestsrc):
* tests/check/elements/volume.c: (setup_volume):
* tests/check/elements/vorbisdec.c: (setup_vorbisdec):
* tests/check/elements/vorbistag.c:
* tests/check/generic/clock-selection.c:
* tests/check/generic/states.c: (setup), (teardown):
* tests/check/libs/cddabasesrc.c:
* tests/check/libs/video.c:
* tests/check/pipelines/gio.c:
* tests/check/pipelines/oggmux.c:
* tests/check/pipelines/simple-launch-lines.c:
(simple_launch_lines_suite):
* tests/check/pipelines/streamheader.c:
* tests/check/pipelines/theoraenc.c:
* tests/check/pipelines/vorbisdec.c:
* tests/check/pipelines/vorbisenc.c:
* tests/examples/seek/scrubby.c:
* tests/examples/seek/seek.c: (query_positions_elems),
(query_positions_pads):
* tests/icles/stress-xoverlay.c: (myclock):
Correct all relevant warnings found by the sparse semantic code
analyzer. This include marking several symbols static, using
NULL instead of 0 for pointers and using "foo (void)" instead
of "foo ()" for declarations.
* win32/common/libgstrtp.def:
Add gst_rtp_buffer_set_extension_data to the symbol definition file.
2008-03-03 06:04:31 +00:00
|
|
|
setup_gnomevfssink (void)
|
2007-05-22 15:45:19 +00:00
|
|
|
{
|
|
|
|
GstElement *gnomevfssink;
|
|
|
|
|
|
|
|
GST_DEBUG ("setup_gnomevfssink");
|
|
|
|
gnomevfssink = gst_check_setup_element ("gnomevfssink");
|
|
|
|
mysrcpad = gst_check_setup_src_pad (gnomevfssink, &srctemplate, NULL);
|
|
|
|
gst_pad_set_active (mysrcpad, TRUE);
|
|
|
|
return gnomevfssink;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
cleanup_gnomevfssink (GstElement * gnomevfssink)
|
|
|
|
{
|
|
|
|
gst_pad_set_active (mysrcpad, FALSE);
|
|
|
|
gst_check_teardown_src_pad (gnomevfssink);
|
|
|
|
gst_check_teardown_element (gnomevfssink);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
/* this queries via the element vfunc, which is currently not implemented */
|
|
|
|
#define CHECK_QUERY_POSITION(gnomevfssink,format,position) \
|
|
|
|
G_STMT_START { \
|
|
|
|
GstFormat fmt = format; \
|
|
|
|
gint64 pos; \
|
|
|
|
fail_unless (gst_element_query_position (gnomevfssink, &fmt, &pos)); \
|
|
|
|
fail_unless_equals_int (pos, position); \
|
|
|
|
} G_STMT_END
|
|
|
|
#else
|
Don't use bad gst_element_get_pad().
Original commit message from CVS:
* ext/ogg/gstoggdemux.c: (gst_ogg_pad_typefind):
* gst/playback/decodetest.c: (new_decoded_pad_cb):
* gst/playback/gstdecodebin.c: (gst_decode_bin_init),
(try_to_link_1), (elem_is_dynamic), (close_link), (type_found),
(cleanup_decodebin):
* gst/playback/gstdecodebin2.c: (gst_decode_bin_init),
(connect_element), (gst_decode_group_control_demuxer_pad):
* gst/playback/gstplaybasebin.c: (queue_remove_probe),
(queue_out_of_data), (gen_preroll_element), (preroll_unlinked),
(mute_group_type):
* gst/playback/gstplaybin.c: (gst_play_bin_vis_blocked),
(gst_play_bin_set_property), (handoff), (gen_video_element),
(gen_text_element), (gen_audio_element), (gen_vis_element),
(remove_sinks), (add_sink), (setup_sinks):
* gst/playback/gstplaybin2.c: (pad_added_cb), (no_more_pads_cb):
* gst/playback/gstplaysink.c: (gst_play_sink_get_video_sink),
(gst_play_sink_get_audio_sink), (gst_play_sink_vis_unblocked),
(gst_play_sink_vis_blocked), (gst_play_sink_set_vis_plugin),
(gst_play_sink_get_vis_plugin), (gst_play_sink_set_mute),
(gen_video_chain), (gen_text_chain), (gen_audio_chain),
(gen_vis_chain), (gst_play_sink_reconfigure),
(gst_play_sink_set_font_desc), (gst_play_sink_get_font_desc),
(gst_play_sink_request_pad):
* gst/playback/gsturidecodebin.c: (type_found), (setup_source):
* gst/playback/test.c: (gen_video_element), (gen_audio_element),
(cb_newpad):
* gst/playback/test6.c: (new_decoded_pad_cb):
* tests/check/elements/audioconvert.c: (GST_START_TEST):
* tests/check/elements/audiorate.c: (test_injector_chain),
(do_perfect_stream_test):
* tests/check/elements/ffmpegcolorspace.c: (GST_START_TEST):
* tests/check/elements/gdpdepay.c: (GST_START_TEST):
* tests/check/elements/gnomevfssink.c:
* tests/check/elements/textoverlay.c:
(notgst_check_setup_src_pad2), (notgst_check_teardown_src_pad2):
* tests/check/elements/videotestsrc.c: (GST_START_TEST):
* tests/check/libs/cddabasesrc.c: (GST_START_TEST):
* tests/check/pipelines/oggmux.c: (test_pipeline):
* tests/check/pipelines/streamheader.c: (GST_START_TEST):
* tests/check/pipelines/theoraenc.c: (GST_START_TEST):
* tests/check/pipelines/vorbisenc.c: (GST_START_TEST):
* tests/examples/seek/scrubby.c: (make_wav_pipeline):
* tests/examples/seek/seek.c: (make_mod_pipeline),
(make_dv_pipeline), (make_wav_pipeline), (make_flac_pipeline),
(make_sid_pipeline), (make_parse_pipeline), (make_vorbis_pipeline),
(make_theora_pipeline), (make_vorbis_theora_pipeline),
(make_avi_msmpeg4v3_mp3_pipeline), (make_mp3_pipeline),
(make_avi_pipeline), (make_mpeg_pipeline), (make_mpegnt_pipeline),
(update_fill), (msg_buffering):
Don't use bad gst_element_get_pad().
2008-05-21 16:36:50 +00:00
|
|
|
#define CHECK_QUERY_POSITION(gnomevfssink,format,position) \
|
2007-05-22 15:45:19 +00:00
|
|
|
G_STMT_START { \
|
|
|
|
GstFormat fmt = format; \
|
|
|
|
GstPad *pad; \
|
|
|
|
gint64 pos; \
|
Don't use bad gst_element_get_pad().
Original commit message from CVS:
* ext/ogg/gstoggdemux.c: (gst_ogg_pad_typefind):
* gst/playback/decodetest.c: (new_decoded_pad_cb):
* gst/playback/gstdecodebin.c: (gst_decode_bin_init),
(try_to_link_1), (elem_is_dynamic), (close_link), (type_found),
(cleanup_decodebin):
* gst/playback/gstdecodebin2.c: (gst_decode_bin_init),
(connect_element), (gst_decode_group_control_demuxer_pad):
* gst/playback/gstplaybasebin.c: (queue_remove_probe),
(queue_out_of_data), (gen_preroll_element), (preroll_unlinked),
(mute_group_type):
* gst/playback/gstplaybin.c: (gst_play_bin_vis_blocked),
(gst_play_bin_set_property), (handoff), (gen_video_element),
(gen_text_element), (gen_audio_element), (gen_vis_element),
(remove_sinks), (add_sink), (setup_sinks):
* gst/playback/gstplaybin2.c: (pad_added_cb), (no_more_pads_cb):
* gst/playback/gstplaysink.c: (gst_play_sink_get_video_sink),
(gst_play_sink_get_audio_sink), (gst_play_sink_vis_unblocked),
(gst_play_sink_vis_blocked), (gst_play_sink_set_vis_plugin),
(gst_play_sink_get_vis_plugin), (gst_play_sink_set_mute),
(gen_video_chain), (gen_text_chain), (gen_audio_chain),
(gen_vis_chain), (gst_play_sink_reconfigure),
(gst_play_sink_set_font_desc), (gst_play_sink_get_font_desc),
(gst_play_sink_request_pad):
* gst/playback/gsturidecodebin.c: (type_found), (setup_source):
* gst/playback/test.c: (gen_video_element), (gen_audio_element),
(cb_newpad):
* gst/playback/test6.c: (new_decoded_pad_cb):
* tests/check/elements/audioconvert.c: (GST_START_TEST):
* tests/check/elements/audiorate.c: (test_injector_chain),
(do_perfect_stream_test):
* tests/check/elements/ffmpegcolorspace.c: (GST_START_TEST):
* tests/check/elements/gdpdepay.c: (GST_START_TEST):
* tests/check/elements/gnomevfssink.c:
* tests/check/elements/textoverlay.c:
(notgst_check_setup_src_pad2), (notgst_check_teardown_src_pad2):
* tests/check/elements/videotestsrc.c: (GST_START_TEST):
* tests/check/libs/cddabasesrc.c: (GST_START_TEST):
* tests/check/pipelines/oggmux.c: (test_pipeline):
* tests/check/pipelines/streamheader.c: (GST_START_TEST):
* tests/check/pipelines/theoraenc.c: (GST_START_TEST):
* tests/check/pipelines/vorbisenc.c: (GST_START_TEST):
* tests/examples/seek/scrubby.c: (make_wav_pipeline):
* tests/examples/seek/seek.c: (make_mod_pipeline),
(make_dv_pipeline), (make_wav_pipeline), (make_flac_pipeline),
(make_sid_pipeline), (make_parse_pipeline), (make_vorbis_pipeline),
(make_theora_pipeline), (make_vorbis_theora_pipeline),
(make_avi_msmpeg4v3_mp3_pipeline), (make_mp3_pipeline),
(make_avi_pipeline), (make_mpeg_pipeline), (make_mpegnt_pipeline),
(update_fill), (msg_buffering):
Don't use bad gst_element_get_pad().
2008-05-21 16:36:50 +00:00
|
|
|
pad = gst_element_get_static_pad (gnomevfssink, "sink"); \
|
2007-05-22 15:45:19 +00:00
|
|
|
fail_unless (gst_pad_query_position (pad, &fmt, &pos)); \
|
|
|
|
fail_unless_equals_int (pos, position); \
|
|
|
|
gst_object_unref (pad); \
|
|
|
|
} G_STMT_END
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define PUSH_BYTES(num_bytes) \
|
|
|
|
G_STMT_START { \
|
|
|
|
GstBuffer *buf = gst_buffer_new_and_alloc(num_bytes); \
|
|
|
|
GRand *rand = g_rand_new_with_seed (num_bytes); \
|
2011-03-28 12:12:24 +00:00
|
|
|
gsize i; \
|
|
|
|
guint8 *data; \
|
|
|
|
data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE); \
|
2007-05-22 15:45:19 +00:00
|
|
|
for (i = 0; i < num_bytes; ++i) \
|
2011-03-28 12:12:24 +00:00
|
|
|
data[i] = (g_rand_int (rand) >> 24) & 0xff; \
|
|
|
|
gst_buffer_unmap (buf, data, num_bytes); \
|
2007-05-22 15:45:19 +00:00
|
|
|
fail_unless_equals_int (gst_pad_push (mysrcpad, buf), GST_FLOW_OK); \
|
|
|
|
g_rand_free (rand); \
|
|
|
|
} G_STMT_END
|
|
|
|
|
|
|
|
/* TODO: we don't check that the data is actually written to the right
|
|
|
|
* position after a seek */
|
|
|
|
GST_START_TEST (test_seeking)
|
|
|
|
{
|
|
|
|
const gchar *tmpdir;
|
|
|
|
GstElement *gnomevfssink;
|
|
|
|
gchar *tmp_fn;
|
|
|
|
gint fd;
|
|
|
|
|
|
|
|
tmpdir = g_get_tmp_dir ();
|
|
|
|
if (tmpdir == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* this is just silly, but gcc warns if we try to use tpmnam() */
|
|
|
|
tmp_fn =
|
|
|
|
g_build_filename (tmpdir, "gstreamer-gnomevfssink-test-XXXXXX", NULL);
|
|
|
|
fd = g_mkstemp (tmp_fn);
|
|
|
|
if (fd < 0) {
|
|
|
|
GST_ERROR ("can't create temp file %s: %s", tmp_fn, g_strerror (errno));
|
|
|
|
g_free (tmp_fn);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* don't want the file, just a filename (hence silly, see above) */
|
|
|
|
close (fd);
|
|
|
|
g_remove (tmp_fn);
|
|
|
|
|
|
|
|
gnomevfssink = setup_gnomevfssink ();
|
|
|
|
|
|
|
|
GST_LOG ("using temp file '%s'", tmp_fn);
|
|
|
|
g_object_set (gnomevfssink, "location", tmp_fn, NULL);
|
|
|
|
|
|
|
|
fail_unless_equals_int (gst_element_set_state (gnomevfssink,
|
|
|
|
GST_STATE_PLAYING), GST_STATE_CHANGE_ASYNC);
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
/* Test that gnomevfssink is seekable with a file fd */
|
|
|
|
/* gnomevfssink doesn't implement seekable query at the moment */
|
|
|
|
GstQuery *seeking_query;
|
|
|
|
gboolean seekable;
|
|
|
|
|
|
|
|
fail_unless ((seeking_query = gst_query_new_seeking (GST_FORMAT_BYTES))
|
|
|
|
!= NULL);
|
|
|
|
fail_unless (gst_element_query (gnomevfssink, seeking_query) == TRUE);
|
|
|
|
gst_query_parse_seeking (seeking_query, NULL, &seekable, NULL, NULL);
|
|
|
|
fail_unless (seekable == TRUE);
|
|
|
|
gst_query_unref (seeking_query);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
fail_unless (gst_pad_push_event (mysrcpad,
|
|
|
|
gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_BYTES, 0, -1, 0)));
|
|
|
|
|
|
|
|
CHECK_QUERY_POSITION (gnomevfssink, GST_FORMAT_BYTES, 0);
|
|
|
|
|
|
|
|
/* push buffer with size 0 and NULL data */
|
|
|
|
PUSH_BYTES (0);
|
|
|
|
CHECK_QUERY_POSITION (gnomevfssink, GST_FORMAT_BYTES, 0);
|
|
|
|
|
|
|
|
PUSH_BYTES (1);
|
|
|
|
CHECK_QUERY_POSITION (gnomevfssink, GST_FORMAT_BYTES, 1);
|
|
|
|
|
|
|
|
PUSH_BYTES (99);
|
|
|
|
CHECK_QUERY_POSITION (gnomevfssink, GST_FORMAT_BYTES, 100);
|
|
|
|
|
|
|
|
PUSH_BYTES (8800);
|
|
|
|
CHECK_QUERY_POSITION (gnomevfssink, GST_FORMAT_BYTES, 8900);
|
|
|
|
|
|
|
|
if (gst_pad_push_event (mysrcpad,
|
|
|
|
gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_BYTES, 8800, -1,
|
|
|
|
0))) {
|
|
|
|
GST_LOG ("seek ok");
|
|
|
|
/* make sure that that new position is reported immediately */
|
|
|
|
CHECK_QUERY_POSITION (gnomevfssink, GST_FORMAT_BYTES, 8800);
|
|
|
|
PUSH_BYTES (1);
|
|
|
|
CHECK_QUERY_POSITION (gnomevfssink, GST_FORMAT_BYTES, 8801);
|
|
|
|
PUSH_BYTES (9256);
|
|
|
|
CHECK_QUERY_POSITION (gnomevfssink, GST_FORMAT_BYTES, 18057);
|
|
|
|
} else {
|
|
|
|
GST_INFO ("seeking not supported for tempfile?!");
|
|
|
|
}
|
|
|
|
|
|
|
|
fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_eos ()));
|
|
|
|
|
|
|
|
fail_unless_equals_int (gst_element_set_state (gnomevfssink, GST_STATE_NULL),
|
|
|
|
GST_STATE_CHANGE_SUCCESS);
|
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_gnomevfssink (gnomevfssink);
|
|
|
|
|
|
|
|
/* check that we wrote data to the right position after the seek */
|
|
|
|
{
|
|
|
|
gchar *data = NULL;
|
|
|
|
gsize len;
|
|
|
|
|
|
|
|
fail_unless (g_file_get_contents (tmp_fn, &data, &len, NULL),
|
|
|
|
"Failed to read in newly-created file '%s'", tmp_fn);
|
|
|
|
fail_unless_equals_int (len, 18057);
|
|
|
|
{
|
|
|
|
/* we wrote 9256 bytes at position 8801 */
|
|
|
|
GRand *rand = g_rand_new_with_seed (9256);
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
for (i = 0; i < 9256; ++i) {
|
|
|
|
guint8 byte_written = *(((guint8 *) data) + 8801 + i);
|
|
|
|
|
|
|
|
fail_unless_equals_int (byte_written, g_rand_int (rand) >> 24);
|
|
|
|
}
|
|
|
|
g_rand_free (rand);
|
|
|
|
}
|
|
|
|
g_free (data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* remove file */
|
|
|
|
g_remove (tmp_fn);
|
|
|
|
g_free (tmp_fn);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_coverage)
|
|
|
|
{
|
|
|
|
GstElement *gnomevfssink;
|
|
|
|
gchar *location;
|
|
|
|
GstBus *bus;
|
|
|
|
GstMessage *message;
|
|
|
|
|
|
|
|
gnomevfssink = setup_gnomevfssink ();
|
|
|
|
bus = gst_bus_new ();
|
|
|
|
|
|
|
|
gst_element_set_bus (gnomevfssink, bus);
|
|
|
|
|
|
|
|
g_object_set (gnomevfssink, "location", "/i/do/not/exist", NULL);
|
|
|
|
g_object_get (gnomevfssink, "location", &location, NULL);
|
|
|
|
fail_unless_equals_string (location, "/i/do/not/exist");
|
|
|
|
g_free (location);
|
|
|
|
|
|
|
|
fail_unless_equals_int (gst_element_set_state (gnomevfssink,
|
|
|
|
GST_STATE_PLAYING), GST_STATE_CHANGE_FAILURE);
|
|
|
|
|
|
|
|
/* a state change and an error */
|
|
|
|
fail_if ((message = gst_bus_pop (bus)) == NULL);
|
|
|
|
fail_unless_message_error (message, RESOURCE, OPEN_WRITE);
|
|
|
|
gst_message_unref (message);
|
|
|
|
|
|
|
|
g_object_set (gnomevfssink, "location", NULL, NULL);
|
|
|
|
g_object_get (gnomevfssink, "location", &location, NULL);
|
|
|
|
fail_if (location);
|
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
gst_element_set_bus (gnomevfssink, NULL);
|
|
|
|
gst_object_unref (GST_OBJECT (bus));
|
|
|
|
cleanup_gnomevfssink (gnomevfssink);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_uri_interface)
|
|
|
|
{
|
|
|
|
GstElement *gnomevfssink;
|
|
|
|
gchar *location;
|
|
|
|
GstBus *bus;
|
|
|
|
|
|
|
|
gnomevfssink = setup_gnomevfssink ();
|
|
|
|
bus = gst_bus_new ();
|
|
|
|
|
|
|
|
gst_element_set_bus (gnomevfssink, bus);
|
|
|
|
|
|
|
|
g_object_set (G_OBJECT (gnomevfssink), "location", "/i/do/not/exist", NULL);
|
|
|
|
g_object_get (G_OBJECT (gnomevfssink), "location", &location, NULL);
|
|
|
|
fail_unless_equals_string (location, "/i/do/not/exist");
|
|
|
|
g_free (location);
|
|
|
|
|
|
|
|
location = (gchar *) gst_uri_handler_get_uri (GST_URI_HANDLER (gnomevfssink));
|
|
|
|
fail_unless_equals_string (location, "file://%2Fi%2Fdo%2Fnot%2Fexist");
|
|
|
|
|
|
|
|
/* should accept file:///foo/bar URIs */
|
|
|
|
fail_unless (gst_uri_handler_set_uri (GST_URI_HANDLER (gnomevfssink),
|
|
|
|
"file:///foo/bar"));
|
|
|
|
location = (gchar *) gst_uri_handler_get_uri (GST_URI_HANDLER (gnomevfssink));
|
|
|
|
fail_unless_equals_string (location, "file://%2Ffoo%2Fbar");
|
|
|
|
g_object_get (G_OBJECT (gnomevfssink), "location", &location, NULL);
|
|
|
|
fail_unless_equals_string (location, "/foo/bar");
|
|
|
|
g_free (location);
|
|
|
|
|
|
|
|
/* should accept file://localhost/foo/bar URIs */
|
|
|
|
fail_unless (gst_uri_handler_set_uri (GST_URI_HANDLER (gnomevfssink),
|
|
|
|
"file://localhost/foo/baz"));
|
|
|
|
location = (gchar *) gst_uri_handler_get_uri (GST_URI_HANDLER (gnomevfssink));
|
|
|
|
fail_unless_equals_string (location, "file://%2Ffoo%2Fbaz");
|
|
|
|
g_object_get (G_OBJECT (gnomevfssink), "location", &location, NULL);
|
|
|
|
fail_unless_equals_string (location, "/foo/baz");
|
|
|
|
g_free (location);
|
|
|
|
|
|
|
|
/* should fail with other hostnames */
|
|
|
|
fail_if (gst_uri_handler_set_uri (GST_URI_HANDLER (gnomevfssink),
|
|
|
|
"file://hostname/foo/foo"));
|
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
gst_element_set_bus (gnomevfssink, NULL);
|
|
|
|
gst_object_unref (GST_OBJECT (bus));
|
|
|
|
cleanup_gnomevfssink (gnomevfssink);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
static Suite *
|
|
|
|
gnomevfssink_suite (void)
|
|
|
|
{
|
|
|
|
Suite *s = suite_create ("gnomevfssink");
|
|
|
|
TCase *tc_chain = tcase_create ("general");
|
|
|
|
|
|
|
|
suite_add_tcase (s, tc_chain);
|
|
|
|
|
|
|
|
/* FIXME: these two tests fail right now because of uri/location stuff */
|
|
|
|
if (0) {
|
|
|
|
tcase_add_test (tc_chain, test_coverage);
|
|
|
|
tcase_add_test (tc_chain, test_uri_interface);
|
|
|
|
}
|
|
|
|
tcase_add_test (tc_chain, test_seeking);
|
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_CHECK_MAIN (gnomevfssink);
|