Objective-C

Publishing a Stream to the Session

When the app connects to the Vonage Video session, we want it to publish an audio-video stream to the session, using the device's camera and microphone:

  1. Add a publisher property to the ViewController class:

The OTPublisher class is defined in the iOS SDK. It uses the device's camera and microphone, to publish a stream Vonage Video session.

  1. Modify the implementation of the sessionDidConnect(_:) method to include code to publish a stream to the session:

When the app connects to a session, it initializes an instance of the OTPublisher, defined in the iOS SDK. The [OTPublisher initWithDelegate:] method takes two parameters: the object that implements the OTPublisherDelegate protocol and a settingsobject.

The code then passes the OTPublisher object in as a parameter of the [OTSession publish:] method. This method publishes an audio-video stream to the Vonage Video session, using the camera and microphone of the iOS device. (Note that in the Xcode simulator, the iOS SDK uses a test video when publishing a stream.)

The OTPublisher object has a view property, which is a UIView object. This view displays the video captured from the device's camera. The code adds this view as a subview of the main ViewController's view.

  1. Change the ViewController interface declaration to indicate that the class implements the OTPublisherDelegate protocol:

Next we will implement methods of the OTSessionDelegate protocol. Add the following code to the end of the ViewController class (before the class's @end statement):

If the client fails to publish to the Vonage Video session, an OTError object is passed into the [OTPublisherDelegate publisher:didFailWithError:] method.

Debug your application. If the app successfully connects to the Vonage Video session, it will publish a stream to the session, and you will see the publisher's video in the app.

Basic video chat

Learn the basic concepts of the Vonage Video API platform, including how users can communicate through video, voice, and messaging. Explore a basic Vonage Video API flow.

手順
1
Introduction
2
Getting Started
3
Creating a New Project
4
Adding the Vonage Video library
5
Setting Up Authentication
6
Connecting to the Session
7
Publishing a Stream to the Session
8
Subscribing to Other Clients' Streams
9
Running the App
10
Conclusion