//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: private AudioTrack decodeTrackDetails(AudioTrackInfo trackInfo, DataInput input) throws IOException private AudioTrack decodeTrackDetails(AudioTrackInfo trackInfo, DataInput input) { string sourceName = input.readUTF(); foreach (AudioSourceManager sourceManager in sourceManagers) { if (sourceName.Equals(sourceManager.SourceName)) { return(sourceManager.decodeTrack(trackInfo, input)); } } return(null); }
GUIContent GetAudioTrackEnabledContent(ushort trackIdx) { while (m_AudioTrackInfos.Count <= trackIdx) { m_AudioTrackInfos.Add(new AudioTrackInfo()); } AudioTrackInfo info = m_AudioTrackInfos[trackIdx]; VideoPlayer player = null; if (!serializedObject.isEditingMultipleObjects) { player = (VideoPlayer)target; } // Only produce a decorated track label with single-selection. No // point trying to come up with a label that makes the average of // the current track params... string language = player ? player.GetAudioLanguageCode(trackIdx) : ""; ushort channelCount = player ? player.GetAudioChannelCount(trackIdx) : (ushort)0; if (language != info.language || channelCount != info.channelCount || info.content == null) { string trackDetails = ""; if (language.Length > 0) { trackDetails += language; } if (channelCount > 0) { if (trackDetails.Length > 0) { trackDetails += ", "; } trackDetails += channelCount + " ch"; } if (trackDetails.Length > 0) { trackDetails = " [" + trackDetails + "]"; } info.content = EditorGUIUtility.TextContent("Track " + trackIdx + trackDetails); info.content.tooltip = s_Styles.enableDecodingTooltip; } return(info.content); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: @Override public void encodeTrack(MessageOutput stream, AudioTrack track) throws IOException public override void encodeTrack(MessageOutput stream, AudioTrack track) { DataOutput output = stream.startMessage(); output.write(TRACK_INFO_VERSION); AudioTrackInfo trackInfo = track.Info; output.writeUTF(trackInfo.title); output.writeUTF(trackInfo.author); output.writeLong(trackInfo.length); output.writeUTF(trackInfo.identifier); output.writeBoolean(trackInfo.isStream); DataFormatTools.writeNullableText(output, trackInfo.uri); encodeTrackDetails(track, output); output.writeLong(track.Position); stream.commitMessage(TRACK_INFO_VERSIONED); }
public VlcPreparsedMedia(Io.MediaInput mediaInput, VlcMediaInternal media) : base(mediaInput) { if (media == null) { throw new ArgumentNullException("media"); } this.media = media; this.Duration = media.Duration; // List <AudioTrackInfo> audioTracks = new List <AudioTrackInfo>(); List <VideoTrackInfo> videoTracks = new List <VideoTrackInfo>(); libvlc_media_track_info_t[] tracks = media.GetTracksInfo(); foreach (libvlc_media_track_info_t track in tracks) { if (track.i_type == libvlc_track_t.libvlc_track_audio) { AudioTrackInfo audioTrack = new AudioTrackInfo(); audioTrack.BitRate = track.i_rate; audioTrack.Channels = (int)Math.Min(track.i_channels, (uint)int.MaxValue); audioTrack.Code = track.i_codec; audioTrack.Description = LibVlcInterop.vlc_fourcc_GetDescription(0, track.i_codec); audioTracks.Add(audioTrack); } else if (track.i_type == libvlc_track_t.libvlc_track_video) { VideoTrackInfo videoTrack = new VideoTrackInfo(); videoTrack.Code = track.i_codec; videoTrack.Description = LibVlcInterop.vlc_fourcc_GetDescription(0, track.i_codec); videoTrack.Height = (int)Math.Min((uint)int.MaxValue, (uint)track.i_height); videoTrack.Width = (int)Math.Min((uint)int.MaxValue, (uint)track.i_width); videoTracks.Add(videoTrack); } } // SetTracksInfo(videoTracks, audioTracks); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: @Override public DecodedTrackHolder decodeTrack(MessageInput stream) throws IOException public override DecodedTrackHolder decodeTrack(MessageInput stream) { DataInput input = stream.nextMessage(); if (input == null) { return(null); } int version = (stream.MessageFlags & TRACK_INFO_VERSIONED) != 0 ? (input.readByte() & 0xFF) : 1; AudioTrackInfo trackInfo = new AudioTrackInfo(input.readUTF(), input.readUTF(), input.readLong(), input.readUTF(), input.readBoolean(), version >= 2 ? DataFormatTools.readNullableText(input) : null); AudioTrack track = decodeTrackDetails(trackInfo, input); long position = input.readLong(); if (track != null) { track.Position = position; } stream.skipRemainingBytes(); return(new DecodedTrackHolder(track)); }
/// <summary> /// get several Audio Informations from the IFO file /// </summary> /// <param name="fileName">name of the IFO file</param> /// <param name="verbose">to have complete infos or not</param> /// <returns>several infos as String</returns> public static AudioTrackInfo[] GetAudioInfos(string FileName, bool verbose) { FileStream fs = new FileStream(FileName, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs); Stream sr = br.BaseStream; // go to audio stream number sr.Seek(0x203, SeekOrigin.Begin); byte a = br.ReadByte(); if (a > 8) { a = 8; // force the max #. According to the specs 8 is the max value for audio streams. } AudioTrackInfo[] ati = new AudioTrackInfo[a]; for (int i = 0; i < a; i++) { ati[i] = new AudioTrackInfo(); byte[] array = new byte[2]; fs.Read(array, 0, 2); string cm = GetAudioCodingMode(array); string sp = GetAudioSamplingRate(array); int ch = (int)((GetAudioChannels(array)) + 1); byte trackID = 0xBD; StringBuilder ad = new StringBuilder(); switch (cm) { case "AC3": trackID = (byte)(0x80 + i); break; case "LPCM": trackID = (byte)(0xA0 + i); break; case "DTS": trackID = (byte)(0x88 + i); break; } if (verbose) { string mce = "Not Present"; if (GetAudioMultichannelExt(array)) { mce = "Present"; } string lt = GetAudioLanguageType(array); string ap = GetAudioApplicationMode(array); string aq = GetAudioQuantization(array); ad.AppendFormat("Track# : {0:00} - [{1:X}]", i, trackID, Environment.NewLine); ad.AppendFormat("Coding Mode : {0}", cm, Environment.NewLine); ad.AppendFormat("Multichannel Extension : {0}", mce, Environment.NewLine); ad.AppendFormat("Language Type : {0}", lt, Environment.NewLine); ad.AppendFormat("Application Mode : {0}", ap, Environment.NewLine); ad.AppendFormat("Quantization : {0}", aq, Environment.NewLine); ad.AppendFormat("Sampling Rate : {0}", sp, Environment.NewLine); ad.AppendFormat("Channels : {0}", ch, Environment.NewLine); } byte[] buff = new byte[2]; br.Read(buff, 0, 2); string ShortLangCode = String.Format("{0}{1}", (char)buff[0], (char)buff[1]); sr.Seek(1, SeekOrigin.Current); byte[] l = new byte[1]; fs.Read(l, 0, 1); string lce = GetAudioLanguageCodeExt(l); ati[i].TrackID = trackID; ati[i].NbChannels = ch + " channels"; ati[i].SamplingRate = sp; ati[i].Type = cm; ati[i].Language = LanguageSelectionContainer.Short2FullLanguageName(ShortLangCode); if (verbose) { ad.AppendFormat("Language : {0} - {1}", LanguageSelectionContainer.Short2FullLanguageName(ShortLangCode), ShortLangCode, Environment.NewLine); ad.AppendFormat("Language Extension : {0}", lce, Environment.NewLine); ad.AppendLine(); ati[i].Description = ad.ToString(); } else { ati[i].Description = String.Format("[{0:X}] - {1} - {2}ch / {3} / {4}", trackID, cm, ch, sp, LanguageSelectionContainer.Short2FullLanguageName(ShortLangCode)); } // go to the next audio stream sr.Seek(2, SeekOrigin.Current); } fs.Close(); return(ati); }
/// <summary> /// get several Audio Informations from the IFO file /// </summary> /// <param name="fileName">name of the IFO file</param> /// <param name="verbose">to have complete infos or not</param> /// <returns>several infos as String</returns> public static AudioTrackInfo[] GetAudioInfos(string FileName, bool verbose) { FileStream fs = new FileStream(FileName, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs); Stream sr = br.BaseStream; // go to audio stream number sr.Seek(0x203, SeekOrigin.Begin); byte a = br.ReadByte(); if (a > 8) a = 8; // force the max #. According to the specs 8 is the max value for audio streams. AudioTrackInfo[] ati = new AudioTrackInfo[a]; for (int i = 0; i < a; i++) { ati[i] = new AudioTrackInfo(); byte[] array = new byte[2]; fs.Read(array, 0, 2); string cm = GetAudioCodingMode(array); string sp = GetAudioSamplingRate(array); int ch = (int)((GetAudioChannels(array)) + 1); byte trackID = 0xBD; StringBuilder ad = new StringBuilder(); switch (cm) { case "AC3": trackID = (byte)(0x80 + i); break; case "LPCM": trackID = (byte)(0xA0 + i); break; case "DTS": trackID = (byte)(0x88 + i); break; case "Mpeg-1": case "Mpeg-2 Ext": trackID = (byte)(0xC0 + i); break; } if (verbose) { string mce = "Not Present"; if (GetAudioMultichannelExt(array)) mce = "Present"; string lt = GetAudioLanguageType(array); string ap = GetAudioApplicationMode(array); string aq = GetAudioQuantization(array); ad.AppendFormat("Track# : {0:00} - [{1:X}]", i, trackID, Environment.NewLine); ad.AppendFormat("Coding Mode : {0}", cm, Environment.NewLine); ad.AppendFormat("Multichannel Extension : {0}", mce, Environment.NewLine); ad.AppendFormat("Language Type : {0}", lt, Environment.NewLine); ad.AppendFormat("Application Mode : {0}", ap, Environment.NewLine); ad.AppendFormat("Quantization : {0}", aq, Environment.NewLine); ad.AppendFormat("Sampling Rate : {0}", sp, Environment.NewLine); ad.AppendFormat("Channels : {0}", ch, Environment.NewLine); } byte[] buff = new byte[2]; br.Read(buff, 0, 2); string ShortLangCode = String.Format("{0}{1}", (char)buff[0], (char)buff[1]); sr.Seek(1, SeekOrigin.Current); byte[] l = new byte[1]; fs.Read(l, 0, 1); string lce = GetAudioLanguageCodeExt(l); ati[i].TrackID = trackID; ati[i].NbChannels = ch + " channels"; ati[i].SamplingRate = sp; ati[i].Type = cm; ati[i].Language = LanguageSelectionContainer.Short2FullLanguageName(ShortLangCode); if (verbose) { ad.AppendFormat("Language : {0} - {1}", LanguageSelectionContainer.Short2FullLanguageName(ShortLangCode), ShortLangCode, Environment.NewLine); ad.AppendFormat("Language Extension : {0}", lce, Environment.NewLine); ad.AppendLine(); ati[i].Description = ad.ToString(); } else { ati[i].Description = String.Format("[{0:X}] - {1} - {2}ch / {3} / {4}", trackID, cm, ch, sp, LanguageSelectionContainer.Short2FullLanguageName(ShortLangCode)); } // go to the next audio stream sr.Seek(2, SeekOrigin.Current); } fs.Close(); return ati; }