Files
omtoy/src/main.zig

63 lines
2.0 KiB
Zig

const std = @import("std");
const omt = @cImport(@cInclude("libomt.h"));
pub fn main() !void {
const gpa = std.heap.GeneralPurposeAllocator(.{}){};
const allocator = gpa.allocator();
std.log.info("Send test...", .{});
omt.omt_setloggingfilename("omtsendtest.log");
const sender = omt.omt_send_create("Omtoy Sender", omt.OMTQuality_Default);
if (sender != null) {
std.log.info("Sender created", .{});
{
var sender_info = std.mem.zeroes(omt.OMTSenderInfo);
const product_name = "Omtoy";
const manufacturer = "Kasper Toy Productions";
const version = "0.1";
@memcpy(sender_info.ProductName[0..product_name.len], product_name);
@memcpy(sender_info.Manufacturer[0..manufacturer.len], manufacturer);
@memcpy(sender_info.Version[0..version.len], version);
omt.omt_send_setsenderinformation(sender, &sender_info);
}
const width = 1920;
const height = 1080;
const stride = width * 2;
const data_length = stride * height;
const frame_buffer = allocator.alloc(u8, data_length);
{
const frame = omt.OMTMediaFrame{
.Type = omt.OMTFrameType_Video,
.Width = width,
.Height = height,
.Codec = omt.OMTCodec_UYVY,
.Timestamp = -1,
.ColorSpace = omt.OMTColorSpace_BT709,
.Flags = omt.OMTVideoFlags_None,
.Stride = width * 2,
.DataLength = width * 2 * height,
.Data = frame_buffer,
.FrameRateN = 60000,
.FrameRateD = 1000,
.CompressedData = 0,
.CompressedLength = 0,
.FrameMetadata = 0,
.FrameMetadataLength = 0,
// TODO
};
}
}
var found_address_count: i32 = 0;
_ = omt.omt_discovery_getaddresses(&found_address_count);
std.debug.print("Found {d} omt addresses\n", .{found_address_count});
}