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
673593dc
Commit
673593dc
authored
Sep 22, 2006
by
Olivier Aubert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mediacontrol API: (mostly) use the new libvlc API
parent
12697ee7
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
233 additions
and
293 deletions
+233
-293
include/mediacontrol_internal.h
include/mediacontrol_internal.h
+26
-4
include/vlc/mediacontrol.h
include/vlc/mediacontrol.h
+6
-2
src/control/mediacontrol_audio_video.c
src/control/mediacontrol_audio_video.c
+71
-82
src/control/mediacontrol_core.c
src/control/mediacontrol_core.c
+130
-84
src/control/mediacontrol_init.c
src/control/mediacontrol_init.c
+0
-103
src/control/mediacontrol_plugin.c
src/control/mediacontrol_plugin.c
+0
-18
No files found.
include/mediacontrol_internal.h
View file @
673593dc
...
...
@@ -29,13 +29,13 @@ extern "C" {
# endif
#include <vlc/vlc.h>
#include "vlc/mediacontrol_structures.h"
#include <vlc/mediacontrol_structures.h>
#include <libvlc_internal.h>
#include <vlc/libvlc.h>
struct
mediacontrol_Instance
{
vlc_object_t
*
p_vlc
;
struct
libvlc_instance_t
*
p_instance
;
playlist_t
*
p_playlist
;
intf_thread_t
*
p_intf
;
int
vlc_object_id
;
};
vlc_int64_t
mediacontrol_unit_convert
(
input_thread_t
*
p_input
,
...
...
@@ -46,6 +46,28 @@ vlc_int64_t mediacontrol_position2microsecond(
input_thread_t
*
p_input
,
const
mediacontrol_Position
*
pos
);
#define RAISE( c, m ) exception->code = c; \
exception->message = strdup(m);
#define RAISE_NULL( c, m ) RAISE( c, m ); return NULL;
#define RAISE_VOID( c, m ) RAISE( c, m ); return;
#define HANDLE_LIBVLC_EXCEPTION_VOID( e ) if( libvlc_exception_raised( e ) ) { \
RAISE( mediacontrol_InternalException, libvlc_exception_get_message( e )); \
libvlc_exception_clear( e ); \
return; }
#define HANDLE_LIBVLC_EXCEPTION_NULL( e ) if( libvlc_exception_raised( e ) ) { \
RAISE( mediacontrol_InternalException, libvlc_exception_get_message( e )); \
libvlc_exception_clear( e ); \
return NULL; }
#define HANDLE_LIBVLC_EXCEPTION_ZERO( e ) if( libvlc_exception_raised( e ) ) { \
RAISE( mediacontrol_InternalException, libvlc_exception_get_message( e )); \
libvlc_exception_clear( e ); \
return 0; }
# ifdef __cplusplus
}
# endif
...
...
include/vlc/mediacontrol.h
View file @
673593dc
...
...
@@ -114,9 +114,13 @@ void mediacontrol_exception_free(mediacontrol_Exception *exception);
mediacontrol_Instance
*
mediacontrol_new
(
char
**
args
,
mediacontrol_Exception
*
exception
);
/* Bridge with the libvlc API */
mediacontrol_Instance
*
mediacontrol_new_from_object
(
int
vlc_object_id
,
mediacontrol_Exception
*
exception
);
mediacontrol_new_from_instance
(
libvlc_instance_t
*
p_instance
,
mediacontrol_Exception
*
exception
);
libvlc_instance_t
*
mediacontrol_get_libvlc_instance
(
mediacontrol_Instance
*
self
);
mediacontrol_Position
*
mediacontrol_get_media_position
(
mediacontrol_Instance
*
self
,
...
...
src/control/mediacontrol_audio_video.c
View file @
673593dc
...
...
@@ -24,6 +24,7 @@
#include <mediacontrol_internal.h>
#include <vlc/mediacontrol.h>
#include <vlc/libvlc.h>
#include <vlc/intf.h>
#include <vlc/vout.h>
...
...
@@ -245,17 +246,16 @@ unsigned short
mediacontrol_sound_get_volume
(
mediacontrol_Instance
*
self
,
mediacontrol_Exception
*
exception
)
{
short
retval
;
audio_volume_t
i_volume
;
libvlc_exception_t
ex
;
int
i_ret
=
0
;
if
(
!
self
->
p_intf
)
{
RAISE
(
mediacontrol_InternalException
,
"No interface module"
);
return
0
;
}
aout_VolumeGet
(
self
->
p_intf
,
&
i_volume
);
retval
=
i_volume
;
return
retval
;
mediacontrol_exception_init
(
exception
);
libvlc_exception_init
(
&
ex
);
i_ret
=
libvlc_audio_get_volume
(
self
->
p_instance
,
&
ex
);
HANDLE_LIBVLC_EXCEPTION_ZERO
(
&
ex
);
/* FIXME: Normalize in [0..100] */
return
(
unsigned
short
)
i_ret
;
}
void
...
...
@@ -263,46 +263,49 @@ mediacontrol_sound_set_volume( mediacontrol_Instance *self,
const
unsigned
short
volume
,
mediacontrol_Exception
*
exception
)
{
if
(
!
self
->
p_intf
)
{
RAISE
(
mediacontrol_InternalException
,
"No interface module"
);
}
else
aout_VolumeSet
(
self
->
p_intf
,(
audio_volume_t
)
volume
);
/* FIXME: Normalize in [0..100] */
libvlc_exception_t
ex
;
mediacontrol_exception_init
(
exception
);
libvlc_exception_init
(
&
ex
);
libvlc_audio_set_volume
(
self
->
p_instance
,
volume
,
&
ex
);
HANDLE_LIBVLC_EXCEPTION_VOID
(
&
ex
);
}
vlc_bool_t
mediacontrol_set_visual
(
mediacontrol_Instance
*
self
,
WINDOWHANDLE
visual_id
,
mediacontrol_Exception
*
exception
)
{
vlc_value_t
value
;
int
ret
;
libvlc_exception_t
ex
;
if
(
!
self
->
p_vlc
)
{
RAISE
(
mediacontrol_InternalException
,
"No vlc reference"
);
return
VLC_FALSE
;
}
value
.
i_int
=
visual_id
;
ret
=
var_Set
(
self
->
p_vlc
,
"drawable"
,
value
);
mediacontrol_exception_init
(
exception
);
libvlc_exception_init
(
&
ex
);
return
(
ret
==
VLC_SUCCESS
);
libvlc_video_set_parent
(
self
->
p_instance
,
visual_id
,
&
ex
);
HANDLE_LIBVLC_EXCEPTION_ZERO
(
&
ex
);
return
VLC_TRUE
;
}
int
mediacontrol_get_rate
(
mediacontrol_Instance
*
self
,
mediacontrol_Exception
*
exception
)
{
int
retval
;
input_thread_t
*
p_input
=
NULL
;
libvlc_exception_t
ex
;
libvlc_input_t
*
p_input
;
int
i_ret
;
mediacontrol_exception_init
(
exception
);
libvlc_exception_init
(
&
ex
);
p_input
=
libvlc_playlist_get_input
(
self
->
p_instance
,
&
ex
);
HANDLE_LIBVLC_EXCEPTION_ZERO
(
&
ex
);
i_ret
=
libvlc_input_get_rate
(
p_input
,
&
ex
);
libvlc_input_free
(
p_input
);
HANDLE_LIBVLC_EXCEPTION_ZERO
(
&
ex
);
p_input
=
self
->
p_playlist
->
p_input
;
if
(
!
p_input
)
{
RAISE
(
mediacontrol_InternalException
,
"No input"
);
return
0
;
}
retval
=
var_GetInteger
(
p_input
,
"rate"
)
/
10
;
return
retval
;
return
i_ret
/
10
;
}
void
...
...
@@ -310,42 +313,39 @@ mediacontrol_set_rate( mediacontrol_Instance *self,
const
int
rate
,
mediacontrol_Exception
*
exception
)
{
input_thread_t
*
p_input
=
NULL
;
libvlc_exception_t
ex
;
libvlc_input_t
*
p_input
;
mediacontrol_exception_init
(
exception
);
libvlc_exception_init
(
&
ex
);
p_input
=
self
->
p_playlist
->
p_input
;
if
(
!
p_input
)
{
RAISE
(
mediacontrol_InternalException
,
"No input"
);
return
;
}
var_SetInteger
(
p_input
,
"rate"
,
rate
*
10
);
return
;
p_input
=
libvlc_playlist_get_input
(
self
->
p_instance
,
&
ex
);
HANDLE_LIBVLC_EXCEPTION_VOID
(
&
ex
);
libvlc_input_set_rate
(
p_input
,
rate
*
10
,
&
ex
);
libvlc_input_free
(
p_input
);
HANDLE_LIBVLC_EXCEPTION_VOID
(
&
ex
);
}
int
mediacontrol_get_fullscreen
(
mediacontrol_Instance
*
self
,
mediacontrol_Exception
*
exception
)
{
vout_thread_t
*
p_vout
=
NULL
;
vlc_value_t
val
;
libvlc_exception_t
ex
;
libvlc_input_t
*
p_input
;
int
i_ret
;
p_vout
=
vlc_object_find
(
self
->
p_playlist
,
VLC_OBJECT_VOUT
,
FIND_CHILD
);
if
(
!
p_vout
)
{
RAISE
(
mediacontrol_InternalException
,
"no video output"
);
return
0
;
}
i_ret
=
var_Get
(
p_vout
,
"fullscreen"
,
&
val
);
vlc_object_release
(
p_vout
);
if
(
i_ret
)
{
RAISE
(
mediacontrol_InternalException
,
"Unexpected error while looking up fullscreen value"
);
return
0
;
}
return
val
.
b_bool
==
VLC_TRUE
?
1
:
0
;
mediacontrol_exception_init
(
exception
);
libvlc_exception_init
(
&
ex
);
p_input
=
libvlc_playlist_get_input
(
self
->
p_instance
,
&
ex
);
HANDLE_LIBVLC_EXCEPTION_ZERO
(
&
ex
);
i_ret
=
libvlc_get_fullscreen
(
p_input
,
&
ex
);
libvlc_input_free
(
p_input
);
HANDLE_LIBVLC_EXCEPTION_ZERO
(
&
ex
);
return
i_ret
;
}
void
...
...
@@ -353,27 +353,16 @@ mediacontrol_set_fullscreen( mediacontrol_Instance *self,
const
int
b_fullscreen
,
mediacontrol_Exception
*
exception
)
{
vout_thread_t
*
p_vout
=
NULL
;
vlc_value_t
val
;
int
i_ret
;
p_vout
=
vlc_object_find
(
self
->
p_playlist
,
VLC_OBJECT_VOUT
,
FIND_CHILD
);
if
(
!
p_vout
)
{
RAISE
(
mediacontrol_InternalException
,
"no video output"
);
return
;
}
libvlc_exception_t
ex
;
libvlc_input_t
*
p_input
;
if
(
b_fullscreen
)
val
.
b_bool
=
VLC_TRUE
;
else
val
.
b_bool
=
VLC_FALSE
;
mediacontrol_exception_init
(
exception
)
;
libvlc_exception_init
(
&
ex
)
;
i_ret
=
var_Set
(
p_vout
,
"fullscreen"
,
val
);
vlc_object_release
(
p_vout
);
p_input
=
libvlc_playlist_get_input
(
self
->
p_instance
,
&
ex
);
HANDLE_LIBVLC_EXCEPTION_VOID
(
&
ex
);
if
(
i_ret
)
{
RAISE
(
mediacontrol_InternalException
,
"Unexpected error while setting fullscreen value"
);
return
;
}
return
;
libvlc_set_fullscreen
(
p_input
,
b_fullscreen
,
&
ex
);
libvlc_input_free
(
p_input
);
HANDLE_LIBVLC_EXCEPTION_VOID
(
&
ex
);
}
src/control/mediacontrol_core.c
View file @
673593dc
...
...
@@ -24,6 +24,7 @@
#include <mediacontrol_internal.h>
#include <vlc/mediacontrol.h>
#include <vlc/libvlc.h>
#include <vlc/intf.h>
#include <vlc/vout.h>
#include <vlc/aout.h>
...
...
@@ -54,46 +55,84 @@
# include <sys/types.h>
#endif
#define RAISE( c, m ) exception->code = c; \
exception->message = strdup(m);
mediacontrol_Instance
*
mediacontrol_new_from_object
(
int
vlc_object_id
,
mediacontrol_Exception
*
exception
)
mediacontrol_Instance
*
mediacontrol_new
(
char
**
args
,
mediacontrol_Exception
*
exception
)
{
mediacontrol_Instance
*
retval
=
NULL
;
vlc_object_t
*
p_vlc
;
vlc_object_t
*
p_object
;
mediacontrol_Instance
*
retval
;
libvlc_exception_t
ex
;
char
**
ppsz_argv
;
int
i_count
=
0
;
int
i_index
;
char
**
p_tmp
;
p_object
=
(
vlc_object_t
*
)
vlc_current_object
(
vlc_object_id
);
if
(
!
p_object
)
libvlc_exception_init
(
&
ex
);
exception
=
mediacontrol_exception_init
(
exception
);
/* Copy args array */
if
(
args
)
{
RAISE
(
mediacontrol_InternalException
,
"unable to find vlc object"
);
return
NULL
;
for
(
p_tmp
=
args
;
*
p_tmp
!=
NULL
;
p_tmp
++
)
i_count
++
;
}
p
_vlc
=
vlc_object_find
(
p_object
,
VLC_OBJECT_ROOT
,
FIND_PARENT
)
;
if
(
!
p
_vlc
)
p
psz_argv
=
malloc
(
(
i_count
+
2
)
*
sizeof
(
char
*
)
)
;
if
(
!
p
psz_argv
)
{
RAISE
(
mediacontrol_InternalException
,
"unable to initialize VLC"
);
return
NULL
;
RAISE_NULL
(
mediacontrol_InternalException
,
"out of memory"
);
}
ppsz_argv
[
0
]
=
"vlc"
;
for
(
i_index
=
0
;
i_index
<
i_count
;
i_index
++
)
{
ppsz_argv
[
i_index
+
1
]
=
strdup
(
args
[
i_index
]
);
if
(
!
ppsz_argv
[
i_index
+
1
]
)
{
RAISE_NULL
(
mediacontrol_InternalException
,
"out of memory"
);
}
}
retval
=
(
mediacontrol_Instance
*
)
malloc
(
sizeof
(
mediacontrol_Instance
)
);
retval
->
p_vlc
=
p_vlc
;
retval
->
vlc_object_id
=
p_vlc
->
i_object_id
;
/* We can keep references on these, which should not change. Is it true ? */
retval
->
p_playlist
=
vlc_object_find
(
p_vlc
,
VLC_OBJECT_PLAYLIST
,
FIND_ANYWHERE
);
retval
->
p_intf
=
vlc_object_find
(
p_vlc
,
VLC_OBJECT_INTF
,
FIND_ANYWHERE
);
ppsz_argv
[
i_count
+
2
]
=
NULL
;
if
(
!
retval
->
p_playlist
||
!
retval
->
p_intf
)
{
RAISE
(
mediacontrol_InternalException
,
"no interface available"
);
return
NULL
;
retval
=
(
mediacontrol_Instance
*
)
malloc
(
sizeof
(
mediacontrol_Instance
)
);
if
(
!
retval
)
{
RAISE_NULL
(
mediacontrol_InternalException
,
"out of memory"
)
;
}
return
retval
;
retval
->
p_instance
=
libvlc_new
(
i_count
+
1
,
ppsz_argv
,
&
ex
);
retval
->
p_playlist
=
retval
->
p_instance
->
p_libvlc_int
->
p_playlist
;
HANDLE_LIBVLC_EXCEPTION_NULL
(
&
ex
);
return
retval
;
};
void
mediacontrol_exit
(
mediacontrol_Instance
*
self
)
{
libvlc_exception_t
ex
;
libvlc_exception_init
(
&
ex
);
libvlc_destroy
(
self
->
p_instance
,
&
ex
);
}
libvlc_instance_t
*
mediacontrol_get_libvlc_instance
(
mediacontrol_Instance
*
self
)
{
return
self
->
p_instance
;
}
mediacontrol_Instance
*
mediacontrol_new_from_instance
(
libvlc_instance_t
*
p_instance
,
mediacontrol_Exception
*
exception
)
{
mediacontrol_Instance
*
retval
;
retval
=
(
mediacontrol_Instance
*
)
malloc
(
sizeof
(
mediacontrol_Instance
)
);
if
(
!
retval
)
{
RAISE_NULL
(
mediacontrol_InternalException
,
"out of memory"
);
}
retval
->
p_instance
=
p_instance
;
retval
->
p_playlist
=
retval
->
p_instance
->
p_libvlc_int
->
p_playlist
;
return
retval
;
}
/**************************************************************************
* Playback management
...
...
@@ -105,38 +144,49 @@ mediacontrol_get_media_position( mediacontrol_Instance *self,
mediacontrol_Exception
*
exception
)
{
mediacontrol_Position
*
retval
=
NULL
;
vlc_value_t
val
;
input_thread_t
*
p_input
=
self
->
p_playlist
->
p_input
;
libvlc_exception_t
ex
;
vlc_int64_t
pos
;
libvlc_input_t
*
p_input
;
exception
=
mediacontrol_exception_init
(
exception
);
libvlc_exception_init
(
&
ex
);
retval
=
(
mediacontrol_Position
*
)
malloc
(
sizeof
(
mediacontrol_Position
)
);
retval
->
origin
=
an_origin
;
retval
->
key
=
a_key
;
if
(
!
p_input
)
{
RAISE
(
mediacontrol_InternalException
,
"No input thread."
);
return
NULL
;
}
p_input
=
libvlc_playlist_get_input
(
self
->
p_instance
,
&
ex
);
HANDLE_LIBVLC_EXCEPTION_NULL
(
&
ex
);
if
(
an_origin
!=
mediacontrol_AbsolutePosition
)
{
libvlc_input_free
(
p_input
);
/* Relative or ModuloPosition make no sense */
RAISE
(
mediacontrol_PositionOriginNotSupported
,
"Only absolute position is valid."
);
return
NULL
;
RAISE_NULL
(
mediacontrol_PositionOriginNotSupported
,
"Only absolute position is valid."
);
}
/* We are asked for an AbsolutePosition. */
val
.
i_time
=
0
;
var_Get
(
p_input
,
"time"
,
&
val
);
/* FIXME: check val.i_time > 0 */
retval
->
value
=
mediacontrol_unit_convert
(
p_input
,
mediacontrol_MediaTime
,
a_key
,
val
.
i_time
/
1000
);
pos
=
libvlc_input_get_time
(
p_input
,
&
ex
);
if
(
a_key
==
mediacontrol_MediaTime
)
{
retval
->
value
=
pos
/
1000
;
}
else
{
if
(
!
self
->
p_playlist
->
p_input
)
{
libvlc_input_free
(
p_input
);
RAISE_NULL
(
mediacontrol_InternalException
,
"No input"
);
}
retval
->
value
=
mediacontrol_unit_convert
(
self
->
p_playlist
->
p_input
,
mediacontrol_MediaTime
,
a_key
,
pos
/
1000
);
}
libvlc_input_free
(
p_input
);
return
retval
;
}
...
...
@@ -146,23 +196,20 @@ mediacontrol_set_media_position( mediacontrol_Instance *self,
const
mediacontrol_Position
*
a_position
,
mediacontrol_Exception
*
exception
)
{
vlc_value_t
val
;
input_thread_t
*
p_input
=
self
->
p_playlist
->
p_input
;
libvlc_input_t
*
p_input
;
libvlc_exception_t
ex
;
vlc_int64_t
i_pos
;
exception
=
mediacontrol_exception_init
(
exception
);
if
(
!
p_input
)
{
RAISE
(
mediacontrol_InternalException
,
"No input thread."
);
}
else
if
(
!
var_GetBool
(
p_input
,
"seekable"
)
)
{
RAISE
(
mediacontrol_InvalidPosition
,
"Stream not seekable"
);
}
else
{
val
.
i_time
=
mediacontrol_position2microsecond
(
p_input
,
a_position
);
var_Set
(
p_input
,
"time"
,
val
);
}
libvlc_exception_init
(
&
ex
);
mediacontrol_exception_init
(
exception
);
p_input
=
libvlc_playlist_get_input
(
self
->
p_instance
,
&
ex
);
HANDLE_LIBVLC_EXCEPTION_VOID
(
&
ex
);
i_pos
=
mediacontrol_position2microsecond
(
self
->
p_playlist
->
p_input
,
a_position
);
libvlc_input_set_time
(
p_input
,
i_pos
,
&
ex
);
libvlc_input_free
(
p_input
);
HANDLE_LIBVLC_EXCEPTION_VOID
(
&
ex
);
}
/* Starts playing a stream */
...
...
@@ -278,40 +325,39 @@ mediacontrol_playlist_add_item( mediacontrol_Instance *self,
const
char
*
psz_file
,
mediacontrol_Exception
*
exception
)
{
exception
=
mediacontrol_exception_init
(
exception
);
if
(
!
self
->
p_playlist
)
{
RAISE
(
mediacontrol_InternalException
,
"No playlist"
);
}
else
playlist_PlaylistAdd
(
self
->
p_playlist
,
psz_file
,
psz_file
,
PLAYLIST_INSERT
,
PLAYLIST_END
);
libvlc_exception_t
ex
;
mediacontrol_exception_init
(
exception
);
libvlc_exception_init
(
&
ex
);
libvlc_playlist_add
(
self
->
p_instance
,
psz_file
,
psz_file
,
&
ex
);
HANDLE_LIBVLC_EXCEPTION_VOID
(
&
ex
);
}
void
mediacontrol_playlist_next_item
(
mediacontrol_Instance
*
self
,
mediacontrol_Exception
*
exception
)
{
exception
=
mediacontrol_exception_init
(
exception
)
;
if
(
!
self
->
p_playlist
)
{
RAISE
(
mediacontrol_InternalException
,
"No playlist"
);
}
else
playlist_Next
(
self
->
p_playlist
);
libvlc_exception_t
ex
;
mediacontrol_exception_init
(
exception
);
libvlc_exception_init
(
&
ex
);
libvlc_playlist_next
(
self
->
p_instance
,
&
ex
);
HANDLE_LIBVLC_EXCEPTION_VOID
(
&
ex
);
}
void
mediacontrol_playlist_clear
(
mediacontrol_Instance
*
self
,
mediacontrol_Exception
*
exception
)
{
exception
=
mediacontrol_exception_init
(
exception
)
;
if
(
!
self
->
p_playlist
)
{
RAISE
(
mediacontrol_PlaylistException
,
"No playlist"
);
}
else
playlist_Clear
(
self
->
p_playlist
);
libvlc_exception_t
ex
;
mediacontrol_exception_init
(
exception
);
libvlc_exception_init
(
&
ex
);
libvlc_playlist_clear
(
self
->
p_instance
,
&
ex
);
HANDLE_LIBVLC_EXCEPTION_VOID
(
&
ex
);
}
mediacontrol_PlaylistSeq
*
...
...
src/control/mediacontrol_init.c
deleted
100644 → 0
View file @
12697ee7
#define __VLC__
#include <mediacontrol_internal.h>
#include <vlc/mediacontrol.h>
mediacontrol_Instance
*
mediacontrol_new
(
char
**
args
,
mediacontrol_Exception
*
exception
)
{
mediacontrol_Instance
*
retval
;
vlc_object_t
*
p_vlc
;
int
p_vlc_id
;
char
**
ppsz_argv
;
int
i_count
=
0
;
int
i_index
;
char
**
p_tmp
;
if
(
args
)
{
for
(
p_tmp
=
args
;
*
p_tmp
!=
NULL
;
p_tmp
++
)
i_count
++
;
}
ppsz_argv
=
malloc
(
(
i_count
+
2
)
*
sizeof
(
char
*
)
)
;
if
(
!
ppsz_argv
)
{
exception
->
code
=
mediacontrol_InternalException
;
exception
->
message
=
"out of memory"
;
return
NULL
;
}
ppsz_argv
[
0
]
=
"vlc"
;
for
(
i_index
=
0
;
i_index
<
i_count
;
i_index
++
)
{
ppsz_argv
[
i_index
+
1
]
=
strdup
(
args
[
i_index
]
);
if
(
!
ppsz_argv
[
i_index
+
1
]
)
{
exception
->
code
=
mediacontrol_InternalException
;
exception
->
message
=
"out of memory"
;
return
NULL
;
}
}
ppsz_argv
[
i_count
+
1
]
=
NULL
;
p_vlc_id
=
VLC_Create
();
if
(
p_vlc_id
<
0
)
{
exception
->
code
=
mediacontrol_InternalException
;
exception
->
message
=
strdup
(
"unable to create VLC"
);
return
NULL
;
}
p_vlc
=
(
vlc_object_t
*
)
vlc_current_object
(
p_vlc_id
);
if
(
!
p_vlc
)
{
exception
->
code
=
mediacontrol_InternalException
;
exception
->
message
=
strdup
(
"unable to find VLC object"
);
return
NULL
;
}
retval
=
(
mediacontrol_Instance
*
)
malloc
(
sizeof
(
mediacontrol_Instance
)
);
if
(
!
retval
)
{
exception
->
code
=
mediacontrol_InternalException
;
exception
->
message
=
strdup
(
"out of memory"
);
return
NULL
;
}
if
(
VLC_Init
(
p_vlc_id
,
i_count
+
1
,
ppsz_argv
)
!=
VLC_SUCCESS
)
{
exception
->
code
=
mediacontrol_InternalException
;
exception
->
message
=
strdup
(
"cannot initialize VLC"
);
return
NULL
;
}
retval
->
p_libvlc
=
p_vlc
;
retval
->
vlc_object_id
=
p_vlc_id
;
/* We can keep references on these, which should not change. Is it true ? */
retval
->
p_playlist
=
vlc_object_find
(
p_vlc
,
VLC_OBJECT_PLAYLIST
,
FIND_ANYWHERE
);
retval
->
p_intf
=
vlc_object_find
(
p_vlc
,
VLC_OBJECT_INTF
,
FIND_ANYWHERE
);
if
(
!
retval
->
p_playlist
||
!
retval
->
p_intf
)
{
exception
->
code
=
mediacontrol_InternalException
;
exception
->
message
=
strdup
(
"no interface available"
);
return
NULL
;
}
return
retval
;
};
void
mediacontrol_exit
(
mediacontrol_Instance
*
self
)
{
vlc_object_release
(
(
vlc_object_t
*
)
self
->
p_playlist
);
vlc_object_release
(
(
vlc_object_t
*
)
self
->
p_intf
);
vlc_object_release
(
(
vlc_object_t
*
)
self
->
p_libvlc
);
VLC_CleanUp
(
self
->
vlc_object_id
);
VLC_Destroy
(
self
->
vlc_object_id
);
}
src/control/mediacontrol_plugin.c
deleted
100644 → 0
View file @
12697ee7
#include <mediacontrol_internal.h>
#include <vlc/mediacontrol.h>
#include <vlc/intf.h>
mediacontrol_Instance
*
mediacontrol_new
(
char
**
args
,
mediacontrol_Exception
*
exception
)
{
exception
->
code
=
mediacontrol_InternalException
;
exception
->
message
=
strdup
(
"The mediacontrol extension was compiled for plugin usage only."
);
return
NULL
;
};
void
mediacontrol_exit
(
mediacontrol_Instance
*
self
)
{
vlc_mutex_lock
(
&
self
->
p_intf
->
change_lock
);
self
->
p_intf
->
b_die
=
1
;
vlc_mutex_unlock
(
&
self
->
p_intf
->
change_lock
);
}
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