Skip to content
This repository has been archived by the owner on Jul 14, 2018. It is now read-only.

Latest commit

 

History

History
98 lines (81 loc) · 2.8 KB

README.md

File metadata and controls

98 lines (81 loc) · 2.8 KB

[Archived]GPUHaishinKit.swift

Platform Language CocoaPods GitHub license

  • GPUImage is unmaintained. Also can't maintenance GPUHaishinKit. 7/14, 2018
  • GPUImage + HaishinKit(lf). Camera and Microphone streaming library via RTMP, HLS for iOS.

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

Installation

CocoaPods

source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!

def import_pods
    pod 'GPUHaishinKit', '~> 1.2.0'
end

target 'Your Target'  do
    platform :ios, '8.0'
    import_pods
end

Carthage

github "shogo4405/GPUHaishinKit.swift" ~> 1.2.0

License

BSD-3-Clause

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