Skip to main content
Version: Next

Publish Video - IoT SDK

The Video publishing feature lets an IoT device capture frames from its on-board camera and stream them into a room, enabling real-time video alongside audio in your VideoSDK-powered applications.

startPublishVideo()

  • The startPublishVideo() function initiates publishing video captured from your IoT device camera into the active room session.
  • This function takes no parameters.
note
  • You must call the init() method before invoking startPublishVideo(). If not, the function returns an INIT_NOT_CALLED result code.

  • Set .videoCodec = VIDEO_CODEC_JPEG in init().

  • Video can only be published once. Calling this function again while video is already publishing returns a TASK_ALREADY_STARTED result code.

  • Both supported boards can send video. If the camera fails to initialize (ribbon unseated, or the wrong board selected in menuconfig), it returns INIT_BOARD_FAILED, not DEVICE_NOT_SUPPORTED. See Supported Microcontrollers.

  • To stop only this stream without leaving, call stopPublishVideo(); startPublishVideo() resumes it. leave() tears down all publishing and subscribing when you exit the room.

Example

#include "videosdk.h"
#include "esp_log.h"
void app_main(){
result_t publish_video_result = startPublishVideo();
ESP_LOGI("IOT-SDK", "Publish Video Result: %d", publish_video_result);
}

stopPublishVideo()

Example

#include "videosdk.h"
#include "esp_log.h"
void app_main(){
result_t stop_result = stopPublishVideo();
ESP_LOGI("IOT-SDK", "Stop Publish Video Result: %d", stop_result);
}

API Reference

The API references for all the methods utilized in this guide are provided below.

Got a Question? Ask us on discord