测试已测试 | ✗ |
语言语言 | Obj-CObjective C |
许可证 | MIT |
发布最后发布 | 2015年12月 |
由 Thomas Shafer,Daniel Klein,Norm Brandinger 维护。
依赖 | |
libjingle_peerconnection | ~> 10842.2.3 |
Primus | >= 0 |
SocketRocket | ~> 0.4.2 |
这是 cine.io 的 iOS SDK,该库允许您将实时直播视频和音频聊天集成到 iOS 应用程序中。它与 cine.io Peer Android SDK 和 cine.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
为了简单起见,让我们将我们的 ViewController
设置为 CinePeerClientDelegate
In ViewController.m
@interface ViewController () <CinePeerClientDelegate>
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];
git checkout -b my-new-feature
)git commit -am '添加一些特性'
)git push origin my-new-feature
)