working buffer retrieval!
This commit is contained in:
parent
aae1de8291
commit
b475ba9782
1 changed files with 14 additions and 5 deletions
19
src/main.zig
19
src/main.zig
|
@ -26,7 +26,8 @@ pub fn main() !void {
|
||||||
gst.init(@ptrCast(&std.os.argv.len), @ptrCast(&std.os.argv.ptr));
|
gst.init(@ptrCast(&std.os.argv.len), @ptrCast(&std.os.argv.ptr));
|
||||||
|
|
||||||
const source: *gst.Element = gst.ElementFactory.make("videotestsrc", "source") orelse unreachable;
|
const source: *gst.Element = gst.ElementFactory.make("videotestsrc", "source") orelse unreachable;
|
||||||
const sink: *gst.Element = gst.ElementFactory.make("autovideosink", "sink") orelse unreachable;
|
const sink_el: *gst.Element = gst.ElementFactory.make("appsink", "sink") orelse unreachable;
|
||||||
|
const sink: *gstapp.AppSink = gobject.ext.cast(gstapp.AppSink, sink_el) orelse unreachable;
|
||||||
|
|
||||||
const pipeline: *gst.Pipeline = gst.Pipeline.new("test-pipeline");
|
const pipeline: *gst.Pipeline = gst.Pipeline.new("test-pipeline");
|
||||||
|
|
||||||
|
@ -38,28 +39,36 @@ pub fn main() !void {
|
||||||
// Gstreamer gives a critical warning when using gst.gst_bin_add_many, but doesn't
|
// Gstreamer gives a critical warning when using gst.gst_bin_add_many, but doesn't
|
||||||
// when calling each individually
|
// when calling each individually
|
||||||
_ = gst.Bin.add(bin, source);
|
_ = gst.Bin.add(bin, source);
|
||||||
_ = gst.Bin.add(bin, sink);
|
_ = gst.Bin.add(bin, sink_el);
|
||||||
|
|
||||||
// the failure return code is -1 I believe
|
// the failure return code is -1 I believe
|
||||||
if (gst.Element.link(source, sink) < 0) {
|
if (gst.Element.link(source, sink_el) < 0) {
|
||||||
pipeline.unref();
|
pipeline.unref();
|
||||||
std.debug.panic("Elements could not be linked\n", .{});
|
std.debug.panic("Elements could not be linked\n", .{});
|
||||||
}
|
}
|
||||||
|
|
||||||
// g_int is just i32. You can
|
// g_int is just i32. You can
|
||||||
// source.set("pattern", @as(i16, 0));
|
// source.set("pattern", @as(i16, 0));
|
||||||
gobject.Object.set(source.as(gobject.Object), "pattern", @as(i16, 0));
|
// gobject.Object.set(source.as(gobject.Object), "pattern", @as(i16, 0));
|
||||||
|
|
||||||
const ret = pipeline.as(gst.Element).setState(gst.State.playing);
|
const ret = pipeline.as(gst.Element).setState(gst.State.playing);
|
||||||
|
std.debug.print("pipeline state change returned: {any}\n", .{ ret });
|
||||||
if (ret == gst.StateChangeReturn.failure) {
|
if (ret == gst.StateChangeReturn.failure) {
|
||||||
pipeline.unref();
|
pipeline.unref();
|
||||||
std.debug.panic("Could not start pipeline", .{});
|
std.debug.panic("Could not start pipeline", .{});
|
||||||
}
|
}
|
||||||
|
|
||||||
const bus: *gst.Bus = pipeline.getBus();
|
const bus: *gst.Bus = pipeline.getBus();
|
||||||
|
|
||||||
|
const sample = sink.pullSample() orelse unreachable;
|
||||||
|
const buffer: *gst.Buffer = sample.getBuffer() orelse unreachable;
|
||||||
|
std.debug.print("Got the buffer! {any}\n", .{ buffer });
|
||||||
|
std.debug.print("My buffer was '{d}' big!\n", .{ buffer.getSize() });
|
||||||
|
|
||||||
|
|
||||||
// const msg: *gst.Message = bus.popFiltered( gst.MessageType.flags_eos + gst.MessageType.flags_warning );
|
// const msg: *gst.Message = bus.popFiltered( gst.MessageType.flags_eos + gst.MessageType.flags_warning );
|
||||||
const message_type: gst.MessageType = .{ .eos = true, .warning = true };
|
const message_type: gst.MessageType = .{ .eos = true, .warning = true };
|
||||||
const ret_msg: ?*gst.Message = bus.popFiltered(message_type);
|
const ret_msg: ?*gst.Message = bus.timedPopFiltered(std.math.maxInt(u64), message_type);
|
||||||
|
|
||||||
std.debug.print("reg_msg returned!\n", .{});
|
std.debug.print("reg_msg returned!\n", .{});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue