diff options
| author | s-ol <s+removethis@s-ol.nu> | 2025-07-29 09:18:23 +0000 |
|---|---|---|
| committer | s-ol <s+removethis@s-ol.nu> | 2025-07-29 09:18:23 +0000 |
| commit | a392d7b43740b58f5ad1dd0e1d4a78f9c4f8a406 (patch) | |
| tree | 2113d4db5dcbdc1e6f939eb9a27e7e83ae6fc302 /src/control.zig | |
| parent | add libav StreamSource, run Sources in threads (diff) | |
| download | glsl-view-a392d7b43740b58f5ad1dd0e1d4a78f9c4f8a406.tar.gz glsl-view-a392d7b43740b58f5ad1dd0e1d4a78f9c4f8a406.zip | |
accept format and format_options for ffmpeg sources
Diffstat (limited to 'src/control.zig')
| -rw-r--r-- | src/control.zig | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/control.zig b/src/control.zig index 48aabc3..032a927 100644 --- a/src/control.zig +++ b/src/control.zig @@ -169,8 +169,8 @@ pub const ControlServer = struct { _ = c.lo_server_add_method(self.server, "/uniform/*", null, wrapCallback(handle_uniform), @as(*anyopaque, @ptrCast(self))); 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))); + _ = c.lo_server_add_method(self.server, "/texture/*/video", null, wrapCallback(handle_texture_video), @as(*anyopaque, @ptrCast(self))); + _ = c.lo_server_add_method(self.server, "/texture/*/stream", null, 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))); @@ -310,7 +310,7 @@ pub const ControlServer = struct { } fn handle_texture_video(self: *ControlServer, path: []const u8, types: []const u8, argv: []const [*c]c.lo_arg) !bool { - _ = types; + try verify_args('s', types); var parts = std.mem.tokenizeScalar(u8, path, '/'); _ = parts.next(); @@ -320,9 +320,11 @@ pub const ControlServer = struct { const texture_typeZ: [*:0]const u8 = @ptrCast(&argv[0].*.s); const texture_type = std.meta.stringToEnum(gl.Texture.Type, std.mem.span(texture_typeZ)) orelse return error.invalidType; const filenameZ: [*:0]const u8 = @ptrCast(&argv[1].*.s); + const formatZ: ?[*:0]const u8 = if (argv.len > 2) @ptrCast(&argv[2].*.s) else null; + const args = if (argv.len > 3) argv[3..] else &.{}; const ffmpeg = @import("ffmpeg.zig"); - const source = try ffmpeg.VideoSource.init(self.cache.allocator, self.progress, filenameZ, texture_type); + const source = try ffmpeg.VideoSource.init(self.cache.allocator, self.progress, texture_type, filenameZ, formatZ, args); const key = try self.cache.allocator.dupe(u8, name); errdefer self.cache.allocator.free(key); @@ -332,7 +334,7 @@ pub const ControlServer = struct { } fn handle_texture_stream(self: *ControlServer, path: []const u8, types: []const u8, argv: []const [*c]c.lo_arg) !bool { - _ = types; + try verify_args('s', types); var parts = std.mem.tokenizeScalar(u8, path, '/'); _ = parts.next(); @@ -341,11 +343,13 @@ pub const ControlServer = struct { const texture_typeZ: [*:0]const u8 = @ptrCast(&argv[0].*.s); const filenameZ: [*:0]const u8 = @ptrCast(&argv[1].*.s); + const formatZ: ?[*:0]const u8 = if (argv.len > 2) @ptrCast(&argv[2].*.s) else null; + const args = if (argv.len > 3) argv[3..] else &.{}; 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 source = try ffmpeg.StreamSource.init(self.cache.allocator, self.constants, filenameZ, formatZ, args); const key = try self.cache.allocator.dupe(u8, name); errdefer self.cache.allocator.free(key); @@ -367,7 +371,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, self.constants, tsv_nameZ, texture_type); + const source = try tsv.TSVSource.init(self.cache.allocator, self.constants, texture_type, tsv_nameZ); const key = try self.cache.allocator.dupe(u8, name); errdefer self.cache.allocator.free(key); |
