gst_plugins_good/gst/avi/gstavidemux.h
changeset 27 d43ce56a1534
parent 23 29ecd5cb86b3
child 31 aec498aab1d3
equal deleted inserted replaced
23:29ecd5cb86b3 27:d43ce56a1534
     1 /* GStreamer
       
     2  * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
       
     3  * Copyright (C) <2006> Nokia Corporation (contact <stefan.kost@nokia.com>)
       
     4  *
       
     5  * This library is free software; you can redistribute it and/or
       
     6  * modify it under the terms of the GNU Library General Public
       
     7  * License as published by the Free Software Foundation; either
       
     8  * version 2 of the License, or (at your option) any later version.
       
     9  *
       
    10  * This library is distributed in the hope that it will be useful,
       
    11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       
    13  * Library General Public License for more details.
       
    14  *
       
    15  * You should have received a copy of the GNU Library General Public
       
    16  * License along with this library; if not, write to the
       
    17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
       
    18  * Boston, MA 02111-1307, USA.
       
    19  */
       
    20 
       
    21 #ifndef __GST_AVI_DEMUX_H__
       
    22 #define __GST_AVI_DEMUX_H__
       
    23 
       
    24 #include <gst/gst.h>
       
    25 
       
    26 #include "avi-ids.h"
       
    27 #include "gst/riff/riff-ids.h"
       
    28 #include "gst/riff/riff-read.h"
       
    29 #include <gst/base/gstadapter.h>
       
    30 
       
    31 G_BEGIN_DECLS
       
    32 
       
    33 #define GST_TYPE_AVI_DEMUX \
       
    34   (gst_avi_demux_get_type ())
       
    35 #define GST_AVI_DEMUX(obj) \
       
    36   (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_AVI_DEMUX, GstAviDemux))
       
    37 #define GST_AVI_DEMUX_CLASS(klass) \
       
    38   (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_AVI_DEMUX, GstAviDemuxClass))
       
    39 #define GST_IS_AVI_DEMUX(obj) \
       
    40   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_AVI_DEMUX))
       
    41 #define GST_IS_AVI_DEMUX_CLASS(klass) \
       
    42   (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_AVI_DEMUX))
       
    43 
       
    44 #define GST_AVI_DEMUX_MAX_STREAMS       16
       
    45 
       
    46 #define CHUNKID_TO_STREAMNR(chunkid) \
       
    47   ((((chunkid) & 0xff) - '0') * 10 + \
       
    48    (((chunkid) >> 8) & 0xff) - '0')
       
    49 
       
    50 #define GST_AVI_INDEX_ENTRY_FLAG_KEYFRAME 1
       
    51 
       
    52 /* 48 bytes */
       
    53 typedef struct {
       
    54   guint          index_nr;      /* = (entry-index_entries)/sizeof(gst_avi_index_entry); */
       
    55   guchar         stream_nr;
       
    56   guchar         flags;
       
    57   guint64        ts;
       
    58   guint64        dur;           /* =entry[1].ts-entry->ts */
       
    59   guint64        offset;
       
    60   guint64        bytes_before;  /* calculated */
       
    61   guint32        frames_before; /* calculated */
       
    62   guint32        size;          /* could be read from the chunk (if we don't split) */
       
    63 } gst_avi_index_entry;
       
    64 
       
    65 typedef struct {
       
    66   /* index of this streamcontext */
       
    67   guint          num;
       
    68 
       
    69   /* pad*/
       
    70   GstPad        *pad;
       
    71 
       
    72   /* stream info and headers */
       
    73   gst_riff_strh *strh;
       
    74   union {
       
    75     gst_riff_strf_vids *vids;
       
    76     gst_riff_strf_auds *auds;
       
    77     gst_riff_strf_iavs *iavs;
       
    78     gpointer     data;
       
    79   } strf;
       
    80   GstBuffer     *extradata, *initdata;
       
    81   gchar         *name;
       
    82 
       
    83   /* current position (byte, frame, time) and other status vars */
       
    84   guint          current_frame;
       
    85   guint64        current_byte;
       
    86   GstFlowReturn  last_flow;
       
    87   gboolean       discont;
       
    88 
       
    89   /* stream length */
       
    90   guint64        total_bytes;
       
    91   guint32        total_frames;
       
    92   guint32        total_blocks;
       
    93   /* stream length according to index */
       
    94   GstClockTime   idx_duration;
       
    95   /* stream length according to header */
       
    96   GstClockTime   hdr_duration;
       
    97   /* stream length based on header/index */
       
    98   GstClockTime   duration;
       
    99 
       
   100   /* VBR indicator */
       
   101   gboolean       is_vbr;
       
   102 
       
   103   /* openDML support (for files >4GB) */
       
   104   gboolean       superindex;
       
   105   guint64       *indexes;
       
   106 
       
   107   GstTagList	*taglist;
       
   108 } avi_stream_context;
       
   109 
       
   110 typedef enum {
       
   111   GST_AVI_DEMUX_START,
       
   112   GST_AVI_DEMUX_HEADER,
       
   113   GST_AVI_DEMUX_MOVI,
       
   114 } GstAviDemuxState;
       
   115 
       
   116 typedef enum {
       
   117   GST_AVI_DEMUX_HEADER_TAG_LIST,
       
   118   GST_AVI_DEMUX_HEADER_AVIH,
       
   119   GST_AVI_DEMUX_HEADER_ELEMENTS,
       
   120   GST_AVI_DEMUX_HEADER_INFO,
       
   121   GST_AVI_DEMUX_HEADER_JUNK,
       
   122   GST_AVI_DEMUX_HEADER_DATA
       
   123 } GstAviDemuxHeaderState;
       
   124 
       
   125 typedef struct _GstAviDemux {
       
   126   GstElement     parent;
       
   127 
       
   128   /* pads */
       
   129   GstPad        *sinkpad;
       
   130 
       
   131   /* AVI decoding state */
       
   132   GstAviDemuxState state;
       
   133   GstAviDemuxHeaderState header_state;
       
   134   guint64        offset;
       
   135 
       
   136   /* index */
       
   137   gst_avi_index_entry *index_entries;
       
   138   guint          index_size;
       
   139   guint64        index_offset;
       
   140   guint          current_entry;
       
   141   guint          reverse_start_index;
       
   142   guint          reverse_stop_index;
       
   143 
       
   144   /* streams */
       
   145   guint          num_streams;
       
   146   guint          num_v_streams;
       
   147   guint          num_a_streams;
       
   148   guint          num_t_streams;  /* subtitle text streams */
       
   149 
       
   150   avi_stream_context stream[GST_AVI_DEMUX_MAX_STREAMS];
       
   151 
       
   152   /* for streaming mode */
       
   153   gboolean      streaming;
       
   154   gboolean      have_eos;
       
   155   GstAdapter    *adapter;
       
   156 
       
   157   /* some stream info for length */
       
   158   gst_riff_avih *avih;
       
   159 
       
   160   /* segment in TIME */
       
   161   GstSegment     segment;
       
   162   gboolean       segment_running;
       
   163 
       
   164   /* pending tags/events */
       
   165   GstEvent      *seek_event;
       
   166   GstTagList	*globaltags;
       
   167   gboolean	got_tags;
       
   168 
       
   169 } GstAviDemux;
       
   170 
       
   171 typedef struct _GstAviDemuxClass {
       
   172   GstElementClass parent_class;
       
   173 } GstAviDemuxClass;
       
   174 
       
   175 GType           gst_avi_demux_get_type          (void);
       
   176 
       
   177 G_END_DECLS
       
   178 
       
   179 #endif /* __GST_AVI_DEMUX_H__ */