Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
Martin Finkel
LibVLCSharp
Commits
8ad6612f
Commit
8ad6612f
authored
Dec 04, 2017
by
Martin Finkel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix TrackDescription retrieval
parent
9ef18f69
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
65 additions
and
156 deletions
+65
-156
Bindings.Tests/MediaPlayerTests.cs
Bindings.Tests/MediaPlayerTests.cs
+14
-5
LibVlcSharp/Manual/deprecated.cs
LibVlcSharp/Manual/deprecated.cs
+7
-7
LibVlcSharp/Manual/libvlc_media_player.cs
LibVlcSharp/Manual/libvlc_media_player.cs
+0
-139
libvlcsharp/Manual/MediaPlayer.cs
libvlcsharp/Manual/MediaPlayer.cs
+13
-5
libvlcsharp/Manual/Structures/TrackDescription.cs
libvlcsharp/Manual/Structures/TrackDescription.cs
+31
-0
No files found.
Bindings.Tests/MediaPlayerTests.cs
View file @
8ad6612f
...
...
@@ -41,16 +41,25 @@ namespace Bindings.Tests
}
[
Test
]
public
void
TrackDescription
()
public
async
Task
TrackDescription
()
{
//FIX ME
var
instance
=
new
Instance
();
var
mp
=
new
MediaPlayer
(
instance
);
var
media
=
new
Media
(
instance
,
RealMediaPath
,
Media
.
FromType
.
FromPath
);
var
tcs
=
new
TaskCompletionSource
<
bool
>();
mp
.
Media
=
media
;
var
track
=
mp
.
AudioTrack
;
Assert
.
True
(
mp
.
SetAudioTrack
(
track
));
Assert
.
IsNotEmpty
(
mp
.
AudioTrackDescription
);
mp
.
Play
();
mp
.
EventManager
.
Playing
+=
(
sender
,
args
)
=>
{
Assert
.
Zero
(
mp
.
AudioTrack
);
var
description
=
mp
.
AudioTrackDescription
;
Assert
.
True
(
mp
.
SetAudioTrack
(
description
.
First
().
Id
));
Assert
.
IsNotEmpty
(
description
);
tcs
.
SetResult
(
true
);
};
await
tcs
.
Task
;
Assert
.
True
(
tcs
.
Task
.
Result
);
}
[
Test
]
...
...
LibVlcSharp/Manual/deprecated.cs
View file @
8ad6612f
...
...
@@ -411,13 +411,13 @@ namespace VideoLAN.LibVLC
//}
/// <remarks>Use libvlc_track_description_list_release() instead</remarks>
public
static
void
LibvlcTrackDescriptionRelease
(
global
::
VideoLAN
.
LibVLC
.
TrackDescription
p_track_description
)
{
var
__arg0
=
ReferenceEquals
(
p_track_description
,
null
)
?
global
::
System
.
IntPtr
.
Zero
:
p_track_description
.
__Instance
;
__Internal
.
LibvlcTrackDescriptionRelease
(
__arg0
);
}
//
public static void LibvlcTrackDescriptionRelease(global::VideoLAN.LibVLC.TrackDescription p_track_description)
//
{
//
var __arg0 = ReferenceEquals(p_track_description, null)
//
? global::System.IntPtr.Zero
//
: p_track_description.__Instance;
//
__Internal.LibvlcTrackDescriptionRelease(__arg0);
//
}
/// <summary>Get current video height.</summary>
/// <param name="p_mi">the media player</param>
...
...
LibVlcSharp/Manual/libvlc_media_player.cs
View file @
8ad6612f
...
...
@@ -204,145 +204,6 @@ namespace VideoLAN.LibVLC
}
}
/// <summary>
/// <para>Description for video, audio tracks and subtitles. It contains</para>
/// <para>id, name (description string) and pointer to next record.</para>
/// </summary>
public
unsafe
partial
class
TrackDescription
:
IDisposable
{
[
StructLayout
(
LayoutKind
.
Explicit
,
Size
=
24
)]
public
partial
struct
__Internal
{
[
FieldOffset
(
0
)]
internal
int
i_id
;
[
FieldOffset
(
8
)]
internal
global
::
System
.
IntPtr
psz_name
;
[
FieldOffset
(
16
)]
internal
global
::
System
.
IntPtr
p_next
;
[
SuppressUnmanagedCodeSecurity
]
[
DllImport
(
"libvlc"
,
CallingConvention
=
global
::
System
.
Runtime
.
InteropServices
.
CallingConvention
.
Cdecl
,
EntryPoint
=
"??0libvlc_track_description_t@@QEAA@AEBU0@@Z"
)]
internal
static
extern
global
::
System
.
IntPtr
cctor
(
global
::
System
.
IntPtr
instance
,
global
::
System
.
IntPtr
_0
);
}
public
global
::
System
.
IntPtr
__Instance
{
get
;
protected
set
;
}
protected
int
__PointerAdjustment
;
internal
static
readonly
global
::
System
.
Collections
.
Concurrent
.
ConcurrentDictionary
<
IntPtr
,
global
::
VideoLAN
.
LibVLC
.
TrackDescription
>
NativeToManagedMap
=
new
global
::
System
.
Collections
.
Concurrent
.
ConcurrentDictionary
<
IntPtr
,
global
::
VideoLAN
.
LibVLC
.
TrackDescription
>();
protected
void
*[]
__OriginalVTables
;
protected
bool
__ownsNativeInstance
;
internal
static
global
::
VideoLAN
.
LibVLC
.
TrackDescription
__CreateInstance
(
global
::
System
.
IntPtr
native
,
bool
skipVTables
=
false
)
{
return
new
global
::
VideoLAN
.
LibVLC
.
TrackDescription
(
native
.
ToPointer
(),
skipVTables
);
}
internal
static
global
::
VideoLAN
.
LibVLC
.
TrackDescription
__CreateInstance
(
global
::
VideoLAN
.
LibVLC
.
TrackDescription
.
__Internal
native
,
bool
skipVTables
=
false
)
{
return
new
global
::
VideoLAN
.
LibVLC
.
TrackDescription
(
native
,
skipVTables
);
}
private
static
void
*
__CopyValue
(
global
::
VideoLAN
.
LibVLC
.
TrackDescription
.
__Internal
native
)
{
var
ret
=
Marshal
.
AllocHGlobal
(
sizeof
(
global
::
VideoLAN
.
LibVLC
.
TrackDescription
.
__Internal
));
*(
global
::
VideoLAN
.
LibVLC
.
TrackDescription
.
__Internal
*)
ret
=
native
;
return
ret
.
ToPointer
();
}
private
TrackDescription
(
global
::
VideoLAN
.
LibVLC
.
TrackDescription
.
__Internal
native
,
bool
skipVTables
=
false
)
:
this
(
__CopyValue
(
native
),
skipVTables
)
{
__ownsNativeInstance
=
true
;
NativeToManagedMap
[
__Instance
]
=
this
;
}
protected
TrackDescription
(
void
*
native
,
bool
skipVTables
=
false
)
{
if
(
native
==
null
)
return
;
__Instance
=
new
global
::
System
.
IntPtr
(
native
);
}
public
TrackDescription
()
{
__Instance
=
Marshal
.
AllocHGlobal
(
sizeof
(
global
::
VideoLAN
.
LibVLC
.
TrackDescription
.
__Internal
));
__ownsNativeInstance
=
true
;
NativeToManagedMap
[
__Instance
]
=
this
;
}
public
TrackDescription
(
global
::
VideoLAN
.
LibVLC
.
TrackDescription
_0
)
{
__Instance
=
Marshal
.
AllocHGlobal
(
sizeof
(
global
::
VideoLAN
.
LibVLC
.
TrackDescription
.
__Internal
));
__ownsNativeInstance
=
true
;
NativeToManagedMap
[
__Instance
]
=
this
;
*((
global
::
VideoLAN
.
LibVLC
.
TrackDescription
.
__Internal
*)
__Instance
)
=
*((
global
::
VideoLAN
.
LibVLC
.
TrackDescription
.
__Internal
*)
_0
.
__Instance
);
}
public
void
Dispose
()
{
Dispose
(
disposing
:
true
);
}
public
virtual
void
Dispose
(
bool
disposing
)
{
if
(
__Instance
==
IntPtr
.
Zero
)
return
;
global
::
VideoLAN
.
LibVLC
.
TrackDescription
__dummy
;
NativeToManagedMap
.
TryRemove
(
__Instance
,
out
__dummy
);
if
(
__ownsNativeInstance
)
Marshal
.
FreeHGlobal
(
__Instance
);
__Instance
=
IntPtr
.
Zero
;
}
public
int
IId
{
get
{
return
((
global
::
VideoLAN
.
LibVLC
.
TrackDescription
.
__Internal
*)
__Instance
)->
i_id
;
}
set
{
((
global
::
VideoLAN
.
LibVLC
.
TrackDescription
.
__Internal
*)
__Instance
)->
i_id
=
value
;
}
}
public
sbyte
*
PszName
{
get
{
return
(
sbyte
*)
((
global
::
VideoLAN
.
LibVLC
.
TrackDescription
.
__Internal
*)
__Instance
)->
psz_name
;
}
set
{
((
global
::
VideoLAN
.
LibVLC
.
TrackDescription
.
__Internal
*)
__Instance
)->
psz_name
=
(
global
::
System
.
IntPtr
)
value
;
}
}
public
global
::
VideoLAN
.
LibVLC
.
TrackDescription
PNext
{
get
{
global
::
VideoLAN
.
LibVLC
.
TrackDescription
__result0
;
if
(((
global
::
VideoLAN
.
LibVLC
.
TrackDescription
.
__Internal
*)
__Instance
)->
p_next
==
IntPtr
.
Zero
)
__result0
=
null
;
else
if
(
global
::
VideoLAN
.
LibVLC
.
TrackDescription
.
NativeToManagedMap
.
ContainsKey
(((
global
::
VideoLAN
.
LibVLC
.
TrackDescription
.
__Internal
*)
__Instance
)->
p_next
))
__result0
=
(
global
::
VideoLAN
.
LibVLC
.
TrackDescription
)
global
::
VideoLAN
.
LibVLC
.
TrackDescription
.
NativeToManagedMap
[((
global
::
VideoLAN
.
LibVLC
.
TrackDescription
.
__Internal
*)
__Instance
)->
p_next
];
else
__result0
=
global
::
VideoLAN
.
LibVLC
.
TrackDescription
.
__CreateInstance
(((
global
::
VideoLAN
.
LibVLC
.
TrackDescription
.
__Internal
*)
__Instance
)->
p_next
);
return
__result0
;
}
set
{
((
global
::
VideoLAN
.
LibVLC
.
TrackDescription
.
__Internal
*)
__Instance
)->
p_next
=
ReferenceEquals
(
value
,
null
)
?
global
::
System
.
IntPtr
.
Zero
:
value
.
__Instance
;
}
}
}
public
unsafe
partial
class
TitleDescription
:
IDisposable
{
[
StructLayout
(
LayoutKind
.
Explicit
,
Size
=
24
)]
...
...
libvlcsharp/Manual/MediaPlayer.cs
View file @
8ad6612f
...
...
@@ -1137,11 +1137,19 @@ namespace VideoLAN.LibVLC.Manual
if
(
trackPtr
==
IntPtr
.
Zero
)
return
Array
.
Empty
<
TrackDescription
>();
var
trackDescriptions
=
new
List
<
TrackDescription
>();
var
tracks
=
Marshal
.
PtrToStructure
<
TrackDescription
>(
trackPtr
);
while
(
tracks
!=
null
)
{
trackDescriptions
.
Add
(
tracks
);
tracks
=
tracks
.
PNext
;
var
track
=
Marshal
.
PtrToStructure
<
TrackDescription
>(
trackPtr
);
while
(
true
)
{
trackDescriptions
.
Add
(
track
);
if
(
track
.
Next
!=
IntPtr
.
Zero
)
{
track
=
Marshal
.
PtrToStructure
<
TrackDescription
>(
track
.
Next
);
}
else
{
break
;
}
}
return
trackDescriptions
.
ToArray
();
}
...
...
libvlcsharp/Manual/Structures/TrackDescription.cs
0 → 100644
View file @
8ad6612f
using
System
;
using
System.Collections.Generic
;
using
System.Runtime.InteropServices
;
using
System.Security
;
namespace
VideoLAN.LibVLC
{
/// <summary>
/// <para>Description for video, audio tracks and subtitles. It contains</para>
/// <para>id, name (description string) and pointer to next record.</para>
/// </summary>
public
struct
TrackDescription
{
public
int
Id
{
get
;
set
;
}
public
string
Name
{
get
;
set
;
}
public
IntPtr
Next
{
get
;
set
;
}
public
override
bool
Equals
(
object
obj
)
{
if
(!(
obj
is
TrackDescription
))
{
return
false
;
}
var
description
=
(
TrackDescription
)
obj
;
return
Id
==
description
.
Id
&&
Name
==
description
.
Name
&&
EqualityComparer
<
IntPtr
>.
Default
.
Equals
(
Next
,
description
.
Next
);
}
}
}
\ No newline at end of file
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