problems with libvlc_media_new_callbacks

This forum is about all development around libVLC.
dreadLocks
Blank Cone
Blank Cone
Posts: 18
Joined: 31 May 2016 23:39

problems with libvlc_media_new_callbacks

Postby dreadLocks » 04 Jun 2016 21:45

Hello,

I'm trying to have vlc read an mp3 data stream from my memory. I decrypt the mp3 file a little at a time on the fly then send decrypted mp3 data to the vlc when it calls read_cb

Im using m = libvlc_media_new_callbacks(inst,
open_cb,
read_cb,
seek_cb,
close_cb,
&opaque[0]
);

I have some problems.

1. what should opaque be above? is it acting like a FILE pointer internally to vlc?
what should i set opaque to???

2. When i run the code vlc calls my open_cb function

int open_cb(void *opaque, void **datap, uint64_t *sizep)
{
*sizep = TotalBytesInMP3File;
*datap = opaque;
seekPosition = 0;
return 0;
}

what exactly should i set opaque and datap to in the open_cb function???

3. i also have a seek function

int seek_cb(void *opaque, uint64_t offset)
{
seekPosition = offset;
return 0;
}

vlc calls my read_cb function that sends back data and sometimes vlc calls my seek_cb function above, then after that, it again calls my read_cb function many times.

Sometimes it keeps reading way past the end of file, strange because i told it the file size during the open_cb, but it keeps reading more bytes than the mp3 file has.

Maybe it has something to do with the seek position. When it calls seek, it seems to suddenly seek (jump) to the middle of the file, and then calls read_cb again after that.

When vlc calls seek, should i change the start reading point to the offset, so that the next time it calls read, it would start from there rather than where it last off last time???

Right now, when it calls seek, i move the read pointer in the mp3 stream to the offset it passed in, so that when it calls read again, it would start reading from the seek position in the mp3 file.

But it keeps reading past the end of file, so maybe when it calls seek i should NOT change the seek point? but then why is it calling seek if not to change the read pointer to a new offset?

Why is it reading past the end of file when i told it the file length during the open_cb call?

Also i thought it would start playing the mp3 data right away, but instead i near nothing and it just keeps reading lots of bytes without playing anything. Does it have to read the whole thing before it starts playing? I thought the whole point of the libvlc_media_new_callbacks function was for streaming where it doesnt have to wait to read megabytes before it starts playing.

Anybody knows? Maybe i got a bug in my code?

Thanks

Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 27 guests