http_server);
}
- public override Element create_gst_source () throws Error {
+ public override Element? create_stream_source () {
Bin bin = new Bin (this.title);
dynamic Element src = ElementFactory.make ("audiotestsrc", null);
Element encoder = ElementFactory.make ("wavenc", null);
if (src == null || encoder == null) {
- throw new LiveResponseError.MISSING_PLUGIN (
- "Required plugin missing");
+ warning ("Required plugin missing");
+
+ return null;
}
// Tell the source to behave like a live source
this.mime_type = mime;
this.author = TEST_AUTHOR;
}
-
- public abstract Element create_gst_source () throws Error;
}
base.root (title, 0);
this.http_server = http_server;
- this.http_server.need_stream_source += this.on_need_stream_source;
this.items = new ArrayList<MediaItem> ();
this.items.add (new TestAudioItem ("sinewave",
return item;
}
-
- /* Private methods */
- private void on_need_stream_source (HTTPServer http_server,
- MediaItem item,
- out Element src) {
- try {
- src = ((TestItem) item).create_gst_source ();
- } catch (Error error) {
- critical ("Error creating Gst source element for item %s: %s",
- item.id,
- error.message);
-
- return;
- }
- }
}
http_server);
}
- public override Element create_gst_source () throws Error {
+ public override Element? create_stream_source () {
Bin bin = new Bin (this.title);
dynamic Element src = ElementFactory.make ("videotestsrc", null);
Element muxer = ElementFactory.make ("mpegtsmux", null);
if (src == null || muxer == null || encoder == null) {
- throw new LiveResponseError.MISSING_PLUGIN (
- "Required plugin missing");
+ warning ("Required plugin missing");
+
+ return null;
}
// Tell the source to behave like a live source
private GUPnP.Context context;
private ArrayList<HTTPResponse> responses;
- public signal void need_stream_source (MediaItem item,
- out Element src);
-
public HTTPServer (ContentDirectory content_dir,
string name) {
this.content_dir = content_dir;
// URI provided, try to create source element from it
src = Element.make_from_uri (URIType.SRC, uri, null);
} else {
- // No URI provided, ask for source element directly
- this.need_stream_source (item, out src);
+ // No URI provided, ask for source element
+ src = item.create_stream_source ();
}
if (src == null) {
didl_writer.end_item ();
}
+ // Live media items need to provide a nice working implementation of this
+ // method if they can/do no provide a valid URI
+ public virtual Gst.Element? create_stream_source () {
+ return null;
+ }
+
private string get_protocol_for_uri (string uri) throws Error {
if (uri.has_prefix ("http")) {
return "http-get";