Skip to content

Commit

Permalink
improve markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
liuxuan30 committed Apr 22, 2020
1 parent 7f30dd6 commit 2058796
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions TelloVideoDecoder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,29 @@ Therefore I will be grateful that if you can send me pull requests to make it be

## Get a valid NAL Unit
You need to first generate valid NALU either by yourself or by `getNalUnits()`/ `readNalUnits()`.

>getNalUnits(streamBuffer: Array<UInt8>) -> NALUnit?
```swift
getNalUnits(streamBuffer: Array<UInt8>) -> NALUnit?
```
will get all valid NALU and abandon incomplete NALU (data before next start code)

>readNalUnits(streamBuffer:inout Array<UInt8>) -> NALUnit?
```swift
readNalUnits(streamBuffer:inout Array<UInt8>) -> NALUnit?
```
will consume `streamBuffer`. To stop reading, call `stopProcessing()`

## Get CMSampleBuffer from NALU
Get a CMSampleBuffer by `getCMSampleBuffer(from nalu: NALUnit)`

## Get CVImageBuffer from CMSampleBuffer
Get a `CVImageBuffer` by calling `decompress()`

>decompress(sampleBuffer: CMSampleBuffer, outputHandler: @escaping VTDecompressionOutputHandler) -> OSStatus
```swift
decompress(sampleBuffer: CMSampleBuffer, outputHandler: @escaping VTDecompressionOutputHandler) -> OSStatus
```
This is a wrapper of `VTDecompressionSessionDecodeFrame(_:sampleBuffer:flags:infoFlagsOut:outputHandler:)`

note that
>outputHandler cannot be called with a session created with a VTDecompressionOutputCallbackRecord.
**outputHandler cannot be called with a session created with a VTDecompressionOutputCallbackRecord.**

### what if I want to use VTDecompressionOutputCallbackRecord?
### what if I want to use `VTDecompressionOutputCallbackRecord`?
Grab the source code and modify `createVTDecompressionSession()` by commenting back
```swift
var outputCallback = VTDecompressionOutputCallbackRecord()
Expand All @@ -44,8 +44,9 @@ and pass to `outputCallback: ` in `VTDecompressionSessionCreate()`
I don't quite understand what each parameter means while creating the CMSampleTimingInfo. Even if I don't set it, the video streaming seems working well. Welcome any improvement and knowledge sharing.

## About renderVideoStream()
>renderVideoStream(streamBuffer: inout Array<UInt8>, to videoLayer: AVSampleBufferDisplayLayer)
```swift
renderVideoStream(streamBuffer: inout Array<UInt8>, to videoLayer: AVSampleBufferDisplayLayer)
```
This is a lazy method for people just want to display the video stream from Tello with `AVSampleBufferDisplayLayer`

It simply keeps consuming `streamBuffer`, so you would want to put it into a `DispatchQueue` as it will block current thread, and be careful not causing write/read corruption. This also applies to `readNalUnits()`.
Expand Down

0 comments on commit 2058796

Please sign in to comment.