gst_plugins_base/ext/ogg/gstoggdemux.h
branchRCL_3
changeset 30 7e817e7e631c
parent 0 0e761a78d257
equal deleted inserted replaced
29:567bb019e3e3 30:7e817e7e631c
       
     1 /* GStreamer
       
     2  * Copyright (C) 2004 Wim Taymans <wim@fluendo.com>
       
     3  *
       
     4  * gstoggdemux.c: ogg stream demuxer
       
     5  *
       
     6  * This library is free software; you can redistribute it and/or
       
     7  * modify it under the terms of the GNU Library General Public
       
     8  * License as published by the Free Software Foundation; either
       
     9  * version 2 of the License, or (at your option) any later version.
       
    10  *
       
    11  * This library is distributed in the hope that it will be useful,
       
    12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       
    14  * Library General Public License for more details.
       
    15  *
       
    16  * You should have received a copy of the GNU Library General Public
       
    17  * License along with this library; if not, write to the
       
    18  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
       
    19  * Boston, MA 02111-1307, USA.
       
    20  */
       
    21 
       
    22 #ifndef __GST_OGG_DEMUX_H__
       
    23 #define __GST_OGG_DEMUX_H__
       
    24 
       
    25 #include <ogg/ogg.h>
       
    26 
       
    27 #include <gst/gst.h>
       
    28 
       
    29 G_BEGIN_DECLS
       
    30 
       
    31 #define GST_TYPE_OGG_PAD (gst_ogg_pad_get_type())
       
    32 #define GST_OGG_PAD(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OGG_PAD, GstOggPad))
       
    33 #define GST_OGG_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OGG_PAD, GstOggPad))
       
    34 #define GST_IS_OGG_PAD(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OGG_PAD))
       
    35 #define GST_IS_OGG_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OGG_PAD))
       
    36 
       
    37 typedef struct _GstOggPad GstOggPad;
       
    38 typedef struct _GstOggPadClass GstOggPadClass;
       
    39 
       
    40 #define GST_TYPE_OGG_DEMUX (gst_ogg_demux_get_type())
       
    41 #define GST_OGG_DEMUX(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OGG_DEMUX, GstOggDemux))
       
    42 #define GST_OGG_DEMUX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OGG_DEMUX, GstOggDemux))
       
    43 #define GST_IS_OGG_DEMUX(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OGG_DEMUX))
       
    44 #define GST_IS_OGG_DEMUX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OGG_DEMUX))
       
    45 
       
    46 static GType gst_ogg_demux_get_type (void);
       
    47 
       
    48 typedef struct _GstOggDemux GstOggDemux;
       
    49 typedef struct _GstOggDemuxClass GstOggDemuxClass;
       
    50 typedef struct _GstOggChain GstOggChain;
       
    51 
       
    52 /* all information needed for one ogg chain (relevant for chained bitstreams) */
       
    53 struct _GstOggChain
       
    54 {
       
    55   GstOggDemux *ogg;
       
    56 
       
    57   gint64 offset;                /* starting offset of chain */
       
    58   gint64 end_offset;            /* end offset of chain */
       
    59   gint64 bytes;                 /* number of bytes */
       
    60 
       
    61   gboolean have_bos;
       
    62 
       
    63   GArray *streams;
       
    64 
       
    65   GstClockTime total_time;      /* the total time of this chain, this is the MAX of
       
    66                                    the totals of all streams */
       
    67   GstClockTime begin_time;      /* when this chain starts in the stream */
       
    68 
       
    69   GstClockTime segment_start;   /* the timestamp of the first sample, this is the MIN of
       
    70                                    the start times of all streams. */
       
    71   GstClockTime segment_stop;    /* the timestamp of the last page, this is the MAX of the
       
    72                                    streams. */
       
    73 };
       
    74 
       
    75 /* different modes for the pad */
       
    76 typedef enum
       
    77 {
       
    78   GST_OGG_PAD_MODE_INIT,        /* we are feeding our internal decoder to get info */
       
    79   GST_OGG_PAD_MODE_STREAMING,   /* we are streaming buffers to the outside */
       
    80 } GstOggPadMode;
       
    81 
       
    82 /* all information needed for one ogg stream */
       
    83 struct _GstOggPad
       
    84 {
       
    85   GstPad pad;                   /* subclass GstPad */
       
    86 
       
    87   gboolean have_type;
       
    88   GstOggPadMode mode;
       
    89 
       
    90   GstPad *elem_pad;             /* sinkpad of internal element */
       
    91   GstElement *element;          /* internal element */
       
    92   GstPad *elem_out;             /* our sinkpad to receive buffers form the internal element */
       
    93 
       
    94   GstOggChain *chain;           /* the chain we are part of */
       
    95   GstOggDemux *ogg;             /* the ogg demuxer we are part of */
       
    96 
       
    97   GList *headers;
       
    98 
       
    99   gboolean is_skeleton;
       
   100   gboolean have_fisbone;
       
   101   gint64 granulerate_n;
       
   102   gint64 granulerate_d;
       
   103   guint32 preroll;
       
   104   guint granuleshift;
       
   105 
       
   106   gint serialno;
       
   107   gint64 packetno;
       
   108   gint64 current_granule;
       
   109 
       
   110   GstClockTime start_time;      /* the timestamp of the first sample */
       
   111 
       
   112   gint64 first_granule;         /* the granulepos of first page == first sample in next page */
       
   113   GstClockTime first_time;      /* the timestamp of the second page or granuletime of first page */
       
   114 
       
   115   ogg_stream_state stream;
       
   116   GList *continued;
       
   117 
       
   118   gboolean discont;
       
   119   GstFlowReturn last_ret;       /* last return of _pad_push() */
       
   120 
       
   121   gboolean dynamic;             /* True if the internal element had dynamic pads */
       
   122   guint padaddedid;             /* The signal id for element::pad-added */
       
   123 };
       
   124 
       
   125 struct _GstOggPadClass
       
   126 {
       
   127   GstPadClass parent_class;
       
   128 };
       
   129 
       
   130 #define GST_CHAIN_LOCK(ogg)     g_mutex_lock((ogg)->chain_lock)
       
   131 #define GST_CHAIN_UNLOCK(ogg)   g_mutex_unlock((ogg)->chain_lock)
       
   132 
       
   133 /**
       
   134  * GstOggDemux:
       
   135  *
       
   136  * The ogg demuxer object structure.
       
   137  */
       
   138 struct _GstOggDemux
       
   139 {
       
   140   GstElement element;
       
   141 
       
   142   GstPad *sinkpad;
       
   143 
       
   144   gint64 length;
       
   145   gint64 offset;
       
   146 
       
   147   gboolean seekable;
       
   148   gboolean running;
       
   149 
       
   150   gboolean need_chains;
       
   151 
       
   152   /* state */
       
   153   GMutex *chain_lock;           /* we need the lock to protect the chains */
       
   154   GArray *chains;               /* list of chains we know */
       
   155   GstClockTime total_time;
       
   156 
       
   157   GstOggChain *current_chain;
       
   158   GstOggChain *building_chain;
       
   159 
       
   160   /* playback start/stop positions */
       
   161   GstSegment segment;
       
   162   gboolean segment_running;
       
   163 
       
   164   GstEvent *event;
       
   165   GstEvent *newsegment;         /* pending newsegment to be sent from _loop */
       
   166 
       
   167   gint64 current_granule;
       
   168 
       
   169   /* annodex stuff */
       
   170   gboolean have_fishead;
       
   171   gint64 basetime;
       
   172 
       
   173   /* ogg stuff */
       
   174   ogg_sync_state sync;
       
   175 };
       
   176 
       
   177 struct _GstOggDemuxClass
       
   178 {
       
   179   GstElementClass parent_class;
       
   180 };
       
   181 
       
   182 G_END_DECLS
       
   183 
       
   184 #endif /* __GST_OGG_DEMUX_H__ */