SightCall Developer Center

Account Login Support

iOS Rtcc SDK

This section is dedicated to the integration of the Rtcc SDK client into a native iOS app.

System requirements

The Rtcc SDK is supported in iOS 8.0+, on the following devices:

Download and link the Rtcc SDK

The Rtcc SDK is a framework. To include it into an application, you can either include it at a dependancy in your pod file if you are using CocoaPods or download the framework and manually add all the mandatory library into your project.

CocoaPods

If you do not have CocoaPods installed on your computer, you need to install it. The CocoaPods installation process is explained on the CocoaPods website. Read also how to create and use a Podfile.

To download and use the Rtcc SDK for iOS just add the following to your Podfile:

pod 'RtccSDK', '~> 6.5'

Then update your Pods:

pod update

Do not forget to close any project-related Xcode session and use the workspace (.xcworkspace) in XCode instead of the project itself (.xcodeproj).

Github

The Rtcc SDK can also be cloned from GitHub using git clone git@github.com:sightcall/iOS-SDK.git

Should you get the Rtcc SDK by cloning it from Github, do not forget to add it in the Linked Framework and Libraries of the General Tab. You also have to add the following frameworks:

AudioToolbox.framework
CoreMedia.framework
AVFoundation.framework
QuartzCore.framework
CoreFoundation.framework
Foundation.framework
CoreTelephony.framework
UIKit.framework
CoreAudio.framework
CoreGraphics.framework
libstdc++.dylib

Capabilities

Once the Rtcc SDK is added, you have to activate Background Modes and check the Audio, AirPlay and Picture in Picture in your project's Capabilities tab.

backgroundModes

Failure to do so will prevent calls to continue when the App in sent to background.

Debugging

You should set the RtccSDK logLevel to logLevel_Info using [Rtcc setLogLevel:logLevel_Info] and add a delegate responding to the RtccLogDelegate protocol.

@interface LLLocalLogDelegate: NSObject <RtccLogDelegate>
@end

@implementation LLLocalLogDelegate

- (void)logWithSelector:(const char *)caller withLevel:(logLevel_t)level andModule:(logModule_t)module message:(NSString *)message, ... NS_REQUIRES_NIL_TERMINATION;
{
    va_list pe;
    va_start(pe, message);
    NSString *messageS = [[NSString alloc] initWithFormat:message arguments:pe];
    va_end(pe);
    NSLog(@"%s: %@", caller, messageS);
}

@end

To use it, initialize a LLLocalLogDelegate variable somewhere in your code, retain it and set the Rtcc.logger with it using [Rtcc setLogger:yourVariable]. This will print log messages from the RtccSDK to your IDE console when running an app.

UI Considerations

One-to-One Calls

Displaying the render views is the responsability of the application integrating the Rtcc SDK.

The content of the inbound video is set by the Rtcc SDK in a sublayer of the viewVideoIn property of the RtccCall object.

If you are using a RtccDefaultVideoSource object, the content of the video out will be set in a subview of this object's renderView. If you are implementing your own video source, you decide how the video out is displayed. See the Video Out entry of this document.

To change a parameter of the call, simply call the related method on the RtccCall object. Each modification is acknowledged to the RtccCallDelegate, i.e. calling - (void)audioStop will trigger rtccCall:audioSending: with a NO value. Those callbacks are triggered on a non specific background thread.

Multiparty Calls

A multi party calls contains a list of contacts: participantsDictionary. Each of those RtccContact has a UIView *renderView. To see the incoming video stream of that person (and if the Multiparty Video Server is sending you this person video stream), just set it to an UIView displayed in your call view.

For example:

- (void)setDisplayViews:(NSArray *)views forCall:(RtccCall *)currentCall
{
    NSDictionary *participants = [currentCall participantsDictionary];

    //assumes more than 4 contact in participants and 4 UIView in views

    RtccContact *whatSpeaker = [participants objectForKey:@0];
    [whatSpeaker setRenderView:[views objectAtIndex:0]];
    whatSpeaker = [participants objectForKey:@1];
    [whatSpeaker setRenderView:[views objectAtIndex:1]];
    whatSpeaker = [participants objectForKey:@2];
    [whatSpeaker setRenderView:[views objectAtIndex:2]];
    whatSpeaker = [participants objectForKey:@3];
    [whatSpeaker setRenderView:[views objectAtIndex:3]];
}

The same considerations as the One-to-One calls apply regarding the video out stream and callbacks.

Testing

Please note that the Rtcc SDK only runs on a real device as iOS simulator does not support camera management. You need to select a real device as target.

Video Out

Following release 6.5.0, the Rtcc SDK uses an external video source instead of an embedded one. That allows applications using the Rtcc SDK to customize the data sent to the remote contact.

However, previous behaviour can be restored by using a RtccDefaultVideoSource object.

Idea

On call start, the user must set a source to the call's videoOut property. This source responds to the RtccVideoSource protocol. Its responsability is to provide data to the call's videoOut.sink (which is provided by the Rtcc SDK).

Default Implementation

A default implementation allows user to rapidly use a video source.

RtccDefaultVideoSource brings to the user a switchable (as in front or back) camera.

The user is notified of the size of the frame sent over through the RtccDefaultVideoSourceDelegate delegate.

Example

Considering the call is active, this code will initialize an instance of RtccDefaultVideoSource (referenced to by RtccDefaultVideoSource *source property), add it to the call and display the camera content in a view (referenced to by a UIView *outgoing; property).

- (void)setupCallCamera
{
    _source = [[RtccDefaultVideoSource alloc] init]; //`source` is retained by the `self` / current object
    _source.delegate = self; //the delegate will be notified of the frame size change
    [_source setRenderView: _outgoing]; //`outgoing` was initialized earlier in the code, or through a storyboard
    [Rtcc.instance.activeCall.videoOut setSource: _source]; //The source is set here. It is retained by the call
}

The user will be notified of a video size change when the delegate's videoSourceSizeChanged: method is called. Take a look at the RtccDefaultVideoSourceDelegate.

- (void)videoSourceSizeChanged:(CGSize)newSize
{
    //newSize is equal to _source.videoSize
    //you can resize the `_outgoing` to keep the correct ratio
}

Custom implementation

A video source is an object that responds to the RtccVideoSource protocol.

Its main components are:

- (void)start; //method called by the Rtcc SDK in response to the [Rtcc.instance.activeCall.videoOut start] method being called. Do not call it directly.
- (void)stop; //method called by the Rtcc SDK in response to the [Rtcc.instance.activeCall.videoOut stop] method being called. Do not call it directly.
@property (nonatomic, weak) id<RtccVideoSink>sink; //this object receives the data created by the source.
//optional
- (void)requestedVideoProfileChange:(VideoProfile_t)requestedProfile; //implement it to change the quality of your stream in response to information from the Rtcc SDK.

start and stop are being called by the Rtcc SDK. Do not call them directly. If you want your video stream to start or stop, call the Rtcc.instance.activeCall.videoOut start or stop.

You must call the Call's VideoOut sink pushVideoFrame:ofWidth:ofHeight:ofStride:andFormat: method to send the data. Make sure your numbers are correct, otherwise the frame sent will likely be corrupted.

The requestedVideoProfileChange: may be called at times. It usually means that the network can support a bigger frame format or the inverse (degraded network conditions). Adapt your stream quality accordingly.