*/
using Soup;
-using Gst;
public errordomain Rygel.TestError {
SKIP = 77,
}
public errordomain Rygel.HTTPRequestError {
- NOT_FOUND = Soup.KnownStatusCode.NOT_FOUND
+ NOT_FOUND = Soup.Status.NOT_FOUND
}
public class Rygel.HTTPResponseTest : GLib.Object {
private Error error;
public static int main (string[] args) {
- Gst.init (ref args);
-
try {
var test = new HTTPResponseTest.complete ();
test.run ();
if (active) {
this.cancellable = new Cancellable ();
- this.cancellable.cancelled += this.on_cancelled;
+ this.cancellable.cancelled.connect (this.on_cancelled);
}
}
private void on_cancelled (Cancellable cancellable) {
this.context.session.cancel_message (this.msg,
- KnownStatusCode.CANCELLED);
+ Status.CANCELLED);
this.completed ();
}
}
this.seek = seek;
this.cancellable = cancellable;
this.msg.response_headers.set_encoding (Soup.Encoding.EOF);
- this.msg.set_status (Soup.KnownStatusCode.OK);
+ this.msg.set_status (Soup.Status.OK);
}
}
}
}
+internal class Rygel.TestDataSource : Rygel.DataSource, Object {
+ private long block_size;
+ private long buffers;
+ private uint64 data_sent;
+ private bool frozen;
+
+ public TestDataSource (long block_size, long buffers) {
+ this.block_size = block_size;
+ this.buffers = buffers;
+ this.data_sent = 0;
+ }
+
+ public void start (HTTPSeek? seek) throws Error {
+ Idle.add ( () => {
+ if (frozen) {
+ return false;
+ }
+
+ var data = new uint8[block_size];
+ this.data_sent += block_size;
+ if (this.data_sent > HTTPResponseTest.MAX_BYTES) {
+ this.done ();
+
+ return false;
+ }
+
+ this.data_available (data);
+
+ return true;
+ });
+ }
+
+ public void freeze () {
+ this.frozen = true;
+ }
+
+ public void thaw () {
+ if (!this.frozen) {
+ return;
+ }
+
+ this.frozen = false;
+
+ try {
+ this.start (null);
+ } catch (GLib.Error error) {
+ assert_not_reached ();
+ }
+ }
+
+ public void stop () {
+ this.freeze ();
+ }
+}
+
public class Rygel.MediaItem {
- private static const long BLOCK_SIZE = HTTPResponseTest.MAX_BYTES / 16 + 1;
+ private static const long BLOCK_SIZE = HTTPResponseTest.MAX_BYTES / 16;
private static const long MAX_BUFFERS = 25;
public int64 size {
}
}
- private dynamic Element src;
+ private DataSource src;
+ bool is_live = false;
public MediaItem () {
- this.src = GstUtils.create_element ("fakesrc", null);
- this.src.sizetype = 2; // fixed
+ this.src = new TestDataSource (BLOCK_SIZE, MAX_BUFFERS);
+ this.is_live = true;
}
public MediaItem.fixed_size () {
this ();
-
- this.src.blocksize = BLOCK_SIZE;
- this.src.num_buffers = MAX_BUFFERS;
- this.src.sizemax = MAX_BUFFERS * BLOCK_SIZE;
}
- public Element? create_stream_source () {
+ public DataSource? create_stream_source () {
return this.src;
}
public bool is_live_stream () {
- return ((int) this.src.num_buffers) < 0;
+ return this.is_live;
}
}