private void ConfigureAudioStream(IMediaParserMediaStream audio) { IAudioConfigurationSource configurationSource = (IAudioConfigurationSource)audio.ConfigurationSource; Dictionary <MediaStreamAttributeKeys, string> dictionary = new Dictionary <MediaStreamAttributeKeys, string>(); string codecPrivateData = configurationSource.CodecPrivateData; Debug.WriteLine("TsMediaStreamSource.ConfigureAudioStream(): CodecPrivateData: " + codecPrivateData); if (!string.IsNullOrWhiteSpace(codecPrivateData)) { dictionary[MediaStreamAttributeKeys.CodecPrivateData] = codecPrivateData; } MediaStreamDescription streamDescription = new MediaStreamDescription(MediaStreamType.Audio, (IDictionary <MediaStreamAttributeKeys, string>)dictionary); lock (this._streamConfigurationLock) { this._audioStreamSource = audio.StreamSource; this._audioStreamDescription = streamDescription; } }
public static AudioStream CreateAudioStream(this IAudioConfigurationSource audioConfigurationSource) { var languageTag = audioConfigurationSource.GetLanguage(); if (string.IsNullOrWhiteSpace(languageTag)) { return(new AudioStream()); } var languageName = languageTag; try { if (Language.IsWellFormed(languageTag)) { var language = new Language(languageTag); var nativeName = language.NativeName; var displayName = language.DisplayName; Debug.WriteLine("Language: " + languageTag + " -> " + languageName + '/' + displayName); if (nativeName == displayName) { languageName = nativeName; } else { languageName = nativeName + '/' + displayName; } } } catch (Exception ex) { Debug.WriteLine("AudioStreamFactory.CreateAudioStream() failed: " + ex.Message); } return(new AudioStream(languageName, languageTag)); }