Commit 92d4e9ed authored by Martin Finkel's avatar Martin Finkel

Media: Fix 1 test and statistics property

parent c53e0db2
using System;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using NUnit.Framework;
using VideoLAN.LibVLC;
using Media = VideoLAN.LibVLC.Media;
......@@ -52,33 +53,30 @@ namespace LibVLCSharp.Tests
}
[Test]
public void CreateRealMedia()
public async Task CreateRealMedia()
{
var instance = new Instance();
var media = new Media(instance, RealMediaPath, Media.FromType.FromPath);
Assert.False(media.IsParsed);
media.Parse();
//await media.ParseAsync();
Assert.True(media.IsParsed);
Assert.NotZero(media.Duration);
Assert.NotZero(media.Tracks.First().Data.Audio.Channels);
Assert.AreEqual(Media.MediaParsedStatus.Done, media.ParsedStatus);
Assert.AreEqual(Media.MediaType.File, media.Type);
}
string RealMediaPath
{
get
using (var instance = new Instance())
{
var dir = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
//var binDir = Path.Combine(dir, "..\\..\\..\\");
var files = Directory.GetFiles(dir);
return files.First(f => f.Contains("Klang"));
using (var media = new Media(instance, RealStreamMediaPath, Media.FromType.FromLocation))
{
Assert.False(media.IsParsed);
media.Parse();
Assert.True(media.IsParsed);
Assert.NotZero(media.Duration);
using (var mp = new MediaPlayer(media))
{
Assert.True(mp.Play());
await Task.Delay(3000); // have to wait a bit for statistics to populate
Assert.Greater(media.Statistics.DemuxBitrate, 0);
mp.Stop();
}
}
}
}
string RealStreamMediaPath => "http://streams.videolan.org/streams/mp3/Owner-MPEG2.5.mp3";
[Test]
public void Duplicate()
{
......@@ -90,8 +88,9 @@ namespace LibVLCSharp.Tests
[Test]
public void CreateMediaFromFileStream()
{
Assert.Fail();
// TODO: fix this.
var media = new Media(new Instance(), new FileStream(RealMediaPath, FileMode.Open, FileAccess.Read, FileShare.Read));
var media = new Media(new Instance(), new FileStream("realFileUri", FileMode.Open, FileAccess.Read, FileShare.Read));
media.Parse();
Assert.NotZero(media.Tracks.First().Data.Audio.Channels);
}
......
......@@ -519,14 +519,7 @@ namespace VideoLAN.LibVLC
/// <summary>Get the current statistics about the media
/// structure that contain the statistics about the media
/// </summary>
public MediaStats Statistics
{
get
{
Internal.LibVLCMediaGetStats(NativeReference, out var stats);
return stats;
}
}
public MediaStats Statistics => Internal.LibVLCMediaGetStats(NativeReference, out var mediaStats) == 0 ? default(MediaStats) : mediaStats;
MediaEventManager _eventManager;
/// <summary>
......@@ -963,7 +956,7 @@ namespace VideoLAN.LibVLC
/// <remarks>callback</remarks>
[SuppressUnmanagedCodeSecurity, UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void CloseMedia(IntPtr opaque);
#endregion
#region Structs
......@@ -985,7 +978,6 @@ namespace VideoLAN.LibVLC
public int DecodedVideo;
public int DecodedAudio;
/* Video Output */
public int DisplayedPictures;
public int LostPictures;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment