New Video Stream

2024-05-17
No Rating

Sample Introduction

MSDK has made some optimizations to the video stream function. Developers have no longer pay attention to the channels but the camera position, data required. The old video stream function has been obsoleted. The new function is recommended.

  • Supports outputting multiple camera views to multiple surfaces. Three scale types are supported, including Filling, adaptive full screen and adaptive zoom.
  • More output formats of video stream are supported, including RGBA, YUV_420, YUV_422, YUV_444, NV21 and YUYV. It is convenient for developers to do further development.
  • The live stream function is no longer depending on the video stream display.
  • The performance and efficiency of video stream are optimized.

API Differences

  • IVideoStreamManager ability transfer
Old APINew APIExplanation
getAvailableStreamSources()
addStreamSourcesListener()
addAvailableCameraUpdatedListener()Combined into one API. Each calling returns latest available camera state. Using the new API, developers only need to focus on the camera index.
removeStreamSourcesListener()removeOnAvailableCameraUpdatedListener()Only name changes. The using method remains the same.
clearAllStreamSourcesListeners()/Not provided
getAvailableVideoChannels()
getAvailableVideoChannel()
/New API cancels the concept of channel. Only camera index and camera data need to be concerned.
destroy()/Not provided
  • IVideoChannel ability transfer
Old APINew APIExplanation
getVideoChannelType()
getVideoChannelStatus()
getStreamSource()
startChannel()
closeChannel()
addVideoChannelStateChangeListener()
removeVideoChannelStateChangeListener()
clearAllVideoChannelStateChangeListeners()
/New API cancels the concept of channel. Only camera index and camera data need to be concerned.
getVideoStreamFormat()addReceiveStreamListener()Function providing stream format is no longer provided. It might be inaccurate. Through the callback of listening function, developer can get stream of one frame and the frame format.
addStreamDataListener()addReceiveStreamListener()/
removeStreamDataListener()removeReceiveStreamListener()/
  • IVideoDecoder ability transfer
Old APINew APIExplanation
destroy()
onPause()
onResume()
setMediaFile()
getMediaFile()
queueInFrame()
/Not provided
getVideoChannelType()
setVideoChannelType()
/New API cancels the concept of channel. Only camera index and camera data need to be concerned.
getDecoderOutputMode()
getDecoderStatus()
addDecoderStateChangeListener()
removeDecoderStateChangeListener()
clearAllDecoderStateChangeListeners()
/Developers don't need to pay attention to the decoding method, output method and the decoder state.
getVideoWidth()addReceiveStreamListener() or addFrameListener()Function providing width and height is no longer provided. It might be inaccurate. Through the callback of listening function, developer can get the width, height and more details.
getVideoHeight()addReceiveStreamListener() or addFrameListener()Function providing width and height is no longer provided. It might be inaccurate. Through the callback of listening function, developer can get the width, height and more details.
addYuvDataListener()addFrameListener()/
removeYuvDataListener()removeFrameListener()/
clearAllYuvDataListeners()/Not provided

Because the concept of channel has been cancelled, some APIs of class ILiveStreamManager and IMediaManager have to be transferred.

  • ILiveStreamManager ability transfer

For more contents, please read the Live Stream Sampleopen in new window

Old APINew APIExplanation
setVideoChannelType()setCameraIndex()/
getVideoChannelType()getCameraIndex()/
  • IMediaManager ability transfer

For more contents, please read the Mdeia File Sampleopen in new window

Old APINew APIExplanation
playVideo()playVideoToSurface()Because IVideoChannel() and IVideoDecoder() are deprecated, new API can directly transmit surface for display. No need to consider the channel and decoder.

Interface Calling Process

The following figure shows a complete interface display and an example of the interface calling process. For detailed usage, please check the ICameraStreamManageropen in new window of Mobile SDK API Reference.

New video stream function is capable for displaying the stream, getting original stream data and frame data.

  • Stream display
    Stream display is able to specify the camera index and which surface to display. Also it can set the surface width, height and zoom type. Camera lens can be switched through KeyCameraVideoStreamSource.

  • Get original stream
    Through the callback of listening function, original stream of specified camera index can be obtained. Developers can get the stream data, data offset, data length, data information and so on. This stream data can be used for further functions, such as display and third-party live streaming.

  • Get frame data
    Through the callback of listening function, frame data of specified camera index and specified frame format can be obtained. Developers can get the frame data, data offset, data length, data width and so on. This frame data can be used for further algorithm processing, such as AI recognition.

Note: setKeepAliveDecoding() is used to decoding continuously in the background. If the API is set to be false, the decoding will be paused and the performance and power consumption will be lowered. But the latency of starting the video stream push will be increased.

Sample Acquisition

Video Stream Sampleopen in new window

If you have any comments or confusion about our documentation, you can click here to give feedback and we will get back to you as soon as possible.