[gstreamermm: 134/167] added VideoDuration test
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gstreamermm: 134/167] added VideoDuration test
- Date: Tue, 3 Sep 2013 19:30:20 +0000 (UTC)
commit fb9afe1ead824c4d4c954e92218018204909d4c5
Author: Marcin Kolny at Flytronic <marcin kolny flytronic pl>
Date: Mon Aug 5 11:39:04 2013 +0200
added VideoDuration test
.gitignore | 1 +
tests/Makefile.am | 3 +-
tests/regression/test-regression-videoduration.cc | 106 +++++++++++++++++++++
3 files changed, 109 insertions(+), 1 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index b8e0859..eacc9c1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -480,6 +480,7 @@ test-plugin-pushsrc
test-plugin-register
test-regression-rewritefile
+test-regression-videoduration
# tools/
/tools/extra_defs_gen/generate_defs_gst
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 1e34858..4ecaf72 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -24,7 +24,7 @@ check_PROGRAMS = test-caps test-buffer test-bus test-caps test-pad \
test-ghostpad \
test-query test-structure test-taglist test-plugin-appsink \
test-plugin-appsrc test-plugin-register test-plugin-pushsrc \
- test-regression-rewritefile
+ test-regression-rewritefile test-regression-videoduration
# Include run of test programs in check:
TESTS = $(check_PROGRAMS)
@@ -46,3 +46,4 @@ test_plugin_pushsrc_SOURCES = plugins/test-plugin-pushsrc.cc
$(TEST_MAIN_SOURC
test_plugin_register_SOURCES = plugins/test-plugin-register.cc $(TEST_MAIN_SOURCE)
test_regression_rewritefile_SOURCES = regression/test-regression-rewritefile.cc $(TEST_MAIN_SOURCE)
$(TEST_REGRESSION_UTILS)
+test_regression_videoduration_SOURCES = regression/test-regression-videoduration.cc $(TEST_MAIN_SOURCE)
$(TEST_REGRESSION_UTILS)
diff --git a/tests/regression/test-regression-videoduration.cc
b/tests/regression/test-regression-videoduration.cc
new file mode 100644
index 0000000..25c5176
--- /dev/null
+++ b/tests/regression/test-regression-videoduration.cc
@@ -0,0 +1,106 @@
+/*
+ * test-regression-videoduration.cc
+ *
+ * Created on: Aug 5, 2013
+ * Author: m.kolny
+ */
+
+#include <gtest/gtest.h>
+#include <gstreamermm.h>
+#include <gstreamermm/fakesink.h>
+#include <glibmm.h>
+#include "utils.h"
+
+using namespace Gst;
+using Glib::RefPtr;
+
+RefPtr<Glib::MainLoop> mainloop;
+
+bool on_bus_message(const RefPtr<Bus>&, const Glib::RefPtr<Message>& message)
+{
+ switch(message->get_message_type())
+ {
+ case Gst::MESSAGE_EOS:
+ mainloop->quit();
+ return false;
+ case Gst::MESSAGE_ERROR:
+ {
+ mainloop->quit();
+ return false;
+ }
+ default:
+ break;
+ }
+
+ return true;
+}
+
+static void
+on_pad_added (GstElement *element,
+ GstPad *pad,
+ gpointer data)
+{
+ GstPad *sinkpad;
+ GstElement *decoder = (GstElement *) data;
+
+ sinkpad = gst_element_get_static_pad (decoder, "sink");
+
+ gst_pad_link (pad, sinkpad);
+
+ gst_object_unref (sinkpad);
+}
+
+
+static gboolean
+cb_print_position (GstElement *pipeline)
+{
+ gint64 len;
+
+ if (gst_element_query_duration (pipeline, GST_FORMAT_TIME, &len))
+ {
+ EXPECT_EQ(333333333, len);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+TEST(RegressionVideodurationTest, CreateVideoAndCheckDuration)
+{
+ Glib::ustring input_filename = "test.ogg";
+
+ GenerateSampleOggFile(10, input_filename);
+
+ Glib::RefPtr<Gst::Pipeline> pipeline;
+ RefPtr<FileSrc> filesrc = Gst::FileSrc::create();
+ ASSERT_TRUE(filesrc);
+
+ filesrc->property_location() = input_filename;
+
+ mainloop = Glib::MainLoop::create();
+ pipeline = Pipeline::create("rewriter");
+ RefPtr<Element> sink = ElementFactory::create_element("fakesink"),
+ demuxer = ElementFactory::create_element("oggdemux"),
+ decoder = ElementFactory::create_element("theoradec");
+ ASSERT_TRUE(sink);
+ ASSERT_TRUE(demuxer);
+ ASSERT_TRUE(decoder);
+
+ RefPtr<Bus> bus = pipeline->get_bus();
+ bus->add_watch(sigc::ptr_fun(&on_bus_message));
+
+ pipeline->add(filesrc)->add(demuxer)->add(decoder)->add(sink);
+ filesrc->link(demuxer);
+ decoder->link(sink);
+ g_signal_connect (demuxer->gobj(), "pad-added", G_CALLBACK(on_pad_added), decoder->gobj());
+
+ pipeline->set_state(Gst::STATE_PLAYING);
+ g_timeout_add(0, (GSourceFunc) cb_print_position, pipeline->gobj());
+ mainloop->run();
+
+ pipeline->set_state(Gst::STATE_NULL);
+
+ remove(input_filename.c_str());
+}
+
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]