cinelio-peer-ios 0.0.10

cinelio-peer-ios 0.0.10

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布最后发布2015年12月

Thomas ShaferDaniel KleinNorm Brandinger 维护。



 
依赖
libjingle_peerconnection~> 10842.2.3
Primus>= 0
SocketRocket~> 0.4.2
 

  • 作者
  • Cine.io 团队

这是 cine.io 的 iOS SDK,该库允许您将实时直播视频和音频聊天集成到 iOS 应用程序中。它与 cine.io Peer Android SDKcine.io peer JavaScript SDK 完全兼容。

目录

安装

使用 SDK 最简单的方法是通过 CocoaPods。创建一个名为 Podfile 的新 XCode 项目,其中包含以下内容

pod 'cineio-peer-ios', '0.0.10'

然后运行 pod install 命令安装 Pod

pod install

然后您可以使用 <project>.xcworkspace 文件打开项目

open <project>.xcworkspace

示例应用程序

查看 cineio-peer-ios-example-app 仓库,以使用此 SDK 的工作示例。

基本用法

首先包含必要的文件

#import "CinePeerClient.h"
#import "CinePeerClientConfig.h"
#import "CineCall.h"
#import "CineIdentity.h" // Only necessary if your app requires identifying
#import "RTCMediaStream.h"
#import "RTCEAGLVideoView.h" // For displaying media strems

初始化

创建 CinePeerClientDelegate

为了简单起见,让我们将我们的 ViewController 设置为 CinePeerClientDelegate

In ViewController.m

@interface ViewController () <CinePeerClientDelegate>

创建 CinePeerClient

In ViewController.m

- (void)viewDidLoad {
    [super viewDidLoad];

    NSString *CINE_IO_PUBLIC_KEY = @"CINE_IO_PUBLIC_KEY";
    NSString *CINE_IO_SECRET_KEY = @"CINE_IO_SECRET_KEY";

    // Initialize the CinePeerClientConfig class
    // Pass in a CinePeerClientDelegate
    CinePeerClientConfig *config = [[CinePeerClientConfig alloc] initWithPublicKey:CINE_IO_PUBLIC_KEY delegate:self];

    // Create the peer client
    CinePeerClient *cinePeerClient  = [[CinePeerClient alloc] initWithConfig:config];
}

CinePeerClientDelegate 方法

您将向 ViewController 添加 CinePeerClientDelegate 方法。

// happens when a new peer joins, or your local camera and microphone starts
- (void) addStream:(RTCMediaStream *)stream peerConnection:(RTCPeerConnection *)peerConnection local:(BOOL)local;
// happens when a peer leaves, or your local camera and microphone stops
- (void) removeStream:(RTCMediaStream *)stream peerConnection:(RTCPeerConnection *)peerConnection local:(BOOL)local;
// when a new call comes in
- (void) handleCall:(CineCall *)call;
// when a call that came to you is cancelled
- (void) onCallCancel:(CineCall *)call;
// when a call that you sent out is rejected
- (void) onCallReject:(CineCall *)call;
// generic error catcher
- (void) handleError:(NSDictionary *)error;

CinePeerClient 方法

启动摄像头和麦克风

[cinePeerClient startMediaStream];

加入房间

NSString *roomName = @"example";
[cinePeerClient joinRoom:roomName];

标识

您需要在配置中设置secretKey以进行识别。

[config setSecretKey:CINE_IO_SECRET_KEY];

NSString *identityName = @"UNIQUE-IDENTITY";
CineIdentity *identity = [config generateIdentity:identityName];
[self.cinePeerClient identify:identity];

调用其他身份

NSString *identityName = @"UNIQUE-IDENTITY-TO-CALL";
[self.cinePeerClient call:identity];

贡献

  1. 进行Fork
  2. 创建您的功能分支(git checkout -b my-new-feature
  3. 提交您的更改(git commit -am '添加一些特性'
  4. 将更改推送到分支(git push origin my-new-feature
  5. 创建新Pull请求