size_t mapsize;
size_t fpos;
int32_t track;
- struct mp4ff *mp4ff;
- struct mp4ff_callback cb;
+ struct mp4 *mp4;
+ struct mp4_callback cb;
};
static uint32_t aac_afh_read_cb(void *user_data, void *dest, uint32_t want)
return 0;
}
-static int32_t aac_afh_get_track(struct mp4ff *mp4ff)
+static int32_t aac_afh_get_track(struct mp4 *mp4)
{
- int32_t i, rc, num_tracks = mp4ff_total_tracks(mp4ff);
+ int32_t i, rc, num_tracks = mp4_total_tracks(mp4);
assert(num_tracks >= 0);
for (i = 0; i < num_tracks; i++) {
unsigned char *buf = NULL;
unsigned buf_size = 0;
- mp4ff_get_decoder_config(mp4ff, i, &buf, &buf_size);
+ mp4_get_decoder_config(mp4, i, &buf, &buf_size);
if (buf) {
mp4AudioSpecificConfig masc;
rc = NeAACDecAudioSpecificConfig(buf, buf_size, &masc);
c->cb.seek = aac_afh_seek_cb;
c->cb.user_data = c;
- ret = -E_MP4FF_OPEN;
- c->mp4ff = mp4ff_open_read(&c->cb);
- if (!c->mp4ff)
+ ret = -E_MP4_OPEN;
+ c->mp4 = mp4_open_read(&c->cb);
+ if (!c->mp4)
goto free_ctx;
- c->track = aac_afh_get_track(c->mp4ff);
- ret = -E_MP4FF_TRACK;
+ c->track = aac_afh_get_track(c->mp4);
+ ret = -E_MP4_TRACK;
if (c->track < 0)
- goto close_mp4ff;
+ goto close_mp4;
*afh_context = c;
return 0;
-close_mp4ff:
- mp4ff_close(c->mp4ff);
+close_mp4:
+ mp4_close(c->mp4);
free_ctx:
free(c);
*afh_context = NULL;
static void aac_afh_close(void *afh_context)
{
struct aac_afh_context *c = afh_context;
- mp4ff_close(c->mp4ff);
+ mp4_close(c->mp4);
free(c);
}
size_t offset;
assert(chunk_num <= INT_MAX);
- mp4ff_set_sample_position(c->mp4ff, c->track, chunk_num);
+ mp4_set_sample_position(c->mp4, c->track, chunk_num);
offset = c->fpos;
- ss = mp4ff_get_sample_size(c->mp4ff, c->track, chunk_num);
+ ss = mp4_get_sample_size(c->mp4, c->track, chunk_num);
if (ss <= 0)
- return -E_MP4FF_BAD_SAMPLE;
+ return -E_MP4_BAD_SAMPLE;
assert(ss + offset <= c->mapsize);
*buf = c->map + offset;
*len = ss;
return 1;
}
-static void _aac_afh_get_taginfo(const struct mp4ff *mp4ff, struct taginfo *tags)
+static void _aac_afh_get_taginfo(const struct mp4 *mp4, struct taginfo *tags)
{
- mp4ff_meta_get_artist(mp4ff, &tags->artist);
- mp4ff_meta_get_title(mp4ff, &tags->title);
- mp4ff_meta_get_date(mp4ff, &tags->year);
- mp4ff_meta_get_album(mp4ff, &tags->album);
- mp4ff_meta_get_comment(mp4ff, &tags->comment);
+ mp4_meta_get_artist(mp4, &tags->artist);
+ mp4_meta_get_title(mp4, &tags->title);
+ mp4_meta_get_date(mp4, &tags->year);
+ mp4_meta_get_album(mp4, &tags->album);
+ mp4_meta_get_comment(mp4, &tags->comment);
}
/*
if (ret < 0)
return ret;
- ret = -E_MP4FF_BAD_SAMPLERATE;
- rv = mp4ff_get_sample_rate(c->mp4ff, c->track);
+ ret = -E_MP4_BAD_SAMPLERATE;
+ rv = mp4_get_sample_rate(c->mp4, c->track);
if (rv <= 0)
goto close;
afhi->frequency = rv;
- ret = -E_MP4FF_BAD_CHANNEL_COUNT;
- rv = mp4ff_get_channel_count(c->mp4ff, c->track);
+ ret = -E_MP4_BAD_CHANNEL_COUNT;
+ rv = mp4_get_channel_count(c->mp4, c->track);
if (rv <= 0)
goto close;
afhi->channels = rv;
- ret = -E_MP4FF_BAD_SAMPLE_COUNT;
- rv = mp4ff_num_samples(c->mp4ff, c->track);
+ ret = -E_MP4_BAD_SAMPLE_COUNT;
+ rv = mp4_num_samples(c->mp4, c->track);
if (rv <= 0)
goto close;
afhi->chunks_total = rv;
break;
afhi->max_chunk_size = PARA_MAX(afhi->max_chunk_size, len);
}
- milliseconds = mp4ff_get_duration(c->mp4ff, c->track);
+ milliseconds = mp4_get_duration(c->mp4, c->track);
afhi->seconds_total = milliseconds / 1000;
ms2tv(milliseconds / afhi->chunks_total, &afhi->chunk_tv);
if (aac_afh_get_chunk(0, c, &buf, &len) >= 0)
numbytes -= buf - map;
afhi->bitrate = 8 * numbytes / afhi->seconds_total / 1000;
- _aac_afh_get_taginfo(c->mp4ff, &afhi->tags);
+ _aac_afh_get_taginfo(c->mp4, &afhi->tags);
ret = 1;
close:
aac_afh_close(c);
return ftruncate(fd, offset);
}
-static void replace_tag(struct mp4ff_tag *tag, const char *new_val, bool *found)
+static void replace_tag(struct mp4_tag *tag, const char *new_val, bool *found)
{
free(tag->value);
tag->value = para_strdup(new_val);
*found = true;
}
-static void add_tag(struct mp4ff_metadata *md, const char *item, const char *value)
+static void add_tag(struct mp4_metadata *md, const char *item, const char *value)
{
md->tags[md->count].item = para_strdup(item);
md->tags[md->count].value = para_strdup(value);
{
int ret, i;
int32_t rv;
- struct mp4ff_metadata metadata;
- struct mp4ff *mp4ff;
- struct mp4ff_callback cb = {
+ struct mp4_metadata metadata;
+ struct mp4 *mp4;
+ struct mp4_callback cb = {
.read = aac_afh_meta_read_cb,
.seek = aac_afh_meta_seek_cb,
.write = aac_afh_meta_write_cb,
return ret;
lseek(fd, 0, SEEK_SET);
- mp4ff = mp4ff_open_meta(&cb);
- if (!mp4ff)
- return -E_MP4FF_OPEN;
+ mp4 = mp4_open_meta(&cb);
+ if (!mp4)
+ return -E_MP4_OPEN;
- ret = -E_MP4FF_META_READ;
- rv = mp4ff_meta_get_num_items(mp4ff);
+ ret = -E_MP4_META_READ;
+ rv = mp4_meta_get_num_items(mp4);
if (rv < 0)
goto close;
metadata.count = rv;
PARA_NOTICE_LOG("%d metadata item(s) found\n", rv);
- metadata.tags = para_malloc((metadata.count + 5) * sizeof(struct mp4ff_tag));
+ metadata.tags = para_malloc((metadata.count + 5) * sizeof(struct mp4_tag));
for (i = 0; i < metadata.count; i++) {
- struct mp4ff_tag *tag = metadata.tags + i;
+ struct mp4_tag *tag = metadata.tags + i;
- ret = -E_MP4FF_META_READ;
- if (!mp4ff_meta_get_by_index(mp4ff, i, &tag->item, &tag->value))
+ ret = -E_MP4_META_READ;
+ if (!mp4_meta_get_by_index(mp4, i, &tag->item, &tag->value))
goto free_tags;
PARA_INFO_LOG("found: %s: %s\n", tag->item, tag->value);
if (!strcmp(tag->item, "artist"))
add_tag(&metadata, "date", tags->year);
if (!found_comment)
add_tag(&metadata, "comment", tags->comment);
- ret = -E_MP4FF_META_WRITE;
- if (!mp4ff_meta_update(&cb, &metadata))
+ ret = -E_MP4_META_WRITE;
+ if (!mp4_meta_update(&cb, &metadata))
goto free_tags;
ret = 1;
free_tags:
}
free(metadata.tags);
close:
- mp4ff_close(mp4ff);
+ mp4_close(mp4);
return ret;
}
#include "string.h"
#include "mp4.h"
-struct mp4ff_track {
+struct mp4_track {
int32_t type;
int32_t channelCount;
int32_t sampleSize;
#define MAX_TRACKS 1024
-struct mp4ff {
+struct mp4 {
/* stream to read from */
- struct mp4ff_callback *stream;
+ struct mp4_callback *stream;
int64_t current_position;
uint64_t moov_offset;
int32_t total_tracks;
/* track data */
- struct mp4ff_track *track[MAX_TRACKS];
+ struct mp4_track *track[MAX_TRACKS];
/* metadata */
- struct mp4ff_metadata tags;
+ struct mp4_metadata tags;
};
-int32_t mp4ff_total_tracks(const struct mp4ff *f)
+int32_t mp4_total_tracks(const struct mp4 *f)
{
return f->total_tracks;
}
-static int32_t read_data(struct mp4ff *f, void *data, uint32_t size)
+static int32_t read_data(struct mp4 *f, void *data, uint32_t size)
{
int32_t result = 1;
return result;
}
-static uint64_t read_int64(struct mp4ff *f)
+static uint64_t read_int64(struct mp4 *f)
{
uint8_t data[8];
}
/* read atom header, return atom size, atom size is with header included */
-static uint64_t atom_read_header(struct mp4ff *f, uint8_t * atom_type,
+static uint64_t atom_read_header(struct mp4 *f, uint8_t * atom_type,
uint8_t * header_size)
{
uint64_t size;
return size;
}
-static int64_t get_position(const struct mp4ff *f)
+static int64_t get_position(const struct mp4 *f)
{
return f->current_position;
}
}
}
-static int32_t set_position(struct mp4ff *f, int64_t position)
+static int32_t set_position(struct mp4 *f, int64_t position)
{
f->stream->seek(f->stream->user_data, position);
f->current_position = position;
return 0;
}
-static void track_add(struct mp4ff *f)
+static void track_add(struct mp4 *f)
{
f->total_tracks++;
f->error++;
return;
}
- f->track[f->total_tracks - 1] = para_calloc(sizeof(struct mp4ff_track));
+ f->track[f->total_tracks - 1] = para_calloc(sizeof(struct mp4_track));
}
-static uint8_t read_char(struct mp4ff *f)
+static uint8_t read_char(struct mp4 *f)
{
uint8_t output;
read_data(f, &output, 1);
return output;
}
-static uint32_t read_int24(struct mp4ff *f)
+static uint32_t read_int24(struct mp4 *f)
{
int8_t data[4];
return read_u24_be(data);
}
-static uint32_t read_int32(struct mp4ff *f)
+static uint32_t read_int32(struct mp4 *f)
{
int8_t data[4];
return read_u32_be(data);
}
-static int32_t read_stsz(struct mp4ff *f)
+static int32_t read_stsz(struct mp4 *f)
{
int32_t i;
- struct mp4ff_track *t;
+ struct mp4_track *t;
if (f->total_tracks == 0)
return f->error++;
return 0;
}
-static int32_t read_stts(struct mp4ff *f)
+static int32_t read_stts(struct mp4 *f)
{
int32_t i;
- struct mp4ff_track *t;
+ struct mp4_track *t;
/* CVE-2017-9223 */
if (f->total_tracks == 0)
return 1;
}
-static int32_t read_ctts(struct mp4ff *f)
+static int32_t read_ctts(struct mp4 *f)
{
int32_t i;
- struct mp4ff_track *t;
+ struct mp4_track *t;
if (f->total_tracks == 0)
return f->error++;
return 1;
}
-static int32_t read_stsc(struct mp4ff *f)
+static int32_t read_stsc(struct mp4 *f)
{
int32_t i;
- struct mp4ff_track *t;
+ struct mp4_track *t;
if (f->total_tracks == 0)
return f->error++;
return 0;
}
-static int32_t read_stco(struct mp4ff *f)
+static int32_t read_stco(struct mp4 *f)
{
int32_t i;
- struct mp4ff_track *t;
+ struct mp4_track *t;
if (f->total_tracks == 0)
return f->error++;
return 0;
}
-static uint16_t read_int16(struct mp4ff *f)
+static uint16_t read_int16(struct mp4 *f)
{
int8_t data[2];
return read_u16_be(data);
}
-static uint32_t read_mp4_descr_length(struct mp4ff *f)
+static uint32_t read_mp4_descr_length(struct mp4 *f)
{
uint8_t b;
uint8_t numBytes = 0;
return length;
}
-static int32_t read_esds(struct mp4ff *f)
+static int32_t read_esds(struct mp4 *f)
{
uint8_t tag;
uint32_t temp;
- struct mp4ff_track *t;
+ struct mp4_track *t;
if (f->total_tracks == 0)
return f->error++;
return 0;
}
-static int32_t read_mp4a(struct mp4ff *f)
+static int32_t read_mp4a(struct mp4 *f)
{
int32_t i;
uint8_t atom_type = 0;
uint8_t header_size = 0;
- struct mp4ff_track *t;
+ struct mp4_track *t;
if (f->total_tracks == 0)
return f->error++;
return 0;
}
-static int32_t read_stsd(struct mp4ff *f)
+static int32_t read_stsd(struct mp4 *f)
{
int32_t i;
uint8_t header_size = 0;
- struct mp4ff_track *t;
+ struct mp4_track *t;
/* CVE-2017-9218 */
if (f->total_tracks == 0)
return 0;
}
-static int32_t read_mvhd(struct mp4ff *f)
+static int32_t read_mvhd(struct mp4 *f)
{
int32_t i;
return 0;
}
-static int32_t tag_add_field(struct mp4ff_metadata *tags, const char *item,
+static int32_t tag_add_field(struct mp4_metadata *tags, const char *item,
const char *value, int32_t len)
{
if (!item || (item && !*item) || !value)
return 0;
tags->tags = para_realloc(tags->tags,
- (tags->count + 1) * sizeof(struct mp4ff_tag));
+ (tags->count + 1) * sizeof(struct mp4_tag));
tags->tags[tags->count].item = para_strdup(item);
tags->tags[tags->count].len = len;
if (len >= 0) {
}
}
-static char *read_string(struct mp4ff *f, uint32_t length)
+static char *read_string(struct mp4 *f, uint32_t length)
{
char *str = para_malloc(length + 1);
if ((uint32_t)read_data(f, str, length) != length) {
}
}
-static int32_t parse_tag(struct mp4ff *f, uint8_t parent, int32_t size)
+static int32_t parse_tag(struct mp4 *f, uint8_t parent, int32_t size)
{
uint8_t atom_type;
uint8_t header_size = 0;
return 1;
}
-static int32_t read_mdhd(struct mp4ff *f)
+static int32_t read_mdhd(struct mp4 *f)
{
uint32_t version;
- struct mp4ff_track *t;
+ struct mp4_track *t;
/* CVE-2017-9221 */
if (f->total_tracks == 0)
return 1;
}
-static int32_t parse_metadata(struct mp4ff *f, int32_t size)
+static int32_t parse_metadata(struct mp4 *f, int32_t size)
{
uint64_t subsize, sumsize = 0;
uint8_t atom_type;
return 0;
}
-static int32_t read_meta(struct mp4ff *f, uint64_t size)
+static int32_t read_meta(struct mp4 *f, uint64_t size)
{
uint64_t subsize, sumsize = 0;
uint8_t atom_type;
return 0;
}
-static int32_t atom_read(struct mp4ff *f, int32_t size, uint8_t atom_type)
+static int32_t atom_read(struct mp4 *f, int32_t size, uint8_t atom_type)
{
uint64_t dest_position = get_position(f) + size - 8;
if (atom_type == ATOM_STSZ) {
}
/* parse atoms that are sub atoms of other atoms */
-static int32_t parse_sub_atoms(struct mp4ff *f, uint64_t total_size, int meta_only)
+static int32_t parse_sub_atoms(struct mp4 *f, uint64_t total_size, int meta_only)
{
uint64_t size;
uint8_t atom_type = 0;
}
/* parse root atoms */
-static int32_t parse_atoms(struct mp4ff *f, int meta_only)
+static int32_t parse_atoms(struct mp4 *f, int meta_only)
{
uint64_t size;
uint8_t atom_type = 0;
return 0;
}
-void mp4ff_get_decoder_config(const struct mp4ff *f, int track,
+void mp4_get_decoder_config(const struct mp4 *f, int track,
unsigned char **ppBuf, unsigned int *pBufSize)
{
if (track >= f->total_tracks) {
}
}
-struct mp4ff *mp4ff_open_read(struct mp4ff_callback *f)
+struct mp4 *mp4_open_read(struct mp4_callback *f)
{
- struct mp4ff *ff = para_calloc(sizeof(struct mp4ff));
+ struct mp4 *ff = para_calloc(sizeof(struct mp4));
ff->stream = f;
return ff;
}
-static int32_t tag_delete(struct mp4ff_metadata *tags)
+static int32_t tag_delete(struct mp4_metadata *tags)
{
uint32_t i;
return 0;
}
-void mp4ff_close(struct mp4ff *ff)
+void mp4_close(struct mp4 *ff)
{
int32_t i;
free(ff);
}
-static int32_t chunk_of_sample(const struct mp4ff *f, int32_t track,
+static int32_t chunk_of_sample(const struct mp4 *f, int32_t track,
int32_t sample, int32_t *chunk_sample, int32_t *chunk)
{
int32_t total_entries = 0;
return 0;
}
-static int32_t chunk_to_offset(const struct mp4ff *f, int32_t track,
+static int32_t chunk_to_offset(const struct mp4 *f, int32_t track,
int32_t chunk)
{
- const struct mp4ff_track *p_track = f->track[track];
+ const struct mp4_track *p_track = f->track[track];
if (p_track->stco_entry_count && (chunk > p_track->stco_entry_count)) {
return p_track->stco_chunk_offset[p_track->stco_entry_count -
return 0;
}
-static int32_t sample_range_size(const struct mp4ff *f, int32_t track,
+static int32_t sample_range_size(const struct mp4 *f, int32_t track,
int32_t chunk_sample, int32_t sample)
{
int32_t i, total;
- const struct mp4ff_track *p_track = f->track[track];
+ const struct mp4_track *p_track = f->track[track];
if (p_track->stsz_sample_size) {
return (sample - chunk_sample) * p_track->stsz_sample_size;
return total;
}
-static int32_t sample_to_offset(const struct mp4ff *f, int32_t track,
+static int32_t sample_to_offset(const struct mp4 *f, int32_t track,
int32_t sample)
{
int32_t chunk, chunk_sample, chunk_offset1, chunk_offset2;
/**
* Return the number of milliseconds of the given track.
*
- * \param f As returned by \ref mp4ff_open_read(), must not be NULL.
- * \param track Between zero and the value returned by \ref mp4ff_total_tracks().
+ * \param f As returned by \ref mp4_open_read(), must not be NULL.
+ * \param track Between zero and the value returned by \ref mp4_total_tracks().
*
* The function returns zero if the audio file is of zero length or contains a
* corrupt track header.
*/
-uint64_t mp4ff_get_duration(const struct mp4ff *f, int32_t track)
+uint64_t mp4_get_duration(const struct mp4 *f, int32_t track)
{
- const struct mp4ff_track *t = f->track[track];
+ const struct mp4_track *t = f->track[track];
if (t->timeScale == 0)
return 0;
return t->duration * 1000 / t->timeScale;
}
-void mp4ff_set_sample_position(struct mp4ff *f, int32_t track, int32_t sample)
+void mp4_set_sample_position(struct mp4 *f, int32_t track, int32_t sample)
{
int32_t offset = sample_to_offset(f, track, sample);
set_position(f, offset);
}
-int32_t mp4ff_get_sample_size(const struct mp4ff *f, int track, int sample)
+int32_t mp4_get_sample_size(const struct mp4 *f, int track, int sample)
{
- const struct mp4ff_track *t = f->track[track];
+ const struct mp4_track *t = f->track[track];
if (t->stsz_sample_size != 0)
return t->stsz_sample_size;
return t->stsz_table[sample];
}
-uint32_t mp4ff_get_sample_rate(const struct mp4ff *f, int32_t track)
+uint32_t mp4_get_sample_rate(const struct mp4 *f, int32_t track)
{
return f->track[track]->sampleRate;
}
-uint32_t mp4ff_get_channel_count(const struct mp4ff *f, int32_t track)
+uint32_t mp4_get_channel_count(const struct mp4 *f, int32_t track)
{
return f->track[track]->channelCount;
}
-int32_t mp4ff_num_samples(const struct mp4ff *f, int32_t track)
+int32_t mp4_num_samples(const struct mp4 *f, int32_t track)
{
int32_t i;
int32_t total = 0;
return total;
}
-struct mp4ff *mp4ff_open_meta(struct mp4ff_callback *f)
+struct mp4 *mp4_open_meta(struct mp4_callback *f)
{
- struct mp4ff *ff = para_calloc(sizeof(struct mp4ff));
+ struct mp4 *ff = para_calloc(sizeof(struct mp4));
ff->stream = f;
return ff;
}
-int32_t mp4ff_meta_get_num_items(const struct mp4ff *f)
+int32_t mp4_meta_get_num_items(const struct mp4 *f)
{
return f->tags.count;
}
-int32_t mp4ff_meta_get_by_index(const struct mp4ff *f, uint32_t index,
+int32_t mp4_meta_get_by_index(const struct mp4 *f, uint32_t index,
char **item, char **value)
{
if (index >= f->tags.count) {
}
}
-static uint32_t find_atom(struct mp4ff *f, uint64_t base, uint32_t size,
+static uint32_t find_atom(struct mp4 *f, uint64_t base, uint32_t size,
const char *name)
{
uint32_t remaining = size;
return 0;
}
-static uint32_t find_atom_v2(struct mp4ff *f, uint64_t base, uint32_t size,
+static uint32_t find_atom_v2(struct mp4 *f, uint64_t base, uint32_t size,
const char *name, uint32_t extraheaders, const char *name_inside)
{
uint64_t first_base = (uint64_t) (-1);
return ret;
}
-static uint32_t create_ilst(const struct mp4ff_metadata *data, void **out_buffer,
+static uint32_t create_ilst(const struct mp4_metadata *data, void **out_buffer,
uint32_t * out_size)
{
struct membuffer *buf = membuffer_create();
const char *genre_ptr = 0, *tempo_ptr = 0;
for (metaptr = 0; metaptr < data->count; metaptr++) {
- struct mp4ff_tag *tag = &data->tags[metaptr];
+ struct mp4_tag *tag = &data->tags[metaptr];
if (!strcasecmp(tag->item, "tracknumber")
|| !strcasecmp(tag->item, "track")) {
if (tracknumber_ptr == 0)
membuffer_write_int16_tag(buf, "gnre", index);
}
for (metaptr = 0; metaptr < data->count; metaptr++) {
- struct mp4ff_tag *tag;
+ struct mp4_tag *tag;
const char *std_meta_atom;
if (mask[metaptr])
buf->error = 1;
}
-static unsigned membuffer_transfer_from_file(struct membuffer *buf, struct mp4ff *src,
+static unsigned membuffer_transfer_from_file(struct membuffer *buf, struct mp4 *src,
unsigned bytes)
{
unsigned oldsize;
return bytes;
}
-static uint32_t create_meta(const struct mp4ff_metadata *data, void **out_buffer,
+static uint32_t create_meta(const struct mp4_metadata *data, void **out_buffer,
uint32_t * out_size)
{
struct membuffer *buf;
return 1;
}
-static uint32_t create_udta(const struct mp4ff_metadata *data, void **out_buffer,
+static uint32_t create_udta(const struct mp4_metadata *data, void **out_buffer,
uint32_t * out_size)
{
struct membuffer *buf;
return read_u32_be(&src);
}
-static uint32_t modify_moov(struct mp4ff *f, const struct mp4ff_metadata *data,
+static uint32_t modify_moov(struct mp4 *f, const struct mp4_metadata *data,
void **out_buffer, uint32_t * out_size)
{
uint64_t total_base = f->moov_offset + 8;
return 1;
}
-static int32_t write_data(struct mp4ff *f, void *data, uint32_t size)
+static int32_t write_data(struct mp4 *f, void *data, uint32_t size)
{
int32_t result = 1;
return result;
}
-static int32_t write_int32(struct mp4ff *f, uint32_t data)
+static int32_t write_int32(struct mp4 *f, uint32_t data)
{
int8_t temp[4];
write_u32_be(temp, data);
return write_data(f, temp, sizeof(temp));
}
-static int32_t truncate_stream(struct mp4ff *f)
+static int32_t truncate_stream(struct mp4 *f)
{
return f->stream->truncate(f->stream->user_data);
}
-int32_t mp4ff_meta_update(struct mp4ff_callback *f, const struct mp4ff_metadata *data)
+int32_t mp4_meta_update(struct mp4_callback *f, const struct mp4_metadata *data)
{
void *new_moov_data;
uint32_t new_moov_size;
- struct mp4ff *ff = para_calloc(sizeof(struct mp4ff));
+ struct mp4 *ff = para_calloc(sizeof(struct mp4));
ff->stream = f;
set_position(ff, 0);
parse_atoms(ff, 1);
if (!modify_moov(ff, data, &new_moov_data, &new_moov_size)) {
- mp4ff_close(ff);
+ mp4_close(ff);
return 0;
}
truncate_stream(ff);
- mp4ff_close(ff);
+ mp4_close(ff);
return 1;
}
/* find a metadata item by name */
/* returns 0 if item found, 1 if no such item */
-static int32_t meta_find_by_name(const struct mp4ff *f, const char *item,
+static int32_t meta_find_by_name(const struct mp4 *f, const char *item,
char **value)
{
uint32_t i;
return 0;
}
-int32_t mp4ff_meta_get_artist(const struct mp4ff *f, char **value)
+int32_t mp4_meta_get_artist(const struct mp4 *f, char **value)
{
return meta_find_by_name(f, "artist", value);
}
-int32_t mp4ff_meta_get_title(const struct mp4ff *f, char **value)
+int32_t mp4_meta_get_title(const struct mp4 *f, char **value)
{
return meta_find_by_name(f, "title", value);
}
-int32_t mp4ff_meta_get_date(const struct mp4ff *f, char **value)
+int32_t mp4_meta_get_date(const struct mp4 *f, char **value)
{
return meta_find_by_name(f, "date", value);
}
-int32_t mp4ff_meta_get_album(const struct mp4ff *f, char **value)
+int32_t mp4_meta_get_album(const struct mp4 *f, char **value)
{
return meta_find_by_name(f, "album", value);
}
-int32_t mp4ff_meta_get_comment(const struct mp4ff *f, char **value)
+int32_t mp4_meta_get_comment(const struct mp4 *f, char **value)
{
return meta_find_by_name(f, "comment", value);
}
-struct mp4ff_callback {
+struct mp4_callback {
uint32_t (*read)(void *user_data, void *buffer, uint32_t length);
uint32_t (*write)(void *udata, void *buffer, uint32_t length);
uint32_t (*seek)(void *user_data, uint64_t position);
uint32_t read_error;
};
-struct mp4ff_tag {
+struct mp4_tag {
char *item;
char *value;
uint32_t len;
};
-struct mp4ff_metadata {
- struct mp4ff_tag *tags;
+struct mp4_metadata {
+ struct mp4_tag *tags;
uint32_t count;
};
-struct mp4ff; /* opaque */
+struct mp4; /* opaque */
-void mp4ff_set_sample_position(struct mp4ff *f, int32_t track, int32_t sample);
-int32_t mp4ff_total_tracks(const struct mp4ff *f);
-void mp4ff_get_decoder_config(const struct mp4ff *f, int track,
+void mp4_set_sample_position(struct mp4 *f, int32_t track, int32_t sample);
+int32_t mp4_total_tracks(const struct mp4 *f);
+void mp4_get_decoder_config(const struct mp4 *f, int track,
unsigned char** ppBuf, unsigned int* pBufSize);
-struct mp4ff *mp4ff_open_read(struct mp4ff_callback *f);
-void mp4ff_close(struct mp4ff *f);
-int32_t mp4ff_get_sample_size(const struct mp4ff *f, int track, int sample);
-uint32_t mp4ff_get_sample_rate(const struct mp4ff *f, int32_t track);
-uint32_t mp4ff_get_channel_count(const struct mp4ff * f, int32_t track);
-int32_t mp4ff_num_samples(const struct mp4ff *f, int track);
-uint64_t mp4ff_get_duration(const struct mp4ff *f, int32_t track);
-struct mp4ff *mp4ff_open_meta(struct mp4ff_callback *f);
+struct mp4 *mp4_open_read(struct mp4_callback *f);
+void mp4_close(struct mp4 *f);
+int32_t mp4_get_sample_size(const struct mp4 *f, int track, int sample);
+uint32_t mp4_get_sample_rate(const struct mp4 *f, int32_t track);
+uint32_t mp4_get_channel_count(const struct mp4 * f, int32_t track);
+int32_t mp4_num_samples(const struct mp4 *f, int track);
+uint64_t mp4_get_duration(const struct mp4 *f, int32_t track);
+struct mp4 *mp4_open_meta(struct mp4_callback *f);
-int mp4ff_meta_get_by_index(const struct mp4ff *f, unsigned int index,
+int mp4_meta_get_by_index(const struct mp4 *f, unsigned int index,
char **item, char **value);
-int32_t mp4ff_meta_update(struct mp4ff_callback *f,const struct mp4ff_metadata * data);
+int32_t mp4_meta_update(struct mp4_callback *f,const struct mp4_metadata * data);
-int mp4ff_meta_get_num_items(const struct mp4ff *f);
-int mp4ff_meta_get_artist(const struct mp4ff *f, char **value);
-int mp4ff_meta_get_title(const struct mp4ff *f, char **value);
-int mp4ff_meta_get_date(const struct mp4ff *f, char **value);
-int mp4ff_meta_get_album(const struct mp4ff *f, char **value);
-int mp4ff_meta_get_comment(const struct mp4ff *f, char **value);
+int mp4_meta_get_num_items(const struct mp4 *f);
+int mp4_meta_get_artist(const struct mp4 *f, char **value);
+int mp4_meta_get_title(const struct mp4 *f, char **value);
+int mp4_meta_get_date(const struct mp4 *f, char **value);
+int mp4_meta_get_album(const struct mp4 *f, char **value);
+int mp4_meta_get_comment(const struct mp4 *f, char **value);