Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
luyikei
VLMC
Commits
15d01e60
Commit
15d01e60
authored
Feb 28, 2014
by
Hugo Beauzée-Luyssen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Backend: Add a log handling
parent
24b0958f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
15 deletions
+38
-15
src/Backend/IBackend.h
src/Backend/IBackend.h
+12
-2
src/Backend/VLC/VLCBackend.cpp
src/Backend/VLC/VLCBackend.cpp
+22
-12
src/Backend/VLC/VLCBackend.h
src/Backend/VLC/VLCBackend.h
+4
-1
No files found.
src/Backend/IBackend.h
View file @
15d01e60
...
...
@@ -35,9 +35,19 @@ class IMemorySource;
class
IBackend
{
public:
enum
LogLevel
{
Debug
,
Warning
,
Error
,
None
};
typedef
void
(
*
LogHandler
)(
void
*
data
,
LogLevel
logLevel
,
const
char
*
msg
);
virtual
~
IBackend
()
{}
virtual
ISource
*
createSource
(
const
char
*
path
)
=
0
;
virtual
IMemorySource
*
createMemorySource
()
=
0
;
virtual
ISource
*
createSource
(
const
char
*
path
)
=
0
;
virtual
IMemorySource
*
createMemorySource
()
=
0
;
virtual
void
setLogHandler
(
void
*
data
,
LogHandler
logHandler
)
=
0
;
};
extern
IBackend
*
getBackend
();
...
...
src/Backend/VLC/VLCBackend.cpp
View file @
15d01e60
...
...
@@ -38,6 +38,8 @@ IBackend *Backend::getBackend()
}
VLCBackend
::
VLCBackend
()
:
m_logHandler
(
NULL
)
,
m_logHandlerData
(
NULL
)
{
QVector
<
const
char
*>
argv
;
argv
<<
"--no-skip-frames"
...
...
@@ -48,13 +50,8 @@ VLCBackend::VLCBackend()
// << "--no-overlay",
<<
"--no-disable-screensaver"
;
//No need to disable the screensaver, and save a thread.
int
debugLevel
=
VLMC_GET_INT
(
"private/VlcLogLevel"
);
if
(
debugLevel
==
VlmcLogger
::
Debug
)
argv
<<
"-vv"
;
else
if
(
debugLevel
==
VlmcLogger
::
Verbose
)
argv
<<
"-v"
;
m_vlcInstance
=
new
LibVLCpp
::
Instance
(
argv
.
count
(),
&
argv
.
front
()
);
m_vlcInstance
->
setLogHook
(
this
,
&
logHook
);
assert
(
m_vlcInstance
!=
NULL
);
}
ISource
*
...
...
@@ -69,6 +66,15 @@ VLCBackend::createMemorySource()
return
new
VLCMemorySource
(
this
);
}
void
VLCBackend
::
setLogHandler
(
void
*
data
,
IBackend
::
LogHandler
logHandler
)
{
m_vlcInstance
->
unsetLogHook
();
m_logHandlerData
=
data
;
m_logHandler
=
logHandler
;
m_vlcInstance
->
setLogHook
(
this
,
&
logHook
);
}
LibVLCpp
::
Instance
*
VLCBackend
::
vlcInstance
()
{
...
...
@@ -76,24 +82,28 @@ VLCBackend::vlcInstance()
}
void
VLCBackend
::
logHook
(
void
*
data
,
int
level
,
const
libvlc_log_t
*
ctx
,
const
char
*
fmt
,
va_list
args
)
VLCBackend
::
logHook
(
void
*
data
,
int
level
,
const
libvlc_log_t
*
ctx
,
const
char
*
fmt
,
va_list
args
)
{
Q_UNUSED
(
data
)
Q_UNUSED
(
ctx
)
VLCBackend
*
self
=
reinterpret_cast
<
VLCBackend
*>
(
data
);
if
(
!
self
->
m_logHandler
)
return
;
char
*
msg
;
if
(
vasprintf
(
&
msg
,
fmt
,
args
)
<
0
)
return
;
if
(
level
<=
LIBVLC_NOTICE
)
vlmcDebug
()
<<
"[VLC]"
<<
msg
;
self
->
m_logHandler
(
self
->
m_logHandlerData
,
Debug
,
msg
)
;
else
if
(
level
==
LIBVLC_WARNING
)
vlmcWarning
()
<<
"[VLC]"
<<
msg
;
self
->
m_logHandler
(
self
->
m_logHandlerData
,
Warning
,
msg
)
;
else
if
(
level
==
LIBVLC_ERROR
)
vlmcCritical
()
<<
"[VLC]"
<<
msg
;
self
->
m_logHandler
(
self
->
m_logHandlerData
,
Error
,
msg
)
;
else
{
vlmcCritical
()
<<
"Unexpected logging level for VLC log"
<<
level
;
vlmcCritical
()
<<
"
[
VLC
]
"
<<
msg
;
vlmcCritical
()
<<
"VLC
Backend:
"
<<
msg
;
}
free
(
msg
);
}
src/Backend/VLC/VLCBackend.h
View file @
15d01e60
...
...
@@ -40,6 +40,7 @@ class VLCBackend : public IBackend, public Singleton<VLCBackend>
VLCBackend
();
virtual
ISource
*
createSource
(
const
char
*
path
);
virtual
IMemorySource
*
createMemorySource
();
virtual
void
setLogHandler
(
void
*
data
,
LogHandler
logHandler
);
// Accessible from VLCBackend only:
LibVLCpp
::
Instance
*
vlcInstance
();
...
...
@@ -50,8 +51,10 @@ class VLCBackend : public IBackend, public Singleton<VLCBackend>
private:
friend
class
Singleton
<
VLCBackend
>
;
LibVLCpp
::
Instance
*
m_vlcInstance
;
LibVLCpp
::
Instance
*
m_vlcInstance
;
LogHandler
m_logHandler
;
void
*
m_logHandlerData
;
};
}
//VLC
...
...
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