* (c) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
* (c) 2006 Tim-Philipp Müller <tim centricular net>
* (c) 2008 Sebastian Dröge <slomo@circular-chaos.org>
+ * (c) 2011 Debarshi Ray <rishi@gnu.org>
*
* matroska-demux.c: matroska file/stream demuxer
*
GST_DEBUG_OBJECT (demux, "Resetting state");
/* reset input */
- demux->state = GST_MATROSKA_DEMUX_STATE_START;
+ demux->common.state = GST_MATROSKA_READ_STATE_START;
/* clean up existing streams */
if (demux->common.src) {
gst_matroska_demux_search_pos (GstMatroskaDemux * demux, GstClockTime time)
{
GstMatroskaIndex *entry = NULL;
- GstMatroskaDemuxState current_state;
+ GstMatroskaReadState current_state;
GstClockTime otime, prev_cluster_time, current_cluster_time, cluster_time;
gint64 opos, newpos, startpos = 0, current_offset;
gint64 prev_cluster_offset = -1, current_cluster_offset, cluster_offset;
prev_cluster_time = GST_CLOCK_TIME_NONE;
/* store some current state */
- current_state = demux->state;
- g_return_val_if_fail (current_state == GST_MATROSKA_DEMUX_STATE_DATA, NULL);
+ current_state = demux->common.state;
+ g_return_val_if_fail (current_state == GST_MATROSKA_READ_STATE_DATA, NULL);
current_cluster_offset = demux->cluster_offset;
current_cluster_time = demux->cluster_time;
current_offset = demux->offset;
- demux->state = GST_MATROSKA_DEMUX_STATE_SCANNING;
+ demux->common.state = GST_MATROSKA_READ_STATE_SCANNING;
/* estimate using start and current position */
GST_OBJECT_LOCK (demux);
demux->cluster_offset = current_cluster_offset;
demux->cluster_time = current_cluster_time;
demux->offset = current_offset;
- demux->state = current_state;
+ demux->common.state = current_state;
return entry;
}
GST_OBJECT_LOCK (demux);
/* handle the seek event in the chain function */
- demux->state = GST_MATROSKA_DEMUX_STATE_SEEK;
+ demux->common.state = GST_MATROSKA_READ_STATE_SEEK;
/* no more seek can be issued until state reset to _DATA */
/* copy the event */
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_SEEK:
/* no seeking until we are (safely) ready */
- if (demux->state != GST_MATROSKA_DEMUX_STATE_DATA) {
+ if (demux->common.state != GST_MATROSKA_READ_STATE_DATA) {
GST_DEBUG_OBJECT (demux, "not ready for seeking yet");
return FALSE;
}
if (G_LIKELY (length != G_MAXUINT64))
read += needed;
- switch (demux->state) {
- case GST_MATROSKA_DEMUX_STATE_START:
+ switch (demux->common.state) {
+ case GST_MATROSKA_READ_STATE_START:
switch (id) {
case GST_EBML_ID_HEADER:
GST_READ_CHECK (gst_matroska_demux_take (demux, read, &ebml));
ret = gst_matroska_demux_parse_header (demux, &ebml);
if (ret != GST_FLOW_OK)
goto parse_failed;
- demux->state = GST_MATROSKA_DEMUX_STATE_SEGMENT;
+ demux->common.state = GST_MATROSKA_READ_STATE_SEGMENT;
gst_matroska_demux_check_seekability (demux);
break;
default:
break;
}
break;
- case GST_MATROSKA_DEMUX_STATE_SEGMENT:
+ case GST_MATROSKA_READ_STATE_SEGMENT:
switch (id) {
case GST_MATROSKA_ID_SEGMENT:
/* eat segment prefix */
/* seeks are from the beginning of the segment,
* after the segment ID/length */
demux->common.ebml_segment_start = demux->offset;
- demux->state = GST_MATROSKA_DEMUX_STATE_HEADER;
+ demux->common.state = GST_MATROSKA_READ_STATE_HEADER;
break;
default:
GST_WARNING_OBJECT (demux,
break;
}
break;
- case GST_MATROSKA_DEMUX_STATE_SCANNING:
+ case GST_MATROSKA_READ_STATE_SCANNING:
if (id != GST_MATROSKA_ID_CLUSTER &&
id != GST_MATROSKA_ID_CLUSTERTIMECODE)
goto skip;
/* fall-through */
- case GST_MATROSKA_DEMUX_STATE_HEADER:
- case GST_MATROSKA_DEMUX_STATE_DATA:
- case GST_MATROSKA_DEMUX_STATE_SEEK:
+ case GST_MATROSKA_READ_STATE_HEADER:
+ case GST_MATROSKA_READ_STATE_DATA:
+ case GST_MATROSKA_READ_STATE_SEEK:
switch (id) {
case GST_MATROSKA_ID_SEGMENTINFO:
if (!demux->segmentinfo_parsed) {
goto no_tracks;
}
}
- if (G_UNLIKELY (demux->state == GST_MATROSKA_DEMUX_STATE_HEADER)) {
- demux->state = GST_MATROSKA_DEMUX_STATE_DATA;
+ if (G_UNLIKELY (demux->common.state
+ == GST_MATROSKA_READ_STATE_HEADER)) {
+ demux->common.state = GST_MATROSKA_READ_STATE_DATA;
demux->first_cluster_offset = demux->offset;
GST_DEBUG_OBJECT (demux, "signaling no more pads");
gst_element_no_more_pads (GST_ELEMENT (demux));
ret = gst_matroska_read_common_parse_index (&demux->common, &ebml);
/* only push based; delayed index building */
if (ret == GST_FLOW_OK
- && demux->state == GST_MATROSKA_DEMUX_STATE_SEEK) {
+ && demux->common.state == GST_MATROSKA_READ_STATE_SEEK) {
GstEvent *event;
GST_OBJECT_LOCK (demux);
goto seek_failed;
/* resume data handling, main thread clear to seek again */
GST_OBJECT_LOCK (demux);
- demux->state = GST_MATROSKA_DEMUX_STATE_DATA;
+ demux->common.state = GST_MATROSKA_READ_STATE_DATA;
GST_OBJECT_UNLOCK (demux);
}
break;
guint needed;
/* If we have to close a segment, send a new segment to do this now */
- if (G_LIKELY (demux->state == GST_MATROSKA_DEMUX_STATE_DATA)) {
+ if (G_LIKELY (demux->common.state == GST_MATROSKA_READ_STATE_DATA)) {
if (G_UNLIKELY (demux->close_segment)) {
gst_matroska_demux_send_event (demux, demux->close_segment);
demux->close_segment = NULL;
"received format %d newsegment %" GST_SEGMENT_FORMAT, format,
&segment);
- if (demux->state < GST_MATROSKA_DEMUX_STATE_DATA) {
+ if (demux->common.state < GST_MATROSKA_READ_STATE_DATA) {
GST_DEBUG_OBJECT (demux, "still starting");
goto exit;
}
}
case GST_EVENT_EOS:
{
- if (demux->state != GST_MATROSKA_DEMUX_STATE_DATA) {
+ if (demux->common.state != GST_MATROSKA_READ_STATE_DATA) {
gst_event_unref (event);
GST_ELEMENT_ERROR (demux, STREAM, DEMUX,
(NULL), ("got eos and didn't receive a complete header object"));
/* GStreamer Matroska muxer/demuxer
* (c) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
+ * (c) 2011 Debarshi Ray <rishi@gnu.org>
*
* matroska-demux.h: matroska file/stream demuxer definition
*
#define GST_IS_MATROSKA_DEMUX_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_MATROSKA_DEMUX))
-typedef enum {
- GST_MATROSKA_DEMUX_STATE_START,
- GST_MATROSKA_DEMUX_STATE_SEGMENT,
- GST_MATROSKA_DEMUX_STATE_HEADER,
- GST_MATROSKA_DEMUX_STATE_DATA,
- GST_MATROSKA_DEMUX_STATE_SEEK,
- GST_MATROSKA_DEMUX_STATE_SCANNING
-} GstMatroskaDemuxState;
-
typedef struct _GstMatroskaDemux {
GstElement parent;
/* state */
gboolean streaming;
- GstMatroskaDemuxState state;
guint level_up;
guint64 seek_block;
gboolean seek_first;
* (c) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
* (c) 2006 Tim-Philipp Müller <tim centricular net>
* (c) 2008 Sebastian Dröge <slomo@circular-chaos.org>
+ * (c) 2011 Debarshi Ray <rishi@gnu.org>
*
* matroska-parse.c: matroska file/stream parser
*
GST_DEBUG_OBJECT (parse, "Resetting state");
/* reset input */
- parse->state = GST_MATROSKA_PARSE_STATE_START;
+ parse->common.state = GST_MATROSKA_READ_STATE_START;
/* clean up existing streams */
if (parse->common.src) {
GST_OBJECT_LOCK (parse);
/* handle the seek event in the chain function */
- parse->state = GST_MATROSKA_PARSE_STATE_SEEK;
+ parse->common.state = GST_MATROSKA_READ_STATE_SEEK;
/* no more seek can be issued until state reset to _DATA */
/* copy the event */
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_SEEK:
/* no seeking until we are (safely) ready */
- if (parse->state != GST_MATROSKA_PARSE_STATE_DATA) {
+ if (parse->common.state != GST_MATROSKA_READ_STATE_DATA) {
GST_DEBUG_OBJECT (parse, "not ready for seeking yet");
return FALSE;
}
if (G_LIKELY (length != G_MAXUINT64))
read += needed;
- switch (parse->state) {
- case GST_MATROSKA_PARSE_STATE_START:
+ switch (parse->common.state) {
+ case GST_MATROSKA_READ_STATE_START:
switch (id) {
case GST_EBML_ID_HEADER:
GST_READ_CHECK (gst_matroska_parse_take (parse, read, &ebml));
ret = gst_matroska_parse_parse_header (parse, &ebml);
if (ret != GST_FLOW_OK)
goto parse_failed;
- parse->state = GST_MATROSKA_PARSE_STATE_SEGMENT;
+ parse->common.state = GST_MATROSKA_READ_STATE_SEGMENT;
gst_matroska_parse_check_seekability (parse);
gst_matroska_parse_accumulate_streamheader (parse, ebml.buf);
break;
break;
}
break;
- case GST_MATROSKA_PARSE_STATE_SEGMENT:
+ case GST_MATROSKA_READ_STATE_SEGMENT:
switch (id) {
case GST_MATROSKA_ID_SEGMENT:
/* eat segment prefix */
/* seeks are from the beginning of the segment,
* after the segment ID/length */
parse->common.ebml_segment_start = parse->offset;
- parse->state = GST_MATROSKA_PARSE_STATE_HEADER;
+ parse->common.state = GST_MATROSKA_READ_STATE_HEADER;
gst_matroska_parse_accumulate_streamheader (parse, ebml.buf);
break;
default:
break;
}
break;
- case GST_MATROSKA_PARSE_STATE_SCANNING:
+ case GST_MATROSKA_READ_STATE_SCANNING:
if (id != GST_MATROSKA_ID_CLUSTER &&
id != GST_MATROSKA_ID_CLUSTERTIMECODE)
goto skip;
/* fall-through */
- case GST_MATROSKA_PARSE_STATE_HEADER:
- case GST_MATROSKA_PARSE_STATE_DATA:
- case GST_MATROSKA_PARSE_STATE_SEEK:
+ case GST_MATROSKA_READ_STATE_HEADER:
+ case GST_MATROSKA_READ_STATE_DATA:
+ case GST_MATROSKA_READ_STATE_SEEK:
switch (id) {
case GST_MATROSKA_ID_SEGMENTINFO:
GST_READ_CHECK (gst_matroska_parse_take (parse, read, &ebml));
GST_DEBUG_OBJECT (parse, "Cluster before Track");
goto not_streamable;
}
- if (G_UNLIKELY (parse->state == GST_MATROSKA_PARSE_STATE_HEADER)) {
- parse->state = GST_MATROSKA_PARSE_STATE_DATA;
+ if (G_UNLIKELY (parse->common.state
+ == GST_MATROSKA_READ_STATE_HEADER)) {
+ parse->common.state = GST_MATROSKA_READ_STATE_DATA;
parse->first_cluster_offset = parse->offset;
GST_DEBUG_OBJECT (parse, "signaling no more pads");
}
ret = gst_matroska_read_common_parse_index (&parse->common, &ebml);
/* only push based; delayed index building */
if (ret == GST_FLOW_OK
- && parse->state == GST_MATROSKA_PARSE_STATE_SEEK) {
+ && parse->common.state == GST_MATROSKA_READ_STATE_SEEK) {
GstEvent *event;
GST_OBJECT_LOCK (parse);
goto seek_failed;
/* resume data handling, main thread clear to seek again */
GST_OBJECT_LOCK (parse);
- parse->state = GST_MATROSKA_PARSE_STATE_DATA;
+ parse->common.state = GST_MATROSKA_READ_STATE_DATA;
GST_OBJECT_UNLOCK (parse);
}
}
guint needed;
/* If we have to close a segment, send a new segment to do this now */
- if (G_LIKELY (parse->state == GST_MATROSKA_PARSE_STATE_DATA)) {
+ if (G_LIKELY (parse->common.state == GST_MATROSKA_READ_STATE_DATA)) {
if (G_UNLIKELY (parse->close_segment)) {
gst_matroska_parse_send_event (parse, parse->close_segment);
parse->close_segment = NULL;
"received format %d newsegment %" GST_SEGMENT_FORMAT, format,
&segment);
- if (parse->state < GST_MATROSKA_PARSE_STATE_DATA) {
+ if (parse->common.state < GST_MATROSKA_READ_STATE_DATA) {
GST_DEBUG_OBJECT (parse, "still starting");
goto exit;
}
}
case GST_EVENT_EOS:
{
- if (parse->state != GST_MATROSKA_PARSE_STATE_DATA) {
+ if (parse->common.state != GST_MATROSKA_READ_STATE_DATA) {
gst_event_unref (event);
GST_ELEMENT_ERROR (parse, STREAM, DEMUX,
(NULL), ("got eos and didn't receive a complete header object"));
/* GStreamer Matroska muxer/demuxer
* (c) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
+ * (c) 2011 Debarshi Ray <rishi@gnu.org>
*
* matroska-parse.h: matroska file/stream parseer definition
*
#define GST_IS_MATROSKA_PARSE_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_MATROSKA_PARSE))
-typedef enum {
- GST_MATROSKA_PARSE_STATE_START,
- GST_MATROSKA_PARSE_STATE_SEGMENT,
- GST_MATROSKA_PARSE_STATE_HEADER,
- GST_MATROSKA_PARSE_STATE_DATA,
- GST_MATROSKA_PARSE_STATE_SEEK,
- GST_MATROSKA_PARSE_STATE_SCANNING
-} GstMatroskaParseState;
-
typedef struct _GstMatroskaParse {
GstElement parent;
/* state */
//gboolean streaming;
- GstMatroskaParseState state;
guint level_up;
guint64 seek_block;
gboolean seek_first;
G_BEGIN_DECLS
typedef enum {
- GST_MATROSKA_READ_COMMON_STATE_START,
- GST_MATROSKA_READ_COMMON_STATE_SEGMENT,
- GST_MATROSKA_READ_COMMON_STATE_HEADER,
- GST_MATROSKA_READ_COMMON_STATE_DATA,
- GST_MATROSKA_READ_COMMON_STATE_SEEK,
- GST_MATROSKA_READ_COMMON_STATE_SCANNING
-} GstMatroskaReadCommonState;
+ 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;
typedef struct _GstMatroskaReadCommon {
GstIndex *element_index;
GPtrArray *src;
guint num_streams;
+ /* state */
+ GstMatroskaReadState state;
+
/* did we parse cues/tracks/segmentinfo already? */
gboolean index_parsed;