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
|
2012-11-04 00:07:18 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2011-05-23 15:06:44 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#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;
|
|
|
|
|
2014-01-16 17:23:13 +00:00
|
|
|
/* stream type */
|
|
|
|
gboolean is_webm;
|
|
|
|
gboolean has_video;
|
2012-03-29 19:05:14 +00:00
|
|
|
|
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;
|
2012-03-29 19:05:14 +00:00
|
|
|
gboolean chapters_parsed;
|
2011-06-05 04:45:23 +00:00
|
|
|
GList *tags_parsed;
|
2011-05-23 15:06:44 +00:00
|
|
|
|
2012-03-29 19:05:14 +00:00
|
|
|
/* chapters stuff */
|
|
|
|
GstToc *toc;
|
|
|
|
gboolean toc_updated;
|
|
|
|
|
2014-09-04 13:21:20 +00:00
|
|
|
/* start-of-segment and length */
|
2011-05-23 15:06:44 +00:00
|
|
|
guint64 ebml_segment_start;
|
2014-09-04 13:21:20 +00:00
|
|
|
guint64 ebml_segment_length;
|
2011-05-23 15:06:44 +00:00
|
|
|
|
|
|
|
/* 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;
|
2015-03-14 16:07:05 +00:00
|
|
|
gboolean global_tags_changed;
|
2011-05-28 16:34:34 +00:00
|
|
|
|
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;
|
2012-01-23 16:25:37 +00:00
|
|
|
GstMapInfo cached_map;
|
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;
|
2015-07-30 00:54:35 +00:00
|
|
|
|
|
|
|
/* cache for track tags that forward-reference their tracks */
|
|
|
|
GHashTable *cached_track_taglists ;
|
|
|
|
|
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
|
2015-01-30 15:30:40 +00:00
|
|
|
seek_pos, GArray ** _index, gint * _entry_index, GstSearchMode snap_dir);
|
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);
|
2014-01-20 20:31:14 +00:00
|
|
|
void gst_matroska_read_common_free_parsed_el (gpointer mem, gpointer user_data);
|
|
|
|
void gst_matroska_read_common_init (GstMatroskaReadCommon * ctx);
|
|
|
|
void gst_matroska_read_common_finalize (GstMatroskaReadCommon * ctx);
|
|
|
|
void gst_matroska_read_common_reset (GstElement * element,
|
|
|
|
GstMatroskaReadCommon * ctx);
|
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__ */
|