aboutsummaryrefslogtreecommitdiffstats
path: root/src/control.zig
diff options
context:
space:
mode:
authors-ol <s+removethis@s-ol.nu>2025-07-27 21:40:42 +0000
committers-ol <s+removethis@s-ol.nu>2025-07-28 18:29:18 +0000
commit6850ad3da37ae1d49b959ddb5e8c11a2a1481bda (patch)
treeb90e231de261c62d38c009d9e6cf907838f34b8c /src/control.zig
parentfix texture binding bug (diff)
downloadglsl-view-6850ad3da37ae1d49b959ddb5e8c11a2a1481bda.tar.gz
glsl-view-6850ad3da37ae1d49b959ddb5e8c11a2a1481bda.zip
add libav StreamSource, run Sources in threads
Diffstat (limited to 'src/control.zig')
-rw-r--r--src/control.zig31
1 files changed, 29 insertions, 2 deletions
diff --git a/src/control.zig b/src/control.zig
index ed2531e..48aabc3 100644
--- a/src/control.zig
+++ b/src/control.zig
@@ -107,6 +107,7 @@ pub const ControlServer = struct {
cache: *gl.UniformCache,
config: *cfg.Config,
+ constants: *const gl.Constants,
progress: std.Progress.Node,
allocator: std.mem.Allocator,
@@ -141,8 +142,9 @@ pub const ControlServer = struct {
pub fn init(
allocator: std.mem.Allocator,
progress: std.Progress.Node,
- config: *cfg.Config,
cache: *gl.UniformCache,
+ config: *cfg.Config,
+ constants: *const gl.Constants,
) !*ControlServer {
var self: *ControlServer = try allocator.create(ControlServer);
self.* = .{
@@ -150,6 +152,7 @@ pub const ControlServer = struct {
.cache = cache,
.config = config,
+ .constants = constants,
.progress = progress,
.allocator = allocator,
};
@@ -167,6 +170,7 @@ pub const ControlServer = struct {
if (build_config.have_ffmpeg) {
_ = c.lo_server_add_method(self.server, "/texture/*/video", "ss", wrapCallback(handle_texture_video), @as(*anyopaque, @ptrCast(self)));
+ _ = c.lo_server_add_method(self.server, "/texture/*/stream", "ss", wrapCallback(handle_texture_stream), @as(*anyopaque, @ptrCast(self)));
}
if (build_config.have_tsv) {
_ = c.lo_server_add_method(self.server, "/texture/*/tsv", "ss", wrapCallback(handle_texture_tsv), @as(*anyopaque, @ptrCast(self)));
@@ -327,6 +331,29 @@ pub const ControlServer = struct {
return true;
}
+ fn handle_texture_stream(self: *ControlServer, path: []const u8, types: []const u8, argv: []const [*c]c.lo_arg) !bool {
+ _ = types;
+
+ var parts = std.mem.tokenizeScalar(u8, path, '/');
+ _ = parts.next();
+ const name = parts.next() orelse unreachable;
+ if (self.cache.textures.contains(name)) return error.textureNameTaken;
+
+ const texture_typeZ: [*:0]const u8 = @ptrCast(&argv[0].*.s);
+ const filenameZ: [*:0]const u8 = @ptrCast(&argv[1].*.s);
+
+ if (!std.mem.eql(u8, std.mem.span(texture_typeZ), "TEXTURE_2D")) return error.textureTypeInvalid;
+
+ const ffmpeg = @import("ffmpeg.zig");
+ const source = try ffmpeg.StreamSource.init(self.cache.allocator, self.constants, filenameZ);
+
+ const key = try self.cache.allocator.dupe(u8, name);
+ errdefer self.cache.allocator.free(key);
+ try self.cache.textures.put(key, source);
+
+ return true;
+ }
+
fn handle_texture_tsv(self: *ControlServer, path: []const u8, types: []const u8, argv: []const [*c]c.lo_arg) !bool {
_ = types;
@@ -340,7 +367,7 @@ pub const ControlServer = struct {
const tsv_nameZ: [*:0]const u8 = @ptrCast(&argv[1].*.s);
const tsv = @import("tsv.zig");
- const source = try tsv.TSVSource.init(self.cache.allocator, tsv_nameZ, texture_type);
+ const source = try tsv.TSVSource.init(self.cache.allocator, self.constants, tsv_nameZ, texture_type);
const key = try self.cache.allocator.dupe(u8, name);
errdefer self.cache.allocator.free(key);