Compare commits

..

2 commits

Author SHA1 Message Date
Nicholas Young
e4cd8bd855 minimal building project 2024-10-29 17:06:14 -07:00
Nicholas Young
330a5d8dba flake.lock: Update
Flake lock file updates:

• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/5633bcff0c6162b9e4b5f1264264611e950c8ec7?narHash=sha256-9UTxR8eukdg%2BXZeHgxW5hQA9fIKHsKCdOIUycTryeVw%3D' (2024-10-09)
  → 'github:NixOS/nixpkgs/2768c7d042a37de65bb1b5b3268fc987e534c49d?narHash=sha256-AlcmCXJZPIlO5dmFzV3V2XF6x/OpNWUV8Y/FMPGd8Z4%3D' (2024-10-23)
• Updated input 'zig':
    'github:mitchellh/zig-overlay/e7b6c43e8d7c091a15b0decede36ac1a2307fbc8?narHash=sha256-MCpC5HXubbYKbjuc3/0jJ4GRCx81XOw6DqHa9BoYK14%3D' (2024-10-10)
  → 'github:mitchellh/zig-overlay/71a0618a10c2fb8d6c60b3498bcdb5dc4573e403?narHash=sha256-Ia6PEIsGiaP3d4ewuJ3QR46pd0b3qyt2/RM2yUZZtL8%3D' (2024-10-25)
2024-10-25 19:03:23 -07:00
4 changed files with 20 additions and 94 deletions

View file

@ -24,47 +24,26 @@ pub fn build(b: *std.Build) void {
.optimize = optimize, .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.linkSystemLibrary("c");
exe.addIncludePath(.{ .cwd_relative = "/usr/include/hailo" });
exe.linkSystemLibrary("gstreamer-1.0"); // exe.linkSystemLibrary("gstreamer-1.0");
exe.linkSystemLibrary("gstapp-1.0"); // exe.linkSystemLibrary("gstapp-1.0");
exe.linkSystemLibrary("glib-2.0"); // exe.linkSystemLibrary("glib-2.0");
exe.linkSystemLibrary("gobject-2.0"); // exe.linkSystemLibrary("gstvideotestsrc");
// exe.linkSystemLibrary("gobject-2.0");
exe.root_module.addImport("glib", gobject.module("glib2")); exe.root_module.addImport("glib", gobject.module("glib2"));
exe.root_module.addImport("gobject", gobject.module("gobject2")); exe.root_module.addImport("gobject", gobject.module("gobject2"));
exe.root_module.addImport("gst", gobject.module("gst1")); // exe.root_module.addImport("gst", gobject.module("gst1"));
exe.root_module.addImport("gstapp", gobject.module("gstapp1")); // exe.root_module.addImport("gstapp", gobject.module("gstapp1"));
exe.addIncludePath(.{ .cwd_relative = "/usr/include/hailo" }); exe.addLibraryPath( .{ .cwd_relative = "/lib/aarch64-linux-gnu" }); // glib
exe.addLibraryPath(.{ .cwd_relative = "/home/nixolas/Documents/hailort/build/hailort/libhailort/src"}); 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"); exe.linkSystemLibrary("hailort");

View file

@ -54,11 +54,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1728492678, "lastModified": 1729665710,
"narHash": "sha256-9UTxR8eukdg+XZeHgxW5hQA9fIKHsKCdOIUycTryeVw=", "narHash": "sha256-AlcmCXJZPIlO5dmFzV3V2XF6x/OpNWUV8Y/FMPGd8Z4=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "5633bcff0c6162b9e4b5f1264264611e950c8ec7", "rev": "2768c7d042a37de65bb1b5b3268fc987e534c49d",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -128,11 +128,11 @@
"nixpkgs": "nixpkgs_2" "nixpkgs": "nixpkgs_2"
}, },
"locked": { "locked": {
"lastModified": 1728562297, "lastModified": 1729858295,
"narHash": "sha256-MCpC5HXubbYKbjuc3/0jJ4GRCx81XOw6DqHa9BoYK14=", "narHash": "sha256-Ia6PEIsGiaP3d4ewuJ3QR46pd0b3qyt2/RM2yUZZtL8=",
"owner": "mitchellh", "owner": "mitchellh",
"repo": "zig-overlay", "repo": "zig-overlay",
"rev": "e7b6c43e8d7c091a15b0decede36ac1a2307fbc8", "rev": "71a0618a10c2fb8d6c60b3498bcdb5dc4573e403",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -21,22 +21,8 @@
]; ];
buildInputs = with pkgs; [ buildInputs = with pkgs; [
zig_exe 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_LOGGER_PATH = "./logs";
HAILORT_CONSOLE_LOGGER_LEVEL = "info"; HAILORT_CONSOLE_LOGGER_LEVEL = "info";
HAILO_MONITOR = 1; HAILO_MONITOR = 1;

View file

@ -3,11 +3,6 @@ const std = @import("std");
const hlo = @cImport({ const hlo = @cImport({
@cInclude("hailort.h"); @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 Allocator = std.mem.Allocator;
const assert = std.debug.assert; const assert = std.debug.assert;
@ -17,8 +12,6 @@ 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
gst.init(@ptrCast(&std.os.argv.len), @ptrCast(&std.os.argv.ptr));
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
defer arena.deinit(); defer arena.deinit();
@ -101,38 +94,6 @@ pub fn main() !void {
std.debug.print("HailoRT init completed\nGstreamer Init starting", .{}); 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", .{}); std.debug.print("Getting vstream info\n", .{});
var stream_info: hlo.hailo_vstream_info_t = undefined; var stream_info: hlo.hailo_vstream_info_t = undefined;