AppRTC 1.0.3

AppRTC 1.0.3

测试已测试
语言语言 Obj-CObjective C
许可证 BSD
发布最后发布2017年6月

Kelly Chu维护。



 
依赖
libjingle_peerconnection>= 0
SocketRocket>= 0
 

AppRTC 1.0.3

  • ISBX

AppRTC - Google WebRTC 示例的 iOS 实现

关于

此 Xcode 项目是 Google 的 WebRTC 示例的本机封装。它将 WebRTC 组件组织到一个 cocoa pod 中,可以轻松部署到任何 Xcode 项目中。与之前版本的 WebRTC 项目不同,该 pod 随附的预编译 libWebRTC 静态库与 64 位应用程序一起工作。目前,该项目旨在在 iOS 设备上运行(不支持 iOS 模拟器)。

此 Xcode 项目包含一个基于本机 Storyboard 的 Room 定位器和视频聊天视图控制器。

AppRTC - iOS WebRTC Client Pod

功能

  • 完全支持原生 objective-c 64 位
  • 预编译的 libWebRTC.a(节省您几个小时的时间编译)
  • 从 v1.0.2 版本开始,我们现在参考由 Pristine.io 维护的 pod libjingle_peerconnection,它有一个自动化的 libWebRTC.a 构建过程
  • 利用 Cocoa Pod 依赖管理
  • 视图控制器,易于拖放到您的项目中
  • 公开 API,易于定制和适应您的需求(以下详细说明)
  • 支持最新的 https://apprtc.appspot.com(2015年10月)
  • 我们还有一个 Google AppRTC Web 服务器 的分支,它与本项目保持完全兼容

备注

以下资源对帮助本项目达到今天的地位很有帮助:

在您的 iOS 设备上运行 AppRTC 应用

要在 iPhone 或 iPad 上运行应用程序,您可以分叉此存储库,并在 Xcode 中打开 AppRTC.xcworkspace,以便将其编译到您的 iOS 设备上以进行检查。默认情况下,服务器地址设置为 https://apprtc.appspot.com

在您的应用程序中使用 AppRTC Pod

如果您想在应用程序中集成 WebRTC 视频聊天,您可以安装 AppRTC pod

pod install AppRTC

从这里您可以查看本项目中的ARTCVideoChatViewController类。以下步骤将详细说明您需要在应用程序中进行的具体更改以添加视频通话。

初始化SSL peer连接

WebRTC可以通过SSL安全通信。如果您想通过https://apprtc.appspot.com进行测试,则需要这样做。您需要修改AppDelegate.m类,如下所示

  1. 导入RTCPeerConnectionFactory.h
#import "RTCPeerConnectionFactory.h"
  1. 将以下代码添加到application:didFinishLaunchingWithOptions:方法中
   [RTCPeerConnectionFactory initializeSSL];
  1. 将以下代码添加到applicationWillTerminate:方法中
   [RTCPeerConnectionFactory deinitializeSSL];

添加视频通话

要将视频通话添加到应用程序中,您需要2个视图

  • 本地视频视图 - 从您的设备摄像头渲染视频的位置
  • 远端视频视图 - 为远程摄像头渲染视频的位置

为此,请执行以下操作

  1. 在包含上述两个视图的ViewController或任何其他类中,添加以下头部导入
#import <libjingle_peerconnection/RTCEAGLVideoView.h>
#import <AppRTC/ARDAppClient.h>
  1. 类应实现ARDAppClientDelegateRTCEAGLVideoViewDelegate协议
@interface ARTCVideoChatViewController : UIViewController <ARDAppClientDelegate, RTCEAGLVideoViewDelegate>
* `ARDAppClientDelegate` - Handles events when remote client connects and disconnect states. Also, handles events when local and remote video feeds are received.
* `RTCEAGLVideoViewDelegate` - Handles event for determining the video frame size.
  1. 在您的类中定义以下属性
@property (strong, nonatomic) ARDAppClient *client;
@property (strong, nonatomic) IBOutlet RTCEAGLVideoView *remoteView;
@property (strong, nonatomic) IBOutlet RTCEAGLVideoView *localView;
@property (strong, nonatomic) RTCVideoTrack *localVideoTrack;
@property (strong, nonatomic) RTCVideoTrack *remoteVideoTrack;
* *ARDAppClient* - Performs the connection to the AppRTC Server and joins the chat room
* *remoteView* - Renders the Remote Video in the view
* *localView* - Renders the Local Video in the view
  1. 在初始化属性变量时,确保设置委托
   /* Initializes the ARDAppClient with the delegate assignment */
   self.client = [[ARDAppClient alloc] initWithDelegate:self];
   
   /* RTCEAGLVideoViewDelegate provides notifications on video frame dimensions */
   [self.remoteView setDelegate:self];
   [self.localView setDelegate:self];
  1. 连接到视频聊天室
   [self.client setServerHostUrl:@"https://apprtc.appspot.com"];
   [self.client connectToRoomWithId:@"room123" options:nil];
  1. 处理ARDAppClientDelegate的委托方法
- (void)appClient:(ARDAppClient *)client didChangeState:(ARDAppClientState)state {
   switch (state) {
       case kARDAppClientStateConnected:
           NSLog(@"Client connected.");
           break;
       case kARDAppClientStateConnecting:
           NSLog(@"Client connecting.");
           break;
       case kARDAppClientStateDisconnected:
           NSLog(@"Client disconnected.");
           [self remoteDisconnected];
           break;
   }
}

- (void)appClient:(ARDAppClient *)client didReceiveLocalVideoTrack:(RTCVideoTrack *)localVideoTrack {
   self.localVideoTrack = localVideoTrack;
   [self.localVideoTrack addRenderer:self.localView];
}

- (void)appClient:(ARDAppClient *)client didReceiveRemoteVideoTrack:(RTCVideoTrack *)remoteVideoTrack {
   self.remoteVideoTrack = remoteVideoTrack;
   [self.remoteVideoTrack addRenderer:self.remoteView];
}

- (void)appClient:(ARDAppClient *)client didError:(NSError *)error {
   /* Handle the error */
}
  1. 处理RTCEAGLVideoViewDelegate的委托回调
- (void)videoView:(RTCEAGLVideoView *)videoView didChangeVideoSize:(CGSize)size {
/* resize self.localView or self.remoteView based on the size returned */
}

贡献

如果您想做出贡献,请fork仓库并发出pull请求。如果您有特殊请求并希望合作,请直接与我联系。谢谢!

已知问题

以下是需要解决并在短期内发布的已知问题

  • 目前没有