also looking at this
feat(video): add native AVC/HEVC and synchronized AAC MP4 streaming
#913
14 files
+1119
-0
Review threads live on the whole diff, not on one commit, so none are shown here - a thread's line means something in the branch's final form, and painting it into an intermediate step would put it on code it is not about.
| @@ -300,3 +300,21 @@ test "fragment sizes, offsets and 64-bit time are exact; sink failure poisons wr | ||
| 300 | 300 | try std.testing.expectError(error.DiskFull, writer.frame(&.{ 0, 0, 0, 1, 1 }, 0x100000001, 1, false)); |
| 301 | 301 | try std.testing.expectError(error.WriterFailed, writer.frame(&.{ 0, 0, 0, 1, 1 }, 0x100000002, 1, false)); |
| 302 | 302 | } |
| 303 | ||
| 304 | /// CodecPrivate for Matroska, without the enclosing avcC/hvcC box header. | |
| 305 | pub fn codecPrivate(codec: Codec, headers: []const u8, destination: []u8) ![]const u8 { | |
| 306 | var b: Buffer = .{}; | |
| 307 | try config(&b, codec, headers); | |
| 308 | const data = b.slice()[8..]; | |
| 309 | if (destination.len < data.len) return error.HeaderTooLarge; | |
| 310 | @memcpy(destination[0..data.len], data); | |
| 311 | return destination[0..data.len]; | |
| 312 | } | |
| 313 | test "Matroska CodecPrivate reuses checked config and respects destination bounds" { | |
| 314 | const headers = [_]u8{ 0, 0, 0, 4, 0x67, 100, 0, 40, 0, 0, 0, 2, 0x68, 0x80 }; | |
| 315 | var destination: [128]u8 = undefined; | |
| 316 | const data = try codecPrivate(.h264, &headers, &destination); | |
| 317 | try std.testing.expectEqualSlices(u8, &.{ 1, 100, 0, 40, 255, 225 }, data[0..6]); | |
| 318 | try std.testing.expectError(error.HeaderTooLarge, codecPrivate(.h264, &headers, destination[0..1])); | |
| 319 | try std.testing.expectError(error.MissingParameterSets, codecPrivate(.h264, &.{}, &destination)); | |
| 320 | } | |