fixed zigified names
This commit is contained in:
parent
1fbbd80dc9
commit
e3a8b39f72
1 changed files with 17 additions and 17 deletions
34
src/main.zig
34
src/main.zig
|
@ -19,12 +19,12 @@ const max_edge_layers = 32;
|
||||||
|
|
||||||
pub fn main() !void {
|
pub fn main() !void {
|
||||||
// This allows me to utilize the same command line args and gstreamer
|
// This allows me to utilize the same command line args and gstreamer
|
||||||
gst.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.GstElement = gst.gst_element_factory_make("videotestsrc", "source");
|
const source: ?*gst.Element = gst.element_factory_make("videotestsrc", "source");
|
||||||
const sink: ?*gst.GstElement = gst.gst_element_factory_make("autovideosink", "sink");
|
const sink: ?*gst.Element = gst.element_factory_make("autovideosink", "sink");
|
||||||
|
|
||||||
const pipeline: ?*gst.GstElement = gst.gst_pipeline_new("test-pipeline");
|
const pipeline: ?*gst.Element = gst.pipeline_new("test-pipeline");
|
||||||
|
|
||||||
if (source == null or sink == null or pipeline == null) {
|
if (source == null or sink == null or pipeline == null) {
|
||||||
std.debug.panic("Not all elements could be created!", .{});
|
std.debug.panic("Not all elements could be created!", .{});
|
||||||
|
@ -37,26 +37,26 @@ 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.gst_bin_add(bin, source);
|
_ = gst.bin_add(bin, source);
|
||||||
_ = gst.gst_bin_add(bin, sink);
|
_ = gst.bin_add(bin, sink);
|
||||||
|
|
||||||
// the failure return code is -1 I believe
|
// the failure return code is -1 I believe
|
||||||
if (gst.gst_element_link(source, sink) < 0) {
|
if (gst.element_link(source, sink) < 0) {
|
||||||
gst.gst_object_unref(pipeline);
|
gst.object_unref(pipeline);
|
||||||
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
|
||||||
gst.g_object_set(source, "pattern", @as(i16, 0));
|
gst.g_object_set(source, "pattern", @as(i16, 0));
|
||||||
|
|
||||||
const ret = gst.gst_element_set_state(pipeline, gst.GST_STATE_PLAYING);
|
const ret = gst.element_set_state(pipeline, gst.GST_STATE_PLAYING);
|
||||||
if (ret == gst.GST_STATE_CHANGE_FAILURE) {
|
if (ret == gst.GST_STATE_CHANGE_FAILURE) {
|
||||||
gst.gst_object_unref(pipeline);
|
gst.object_unref(pipeline);
|
||||||
std.debug.panic("Could not start pipeline", .{});
|
std.debug.panic("Could not start pipeline", .{});
|
||||||
}
|
}
|
||||||
|
|
||||||
const bus: *gst.GstBus = gst.gst_element_get_bus(pipeline);
|
const bus: *gst.GstBus = gst.element_get_bus(pipeline);
|
||||||
const msg: *gst.GstMessage = gst.gst_bus_timed_pop_filtered( // This call holds until there is a valid message
|
const msg: *gst.GstMessage = gst.bus_timed_pop_filtered( // This call holds until there is a valid message
|
||||||
bus,
|
bus,
|
||||||
gst.GST_CLOCK_TIME_NONE,
|
gst.GST_CLOCK_TIME_NONE,
|
||||||
gst.GST_MESSAGE_ERROR | gst.GST_MESSAGE_EOS,
|
gst.GST_MESSAGE_ERROR | gst.GST_MESSAGE_EOS,
|
||||||
|
@ -68,7 +68,7 @@ pub fn main() !void {
|
||||||
|
|
||||||
switch (gst.GST_MESSAGE_TYPE(msg)) {
|
switch (gst.GST_MESSAGE_TYPE(msg)) {
|
||||||
gst.GST_MESSAGE_ERROR => {
|
gst.GST_MESSAGE_ERROR => {
|
||||||
gst.gst_message_parse_error(msg, err, &debug_info);
|
gst.message_parse_error(msg, err, &debug_info);
|
||||||
std.debug.print("Error received from element {s}: {s}", .{ gst.GST_OBJECT_NAME(msg.src), err.*.*.message });
|
std.debug.print("Error received from element {s}: {s}", .{ gst.GST_OBJECT_NAME(msg.src), err.*.*.message });
|
||||||
if (debug_info != null) { // I couldn't figure out how to do a orelse statement for this unwrap.
|
if (debug_info != null) { // I couldn't figure out how to do a orelse statement for this unwrap.
|
||||||
std.debug.print("Debugging information: {s}", .{debug_info.?});
|
std.debug.print("Debugging information: {s}", .{debug_info.?});
|
||||||
|
@ -78,10 +78,10 @@ pub fn main() !void {
|
||||||
},
|
},
|
||||||
else => {},
|
else => {},
|
||||||
}
|
}
|
||||||
gst.gst_message_unref(msg);
|
gst.message_unref(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
gst.gst_object_unref(bus);
|
gst.object_unref(bus);
|
||||||
_ = gst.gst_element_set_state(pipeline, gst.GST_STATE_NULL);
|
_ = gst.element_set_state(pipeline, gst.GST_STATE_NULL);
|
||||||
gst.gst_object_unref(pipeline);
|
gst.object_unref(pipeline);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue