/// <summary> /// Allocate storage for all buffers. This should be called after CreateBufferIndex, /// after SetMediaTypes and before Start. Also create the audio mixer here. /// </summary> /// <returns></returns> public bool CreateBuffers() { if ((audioMediaType == null) || (videoMediaType == null)) { return(false); } UW.CSE.MDShow.MediaTypeWaveFormatEx wf = audioMediaType.ToMediaTypeWaveFormatEx(); audioMixer = new AudioMixer(wf.WaveFormatEx.BitsPerSample, wf.WaveFormatEx.AvgBytesPerSec, wf.WaveFormatEx.Channels); if (videoBuffer != null) { if (!videoBuffer.Create(videoMediaType)) { return(false); } } else { return(false); } lock (this) { foreach (AudioBuffer ab in audioBuffers.Values) { if (!ab.Create()) { return(false); } } } return(true); }
/// <summary> /// Allocate and configure one of the temp buffers. These are to be used in preparation for /// switching sources while encoding. /// </summary> /// <param name="index"></param> /// <param name="mt"></param> public void CreateTempBuffer(int index, UW.CSE.MDShow.MediaType mt) { if ((tmpVideoBuffer != null) && (tmpVideoBuffer.Index == index)) { tmpVideoMediaType = mt; tmpVideoBuffer.Create(mt); } else if ((tmpAudioBuffer != null) && (tmpAudioBuffer.Index == index)) { tmpAudioMediaType = mt; tmpAudioBuffer.AudioMediaType = mt; tmpAudioBuffer.Create(); } }