rygel r345 - trunk/src/plugins/test
- From: zeeshanak svn gnome org
- To: svn-commits-list gnome org
- Subject: rygel r345 - trunk/src/plugins/test
- Date: Sun, 14 Dec 2008 20:22:23 +0000 (UTC)
Author: zeeshanak
Date: Sun Dec 14 20:22:23 2008
New Revision: 345
URL: http://svn.gnome.org/viewvc/rygel?rev=345&view=rev
Log:
Generalize: Put common code into TestItem class.
Put common code from TestAudioItem and TestVideoItem into TestItem class.
Modified:
trunk/src/plugins/test/Makefile.am
trunk/src/plugins/test/rygel-test-audio-item.vala
trunk/src/plugins/test/rygel-test-item.vala
trunk/src/plugins/test/rygel-test-video-item.vala
Modified: trunk/src/plugins/test/Makefile.am
==============================================================================
--- trunk/src/plugins/test/Makefile.am (original)
+++ trunk/src/plugins/test/Makefile.am Sun Dec 14 20:22:23 2008
@@ -12,6 +12,8 @@
BUILT_SOURCES = rygel-test.stamp \
rygel-test-content-dir.h \
rygel-test-content-dir.c \
+ rygel-test-item.h \
+ rygel-test-item.c \
rygel-test-audio-item.h \
rygel-test-audio-item.c \
rygel-test-video-item.h \
@@ -22,6 +24,9 @@
librygel_test_la_SOURCES = rygel-test-content-dir.h \
rygel-test-content-dir.c \
rygel-test-content-dir.vala \
+ rygel-test-item.h \
+ rygel-test-item.c \
+ rygel-test-item.vala \
rygel-test-audio-item.h \
rygel-test-audio-item.c \
rygel-test-audio-item.vala \
Modified: trunk/src/plugins/test/rygel-test-audio-item.vala
==============================================================================
--- trunk/src/plugins/test/rygel-test-audio-item.vala (original)
+++ trunk/src/plugins/test/rygel-test-audio-item.vala Sun Dec 14 20:22:23 2008
@@ -32,54 +32,24 @@
/**
* Represents Test audio item.
*/
-public class Rygel.TestAudioItem : Rygel.MediaItem {
+public class Rygel.TestAudioItem : Rygel.TestItem {
const string TEST_PATH = "/test.wav";
const string TEST_MIMETYPE = "audio/x-wav";
- const string TEST_AUTHOR = "Zeeshan Ali (Khattak)";
-
- private Streamer streamer;
public TestAudioItem (string id,
string parent_id,
string title,
Streamer streamer) {
- base (id, parent_id, title, MediaItem.AUDIO_CLASS);
- this.mime = TEST_MIMETYPE;
- this.author = TEST_AUTHOR;
- this.uri = streamer.create_uri_for_path (TEST_PATH);
-
- this.streamer = streamer;
-
- streamer.stream_available += this.on_stream_available;
- }
-
- private void on_stream_available (Streamer streamer,
- Stream stream,
- string path) {
- if (path != TEST_PATH) {
- /* Not our path and therefore not interesting. */
- stream.reject ();
- return;
- }
-
- // FIXME: This should be done by GstStream
- stream.set_mime_type (TestAudioItem.TEST_MIMETYPE);
-
- try {
- Element src = this.create_gst_source ();
- // Ask streamer to handle the stream for us but use our source in
- // the pipeline.
- streamer.stream_from_gst_source (src, stream);
- } catch (Error error) {
- critical ("Error in attempting to start streaming %s: %s",
- path,
- error.message);
-
- return;
- }
+ base (id,
+ parent_id,
+ title,
+ TEST_MIMETYPE,
+ MediaItem.AUDIO_CLASS,
+ streamer,
+ TEST_PATH);
}
- private Element create_gst_source () throws Error {
+ protected override Element create_gst_source () throws Error {
Bin bin = new Bin (this.title);
dynamic Element src = ElementFactory.make ("audiotestsrc", null);
Modified: trunk/src/plugins/test/rygel-test-item.vala
==============================================================================
--- trunk/src/plugins/test/rygel-test-item.vala (original)
+++ trunk/src/plugins/test/rygel-test-item.vala Sun Dec 14 20:22:23 2008
@@ -26,20 +26,62 @@
using Rygel;
using GUPnP;
-using DBus;
+using Gst;
/**
* Represents Test item.
*/
-public abstract class Rygel.TestItem : MediaItem {
- protected string parent_id;
+public abstract class Rygel.TestItem : Rygel.MediaItem {
+ const string TEST_AUTHOR = "Zeeshan Ali (Khattak)";
- public TestItem (string id,
- string parent_id,
- string title) {
- this.id = id;
- this.parent_id = parent_id;
- this.title = title;
+ public string path;
+
+ private Streamer streamer;
+
+ public TestItem (string id,
+ string parent_id,
+ string title,
+ string mime,
+ string upnp_class,
+ Streamer streamer,
+ string path) {
+ base (id, parent_id, title, upnp_class);
+ this.mime = mime;
+ this.streamer = streamer;
+ this.author = TEST_AUTHOR;
+ this.path= path;
+
+ this.uri = streamer.create_uri_for_path (path);
+
+ streamer.stream_available += this.on_stream_available;
+ }
+
+ private void on_stream_available (Streamer streamer,
+ Stream stream,
+ string path) {
+ if (path != this.path) {
+ /* Not our path and therefore not interesting. */
+ stream.reject ();
+ return;
+ }
+
+ // FIXME: This should be done by GstStream
+ stream.set_mime_type (this.mime);
+
+ try {
+ Element src = this.create_gst_source ();
+ // Ask streamer to handle the stream for us but use our source in
+ // the pipeline.
+ streamer.stream_from_gst_source (src, stream);
+ } catch (Error error) {
+ critical ("Error in attempting to start streaming %s: %s",
+ path,
+ error.message);
+
+ return;
+ }
}
+
+ protected abstract Element create_gst_source () throws Error;
}
Modified: trunk/src/plugins/test/rygel-test-video-item.vala
==============================================================================
--- trunk/src/plugins/test/rygel-test-video-item.vala (original)
+++ trunk/src/plugins/test/rygel-test-video-item.vala Sun Dec 14 20:22:23 2008
@@ -32,54 +32,24 @@
/**
* Represents Test video item.
*/
-public class Rygel.TestVideoItem : Rygel.MediaItem {
+public class Rygel.TestVideoItem : Rygel.TestItem {
const string TEST_PATH = "/test.ogg";
const string TEST_MIMETYPE = "application/ogg";
- const string TEST_AUTHOR = "Zeeshan Ali (Khattak)";
-
- private Streamer streamer;
public TestVideoItem (string id,
string parent_id,
string title,
Streamer streamer) {
- base (id, parent_id, title, MediaItem.VIDEO_CLASS);
- this.mime = TEST_MIMETYPE;
- this.author = TEST_AUTHOR;
- this.uri = streamer.create_uri_for_path (TEST_PATH);
-
- this.streamer = streamer;
-
- streamer.stream_available += this.on_stream_available;
- }
-
- private void on_stream_available (Streamer streamer,
- Stream stream,
- string path) {
- if (path != TEST_PATH) {
- /* Not our path and therefore not interesting. */
- stream.reject ();
- return;
- }
-
- // FIXME: This should be done by GstStream
- stream.set_mime_type (TestVideoItem.TEST_MIMETYPE);
-
- try {
- Element src = this.create_gst_source ();
- // Ask streamer to handle the stream for us but use our source in
- // the pipeline.
- streamer.stream_from_gst_source (src, stream);
- } catch (Error error) {
- critical ("Error in attempting to start streaming %s: %s",
- path,
- error.message);
-
- return;
- }
+ base (id,
+ parent_id,
+ title,
+ TEST_MIMETYPE,
+ MediaItem.VIDEO_CLASS,
+ streamer,
+ TEST_PATH);
}
- private Element create_gst_source () throws Error {
+ protected override Element create_gst_source () throws Error {
Bin bin = new Bin (this.title);
dynamic Element src = ElementFactory.make ("videotestsrc", null);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]