Merge pull request #2401 from connortechnology/vlc_logging
add a logging callback to the libvlc camera
This commit is contained in:
commit
9811679cc0
|
@ -186,6 +186,8 @@ int LibvlcCamera::PrimeCapture() {
|
||||||
Error("Unable to create libvlc instance due to: %s", libvlc_errmsg());
|
Error("Unable to create libvlc instance due to: %s", libvlc_errmsg());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
libvlc_log_set(mLibvlcInstance, LibvlcCamera::log_callback, NULL);
|
||||||
|
|
||||||
|
|
||||||
mLibvlcMedia = libvlc_media_new_location(mLibvlcInstance, mPath.c_str());
|
mLibvlcMedia = libvlc_media_new_location(mLibvlcInstance, mPath.c_str());
|
||||||
if ( mLibvlcMedia == NULL ) {
|
if ( mLibvlcMedia == NULL ) {
|
||||||
|
@ -214,6 +216,7 @@ int LibvlcCamera::PrimeCapture() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int LibvlcCamera::PreCapture() {
|
int LibvlcCamera::PreCapture() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -244,4 +247,28 @@ int LibvlcCamera::PostCapture() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LibvlcCamera::log_callback(void *ptr, int level, const libvlc_log_t *ctx, const char *fmt, va_list vargs) {
|
||||||
|
Logger *log = Logger::fetch();
|
||||||
|
int log_level = Logger::NOLOG;
|
||||||
|
if ( level == LIBVLC_ERROR ) {
|
||||||
|
log_level = Logger::WARNING; // ffmpeg outputs a lot of errors that don't really affect anything.
|
||||||
|
//log_level = Logger::ERROR;
|
||||||
|
} else if ( level == LIBVLC_WARNING ) {
|
||||||
|
log_level = Logger::INFO;
|
||||||
|
//log_level = Logger::WARNING;
|
||||||
|
} else if ( level == LIBVLC_NOTICE ) {
|
||||||
|
log_level = Logger::DEBUG1;
|
||||||
|
//log_level = Logger::INFO;
|
||||||
|
} else if ( level == LIBVLC_DEBUG ) {
|
||||||
|
log_level = Logger::DEBUG3;
|
||||||
|
} else {
|
||||||
|
Error("Unknown log level %d", level);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( log ) {
|
||||||
|
char logString[8192];
|
||||||
|
vsnprintf(logString, sizeof(logString)-1, fmt, vargs);
|
||||||
|
log->logPrint(false, __FILE__, __LINE__, log_level, logString);
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif // HAVE_LIBVLC
|
#endif // HAVE_LIBVLC
|
||||||
|
|
|
@ -42,6 +42,8 @@ struct LibvlcPrivateData
|
||||||
};
|
};
|
||||||
|
|
||||||
class LibvlcCamera : public Camera {
|
class LibvlcCamera : public Camera {
|
||||||
|
private:
|
||||||
|
static void log_callback( void *ptr, int level, const libvlc_log_t *ctx, const char *format, va_list vargs );
|
||||||
protected:
|
protected:
|
||||||
std::string mPath;
|
std::string mPath;
|
||||||
std::string mMethod;
|
std::string mMethod;
|
||||||
|
@ -59,9 +61,9 @@ public:
|
||||||
LibvlcCamera( int p_id, const std::string &path, const std::string &p_method, const std::string &p_options, int p_width, int p_height, int p_colours, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture, bool p_record_audio );
|
LibvlcCamera( int p_id, const std::string &path, const std::string &p_method, const std::string &p_options, int p_width, int p_height, int p_colours, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture, bool p_record_audio );
|
||||||
~LibvlcCamera();
|
~LibvlcCamera();
|
||||||
|
|
||||||
const std::string &Path() const { return( mPath ); }
|
const std::string &Path() const { return mPath; }
|
||||||
const std::string &Options() const { return( mOptions ); }
|
const std::string &Options() const { return mOptions; }
|
||||||
const std::string &Method() const { return( mMethod ); }
|
const std::string &Method() const { return mMethod; }
|
||||||
|
|
||||||
void Initialise();
|
void Initialise();
|
||||||
void Terminate();
|
void Terminate();
|
||||||
|
|
Loading…
Reference in New Issue