|
Packit |
971217 |
/* GStreamer
|
|
Packit |
971217 |
* Copyright (C) 2004 Wim Taymans <wim@fluendo.com>
|
|
Packit |
971217 |
*
|
|
Packit |
971217 |
* gstoggdemux.c: ogg stream demuxer
|
|
Packit |
971217 |
*
|
|
Packit |
971217 |
* This library is free software; you can redistribute it and/or
|
|
Packit |
971217 |
* modify it under the terms of the GNU Library General Public
|
|
Packit |
971217 |
* License as published by the Free Software Foundation; either
|
|
Packit |
971217 |
* version 2 of the License, or (at your option) any later version.
|
|
Packit |
971217 |
*
|
|
Packit |
971217 |
* This library is distributed in the hope that it will be useful,
|
|
Packit |
971217 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
971217 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
971217 |
* Library General Public License for more details.
|
|
Packit |
971217 |
*
|
|
Packit |
971217 |
* You should have received a copy of the GNU Library General Public
|
|
Packit |
971217 |
* License along with this library; if not, write to the
|
|
Packit |
971217 |
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
Packit |
971217 |
* Boston, MA 02110-1301, USA.
|
|
Packit |
971217 |
*/
|
|
Packit |
971217 |
|
|
Packit |
971217 |
#ifndef __GST_OGG_DEMUX_H__
|
|
Packit |
971217 |
#define __GST_OGG_DEMUX_H__
|
|
Packit |
971217 |
|
|
Packit |
971217 |
#include <ogg/ogg.h>
|
|
Packit |
971217 |
|
|
Packit |
971217 |
#include <gst/gst.h>
|
|
Packit |
971217 |
#include <gst/base/gstflowcombiner.h>
|
|
Packit |
971217 |
|
|
Packit |
971217 |
#include "gstoggstream.h"
|
|
Packit |
971217 |
|
|
Packit |
971217 |
G_BEGIN_DECLS
|
|
Packit |
971217 |
|
|
Packit |
971217 |
#define GST_TYPE_OGG_PAD (gst_ogg_pad_get_type())
|
|
Packit |
971217 |
#define GST_OGG_PAD(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OGG_PAD, GstOggPad))
|
|
Packit |
971217 |
#define GST_OGG_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OGG_PAD, GstOggPad))
|
|
Packit |
971217 |
#define GST_IS_OGG_PAD(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OGG_PAD))
|
|
Packit |
971217 |
#define GST_IS_OGG_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OGG_PAD))
|
|
Packit |
971217 |
|
|
Packit |
971217 |
typedef struct _GstOggPad GstOggPad;
|
|
Packit |
971217 |
typedef struct _GstOggPadClass GstOggPadClass;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
#define GST_TYPE_OGG_DEMUX (gst_ogg_demux_get_type())
|
|
Packit |
971217 |
#define GST_OGG_DEMUX(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OGG_DEMUX, GstOggDemux))
|
|
Packit |
971217 |
#define GST_OGG_DEMUX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OGG_DEMUX, GstOggDemux))
|
|
Packit |
971217 |
#define GST_IS_OGG_DEMUX(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OGG_DEMUX))
|
|
Packit |
971217 |
#define GST_IS_OGG_DEMUX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OGG_DEMUX))
|
|
Packit |
971217 |
|
|
Packit |
971217 |
GType gst_ogg_demux_get_type (void);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
typedef struct _GstOggDemux GstOggDemux;
|
|
Packit |
971217 |
typedef struct _GstOggDemuxClass GstOggDemuxClass;
|
|
Packit |
971217 |
typedef struct _GstOggChain GstOggChain;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
/* all information needed for one ogg chain (relevant for chained bitstreams) */
|
|
Packit |
971217 |
struct _GstOggChain
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
GstOggDemux *ogg;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
gint64 offset; /* starting offset of chain */
|
|
Packit |
971217 |
gint64 end_offset; /* end offset of chain */
|
|
Packit |
971217 |
gint64 bytes; /* number of bytes */
|
|
Packit |
971217 |
|
|
Packit |
971217 |
gboolean have_bos;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
GArray *streams;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
GstClockTime total_time; /* the total time of this chain, this is the MAX of
|
|
Packit |
971217 |
the totals of all streams */
|
|
Packit |
971217 |
GstClockTime begin_time; /* when this chain starts in the stream */
|
|
Packit |
971217 |
|
|
Packit |
971217 |
GstClockTime segment_start; /* the timestamp of the first sample, this is the MIN of
|
|
Packit |
971217 |
the start times of all streams. */
|
|
Packit |
971217 |
GstClockTime segment_stop; /* the timestamp of the last page, this is the MAX of the
|
|
Packit |
971217 |
streams. */
|
|
Packit |
971217 |
};
|
|
Packit |
971217 |
|
|
Packit |
971217 |
/* all information needed for one ogg stream */
|
|
Packit |
971217 |
struct _GstOggPad
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
GstPad pad; /* subclass GstPad */
|
|
Packit |
971217 |
|
|
Packit |
971217 |
gboolean have_type;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
GstOggChain *chain; /* the chain we are part of */
|
|
Packit |
971217 |
GstOggDemux *ogg; /* the ogg demuxer we are part of */
|
|
Packit |
971217 |
|
|
Packit |
971217 |
GstOggStream map;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
gint64 packetno;
|
|
Packit |
971217 |
gint64 current_granule;
|
|
Packit |
971217 |
gint64 prev_granule;
|
|
Packit |
971217 |
gint64 keyframe_granule;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
GstClockTime start_time; /* the timestamp of the first sample */
|
|
Packit |
971217 |
|
|
Packit |
971217 |
gint64 first_granule; /* the granulepos of first page == first sample in next page */
|
|
Packit |
971217 |
GstClockTime first_time; /* the timestamp of the second page or granuletime of first page */
|
|
Packit |
971217 |
|
|
Packit |
971217 |
GstClockTime position; /* position when last push occured; used to detect when we
|
|
Packit |
971217 |
* need to send a newsegment update event for sparse streams */
|
|
Packit |
971217 |
|
|
Packit |
971217 |
GList *continued;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
gboolean discont;
|
|
Packit |
971217 |
GstFlowReturn last_ret; /* last return of _pad_push() */
|
|
Packit |
971217 |
gboolean is_eos;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
gboolean added;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
/* push mode seeking */
|
|
Packit |
971217 |
GstClockTime push_kf_time;
|
|
Packit |
971217 |
GstClockTime push_sync_time;
|
|
Packit |
971217 |
};
|
|
Packit |
971217 |
|
|
Packit |
971217 |
struct _GstOggPadClass
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
GstPadClass parent_class;
|
|
Packit |
971217 |
};
|
|
Packit |
971217 |
|
|
Packit |
971217 |
/**
|
|
Packit |
971217 |
* GstOggDemux:
|
|
Packit |
971217 |
*
|
|
Packit |
971217 |
* The ogg demuxer object structure.
|
|
Packit |
971217 |
*/
|
|
Packit |
971217 |
struct _GstOggDemux
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
GstElement element;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
GstPad *sinkpad;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
GstFlowCombiner *flowcombiner;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
gint64 length;
|
|
Packit |
971217 |
gint64 read_offset;
|
|
Packit |
971217 |
gint64 offset;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
gboolean pullmode;
|
|
Packit |
971217 |
gboolean running;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
gboolean have_group_id;
|
|
Packit |
971217 |
guint group_id;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
gboolean need_chains;
|
|
Packit |
971217 |
gboolean resync;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
/* keep track of how large pages and packets are,
|
|
Packit |
971217 |
useful for skewing when seeking */
|
|
Packit |
971217 |
guint64 max_packet_size, max_page_size;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
gboolean check_index_overflow;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
/* state */
|
|
Packit |
971217 |
GMutex chain_lock; /* we need the lock to protect the chains */
|
|
Packit |
971217 |
GArray *chains; /* list of chains we know */
|
|
Packit |
971217 |
GstClockTime total_time;
|
|
Packit |
971217 |
gint bitrate; /* bitrate of the current chain */
|
|
Packit |
971217 |
|
|
Packit |
971217 |
GstOggChain *current_chain;
|
|
Packit |
971217 |
GstOggChain *building_chain;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
/* playback start/stop positions */
|
|
Packit |
971217 |
GstSegment segment;
|
|
Packit |
971217 |
guint32 seqnum;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
GstEvent *newsegment; /* pending newsegment to be sent from _loop */
|
|
Packit |
971217 |
|
|
Packit |
971217 |
/* annodex stuff */
|
|
Packit |
971217 |
gint64 basetime;
|
|
Packit |
971217 |
gint64 prestime;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
/* push mode seeking support */
|
|
Packit |
971217 |
GMutex push_lock; /* we need the lock to protect the push mode variables */
|
|
Packit |
971217 |
gint64 push_byte_offset; /* where were are at in the stream, in bytes */
|
|
Packit |
971217 |
gint64 push_byte_length; /* length in bytes of the stream, -1 if unknown */
|
|
Packit |
971217 |
GstClockTime push_time_length; /* length in time of the stream */
|
|
Packit |
971217 |
GstClockTime push_start_time; /* start time of the stream */
|
|
Packit |
971217 |
GstClockTime push_time_offset; /* where were are at in the stream, in time */
|
|
Packit |
971217 |
enum { PUSH_PLAYING, PUSH_DURATION, PUSH_BISECT1, PUSH_LINEAR1, PUSH_BISECT2, PUSH_LINEAR2 } push_state;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
GstClockTime push_seek_time_original_target;
|
|
Packit |
971217 |
GstClockTime push_seek_time_original_stop;
|
|
Packit |
971217 |
GstClockTime push_seek_time_target;
|
|
Packit |
971217 |
gint64 push_last_seek_offset;
|
|
Packit |
971217 |
GstClockTime push_last_seek_time;
|
|
Packit |
971217 |
gint64 push_offset0, push_offset1; /* bisection search offset bounds */
|
|
Packit |
971217 |
GstClockTime push_time0, push_time1; /* bisection search time bounds */
|
|
Packit |
971217 |
|
|
Packit |
971217 |
double push_seek_rate;
|
|
Packit |
971217 |
GstSeekFlags push_seek_flags;
|
|
Packit |
971217 |
GstEvent *push_mode_seek_delayed_event;
|
|
Packit |
971217 |
gboolean push_disable_seeking;
|
|
Packit |
971217 |
gboolean seek_secant;
|
|
Packit |
971217 |
gboolean seek_undershot;
|
|
Packit |
971217 |
GstClockTime push_prev_seek_time;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
gint push_bisection_steps[2];
|
|
Packit |
971217 |
gint stats_bisection_steps[2];
|
|
Packit |
971217 |
gint stats_bisection_max_steps[2];
|
|
Packit |
971217 |
gint stats_nbisections;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
/* ogg stuff */
|
|
Packit |
971217 |
ogg_sync_state sync;
|
|
Packit |
971217 |
long chunk_size;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
/* Seek events set up by the streaming thread in push mode */
|
|
Packit |
971217 |
GstEvent *seek_event;
|
|
Packit |
971217 |
GThread *seek_event_thread;
|
|
Packit |
971217 |
GMutex seek_event_mutex;
|
|
Packit |
971217 |
GCond seek_event_cond;
|
|
Packit |
971217 |
gboolean seek_event_thread_stop;
|
|
Packit |
971217 |
gboolean seek_thread_started;
|
|
Packit |
971217 |
GCond thread_started_cond;
|
|
Packit |
971217 |
guint32 seek_event_drop_till;
|
|
Packit |
971217 |
};
|
|
Packit |
971217 |
|
|
Packit |
971217 |
struct _GstOggDemuxClass
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
GstElementClass parent_class;
|
|
Packit |
971217 |
};
|
|
Packit |
971217 |
|
|
Packit |
971217 |
gboolean gst_ogg_demux_plugin_init (GstPlugin * plugin);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
G_END_DECLS
|
|
Packit |
971217 |
|
|
Packit |
971217 |
#endif /* __GST_OGG_DEMUX_H__ */
|