Logging with libvlc
Posted: 25 Aug 2017 14:57
Hi,
I'm developing a Qt application which provides users to watch up to 4 different videos simultaneously. I'm using libvlc api for playing media. Anyway, what I'd like to do is to print vlc logs for each specific player. Same as Tools->Messages and you can view the whole log in the console. So far I can print all the messages using;
and in my callback function:
The problem is; I can not separate 4 different media player logs. In other words, I dont know which log message belongs to which media player. For instance;
"picture might be displayed late (missing 5 ms)" message may belong to Media Player 1 or Media Player 2. How can I filter those messages further? I've used libvlc_log_get_object function as;
and the result is something like;
NAME: video output,ID: 75860772
But I couldn't relate "ID" with anything since for each different module, it may vary.
Any help would be appreciated.
P.S: I know I can create each player using different VLC instances, and I can define 4 different callback functions and the problem can be solved. But I'd like to use only 1 VLC instance for simplicity and some other concerns.
Cheers.
I'm developing a Qt application which provides users to watch up to 4 different videos simultaneously. I'm using libvlc api for playing media. Anyway, what I'd like to do is to print vlc logs for each specific player. Same as Tools->Messages and you can view the whole log in the console. So far I can print all the messages using;
Code: Select all
libvlc_log_set(instance->core(), log_cb, NULL);
Code: Select all
void log_cb(void *logdata, int level, const libvlc_log_t *ctx, const char *fmt, va_list args)
{
char message[1024 * 16];
memset(message, 0, sizeof(char) * 1024 * 16);
vsnprintf(message, 1024 * 16, fmt, args);
int messageLength = strlen(message);
int messageBufferLength = utf8_to_wchar_len(message, messageLength, 0);
wchar_t *messageBuffer = static_cast<wchar_t *>(calloc(messageBufferLength + 1, sizeof(wchar_t)));
utf8_to_wchar(message, messageLength, messageBuffer, messageBufferLength, 0);
qDebug()<<QString::fromWCharArray(messageBuffer);
free(messageBuffer);
}
"picture might be displayed late (missing 5 ms)" message may belong to Media Player 1 or Media Player 2. How can I filter those messages further? I've used libvlc_log_get_object function as;
Code: Select all
const char *name = "";
const char *header = "";
uintptr_t id = 0;
libvlc_log_get_object(ctx,&name,&header,&id);
qDebug() << "NAME:"<<name<<",ID:"<<id;
NAME: video output,ID: 75860772
But I couldn't relate "ID" with anything since for each different module, it may vary.
Any help would be appreciated.
P.S: I know I can create each player using different VLC instances, and I can define 4 different callback functions and the problem can be solved. But I'd like to use only 1 VLC instance for simplicity and some other concerns.
Cheers.