Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
VideoLAN
VLMC
Commits
62d32a70
Commit
62d32a70
authored
Mar 21, 2009
by
Hugo Beauzee-Luyssen
Browse files
More C++ binding
parent
71696db1
Changes
8
Hide whitespace changes
Inline
Side-by-side
src/LibVLCpp/VLCMedia.cpp
0 → 100644
View file @
62d32a70
#include
<cassert>
#include
"VLCMedia.h"
using
namespace
LibVLCpp
;
Media
::
Media
(
Instance
*
instance
,
const
QString
&
filename
)
:
_instance
(
*
instance
)
{
this
->
_internalPtr
=
libvlc_media_new
(
this
->
_instance
,
filename
.
toLocal8Bit
(),
this
->
_ex
);
this
->
_ex
.
checkThrow
();
}
Media
::~
Media
()
{
libvlc_media_release
(
this
->
_internalPtr
);
}
Media
::
DataCtx
*
Media
::
buildDataCtx
()
{
Media
::
DataCtx
*
dataCtx
=
new
Media
::
DataCtx
;
dataCtx
->
mutex
=
new
QMutex
();
dataCtx
->
pixelBuffer
=
new
uchar
[
VIDEOHEIGHT
*
VIDEOWIDTH
*
4
];
return
dataCtx
;
}
void
Media
::
addOption
(
const
char
*
opt
)
{
libvlc_media_add_option
(
this
->
_internalPtr
,
opt
,
this
->
_ex
);
this
->
_ex
.
checkThrow
();
}
Media
::
DataCtx
::~
DataCtx
()
{
delete
[]
this
->
pixelBuffer
;
delete
this
->
mutex
;
}
void
Media
::
setLockCallback
(
Media
::
lockCallback
callback
)
{
char
param
[
64
];
sprintf
(
param
,
":vmem-lock=%lld"
,
(
long
long
int
)(
intptr_t
)
callback
);
this
->
addOption
(
param
);
}
void
Media
::
setUnlockCallback
(
Media
::
unlockCallback
callback
)
{
char
param
[
64
];
sprintf
(
param
,
":vmem-unlock=%lld"
,
(
long
long
int
)(
intptr_t
)
callback
);
this
->
addOption
(
param
);
}
void
Media
::
setDataCtx
(
Media
::
DataCtx
*
dataCtx
)
{
char
param
[
64
];
sprintf
(
param
,
":vmem-data=%lld"
,
(
long
long
int
)(
intptr_t
)
dataCtx
);
this
->
addOption
(
param
);
}
void
Media
::
outputInVmem
()
{
this
->
addOption
(
":vout=vmem"
);
}
void
Media
::
outputInWindow
()
{
// this->addOption();
}
src/LibVLCpp/VLCMedia.h
0 → 100644
View file @
62d32a70
#ifndef VLCMEDIA_H
#define VLCMEDIA_H
#include
"vlc/vlc.h"
#include
<QString>
#include
<QMutex>
#include
"VLCpp.hpp"
#include
"VLCException.h"
#include
"VLCInstance.h"
#define VIDEOWIDTH 854
#define VIDEOHEIGHT 480
namespace
LibVLCpp
{
class
Media
:
public
Internal
<
libvlc_media_t
>
{
public:
struct
DataCtx
{
~
DataCtx
();
uchar
*
pixelBuffer
;
QMutex
*
mutex
;
};
typedef
void
(
*
lockCallback
)(
Media
::
DataCtx
*
dataCtx
,
void
**
pp_ret
);
typedef
void
(
*
unlockCallback
)(
Media
::
DataCtx
*
dataCtx
);
Media
(
Instance
*
instance
,
const
QString
&
filename
);
~
Media
();
void
addOption
(
const
char
*
opt
);
void
setLockCallback
(
Media
::
lockCallback
);
void
setUnlockCallback
(
Media
::
unlockCallback
);
void
setDataCtx
(
Media
::
DataCtx
*
dataCtx
);
void
outputInVmem
();
void
outputInWindow
();
static
DataCtx
*
buildDataCtx
();
private:
Exception
_ex
;
Instance
&
_instance
;
};
}
#endif // VLCMEDIA_H
src/LibVLCpp/VLCMediaPlayer.cpp
0 → 100644
View file @
62d32a70
#include
<cassert>
#include
"VLCMediaPlayer.h"
using
namespace
LibVLCpp
;
MediaPlayer
::
MediaPlayer
(
Media
*
media
)
{
this
->
_internalPtr
=
libvlc_media_player_new_from_media
(
media
->
getInternalPtr
(),
this
->
_ex
);
this
->
_ex
.
checkThrow
();
}
void
MediaPlayer
::
play
()
{
libvlc_media_player_play
(
this
->
_internalPtr
,
this
->
_ex
);
this
->
_ex
.
checkThrow
();
}
void
MediaPlayer
::
pause
()
{
libvlc_media_player_pause
(
this
->
_internalPtr
,
this
->
_ex
);
this
->
_ex
.
checkThrow
();
}
void
MediaPlayer
::
stop
()
{
libvlc_media_player_stop
(
this
->
_internalPtr
,
this
->
_ex
);
}
qint64
MediaPlayer
::
getTime
()
{
qint64
t
=
libvlc_media_player_get_time
(
this
->
_internalPtr
,
this
->
_ex
);
this
->
_ex
.
checkThrow
();
return
t
;
}
void
MediaPlayer
::
setTime
(
qint64
time
)
{
libvlc_media_player_set_time
(
this
->
_internalPtr
,
time
,
this
->
_ex
);
this
->
_ex
.
checkThrow
();
}
qint64
MediaPlayer
::
getLength
()
{
qint64
length
=
libvlc_media_player_get_length
(
this
->
_internalPtr
,
this
->
_ex
);
this
->
_ex
.
checkThrow
();
return
length
;
}
src/LibVLCpp/VLCMediaPlayer.h
0 → 100644
View file @
62d32a70
#ifndef VLCMEDIAPLAYER_H
#define VLCMEDIAPLAYER_H
#include
"vlc/vlc.h"
#include
<QMutex>
#include
"VLCpp.hpp"
#include
"VLCMedia.h"
#include
"VLCException.h"
namespace
LibVLCpp
{
class
MediaPlayer
:
public
Internal
<
libvlc_media_player_t
>
{
public:
MediaPlayer
(
Media
*
media
);
void
play
();
void
pause
();
void
stop
();
qint64
getTime
();
void
setTime
(
qint64
time
);
qint64
getLength
();
private:
Exception
_ex
;
};
}
#endif // VLCMEDIAPLAYER_H
src/LibVLCpp/VlmManager.cpp
View file @
62d32a70
...
...
@@ -9,7 +9,7 @@ VlmManager::VlmManager(Instance* instance) : _instance(*instance)
VlmMedia
*
VlmManager
::
addMedia
(
const
QString
&
filename
,
const
char
*
const
*
argv
,
int
argc
)
{
VlmMedia
*
media
=
new
VlmMedia
(
filename
);
VlmMedia
*
media
=
new
VlmMedia
(
this
->
_instance
,
filename
);
libvlc_vlm_add_broadcast
(
this
->
_instance
,
media
->
getHash
().
toLocal8Bit
(),
filename
.
toLocal8Bit
(),
"#duplicate{dst=display{vmem}}"
,
...
...
src/LibVLCpp/VlmMedia.cpp
View file @
62d32a70
#include
<QtDebug>
#include
<QCryptographicHash>
#include
"vlc/vlc.h"
#include
"VlmMedia.h"
using
namespace
LibVLCpp
;
VlmMedia
::
VlmMedia
(
const
QString
&
filename
)
VlmMedia
::
VlmMedia
(
Instance
&
instance
,
const
QString
&
filename
)
:
_instance
(
instance
)
{
QByteArray
hash
=
QCryptographicHash
::
hash
(
filename
.
toAscii
(),
QCryptographicHash
::
Md5
);
this
->
_hash
=
hash
;
//To have a printable value :
this
->
_hash
=
hash
.
toHex
();
}
...
...
@@ -14,3 +20,16 @@ const QString& VlmMedia::getHash() const
{
return
this
->
_hash
;
}
void
VlmMedia
::
play
()
{
libvlc_vlm_play_media
(
this
->
_instance
,
this
->
_hash
.
toLocal8Bit
(),
this
->
_ex
);
this
->
_ex
.
checkThrow
();
}
int
VlmMedia
::
getLength
()
{
int
length
=
libvlc_vlm_get_media_instance_length
(
this
->
_instance
,
this
->
_hash
.
toLocal8Bit
(),
0
,
this
->
_ex
);
this
->
_ex
.
checkThrow
();
return
length
;
}
src/LibVLCpp/VlmMedia.h
View file @
62d32a70
...
...
@@ -3,15 +3,22 @@
#include
<QString>
#include
"VLCInstance.h"
#include
"VLCException.h"
namespace
LibVLCpp
{
class
VlmMedia
{
public:
VlmMedia
(
const
QString
&
filename
);
VlmMedia
(
Instance
&
inst
,
const
QString
&
filename
);
const
QString
&
getHash
()
const
;
int
getLength
();
void
play
();
private:
Instance
&
_instance
;
Exception
_ex
;
QString
_hash
;
};
}
...
...
vlmc.pro
View file @
62d32a70
...
...
@@ -17,7 +17,9 @@ SOURCES += src/main.cpp \
src
/
LibVLCpp
/
VlmManager
.
cpp
\
src
/
LibVLCpp
/
VLCInstance
.
cpp
\
src
/
LibVLCpp
/
VlmMedia
.
cpp
\
src
/
gui
/
Timeline
.
cpp
src
/
gui
/
Timeline
.
cpp
\
src
/
LibVLCpp
/
VLCMediaPlayer
.
cpp
\
src
/
LibVLCpp
/
VLCMedia
.
cpp
HEADERS
+=
src
/
gui
/
MainWindow
.
h
\
src
/
gui
/
DockWidgetManager
.
h
\
src
/
gui
/
LibraryWidget
.
h
\
...
...
@@ -26,10 +28,15 @@ HEADERS += src/gui/MainWindow.h \
src
/
LibVLCpp
/
VlmManager
.
h
\
src
/
LibVLCpp
/
VLCInstance
.
h
\
src
/
LibVLCpp
/
VlmMedia
.
h
\
src
/
gui
/
Timeline
.
h
src
/
gui
/
Timeline
.
h
\
src
/
LibVLCpp
/
VLCMediaPlayer
.
h
\
src
/
LibVLCpp
/
VLCMedia
.
h
FORMS
+=
src
/
gui
/
ui
/
MainWindow
.
ui
\
src
/
gui
/
ui
/
Timeline
.
ui
\
src
/
gui
/
ui
/
LibraryWidget
.
ui
RESOURCES
+=
INCLUDEPATH
+=
src
/
LibVLCpp
LIBS
=
-
L
/
usr
/
local
/
lib
\
-
lvlc
Write
Preview
Supports
Markdown
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