Mercurial > mplayer.hg
changeset 25657:dfeb8ea2a7a8
Add demuxer interface for attachments.
author | eugeni |
---|---|
date | Sat, 12 Jan 2008 01:12:36 +0000 |
parents | 00e4d59a0be4 |
children | 0d0c48ecba90 |
files | libmpdemux/demuxer.c libmpdemux/demuxer.h |
diffstat | 2 files changed, 36 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libmpdemux/demuxer.c Fri Jan 11 21:45:20 2008 +0000 +++ b/libmpdemux/demuxer.c Sat Jan 12 01:12:36 2008 +0000 @@ -339,6 +339,14 @@ free(demuxer->chapters[i].name); free(demuxer->chapters); } + if (demuxer->attachments) { + for (i=0; i<demuxer->num_attachments; i++) { + free(demuxer->attachments[i].name); + free(demuxer->attachments[i].type); + free(demuxer->attachments[i].data); + } + free(demuxer->attachments); + } free(demuxer); } @@ -1122,6 +1130,20 @@ return index; } +int demuxer_add_attachment(demuxer_t* demuxer, const char* name, + const char* type, const void* data, size_t size) { + if (!(demuxer->num_attachments & 31)) + demuxer->attachments = realloc(demuxer->attachments, (demuxer->num_attachments + 32) * sizeof(demux_attachment_t)); + + demuxer->attachments[demuxer->num_attachments].name = strdup(name); + demuxer->attachments[demuxer->num_attachments].type = strdup(type); + demuxer->attachments[demuxer->num_attachments].data = malloc(size); + memcpy(demuxer->attachments[demuxer->num_attachments].data, data, size); + demuxer->attachments[demuxer->num_attachments].data_size = size; + + return demuxer->num_attachments ++; +} + int demuxer_add_chapter(demuxer_t* demuxer, const char* name, uint64_t start, uint64_t end){ if (demuxer->chapters == NULL) demuxer->chapters = malloc (32*sizeof(*demuxer->chapters));
--- a/libmpdemux/demuxer.h Fri Jan 11 21:45:20 2008 +0000 +++ b/libmpdemux/demuxer.h Sat Jan 12 01:12:36 2008 +0000 @@ -174,6 +174,14 @@ char* name; } demux_chapter_t; +typedef struct demux_attachment_s +{ + char* name; + char* type; + void* data; + unsigned int data_size; +} demux_attachment_t; + typedef struct demuxer_st { demuxer_desc_t *desc; ///< Demuxer description structure off_t filepos; // input stream current pos. @@ -199,6 +207,9 @@ demux_chapter_t* chapters; int num_chapters; + demux_attachment_t* attachments; + int num_attachments; + void* priv; // fileformat-dependent data char** info; } demuxer_t; @@ -384,6 +395,9 @@ extern void demuxer_help(void); extern int get_demuxer_type_from_name(char *demuxer_name, int *force); +int demuxer_add_attachment(demuxer_t* demuxer, const char* name, + const char* type, const void* data, size_t size); + int demuxer_add_chapter(demuxer_t* demuxer, const char* name, uint64_t start, uint64_t end); int demuxer_seek_chapter(demuxer_t *demuxer, int chapter, int mode, float *seek_pts, int *num_chapters, char **chapter_name);