[MPlayer-cvslog] r25685 - in trunk/libmpdemux: demuxer.c demuxer.h

eugeni subversion at mplayerhq.hu
Sat Jan 12 02:12:37 CET 2008


Author: eugeni
Date: Sat Jan 12 02:12:36 2008
New Revision: 25685

Log:
Add demuxer interface for attachments.


Modified:
   trunk/libmpdemux/demuxer.c
   trunk/libmpdemux/demuxer.h

Modified: trunk/libmpdemux/demuxer.c
==============================================================================
--- trunk/libmpdemux/demuxer.c	(original)
+++ trunk/libmpdemux/demuxer.c	Sat Jan 12 02:12:36 2008
@@ -339,6 +339,14 @@ skip_streamfree:
           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 @@ int demuxer_switch_video(demuxer_t *demu
     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));

Modified: trunk/libmpdemux/demuxer.h
==============================================================================
--- trunk/libmpdemux/demuxer.h	(original)
+++ trunk/libmpdemux/demuxer.h	Sat Jan 12 02:12:36 2008
@@ -174,6 +174,14 @@ typedef struct demux_chapter_s
   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 @@ typedef struct demuxer_st {
   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 int demuxer_type_by_filename(char
 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);
 



More information about the MPlayer-cvslog mailing list