Help for using libvlc_media_get_stats libvlc 2.0.6?

This forum is about all development around libVLC.
henrymark
Blank Cone
Blank Cone
Posts: 46
Joined: 11 Aug 2009 09:55

Help for using libvlc_media_get_stats libvlc 2.0.6?

Postby henrymark » 22 Apr 2013 11:38

When I use libvlc_media_get_stats in c#, I always get zero in all fields?
Does anybody get right response in this function?

My Code just like:

libvlc_media_get_stats(IntPtr handle, out libvlc_media_stats_t info);
[StructLayout(LayoutKind.Sequential)]
struct libvlc_media_stats
{
public float f_demux_bitrate;
...

}
Thanks for help!

Rémi Denis-Courmont
Developer
Developer
Posts: 15265
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: Help for using libvlc_media_get_stats libvlc 2.0.6?

Postby Rémi Denis-Courmont » 22 Apr 2013 17:09

I think it only works if the media is currently playing.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

henrymark
Blank Cone
Blank Cone
Posts: 46
Joined: 11 Aug 2009 09:55

Re: Help for using libvlc_media_get_stats libvlc 2.0.6?

Postby henrymark » 23 Apr 2013 03:32

Thanks a lot for reply.

I just checked the play state were playing(rtsp).

So I don't know that if my usage is wrong or this function not work?

sherington
Cone that earned his stripes
Cone that earned his stripes
Posts: 491
Joined: 10 Sep 2008 11:57
VLC version: master
Operating System: Linux

Re: Help for using libvlc_media_get_stats libvlc 2.0.6?

Postby sherington » 23 Apr 2013 17:19

I tested libvlc_media_get_stats in my own bindings with vlc 2.0.6 and it worked just fine.

henrymark
Blank Cone
Blank Cone
Posts: 46
Joined: 11 Aug 2009 09:55

Re: Help for using libvlc_media_get_stats libvlc 2.0.6?

Postby henrymark » 24 Apr 2013 05:53

Thanks for your reply,sherington , sorry about my poor coding experience.

Could you please give me some advice or hint.

Maybe I have written wrong code.In c#, I use [out] to get libvlc_media_stats_t structure. Is this right??

sherington
Cone that earned his stripes
Cone that earned his stripes
Posts: 491
Joined: 10 Sep 2008 11:57
VLC version: master
Operating System: Linux

Re: Help for using libvlc_media_get_stats libvlc 2.0.6?

Postby sherington » 24 Apr 2013 08:19

If I remember correctly, you allocate the libvlc_media_stats_t structure on your side, then invoke the libvlc_media_get_stats passing the pointer to your structure.

henrymark
Blank Cone
Blank Cone
Posts: 46
Joined: 11 Aug 2009 09:55

Re: Help for using libvlc_media_get_stats libvlc 2.0.6?

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;
}

sherington
Cone that earned his stripes
Cone that earned his stripes
Posts: 491
Joined: 10 Sep 2008 11:57
VLC version: master
Operating System: Linux

Re: Help for using libvlc_media_get_stats libvlc 2.0.6?

Postby sherington » 24 Apr 2013 17:24

I don't really use C#, but when I dabbled with it a while ago I did this:

Code: Select all

IntPtr statsPointer = Marshal.AllocHGlobal(Marshal.SizeOf(libvlcMediaStats)); try { Marshal.StructureToPtr(libvlcMediaStats, statsPointer, false); LibVlc.libvlc_media_get_stats(media, statsPointer); } finally { Marshal.FreeHGlobal(statsPointer); }
Maybe that can give you an idea, I don't know...

michikommader
New Cone
New Cone
Posts: 6
Joined: 15 May 2013 15:16

Re: Help for using libvlc_media_get_stats libvlc 2.0.6?

Postby michikommader » 15 May 2013 15:59

I currently observe a similar behaviour on 2.0.6. When recording an RTSP-stream with libvlc only i_demux_read_bytes and f_demux_bitrate of the stats are written. The same when using standalone VLC media player and recording my stream to a file. Just observe the statistics in the media information dialogue ...
It looks differently when I actually display the stream: Most of the values are written as expected.

It would be nice to get a number of recorded frames with libvlc also in recording mode, without (dis)playing the stream.

Michi


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 17 guests