Streaming Audio to a Client
There are two ways your application can transmit audio to clients:
Explicitly send audio frames to the client—Explicitly sending audio frame-by-frame is best for situations in which you need tight integration between the video and audio frames, for example, if you are streaming speech synchronized with video of a person talking. To do so, call the
XStxServerSetAudioSourcefunction of the
XStxServerobject and set an audio source, you can then explicitly stream audio frames to the client by implementing the
XStxIAudioSourceFcnGetFramefunction of the
Automatically capture system audio and send that to the client —This is the easiest way to stream audio and works best in cases where you do not need tight integration between audio and video, for example if you are streaming background music during a puzzle game. To automatically stream audio, do not set an audio source by calling the
XStxServerSetAudioSourcefunction. When no audio source is set, the
XStxServerobject automatically captures system audio and streams that to the client.
Timestamps are important for keeping the audio and video frames in synchronization. If your application uses
automatic streaming of the system audio, the
XStxServer object timestamps the audio
frames using a built-in timestamp manager. You can also have the
automatically timestamp your video frames by setting the
willProvideTimestamps parameter to
false when you call the
XStxServerSetVideoSource function to set the video
source of your application.
If you want to set the timestamps explicitly for your video frames and your application is using the automatic
streaming of system audio, you can do so by having your application call the
XStxServerGetTimestampUs function. This function returns the current mono timestamp from
XStxServer object, in microseconds.