[vlc-devel] [PATCH 3/5] demux/mp4: move some stuff in a header file

Frédéric Yhuel fyhuel at viotech.net
Wed Apr 11 11:40:04 CEST 2012


I need to include mp4_track_t definition in my Smooth Streaming module
---
 modules/demux/mp4/Modules.am |    1 +
 modules/demux/mp4/mp4.c      |  109 +-----------------------------------
 modules/demux/mp4/mp4.h      |  130 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 132 insertions(+), 108 deletions(-)
 create mode 100644 modules/demux/mp4/mp4.h

diff --git a/modules/demux/mp4/Modules.am b/modules/demux/mp4/Modules.am
index e9fa0b7..c4d7167 100644
--- a/modules/demux/mp4/Modules.am
+++ b/modules/demux/mp4/Modules.am
@@ -1,5 +1,6 @@
 SOURCES_mp4 = \
 	mp4.c \
+	mp4.h \
 	libmp4.c \
 	libmp4.h \
 	id3genres.h \
diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c
index 8faba8e..cd63051 100644
--- a/modules/demux/mp4/mp4.c
+++ b/modules/demux/mp4/mp4.c
@@ -28,15 +28,7 @@
 # include "config.h"
 #endif
 
-#include <vlc_common.h>
-#include <vlc_plugin.h>
-
-#include <vlc_demux.h>
-#include <vlc_charset.h>                           /* EnsureUTF8 */
-#include <vlc_meta.h>                              /* vlc_meta_t, vlc_meta_ */
-#include <vlc_input.h>
-
-#include "libmp4.h"
+#include "mp4.h"
 #include "id3genres.h"                             /* for ATOM_gnre */
 
 /*****************************************************************************
@@ -62,105 +54,6 @@ static int   DemuxRef( demux_t *p_demux ){ (void)p_demux; return 0;}
 static int   Seek    ( demux_t *, mtime_t );
 static int   Control ( demux_t *, int, va_list );
 
-/* Contain all information about a chunk */
-typedef struct
-{
-    uint64_t     i_offset; /* absolute position of this chunk in the file */
-    uint32_t     i_sample_description_index; /* index for SampleEntry to use */
-    uint32_t     i_sample_count; /* how many samples in this chunk */
-    uint32_t     i_sample_first; /* index of the first sample in this chunk */
-
-    /* now provide way to calculate pts, dts, and offset without too
-        much memory and with fast access */
-
-    /* with this we can calculate dts/pts without waste memory */
-    uint64_t     i_first_dts;   /* DTS of the first sample */
-    uint64_t     i_last_dts;    /* DTS of the last sample */
-    uint32_t     *p_sample_count_dts;
-    uint32_t     *p_sample_delta_dts;   /* dts delta */
-
-    uint32_t     *p_sample_count_pts;
-    int32_t      *p_sample_offset_pts;  /* pts-dts */
-
-    /* TODO if needed add pts
-        but quickly *add* support for edts and seeking */
-
-} mp4_chunk_t;
-
- /* Contain all needed information for read all track with vlc */
-typedef struct
-{
-    unsigned int i_track_ID;/* this should be unique */
-
-    int b_ok;               /* The track is usable */
-    int b_enable;           /* is the trak enable by default */
-    bool b_selected;  /* is the trak being played */
-    bool b_chapter;   /* True when used for chapter only */
-
-    bool b_mac_encoding;
-
-    es_format_t fmt;
-    es_out_id_t *p_es;
-
-    /* display size only ! */
-    int i_width;
-    int i_height;
-    float f_rotation;
-
-    /* more internal data */
-    uint64_t        i_timescale;    /* time scale for this track only */
-
-    /* elst */
-    int             i_elst;         /* current elst */
-    int64_t         i_elst_time;    /* current elst start time (in movie time scale)*/
-    MP4_Box_t       *p_elst;        /* elst (could be NULL) */
-
-    /* give the next sample to read, i_chunk is to find quickly where
-      the sample is located */
-    uint32_t         i_sample;       /* next sample to read */
-    uint32_t         i_chunk;        /* chunk where next sample is stored */
-    /* total count of chunk and sample */
-    uint32_t         i_chunk_count;
-    uint32_t         i_sample_count;
-
-    mp4_chunk_t    *chunk; /* always defined  for each chunk */
-
-    /* sample size, p_sample_size defined only if i_sample_size == 0
-        else i_sample_size is size for all sample */
-    uint32_t         i_sample_size;
-    uint32_t         *p_sample_size; /* XXX perhaps add file offset if take
-                                    too much time to do sumations each time*/
-
-    MP4_Box_t *p_stbl;  /* will contain all timing information */
-    MP4_Box_t *p_stsd;  /* will contain all data to initialize decoder */
-    MP4_Box_t *p_sample;/* point on actual sdsd */
-
-    MP4_Box_t *p_skcr;
-
-} mp4_track_t;
-
-
-struct demux_sys_t
-{
-    MP4_Box_t    *p_root;      /* container for the whole file */
-
-    mtime_t      i_pcr;
-
-    uint64_t     i_time;         /* time position of the presentation
-                                  * in movie timescale */
-    uint64_t     i_timescale;    /* movie time scale */
-    uint64_t     i_duration;     /* movie duration */
-    unsigned int i_tracks;       /* number of tracks */
-    mp4_track_t  *track;         /* array of track */
-    float        f_fps;          /* number of frame per seconds */
-
-    /* */
-    MP4_Box_t    *p_tref_chap;
-
-    /* */
-    input_title_t *p_title;
-};
-
 /*****************************************************************************
  * Declaration of local function
  *****************************************************************************/
diff --git a/modules/demux/mp4/mp4.h b/modules/demux/mp4/mp4.h
new file mode 100644
index 0000000..e0356df
--- /dev/null
+++ b/modules/demux/mp4/mp4.h
@@ -0,0 +1,130 @@
+#ifndef _MP4_H
+#define _MP4_H 1
+
+#include <assert.h>
+#include <vlc_demux.h>
+#include <vlc_common.h>
+#include <vlc_plugin.h>
+
+#include <vlc_charset.h>                           /* EnsureUTF8 */
+#include <vlc_meta.h>                              /* vlc_meta_t, vlc_meta_ */
+#include <vlc_input.h>
+#include <vlc_modules.h>
+#include "libmp4.h"
+
+
+/* Contain all information about a chunk */
+typedef struct
+{
+    uint64_t     i_offset; /* absolute position of this chunk in the file */
+    uint32_t     i_sample_description_index; /* index for SampleEntry to use */
+    uint32_t     i_sample_count; /* how many samples in this chunk */
+    uint32_t     i_sample_first; /* index of the first sample in this chunk */
+    uint32_t     i_sample; /* index of the next sample to read in this chunk */
+
+    /* now provide way to calculate pts, dts, and offset without too
+        much memory and with fast access */
+
+    /* with this we can calculate dts/pts without waste memory */
+    uint64_t     i_first_dts;   /* DTS of the first sample */
+    uint64_t     i_last_dts;    /* DTS of the last sample */
+    uint32_t     *p_sample_count_dts;
+    uint32_t     *p_sample_delta_dts;   /* dts delta */
+
+    uint32_t     *p_sample_count_pts;
+    int32_t      *p_sample_offset_pts;  /* pts-dts */
+
+    uint8_t      **p_sample_data;     /* set when b_fragmented is true */
+    uint32_t     *p_sample_size;
+    /* TODO if needed add pts
+        but quickly *add* support for edts and seeking */
+
+} mp4_chunk_t;
+
+ /* Contain all needed information for read all track with vlc */
+typedef struct
+{
+    unsigned int i_track_ID;/* this should be unique */
+
+    int b_ok;               /* The track is usable */
+    int b_enable;           /* is the trak enable by default */
+    bool b_selected;  /* is the trak being played */
+    bool b_chapter;   /* True when used for chapter only */
+
+    bool b_mac_encoding;
+
+    es_format_t fmt;
+    es_out_id_t *p_es;
+
+    /* display size only ! */
+    int i_width;
+    int i_height;
+    float f_rotation;
+
+    /* more internal data */
+    uint64_t        i_timescale;    /* time scale for this track only */
+    uint16_t        current_qid;    /* Smooth Streaming quality level ID */
+
+    /* elst */
+    int             i_elst;         /* current elst */
+    int64_t         i_elst_time;    /* current elst start time (in movie time scale)*/
+    MP4_Box_t       *p_elst;        /* elst (could be NULL) */
+
+    /* give the next sample to read, i_chunk is to find quickly where
+      the sample is located */
+    uint32_t         i_sample;       /* next sample to read */
+    uint32_t         i_chunk;        /* chunk where next sample is stored */
+    /* total count of chunk and sample */
+    uint32_t         i_chunk_count;
+    uint32_t         i_sample_count;
+
+    mp4_chunk_t    *chunk; /* always defined  for each chunk */
+    mp4_chunk_t    *cchunk; /* current chunk if b_fragmented is true */
+
+    /* sample size, p_sample_size defined only if i_sample_size == 0
+        else i_sample_size is size for all sample */
+    uint32_t         i_sample_size;
+    uint32_t         *p_sample_size; /* XXX perhaps add file offset if take
+                                    too much time to do sumations each time*/
+
+    uint32_t     i_sample_first; /* i_sample_first value
+                                                   of the next chunk */
+    uint64_t     i_first_dts;    /* i_first_dts value
+                                                   of the next chunk */
+
+    MP4_Box_t *p_stbl;  /* will contain all timing information */
+    MP4_Box_t *p_stsd;  /* will contain all data to initialize decoder */
+    MP4_Box_t *p_sample;/* point on actual sdsd */
+
+    bool b_drms;
+    bool b_end_of_chunk;
+    void      *p_drms;
+    MP4_Box_t *p_skcr;
+
+} mp4_track_t;
+
+struct demux_sys_t
+{
+    MP4_Box_t    *p_root;      /* container for the whole file */
+
+    mtime_t      i_pcr;
+
+    uint64_t     i_time;         /* time position of the presentation
+                                    in movie timescale */
+    uint64_t     i_timescale;    /* movie time scale */
+    uint64_t     i_duration;     /* movie duration */
+    unsigned int i_tracks;       /* number of tracks */
+    mp4_track_t  *track;         /* array of track */
+    float        f_fps;          /* number of frame per seconds */
+
+    bool         b_smooth;       /* Smooth Streaming => no moov box */
+    bool         b_dash;         /* DASH */
+    bool         b_fragmented;   /* fMP4 */
+
+    /* */
+    MP4_Box_t    *p_tref_chap;
+
+    /* */
+    input_title_t *p_title;
+};
+#endif
-- 
1.7.5.4




More information about the vlc-devel mailing list