LFLiveKit推流框架

10 篇文章 0 订阅

转自:https://github.com/LaiFengiOS/LFLiveKit


LaiFeng IOS Live Kit,H264和AAC硬编码,支持GPUImage美观,rtmp传输,弱网络丢帧,动态切换速率


LFLiveKit

icon~

Build Status  License MIT  CocoaPods  Support  platform 

LFLiveKit is a opensource RTMP streaming SDK for iOS.

Features

  •  Background recording
  •  Support horizontal vertical recording
  •  Support Beauty Face With GPUImage
  •  Support H264+AAC Hardware Encoding
  •  Drop frames on bad network
  •  Dynamic switching rate
  •  Audio configuration
  •  Video configuration
  •  RTMP Transport
  •  Switch camera position
  •  Audio Mute
  •  Support Send Buffer
  •  Support WaterMark
  •  Swift Support
  •  Support Single Video or Audio
  •  Support External input video or audio(Screen recording or Peripheral)
  •  FLV package and send

Requirements

- iOS 7.0+
- Xcode 7.3

Installation

CocoaPods
# To integrate LFLiveKit into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '7.0'
pod 'LFLiveKit'

# Then, run the following command:
$ pod install
Carthage
1. Add `github "LaiFengiOS/LFLiveKit"` to your Cartfile.
2. Run `carthage update --platform ios` and add the framework to your project.
3. Import \<LFLiveKit/LFLiveKit.h\>.
Manually
1. Download all the files in the `LFLiveKit` subdirectory.
2. Add the source files to your Xcode project.
3. Link with required frameworks:
    * UIKit
    * Foundation
    * AVFoundation
    * VideoToolbox
    * AudioToolbox
    * libz
    * libstdc++

Usage example

Objective-C
- (LFLiveSession*)session {
    if (!_session) {
        _session = [[LFLiveSession alloc] initWithAudioConfiguration:[LFLiveAudioConfiguration defaultConfiguration] videoConfiguration:[LFLiveVideoConfiguration defaultConfiguration]];
        _session.preView = self;
        _session.delegate = self;
    }
    return _session;
}

- (void)startLive { 
    LFLiveStreamInfo *streamInfo = [LFLiveStreamInfo new];
    streamInfo.url = @"your server rtmp url";
    [self.session startLive:streamInfo];
}

- (void)stopLive {
    [self.session stopLive];
}

//MARK: - CallBack:
- (void)liveSession:(nullable LFLiveSession *)session liveStateDidChange: (LFLiveState)state;
- (void)liveSession:(nullable LFLiveSession *)session debugInfo:(nullable LFLiveDebug*)debugInfo;
- (void)liveSession:(nullable LFLiveSession*)session errorCode:(LFLiveSocketErrorCode)errorCode;
Swift
// import LFLiveKit in [ProjectName]-Bridging-Header.h
#import <LFLiveKit.h> 

//MARK: - Getters and Setters
lazy var session: LFLiveSession = {
    let audioConfiguration = LFLiveAudioConfiguration.defaultConfiguration()
    let videoConfiguration = LFLiveVideoConfiguration.defaultConfigurationForQuality(LFLiveVideoQuality.Low3, landscape: false)
    let session = LFLiveSession(audioConfiguration: audioConfiguration, videoConfiguration: videoConfiguration)

    session?.delegate = self
    session?.preView = self.view
    return session!
}()

//MARK: - Event
func startLive() -> Void { 
    let stream = LFLiveStreamInfo()
    stream.url = "your server rtmp url";
    session.startLive(stream)
}

func stopLive() -> Void {
    session.stopLive()
}

//MARK: - Callback
func liveSession(session: LFLiveSession?, debugInfo: LFLiveDebug?) 
func liveSession(session: LFLiveSession?, errorCode: LFLiveSocketErrorCode)
func liveSession(session: LFLiveSession?, liveStateDidChange state: LFLiveState)

Release History

* 2.0.0
    * CHANGE: modify bugs,support ios7 live.
* 2.2.4.3
    * CHANGE: modify bugs,support swift import.
* 2.5 
    * CHANGE: modify bugs,support bitcode.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Android可以通过使用RTSP(Real-Time Streaming Protocol)拉取音视频流,以实现实时播放。RTSP是一种用于互联网上会话层(application layer)的协议,可以支持实时流媒体播放和控制。在Android中,可以使用MediaCodec和MediaExtractor等API来解码和播放RTSP流。首先,需要创建一个RTSP的URL,以指定要拉取的音视频资源的位置和格式。然后,可以使用MediaPlayer类或ExoPlayer库来创建一个播放器对象,将RTSP URL传递给播放器,然后开始播放。播放器会自动处理RTSP流的解码和渲染。 另一方面,Android也可以通过RTMP(Real-Time Messaging Protocol)推送音视频流至服务器。RTMP是一种用于实现实时通信的协议,常用于实时流媒体的发布和交互。要在Android中实现RTMP推流,可以使用第三方库,如libRtmpLFLiveKit。首先,需要创建一个RTMP推流URL,以指定要推送的服务器和流的名称。然后,可以使用库提供的API,将音视频数据发送到服务器。可以使用Camera API或MediaCodec API来获取音视频数据,并将其编码为RTMP可接受的格式,然后通过网络发送。服务器将接收到的数据进行处理和分发,以实现实时流媒体播放或与其他用户进行交互。 总而言之,Android可以通过使用RTSP拉取音视频流,以实现实时播放,并可以通过RTMP推送音视频流至服务器,实现实时的流媒体发布和交互。这种功能在许多应用程序(例如视频播放器、实时直播、视频会议等)中都会用到。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值