Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
Martin Finkel
LibVLCSharp
Commits
4e07fc09
Commit
4e07fc09
authored
Feb 09, 2018
by
Martin Finkel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
libvlc_renderer_item_hold call is currently failing
parent
49e3d4aa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
6 deletions
+57
-6
LibVLCSharp.Tests/RendererDiscovererTests.cs
LibVLCSharp.Tests/RendererDiscovererTests.cs
+15
-3
LibVLCSharp/RendererDiscoverer.cs
LibVLCSharp/RendererDiscoverer.cs
+42
-3
No files found.
LibVLCSharp.Tests/RendererDiscovererTests.cs
View file @
4e07fc09
using
System.Threading.Tasks
;
using
System.Linq
;
using
System.Threading.Tasks
;
using
NUnit.Framework
;
using
VideoLAN.LibVLC
;
using
static
System
.
Diagnostics
.
Debug
;
...
...
@@ -9,12 +10,13 @@ namespace LibVLCSharp.Tests
public
class
RendererDiscovererTests
{
[
Test
]
public
async
Task
T
()
public
async
Task
DiscoverItems
()
{
var
instance
=
new
Instance
();
var
rendererDiscoverer
=
new
RendererDiscoverer
(
instance
,
"microdns"
);
var
em
=
rendererDiscoverer
.
EventManager
;
var
itemAdded
=
false
;
em
.
ItemAdded
+=
(
sender
,
args
)
=>
{
...
...
@@ -23,12 +25,22 @@ namespace LibVLCSharp.Tests
WriteLine
(
"Can render video"
);
if
(
args
.
RendererItem
.
CanRenderAudio
)
WriteLine
(
"Can render audio"
);
itemAdded
=
true
;
};
if
(!
rendererDiscoverer
.
Start
())
NUnit
.
Framework
.
Assert
.
Fail
();
await
Task
.
Delay
(
1000
);
await
Task
.
Delay
(
10000
);
NUnit
.
Framework
.
Assert
.
True
(
itemAdded
);
}
[
Test
]
public
void
RetrieveListInformation
()
{
var
rd
=
new
RendererDiscoverer
(
new
Instance
(),
"rd"
);
NUnit
.
Framework
.
Assert
.
Positive
(
rd
.
List
.
Length
);
}
}
}
LibVLCSharp/RendererDiscoverer.cs
View file @
4e07fc09
...
...
@@ -6,6 +6,8 @@ namespace VideoLAN.LibVLC
{
public
class
RendererDiscoverer
:
Internal
{
readonly
IntPtr
_instanceNativeReference
;
struct
Native
{
[
SuppressUnmanagedCodeSecurity
]
...
...
@@ -36,17 +38,18 @@ namespace VideoLAN.LibVLC
[
SuppressUnmanagedCodeSecurity
]
[
DllImport
(
"libvlc"
,
CallingConvention
=
CallingConvention
.
Cdecl
,
EntryPoint
=
"libvlc_renderer_discoverer_list_get"
)]
internal
static
extern
UIntPtr
LibVLCRendererDiscovererGetList
(
IntPtr
instance
,
out
IntPtr
discovererList
);
internal
static
extern
ulong
LibVLCRendererDiscovererGetList
(
IntPtr
instance
,
ref
IntPtr
discovererList
);
[
SuppressUnmanagedCodeSecurity
]
[
DllImport
(
"libvlc"
,
CallingConvention
=
CallingConvention
.
Cdecl
,
EntryPoint
=
"libvlc_renderer_discoverer_list_release"
)]
internal
static
extern
void
LibVLCRendererDiscovererReleaseList
(
IntPtr
discovererList
,
UIntPtr
count
);
internal
static
extern
void
LibVLCRendererDiscovererReleaseList
(
IntPtr
discovererList
,
ulong
count
);
}
public
RendererDiscoverer
(
Instance
instance
,
string
name
)
:
base
(()
=>
Native
.
LibVLCRendererDiscovererNew
(
instance
.
NativeReference
,
name
),
Native
.
LibVLCRendererDiscovererRelease
)
{
_instanceNativeReference
=
instance
.
NativeReference
;
}
RendererDiscovererEventManager
_eventManager
;
...
...
@@ -67,6 +70,42 @@ namespace VideoLAN.LibVLC
public
bool
Start
()
=>
Native
.
LibVLCRendererDiscovererStart
(
NativeReference
)
==
0
;
public
void
Stop
()
=>
Native
.
LibVLCRendererDiscovererStop
(
NativeReference
);
public
Description
[]
List
{
get
{
var
discoverList
=
IntPtr
.
Zero
;
var
count
=
Native
.
LibVLCRendererDiscovererGetList
(
_instanceNativeReference
,
ref
discoverList
);
if
(
count
==
0
)
return
Array
.
Empty
<
Description
>();
var
rendererDiscovererDescription
=
new
Description
[(
int
)
count
];
for
(
var
i
=
0
;
i
<
(
int
)
count
;
i
++)
{
var
ptr
=
Marshal
.
ReadIntPtr
(
discoverList
,
i
*
IntPtr
.
Size
);
var
managedStruct
=
(
Description
)
Marshal
.
PtrToStructure
(
ptr
,
typeof
(
Description
));
rendererDiscovererDescription
[
i
]
=
managedStruct
;
}
Native
.
LibVLCRendererDiscovererReleaseList
(
discoverList
,
count
);
return
rendererDiscovererDescription
;
}
}
public
struct
Description
{
public
string
Name
{
get
;
}
public
string
LongName
{
get
;
}
public
Description
(
string
name
,
string
longName
)
{
Name
=
name
;
LongName
=
longName
;
}
}
}
public
class
RendererItem
:
Internal
...
...
@@ -109,7 +148,7 @@ namespace VideoLAN.LibVLC
public
RendererItem
(
IntPtr
reference
)
:
base
(()
=>
reference
,
Native
.
LibVLCRendererItemRelease
)
{
Native
.
LibVLCRendererItemHold
(
reference
);
Native
.
LibVLCRendererItemHold
(
reference
);
//fail
}
public
string
Name
=>
Native
.
LibVLCRendererItemName
(
NativeReference
);
...
...
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