more frame informationon dump

This commit is contained in:
2025-10-20 22:41:49 +03:00
parent bfca9bc0a0
commit a8f1bf5d85
2 changed files with 38 additions and 11 deletions

View File

@@ -24,8 +24,8 @@ fn discoverStream() ?[*c]u8 {
}
pub fn main() !void {
// var gpa = std.heap.GeneralPurposeAllocator(.{}){};
// const allocator = gpa.allocator();
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
const allocator = gpa.allocator();
std.log.info("Receiving...", .{});
comt.omt_setloggingfilename("omtrecvtest.log");
@@ -44,24 +44,24 @@ pub fn main() !void {
while (true) {
const frame = comt.omt_receive(receiver, frametype_flags, 40);
if (frame != null) {
dumpOMTMediaFrameInfo(frame);
dumpOMTMediaFrameInfo(allocator, frame);
}
}
}
fn dumpOMTMediaFrameInfo(frame: *comt.OMTMediaFrame) void {
fn dumpOMTMediaFrameInfo(allocator: std.mem.Allocator, frame: *comt.OMTMediaFrame) void {
std.log.info("--------- Received --------", .{});
switch (frame.*.Type) {
comt.OMTFrameType_Video => dumpVideoFrameInfo(frame),
comt.OMTFrameType_Audio => dumpAudioFrameInfo(frame),
comt.OMTFrameType_Metadata => dumpMetadataFrameInfo(frame),
comt.OMTFrameType_Metadata => dumpMetadataFrameInfo(allocator, frame),
else => std.log.err("Undefined frame type", .{}),
}
}
fn dumpVideoFrameInfo(frame: *comt.OMTMediaFrame) void {
std.log.info("Frame: Video", .{});
std.log.info(
\\Frame: Video
\\Timestamp: {d}
\\Codec: {s}
\\Width: {d}
@@ -70,24 +70,42 @@ fn dumpVideoFrameInfo(frame: *comt.OMTMediaFrame) void {
\\FrameRateN: {d}
\\FrameRateD: {d}
\\AspectRatio: {d}
\\ColorSpace: {s}
, .{
frame.Timestamp,
omt.codecToString(frame.Codec),
omt.codecToString(frame.Codec) orelse "Invalid",
frame.Width,
frame.Height,
frame.Stride,
frame.FrameRateN,
frame.FrameRateD,
frame.AspectRatio,
omt.colorSpaceToString(frame.ColorSpace),
});
}
fn dumpAudioFrameInfo(frame: *comt.OMTMediaFrame) void {
std.log.info("Frame: Audio", .{});
_ = frame;
std.log.info(
\\Timestamp: {d}
\\SampleRate: {d}
\\Channels: {d}
\\SamplesPerChannel: {d}
, .{ frame.Timestamp, frame.SampleRate, frame.Channels, frame.SamplesPerChannel });
}
fn dumpMetadataFrameInfo(frame: *comt.OMTMediaFrame) void {
fn dumpMetadataFrameInfo(allocator: std.mem.Allocator, frame: *comt.OMTMediaFrame) void {
std.log.info("Frame: Metadata", .{});
_ = frame;
if (frame.FrameMetadataLength == 0 or frame.FrameMetadata == null) {
std.log.info("None", .{});
return;
}
const metadata_length: usize = @intCast(frame.FrameMetadataLength);
const buffer = allocator.alloc(u8, metadata_length) catch @panic("OOM");
defer allocator.free(buffer);
std.debug.print("metadata: {?p}\n", .{frame.FrameMetadata});
std.mem.copyForwards(u8, buffer, @ptrCast(@alignCast(frame.FrameMetadata)));
std.log.info("{s}", .{buffer});
}