Created
August 6, 2014 01:08
-
-
Save superlou/c3955431f71eb5766b4c to your computer and use it in GitHub Desktop.
Trying to write intervideosrc/sink test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* GStreamer | |
* | |
* unit test for intervideosrc | |
* | |
* Copyright (C) <2014> Louis Simons <lousimons at gmail dot com> | |
* | |
* 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., 51 Franklin St, Fifth Floor, | |
* Boston, MA 02110-1301, USA. | |
*/ | |
#ifdef HAVE_CONFIG_H | |
# include <config.h> | |
#endif | |
#ifdef HAVE_VALGRIND | |
# include <valgrind/valgrind.h> | |
#endif | |
#include <unistd.h> | |
#include <gst/check/gstcheck.h> | |
#include <gst/check/gstbufferstraw.h> | |
void print_info (GstMapInfo* info) | |
{ | |
g_printf ("size: %d\n", info->size); | |
for (guint32 i=0; i < info->size; i++) { | |
g_printf ("%x ", info->data[i]); | |
if ((i % 32) == 0) { | |
g_printf ("\n"); | |
} | |
} | |
g_printf ("\n"); | |
} | |
GST_START_TEST (switch_channel_while_playing) | |
{ | |
GstElement *pipeline; | |
GstElement *sink; | |
GstPad *pad; | |
GError *error = NULL; | |
GString *pipe_desc; | |
GstBuffer *buffer; | |
gboolean memory_map_success; | |
GstMapInfo info; | |
pipe_desc = g_string_new (""); | |
g_string_append (pipe_desc, "videotestsrc pattern=1 ! intervideosink"); // <-- shows a bunch of 0x80 followed by 0x10 | |
g_string_append (pipe_desc, " intervideosrc ! fakesink name=sink"); | |
// g_string_append (pipe_desc, "videotestsrc pattern=1 ! fakesink name=sink"); <-- shows reasonable data (random values) | |
pipeline = (GstElement *) gst_parse_launch(pipe_desc->str, &error); | |
fail_if (error, "Could not parse test pipeline"); | |
sink = gst_bin_get_by_name (GST_BIN (pipeline), "sink"); | |
pad = gst_element_get_static_pad(sink, "sink"); | |
gst_buffer_straw_start_pipeline(pipeline, pad); | |
g_usleep(1 * G_USEC_PER_SEC); | |
buffer = gst_buffer_straw_get_buffer (pipeline, pad); | |
memory_map_success = gst_buffer_map (buffer, &info, GST_MAP_READ); | |
fail_unless (memory_map_success, "Could not access buffer memory"); | |
print_info (&info); | |
gst_buffer_straw_stop_pipeline (pipeline, pad); | |
gst_object_unref (sink); | |
gst_object_unref (pad); | |
gst_object_unref (pipeline); | |
gst_buffer_unref (buffer); | |
g_string_free (pipe_desc, TRUE); | |
} | |
GST_END_TEST; | |
static Suite * | |
intervideosrc_suite(void) | |
{ | |
Suite *s = suite_create ("intervideosrc"); | |
TCase *tc_chain = tcase_create ("general"); | |
suite_add_tcase (s, tc_chain); | |
tcase_add_test (tc_chain, switch_channel_while_playing); | |
return s; | |
} | |
GST_CHECK_MAIN (intervideosrc) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment