private static IWMStreamConfig CreateAudioConf( IWMProfile wmProfile)
{
IWMProfileManager pProfileManager = null;
IWMStreamConfig pFormatCofig = null;
try
{
var WMMEDIATYPE_Audio = new Guid("73647561-0000-0010-8000-00AA00389B71");
IWMStreamConfig pStreamConfig;
wmProfile.CreateNewStream(WMMEDIATYPE_Audio, out pStreamConfig);
NativeMethods.WMCreateProfileManager(out pProfileManager);
var m_pCodecInfo = pProfileManager as IWMCodecInfo3;
var g_wszVBREnabled = "_VBRENABLED";
m_pCodecInfo.SetCodecEnumerationSetting(WMMEDIATYPE_Audio, 3, g_wszVBREnabled, AttrDataType.BOOL,
BitConverter.GetBytes(true), Marshal.SizeOf(true));
var g_wszNumPasses = "_PASSESUSED";
m_pCodecInfo.SetCodecEnumerationSetting(WMMEDIATYPE_Audio, 3, g_wszNumPasses, AttrDataType.DWORD,
BitConverter.GetBytes(1), sizeof(uint));
m_pCodecInfo.GetCodecFormat(WMMEDIATYPE_Audio, 3, 0, out pFormatCofig);
var pMediaProps = pFormatCofig as IWMMediaProps;
int dwMediaTypeLength = 0;
pMediaProps.GetMediaType(null, ref dwMediaTypeLength);
var ppmtDestination = new AMMediaType();
pMediaProps.GetMediaType(ppmtDestination, ref dwMediaTypeLength);
int bit;
pFormatCofig.GetBitrate(out bit);
pStreamConfig.SetBitrate(bit);
pStreamConfig.SetBufferWindow(3000);
var pMediaProps2 = pStreamConfig as IWMMediaProps;
pMediaProps2.SetMediaType(ppmtDestination);
var pPropertyVault = pStreamConfig as IWMPropertyVault;
pPropertyVault.SetProperty(g_wszVBREnabled, AttrDataType.BOOL, BitConverter.GetBytes(true),
Marshal.SizeOf(true));
pStreamConfig.SetStreamName("AudioStream1");
pStreamConfig.SetConnectionName("AudioOutput");
pStreamConfig.SetStreamNumber(2);
//
return pStreamConfig;
}
finally
{
Marshal.ReleaseComObject(pProfileManager);
Marshal.ReleaseComObject(pFormatCofig);
}
}