Post

Replies

Boosts

Views

Activity

Reply to NWConnectionGroup with Both Datagram and Non-datagram streams
Thank you Quinn, copying data works! I have tested. Sorry for my sloppy answer. The piece of code are in a Swift library that is intended to be run on iOS 26, iPadOS 26 and MacOS 26 and later. But I currently only run them on iPhone/iPad. Oh, hey, that wasn’t the answer I was expecting! The chunks are format descriptions of HEVC buffer, more specifically, VPS, SPS and PPS. I searched web and learned the sizes are typically less than 500 bytes. That manipulation runs when encountering I-frame, usually once in a second. I realized that my intuitions borrowed from C pointer misled me. I should check out manual memory management and your links. I wish I could give your helps credits again! These teach me a lot. And I am pretty sure right now the original Accepted Answer truly solves my original problem. I will start a new post if I encounter problems. Thank you!
2d
Reply to NWConnectionGroup with Both Datagram and Non-datagram streams
The target is AppleOS 26 and later. That means I can take a look at Span. I was trying to convert a variable of [[UInt8]] to UnsafePointer<UnsafePointer<UInt8>> so I can pass it to parameterSetPointers of func CMVideoFormatDescriptionCreateFromHEVCParameterSets( allocator: CFAllocator?, parameterSetCount: Int, parameterSetPointers: UnsafePointer<UnsafePointer<UInt8>>, parameterSetSizes: UnsafePointer<Int>, nalUnitHeaderLength NALUnitHeaderLength: Int32, extensions: CFDictionary?, formatDescriptionOut: UnsafeMutablePointer<CMFormatDescription?> ) -> OSStatus Sorry about that. It’s better to reply as a reply, rather than in the comments; see Quinn’s Top Ten DevForums Tips for this and other titbits. I repeat the last reply here so others can see: The type of bytes is [UInt8]. Thank you for bringing more details. I have to confess I didn't check the docs before use. My purpose was to satisfy the argument type: parameterSetPointers: UnsafePointer<UnsafePointer>.
3d
Reply to NWConnectionGroup with Both Datagram and Non-datagram streams
Thank you! I should release run first! After several sessions, I noticed that CMVideoFormatDescriptionGetHEVCParameterSetAtIndex in the following snippet returns -12712 only in release build. After the removal of the nonfunctional check, for the first time I can see the streamed video in the release build. Also thank you for telling me TN3213, that is informative. extension CMSampleBuffer { func getHEVCParameterSets() throws -> [HEVCNALUnit]? { guard let formatDescription else { return nil } var count: Int = 0 try ensureSuccess( osStatus: CMVideoFormatDescriptionGetHEVCParameterSetAtIndex( formatDescription, parameterSetIndex: 0, parameterSetPointerOut: nil, parameterSetSizeOut: nil, parameterSetCountOut: &count, nalUnitHeaderLengthOut: nil ) ) let nalus = try Array(0..<count).map { try getHEVCParameterSet(at: $0, from: formatDescription) } // Ensure if the format description can be rebuilt let datas = nalus.map { $0.bytes } let sizes = datas.map { $0.count } let pointer = datas.map { $0.withUnsafeBufferPointer { $0 }.baseAddress! } var formatDescriptionOut: CMFormatDescription? try ensureSuccess( osStatus: CMVideoFormatDescriptionCreateFromHEVCParameterSets( // <-- Return error (-12712) here allocator: kCFAllocatorDefault, parameterSetCount: sizes.count, parameterSetPointers: pointer, parameterSetSizes: sizes, nalUnitHeaderLength: 4, extensions: nil, formatDescriptionOut: &formatDescriptionOut ) ) assert(formatDescriptionOut != nil) //End of check return nalus } //.... }
1w
Reply to NWConnectionGroup with Both Datagram and Non-datagram streams
I have migrated my QUIC code to iOS26, the new datagram API works sometimes in debug build. However, when I tried release build, datagram never worked. The failure in debug mode usually happened in first few test runs (between my iPhone 15 pro and an iPhone simulator on Intel MacBook Pro) after computer restart. In that case, I can see status on both side are ready and successful data sent on one side but no single piece of data received on the other side. At the same time, I can see data streaming through the QUICStream smoothly. The QUICDatagram API looks simple to use, just send and messages, or did I misunderstand the API?
1w
Reply to NWConnectionGroup with Both Datagram and Non-datagram streams
Thank you Quinn, copying data works! I have tested. Sorry for my sloppy answer. The piece of code are in a Swift library that is intended to be run on iOS 26, iPadOS 26 and MacOS 26 and later. But I currently only run them on iPhone/iPad. Oh, hey, that wasn’t the answer I was expecting! The chunks are format descriptions of HEVC buffer, more specifically, VPS, SPS and PPS. I searched web and learned the sizes are typically less than 500 bytes. That manipulation runs when encountering I-frame, usually once in a second. I realized that my intuitions borrowed from C pointer misled me. I should check out manual memory management and your links. I wish I could give your helps credits again! These teach me a lot. And I am pretty sure right now the original Accepted Answer truly solves my original problem. I will start a new post if I encounter problems. Thank you!
Replies
Boosts
Views
Activity
2d
Reply to NWConnectionGroup with Both Datagram and Non-datagram streams
The target is AppleOS 26 and later. That means I can take a look at Span. I was trying to convert a variable of [[UInt8]] to UnsafePointer<UnsafePointer<UInt8>> so I can pass it to parameterSetPointers of func CMVideoFormatDescriptionCreateFromHEVCParameterSets( allocator: CFAllocator?, parameterSetCount: Int, parameterSetPointers: UnsafePointer<UnsafePointer<UInt8>>, parameterSetSizes: UnsafePointer<Int>, nalUnitHeaderLength NALUnitHeaderLength: Int32, extensions: CFDictionary?, formatDescriptionOut: UnsafeMutablePointer<CMFormatDescription?> ) -> OSStatus Sorry about that. It’s better to reply as a reply, rather than in the comments; see Quinn’s Top Ten DevForums Tips for this and other titbits. I repeat the last reply here so others can see: The type of bytes is [UInt8]. Thank you for bringing more details. I have to confess I didn't check the docs before use. My purpose was to satisfy the argument type: parameterSetPointers: UnsafePointer<UnsafePointer>.
Replies
Boosts
Views
Activity
3d
Reply to NWConnectionGroup with Both Datagram and Non-datagram streams
Thank you! I should release run first! After several sessions, I noticed that CMVideoFormatDescriptionGetHEVCParameterSetAtIndex in the following snippet returns -12712 only in release build. After the removal of the nonfunctional check, for the first time I can see the streamed video in the release build. Also thank you for telling me TN3213, that is informative. extension CMSampleBuffer { func getHEVCParameterSets() throws -> [HEVCNALUnit]? { guard let formatDescription else { return nil } var count: Int = 0 try ensureSuccess( osStatus: CMVideoFormatDescriptionGetHEVCParameterSetAtIndex( formatDescription, parameterSetIndex: 0, parameterSetPointerOut: nil, parameterSetSizeOut: nil, parameterSetCountOut: &count, nalUnitHeaderLengthOut: nil ) ) let nalus = try Array(0..<count).map { try getHEVCParameterSet(at: $0, from: formatDescription) } // Ensure if the format description can be rebuilt let datas = nalus.map { $0.bytes } let sizes = datas.map { $0.count } let pointer = datas.map { $0.withUnsafeBufferPointer { $0 }.baseAddress! } var formatDescriptionOut: CMFormatDescription? try ensureSuccess( osStatus: CMVideoFormatDescriptionCreateFromHEVCParameterSets( // <-- Return error (-12712) here allocator: kCFAllocatorDefault, parameterSetCount: sizes.count, parameterSetPointers: pointer, parameterSetSizes: sizes, nalUnitHeaderLength: 4, extensions: nil, formatDescriptionOut: &formatDescriptionOut ) ) assert(formatDescriptionOut != nil) //End of check return nalus } //.... }
Replies
Boosts
Views
Activity
1w
Reply to NWConnectionGroup with Both Datagram and Non-datagram streams
I have migrated my QUIC code to iOS26, the new datagram API works sometimes in debug build. However, when I tried release build, datagram never worked. The failure in debug mode usually happened in first few test runs (between my iPhone 15 pro and an iPhone simulator on Intel MacBook Pro) after computer restart. In that case, I can see status on both side are ready and successful data sent on one side but no single piece of data received on the other side. At the same time, I can see data streaming through the QUICStream smoothly. The QUICDatagram API looks simple to use, just send and messages, or did I misunderstand the API?
Replies
Boosts
Views
Activity
1w