public static MediaTrackInfo ToMediaInfo(this libvlc_media_track_info_t tInfo) { MediaTrackInfo mti = new MediaTrackInfo(); mti.Channels = tInfo.audio.i_channels; mti.Codec = tInfo.i_codec; mti.Height = tInfo.video.i_width; mti.Id = tInfo.i_id; mti.Level = tInfo.i_level; mti.Profile = tInfo.i_profile; mti.Rate = tInfo.audio.i_rate; mti.Width = tInfo.video.i_width; return(mti); }
/// <summary> /// 获取媒体的基本流的描述,注意,在调用该方法之前你需要首先调用 <see cref="ParseMedia"/> 方法,或者至少播放一次. /// 否则,你将的得到一个空数组 /// </summary> /// <returns>一个 <see cref="MediaTrackInfo"/> 数组</returns> public MediaTrackInfo[] GetTrackInfo() { IntPtr pointer; var count = _getTracksInfoFunction.Delegate(InstancePointer, out pointer); var result = new MediaTrackInfo[count]; var temp = pointer; for (var i = 0; i < count; i++) { result[i] = (MediaTrackInfo)Marshal.PtrToStructure(temp, typeof(MediaTrackInfo)); temp = (IntPtr)((int)temp + Marshal.SizeOf(typeof(MediaTrackInfo))); } Vlc.Free(pointer); return(result); }