diff --git a/build.zig b/build.zig index 09e1bd2..d78e75b 100644 --- a/build.zig +++ b/build.zig @@ -24,48 +24,27 @@ pub fn build(b: *std.Build) void { .optimize = optimize, }); - // These environment vars are set with the `nix develop` command - const gst_dev_path = b.graph.env_map.get("GST_DEV_PATH"); - const gst_plugins_base_path = b.graph.env_map.get("GST_PLUGINS_BASE_PATH"); // system libraries - const gst_plugins_base_dev_path = b.graph.env_map.get("GST_PLUGINS_BASE_DEV_PATH"); // header files - const glib_dev_path = b.graph.env_map.get("GLIB_DEV_PATH"); - const glib_path = b.graph.env_map.get("GLIB_PATH"); - - if (gst_dev_path == null) { - std.debug.panic("GST_DEV_PATH environment variable was not set. Has the nix flake been updated? This should point at the gstreamer.XXX-dev folder", .{}); - } - - if (gst_plugins_base_path == null) { - std.debug.panic("GST_PLUGINS_PATH environment variable was not set. Has the nix flake been updated? This should point at the gst_all_1.gst-plugins-base folder", .{}); - } - - if (gst_plugins_base_dev_path == null) { - std.debug.panic("GST_PLUGINS_DEV_PATH environment variable was not set. Has the nix flake been updated? This should point at the gst_all_1.gst-plugins-base.dev folder", .{}); - } - - if (glib_dev_path == null) { - std.debug.panic("GLIB_DEV_PATH environment variable was not set. Has the nix flake been updated? This should point at the glib.XXX-dev folder", .{}); - } - - if (glib_path == null) { - std.debug.panic("GLIB_PATH environment variable was not set. Has the nix flake been updated? This should point at the glib.XXX folder", .{}); - } exe.linkSystemLibrary("c"); + exe.addIncludePath(.{ .cwd_relative = "/usr/include/hailo" }); - exe.linkSystemLibrary("gstreamer-1.0"); - exe.linkSystemLibrary("gstapp-1.0"); - exe.linkSystemLibrary("glib-2.0"); - exe.linkSystemLibrary("gobject-2.0"); + // exe.linkSystemLibrary("gstreamer-1.0"); + // exe.linkSystemLibrary("gstapp-1.0"); + // exe.linkSystemLibrary("glib-2.0"); + // exe.linkSystemLibrary("gstvideotestsrc"); + // exe.linkSystemLibrary("gobject-2.0"); exe.root_module.addImport("glib", gobject.module("glib2")); exe.root_module.addImport("gobject", gobject.module("gobject2")); - exe.root_module.addImport("gst", gobject.module("gst1")); - exe.root_module.addImport("gstapp", gobject.module("gstapp1")); + // exe.root_module.addImport("gst", gobject.module("gst1")); + // exe.root_module.addImport("gstapp", gobject.module("gstapp1")); - exe.addIncludePath(.{ .cwd_relative = "/usr/include/hailo" }); - exe.addLibraryPath(.{ .cwd_relative = "/home/nixolas/Documents/hailort/build/hailort/libhailort/src"}); - exe.linkSystemLibrary("hailort"); + exe.addLibraryPath( .{ .cwd_relative = "/lib/aarch64-linux-gnu" }); // glib + exe.addLibraryPath( .{ .cwd_relative = "/lib/aarch64-linux-gnu/gstreamer-1.0" }); // gstreamer + exe.addLibraryPath( .{ .cwd_relative = "/usr/lib" }); // hailort + + // exe.addLibraryPath(.{ .cwd_relative = "/home/nixolas/Documents/hailort/build/hailort/libhailort/src"}); + exe.linkSystemLibrary("hailort"); diff --git a/flake.nix b/flake.nix index e6527bc..ee4f406 100644 --- a/flake.nix +++ b/flake.nix @@ -21,22 +21,8 @@ ]; buildInputs = with pkgs; [ zig_exe - pkg-config - glib - glib.dev - gst_all_1.gstreamer - gst_all_1.gstreamer.dev - gst_all_1.gst-plugins-base - gst_all_1.gst-plugins-base.dev - gst_all_1.gst-plugins-good ]; - GST_DEV_PATH = pkgs.gst_all_1.gstreamer.dev; - GST_PLUGINS_BASE_PATH = pkgs.gst_all_1.gst-plugins-base; - GST_PLUGINS_BASE_DEV_PATH = pkgs.gst_all_1.gst-plugins-base.dev; - GLIB_DEV_PATH = pkgs.glib.dev; - GLIB_PATH = pkgs.glib.out; - HAILORT_LOGGER_PATH = "./logs"; HAILORT_CONSOLE_LOGGER_LEVEL = "info"; HAILO_MONITOR = 1; diff --git a/src/main.zig b/src/main.zig index 6b78387..af7d714 100644 --- a/src/main.zig +++ b/src/main.zig @@ -3,11 +3,6 @@ const std = @import("std"); const hlo = @cImport({ @cInclude("hailort.h"); }); -const gst = @import("gst"); -const gstapp = @import ("gstapp"); -const glib = @import("glib"); -const gobject = @import("gobject"); - const Allocator = std.mem.Allocator; const assert = std.debug.assert; @@ -17,8 +12,6 @@ const max_edge_layers = 32; pub fn main() !void { - // This allows me to utilize the same command line args and gstreamer - gst.init(@ptrCast(&std.os.argv.len), @ptrCast(&std.os.argv.ptr)); var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); defer arena.deinit(); @@ -101,38 +94,6 @@ pub fn main() !void { std.debug.print("HailoRT init completed\nGstreamer Init starting", .{}); - const source: *gst.Element = gst.ElementFactory.make("videotestsrc", "source") orelse unreachable; - const scale: *gst.Element = gst.ElementFactory.make("videoscale", "scale") orelse unreachable; - const format: *gst.Element = gst.ElementFactory.make("videoconvert", "format") 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 sink_caps = gst.Caps.fromString("video/x-raw,format=RGB,width=640,height=640") orelse unreachable; - sink.setCaps(sink_caps); - const pipeline: *gst.Pipeline = gst.Pipeline.new("test-pipeline"); - const bin: *gst.Bin = &pipeline.f_bin; - - _ = gst.Bin.addMany(bin, source, scale, format, sink_el); - if (gst.Element.linkMany(source, scale, format, sink_el) < 0) { - pipeline.unref(); - std.debug.panic("Elements could not be linked\n", .{}); - } - - - const ret = pipeline.as(gst.Element).setState(gst.State.playing); - if (ret == gst.StateChangeReturn.failure) { - pipeline.unref(); - std.debug.panic("Could not start pipeline", .{}); - } - - // const bus: *gst.Bus = pipeline.getBus(); - - const sample = sink.pullSample() orelse unreachable; - const buffer: *gst.Buffer = sample.getBuffer() orelse unreachable; - - const buf_ret = buffer.extract(0, @ptrCast(input_data), input_frame_size); - std.debug.print("Buffer extract returned: '{d}'\n", .{ buf_ret }); - - std.debug.print("Getting vstream info\n", .{}); var stream_info: hlo.hailo_vstream_info_t = undefined;