Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

Overview

WCS provides SDK to develop client applications for the iOS platform.

Operation flowchart

Image Removed

  1. The browser connects to the server via the Websocket protocol and sends the publish command.
  2. The browser captures the microphone and the camera and sends the WebRTC stream to the server.
  3. The iOS device connects to the server via the Websocket protocol and sends the play command.
  4. The iOS device receives the WebRTC stream from the server and plays it in the application.

Quick manual on testing

Playing a video stream in

Include Page
WCS5EN:In an iOS mobile application

1. For the test we use:

2. Open the Two Way Streaming web application. Click Connect, then Publish. Copy the identifier of the stream:

Image Removed

...

Image Removed

Call flow

Below is the call flow when using the Player example.

ViewController.m

Image Removed

...

Flashphoner.createSession(); code

Code Block
languagecpp
themeRDark
    FPWCSApi2SessionOptions *options = [[FPWCSApi2SessionOptions alloc] init];
    options.urlServer = _connectUrl.text;
    options.appKey = @"defaultApp";
    NSError *error;
    FPWCSApi2Session *session = [FPWCSApi2 createSession:options error:&error];

2. Receiving from the server an event confirming successful connection.

ConnectionStatusEvent ESTABLISHED code

Code Block
languagecpp
themeRDark
    [session on:kFPWCSSessionStatusEstablished callback:^(FPWCSApi2Session *rSession){
        [self changeConnectionStatus:[rSession getStatus]];
        [self onConnected:rSession];
    }];

...

session.createStream(); code

Code Block
languagecpp
themeRDark
- (FPWCSApi2Stream *)playStream {
    FPWCSApi2Session *session = [FPWCSApi2 getSessions][0];
    FPWCSApi2StreamOptions *options = [[FPWCSApi2StreamOptions alloc] init];
    options.name = _remoteStreamName.text;
    options.display = _remoteDisplay;
    NSError *error;
    FPWCSApi2Stream *stream = [session createStream:options error:nil];
    if (!stream) {
        ...
        return nil;
    }

4. Receiving from the server an event confirming successful playing of the stream.

StreamStatusEvent, status PLAYING code

Code Block
languagecpp
themeRDark
    [stream on:kFPWCSStreamStatusPlaying callback:^(FPWCSApi2Stream *rStream){
        [self changeStreamStatus:rStream];
        [self onPlaying:rStream];
    }];

...

6. Stopping the playback of the stream.

session.disconnect(); code

Code Block
languagecpp
themeRDark
    if ([button.titleLabel.text isEqualToString:@"STOP"]) {
        if ([FPWCSApi2 getSessions].count) {
            FPWCSApi2Session *session = [FPWCSApi2 getSessions][0];
            NSLog(@"Disconnect session with server %@", [session getServerUrl]);
            [session disconnect];
        } else {
            NSLog(@"Nothing to disconnect");
            [self onDisconnected];
        }
        ...
    }

7. Receiving from the server an event confirming the playback of the stream is stopped.

ConnectionStatusEvent DISCONNECTED code

...

languagecpp
themeRDark

...

via WebRTC
WCS5EN:In an iOS mobile application via WebRTC