Skip to content

Frames truncated as code picks only first slice #1921

Description

@AlejandroBelloIglesias

Observed behavior

In the following file:

SRTHaishinKit/Sources/TS/TSReader.swift
at makeSampleBuffer()

The current code picks only the first slice and drops the rest:

case .h264:
  let units = nalUnitReader.read(&pes.data, type: H264NALUnit.self)
  if let unit = units.first(where: { $0.type == .idr || $0.type == .slice }) {
      var data = Data([0x00, 0x00, 0x00, 0x01])
      data.append(unit.data)
      pes.data = data
  }
  isNotSync = !units.contains { $0.type == .idr }

(See first screenshot)

Expected behavior

my suggestion:

var annexB = Data()
for unit in units where unit.type == .idr || unit.type == .slice {
    annexB.append(contentsOf: [0x00, 0x00, 0x00, 0x01])
    annexB.append(unit.data)
}
if !annexB.isEmpty {
    pes.data = annexB

It should gather all the slices to fully recreate the frame (See screenshot)

To Reproduce

I used VisionPro as a sender. It seems that VPro sends video in multiple slices instead of just one.

Version

2.2.5

Smartphone info.

VisionPro 26.2

Additional context

Sender is a VisionPro device with mode=caller sending a mock video
Used SRT mode=listener in ipad

Screenshots

Before:

Image

After:

Image

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions