Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
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
Commits
b93beb4c
Commit
b93beb4c
authored
Feb 21, 2009
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup instance and media class
parent
e876396a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
237 additions
and
152 deletions
+237
-152
bindings/cil/src/Makefile.am
bindings/cil/src/Makefile.am
+1
-0
bindings/cil/src/instance.cs
bindings/cil/src/instance.cs
+148
-0
bindings/cil/src/libvlc.cs
bindings/cil/src/libvlc.cs
+84
-127
bindings/cil/src/media.cs
bindings/cil/src/media.cs
+4
-25
No files found.
bindings/cil/src/Makefile.am
View file @
b93beb4c
...
...
@@ -7,6 +7,7 @@ SOURCES_dll = \
ustring.cs
\
exception.cs
\
marshal.cs
\
instance.cs
\
media.cs
\
player.cs
\
libvlc.cs
...
...
bindings/cil/src/instance.cs
0 → 100644
View file @
b93beb4c
/**
* @file instance.cs
* @brief Bindings to LibVLC for the .NET Common Intermediate Language
* @ingroup API
*
* @defgroup API Managed interface to LibVLC
* This is the primary class library for .NET applications
* to embed and control LibVLC.
*/
/**********************************************************************
* 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.Runtime.InteropServices
;
namespace
VideoLAN.LibVLC
{
/**
* @brief InstanceHandle: unmanaged LibVLC instance pointer
* @ingroup Internals
*/
internal
sealed
class
InstanceHandle
:
NonNullHandle
{
protected
override
void
Destroy
()
{
LibVLC
.
Release
(
handle
,
null
);
}
};
/**
* @brief VLC: VLC media player instance
* @ingroup API
*
* The VLC class provides represent a run-time instance of a media player.
* An instance can spawn multiple independent medias, however
* configuration settings, message logging, etc are common to all medias
* from the same instance.
*/
public
class
VLC
:
BaseObject
{
internal
InstanceHandle
Handle
{
get
{
return
handle
as
InstanceHandle
;
}
}
/**
* Loads the native LibVLC and creates a LibVLC instance.
*
* @param args VLC command line parameters for the LibVLC Instance.
*/
public
VLC
(
string
[]
args
)
{
U8String
[]
argv
=
new
U8String
[
args
.
Length
];
for
(
int
i
=
0
;
i
<
args
.
Length
;
i
++)
argv
[
i
]
=
new
U8String
(
args
[
i
]);
handle
=
LibVLC
.
Create
(
argv
.
Length
,
argv
,
ex
);
Raise
();
}
/**
* Starts a VLC interface plugin.
*
* @param name name of the interface plugin (e.g. "http", "qt4", ...)
*/
public
void
AddInterface
(
string
name
)
{
U8String
uname
=
new
U8String
(
name
);
LibVLC
.
AddIntf
(
Handle
,
uname
,
ex
);
Raise
();
}
/**
* Waits until VLC instance exits. This can happen if a fatal error
* occurs (e.g. cannot parse the arguments), if the user has quit
* through an interface, or if the special vlc://quit item was played.
*/
public
void
Run
()
{
LibVLC
.
Wait
(
Handle
);
}
/**
* The human-readable LibVLC version number.
*/
public
static
string
Version
{
get
{
return
U8String
.
FromNative
(
LibVLC
.
GetVersion
());
}
}
/**
* The human-readable LibVLC C compiler infos.
*/
public
static
string
Compiler
{
get
{
return
U8String
.
FromNative
(
LibVLC
.
GetCompiler
());
}
}
/**
* The unique commit identifier from the LibVLC source control system,
* or "exported" if unknown.
*/
public
static
string
ChangeSet
{
get
{
return
U8String
.
FromNative
(
LibVLC
.
GetChangeset
());
}
}
/**
* The unmanaged VLC-internal instance object.
* Do not use this unless you really know what you are doing.
*/
public
SafeHandle
Object
{
get
{
return
LibVLC
.
GetVLCInstance
(
Handle
);
}
}
};
};
bindings/cil/src/libvlc.cs
View file @
b93beb4c
/**
* @file libvlc.cs
* @brief Bindings to LibVLC for the .NET Common Intermediate Language
* @ingroup API
*
* @defgroup API Managed interface to LibVLC
* This is the primary class library for .NET applications
* to embed and control LibVLC.
* @brief Unmanaged LibVLC APIs
* @ingroup Internals
*
* @defgroup Internals LibVLC internals
* This covers internal marshalling functions to use the native LibVLC.
...
...
@@ -35,11 +31,12 @@ using System.Runtime.InteropServices;
namespace
VideoLAN.LibVLC
{
/**
* @brief
InstanceHandle: unmanaged LibVLC instance pointer
* @brief
Native: unmanaged LibVLC APIs
* @ingroup Internals
*/
internal
s
ealed
class
InstanceHandle
:
NonNullHandle
internal
s
tatic
class
LibVLC
{
/* core.c */
[
DllImport
(
"libvlc.dll"
,
EntryPoint
=
"libvlc_get_version"
)]
public
static
extern
IntPtr
GetVersion
();
...
...
@@ -47,139 +44,99 @@ namespace VideoLAN.LibVLC
public
static
extern
IntPtr
GetCompiler
();
[
DllImport
(
"libvlc.dll"
,
EntryPoint
=
"libvlc_get_changeset"
)]
public
static
extern
IntPtr
GetChange
S
et
();
public
static
extern
IntPtr
GetChange
s
et
();
[
DllImport
(
"libvlc.dll"
,
EntryPoint
=
"libvlc_new"
)]
public
static
extern
InstanceHandle
Create
(
int
argc
,
U8String
[]
argv
,
NativeException
ex
);
InstanceHandle
Create
(
int
argc
,
U8String
[]
argv
,
NativeException
ex
);
/*[DllImport ("libvlc.dll", EntryPoint="libvlc_retain")]
public static extern
void Hold (InstanceHandle h,
NativeException ex);*/
public static extern
void Retain (InstanceHandle h,
NativeException ex);*/
[
DllImport
(
"libvlc.dll"
,
EntryPoint
=
"libvlc_release"
)]
p
rivate
static
extern
void
Release
(
IntPtr
h
,
NativeException
ex
);
p
ublic
static
extern
void
Release
(
IntPtr
h
,
NativeException
ex
);
[
DllImport
(
"libvlc.dll"
,
EntryPoint
=
"libvlc_add_intf"
)]
public
static
extern
void
AddInterface
(
InstanceHandle
h
,
U8String
name
,
NativeException
ex
);
public
static
extern
void
AddIntf
(
InstanceHandle
h
,
U8String
name
,
NativeException
ex
);
[
DllImport
(
"libvlc.dll"
,
EntryPoint
=
"libvlc_wait"
)]
public
static
extern
void
Run
(
InstanceHandle
h
);
public
static
extern
void
Wait
(
InstanceHandle
h
);
[
DllImport
(
"libvlc.dll"
,
EntryPoint
=
"libvlc_get_vlc_instance"
)]
public
static
extern
NonNullHandle
GetVLC
(
InstanceHandle
h
);
public
static
extern
SafeHandle
GetVLCInstance
(
InstanceHandle
h
);
protected
override
void
Destroy
()
{
Release
(
handle
,
null
);
}
}
;
/* media.c */
[
DllImport
(
"libvlc.dll"
,
EntryPoint
=
"libvlc_media_new"
)]
public
static
extern
MediaHandle
MediaCreate
(
InstanceHandle
inst
,
U8String
mrl
,
NativeException
ex
)
;
/**
* @brief VLC: VLC media player instance
* @ingroup API
*
* The VLC class provides represent a run-time instance of a media player.
* An instance can spawn multiple independent medias, however
* configuration settings, message logging, etc are common to all medias
* from the same instance.
*/
public
class
VLC
:
BaseObject
{
internal
InstanceHandle
Handle
{
get
{
return
handle
as
InstanceHandle
;
}
}
/**
* Loads the native LibVLC and creates a LibVLC instance.
*
* @param args VLC command line parameters for the LibVLC Instance.
*/
public
VLC
(
string
[]
args
)
{
U8String
[]
argv
=
new
U8String
[
args
.
Length
];
for
(
int
i
=
0
;
i
<
args
.
Length
;
i
++)
argv
[
i
]
=
new
U8String
(
args
[
i
]);
handle
=
InstanceHandle
.
Create
(
argv
.
Length
,
argv
,
ex
);
Raise
();
}
/**
* Starts a VLC interface plugin.
*
* @param name name of the interface plugin (e.g. "http", "qt4", ...)
*/
public
void
AddInterface
(
string
name
)
{
U8String
uname
=
new
U8String
(
name
);
InstanceHandle
.
AddInterface
(
Handle
,
uname
,
ex
);
Raise
();
}
/**
* Waits until VLC instance exits. This can happen if a fatal error
* occurs (e.g. cannot parse the arguments), if the user has quit
* through an interface, or if the special vlc://quit item was played.
*/
public
void
Run
()
{
InstanceHandle
.
Run
(
Handle
);
}
/**
* The human-readable LibVLC version number.
*/
public
static
string
Version
{
get
{
return
U8String
.
FromNative
(
InstanceHandle
.
GetVersion
());
}
}
/**
* The human-readable LibVLC C compiler infos.
*/
public
static
string
Compiler
{
get
{
return
U8String
.
FromNative
(
InstanceHandle
.
GetCompiler
());
}
}
/**
* The unique commit identifier from the LibVLC source control system,
* or "exported" if unknown.
*/
public
static
string
ChangeSet
{
get
{
return
U8String
.
FromNative
(
InstanceHandle
.
GetChangeSet
());
}
}
/**
* The unmanaged VLC-internal instance object.
* Do not use this unless you really know what you are doing.
*/
public
SafeHandle
Object
{
get
{
return
InstanceHandle
.
GetVLC
(
Handle
);
}
}
[
DllImport
(
"libvlc.dll"
,
EntryPoint
=
"libvlc_media_new_as_node"
)]
public
static
extern
MediaHandle
MediaCreateAsNode
(
InstanceHandle
inst
,
U8String
name
,
NativeException
ex
);
[
DllImport
(
"libvlc.dll"
,
EntryPoint
=
"libvlc_media_add_option"
)]
public
static
extern
void
MediaAddOption
(
MediaHandle
media
,
U8String
options
,
NativeException
ex
);
[
DllImport
(
"libvlc.dll"
,
EntryPoint
=
"libvlc_media_add_option_untrusted"
)]
public
static
extern
void
MediaAddUntrustedOption
(
MediaHandle
media
,
U8String
options
,
NativeException
ex
);
[
DllImport
(
"libvlc.dll"
,
EntryPoint
=
"libvlc_media_release"
)]
public
static
extern
void
MediaRelease
(
IntPtr
ptr
);
[
DllImport
(
"libvlc.dll"
,
EntryPoint
=
"libvlc_media_get_mrl"
)]
public
static
extern
void
MediaGetMRL
(
MediaHandle
media
);
[
DllImport
(
"libvlc.dll"
,
EntryPoint
=
"libvlc_media_duplicate"
)]
public
static
extern
MediaHandle
MediaDuplicate
(
MediaHandle
media
);
/*[DllImport ("libvlc.dll", EntryPoint="libvlc_media_read_meta")]
public static extern
MediaHandle MediaDuplicate (MediaHandle media, int type,
NativeException ex);*/
/*[DllImport ("libvlc.dll", EntryPoint="libvlc_media_get_state")]
public static extern
int MediaGetState (MediaHandle media, NativeException ex);*/
/*[DllImport ("libvlc.dll", EntryPoint="libvlc_media_subitems")]
public static extern
MediaListHandle MediaSubItems (MediaHandle media, NativeException ex);*/
/*[DllImport ("libvlc.dll", EntryPoint="libvlc_media_get_state")]
public static extern
EventManagerHandle MediaGetEventManager (MediaHandle media,
NativeException ex);*/
[
DllImport
(
"libvlc.dll"
,
EntryPoint
=
"libvlc_media_get_duration"
)]
public
static
extern
long
MediaGetDuration
(
MediaHandle
media
,
NativeException
ex
);
[
DllImport
(
"libvlc.dll"
,
EntryPoint
=
"libvlc_media_is_preparsed"
)]
public
static
extern
int
MediaIsPreparsed
(
MediaHandle
media
,
NativeException
ex
);
/*[DllImport ("libvlc.dll", EntryPoint="libvlc_media_set_user_data")]
public static extern
void MediaIsPreparsed (MediaHandle media, IntPtr data,
NativeException ex);*/
/*[DllImport ("libvlc.dll", EntryPoint="libvlc_media_get_user_data")]
public static extern
IntPtr MediaIsPreparsed (MediaHandle media, NativeException ex);*/
};
};
bindings/cil/src/media.cs
View file @
b93beb4c
...
...
@@ -33,30 +33,9 @@ namespace VideoLAN.LibVLC
*/
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
);
LibVLC
.
Media
Release
(
handle
);
}
};
...
...
@@ -84,7 +63,7 @@ namespace VideoLAN.LibVLC
{
U8String
umrl
=
new
U8String
(
mrl
);
handle
=
MediaHandle
.
Create
(
instance
.
Handle
,
umrl
,
ex
);
handle
=
LibVLC
.
Media
Create
(
instance
.
Handle
,
umrl
,
ex
);
Raise
();
}
...
...
@@ -93,9 +72,9 @@ namespace VideoLAN.LibVLC
U8String
uopts
=
new
U8String
(
options
);
if
(
trusted
)
MediaHandle
.
AddOption
(
Handle
,
uopts
,
ex
);
LibVLC
.
Media
AddOption
(
Handle
,
uopts
,
ex
);
else
MediaHandle
.
AddUntrustedOption
(
Handle
,
uopts
,
ex
);
LibVLC
.
Media
AddUntrustedOption
(
Handle
,
uopts
,
ex
);
Raise
();
}
};
...
...
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