2011-05-23 15:06:44 +00:00
|
|
|
/* GStreamer Matroska muxer/demuxer
|
2011-05-23 17:46:04 +00:00
|
|
|
* (c) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
|
2011-05-23 15:06:44 +00:00
|
|
|
* (c) 2011 Debarshi Ray <rishi@gnu.org>
|
|
|
|
*
|
|
|
|
* matroska-read-common.h: shared by matroska file/stream demuxer and parser
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __GST_MATROSKA_READ_COMMON_H__
|
|
|
|
#define __GST_MATROSKA_READ_COMMON_H__
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
#include <gst/gst.h>
|
2011-05-23 15:06:44 +00:00
|
|
|
#include <gst/base/gstadapter.h>
|
2011-05-23 15:06:44 +00:00
|
|
|
|
2011-05-23 15:06:44 +00:00
|
|
|
#include "matroska-ids.h"
|
|
|
|
|
2011-05-23 15:06:44 +00:00
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
2011-08-03 12:50:05 +00:00
|
|
|
GST_DEBUG_CATEGORY_EXTERN(matroskareadcommon_debug);
|
|
|
|
|
2011-05-23 15:06:44 +00:00
|
|
|
typedef enum {
|
2011-05-23 15:48:57 +00:00
|
|
|
GST_MATROSKA_READ_STATE_START,
|
|
|
|
GST_MATROSKA_READ_STATE_SEGMENT,
|
|
|
|
GST_MATROSKA_READ_STATE_HEADER,
|
|
|
|
GST_MATROSKA_READ_STATE_DATA,
|
|
|
|
GST_MATROSKA_READ_STATE_SEEK,
|
|
|
|
GST_MATROSKA_READ_STATE_SCANNING
|
|
|
|
} GstMatroskaReadState;
|
2011-05-23 15:06:44 +00:00
|
|
|
|
|
|
|
typedef struct _GstMatroskaReadCommon {
|
2011-12-30 17:41:46 +00:00
|
|
|
#if 0
|
2011-05-23 15:06:44 +00:00
|
|
|
GstIndex *element_index;
|
|
|
|
gint element_index_writer_id;
|
2011-12-30 17:41:46 +00:00
|
|
|
#endif
|
2011-05-23 15:06:44 +00:00
|
|
|
|
|
|
|
/* pads */
|
2011-05-23 15:06:44 +00:00
|
|
|
GstPad *sinkpad;
|
2011-05-23 15:06:44 +00:00
|
|
|
GPtrArray *src;
|
|
|
|
guint num_streams;
|
|
|
|
|
2011-06-05 17:15:55 +00:00
|
|
|
/* metadata */
|
|
|
|
gchar *muxing_app;
|
|
|
|
gchar *writing_app;
|
|
|
|
gint64 created;
|
|
|
|
|
2011-05-23 15:48:57 +00:00
|
|
|
/* state */
|
|
|
|
GstMatroskaReadState state;
|
|
|
|
|
2011-05-23 15:06:44 +00:00
|
|
|
/* did we parse cues/tracks/segmentinfo already? */
|
|
|
|
gboolean index_parsed;
|
2011-06-05 17:15:55 +00:00
|
|
|
gboolean segmentinfo_parsed;
|
2011-06-06 09:17:27 +00:00
|
|
|
gboolean attachments_parsed;
|
2011-06-05 04:45:23 +00:00
|
|
|
GList *tags_parsed;
|
2011-05-23 15:06:44 +00:00
|
|
|
|
|
|
|
/* start-of-segment */
|
|
|
|
guint64 ebml_segment_start;
|
|
|
|
|
|
|
|
/* a cue (index) table */
|
|
|
|
GArray *index;
|
|
|
|
|
|
|
|
/* timescale in the file */
|
|
|
|
guint64 time_scale;
|
2011-05-23 15:06:44 +00:00
|
|
|
|
2011-06-05 17:15:55 +00:00
|
|
|
/* keeping track of playback position */
|
|
|
|
GstSegment segment;
|
|
|
|
|
2011-05-28 16:34:34 +00:00
|
|
|
GstTagList *global_tags;
|
|
|
|
|
2011-05-23 15:06:44 +00:00
|
|
|
/* pull mode caching */
|
|
|
|
GstBuffer *cached_buffer;
|
2011-11-26 09:01:07 +00:00
|
|
|
guint8 *cached_data;
|
2011-05-23 15:06:44 +00:00
|
|
|
|
|
|
|
/* push and pull mode */
|
|
|
|
guint64 offset;
|
2011-05-23 15:06:44 +00:00
|
|
|
|
|
|
|
/* push based mode usual suspects */
|
|
|
|
GstAdapter *adapter;
|
2011-05-23 15:06:44 +00:00
|
|
|
} GstMatroskaReadCommon;
|
|
|
|
|
2011-05-23 15:06:44 +00:00
|
|
|
GstFlowReturn gst_matroska_decode_content_encodings (GArray * encodings);
|
2011-11-26 09:01:07 +00:00
|
|
|
gboolean gst_matroska_decode_data (GArray * encodings, gpointer * data_out,
|
|
|
|
gsize * size_out, GstMatroskaTrackEncodingScope scope, gboolean free);
|
2011-05-28 05:29:09 +00:00
|
|
|
gint gst_matroska_index_seek_find (GstMatroskaIndex * i1, GstClockTime * time,
|
|
|
|
gpointer user_data);
|
|
|
|
GstMatroskaIndex * gst_matroska_read_common_do_index_seek (
|
|
|
|
GstMatroskaReadCommon * common, GstMatroskaTrackContext * track, gint64
|
|
|
|
seek_pos, GArray ** _index, gint * _entry_index);
|
2011-05-28 16:34:34 +00:00
|
|
|
void gst_matroska_read_common_found_global_tag (GstMatroskaReadCommon * common,
|
|
|
|
GstElement * el, GstTagList * taglist);
|
2011-05-27 14:00:48 +00:00
|
|
|
gint64 gst_matroska_read_common_get_length (GstMatroskaReadCommon * common);
|
2011-05-30 05:10:08 +00:00
|
|
|
GstMatroskaTrackContext * gst_matroska_read_common_get_seek_track (
|
|
|
|
GstMatroskaReadCommon * common, GstMatroskaTrackContext * track);
|
2011-05-23 15:06:44 +00:00
|
|
|
GstFlowReturn gst_matroska_read_common_parse_index (GstMatroskaReadCommon *
|
|
|
|
common, GstEbmlRead * ebml);
|
2011-06-05 17:15:55 +00:00
|
|
|
GstFlowReturn gst_matroska_read_common_parse_info (GstMatroskaReadCommon *
|
|
|
|
common, GstElement * el, GstEbmlRead * ebml);
|
2011-06-06 09:17:27 +00:00
|
|
|
GstFlowReturn gst_matroska_read_common_parse_attachments (
|
|
|
|
GstMatroskaReadCommon * common, GstElement * el, GstEbmlRead * ebml);
|
2011-06-06 12:51:04 +00:00
|
|
|
GstFlowReturn gst_matroska_read_common_parse_chapters (GstMatroskaReadCommon *
|
|
|
|
common, GstEbmlRead * ebml);
|
2011-05-30 13:01:50 +00:00
|
|
|
GstFlowReturn gst_matroska_read_common_parse_header (GstMatroskaReadCommon *
|
|
|
|
common, GstEbmlRead * ebml);
|
2011-06-05 04:45:23 +00:00
|
|
|
GstFlowReturn gst_matroska_read_common_parse_metadata (GstMatroskaReadCommon *
|
|
|
|
common, GstElement * el, GstEbmlRead * ebml);
|
2011-05-23 15:06:44 +00:00
|
|
|
GstFlowReturn gst_matroska_read_common_parse_skip (GstMatroskaReadCommon *
|
|
|
|
common, GstEbmlRead * ebml, const gchar * parent_name, guint id);
|
2011-05-23 15:06:44 +00:00
|
|
|
GstFlowReturn gst_matroska_read_common_peek_bytes (GstMatroskaReadCommon *
|
|
|
|
common, guint64 offset, guint size, GstBuffer ** p_buf, guint8 ** bytes);
|
2011-05-23 15:06:44 +00:00
|
|
|
GstFlowReturn gst_matroska_read_common_peek_id_length_pull (GstMatroskaReadCommon *
|
|
|
|
common, GstElement * el, guint32 * _id, guint64 * _length, guint *
|
|
|
|
_needed);
|
|
|
|
GstFlowReturn gst_matroska_read_common_peek_id_length_push (GstMatroskaReadCommon *
|
|
|
|
common, GstElement * el, guint32 * _id, guint64 * _length, guint *
|
|
|
|
_needed);
|
2011-05-23 15:06:44 +00:00
|
|
|
gint gst_matroska_read_common_stream_from_num (GstMatroskaReadCommon * common,
|
|
|
|
guint track_num);
|
2011-05-26 18:05:52 +00:00
|
|
|
GstFlowReturn gst_matroska_read_common_read_track_encodings (
|
2011-05-23 15:06:44 +00:00
|
|
|
GstMatroskaReadCommon * common, GstEbmlRead * ebml,
|
|
|
|
GstMatroskaTrackContext * context);
|
2011-05-30 05:10:08 +00:00
|
|
|
void gst_matroska_read_common_reset_streams (GstMatroskaReadCommon * common,
|
|
|
|
GstClockTime time, gboolean full);
|
2011-05-27 17:45:23 +00:00
|
|
|
gboolean gst_matroska_read_common_tracknumber_unique (GstMatroskaReadCommon *
|
|
|
|
common, guint64 num);
|
2011-05-23 15:06:44 +00:00
|
|
|
|
|
|
|
G_END_DECLS
|
|
|
|
|
|
|
|
#endif /* __GST_MATROSKA_READ_COMMON_H__ */
|