GPUHaishinKit 1.2.0

GPUHaishinKit 1.2.0

TestsTested
LangLanguage SwiftSwift
License BSD 3.0
ReleasedLast Release Sep 2017
SwiftSwift Version 4.0
SPMSupports SPM

Maintained by shogo4405.



 
Depends on:
GPUImage~> 0.1.7
HaishinKit~> 0.8.0
 

GPUHaishinKit.swift




GPUImage + HaishinKit(lf). Camera and Microphone streaming library via RTMP, HLS for iOS.

Whare is Issues page?

Features

Requirements

- iOS XCode Swift CocoaPods Carthage
1.2.0 8.0+ 8.3+ 4.0 1.2.0 0.20.0+
1.1.0 8.0+ 8.3+ 3.1 1.2.0 0.20.0+

Cocoa Keys

iOS10.0+

  • NSMicrophoneUsageDescription
  • NSCameraUsageDescription

License

New BSD

Donation

Bitcoin

1CWA9muX36QKBdJiRQJGpu2HvchfEpJbWr

RTMP Usage

// must import HaishinKit and GPUHaishinKit
import HaishinKit
import GPUHaishinKit

import GPUImage

class ViewController: UIViewController {
    @IBOutlet weak var outputView: GPUImageView?

    var camera:GPUImageVideoCamera?
    var filter:GPUImageSepiaFilter?
    var rtmpConnection:RTMPConnection?
    var rtmpStream:RTMPStream?

    var output:GPUImageRawDataOutput!

    override func viewDidLoad() {
        super.viewDidLoad()
        camera = GPUImageVideoCamera(sessionPreset: AVCaptureSessionPreset1280x720, cameraPosition: .back)
        rtmpConnection = RTMPConnection()
        rtmpStream = RTMPStream(connection: rtmpConnection!)
        filter = GPUImageSepiaFilter()
    }

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        rtmpStream?.attachGPUImageVideoCamera(camera!)
        rtmpStream?.attachAudio(AVCaptureDevice.defaultDevice(withMediaType: AVMediaTypeAudio))
        rtmpStream?.videoSettings = [
            "width": 720,
            "height": 1280,
        ]
        camera?.addTarget(filter!)
        filter?.addTarget(outputView)
        filter?.addTarget(rtmpStream!.rawDataOutput)
        camera?.outputImageOrientation = .portrait
        camera?.startCapture()
    }

    override func viewWillDisappear(_ animated: Bool) {
        rtmpStream?.close()
        rtmpStream?.dispose()
        camera?.stopCapture()
        super.viewWillDisappear(animated)
    }
}