Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-gpu
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-gpu
Commits
a744c7cf
Commit
a744c7cf
authored
Feb 19, 2009
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Start rewriting the CIL bindings
parent
866faad6
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
417 additions
and
310 deletions
+417
-310
bindings/cil/src/Makefile.am
bindings/cil/src/Makefile.am
+2
-0
bindings/cil/src/exception.cs
bindings/cil/src/exception.cs
+11
-6
bindings/cil/src/libvlc.cs
bindings/cil/src/libvlc.cs
+101
-265
bindings/cil/src/marshal.cs
bindings/cil/src/marshal.cs
+41
-15
bindings/cil/src/media.cs
bindings/cil/src/media.cs
+102
-0
bindings/cil/src/player.cs
bindings/cil/src/player.cs
+130
-0
bindings/cil/src/ustring.cs
bindings/cil/src/ustring.cs
+21
-7
bindings/cil/tests/testvlc.cs
bindings/cil/tests/testvlc.cs
+9
-17
No files found.
bindings/cil/src/Makefile.am
View file @
a744c7cf
...
@@ -7,6 +7,8 @@ SOURCES_dll = \
...
@@ -7,6 +7,8 @@ SOURCES_dll = \
ustring.cs
\
ustring.cs
\
exception.cs
\
exception.cs
\
marshal.cs
\
marshal.cs
\
media.cs
\
player.cs
\
libvlc.cs
libvlc.cs
VideoLAN.LibVLC.dll
:
$(SOURCES_dll)
VideoLAN.LibVLC.dll
:
$(SOURCES_dll)
...
...
bindings/cil/src/exception.cs
View file @
a744c7cf
/*
/*
*
*
libvlc.cs - libvlc CIL binding
s
*
@file exception.c
s
*
*
@brief LibVLC exceptions
*
$Id$
*
@ingroup API
*/
*/
/**********************************************************************
/**********************************************************************
* Copyright (C) 2007
Rémi Denis-Courmont.
*
* Copyright (C) 2007
-2009 Rémi Denis-Courmont.
*
* This program is free software; you can redistribute and/or modify *
* This program is free software; you can redistribute and/or modify *
* it under the terms of the GNU General Public License as published *
* it under the terms of the GNU General Public License as published *
* by the Free Software Foundation; version 2 of the license, or (at *
* by the Free Software Foundation; version 2 of the license, or (at *
...
@@ -27,7 +27,8 @@ using System.Runtime.InteropServices;
...
@@ -27,7 +27,8 @@ using System.Runtime.InteropServices;
namespace
VideoLAN.LibVLC
namespace
VideoLAN.LibVLC
{
{
/**
/**
* VLCException: managed base class for LibVLC exceptions
* @brief VLCException: base class for LibVLC exceptions
* @ingroup API
*/
*/
public
class
VLCException
:
Exception
public
class
VLCException
:
Exception
{
{
...
@@ -58,6 +59,10 @@ namespace VideoLAN.LibVLC
...
@@ -58,6 +59,10 @@ namespace VideoLAN.LibVLC
}
}
};
};
/**
* @section Internals
*/
/**
/**
* libvlc_exception_t: structure for unmanaged LibVLC exceptions
* libvlc_exception_t: structure for unmanaged LibVLC exceptions
*/
*/
...
...
bindings/cil/src/libvlc.cs
View file @
a744c7cf
This diff is collapsed.
Click to expand it.
bindings/cil/src/marshal.cs
View file @
a744c7cf
/**
/**
* @file marshal.cs
* @file marshal.cs
* @brief LibVLC marshalling utilities
* @brief Common LibVLC objects marshalling utilities
*
* @ingroup Internals
* $Id$
*/
*/
/**********************************************************************
/**********************************************************************
* Copyright (C) 2007
Rémi Denis-Courmont.
*
* Copyright (C) 2007
-2009 Rémi Denis-Courmont.
*
* This program is free software; you can redistribute and/or modify *
* This program is free software; you can redistribute and/or modify *
* it under the terms of the GNU General Public License as published *
* it under the terms of the GNU General Public License as published *
* by the Free Software Foundation; version 2 of the license, or (at *
* by the Free Software Foundation; version 2 of the license, or (at *
...
@@ -28,17 +27,21 @@ using System.Runtime.InteropServices;
...
@@ -28,17 +27,21 @@ using System.Runtime.InteropServices;
namespace
VideoLAN.LibVLC
namespace
VideoLAN.LibVLC
{
{
/**
/**
* Abstract safe handle class for non-NULL pointers
* @brief NonNullHandle: abstract safe handle class for non-NULL pointers
* (Microsoft.* namespace has a similar class,
* @ingroup Internals
* but lets stick to System.*).
* Microsoft.* namespace has a similar class. However we want to use the
* System.* namespace only.
*/
*/
public
abstract
class
NonNullHandle
:
SafeHandle
internal
abstract
class
NonNullHandle
:
SafeHandle
{
{
protected
NonNullHandle
()
protected
NonNullHandle
()
:
base
(
IntPtr
.
Zero
,
true
)
:
base
(
IntPtr
.
Zero
,
true
)
{
{
}
}
/**
* System.Runtime.InteropServices.SafeHandle::IsInvalid.
*/
public
override
bool
IsInvalid
public
override
bool
IsInvalid
{
{
get
get
...
@@ -46,26 +49,49 @@ namespace VideoLAN.LibVLC
...
@@ -46,26 +49,49 @@ namespace VideoLAN.LibVLC
return
handle
==
IntPtr
.
Zero
;
return
handle
==
IntPtr
.
Zero
;
}
}
}
}
protected
abstract
void
Destroy
();
/**
* System.Runtime.InteropServices.SafeHandle::ReleaseHandle.
*/
protected
override
bool
ReleaseHandle
()
{
Destroy
();
return
true
;
}
};
};
/**
/**
* Generic class for managed wrapper around a native safe handle.
* @brief BaseObject: generic wrapper around a safe handle.
* @ingroup Internals
* This is the baseline for all managed LibVLC objects which wrap
* an unmanaged LibVLC pointer.
*/
*/
public
class
BaseObject
<
HandleT
>
:
IDisposable
where
HandleT
:
SafeHand
le
public
class
BaseObject
:
IDisposab
le
{
{
protected
NativeException
ex
;
protected
NativeException
ex
;
/**< buffer for LibVLC exceptions */
protected
HandleT
self
;
protected
SafeHandle
handle
;
/**< wrapped safe handle */
internal
BaseObject
(
HandleT
self
)
internal
BaseObject
()
{
{
this
.
self
=
self
;
ex
=
new
NativeException
();
ex
=
new
NativeException
();
this
.
handle
=
null
;
}
protected
void
Raise
()
{
ex
.
Raise
();
}
}
/**
* IDisposable::Dispose.
*/
public
void
Dispose
()
public
void
Dispose
()
{
{
ex
.
Dispose
();
ex
.
Dispose
();
self
.
Close
();
handle
.
Close
();
}
}
};
};
};
};
bindings/cil/src/media.cs
0 → 100644
View file @
a744c7cf
/**
* @file media.cs
* @brief Media descriptor class
* @ingroup API
*/
/**********************************************************************
* Copyright (C) 2007-2009 Rémi Denis-Courmont. *
* This program is free software; you can redistribute and/or modify *
* it under the terms of the GNU General Public License as published *
* by the Free Software Foundation; version 2 of the license, or (at *
* your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, you can get it from: *
* http://www.gnu.org/copyleft/gpl.html *
**********************************************************************/
using
System
;
//using System.Collections.Generic;
using
System.Runtime.InteropServices
;
namespace
VideoLAN.LibVLC
{
/**
* @brief MediaHandle: unmanaged LibVLC media pointer
* @ingroup Internals
*/
internal
sealed
class
MediaHandle
:
NonNullHandle
{
[
DllImport
(
"libvlc.dll"
,
EntryPoint
=
"libvlc_media_new"
)]
public
static
extern
MediaHandle
Create
(
InstanceHandle
inst
,
U8String
mrl
,
NativeException
ex
);
[
DllImport
(
"libvlc.dll"
,
EntryPoint
=
"libvlc_media_release"
)]
private
static
extern
void
Release
(
IntPtr
ptr
);
[
DllImport
(
"libvlc.dll"
,
EntryPoint
=
"libvlc_media_add_option"
)]
public
static
extern
void
AddOption
(
MediaHandle
ptr
,
U8String
options
,
NativeException
ex
);
[
DllImport
(
"libvlc.dll"
,
EntryPoint
=
"libvlc_media_add_option_untrusted"
)]
public
static
extern
void
AddUntrustedOption
(
MediaHandle
ptr
,
U8String
options
,
NativeException
ex
);
protected
override
void
Destroy
()
{
Release
(
handle
);
}
};
/**
* @brief Media: a source media
* Use this class to extract meta-informations from a media.
*/
public
class
Media
:
BaseObject
{
internal
MediaHandle
Handle
{
get
{
return
handle
as
MediaHandle
;
}
}
/**
* Creates a Media object.
*
* @param instance VLC instance
* @param mrl Media Resource Locator (file path or URL)
*/
public
Media
(
VLC
instance
,
string
mrl
)
{
U8String
umrl
=
new
U8String
(
mrl
);
handle
=
MediaHandle
.
Create
(
instance
.
Handle
,
umrl
,
ex
);
Raise
();
}
public
void
AddOptions
(
string
options
,
bool
trusted
)
{
U8String
uopts
=
new
U8String
(
options
);
if
(
trusted
)
MediaHandle
.
AddOption
(
Handle
,
uopts
,
ex
);
else
MediaHandle
.
AddUntrustedOption
(
Handle
,
uopts
,
ex
);
Raise
();
}
};
};
bindings/cil/src/player.cs
0 → 100644
View file @
a744c7cf
/**
* @file player.cs
* @brief Media player class
* @ingroup API
*
* @defgroup API Managed interface to LibVLC
* This is the primary class library for .NET applications
* to embed and control LibVLC.
*
* @defgroup Internals LibVLC internals
* This covers internal marshalling functions to use the native LibVLC.
* Only VLC developpers should need to read this section.
*/
/**********************************************************************
* Copyright (C) 2009 Rémi Denis-Courmont. *
* This program is free software; you can redistribute and/or modify *
* it under the terms of the GNU General Public License as published *
* by the Free Software Foundation; version 2 of the license, or (at *
* your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, you can get it from: *
* http://www.gnu.org/copyleft/gpl.html *
**********************************************************************/
using
System
;
using
System.Runtime.InteropServices
;
namespace
VideoLAN.LibVLC
{
/**
* @brief MediaPlayerHandle: unmanaged LibVLC media player pointer
* @ingroup Internals
*/
internal
sealed
class
MediaPlayerHandle
:
NonNullHandle
{
[
DllImport
(
"libvlc.dll"
,
EntryPoint
=
"libvlc_media_player_new"
)]
internal
static
extern
MediaPlayerHandle
Create
(
InstanceHandle
inst
,
NativeException
ex
);
[
DllImport
(
"libvlc.dll"
,
EntryPoint
=
"libvlc_media_player_new_from_media"
)]
internal
static
extern
MediaPlayerHandle
Create
(
MediaHandle
media
,
NativeException
ex
);
[
DllImport
(
"libvlc.dll"
,
EntryPoint
=
"libvlc_media_player_release"
)]
internal
static
extern
void
Release
(
IntPtr
ptr
);
[
DllImport
(
"libvlc.dll"
,
EntryPoint
=
"libvlc_media_player_set_media"
)]
internal
static
extern
MediaPlayerHandle
SetMedia
(
MediaPlayerHandle
player
,
MediaHandle
media
,
NativeException
ex
);
protected
override
void
Destroy
()
{
Release
(
handle
);
}
};
/**
* @brief MediaPlayer: a simple media player
* Use this class to play a media.
*/
public
class
MediaPlayer
:
BaseObject
{
internal
MediaPlayerHandle
Handle
{
get
{
return
handle
as
MediaPlayerHandle
;
}
}
Media
media
;
/**< Active media */
/**
* The Media object that the MediaPlayer is using,
* or null if there is none.
*/
public
Media
Media
{
get
{
return
media
;
}
set
{
MediaHandle
mh
=
(
value
!=
null
)
?
value
.
Handle
:
null
;
MediaPlayerHandle
.
SetMedia
(
Handle
,
mh
,
null
);
media
=
value
;
}
}
/**
* Creates an empty MediaPlayer object.
* An input media will be needed before this media player can be used.
*
* @param instance VLC instance
*/
public
MediaPlayer
(
VLC
instance
)
{
this
.
media
=
null
;
handle
=
MediaPlayerHandle
.
Create
(
instance
.
Handle
,
ex
);
ex
.
Raise
();
}
/**
* Creates a MediaPlayer object from a Media object.
* This allows playing the specified media.
*
* @param media media object
*/
public
MediaPlayer
(
Media
media
)
{
this
.
media
=
media
;
handle
=
MediaPlayerHandle
.
Create
(
media
.
Handle
,
ex
);
ex
.
Raise
();
}
};
};
bindings/cil/src/ustring.cs
View file @
a744c7cf
/*
/*
*
*
ustring.cs - Managed LibVLC string
*
@file ustring.cs
*
*
@brief Managed LibVLC strings
*
$Id$
*
@ingroup Internals
*/
*/
/**********************************************************************
/**********************************************************************
...
@@ -27,13 +27,20 @@ using System.Runtime.InteropServices;
...
@@ -27,13 +27,20 @@ using System.Runtime.InteropServices;
namespace
VideoLAN.LibVLC
namespace
VideoLAN.LibVLC
{
{
/**
/**
* Managed class for UTF-8 nul-terminated character arrays
* @brief U8String: Native UTF-8 characters array
* @ingroup Internals
* This supports conversion between native UTF-8 nul-terminated characters
* arrays (as used by the native LibVLC) and managed strings.
*/
*/
[
StructLayout
(
LayoutKind
.
Sequential
)]
[
StructLayout
(
LayoutKind
.
Sequential
)]
public
struct
U8String
public
struct
U8String
{
{
public
byte
[]
mb_str
;
public
byte
[]
mb_str
;
/**< nul-terminated UTF-8 bytes array */
/**
* Creates an UTF-8 characters array from a .NET string.
* @param value string to convert
*/
public
U8String
(
string
value
)
public
U8String
(
string
value
)
{
{
mb_str
=
null
;
mb_str
=
null
;
...
@@ -46,7 +53,7 @@ namespace VideoLAN.LibVLC
...
@@ -46,7 +53,7 @@ namespace VideoLAN.LibVLC
mb_str
[
bytes
.
Length
]
=
0
;
mb_str
[
bytes
.
Length
]
=
0
;
}
}
p
ublic
U8String
(
IntPtr
ptr
)
p
rivate
U8String
(
IntPtr
ptr
)
{
{
mb_str
=
null
;
mb_str
=
null
;
if
(
ptr
==
IntPtr
.
Zero
)
if
(
ptr
==
IntPtr
.
Zero
)
...
@@ -61,6 +68,9 @@ namespace VideoLAN.LibVLC
...
@@ -61,6 +68,9 @@ namespace VideoLAN.LibVLC
Marshal
.
Copy
(
ptr
,
mb_str
,
0
,
i
);
Marshal
.
Copy
(
ptr
,
mb_str
,
0
,
i
);
}
}
/**
* Object::ToString.
*/
public
override
string
ToString
()
public
override
string
ToString
()
{
{
if
(
mb_str
==
null
)
if
(
mb_str
==
null
)
...
@@ -72,6 +82,10 @@ namespace VideoLAN.LibVLC
...
@@ -72,6 +82,10 @@ namespace VideoLAN.LibVLC
return
System
.
Text
.
Encoding
.
UTF8
.
GetString
(
bytes
);
return
System
.
Text
.
Encoding
.
UTF8
.
GetString
(
bytes
);
}
}
/**
* Converts a pointer to a nul-terminated UTF-8 characters array into
* a managed string.
*/
public
static
string
FromNative
(
IntPtr
ptr
)
public
static
string
FromNative
(
IntPtr
ptr
)
{
{
return
new
U8String
(
ptr
).
ToString
();
return
new
U8String
(
ptr
).
ToString
();
...
...
bindings/cil/tests/testvlc.cs
View file @
a744c7cf
...
@@ -31,28 +31,20 @@ namespace VideoLAN.LibVLC.Test
...
@@ -31,28 +31,20 @@ namespace VideoLAN.LibVLC.Test
public
static
int
Main
(
string
[]
args
)
public
static
int
Main
(
string
[]
args
)
{
{
string
[]
argv
=
new
string
[]{
string
[]
argv
=
new
string
[]{
"-v
vv
"
,
"-I"
,
"dummy"
,
"--plugin-path=../../modules"
"-v"
,
"-I"
,
"dummy"
,
"--plugin-path=../../modules"
};
};
Instance
vlc
=
VLC
.
CreateInstance
(
argv
);
Console
.
WriteLine
(
"Running on VLC {0} ({1})"
,
VLC
.
Version
,
MediaDescriptor
md
=
vlc
.
CreateDescriptor
(
"/dev/null"
);
VLC
.
ChangeSet
);
md
.
Dispose
(
);
Console
.
WriteLine
(
"Compiled with {0}"
,
VLC
.
Compiler
);
PlaylistItem
item
=
null
;
VLC
vlc
=
new
VLC
(
argv
);
Media
m
=
new
Media
(
vlc
,
"/dev/null"
);
foreach
(
string
s
in
args
)
vlc
.
AddInterface
(
"qt4"
);
item
=
vlc
.
Add
(
s
);
vlc
.
Run
(
);
vlc
.
Loop
=
false
;
m
.
Dispose
();
vlc
.
TogglePause
();
Console
.
ReadLine
();
vlc
.
Stop
();
if
(
item
!=
null
)
vlc
.
Delete
(
item
);
vlc
.
Clear
();
Console
.
ReadLine
();
vlc
.
Dispose
();
vlc
.
Dispose
();
return
0
;
return
0
;
}
}
...
...
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