Skip to main contentIBM Video Streaming Developers

Customization

Implementing a custom frame source

You can create your own frame source by implementing IBMWatsonMediaFrameSource and passing to IBMWatsonMediaBroadcaster in its init method. Here are the main components of the protocol:

Start and stop capturing

  • startCaptureWithCompletion:completion will called by IBMWatsonMediaBroadcaster to start to emitting frames. Call completion block once the frame sending is started or there was an error during the initialization process. If completion block returns with error IBMWatsonMediaBroadcaster state will set to IBMWatsonMediaVideoBroadcasterStateInitial and error will be reported via broadcaster:didFailWithError:

  • stopCapture calls to the stop frame source.

Preferred output format

IBMWatsonMediaCaptureConfig *preferredCaptureConfig describes ideal output format of video and audio frames that source should send to the broadcaster. It may change during the session. Note that sending video or audio frames with different format will cause conversion. Video frames with different aspect ratio will be scaled to fit to the preferred resolution with preserved original aspect ratio.

Frame source listener

id<IBMWatsonMediaFrameSourceListener> delegate provides methods to send audio or video frames, reporting error or custom events to the broadcaster.

  • If a video or audio frame was produced you can send to the broadcaster with frameSource:didOutputSampleBuffer: (both video and audio) or frameSource:didOutputPixelBuffer:timestamp:.

  • If an error happened and capturing cannot be continued you should call frameSource:didFailWithError:. Broadcast will stop and IBMWatsonMediaBroadcaster will send a didFailedWithError: to its delegate.