<commit_before>PerchRTC
========

This iOS sample demonstrates multi-party video conferencing using WebRTC and the XirSys cloud infrastructure.

* Integrates WebRTC using a universal build packaged as a CocoaPod.
* Uses Signaling and ICE Servers provided by [XirSys](http://xirsys.com). Requires a free account & credentials to run.
* Uses the [XirSys API client project](https://github.com/samsymons/XirSys).
* Includes `XSPeerClient`, a websocket signaling client. (to be migrated to the XirSys project)
* Includes `PHQuartzVideoView`, a video renderer which uses a CALayer to display CGImages.
* Includes `PHSampleBufferRenderer` & `PHSampleBufferView` which render video using AVSampleBufferDisplayLayer.
* An AVFoundation based capture pipeline with device controls and flexible capture format support.
* A custom C++ cricket::VideoCapturer to interface with WebRTC.
* Basic support for camera rotation & audio muting.
* iOS simulator can receive both audio & video, and transmit audio.
* iOS devices support full duplex audio & video using the front camera.

## Installation

PerchRTC uses [CocoaPods](https://cocoapods.org/) 0.37.1 to install its dependencies.

To get started, clone the repo and install its dependencies:

```
git clone <EMAIL>:perchco/perchrtc.git PerchRTC
cd PerchRTC
pod install
```

This demo assumes a single XirSys room, domain, and application. Here's how to configure PerchRTC to use your XirSys account:

1. Sign up for a free account on the [XirSys website](http://xirsys.com).
2. Accept the activation email, and sign in to your account.
3. Configure your application, domain, and room in the dashboard.
4. Enter your credentials, including the room name, in `PHCredentials.h`.

## Usage

From the perspective of our view controller, video chatting isn’t hard at all.

First, we start by creating a PHConnectionBroker instance. This class is going to perform most of the heavy lifting of discovering peers, and negotiating connections with them. For simplicity’s sake, we’ve hardcoded the app to work in a single room, which we ask the broker to join.

``` obj-c
XSRoom *room = [[XSRoom alloc] initWithAuthToken:nil username:name andRoomName:roomName];
PHConnectionBroker *connectionBroker = [[PHConnectionBroker alloc] initWithDelegate:self];

[connectionBroker addObserver:self forKeyPath:@"peerConnectionState" options:NSKeyValueObservingOptionOld context:NULL];
[connectionBroker connectToRoom:room];
```

Next, wait for the local stream to become ready. In order to display the video from a stream we need a PHRenderer. Lets create the local renderer immediately, and assign ourselves as its delegate. We also add a tap gesture recognizer so the user can mute and unmute the local feed.

``` obj-c
- (void)connectionBroker:(PHConnectionBroker *)broker didAddLocalStream:(RTCMediaStream *)localStream
{
    // Prepare a renderer for the local stream.
    <commit_msg>Update README to mention XirSys v2 platform.<commit_after>PerchRTC
========

This iOS sample demonstrates multi-party video conferencing using WebRTC and the XirSys cloud infrastructure.

* Integrates WebRTC using a universal build packaged as a CocoaPod.
* Uses Signaling and ICE Servers provided by [XirSys](http://xirsys.com). Requires a free account & credentials to run.
* Uses the [XirSys API client project](https://github.com/samsymons/XirSys).
* Includes `XSPeerClient`, a websocket signaling client. (to be migrated to the XirSys project)
* Includes `PHQuartzVideoView`, a video renderer which uses a CALayer to display CGImages.
* Includes `PHSampleBufferRenderer` & `PHSampleBufferView` which render video using AVSampleBufferDisplayLayer.
* An AVFoundation based capture pipeline with device controls and flexible capture format support.
* A custom C++ cricket::VideoCapturer to interface with WebRTC.
* Basic support for camera rotation & audio muting.
* iOS simulator can receive both audio & video, and transmit audio.
* iOS devices support full duplex audio & video using the front camera.

## Installation

PerchRTC uses [CocoaPods](https://cocoapods.org/) 0.37.2 to install its dependencies.

To get started, clone the repo and install its dependencies:

```
git clone <EMAIL>:perchco/perchrtc.git PerchRTC
cd PerchRTC
pod install
```

This demo assumes a single XirSys room, domain, and application. Here's how to configure PerchRTC to use your XirSys account:

1. Sign up for a free account on the [XirSys website](http://xirsys.com).
2. Accept the activation email, and sign in to your account.
3. Configure your application, domain, and room in the dashboard.
4. Enter your credentials, including the room name, in `PHCredentials.h`.

Only XirSys v2 accounts are supported. If you wish to use PerchRTC with a XirSys v1 account, please try the 0.1 tag.

## Usage

From the perspective of our view controller, video chatting isn’t hard at all.

First, we start by creating a PHConnectionBroker instance. This class is going to perform most of the heavy lifting of discovering peers, and negotiating connections with them. For simplicity’s sake, we’ve hardcoded the app to work in a single room, which we ask the broker to join.

``` obj-c
XSRoom *room = [[XSRoom alloc] initWithAuthToken:nil username:name andRoomName:roomName];
PHConnectionBroker *connectionBroker = [[PHConnectionBroker alloc] initWithDelegate:self];

[connectionBroker addObserver:self forKeyPath:@"peerConnectionState" options:NSKeyValueObservingOptionOld context:NULL];
[connectionBroker connectToRoom:room];
```

Next, wait for the local stream to become ready. In order to display the video from a stream we need a PHRenderer. Lets create the local renderer immediately, and assign ourselves as its delegate. We also add a tap gesture recognizer so the user can mute and unmute the local feed.

``` obj-c
- (void)connectionBroker:(PHConnectionBroker *)broker didAddLocalStream:(RTCMediaStream *)localStream
{
    // Prepare a renderer for the local stream.
    
{'fraction_non_alphanumeric': 0.07127284923696126, 'fraction_numerical': 0.0035217172564145564, 'mean_word_length': 5.110655737704918, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3123638', 'n_tokens_mistral': 1666, 'n_tokens_neox': 1581, 'n_words': 750}