mp4: pass struct mp4_context to the mp4ff_callback_t methods
We need the decoder object, so we have to begin passing a new struct to these callbacks, instead of only the pointer to the input_stream object.
This commit is contained in:
parent
632dc7c96b
commit
9ecfc57c3a
@ -28,6 +28,10 @@
|
|||||||
|
|
||||||
/* all code here is either based on or copied from FAAD2's frontend code */
|
/* all code here is either based on or copied from FAAD2's frontend code */
|
||||||
|
|
||||||
|
struct mp4_context {
|
||||||
|
struct input_stream *input_stream;
|
||||||
|
};
|
||||||
|
|
||||||
static int
|
static int
|
||||||
mp4_get_aac_track(mp4ff_t * infile)
|
mp4_get_aac_track(mp4ff_t * infile)
|
||||||
{
|
{
|
||||||
@ -71,25 +75,30 @@ mp4_get_aac_track(mp4ff_t * infile)
|
|||||||
static uint32_t
|
static uint32_t
|
||||||
mp4_read(void *user_data, void *buffer, uint32_t length)
|
mp4_read(void *user_data, void *buffer, uint32_t length)
|
||||||
{
|
{
|
||||||
return input_stream_read((struct input_stream *) user_data,
|
struct mp4_context *ctx = user_data;
|
||||||
buffer, length);
|
|
||||||
|
return input_stream_read(ctx->input_stream, buffer, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t
|
static uint32_t
|
||||||
mp4_seek(void *user_data, uint64_t position)
|
mp4_seek(void *user_data, uint64_t position)
|
||||||
{
|
{
|
||||||
return input_stream_seek((struct input_stream *) user_data,
|
struct mp4_context *ctx = user_data;
|
||||||
position, SEEK_SET)
|
|
||||||
|
return input_stream_seek(ctx->input_stream, position, SEEK_SET)
|
||||||
? 0 : -1;
|
? 0 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
mp4_decode(struct decoder *mpd_decoder, struct input_stream *input_stream)
|
mp4_decode(struct decoder *mpd_decoder, struct input_stream *input_stream)
|
||||||
{
|
{
|
||||||
|
struct mp4_context ctx = {
|
||||||
|
.input_stream = input_stream,
|
||||||
|
};
|
||||||
mp4ff_callback_t callback = {
|
mp4ff_callback_t callback = {
|
||||||
.read = mp4_read,
|
.read = mp4_read,
|
||||||
.seek = mp4_seek,
|
.seek = mp4_seek,
|
||||||
.user_data = input_stream,
|
.user_data = &ctx,
|
||||||
};
|
};
|
||||||
mp4ff_t *mp4fh;
|
mp4ff_t *mp4fh;
|
||||||
int32_t track;
|
int32_t track;
|
||||||
@ -119,10 +128,6 @@ mp4_decode(struct decoder *mpd_decoder, struct input_stream *input_stream)
|
|||||||
double seek_where = 0;
|
double seek_where = 0;
|
||||||
bool initialized = false;
|
bool initialized = false;
|
||||||
|
|
||||||
callback.read = mp4_read;
|
|
||||||
callback.seek = mp4_seek;
|
|
||||||
callback.user_data = input_stream;
|
|
||||||
|
|
||||||
mp4fh = mp4ff_open_read(&callback);
|
mp4fh = mp4ff_open_read(&callback);
|
||||||
if (!mp4fh) {
|
if (!mp4fh) {
|
||||||
g_warning("Input does not appear to be a mp4 stream.\n");
|
g_warning("Input does not appear to be a mp4 stream.\n");
|
||||||
@ -307,10 +312,13 @@ mp4_load_tag(const char *file)
|
|||||||
{
|
{
|
||||||
struct tag *ret = NULL;
|
struct tag *ret = NULL;
|
||||||
struct input_stream input_stream;
|
struct input_stream input_stream;
|
||||||
|
struct mp4_context ctx = {
|
||||||
|
.input_stream = &input_stream,
|
||||||
|
};
|
||||||
mp4ff_callback_t callback = {
|
mp4ff_callback_t callback = {
|
||||||
.read = mp4_read,
|
.read = mp4_read,
|
||||||
.seek = mp4_seek,
|
.seek = mp4_seek,
|
||||||
.user_data = &input_stream,
|
.user_data = &ctx,
|
||||||
};
|
};
|
||||||
mp4ff_t *mp4fh;
|
mp4ff_t *mp4fh;
|
||||||
int32_t track;
|
int32_t track;
|
||||||
|
Loading…
Reference in New Issue
Block a user