[rygel] renderer: Add checks for GstPlayBin2
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] renderer: Add checks for GstPlayBin2
- Date: Thu, 20 Sep 2012 15:14:29 +0000 (UTC)
commit 0939d0ec10a0a59eabbe9d8666743ce23aad1794
Author: Murray Cumming <murrayc murrayc com>
Date: Mon Sep 10 12:35:17 2012 +0200
renderer: Add checks for GstPlayBin2
src/librygel-renderer/rygel-playbin-player.vala | 4 ++
src/librygel-renderer/rygel-playbin-renderer.vala | 8 +++
tests/Makefile.am | 24 ++++++++++
tests/rygel-playbin-renderer-test.vala | 52 +++++++++++++++++++++
4 files changed, 88 insertions(+), 0 deletions(-)
---
diff --git a/src/librygel-renderer/rygel-playbin-player.vala b/src/librygel-renderer/rygel-playbin-player.vala
index 392f21e..65c03ca 100644
--- a/src/librygel-renderer/rygel-playbin-player.vala
+++ b/src/librygel-renderer/rygel-playbin-player.vala
@@ -253,6 +253,10 @@ public class Rygel.Playbin.Player : GLib.Object, Rygel.MediaPlayer {
}
public Player.wrap (Gst.Element playbin) {
+
+ return_if_fail (playbin != null);
+ return_if_fail (playbin.get_type ().name() == "GstPlayBin2");
+
this.playbin = playbin;
this.setup_playbin ();
}
diff --git a/src/librygel-renderer/rygel-playbin-renderer.vala b/src/librygel-renderer/rygel-playbin-renderer.vala
index dd81780..d85ae6b 100644
--- a/src/librygel-renderer/rygel-playbin-renderer.vala
+++ b/src/librygel-renderer/rygel-playbin-renderer.vala
@@ -26,6 +26,10 @@ internal class Rygel.Playbin.WrappingPlugin : Rygel.MediaRendererPlugin {
public WrappingPlugin (Gst.Element playbin) {
base ("LibRygel-Renderer", _("LibRygel Renderer"));
+
+ return_val_if_fail (playbin != null, null);
+ return_val_if_fail (playbin.get_type ().name() == "GstPlayBin2", null);
+
this.player = new Player.wrap (playbin);
}
@@ -67,6 +71,10 @@ public class Rygel.Playbin.Renderer : Rygel.MediaDevice {
*/
public Renderer.wrap (Gst.Element pipeline, string title) {
base ();
+
+ return_val_if_fail (pipeline != null, null);
+ return_val_if_fail (pipeline.get_type ().name() == "GstPlayBin2", null);
+
this.plugin = new WrappingPlugin (pipeline);
this.prepare_upnp (title);
}
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 6f45dfb..7ee2aa7 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -42,6 +42,7 @@ check_PROGRAMS = rygel-http-item-uri-test \
rygel-http-post-test \
rygel-searchable-container-test \
rygel-item-creator-test \
+ rygel-playbin-renderer-test \
rygel-regression
TESTS = $(check_PROGRAMS)
@@ -93,6 +94,29 @@ rygel_item_creator_test_SOURCES = rygel-item-creator-test.vala \
rygel-relational-expression.vala \
rygel-search-expression.vala
+
+rygel_playbin_renderer_test_SOURCES = rygel-playbin-renderer-test.vala
+
+rygel_playbin_renderer_test_VALAFLAGS = \
+ $(AM_VALAFLAGS) \
+ --pkg rygel-renderer-1.0 \
+ --pkg rygel-core-1.0 \
+ --vapidir $(top_builddir)/src/librygel-renderer \
+ --vapidir $(top_builddir)/src/librygel-core
+
+rygel_playbin_renderer_test_LDADD = \
+ $(LDADD) \
+ $(top_builddir)/src/librygel-renderer/librygel-renderer-1.0.la \
+ $(top_builddir)/src/librygel-core/librygel-core-1.0.la
+
+rygel_playbin_renderer_test_CFLAGS = \
+ $(AM_CFLAGS) \
+ -I$(top_builddir)/src/librygel-renderer \
+ -I$(top_srcdir)/src/librygel-renderer \
+ -I$(top_builddir)/src/librygel-core \
+ -I$(top_srcdir)/src/librygel-core
+
+
rygel_regression_SOURCES = \
rygel-regression.vala
diff --git a/tests/rygel-playbin-renderer-test.vala b/tests/rygel-playbin-renderer-test.vala
new file mode 100644
index 0000000..94d35ea
--- /dev/null
+++ b/tests/rygel-playbin-renderer-test.vala
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2012 Openismus GmbH
+ *
+ * Author: Murray Cumming <murrayc openismus com>
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/**
+ * TODO: This currently just tests instantiation.
+ * We should also test how it works somehow.
+ */
+private class Rygel.PlaybinRendererTest : GLib.Object {
+ public static int main (string[] args) {
+ Gst.init (ref args);
+
+ var test = new PlaybinRendererTest ();
+ test.test_with_default_gstplaybin2 ();
+ test.test_with_existing_gstplaybin2 ();
+
+ return 0;
+ }
+
+ public void test_with_default_gstplaybin2() {
+ var renderer = new Rygel.Playbin.Renderer ("test playbin renderer");
+ assert (renderer != null);
+ var player = Rygel.Playbin.Player.get_default ();
+ assert (player.playbin != null);
+ }
+
+ public void test_with_existing_gstplaybin2() {
+ var element = Gst.ElementFactory.make ("playbin2", null);
+ var renderer = new Rygel.Playbin.Renderer.wrap (element, "test playbin renderer");
+ assert (renderer != null);
+ var player = Rygel.Playbin.Player.get_default ();
+ assert (player.playbin != null);
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]