Compare commits
No commits in common. "e4cd8bd855361ab4845742c2f976c1eabff8bb43" and "a43f3d7b8d7a1d7649fc43adeb1246c1fac934be" have entirely different histories.
e4cd8bd855
...
a43f3d7b8d
4 changed files with 94 additions and 20 deletions
49
build.zig
49
build.zig
|
@ -24,27 +24,48 @@ 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("gstvideotestsrc");
|
exe.linkSystemLibrary("gobject-2.0");
|
||||||
// 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.addLibraryPath( .{ .cwd_relative = "/lib/aarch64-linux-gnu" }); // glib
|
exe.addIncludePath(.{ .cwd_relative = "/usr/include/hailo" });
|
||||||
exe.addLibraryPath( .{ .cwd_relative = "/lib/aarch64-linux-gnu/gstreamer-1.0" }); // gstreamer
|
exe.addLibraryPath(.{ .cwd_relative = "/home/nixolas/Documents/hailort/build/hailort/libhailort/src"});
|
||||||
exe.addLibraryPath( .{ .cwd_relative = "/usr/lib" }); // hailort
|
exe.linkSystemLibrary("hailort");
|
||||||
|
|
||||||
// exe.addLibraryPath(.{ .cwd_relative = "/home/nixolas/Documents/hailort/build/hailort/libhailort/src"});
|
|
||||||
exe.linkSystemLibrary("hailort");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
12
flake.lock
12
flake.lock
|
@ -54,11 +54,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1729665710,
|
"lastModified": 1728492678,
|
||||||
"narHash": "sha256-AlcmCXJZPIlO5dmFzV3V2XF6x/OpNWUV8Y/FMPGd8Z4=",
|
"narHash": "sha256-9UTxR8eukdg+XZeHgxW5hQA9fIKHsKCdOIUycTryeVw=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "2768c7d042a37de65bb1b5b3268fc987e534c49d",
|
"rev": "5633bcff0c6162b9e4b5f1264264611e950c8ec7",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -128,11 +128,11 @@
|
||||||
"nixpkgs": "nixpkgs_2"
|
"nixpkgs": "nixpkgs_2"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1729858295,
|
"lastModified": 1728562297,
|
||||||
"narHash": "sha256-Ia6PEIsGiaP3d4ewuJ3QR46pd0b3qyt2/RM2yUZZtL8=",
|
"narHash": "sha256-MCpC5HXubbYKbjuc3/0jJ4GRCx81XOw6DqHa9BoYK14=",
|
||||||
"owner": "mitchellh",
|
"owner": "mitchellh",
|
||||||
"repo": "zig-overlay",
|
"repo": "zig-overlay",
|
||||||
"rev": "71a0618a10c2fb8d6c60b3498bcdb5dc4573e403",
|
"rev": "e7b6c43e8d7c091a15b0decede36ac1a2307fbc8",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
14
flake.nix
14
flake.nix
|
@ -21,8 +21,22 @@
|
||||||
];
|
];
|
||||||
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;
|
||||||
|
|
39
src/main.zig
39
src/main.zig
|
@ -3,6 +3,11 @@ 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;
|
||||||
|
@ -12,6 +17,8 @@ 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();
|
||||||
|
@ -94,6 +101,38 @@ 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;
|
||||||
|
|
Loading…
Reference in a new issue