- Camera and Microphone streaming library via SRT for iOS.
- API Documentation
- This project status is working in progress.
This project has been integrated into HaishinKit.swift
- Publish and Recording (H264/AAC)
- Playback(beta)
- mode
- caller
- listener
- rendezvous
- | iOS | Xcode | Swift |
---|---|---|---|
0.1.0+ | 11.0+ | 14.0+ | 5.7 |
0.0.0+ | 8.0+ | 10.0+ | 4.2 |
Not available.
- CocoaPods
github "shogo4405/SRTHaishinKit.swift" "0.1.2"
https://github.com/shogo4405/SRTHaishinKit.swift
Please contains Info.plist.
iOS 10.0+
- NSMicrophoneUsageDescription
- NSCameraUsageDescription
Make sure you setup and activate your AVAudioSession.
import AVFoundation
let session: AVAudioSession = AVAudioSession.sharedInstance()
do {
try session.setPreferredSampleRate(44_100)
// https://stackoverflow.com/questions/51010390/avaudiosession-setcategory-swift-4-2-ios-12-play-sound-on-silent
if #available(iOS 10.0, *) {
try session.setCategory(.playAndRecord, mode: .default, options: [.allowBluetooth])
} else {
session.perform(NSSelectorFromString("setCategory:withOptions:error:"), with: AVAudioSession.Category.playAndRecord, with: [AVAudioSession.CategoryOptions.allowBluetooth])
}
try session.setMode(AVAudioSessionModeDefault)
try session.setActive(true)
} catch {
}
let connection = SRTConnection()
let stream = SRTStream(connection: connection)
stream.attachAudio(AVCaptureDevice.default(for: .audio)) { error in
// print(error)
}
stream.attachCamera(AVCaptureDevice.default(.builtInWideAngleCamera, for: .video, position: .back)) { error in
// print(error)
}
let hkView = HKView(frame: view.bounds)
hkView.videoGravity = AVLayerVideoGravity.resizeAspectFill
hkView.attachStream(rtmpStream)
// add ViewController#view
view.addSubview(hkView)
connection.connect("srt://host:port?option=foo")
stream.publish()
let connection = SRTConnection()
let stream = SRTStream(connection: connection)
let hkView = MTHKView(frame: view.bounds)
hkView.videoGravity = AVLayerVideoGravity.resizeAspectFill
hkView.attachStream(rtmpStream)
// add ViewController#view
view.addSubview(hkView)
connection.connect("srt://host:port?option=foo")
stream.play("")
SRTHaishinKit needs other dependencies. Please build.
brew install cmake
carthage update --use-xcframeworks --platform iOS
ffplay -analyzeduration 100 -i 'srt://${YOUR_IP_ADDRESS}?mode=listener'
BSD-3-Clause