rtmp-wrapper 1.0.8

rtmp-wrapper 1.0.8

测试已测试
Lang语言 Obj-CObjective C
许可 MIT
发布上次发布2014年12月

Min Kim 维护。



 
依赖
librtmp-iOS~> 1.0.1
IFTimeoutBlock~> 1.0.0
 

  • Min Kim

rtmp-wrapper 是为 iOS 平台提供的 librtmp 封装库

入门

安装必备条件

  • 所有 iOS 开发都需要 OS X
  • XCODE 来自 App Store
  • 需要 GIT
  • 需要 CocoaPods 来管理 iOS 依赖。在安装 CocoaPods 之前,您应该在机器上安装 ruby

安装库

SDK 的源代码可在 GitHub 上获取

$ git clone [email protected]:ifactorylab/rtmp-wrapper.git

将 rtmp-wrapper 添加到您的项目中

如果不存在,创建 Podfile,添加以下行

pod 'rtmp-wrapper',   '~> 1.0.6'

发布 RTMP 流

#import "RtmpWrapper.h"

RtmpWrapper *rtmp = [[RtmpWrapper alloc] init];
BOOL ret = [rtmp rtmpOpenWithURL:@"YOUR RTMP PUBLISHING POINT" enableWrite:YES];
if (ret) {    
  NSData *video =
    [NSData dataWithContentsOfURL:[NSURL URLWithString:@"FLV VIDEO URL ON THE NET"]];
  NSLog(@"original video length: %d", [video length]);
  NSUInteger length = [video length];  
  NSUInteger chunkSize = 10 * 5120;
  NSUInteger offset = 0;

  // Let's split video to small chunks to publish to media server
  do {
    NSUInteger thisChunkSize = length - offset > chunkSize ? chunkSize : length - offset;
    NSData* chunk = [NSData dataWithBytesNoCopy:(char *)[video bytes] + offset
                                         length:thisChunkSize
                                   freeWhenDone:NO];
    offset += thisChunkSize;

    // Write new chunk to rtmp server
    NSLog(@"%d", [rtmp rtmpWrite:chunk]);
    sleep(1);
  } while (offset < length);
}

// Close rtmp connection and release class object
[rtmp rtmpClose];
[rtmp release];

版本详情

1.0.8

  • arc 启用

1.0.6

  • 添加了异步打开/写入
  • 移除了自动重连

1.0.5

  • sigpipe => 忽略
  • 添加了重连函数

1.0.4

  • 添加了 connected 和 autoReconnect