Postby henrymark » 24 Apr 2013 08:39
I just try two ways,and both always return zero.
1.
[DllImport("libvlc")]
public static extern int libvlc_media_get_stats(MediaPlayerHandle mediaPlayerHandle, ref libvlc_media_stats_t stats);
libvlc_media_stats stats = new libvlc_media_stats();
libvlc_media_get_stats(MediaPlayerHandle, ref stats);
2.
[DllImport("libvlc")]
public static extern int libvlc_media_get_stats(MediaPlayerHandle mediaPlayerHandle, ref IntPtr ptr);
libvlc_media_stats stats = new libvlc_media_stats();
IntPtr buffer = Marshal.AllocCoTaskMem(Marshal.SizeOf(stats));
Marshal.StructureToPtr(stats, buffer, false);
libvlc_media_get_stats(MediaPlayerHandle, ref buffer);
stats = (libvlc_media_stats)Marshal.PtrToStructure(buffer, typeof(libvlc_media_stats));
Marshal.FreeCoTaskMem(buffer);
structure declare:
[StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode)]
public struct libvlc_media_stats
{
public int i_read_bytes;
public float f_input_bitrate;
public int i_demux_read_bytes;
public float f_demux_bitrate;
public int i_demux_corrupted;
public int i_demux_discontinuity;
public int i_decoded_video;
public int i_decoded_audio;
public int i_displayed_pictures;
public int i_lost_pictures;
public int i_played_abuffers;
public int i_lost_abuffers;
public int i_sent_packets;
public int i_sent_bytes;
public float f_send_bitrate;
}