Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Martin Finkel
LibVLCSharp
Commits
92d4e9ed
Commit
92d4e9ed
authored
Mar 21, 2018
by
Martin Finkel
Browse files
Media: Fix 1 test and statistics property
parent
c53e0db2
Changes
2
Hide whitespace changes
Inline
Side-by-side
LibVLCSharp.Tests/MediaTests.cs
View file @
92d4e9ed
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
(
R
eal
MediaPath
,
FileMode
.
Open
,
FileAccess
.
Read
,
FileShare
.
Read
));
var
media
=
new
Media
(
new
Instance
(),
new
FileStream
(
"r
eal
FileUri"
,
FileMode
.
Open
,
FileAccess
.
Read
,
FileShare
.
Read
));
media
.
Parse
();
Assert
.
NotZero
(
media
.
Tracks
.
First
().
Data
.
Audio
.
Channels
);
}
...
...
LibVLCSharp/Media.cs
View file @
92d4e9ed
...
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment