This article is related to MPlatform SDK only.
For example, you'd like to disable the original audio from the video source like a playlist, and instead, take the audio from an external source (a soundcard or any other source) to replace the original audio.
Create an MMixer object
Well, here is the simplest part of this scenario:
MMixerClass myMixer = new MMixerClass() // ... configure preview, set video and audio formats // myMixer.ObjectStart(null);
Streams configuration
You should add both your sources to the MMixer as streams.
The video source can be added like
MItem videoStream; myMixer.StreamsAdd("videoStream", myPlaylist, "", "", out videoStream, 0.0);
As for a stream that we'll use as an audio source, it should be an MLive object configured to use None as a video source and required audio as the external audio:
MLiveClass myLive = new MLiveClass(); myLive.DeviceSet("video", "<None>", ""); myLive.DeviceSet("ext_audio", myAudioSource, ""); myLive.ObjectStart(null);
And then you should add the MLive object to the MMixer:
MItem audioStream; myMixer.StreamsAdd("audioStream", myPlaylist, "", "", out audioStream, 0.0);
Scene configuration
For our sources, we need 2 elements in the MMixer scene. The element related to the video source should be displayed on a full screen and its audio should be disabled. The element related to audio should be located out of the screen (so it doesn't overlay the video source), but its audio should be on. Here is a code:
MElement rootElement; m_objMixer.ElementsGetByIndex(0, out rootElement); MElement audioElement; MElement videoElement; ((IMElements)rootElement).ElementsAdd("", "video", "stream_id='audioStream' x=2 show=1 audio_gain=0", out audioElement, 0.0); ((IMElements)rootElement).ElementsAdd("", "video", "stream_id='videoStream' h=1 w=1 x=0 y=0 show=1 audio_gain=-100", out videoElement, 0.0);
Actually, that's it.