/lf.swift

iOS Camera/Microphone streaming library via RTMP/HTTP

Primary LanguageSwiftOtherNOASSERTION

lf.swift

lf is a lIVE fRAMEWORK. iOS/OSX Camera/Microphone streaming library via RTMP/HTTP

Install

Cocoapod

pod 'lf'
use_frameworks!

Usage/RTMP

Real Time Messaging Protocol (RTMP). Basic snipet.

var rtmpConnection:RTMPConnection = RTMPConnection()
var rtmpStream = RTMPStream(rtmpConnection: rtmpConnection)
rtmpStream.videoGravity = AVLayerVideoGravityResizeAspectFill
rtmpStream.attachAudio(AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeAudio))
rtmpStream.attachCamera(AVMixer.deviceWithPosition(.Back))

view.addSubview(rtmpStream.view)
rtmpConnection.connect("rtmp://localhost/appName/instanceName")
rtmpStream.publish("streamName")

Settings

var rtmpStream = RTMPStream(rtmpConnection: rtmpConnection)
rtmpStream.videoSettings = [
    "width": 640, // video output width
    "height": 360, // video output height
]

RTMP Auth

var rtmpConnection:RTMPConnection = RTMPConnection()
rtmpConnection.connect("rtmp://username:password@localhost/appName/instanceName")

Usage/HTTP

HTTP Live Streaming (HLS). Your iPhone/Mac become a IP Camera. Basic snipet.

httpStream = HTTPStream()
httpStream.syncOrientation = true
httpStream.attachCamera(AVMixer.deviceWithPosition(.Back))
rtmpStream.attachAudio(AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeAudio))

httpStream.publish("hello")

httpService = HTTPService(domain: "", type: "_http._tcp", name: "lf", port: 8080)
httpService.startRunning()
httpService.addHTTPStream(httpStream)

view.addSubview(httpStream.view)

You can see http://ip.address:8080/hello/playlist.m3u8

Class Overview

AS3 lf
flash.net.SharedObject RTMPSharedObject
flash.net.Responder Responder
flash.net.NetConnection RTMPConnection
flash.net.NetStream RTMPStream

License

New BSD

Enviroment

lf iOS OSX Swift CocoaPod
0.3 8.0 10.11 2.3 1.0.0
0.2 8.0 - 2.3 0.39.0

Reference