Render a User's Video

The Video SDK allows you to render the video of each user who joins a session.

  1. Retrieve the ZMVideoSDKUser object related to each user as they join the session.
  2. Obtain the ZMVideoSDKRawDataPipe from each user whose stream you'd like to render.
  3. Subscribe to their video pipe.
  4. Listen for the user's video frames.

Retrieve user

The ZMVideoSDKUserHelper helps with retrieval of user information. See Manage User Information for more details on user management.

To be notified when users join a session, you can use onUserJoin within ZMVideoSDKDelegate:


- (void)onUserJoin:(ZMVideoSDKUserHelper*)userHelper userList:(NSArray<ZMVideoSDKUser >)userArray {
    // UserArray contains the new users.
    // Use helper to perform actions on a user.
    for (int i = 0; i < userArray.count; i++) {
        NSLog(@"%@", userArray[i]);
    }
}

func onUserJoin(_ userHelper: ZMVideoSDKUserHelper!, userList userArray: [ZMVideoSDKUser]!) {
    // UserArray contains the new users.
    // Use helper to perform actions on a user.
    if let userArray = userArray {
        for user in userArray {
            print(user)
        }
    }
}

Subscribe to a user's video pipe

Now that you have access to each user represented by an ZMVideoSDKUser object, you must retrieve the ZMVideoSDKRawDataPipe of each user whose video you would like to render and to subscribe to that user's video pipe with your implementation of ZMVideoSDKRawDataPipeDelegate.


- (void) onRawDataFrameRecieved: (ZMVideoSDKYUVRawDataI420 *) rawData {
    // Access the video data here.
}
ZMVideoSDKRawDataPipe pipe = [user getVideoPipe];
[pipe subscribe:ZMVideoSDKResolution_720P listener:self];

func onRawDataFrameReceived(_ rawData: ZMVideoSDKYUVRawDataI420!) {
    // Access the video data here.
}
let pipe = user.getVideoPipe()
pipe?.subscribe(ZMVideoSDKResolution_720P, listener: self);

Send raw video data (optional)

You may also choose to send video data after modifying it (for example, adding a virtual background or filter) by using sendVideoFrame within ZMVideoSDKVideoSender. To obtain an ZMVideoSDKVideoSender you must assign a ZMVideoSDKVideoSource. The onInitialize within ZMVideoSDKVideoSource will provide an ZMVideoSDKVideoSender.


- (void) onInitialize:(ZMVideoSDKVideoSender *)sender supportedCapbilityList:(NSArray<ZMVideoSDKVideoCapability *> *)supportedCapList suggestCapbility:(ZMVideoSDKVideoCapability *)suggestCap {
    // Store video rawdata sender.
    self.videoRawdataSender = rawDataSender;
}
//Call sendVideoFrame to send a frame buffer of raw data.
[self.videoRawdataSender sendVideoFrame:frameBuffer width:width height:height frameLength:frameLength rotation:rotation];

func onInitialize(_ sender: ZMVideoSDKVideoSender!, supportedCapbilityList supportedCapList: [ZMVideoSDKVideoCapability]!, suggestCapbility suggestCap: ZMVideoSDKVideoCapability!) {
    // Store video rawdata sender.
    self.rawDataSender = rawDataSender
}
// Call sendVideoFrame to send a frame buffer of raw data.
self.rawDataSender?.sendVideoFrame(frameBuffer, width: width, height: height, frameLength: frameLength, rotation: rotation)

Raw video data can also be preprocessed using onPreProcessRawData within ZMVideoSDKVideoSourcePreProcessor.


- (void) onPreProcessRawData:(ZMVideoSDKYUVProcessDataI420 *)rawData {
    // Perform preprocess actions here.
}

func onPreProcessRawData(_ rawData: ZMVideoSDKYUVProcessDataI420!) {
    // Perform preprocess actions here.
}

Need help?

If you're looking for help, try Developer Support or our Developer Forum. Priority support is also available with Premier Developer Support plans.