Skip to content

[WIP] Camera and Microphone streaming library via SRT for iOS, macOS.

License

Notifications You must be signed in to change notification settings

blazeinmedia/SRTHaishinKit.swift

 
 

Repository files navigation

SRTHaishinKit

GitHub license

  • Camera and Microphone streaming library via SRT for iOS.
  • Issuesの言語は、英語か、日本語でお願いします!

Features

SRT

  • Publish and Recording (H264/AAC)
  • Playback
  • mode
    • caller
    • listener
    • rendezvous

see also https://github.com/shogo4405/HaishinKit.swift/blob/master/README.md

Rendering

- HKView GLHKView MTHKView
Engine AVCaptureVideoPreviewLayer OpenGL ES Metal
Publish
VIsualEffect ×
Condition Stable Stable Beta

Requirements

- iOS OSX tvOS XCode Swift CocoaPods Carthage
0.0.0+ 8.0+ 10.11+ - 10.0+ 4.2 1.5.0+ 0.29.0+

Cocoa Keys

Please contains Info.plist.

iOS 10.0+

  • NSMicrophoneUsageDescription
  • NSCameraUsageDescription

License

BSD-3-Clause

Donation

Paypal

Bitcoin

1LP7Jo4VwAFdEisJSykBAtUyAusZjozSpw

Prerequisites

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 {
}

SRT Usage

let srtConnection: SRTConnection = SRTConnection()
let srtStream: SRTStream = SRTStream(connection: srtConnection)
srtStream.attachCamera(DeviceUtil.device(withPosition: .back))
srtStream.attachAudio(AVCaptureDevice.defaultDevice(withMediaType: AVMediaTypeAudio))
srtStream.publish("hello")
srtConnection.connect("srt://host:port?option=foo")

var hkView: HKView = HKView(frame: view.bounds)
hkView.attachStream(srtStream)

// add ViewController#view
view.addSubview(hkView)

📘 FAQ

📝 How can I test SRT Service.

You can run the ffplay as SRT service.

ffplay -analyzeduration 100 -i 'srt://${YOUR_IP_ADDRESS}?mode=listener'

📝 How can I run example project?

SRTHaishinKit needs other dependencies. Please build.

iOS

carthage update --platform iOS

cd /Vendor/SRT/ ./build-openssl-iOS.sh ./build-srt-iOS.sh

macOS

carthage update --platform macOS
brew update
brew install srt

📝 Do you support me via Email?

Yes. Consulting fee is $50/1 incident. I don't recommend. Please consider to use Issues.

Dependencies

  1. https://github.com/Haivision/srt
  2. https://github.com/shogo4405/HaishinKit.swift
  3. https://github.com/shogo4405/Logboard

References

About

[WIP] Camera and Microphone streaming library via SRT for iOS, macOS.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Swift 75.2%
  • Ruby 23.1%
  • Objective-C 1.7%