Logging with libvlc

This forum is about all development around libVLC.
Moriquendi
Blank Cone
Blank Cone
Posts: 74
Joined: 31 May 2011 16:22

Logging with libvlc

Postby Moriquendi » 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;

Code: Select all

libvlc_log_set(instance->core(), log_cb, NULL);
and in my callback function:

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); }
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;

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;
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.

Rémi Denis-Courmont
Developer
Developer
Posts: 15265
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: Logging with libvlc

Postby Rémi Denis-Courmont » 25 Aug 2017 22:02

Logs are per instance - also in VLC itself.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 2 guests