-
-
Notifications
You must be signed in to change notification settings - Fork 629
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support the OPUS format for Enhanced RTMP.
- Loading branch information
Showing
9 changed files
with
270 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import CoreMedia | ||
import Foundation | ||
|
||
struct OpusHeaderPacket { | ||
static let signature = "OpusHead" | ||
|
||
let channels: Int | ||
let sampleRate: Double | ||
|
||
var payload: Data { | ||
var data = Data() | ||
data.append(contentsOf: Self.signature.utf8) | ||
data.append(0x01) | ||
data.append(UInt8(channels)) | ||
data.append(UInt16(0).data) | ||
data.append(UInt32(sampleRate).data) | ||
data.append(UInt16(0).data) | ||
data.append(0x00) | ||
return data | ||
} | ||
|
||
init?(formatDescription: CMFormatDescription?) { | ||
guard | ||
let streamDescription = formatDescription?.audioStreamBasicDescription else { | ||
return nil | ||
} | ||
channels = Int(streamDescription.mChannelsPerFrame) | ||
sampleRate = streamDescription.mSampleRate | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.