2007-05-16 19:07:45 +00:00
|
|
|
/* GStreamer RealMedia demuxer
|
2003-06-22 03:59:01 +00:00
|
|
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
* Copyright (C) <2003> David A. Schleef <ds@schleef.org>
|
2004-10-03 11:50:11 +00:00
|
|
|
* Copyright (C) <2004> Stephane Loeuillet <gstreamer@leroutier.net>
|
2005-06-27 09:16:09 +00:00
|
|
|
* Copyright (C) <2005> Owen Fraser-Green <owen@discobabe.net>
|
2005-10-05 11:25:51 +00:00
|
|
|
* Copyright (C) <2005> Michael Smith <fluendo.com>
|
gst/realmedia/rmdemux.*: Cleanups, use GstSegment for seeking.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_finalize), (gst_rmdemux_src_event),
(find_seek_offset_time), (gst_rmdemux_perform_seek),
(gst_rmdemux_src_query), (gst_rmdemux_change_state),
(gst_rmdemux_loop), (gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream), (gst_rmdemux_parse_mdpr),
(gst_rmdemux_combine_flows), (gst_rmdemux_parse_packet):
* gst/realmedia/rmdemux.h:
Cleanups, use GstSegment for seeking.
Fix error handling.
Combine flow return from all streams.
2006-07-13 11:28:32 +00:00
|
|
|
* Copyright (C) <2006> Wim Taymans <wim@fluendo.com>
|
gst/realmedia/rmdemux.c: Descramble cook audio streams before sending them to the decoder. Fixes #347292.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_init), (gst_rmdemux_chain), (gst_rmdemux_add_stream),
(gst_rmdemux_parse_mdpr), (gst_rmdemux_parse_data),
(gst_rmdemux_stream_clear_cached_subpackets),
(gst_rmdemux_descramble_cook_audio),
(gst_rmdemux_descramble_dnet_audio),
(gst_rmdemux_handle_scrambled_packet), (gst_rmdemux_parse_packet):
Descramble cook audio streams before sending them to the
decoder. Fixes #347292.
Also miscellaneous clean-ups and log-level changes.
2006-07-27 20:34:25 +00:00
|
|
|
* Copyright (C) <2006> Tim-Philipp Müller <tim centricular net>
|
2007-08-07 10:57:09 +00:00
|
|
|
* Copyright (C) <2007> Wim Taymans <wim.taymans@gmail.com>
|
2003-06-22 03:59:01 +00:00
|
|
|
*
|
|
|
|
* 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-03 20:40:37 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2003-06-22 03:59:01 +00:00
|
|
|
*/
|
|
|
|
|
2003-06-29 19:46:09 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2005-06-27 09:16:09 +00:00
|
|
|
# include "config.h"
|
2003-06-29 19:46:09 +00:00
|
|
|
#endif
|
2007-01-11 12:49:23 +00:00
|
|
|
|
2003-06-22 03:59:01 +00:00
|
|
|
#include "rmdemux.h"
|
2006-08-04 13:05:01 +00:00
|
|
|
#include "rmutils.h"
|
2007-01-11 12:49:23 +00:00
|
|
|
|
2003-06-22 03:59:01 +00:00
|
|
|
#include <string.h>
|
2005-09-30 16:39:47 +00:00
|
|
|
#include <ctype.h>
|
2005-10-23 22:44:44 +00:00
|
|
|
|
2005-12-06 19:48:07 +00:00
|
|
|
#define RMDEMUX_GUINT32_GET(a) GST_READ_UINT32_BE(a)
|
|
|
|
#define RMDEMUX_GUINT16_GET(a) GST_READ_UINT16_BE(a)
|
|
|
|
#define RMDEMUX_FOURCC_GET(a) GST_READ_UINT32_LE(a)
|
2005-08-10 08:33:19 +00:00
|
|
|
#define HEADER_SIZE 10
|
|
|
|
#define DATA_SIZE 8
|
2005-10-23 22:44:44 +00:00
|
|
|
|
2007-08-07 10:57:09 +00:00
|
|
|
#define MAX_FRAGS 256
|
|
|
|
|
2010-05-13 15:57:57 +00:00
|
|
|
static const guint8 sipr_subpk_size[4] = { 29, 19, 37, 20 };
|
|
|
|
|
2003-06-22 03:59:01 +00:00
|
|
|
typedef struct _GstRMDemuxIndex GstRMDemuxIndex;
|
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
struct _GstRMDemuxStream
|
|
|
|
{
|
2003-06-22 03:59:01 +00:00
|
|
|
guint32 subtype;
|
|
|
|
guint32 fourcc;
|
2005-06-27 09:16:09 +00:00
|
|
|
guint32 subformat;
|
|
|
|
guint32 format;
|
|
|
|
|
2003-06-22 03:59:01 +00:00
|
|
|
int id;
|
|
|
|
GstPad *pad;
|
2008-08-27 09:47:17 +00:00
|
|
|
gboolean discont;
|
2003-06-22 03:59:01 +00:00
|
|
|
int timescale;
|
|
|
|
|
|
|
|
int sample_index;
|
|
|
|
GstRMDemuxIndex *index;
|
|
|
|
int index_length;
|
gst/realmedia/rmdemux.c: Fractional framerates.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_sink_event),
(gst_rmdemux_src_event), (gst_rmdemux_validate_offset),
(find_seek_offset_bytes), (find_seek_offset_time),
(gst_rmdemux_perform_seek), (gst_rmdemux_src_query),
(gst_rmdemux_loop), (gst_rmdemux_fourcc_isplausible),
(gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream), (gst_rmdemux_parse_mdpr),
(gst_rmdemux_parse_packet):
Fractional framerates.
2005-11-23 00:26:42 +00:00
|
|
|
gint framerate_numerator;
|
|
|
|
gint framerate_denominator;
|
2005-08-22 07:33:00 +00:00
|
|
|
guint32 seek_offset;
|
2005-06-27 09:16:09 +00:00
|
|
|
|
|
|
|
guint16 width;
|
|
|
|
guint16 height;
|
|
|
|
guint16 flavor;
|
2006-03-24 12:08:39 +00:00
|
|
|
guint16 rate; /* samplerate */
|
|
|
|
guint16 n_channels; /* channels */
|
|
|
|
guint16 sample_width; /* bits_per_sample */
|
|
|
|
guint16 leaf_size; /* subpacket_size */
|
|
|
|
guint32 packet_size; /* coded_frame_size */
|
2005-06-27 09:16:09 +00:00
|
|
|
guint16 version;
|
2006-03-24 12:08:39 +00:00
|
|
|
guint32 extra_data_size; /* codec_data_length */
|
|
|
|
guint8 *extra_data; /* extras */
|
2010-06-05 12:11:30 +00:00
|
|
|
guint32 bitrate;
|
gst/realmedia/rmdemux.c: Descramble cook audio streams before sending them to the decoder. Fixes #347292.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_init), (gst_rmdemux_chain), (gst_rmdemux_add_stream),
(gst_rmdemux_parse_mdpr), (gst_rmdemux_parse_data),
(gst_rmdemux_stream_clear_cached_subpackets),
(gst_rmdemux_descramble_cook_audio),
(gst_rmdemux_descramble_dnet_audio),
(gst_rmdemux_handle_scrambled_packet), (gst_rmdemux_parse_packet):
Descramble cook audio streams before sending them to the
decoder. Fixes #347292.
Also miscellaneous clean-ups and log-level changes.
2006-07-27 20:34:25 +00:00
|
|
|
|
|
|
|
gboolean needs_descrambling;
|
|
|
|
guint subpackets_needed; /* subpackets needed for descrambling */
|
|
|
|
GPtrArray *subpackets; /* array containing subpacket GstBuffers */
|
2007-05-16 19:07:45 +00:00
|
|
|
|
2007-08-07 11:50:44 +00:00
|
|
|
/* Variables needed for fixing timestamps. */
|
|
|
|
GstClockTime next_ts, last_ts;
|
|
|
|
guint16 next_seq, last_seq;
|
|
|
|
|
2007-08-07 10:57:09 +00:00
|
|
|
gint frag_seqnum;
|
|
|
|
gint frag_subseq;
|
|
|
|
guint frag_length;
|
|
|
|
guint frag_current;
|
|
|
|
guint frag_count;
|
|
|
|
guint frag_offset[MAX_FRAGS];
|
|
|
|
GstAdapter *adapter;
|
|
|
|
|
2007-05-16 19:07:45 +00:00
|
|
|
GstTagList *pending_tags;
|
2003-06-22 03:59:01 +00:00
|
|
|
};
|
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
struct _GstRMDemuxIndex
|
|
|
|
{
|
2003-06-22 03:59:01 +00:00
|
|
|
guint32 offset;
|
2005-08-10 08:33:19 +00:00
|
|
|
GstClockTime timestamp;
|
2003-06-22 03:59:01 +00:00
|
|
|
};
|
|
|
|
|
2003-12-22 01:47:08 +00:00
|
|
|
static GstStaticPadTemplate gst_rmdemux_sink_template =
|
2004-03-14 22:34:30 +00:00
|
|
|
GST_STATIC_PAD_TEMPLATE ("sink",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
2004-10-03 01:37:11 +00:00
|
|
|
GST_STATIC_CAPS ("application/vnd.rn-realmedia")
|
2004-03-14 22:34:30 +00:00
|
|
|
);
|
2003-06-22 03:59:01 +00:00
|
|
|
|
2003-12-22 01:47:08 +00:00
|
|
|
static GstStaticPadTemplate gst_rmdemux_videosrc_template =
|
2011-11-04 15:40:59 +00:00
|
|
|
GST_STATIC_PAD_TEMPLATE ("video_%u",
|
2004-03-14 22:34:30 +00:00
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_SOMETIMES,
|
|
|
|
GST_STATIC_CAPS_ANY);
|
2003-06-22 03:59:01 +00:00
|
|
|
|
2003-12-22 01:47:08 +00:00
|
|
|
static GstStaticPadTemplate gst_rmdemux_audiosrc_template =
|
2011-11-04 15:40:59 +00:00
|
|
|
GST_STATIC_PAD_TEMPLATE ("audio_%u",
|
2004-03-14 22:34:30 +00:00
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_SOMETIMES,
|
|
|
|
GST_STATIC_CAPS_ANY);
|
2003-06-22 03:59:01 +00:00
|
|
|
|
gst/realmedia/rmdemux.c: Use debug category, fix EOS handling. filesrc ! rmdemux now works.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_init), (gst_rmdemux_handle_sink_event),
(gst_rmdemux_loop), (gst_rmdemux_add_stream), (re_hexdump_bytes),
(re_dump_pascal_string), (gst_rmdemux_dump__rmf),
(gst_rmdemux_dump_prop), (gst_rmdemux_parse_mdpr),
(gst_rmdemux_dump_mdpr), (gst_rmdemux_dump_indx),
(gst_rmdemux_dump_data):
Use debug category, fix EOS handling. filesrc ! rmdemux now
works.
2004-10-04 14:43:23 +00:00
|
|
|
GST_DEBUG_CATEGORY_STATIC (rmdemux_debug);
|
|
|
|
#define GST_CAT_DEFAULT rmdemux_debug
|
|
|
|
|
2003-06-22 03:59:01 +00:00
|
|
|
static GstElementClass *parent_class = NULL;
|
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
static void gst_rmdemux_class_init (GstRMDemuxClass * klass);
|
|
|
|
static void gst_rmdemux_base_init (GstRMDemuxClass * klass);
|
|
|
|
static void gst_rmdemux_init (GstRMDemux * rmdemux);
|
gst/realmedia/rmdemux.*: Cleanups, use GstSegment for seeking.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_finalize), (gst_rmdemux_src_event),
(find_seek_offset_time), (gst_rmdemux_perform_seek),
(gst_rmdemux_src_query), (gst_rmdemux_change_state),
(gst_rmdemux_loop), (gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream), (gst_rmdemux_parse_mdpr),
(gst_rmdemux_combine_flows), (gst_rmdemux_parse_packet):
* gst/realmedia/rmdemux.h:
Cleanups, use GstSegment for seeking.
Fix error handling.
Combine flow return from all streams.
2006-07-13 11:28:32 +00:00
|
|
|
static void gst_rmdemux_finalize (GObject * object);
|
2005-09-02 15:43:54 +00:00
|
|
|
static GstStateChangeReturn gst_rmdemux_change_state (GstElement * element,
|
|
|
|
GstStateChange transition);
|
2011-11-17 14:25:58 +00:00
|
|
|
static GstFlowReturn gst_rmdemux_chain (GstPad * pad, GstObject * parent,
|
|
|
|
GstBuffer * buffer);
|
2005-08-10 08:33:19 +00:00
|
|
|
static void gst_rmdemux_loop (GstPad * pad);
|
2011-11-18 12:59:29 +00:00
|
|
|
static gboolean gst_rmdemux_sink_activate (GstPad * sinkpad,
|
|
|
|
GstObject * parent);
|
2011-11-21 12:36:10 +00:00
|
|
|
static gboolean gst_rmdemux_sink_activate_mode (GstPad * sinkpad,
|
|
|
|
GstObject * parent, GstPadMode mode, gboolean active);
|
2011-11-17 14:25:58 +00:00
|
|
|
static gboolean gst_rmdemux_sink_event (GstPad * pad, GstObject * parent,
|
|
|
|
GstEvent * event);
|
|
|
|
static gboolean gst_rmdemux_src_event (GstPad * pad, GstObject * parent,
|
|
|
|
GstEvent * event);
|
2006-03-24 11:42:31 +00:00
|
|
|
static void gst_rmdemux_send_event (GstRMDemux * rmdemux, GstEvent * event);
|
2011-11-16 16:28:56 +00:00
|
|
|
static gboolean gst_rmdemux_src_query (GstPad * pad, GstObject * parent,
|
|
|
|
GstQuery * query);
|
gst/realmedia/rmdemux.*: Cleanups, use GstSegment for seeking.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_finalize), (gst_rmdemux_src_event),
(find_seek_offset_time), (gst_rmdemux_perform_seek),
(gst_rmdemux_src_query), (gst_rmdemux_change_state),
(gst_rmdemux_loop), (gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream), (gst_rmdemux_parse_mdpr),
(gst_rmdemux_combine_flows), (gst_rmdemux_parse_packet):
* gst/realmedia/rmdemux.h:
Cleanups, use GstSegment for seeking.
Fix error handling.
Combine flow return from all streams.
2006-07-13 11:28:32 +00:00
|
|
|
static gboolean gst_rmdemux_perform_seek (GstRMDemux * rmdemux,
|
|
|
|
GstEvent * event);
|
2004-03-14 22:34:30 +00:00
|
|
|
|
2006-10-16 18:07:23 +00:00
|
|
|
static void gst_rmdemux_parse__rmf (GstRMDemux * rmdemux, const guint8 * data,
|
2004-03-14 22:34:30 +00:00
|
|
|
int length);
|
2006-10-16 18:07:23 +00:00
|
|
|
static void gst_rmdemux_parse_prop (GstRMDemux * rmdemux, const guint8 * data,
|
2004-03-14 22:34:30 +00:00
|
|
|
int length);
|
gst/realmedia/rmdemux.*: Cleanups, use GstSegment for seeking.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_finalize), (gst_rmdemux_src_event),
(find_seek_offset_time), (gst_rmdemux_perform_seek),
(gst_rmdemux_src_query), (gst_rmdemux_change_state),
(gst_rmdemux_loop), (gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream), (gst_rmdemux_parse_mdpr),
(gst_rmdemux_combine_flows), (gst_rmdemux_parse_packet):
* gst/realmedia/rmdemux.h:
Cleanups, use GstSegment for seeking.
Fix error handling.
Combine flow return from all streams.
2006-07-13 11:28:32 +00:00
|
|
|
static void gst_rmdemux_parse_mdpr (GstRMDemux * rmdemux,
|
2006-10-16 18:07:23 +00:00
|
|
|
const guint8 * data, int length);
|
|
|
|
static guint gst_rmdemux_parse_indx (GstRMDemux * rmdemux, const guint8 * data,
|
2004-03-14 22:34:30 +00:00
|
|
|
int length);
|
2006-10-16 18:07:23 +00:00
|
|
|
static void gst_rmdemux_parse_data (GstRMDemux * rmdemux, const guint8 * data,
|
2004-03-14 22:34:30 +00:00
|
|
|
int length);
|
2006-10-16 18:07:23 +00:00
|
|
|
static void gst_rmdemux_parse_cont (GstRMDemux * rmdemux, const guint8 * data,
|
2004-03-14 22:34:30 +00:00
|
|
|
int length);
|
2005-10-05 11:25:51 +00:00
|
|
|
static GstFlowReturn gst_rmdemux_parse_packet (GstRMDemux * rmdemux,
|
2007-08-07 10:57:09 +00:00
|
|
|
GstBuffer * in, guint16 version);
|
2006-10-16 18:07:23 +00:00
|
|
|
static void gst_rmdemux_parse_indx_data (GstRMDemux * rmdemux,
|
|
|
|
const guint8 * data, int length);
|
2006-07-28 13:28:19 +00:00
|
|
|
static void gst_rmdemux_stream_clear_cached_subpackets (GstRMDemux * rmdemux,
|
|
|
|
GstRMDemuxStream * stream);
|
2004-03-14 22:34:30 +00:00
|
|
|
static GstRMDemuxStream *gst_rmdemux_get_stream_by_id (GstRMDemux * rmdemux,
|
2003-06-24 08:05:12 +00:00
|
|
|
int id);
|
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
static GType
|
|
|
|
gst_rmdemux_get_type (void)
|
2003-06-22 03:59:01 +00:00
|
|
|
{
|
|
|
|
static GType rmdemux_type = 0;
|
|
|
|
|
|
|
|
if (!rmdemux_type) {
|
|
|
|
static const GTypeInfo rmdemux_info = {
|
2004-03-14 22:34:30 +00:00
|
|
|
sizeof (GstRMDemuxClass),
|
|
|
|
(GBaseInitFunc) gst_rmdemux_base_init, NULL,
|
|
|
|
(GClassInitFunc) gst_rmdemux_class_init,
|
|
|
|
NULL, NULL, sizeof (GstRMDemux), 0,
|
|
|
|
(GInstanceInitFunc) gst_rmdemux_init,
|
2003-06-22 03:59:01 +00:00
|
|
|
};
|
2004-03-15 19:32:25 +00:00
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
rmdemux_type =
|
2004-03-15 19:32:25 +00:00
|
|
|
g_type_register_static (GST_TYPE_ELEMENT, "GstRMDemux", &rmdemux_info,
|
|
|
|
0);
|
2003-06-22 03:59:01 +00:00
|
|
|
}
|
|
|
|
return rmdemux_type;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
static void
|
|
|
|
gst_rmdemux_base_init (GstRMDemuxClass * klass)
|
2003-11-02 21:52:09 +00:00
|
|
|
{
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
|
|
|
|
2016-03-04 07:14:44 +00:00
|
|
|
gst_element_class_add_static_pad_template (element_class,
|
|
|
|
&gst_rmdemux_sink_template);
|
|
|
|
gst_element_class_add_static_pad_template (element_class,
|
|
|
|
&gst_rmdemux_videosrc_template);
|
|
|
|
gst_element_class_add_static_pad_template (element_class,
|
|
|
|
&gst_rmdemux_audiosrc_template);
|
2012-04-09 23:47:44 +00:00
|
|
|
gst_element_class_set_static_metadata (element_class, "RealMedia Demuxer",
|
2010-03-18 14:53:14 +00:00
|
|
|
"Codec/Demuxer",
|
|
|
|
"Demultiplex a RealMedia file into audio and video streams",
|
|
|
|
"David Schleef <ds@schleef.org>");
|
2003-11-02 21:52:09 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
static void
|
|
|
|
gst_rmdemux_class_init (GstRMDemuxClass * klass)
|
2003-06-22 03:59:01 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
GstElementClass *gstelement_class;
|
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
gobject_class = (GObjectClass *) klass;
|
|
|
|
gstelement_class = (GstElementClass *) klass;
|
2003-06-22 03:59:01 +00:00
|
|
|
|
2006-04-08 21:42:19 +00:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2003-06-22 03:59:01 +00:00
|
|
|
|
gst/realmedia/rmdemux.c: Descramble cook audio streams before sending them to the decoder. Fixes #347292.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_init), (gst_rmdemux_chain), (gst_rmdemux_add_stream),
(gst_rmdemux_parse_mdpr), (gst_rmdemux_parse_data),
(gst_rmdemux_stream_clear_cached_subpackets),
(gst_rmdemux_descramble_cook_audio),
(gst_rmdemux_descramble_dnet_audio),
(gst_rmdemux_handle_scrambled_packet), (gst_rmdemux_parse_packet):
Descramble cook audio streams before sending them to the
decoder. Fixes #347292.
Also miscellaneous clean-ups and log-level changes.
2006-07-27 20:34:25 +00:00
|
|
|
gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_rmdemux_change_state);
|
gst/realmedia/rmdemux.c: Use debug category, fix EOS handling. filesrc ! rmdemux now works.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_init), (gst_rmdemux_handle_sink_event),
(gst_rmdemux_loop), (gst_rmdemux_add_stream), (re_hexdump_bytes),
(re_dump_pascal_string), (gst_rmdemux_dump__rmf),
(gst_rmdemux_dump_prop), (gst_rmdemux_parse_mdpr),
(gst_rmdemux_dump_mdpr), (gst_rmdemux_dump_indx),
(gst_rmdemux_dump_data):
Use debug category, fix EOS handling. filesrc ! rmdemux now
works.
2004-10-04 14:43:23 +00:00
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_INIT (rmdemux_debug, "rmdemux",
|
|
|
|
0, "Demuxer for Realmedia streams");
|
2005-06-27 09:16:09 +00:00
|
|
|
|
gst/realmedia/rmdemux.*: Cleanups, use GstSegment for seeking.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_finalize), (gst_rmdemux_src_event),
(find_seek_offset_time), (gst_rmdemux_perform_seek),
(gst_rmdemux_src_query), (gst_rmdemux_change_state),
(gst_rmdemux_loop), (gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream), (gst_rmdemux_parse_mdpr),
(gst_rmdemux_combine_flows), (gst_rmdemux_parse_packet):
* gst/realmedia/rmdemux.h:
Cleanups, use GstSegment for seeking.
Fix error handling.
Combine flow return from all streams.
2006-07-13 11:28:32 +00:00
|
|
|
gobject_class->finalize = gst_rmdemux_finalize;
|
2003-06-22 03:59:01 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
static void
|
gst/realmedia/rmdemux.*: Cleanups, use GstSegment for seeking.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_finalize), (gst_rmdemux_src_event),
(find_seek_offset_time), (gst_rmdemux_perform_seek),
(gst_rmdemux_src_query), (gst_rmdemux_change_state),
(gst_rmdemux_loop), (gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream), (gst_rmdemux_parse_mdpr),
(gst_rmdemux_combine_flows), (gst_rmdemux_parse_packet):
* gst/realmedia/rmdemux.h:
Cleanups, use GstSegment for seeking.
Fix error handling.
Combine flow return from all streams.
2006-07-13 11:28:32 +00:00
|
|
|
gst_rmdemux_finalize (GObject * object)
|
2003-06-22 03:59:01 +00:00
|
|
|
{
|
2005-06-27 09:16:09 +00:00
|
|
|
GstRMDemux *rmdemux = GST_RMDEMUX (object);
|
|
|
|
|
|
|
|
if (rmdemux->adapter) {
|
|
|
|
g_object_unref (rmdemux->adapter);
|
|
|
|
rmdemux->adapter = NULL;
|
|
|
|
}
|
2014-05-26 20:55:43 +00:00
|
|
|
if (rmdemux->flowcombiner) {
|
|
|
|
gst_flow_combiner_free (rmdemux->flowcombiner);
|
|
|
|
rmdemux->flowcombiner = NULL;
|
|
|
|
}
|
gst/realmedia/rmdemux.c: Use debug category, fix EOS handling. filesrc ! rmdemux now works.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_init), (gst_rmdemux_handle_sink_event),
(gst_rmdemux_loop), (gst_rmdemux_add_stream), (re_hexdump_bytes),
(re_dump_pascal_string), (gst_rmdemux_dump__rmf),
(gst_rmdemux_dump_prop), (gst_rmdemux_parse_mdpr),
(gst_rmdemux_dump_mdpr), (gst_rmdemux_dump_indx),
(gst_rmdemux_dump_data):
Use debug category, fix EOS handling. filesrc ! rmdemux now
works.
2004-10-04 14:43:23 +00:00
|
|
|
|
gst/realmedia/rmdemux.*: Cleanups, use GstSegment for seeking.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_finalize), (gst_rmdemux_src_event),
(find_seek_offset_time), (gst_rmdemux_perform_seek),
(gst_rmdemux_src_query), (gst_rmdemux_change_state),
(gst_rmdemux_loop), (gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream), (gst_rmdemux_parse_mdpr),
(gst_rmdemux_combine_flows), (gst_rmdemux_parse_packet):
* gst/realmedia/rmdemux.h:
Cleanups, use GstSegment for seeking.
Fix error handling.
Combine flow return from all streams.
2006-07-13 11:28:32 +00:00
|
|
|
GST_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
|
2005-06-27 09:16:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_rmdemux_init (GstRMDemux * rmdemux)
|
|
|
|
{
|
2004-03-14 22:34:30 +00:00
|
|
|
rmdemux->sinkpad =
|
gst/realmedia/rmdemux.c: Descramble cook audio streams before sending them to the decoder. Fixes #347292.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_init), (gst_rmdemux_chain), (gst_rmdemux_add_stream),
(gst_rmdemux_parse_mdpr), (gst_rmdemux_parse_data),
(gst_rmdemux_stream_clear_cached_subpackets),
(gst_rmdemux_descramble_cook_audio),
(gst_rmdemux_descramble_dnet_audio),
(gst_rmdemux_handle_scrambled_packet), (gst_rmdemux_parse_packet):
Descramble cook audio streams before sending them to the
decoder. Fixes #347292.
Also miscellaneous clean-ups and log-level changes.
2006-07-27 20:34:25 +00:00
|
|
|
gst_pad_new_from_static_template (&gst_rmdemux_sink_template, "sink");
|
2006-03-24 12:08:39 +00:00
|
|
|
gst_pad_set_event_function (rmdemux->sinkpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_rmdemux_sink_event));
|
|
|
|
gst_pad_set_chain_function (rmdemux->sinkpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_rmdemux_chain));
|
|
|
|
gst_pad_set_activate_function (rmdemux->sinkpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_rmdemux_sink_activate));
|
2011-11-21 12:36:10 +00:00
|
|
|
gst_pad_set_activatemode_function (rmdemux->sinkpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_rmdemux_sink_activate_mode));
|
2005-07-03 17:40:04 +00:00
|
|
|
|
2003-06-22 03:59:01 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (rmdemux), rmdemux->sinkpad);
|
2005-06-27 09:16:09 +00:00
|
|
|
|
|
|
|
rmdemux->adapter = gst_adapter_new ();
|
2007-05-16 19:07:45 +00:00
|
|
|
rmdemux->first_ts = GST_CLOCK_TIME_NONE;
|
2008-08-27 09:47:17 +00:00
|
|
|
rmdemux->base_ts = GST_CLOCK_TIME_NONE;
|
2007-05-16 19:07:45 +00:00
|
|
|
rmdemux->need_newsegment = TRUE;
|
2013-07-22 14:01:13 +00:00
|
|
|
rmdemux->have_group_id = FALSE;
|
|
|
|
rmdemux->group_id = G_MAXUINT;
|
2014-05-26 20:55:43 +00:00
|
|
|
rmdemux->flowcombiner = gst_flow_combiner_new ();
|
2010-05-14 14:02:47 +00:00
|
|
|
|
|
|
|
gst_rm_utils_run_tests ();
|
2003-06-22 03:59:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2011-11-17 14:25:58 +00:00
|
|
|
gst_rmdemux_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
|
2003-06-22 03:59:01 +00:00
|
|
|
{
|
2007-05-16 19:07:45 +00:00
|
|
|
gboolean ret;
|
2003-06-22 03:59:01 +00:00
|
|
|
|
2005-06-27 09:16:09 +00:00
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
2011-10-05 11:18:45 +00:00
|
|
|
case GST_EVENT_SEGMENT:
|
2005-06-27 09:16:09 +00:00
|
|
|
gst_event_unref (event);
|
2007-05-16 19:07:45 +00:00
|
|
|
ret = TRUE;
|
2003-06-22 03:59:01 +00:00
|
|
|
break;
|
|
|
|
default:
|
2011-11-17 14:25:58 +00:00
|
|
|
ret = gst_pad_event_default (pad, parent, event);
|
2003-06-22 03:59:01 +00:00
|
|
|
break;
|
|
|
|
}
|
2005-06-27 09:16:09 +00:00
|
|
|
return ret;
|
2003-06-22 03:59:01 +00:00
|
|
|
}
|
|
|
|
|
2005-08-10 08:33:19 +00:00
|
|
|
static gboolean
|
2011-11-17 14:25:58 +00:00
|
|
|
gst_rmdemux_src_event (GstPad * pad, GstObject * parent, GstEvent * event)
|
2005-08-10 08:33:19 +00:00
|
|
|
{
|
|
|
|
gboolean ret = TRUE;
|
|
|
|
|
2011-11-17 14:25:58 +00:00
|
|
|
GstRMDemux *rmdemux = GST_RMDEMUX (parent);
|
2005-08-10 08:33:19 +00:00
|
|
|
|
|
|
|
GST_LOG_OBJECT (rmdemux, "handling src event");
|
|
|
|
|
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
gst/realmedia/rmdemux.*: Cleanups, use GstSegment for seeking.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_finalize), (gst_rmdemux_src_event),
(find_seek_offset_time), (gst_rmdemux_perform_seek),
(gst_rmdemux_src_query), (gst_rmdemux_change_state),
(gst_rmdemux_loop), (gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream), (gst_rmdemux_parse_mdpr),
(gst_rmdemux_combine_flows), (gst_rmdemux_parse_packet):
* gst/realmedia/rmdemux.h:
Cleanups, use GstSegment for seeking.
Fix error handling.
Combine flow return from all streams.
2006-07-13 11:28:32 +00:00
|
|
|
case GST_EVENT_SEEK:
|
|
|
|
{
|
2005-08-10 08:33:19 +00:00
|
|
|
gboolean running;
|
|
|
|
|
2005-08-22 07:33:00 +00:00
|
|
|
GST_LOG_OBJECT (rmdemux, "Event on src: SEEK");
|
2005-08-10 08:33:19 +00:00
|
|
|
/* can't seek if we are not seekable, FIXME could pass the
|
|
|
|
* seek query upstream after converting it to bytes using
|
|
|
|
* the average bitrate of the stream. */
|
|
|
|
if (!rmdemux->seekable) {
|
|
|
|
ret = FALSE;
|
|
|
|
GST_DEBUG ("seek on non seekable stream");
|
|
|
|
goto done_unref;
|
|
|
|
}
|
2005-09-29 13:44:15 +00:00
|
|
|
|
2005-11-21 16:36:44 +00:00
|
|
|
GST_OBJECT_LOCK (rmdemux);
|
2005-08-10 08:33:19 +00:00
|
|
|
/* check if we can do the seek now */
|
|
|
|
running = rmdemux->running;
|
2005-11-21 16:36:44 +00:00
|
|
|
GST_OBJECT_UNLOCK (rmdemux);
|
2005-08-10 08:33:19 +00:00
|
|
|
|
|
|
|
/* now do the seek */
|
|
|
|
if (running) {
|
gst/realmedia/rmdemux.*: Cleanups, use GstSegment for seeking.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_finalize), (gst_rmdemux_src_event),
(find_seek_offset_time), (gst_rmdemux_perform_seek),
(gst_rmdemux_src_query), (gst_rmdemux_change_state),
(gst_rmdemux_loop), (gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream), (gst_rmdemux_parse_mdpr),
(gst_rmdemux_combine_flows), (gst_rmdemux_parse_packet):
* gst/realmedia/rmdemux.h:
Cleanups, use GstSegment for seeking.
Fix error handling.
Combine flow return from all streams.
2006-07-13 11:28:32 +00:00
|
|
|
ret = gst_rmdemux_perform_seek (rmdemux, event);
|
2005-08-10 08:33:19 +00:00
|
|
|
} else
|
|
|
|
ret = TRUE;
|
gst/realmedia/rmdemux.*: Cleanups, use GstSegment for seeking.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_finalize), (gst_rmdemux_src_event),
(find_seek_offset_time), (gst_rmdemux_perform_seek),
(gst_rmdemux_src_query), (gst_rmdemux_change_state),
(gst_rmdemux_loop), (gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream), (gst_rmdemux_parse_mdpr),
(gst_rmdemux_combine_flows), (gst_rmdemux_parse_packet):
* gst/realmedia/rmdemux.h:
Cleanups, use GstSegment for seeking.
Fix error handling.
Combine flow return from all streams.
2006-07-13 11:28:32 +00:00
|
|
|
|
|
|
|
gst_event_unref (event);
|
2005-08-10 08:33:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2005-08-22 07:33:00 +00:00
|
|
|
GST_LOG_OBJECT (rmdemux, "Event on src: type=%d", GST_EVENT_TYPE (event));
|
2011-11-17 14:25:58 +00:00
|
|
|
ret = gst_pad_event_default (pad, parent, event);
|
2005-08-10 08:33:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
done_unref:
|
|
|
|
GST_DEBUG ("error handling event");
|
|
|
|
gst_event_unref (event);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-10-05 11:25:51 +00:00
|
|
|
/* Validate that this looks like a reasonable point to seek to */
|
|
|
|
static gboolean
|
|
|
|
gst_rmdemux_validate_offset (GstRMDemux * rmdemux)
|
|
|
|
{
|
|
|
|
GstBuffer *buffer;
|
|
|
|
GstFlowReturn flowret;
|
|
|
|
guint16 version, length;
|
|
|
|
gboolean ret = TRUE;
|
2012-01-25 06:24:59 +00:00
|
|
|
GstMapInfo map;
|
2005-10-05 11:25:51 +00:00
|
|
|
|
2012-03-16 20:48:02 +00:00
|
|
|
buffer = NULL;
|
2005-10-05 11:25:51 +00:00
|
|
|
flowret = gst_pad_pull_range (rmdemux->sinkpad, rmdemux->offset, 4, &buffer);
|
|
|
|
|
|
|
|
if (flowret != GST_FLOW_OK) {
|
|
|
|
GST_DEBUG_OBJECT (rmdemux, "Failed to pull data at offset %d",
|
|
|
|
rmdemux->offset);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2006-03-24 12:08:39 +00:00
|
|
|
/* TODO: Can we also be seeking to a 'DATA' chunk header? Check this.
|
|
|
|
* Also, for the case we currently handle, can we check any more? It's pretty
|
|
|
|
* sucky to not be validating a little more heavily than this... */
|
2005-10-05 11:25:51 +00:00
|
|
|
/* This should now be the start of a data packet header. That begins with
|
|
|
|
* a 2-byte 'version' field, which has to be 0 or 1, then a length. I'm not
|
|
|
|
* certain what values are valid for length, but it must always be at least
|
|
|
|
* 4 bytes, and we can check that it won't take us past our known total size
|
|
|
|
*/
|
|
|
|
|
2012-01-25 06:24:59 +00:00
|
|
|
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
|
|
|
version = RMDEMUX_GUINT16_GET (map.data);
|
2005-10-05 11:25:51 +00:00
|
|
|
if (version != 0 && version != 1) {
|
|
|
|
GST_DEBUG_OBJECT (rmdemux, "Expected version 0 or 1, got %d",
|
|
|
|
(int) version);
|
|
|
|
ret = FALSE;
|
|
|
|
}
|
|
|
|
|
2012-01-25 06:24:59 +00:00
|
|
|
length = RMDEMUX_GUINT16_GET (map.data + 2);
|
2006-03-24 12:08:39 +00:00
|
|
|
/* TODO: Also check against total stream length */
|
2005-10-05 11:25:51 +00:00
|
|
|
if (length < 4) {
|
|
|
|
GST_DEBUG_OBJECT (rmdemux, "Expected length >= 4, got %d", (int) length);
|
|
|
|
ret = FALSE;
|
|
|
|
}
|
2012-01-25 06:24:59 +00:00
|
|
|
gst_buffer_unmap (buffer, &map);
|
2005-10-05 11:25:51 +00:00
|
|
|
|
|
|
|
if (ret) {
|
|
|
|
rmdemux->offset += 4;
|
|
|
|
gst_adapter_clear (rmdemux->adapter);
|
|
|
|
gst_adapter_push (rmdemux->adapter, buffer);
|
|
|
|
} else {
|
|
|
|
GST_WARNING_OBJECT (rmdemux, "Failed to validate seek offset at %d",
|
|
|
|
rmdemux->offset);
|
2011-10-05 11:18:45 +00:00
|
|
|
gst_buffer_unref (buffer);
|
2005-10-05 11:25:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
find_seek_offset_bytes (GstRMDemux * rmdemux, guint target)
|
|
|
|
{
|
2007-04-12 10:10:22 +00:00
|
|
|
int i;
|
|
|
|
GSList *cur;
|
2005-10-05 11:25:51 +00:00
|
|
|
gboolean ret = FALSE;
|
|
|
|
|
2007-04-12 10:10:22 +00:00
|
|
|
for (cur = rmdemux->streams; cur; cur = cur->next) {
|
|
|
|
GstRMDemuxStream *stream = cur->data;
|
2005-10-05 11:25:51 +00:00
|
|
|
|
|
|
|
/* Search backwards through this stream's index until we find the first
|
|
|
|
* timestamp before our target time */
|
|
|
|
for (i = stream->index_length - 1; i >= 0; i--) {
|
|
|
|
if (stream->index[i].offset <= target) {
|
|
|
|
/* Set the seek_offset for the stream so we don't bother parsing it
|
|
|
|
* until we've passed that point */
|
|
|
|
stream->seek_offset = stream->index[i].offset;
|
|
|
|
rmdemux->offset = stream->index[i].offset;
|
|
|
|
ret = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
find_seek_offset_time (GstRMDemux * rmdemux, GstClockTime time)
|
|
|
|
{
|
2007-04-12 10:10:22 +00:00
|
|
|
int i, n_stream;
|
2005-10-05 11:25:51 +00:00
|
|
|
gboolean ret = FALSE;
|
2007-04-12 10:10:22 +00:00
|
|
|
GSList *cur;
|
2005-10-05 11:25:51 +00:00
|
|
|
GstClockTime earliest = GST_CLOCK_TIME_NONE;
|
|
|
|
|
2007-04-12 10:10:22 +00:00
|
|
|
n_stream = 0;
|
|
|
|
for (cur = rmdemux->streams; cur; cur = cur->next, n_stream++) {
|
|
|
|
GstRMDemuxStream *stream = cur->data;
|
2005-10-05 11:25:51 +00:00
|
|
|
|
|
|
|
/* Search backwards through this stream's index until we find the first
|
|
|
|
* timestamp before our target time */
|
|
|
|
for (i = stream->index_length - 1; i >= 0; i--) {
|
|
|
|
if (stream->index[i].timestamp <= time) {
|
|
|
|
/* Set the seek_offset for the stream so we don't bother parsing it
|
|
|
|
* until we've passed that point */
|
|
|
|
stream->seek_offset = stream->index[i].offset;
|
|
|
|
|
|
|
|
/* If it's also the earliest timestamp we've seen of all streams, then
|
|
|
|
* that's our target!
|
|
|
|
*/
|
|
|
|
if (earliest == GST_CLOCK_TIME_NONE ||
|
|
|
|
stream->index[i].timestamp < earliest) {
|
|
|
|
earliest = stream->index[i].timestamp;
|
|
|
|
rmdemux->offset = stream->index[i].offset;
|
|
|
|
GST_DEBUG_OBJECT (rmdemux,
|
|
|
|
"We're looking for %" GST_TIME_FORMAT
|
|
|
|
" and we found that stream %d has the latest index at %"
|
2007-04-12 10:10:22 +00:00
|
|
|
GST_TIME_FORMAT, GST_TIME_ARGS (rmdemux->segment.start), n_stream,
|
2005-10-05 11:25:51 +00:00
|
|
|
GST_TIME_ARGS (earliest));
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = TRUE;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-08-27 09:47:17 +00:00
|
|
|
stream->discont = TRUE;
|
2005-10-05 11:25:51 +00:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-08-10 08:33:19 +00:00
|
|
|
static gboolean
|
gst/realmedia/rmdemux.*: Cleanups, use GstSegment for seeking.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_finalize), (gst_rmdemux_src_event),
(find_seek_offset_time), (gst_rmdemux_perform_seek),
(gst_rmdemux_src_query), (gst_rmdemux_change_state),
(gst_rmdemux_loop), (gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream), (gst_rmdemux_parse_mdpr),
(gst_rmdemux_combine_flows), (gst_rmdemux_parse_packet):
* gst/realmedia/rmdemux.h:
Cleanups, use GstSegment for seeking.
Fix error handling.
Combine flow return from all streams.
2006-07-13 11:28:32 +00:00
|
|
|
gst_rmdemux_perform_seek (GstRMDemux * rmdemux, GstEvent * event)
|
2005-08-10 08:33:19 +00:00
|
|
|
{
|
2005-10-05 11:25:51 +00:00
|
|
|
gboolean validated;
|
|
|
|
gboolean ret = TRUE;
|
2009-04-19 11:58:31 +00:00
|
|
|
gboolean flush;
|
gst/realmedia/rmdemux.*: Cleanups, use GstSegment for seeking.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_finalize), (gst_rmdemux_src_event),
(find_seek_offset_time), (gst_rmdemux_perform_seek),
(gst_rmdemux_src_query), (gst_rmdemux_change_state),
(gst_rmdemux_loop), (gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream), (gst_rmdemux_parse_mdpr),
(gst_rmdemux_combine_flows), (gst_rmdemux_parse_packet):
* gst/realmedia/rmdemux.h:
Cleanups, use GstSegment for seeking.
Fix error handling.
Combine flow return from all streams.
2006-07-13 11:28:32 +00:00
|
|
|
GstFormat format;
|
|
|
|
gdouble rate;
|
|
|
|
GstSeekFlags flags;
|
|
|
|
GstSeekType cur_type, stop_type;
|
|
|
|
gint64 cur, stop;
|
|
|
|
gboolean update;
|
|
|
|
|
|
|
|
if (event) {
|
|
|
|
GST_DEBUG_OBJECT (rmdemux, "seek with event");
|
|
|
|
|
|
|
|
gst_event_parse_seek (event, &rate, &format, &flags,
|
|
|
|
&cur_type, &cur, &stop_type, &stop);
|
|
|
|
|
|
|
|
/* we can only seek on time */
|
|
|
|
if (format != GST_FORMAT_TIME) {
|
|
|
|
GST_DEBUG_OBJECT (rmdemux, "can only seek on TIME");
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
/* cannot yet do backwards playback */
|
|
|
|
if (rate <= 0.0) {
|
|
|
|
GST_DEBUG_OBJECT (rmdemux, "can only seek with positive rate, not %lf",
|
|
|
|
rate);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
GST_DEBUG_OBJECT (rmdemux, "seek without event");
|
|
|
|
|
|
|
|
flags = 0;
|
|
|
|
rate = 1.0;
|
|
|
|
}
|
2005-10-05 11:25:51 +00:00
|
|
|
|
gst/realmedia/rmdemux.*: Cleanups, use GstSegment for seeking.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_finalize), (gst_rmdemux_src_event),
(find_seek_offset_time), (gst_rmdemux_perform_seek),
(gst_rmdemux_src_query), (gst_rmdemux_change_state),
(gst_rmdemux_loop), (gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream), (gst_rmdemux_parse_mdpr),
(gst_rmdemux_combine_flows), (gst_rmdemux_parse_packet):
* gst/realmedia/rmdemux.h:
Cleanups, use GstSegment for seeking.
Fix error handling.
Combine flow return from all streams.
2006-07-13 11:28:32 +00:00
|
|
|
GST_DEBUG_OBJECT (rmdemux, "seek, rate %g", rate);
|
2005-08-10 08:33:19 +00:00
|
|
|
|
gst/realmedia/rmdemux.*: Cleanups, use GstSegment for seeking.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_finalize), (gst_rmdemux_src_event),
(find_seek_offset_time), (gst_rmdemux_perform_seek),
(gst_rmdemux_src_query), (gst_rmdemux_change_state),
(gst_rmdemux_loop), (gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream), (gst_rmdemux_parse_mdpr),
(gst_rmdemux_combine_flows), (gst_rmdemux_parse_packet):
* gst/realmedia/rmdemux.h:
Cleanups, use GstSegment for seeking.
Fix error handling.
Combine flow return from all streams.
2006-07-13 11:28:32 +00:00
|
|
|
flush = flags & GST_SEEK_FLAG_FLUSH;
|
2005-08-10 08:33:19 +00:00
|
|
|
|
|
|
|
/* first step is to unlock the streaming thread if it is
|
2005-09-29 13:44:15 +00:00
|
|
|
* blocked in a chain call, we do this by starting the flush. */
|
2005-08-10 08:33:19 +00:00
|
|
|
if (flush) {
|
gst/realmedia/rmdemux.*: Cleanups, use GstSegment for seeking.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_finalize), (gst_rmdemux_src_event),
(find_seek_offset_time), (gst_rmdemux_perform_seek),
(gst_rmdemux_src_query), (gst_rmdemux_change_state),
(gst_rmdemux_loop), (gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream), (gst_rmdemux_parse_mdpr),
(gst_rmdemux_combine_flows), (gst_rmdemux_parse_packet):
* gst/realmedia/rmdemux.h:
Cleanups, use GstSegment for seeking.
Fix error handling.
Combine flow return from all streams.
2006-07-13 11:28:32 +00:00
|
|
|
gst_pad_push_event (rmdemux->sinkpad, gst_event_new_flush_start ());
|
2006-03-24 11:42:31 +00:00
|
|
|
gst_rmdemux_send_event (rmdemux, gst_event_new_flush_start ());
|
2005-08-10 08:33:19 +00:00
|
|
|
} else {
|
|
|
|
gst_pad_pause_task (rmdemux->sinkpad);
|
|
|
|
}
|
|
|
|
|
2005-10-05 11:25:51 +00:00
|
|
|
GST_LOG_OBJECT (rmdemux, "Done starting flushes");
|
|
|
|
|
2005-08-10 08:33:19 +00:00
|
|
|
/* now grab the stream lock so that streaming cannot continue, for
|
|
|
|
* non flushing seeks when the element is in PAUSED this could block
|
|
|
|
* forever. */
|
2005-11-21 17:34:30 +00:00
|
|
|
GST_PAD_STREAM_LOCK (rmdemux->sinkpad);
|
2005-08-10 08:33:19 +00:00
|
|
|
|
2005-10-05 11:25:51 +00:00
|
|
|
GST_LOG_OBJECT (rmdemux, "Took streamlock");
|
|
|
|
|
gst/realmedia/rmdemux.*: Cleanups, use GstSegment for seeking.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_finalize), (gst_rmdemux_src_event),
(find_seek_offset_time), (gst_rmdemux_perform_seek),
(gst_rmdemux_src_query), (gst_rmdemux_change_state),
(gst_rmdemux_loop), (gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream), (gst_rmdemux_parse_mdpr),
(gst_rmdemux_combine_flows), (gst_rmdemux_parse_packet):
* gst/realmedia/rmdemux.h:
Cleanups, use GstSegment for seeking.
Fix error handling.
Combine flow return from all streams.
2006-07-13 11:28:32 +00:00
|
|
|
if (event) {
|
2011-10-05 11:18:45 +00:00
|
|
|
gst_segment_do_seek (&rmdemux->segment, rate, format, flags,
|
gst/realmedia/rmdemux.*: Cleanups, use GstSegment for seeking.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_finalize), (gst_rmdemux_src_event),
(find_seek_offset_time), (gst_rmdemux_perform_seek),
(gst_rmdemux_src_query), (gst_rmdemux_change_state),
(gst_rmdemux_loop), (gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream), (gst_rmdemux_parse_mdpr),
(gst_rmdemux_combine_flows), (gst_rmdemux_parse_packet):
* gst/realmedia/rmdemux.h:
Cleanups, use GstSegment for seeking.
Fix error handling.
Combine flow return from all streams.
2006-07-13 11:28:32 +00:00
|
|
|
cur_type, cur, stop_type, stop, &update);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (rmdemux, "segment positions set to %" GST_TIME_FORMAT "-%"
|
|
|
|
GST_TIME_FORMAT, GST_TIME_ARGS (rmdemux->segment.start),
|
|
|
|
GST_TIME_ARGS (rmdemux->segment.stop));
|
|
|
|
|
2005-09-29 13:44:15 +00:00
|
|
|
/* we need to stop flushing on the sinkpad as we're going to use it
|
2005-08-10 08:33:19 +00:00
|
|
|
* next. We can do this as we have the STREAM lock now. */
|
2011-10-05 11:18:45 +00:00
|
|
|
gst_pad_push_event (rmdemux->sinkpad, gst_event_new_flush_stop (TRUE));
|
2005-08-10 08:33:19 +00:00
|
|
|
|
2005-10-05 11:25:51 +00:00
|
|
|
GST_LOG_OBJECT (rmdemux, "Pushed FLUSH_STOP event");
|
2005-08-10 08:33:19 +00:00
|
|
|
|
2005-10-05 11:25:51 +00:00
|
|
|
/* For each stream, find the first index offset equal to or before our seek
|
|
|
|
* target. Of these, find the smallest offset. That's where we seek to.
|
|
|
|
*
|
gst/realmedia/rmdemux.c: Fractional framerates.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_sink_event),
(gst_rmdemux_src_event), (gst_rmdemux_validate_offset),
(find_seek_offset_bytes), (find_seek_offset_time),
(gst_rmdemux_perform_seek), (gst_rmdemux_src_query),
(gst_rmdemux_loop), (gst_rmdemux_fourcc_isplausible),
(gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream), (gst_rmdemux_parse_mdpr),
(gst_rmdemux_parse_packet):
Fractional framerates.
2005-11-23 00:26:42 +00:00
|
|
|
* Then we pull 4 bytes from that offset, and validate that we've seeked to a
|
|
|
|
* what looks like a plausible packet.
|
2005-10-05 11:25:51 +00:00
|
|
|
* If that fails, restart, with the seek target set to one less than the
|
|
|
|
* offset we just tried. If we run out of places to try, treat that as a fatal
|
|
|
|
* error.
|
|
|
|
*/
|
2011-10-05 11:18:45 +00:00
|
|
|
if (!find_seek_offset_time (rmdemux, rmdemux->segment.position)) {
|
2005-10-05 11:25:51 +00:00
|
|
|
GST_LOG_OBJECT (rmdemux, "Failed to find seek offset by time");
|
|
|
|
ret = FALSE;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_LOG_OBJECT (rmdemux, "Validating offset %u", rmdemux->offset);
|
|
|
|
validated = gst_rmdemux_validate_offset (rmdemux);
|
|
|
|
while (!validated) {
|
|
|
|
GST_INFO_OBJECT (rmdemux, "Failed to validate offset at %u",
|
|
|
|
rmdemux->offset);
|
|
|
|
if (!find_seek_offset_bytes (rmdemux, rmdemux->offset - 1)) {
|
|
|
|
ret = FALSE;
|
|
|
|
goto done;
|
2005-08-10 08:33:19 +00:00
|
|
|
}
|
2005-10-05 11:25:51 +00:00
|
|
|
validated = gst_rmdemux_validate_offset (rmdemux);
|
2005-08-10 08:33:19 +00:00
|
|
|
}
|
|
|
|
|
2005-10-05 11:25:51 +00:00
|
|
|
GST_LOG_OBJECT (rmdemux, "Found final offset. Excellent!");
|
|
|
|
|
2005-08-10 08:33:19 +00:00
|
|
|
/* now we have a new position, prepare for streaming again */
|
|
|
|
{
|
|
|
|
/* Reset the demuxer state */
|
|
|
|
rmdemux->state = RMDEMUX_STATE_DATA_PACKET;
|
|
|
|
|
|
|
|
if (flush)
|
2011-10-05 11:18:45 +00:00
|
|
|
gst_rmdemux_send_event (rmdemux, gst_event_new_flush_stop (TRUE));
|
2005-08-10 08:33:19 +00:00
|
|
|
|
2007-05-16 19:07:45 +00:00
|
|
|
/* must send newsegment event from streaming thread, so just set flag */
|
|
|
|
rmdemux->need_newsegment = TRUE;
|
2005-08-10 08:33:19 +00:00
|
|
|
|
|
|
|
/* notify start of new segment */
|
gst/realmedia/rmdemux.*: Cleanups, use GstSegment for seeking.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_finalize), (gst_rmdemux_src_event),
(find_seek_offset_time), (gst_rmdemux_perform_seek),
(gst_rmdemux_src_query), (gst_rmdemux_change_state),
(gst_rmdemux_loop), (gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream), (gst_rmdemux_parse_mdpr),
(gst_rmdemux_combine_flows), (gst_rmdemux_parse_packet):
* gst/realmedia/rmdemux.h:
Cleanups, use GstSegment for seeking.
Fix error handling.
Combine flow return from all streams.
2006-07-13 11:28:32 +00:00
|
|
|
if (rmdemux->segment.flags & GST_SEEK_FLAG_SEGMENT) {
|
|
|
|
gst_element_post_message (GST_ELEMENT_CAST (rmdemux),
|
|
|
|
gst_message_new_segment_start (GST_OBJECT_CAST (rmdemux),
|
2011-10-05 11:18:45 +00:00
|
|
|
GST_FORMAT_TIME, rmdemux->segment.position));
|
2005-08-10 08:33:19 +00:00
|
|
|
}
|
2007-05-16 19:07:45 +00:00
|
|
|
|
2005-08-10 08:33:19 +00:00
|
|
|
/* restart our task since it might have been stopped when we did the
|
|
|
|
* flush. */
|
|
|
|
gst_pad_start_task (rmdemux->sinkpad, (GstTaskFunction) gst_rmdemux_loop,
|
2012-06-20 08:39:37 +00:00
|
|
|
rmdemux->sinkpad, NULL);
|
2005-08-10 08:33:19 +00:00
|
|
|
}
|
|
|
|
|
2005-10-05 11:25:51 +00:00
|
|
|
done:
|
2005-08-10 08:33:19 +00:00
|
|
|
/* streaming can continue now */
|
2005-11-21 17:34:30 +00:00
|
|
|
GST_PAD_STREAM_UNLOCK (rmdemux->sinkpad);
|
2005-08-10 08:33:19 +00:00
|
|
|
|
2009-04-21 18:21:11 +00:00
|
|
|
return ret;
|
gst/realmedia/rmdemux.*: Cleanups, use GstSegment for seeking.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_finalize), (gst_rmdemux_src_event),
(find_seek_offset_time), (gst_rmdemux_perform_seek),
(gst_rmdemux_src_query), (gst_rmdemux_change_state),
(gst_rmdemux_loop), (gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream), (gst_rmdemux_parse_mdpr),
(gst_rmdemux_combine_flows), (gst_rmdemux_parse_packet):
* gst/realmedia/rmdemux.h:
Cleanups, use GstSegment for seeking.
Fix error handling.
Combine flow return from all streams.
2006-07-13 11:28:32 +00:00
|
|
|
|
|
|
|
error:
|
|
|
|
{
|
|
|
|
GST_DEBUG_OBJECT (rmdemux, "seek failed");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2005-08-10 08:33:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gboolean
|
2011-11-16 16:28:56 +00:00
|
|
|
gst_rmdemux_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
|
2005-08-10 08:33:19 +00:00
|
|
|
{
|
2006-12-15 18:25:17 +00:00
|
|
|
gboolean res = FALSE;
|
2005-08-10 08:33:19 +00:00
|
|
|
GstRMDemux *rmdemux;
|
|
|
|
|
2011-11-16 16:28:56 +00:00
|
|
|
rmdemux = GST_RMDEMUX (parent);
|
2005-08-10 08:33:19 +00:00
|
|
|
|
|
|
|
switch (GST_QUERY_TYPE (query)) {
|
|
|
|
case GST_QUERY_POSITION:
|
gst/realmedia/rmdemux.c: Fractional framerates.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_sink_event),
(gst_rmdemux_src_event), (gst_rmdemux_validate_offset),
(find_seek_offset_bytes), (find_seek_offset_time),
(gst_rmdemux_perform_seek), (gst_rmdemux_src_query),
(gst_rmdemux_loop), (gst_rmdemux_fourcc_isplausible),
(gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream), (gst_rmdemux_parse_mdpr),
(gst_rmdemux_parse_packet):
Fractional framerates.
2005-11-23 00:26:42 +00:00
|
|
|
GST_DEBUG_OBJECT (rmdemux, "Position query: no idea from demuxer!");
|
2005-08-10 08:33:19 +00:00
|
|
|
break;
|
2006-12-15 18:25:17 +00:00
|
|
|
case GST_QUERY_DURATION:{
|
|
|
|
GstFormat fmt;
|
|
|
|
|
|
|
|
gst_query_parse_duration (query, &fmt, NULL);
|
|
|
|
if (fmt == GST_FORMAT_TIME) {
|
|
|
|
GST_OBJECT_LOCK (rmdemux);
|
|
|
|
if (G_LIKELY (rmdemux->running)) {
|
|
|
|
gst_query_set_duration (query, GST_FORMAT_TIME, rmdemux->duration);
|
|
|
|
GST_DEBUG_OBJECT (rmdemux, "duration set to %" GST_TIME_FORMAT,
|
|
|
|
GST_TIME_ARGS (rmdemux->duration));
|
|
|
|
res = TRUE;
|
|
|
|
}
|
|
|
|
GST_OBJECT_UNLOCK (rmdemux);
|
|
|
|
}
|
2005-08-10 08:33:19 +00:00
|
|
|
break;
|
2006-12-15 18:25:17 +00:00
|
|
|
}
|
|
|
|
case GST_QUERY_SEEKING:{
|
|
|
|
GstFormat fmt;
|
|
|
|
|
|
|
|
gst_query_parse_seeking (query, &fmt, NULL, NULL, NULL);
|
|
|
|
if (fmt == GST_FORMAT_TIME) {
|
|
|
|
GST_OBJECT_LOCK (rmdemux);
|
|
|
|
if (G_LIKELY (rmdemux->running)) {
|
|
|
|
gst_query_set_seeking (query, GST_FORMAT_TIME, rmdemux->seekable,
|
|
|
|
0, rmdemux->duration);
|
|
|
|
res = TRUE;
|
|
|
|
}
|
|
|
|
GST_OBJECT_UNLOCK (rmdemux);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2013-07-29 08:57:38 +00:00
|
|
|
case GST_QUERY_SEGMENT:
|
|
|
|
{
|
|
|
|
GstFormat format;
|
|
|
|
gint64 start, stop;
|
|
|
|
|
|
|
|
format = rmdemux->segment.format;
|
|
|
|
|
|
|
|
start =
|
|
|
|
gst_segment_to_stream_time (&rmdemux->segment, format,
|
|
|
|
rmdemux->segment.start);
|
|
|
|
if ((stop = rmdemux->segment.stop) == -1)
|
|
|
|
stop = rmdemux->segment.duration;
|
|
|
|
else
|
|
|
|
stop = gst_segment_to_stream_time (&rmdemux->segment, format, stop);
|
|
|
|
|
|
|
|
gst_query_set_segment (query, rmdemux->segment.rate, format, start, stop);
|
|
|
|
res = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
2005-08-10 08:33:19 +00:00
|
|
|
default:
|
2011-11-16 16:28:56 +00:00
|
|
|
res = gst_pad_query_default (pad, parent, query);
|
2005-08-10 08:33:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2015-07-16 09:11:37 +00:00
|
|
|
static void
|
|
|
|
gst_rmdemux_free_stream (GstRMDemux * rmdemux, GstRMDemuxStream * stream)
|
|
|
|
{
|
|
|
|
g_object_unref (stream->adapter);
|
|
|
|
gst_rmdemux_stream_clear_cached_subpackets (rmdemux, stream);
|
|
|
|
if (stream->pending_tags)
|
|
|
|
gst_tag_list_unref (stream->pending_tags);
|
|
|
|
if (stream->subpackets)
|
|
|
|
g_ptr_array_free (stream->subpackets, TRUE);
|
|
|
|
g_free (stream->index);
|
|
|
|
g_free (stream);
|
|
|
|
}
|
|
|
|
|
2006-07-28 13:28:19 +00:00
|
|
|
static void
|
|
|
|
gst_rmdemux_reset (GstRMDemux * rmdemux)
|
|
|
|
{
|
2007-04-12 10:10:22 +00:00
|
|
|
GSList *cur;
|
2006-07-28 13:28:19 +00:00
|
|
|
|
|
|
|
GST_OBJECT_LOCK (rmdemux);
|
|
|
|
rmdemux->running = FALSE;
|
|
|
|
GST_OBJECT_UNLOCK (rmdemux);
|
|
|
|
|
2007-04-12 10:10:22 +00:00
|
|
|
for (cur = rmdemux->streams; cur; cur = cur->next) {
|
|
|
|
GstRMDemuxStream *stream = cur->data;
|
|
|
|
|
2014-05-26 20:55:43 +00:00
|
|
|
gst_flow_combiner_remove_pad (rmdemux->flowcombiner, stream->pad);
|
2007-04-12 10:10:22 +00:00
|
|
|
gst_element_remove_pad (GST_ELEMENT (rmdemux), stream->pad);
|
2015-07-16 09:11:37 +00:00
|
|
|
gst_rmdemux_free_stream (rmdemux, stream);
|
2006-07-28 13:28:19 +00:00
|
|
|
}
|
2007-04-12 10:10:22 +00:00
|
|
|
g_slist_free (rmdemux->streams);
|
|
|
|
rmdemux->streams = NULL;
|
2006-07-28 13:28:19 +00:00
|
|
|
rmdemux->n_audio_streams = 0;
|
|
|
|
rmdemux->n_video_streams = 0;
|
|
|
|
|
2011-09-08 13:33:00 +00:00
|
|
|
if (rmdemux->pending_tags != NULL) {
|
2012-08-04 15:13:36 +00:00
|
|
|
gst_tag_list_unref (rmdemux->pending_tags);
|
2011-09-08 13:33:00 +00:00
|
|
|
rmdemux->pending_tags = NULL;
|
|
|
|
}
|
|
|
|
|
2006-07-28 13:28:19 +00:00
|
|
|
gst_adapter_clear (rmdemux->adapter);
|
|
|
|
rmdemux->state = RMDEMUX_STATE_HEADER;
|
|
|
|
rmdemux->have_pads = FALSE;
|
|
|
|
|
|
|
|
gst_segment_init (&rmdemux->segment, GST_FORMAT_UNDEFINED);
|
2007-05-16 19:07:45 +00:00
|
|
|
rmdemux->first_ts = GST_CLOCK_TIME_NONE;
|
2008-08-27 09:47:17 +00:00
|
|
|
rmdemux->base_ts = GST_CLOCK_TIME_NONE;
|
2007-05-16 19:07:45 +00:00
|
|
|
rmdemux->need_newsegment = TRUE;
|
2013-07-22 14:01:13 +00:00
|
|
|
|
|
|
|
rmdemux->have_group_id = FALSE;
|
|
|
|
rmdemux->group_id = G_MAXUINT;
|
2006-07-28 13:28:19 +00:00
|
|
|
}
|
|
|
|
|
2005-09-02 15:43:54 +00:00
|
|
|
static GstStateChangeReturn
|
|
|
|
gst_rmdemux_change_state (GstElement * element, GstStateChange transition)
|
2003-06-22 03:59:01 +00:00
|
|
|
{
|
2004-03-14 22:34:30 +00:00
|
|
|
GstRMDemux *rmdemux = GST_RMDEMUX (element);
|
2005-09-02 15:43:54 +00:00
|
|
|
GstStateChangeReturn res;
|
2005-07-18 10:33:19 +00:00
|
|
|
|
|
|
|
switch (transition) {
|
2005-09-02 15:43:54 +00:00
|
|
|
case GST_STATE_CHANGE_NULL_TO_READY:
|
2003-06-22 03:59:01 +00:00
|
|
|
break;
|
2005-09-02 15:43:54 +00:00
|
|
|
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
2003-06-22 03:59:01 +00:00
|
|
|
rmdemux->state = RMDEMUX_STATE_HEADER;
|
2005-07-03 17:40:04 +00:00
|
|
|
rmdemux->have_pads = FALSE;
|
gst/realmedia/rmdemux.*: Cleanups, use GstSegment for seeking.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_finalize), (gst_rmdemux_src_event),
(find_seek_offset_time), (gst_rmdemux_perform_seek),
(gst_rmdemux_src_query), (gst_rmdemux_change_state),
(gst_rmdemux_loop), (gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream), (gst_rmdemux_parse_mdpr),
(gst_rmdemux_combine_flows), (gst_rmdemux_parse_packet):
* gst/realmedia/rmdemux.h:
Cleanups, use GstSegment for seeking.
Fix error handling.
Combine flow return from all streams.
2006-07-13 11:28:32 +00:00
|
|
|
gst_segment_init (&rmdemux->segment, GST_FORMAT_TIME);
|
2005-08-10 08:33:19 +00:00
|
|
|
rmdemux->running = FALSE;
|
2003-06-22 03:59:01 +00:00
|
|
|
break;
|
2005-09-02 15:43:54 +00:00
|
|
|
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
|
|
|
|
break;
|
|
|
|
default:
|
2003-06-22 03:59:01 +00:00
|
|
|
break;
|
2005-07-18 10:33:19 +00:00
|
|
|
}
|
|
|
|
|
2005-09-02 15:43:54 +00:00
|
|
|
res = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
|
2005-07-18 10:33:19 +00:00
|
|
|
|
|
|
|
switch (transition) {
|
2005-09-02 15:43:54 +00:00
|
|
|
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
|
2003-06-22 03:59:01 +00:00
|
|
|
break;
|
2006-07-28 13:28:19 +00:00
|
|
|
case GST_STATE_CHANGE_PAUSED_TO_READY:{
|
|
|
|
gst_rmdemux_reset (rmdemux);
|
2003-06-22 03:59:01 +00:00
|
|
|
break;
|
2006-07-28 13:28:19 +00:00
|
|
|
}
|
2005-09-02 15:43:54 +00:00
|
|
|
case GST_STATE_CHANGE_READY_TO_NULL:
|
2003-06-22 03:59:01 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-07-18 10:33:19 +00:00
|
|
|
return res;
|
2003-06-22 03:59:01 +00:00
|
|
|
}
|
|
|
|
|
2005-08-10 08:33:19 +00:00
|
|
|
/* this function is called when the pad is activated and should start
|
|
|
|
* processing data.
|
|
|
|
*
|
|
|
|
* We check if we can do random access to decide if we work push or
|
|
|
|
* pull based.
|
|
|
|
*/
|
|
|
|
static gboolean
|
2011-11-18 12:59:29 +00:00
|
|
|
gst_rmdemux_sink_activate (GstPad * sinkpad, GstObject * parent)
|
2005-08-10 08:33:19 +00:00
|
|
|
{
|
2011-10-05 11:18:45 +00:00
|
|
|
GstQuery *query;
|
|
|
|
gboolean pull_mode;
|
|
|
|
|
|
|
|
query = gst_query_new_scheduling ();
|
|
|
|
|
|
|
|
if (!gst_pad_peer_query (sinkpad, query)) {
|
|
|
|
gst_query_unref (query);
|
|
|
|
goto activate_push;
|
|
|
|
}
|
|
|
|
|
2012-09-11 15:37:03 +00:00
|
|
|
pull_mode = gst_query_has_scheduling_mode_with_flags (query,
|
|
|
|
GST_PAD_MODE_PULL, GST_SCHEDULING_FLAG_SEEKABLE);
|
2011-11-18 17:00:28 +00:00
|
|
|
gst_query_unref (query);
|
2011-10-05 11:18:45 +00:00
|
|
|
|
|
|
|
if (!pull_mode)
|
|
|
|
goto activate_push;
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (sinkpad, "activating pull");
|
2011-11-21 12:36:10 +00:00
|
|
|
return gst_pad_activate_mode (sinkpad, GST_PAD_MODE_PULL, TRUE);
|
2011-10-05 11:18:45 +00:00
|
|
|
|
|
|
|
activate_push:
|
|
|
|
{
|
|
|
|
GST_DEBUG_OBJECT (sinkpad, "activating push");
|
2011-11-21 12:36:10 +00:00
|
|
|
return gst_pad_activate_mode (sinkpad, GST_PAD_MODE_PUSH, TRUE);
|
2005-08-10 08:33:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2011-11-21 12:36:10 +00:00
|
|
|
gst_rmdemux_sink_activate_mode (GstPad * sinkpad, GstObject * parent,
|
|
|
|
GstPadMode mode, gboolean active)
|
2005-08-10 08:33:19 +00:00
|
|
|
{
|
2011-11-21 12:36:10 +00:00
|
|
|
gboolean res;
|
|
|
|
GstRMDemux *demux;
|
2005-08-10 08:33:19 +00:00
|
|
|
|
2011-11-21 12:36:10 +00:00
|
|
|
demux = GST_RMDEMUX (parent);
|
2005-08-10 08:33:19 +00:00
|
|
|
|
2011-11-21 12:36:10 +00:00
|
|
|
switch (mode) {
|
|
|
|
case GST_PAD_MODE_PUSH:
|
|
|
|
demux->seekable = FALSE;
|
2013-07-18 15:14:29 +00:00
|
|
|
demux->running = active;
|
2011-11-21 12:36:10 +00:00
|
|
|
res = TRUE;
|
|
|
|
break;
|
|
|
|
case GST_PAD_MODE_PULL:
|
|
|
|
if (active) {
|
|
|
|
demux->seekable = TRUE;
|
|
|
|
demux->offset = 0;
|
|
|
|
demux->loop_state = RMDEMUX_LOOP_STATE_HEADER;
|
|
|
|
demux->data_offset = G_MAXUINT;
|
|
|
|
res =
|
|
|
|
gst_pad_start_task (sinkpad, (GstTaskFunction) gst_rmdemux_loop,
|
2012-06-20 08:39:37 +00:00
|
|
|
sinkpad, NULL);
|
2011-11-21 12:36:10 +00:00
|
|
|
} else {
|
|
|
|
res = gst_pad_stop_task (sinkpad);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
res = FALSE;
|
|
|
|
break;
|
2005-08-10 08:33:19 +00:00
|
|
|
}
|
2011-11-21 12:36:10 +00:00
|
|
|
return res;
|
2005-08-10 08:33:19 +00:00
|
|
|
}
|
|
|
|
|
2011-11-21 12:36:10 +00:00
|
|
|
|
2005-08-10 08:33:19 +00:00
|
|
|
/* random access mode - just pass over to our chain function */
|
|
|
|
static void
|
|
|
|
gst_rmdemux_loop (GstPad * pad)
|
|
|
|
{
|
|
|
|
GstRMDemux *rmdemux;
|
|
|
|
GstBuffer *buffer;
|
2005-09-29 13:44:15 +00:00
|
|
|
GstFlowReturn ret = GST_FLOW_OK;
|
2005-08-10 08:33:19 +00:00
|
|
|
guint size;
|
|
|
|
|
|
|
|
rmdemux = GST_RMDEMUX (GST_PAD_PARENT (pad));
|
|
|
|
|
2006-03-24 12:08:39 +00:00
|
|
|
GST_LOG_OBJECT (rmdemux, "loop with state=%d and offset=0x%x",
|
2005-08-10 08:33:19 +00:00
|
|
|
rmdemux->loop_state, rmdemux->offset);
|
|
|
|
|
|
|
|
switch (rmdemux->state) {
|
|
|
|
case RMDEMUX_STATE_HEADER:
|
|
|
|
size = HEADER_SIZE;
|
|
|
|
break;
|
|
|
|
case RMDEMUX_STATE_HEADER_DATA:
|
|
|
|
size = DATA_SIZE;
|
|
|
|
break;
|
|
|
|
case RMDEMUX_STATE_DATA_PACKET:
|
|
|
|
size = rmdemux->avg_packet_size;
|
|
|
|
break;
|
2005-08-25 00:32:22 +00:00
|
|
|
case RMDEMUX_STATE_EOS:
|
2005-10-05 11:25:51 +00:00
|
|
|
GST_LOG_OBJECT (rmdemux, "At EOS, pausing task");
|
2012-01-03 14:27:42 +00:00
|
|
|
ret = GST_FLOW_EOS;
|
2005-08-25 00:32:22 +00:00
|
|
|
goto need_pause;
|
2005-08-10 08:33:19 +00:00
|
|
|
default:
|
2005-09-30 16:39:47 +00:00
|
|
|
GST_LOG_OBJECT (rmdemux, "Default: requires %d bytes (state is %d)",
|
|
|
|
(int) rmdemux->size, rmdemux->state);
|
2005-08-10 08:33:19 +00:00
|
|
|
size = rmdemux->size;
|
|
|
|
}
|
|
|
|
|
2012-03-16 20:48:02 +00:00
|
|
|
buffer = NULL;
|
2005-08-10 08:33:19 +00:00
|
|
|
ret = gst_pad_pull_range (pad, rmdemux->offset, size, &buffer);
|
2005-08-25 00:32:22 +00:00
|
|
|
if (ret != GST_FLOW_OK) {
|
|
|
|
if (rmdemux->offset == rmdemux->index_offset) {
|
|
|
|
/* The index isn't available so forget about it */
|
|
|
|
rmdemux->loop_state = RMDEMUX_LOOP_STATE_DATA;
|
|
|
|
rmdemux->offset = rmdemux->data_offset;
|
2005-11-21 16:36:44 +00:00
|
|
|
GST_OBJECT_LOCK (rmdemux);
|
2005-08-25 00:32:22 +00:00
|
|
|
rmdemux->running = TRUE;
|
|
|
|
rmdemux->seekable = FALSE;
|
2005-11-21 16:36:44 +00:00
|
|
|
GST_OBJECT_UNLOCK (rmdemux);
|
2005-08-25 00:32:22 +00:00
|
|
|
return;
|
|
|
|
} else {
|
2006-10-05 17:07:52 +00:00
|
|
|
GST_DEBUG_OBJECT (rmdemux, "Unable to pull %d bytes at offset 0x%08x "
|
|
|
|
"(pull_range returned flow %s, state is %d)", (gint) size,
|
|
|
|
rmdemux->offset, gst_flow_get_name (ret), GST_STATE (rmdemux));
|
2005-08-25 00:32:22 +00:00
|
|
|
goto need_pause;
|
|
|
|
}
|
|
|
|
}
|
2005-08-10 08:33:19 +00:00
|
|
|
|
2012-01-09 15:00:18 +00:00
|
|
|
size = gst_buffer_get_size (buffer);
|
|
|
|
|
2005-08-10 08:33:19 +00:00
|
|
|
/* Defer to the chain function */
|
2011-11-17 14:25:58 +00:00
|
|
|
ret = gst_rmdemux_chain (pad, GST_OBJECT_CAST (rmdemux), buffer);
|
2005-09-29 13:44:15 +00:00
|
|
|
if (ret != GST_FLOW_OK) {
|
gst/realmedia/rmdemux.*: Cleanups, use GstSegment for seeking.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_finalize), (gst_rmdemux_src_event),
(find_seek_offset_time), (gst_rmdemux_perform_seek),
(gst_rmdemux_src_query), (gst_rmdemux_change_state),
(gst_rmdemux_loop), (gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream), (gst_rmdemux_parse_mdpr),
(gst_rmdemux_combine_flows), (gst_rmdemux_parse_packet):
* gst/realmedia/rmdemux.h:
Cleanups, use GstSegment for seeking.
Fix error handling.
Combine flow return from all streams.
2006-07-13 11:28:32 +00:00
|
|
|
GST_DEBUG_OBJECT (rmdemux, "Chain flow failed at offset 0x%08x",
|
|
|
|
rmdemux->offset);
|
2005-08-10 08:33:19 +00:00
|
|
|
goto need_pause;
|
2005-08-25 00:32:22 +00:00
|
|
|
}
|
2005-08-10 08:33:19 +00:00
|
|
|
|
2012-01-09 15:00:18 +00:00
|
|
|
rmdemux->offset += size;
|
2005-08-10 08:33:19 +00:00
|
|
|
|
|
|
|
switch (rmdemux->loop_state) {
|
|
|
|
case RMDEMUX_LOOP_STATE_HEADER:
|
|
|
|
if (rmdemux->offset >= rmdemux->data_offset) {
|
|
|
|
/* It's the end of the header */
|
|
|
|
rmdemux->loop_state = RMDEMUX_LOOP_STATE_INDEX;
|
|
|
|
rmdemux->offset = rmdemux->index_offset;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case RMDEMUX_LOOP_STATE_INDEX:
|
|
|
|
if (rmdemux->state == RMDEMUX_STATE_HEADER) {
|
|
|
|
if (rmdemux->index_offset == 0) {
|
|
|
|
/* We've read the last index */
|
|
|
|
rmdemux->loop_state = RMDEMUX_LOOP_STATE_DATA;
|
|
|
|
rmdemux->offset = rmdemux->data_offset;
|
2005-11-21 16:36:44 +00:00
|
|
|
GST_OBJECT_LOCK (rmdemux);
|
2005-08-10 08:33:19 +00:00
|
|
|
rmdemux->running = TRUE;
|
2005-11-21 16:36:44 +00:00
|
|
|
GST_OBJECT_UNLOCK (rmdemux);
|
2005-08-10 08:33:19 +00:00
|
|
|
} else {
|
|
|
|
/* Get the next index */
|
|
|
|
rmdemux->offset = rmdemux->index_offset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case RMDEMUX_LOOP_STATE_DATA:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
gst/realmedia/rmdemux.*: Cleanups, use GstSegment for seeking.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_finalize), (gst_rmdemux_src_event),
(find_seek_offset_time), (gst_rmdemux_perform_seek),
(gst_rmdemux_src_query), (gst_rmdemux_change_state),
(gst_rmdemux_loop), (gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream), (gst_rmdemux_parse_mdpr),
(gst_rmdemux_combine_flows), (gst_rmdemux_parse_packet):
* gst/realmedia/rmdemux.h:
Cleanups, use GstSegment for seeking.
Fix error handling.
Combine flow return from all streams.
2006-07-13 11:28:32 +00:00
|
|
|
/* ERRORS */
|
2005-08-10 08:33:19 +00:00
|
|
|
need_pause:
|
|
|
|
{
|
gst/realmedia/rmdemux.*: Cleanups, use GstSegment for seeking.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_finalize), (gst_rmdemux_src_event),
(find_seek_offset_time), (gst_rmdemux_perform_seek),
(gst_rmdemux_src_query), (gst_rmdemux_change_state),
(gst_rmdemux_loop), (gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream), (gst_rmdemux_parse_mdpr),
(gst_rmdemux_combine_flows), (gst_rmdemux_parse_packet):
* gst/realmedia/rmdemux.h:
Cleanups, use GstSegment for seeking.
Fix error handling.
Combine flow return from all streams.
2006-07-13 11:28:32 +00:00
|
|
|
const gchar *reason = gst_flow_get_name (ret);
|
|
|
|
|
|
|
|
GST_LOG_OBJECT (rmdemux, "pausing task, reason %s", reason);
|
|
|
|
rmdemux->segment_running = FALSE;
|
|
|
|
gst_pad_pause_task (rmdemux->sinkpad);
|
|
|
|
|
2012-01-03 14:27:42 +00:00
|
|
|
if (ret == GST_FLOW_EOS) {
|
2010-08-27 16:22:45 +00:00
|
|
|
/* perform EOS logic */
|
|
|
|
if (rmdemux->segment.flags & GST_SEEK_FLAG_SEGMENT) {
|
|
|
|
gint64 stop;
|
|
|
|
|
|
|
|
/* for segment playback we need to post when (in stream time)
|
|
|
|
* we stopped, this is either stop (when set) or the duration. */
|
|
|
|
if ((stop = rmdemux->segment.stop) == -1)
|
|
|
|
stop = rmdemux->segment.duration;
|
|
|
|
|
|
|
|
GST_LOG_OBJECT (rmdemux, "Sending segment done, at end of segment");
|
|
|
|
gst_element_post_message (GST_ELEMENT (rmdemux),
|
|
|
|
gst_message_new_segment_done (GST_OBJECT (rmdemux),
|
|
|
|
GST_FORMAT_TIME, stop));
|
2012-07-05 11:12:17 +00:00
|
|
|
gst_rmdemux_send_event (rmdemux,
|
|
|
|
gst_event_new_segment_done (GST_FORMAT_TIME, stop));
|
gst/realmedia/rmdemux.*: Cleanups, use GstSegment for seeking.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_finalize), (gst_rmdemux_src_event),
(find_seek_offset_time), (gst_rmdemux_perform_seek),
(gst_rmdemux_src_query), (gst_rmdemux_change_state),
(gst_rmdemux_loop), (gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream), (gst_rmdemux_parse_mdpr),
(gst_rmdemux_combine_flows), (gst_rmdemux_parse_packet):
* gst/realmedia/rmdemux.h:
Cleanups, use GstSegment for seeking.
Fix error handling.
Combine flow return from all streams.
2006-07-13 11:28:32 +00:00
|
|
|
} else {
|
2010-08-27 16:22:45 +00:00
|
|
|
/* normal playback, send EOS to all linked pads */
|
|
|
|
GST_LOG_OBJECT (rmdemux, "Sending EOS, at end of stream");
|
gst/realmedia/rmdemux.*: Cleanups, use GstSegment for seeking.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_finalize), (gst_rmdemux_src_event),
(find_seek_offset_time), (gst_rmdemux_perform_seek),
(gst_rmdemux_src_query), (gst_rmdemux_change_state),
(gst_rmdemux_loop), (gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream), (gst_rmdemux_parse_mdpr),
(gst_rmdemux_combine_flows), (gst_rmdemux_parse_packet):
* gst/realmedia/rmdemux.h:
Cleanups, use GstSegment for seeking.
Fix error handling.
Combine flow return from all streams.
2006-07-13 11:28:32 +00:00
|
|
|
gst_rmdemux_send_event (rmdemux, gst_event_new_eos ());
|
2005-11-28 18:54:09 +00:00
|
|
|
}
|
2012-01-03 14:27:42 +00:00
|
|
|
} else if (ret == GST_FLOW_NOT_LINKED || ret < GST_FLOW_EOS) {
|
2010-08-27 16:22:45 +00:00
|
|
|
GST_ELEMENT_ERROR (rmdemux, STREAM, FAILED,
|
|
|
|
(NULL), ("stream stopped, reason %s", reason));
|
|
|
|
gst_rmdemux_send_event (rmdemux, gst_event_new_eos ());
|
2005-09-29 13:44:15 +00:00
|
|
|
}
|
2005-08-10 08:33:19 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-30 16:39:47 +00:00
|
|
|
static gboolean
|
|
|
|
gst_rmdemux_fourcc_isplausible (guint32 fourcc)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
|
if (!isprint ((int) ((unsigned char *) (&fourcc))[i])) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-06-27 09:16:09 +00:00
|
|
|
static GstFlowReturn
|
2011-11-17 14:25:58 +00:00
|
|
|
gst_rmdemux_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
2003-06-22 03:59:01 +00:00
|
|
|
{
|
2005-06-27 09:16:09 +00:00
|
|
|
GstFlowReturn ret = GST_FLOW_OK;
|
|
|
|
const guint8 *data;
|
|
|
|
guint16 version;
|
2007-08-07 10:57:09 +00:00
|
|
|
guint avail;
|
2004-03-14 22:34:30 +00:00
|
|
|
|
2011-11-17 14:25:58 +00:00
|
|
|
GstRMDemux *rmdemux = GST_RMDEMUX (parent);
|
2004-03-14 22:34:30 +00:00
|
|
|
|
2008-08-27 09:47:17 +00:00
|
|
|
if (rmdemux->base_ts == -1) {
|
2012-09-13 11:49:33 +00:00
|
|
|
if (GST_BUFFER_DTS_IS_VALID (buffer))
|
|
|
|
rmdemux->base_ts = GST_BUFFER_DTS (buffer);
|
|
|
|
else
|
|
|
|
rmdemux->base_ts = GST_BUFFER_PTS (buffer);
|
|
|
|
|
2008-08-27 09:47:17 +00:00
|
|
|
GST_LOG_OBJECT (rmdemux, "base_ts %" GST_TIME_FORMAT,
|
|
|
|
GST_TIME_ARGS (rmdemux->base_ts));
|
|
|
|
}
|
|
|
|
|
2007-08-07 10:57:09 +00:00
|
|
|
gst_adapter_push (rmdemux->adapter, buffer);
|
|
|
|
|
2011-11-21 21:02:07 +00:00
|
|
|
GST_LOG_OBJECT (rmdemux, "Chaining buffer of size %" G_GSIZE_FORMAT,
|
2011-10-05 11:18:45 +00:00
|
|
|
gst_buffer_get_size (buffer));
|
2005-08-10 08:33:19 +00:00
|
|
|
|
2005-06-27 09:16:09 +00:00
|
|
|
while (TRUE) {
|
2007-08-07 10:57:09 +00:00
|
|
|
avail = gst_adapter_available (rmdemux->adapter);
|
|
|
|
|
|
|
|
GST_LOG_OBJECT (rmdemux, "looping in chain, avail %u", avail);
|
2005-06-27 09:16:09 +00:00
|
|
|
switch (rmdemux->state) {
|
|
|
|
case RMDEMUX_STATE_HEADER:
|
|
|
|
{
|
2005-08-10 08:33:19 +00:00
|
|
|
if (gst_adapter_available (rmdemux->adapter) < HEADER_SIZE)
|
2005-06-27 09:16:09 +00:00
|
|
|
goto unlock;
|
2003-06-24 08:05:12 +00:00
|
|
|
|
2011-10-05 11:18:45 +00:00
|
|
|
data = gst_adapter_map (rmdemux->adapter, HEADER_SIZE);
|
2003-06-22 03:59:01 +00:00
|
|
|
|
2005-06-27 09:16:09 +00:00
|
|
|
rmdemux->object_id = RMDEMUX_FOURCC_GET (data + 0);
|
2005-08-10 08:33:19 +00:00
|
|
|
rmdemux->size = RMDEMUX_GUINT32_GET (data + 4) - HEADER_SIZE;
|
2005-06-27 09:16:09 +00:00
|
|
|
rmdemux->object_version = RMDEMUX_GUINT16_GET (data + 8);
|
2004-03-14 22:34:30 +00:00
|
|
|
|
2005-10-05 11:25:51 +00:00
|
|
|
/* Sanity-check. We assume that the FOURCC is printable ASCII */
|
2005-09-30 16:39:47 +00:00
|
|
|
if (!gst_rmdemux_fourcc_isplausible (rmdemux->object_id)) {
|
2005-10-05 11:25:51 +00:00
|
|
|
/* Failed. Remain in HEADER state, try again... We flush only
|
|
|
|
* the actual FOURCC, not the entire header, because we could
|
|
|
|
* need to resync anywhere at all... really, this should never
|
|
|
|
* happen. */
|
|
|
|
GST_WARNING_OBJECT (rmdemux, "Bogus looking header, unprintable "
|
|
|
|
"FOURCC");
|
2011-11-10 17:25:38 +00:00
|
|
|
gst_adapter_unmap (rmdemux->adapter);
|
|
|
|
gst_adapter_flush (rmdemux->adapter, 4);
|
2005-09-30 16:39:47 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-11-21 14:08:45 +00:00
|
|
|
GST_LOG_OBJECT (rmdemux, "header found with object_id=%"
|
2005-06-27 09:16:09 +00:00
|
|
|
GST_FOURCC_FORMAT
|
|
|
|
" size=%08x object_version=%d",
|
|
|
|
GST_FOURCC_ARGS (rmdemux->object_id), rmdemux->size,
|
|
|
|
rmdemux->object_version);
|
2004-03-14 22:34:30 +00:00
|
|
|
|
2011-11-10 17:25:38 +00:00
|
|
|
gst_adapter_unmap (rmdemux->adapter);
|
|
|
|
gst_adapter_flush (rmdemux->adapter, HEADER_SIZE);
|
2004-03-14 22:34:30 +00:00
|
|
|
|
2005-06-27 09:16:09 +00:00
|
|
|
switch (rmdemux->object_id) {
|
|
|
|
case GST_MAKE_FOURCC ('.', 'R', 'M', 'F'):
|
|
|
|
rmdemux->state = RMDEMUX_STATE_HEADER_RMF;
|
|
|
|
break;
|
|
|
|
case GST_MAKE_FOURCC ('P', 'R', 'O', 'P'):
|
|
|
|
rmdemux->state = RMDEMUX_STATE_HEADER_PROP;
|
|
|
|
break;
|
|
|
|
case GST_MAKE_FOURCC ('M', 'D', 'P', 'R'):
|
|
|
|
rmdemux->state = RMDEMUX_STATE_HEADER_MDPR;
|
|
|
|
break;
|
|
|
|
case GST_MAKE_FOURCC ('I', 'N', 'D', 'X'):
|
|
|
|
rmdemux->state = RMDEMUX_STATE_HEADER_INDX;
|
|
|
|
break;
|
|
|
|
case GST_MAKE_FOURCC ('D', 'A', 'T', 'A'):
|
|
|
|
rmdemux->state = RMDEMUX_STATE_HEADER_DATA;
|
|
|
|
break;
|
|
|
|
case GST_MAKE_FOURCC ('C', 'O', 'N', 'T'):
|
|
|
|
rmdemux->state = RMDEMUX_STATE_HEADER_CONT;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
rmdemux->state = RMDEMUX_STATE_HEADER_UNKNOWN;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2003-06-22 03:59:01 +00:00
|
|
|
}
|
2005-06-27 09:16:09 +00:00
|
|
|
case RMDEMUX_STATE_HEADER_UNKNOWN:
|
|
|
|
{
|
|
|
|
if (gst_adapter_available (rmdemux->adapter) < rmdemux->size)
|
|
|
|
goto unlock;
|
2003-06-22 03:59:01 +00:00
|
|
|
|
2005-11-21 14:08:45 +00:00
|
|
|
GST_WARNING_OBJECT (rmdemux, "Unknown object_id %" GST_FOURCC_FORMAT,
|
2005-06-27 09:16:09 +00:00
|
|
|
GST_FOURCC_ARGS (rmdemux->object_id));
|
2003-06-24 08:05:12 +00:00
|
|
|
|
2005-06-27 09:16:09 +00:00
|
|
|
gst_adapter_flush (rmdemux->adapter, rmdemux->size);
|
|
|
|
rmdemux->state = RMDEMUX_STATE_HEADER;
|
|
|
|
break;
|
2004-10-04 16:10:41 +00:00
|
|
|
}
|
2005-06-27 09:16:09 +00:00
|
|
|
case RMDEMUX_STATE_HEADER_RMF:
|
|
|
|
{
|
|
|
|
if (gst_adapter_available (rmdemux->adapter) < rmdemux->size)
|
|
|
|
goto unlock;
|
2004-03-14 22:34:30 +00:00
|
|
|
|
2005-06-27 09:16:09 +00:00
|
|
|
if ((rmdemux->object_version == 0) || (rmdemux->object_version == 1)) {
|
2011-10-05 11:18:45 +00:00
|
|
|
data = gst_adapter_map (rmdemux->adapter, rmdemux->size);
|
2005-06-27 09:16:09 +00:00
|
|
|
gst_rmdemux_parse__rmf (rmdemux, data, rmdemux->size);
|
2011-11-10 17:25:38 +00:00
|
|
|
gst_adapter_unmap (rmdemux->adapter);
|
|
|
|
gst_adapter_flush (rmdemux->adapter, rmdemux->size);
|
2011-10-05 11:18:45 +00:00
|
|
|
} else {
|
|
|
|
gst_adapter_flush (rmdemux->adapter, rmdemux->size);
|
2004-03-15 19:32:25 +00:00
|
|
|
}
|
2005-06-27 09:16:09 +00:00
|
|
|
rmdemux->state = RMDEMUX_STATE_HEADER;
|
|
|
|
break;
|
2003-06-22 03:59:01 +00:00
|
|
|
}
|
2005-06-27 09:16:09 +00:00
|
|
|
case RMDEMUX_STATE_HEADER_PROP:
|
|
|
|
{
|
|
|
|
if (gst_adapter_available (rmdemux->adapter) < rmdemux->size)
|
|
|
|
goto unlock;
|
2003-06-22 03:59:01 +00:00
|
|
|
|
2011-10-05 11:18:45 +00:00
|
|
|
data = gst_adapter_map (rmdemux->adapter, rmdemux->size);
|
2005-06-27 09:16:09 +00:00
|
|
|
gst_rmdemux_parse_prop (rmdemux, data, rmdemux->size);
|
2011-11-10 17:25:38 +00:00
|
|
|
gst_adapter_unmap (rmdemux->adapter);
|
|
|
|
gst_adapter_flush (rmdemux->adapter, rmdemux->size);
|
2004-03-14 22:34:30 +00:00
|
|
|
|
2005-06-27 09:16:09 +00:00
|
|
|
rmdemux->state = RMDEMUX_STATE_HEADER;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case RMDEMUX_STATE_HEADER_MDPR:
|
|
|
|
{
|
|
|
|
if (gst_adapter_available (rmdemux->adapter) < rmdemux->size)
|
|
|
|
goto unlock;
|
2003-06-22 03:59:01 +00:00
|
|
|
|
2011-10-05 11:18:45 +00:00
|
|
|
data = gst_adapter_map (rmdemux->adapter, rmdemux->size);
|
gst/realmedia/rmdemux.*: Cleanups, use GstSegment for seeking.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_finalize), (gst_rmdemux_src_event),
(find_seek_offset_time), (gst_rmdemux_perform_seek),
(gst_rmdemux_src_query), (gst_rmdemux_change_state),
(gst_rmdemux_loop), (gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream), (gst_rmdemux_parse_mdpr),
(gst_rmdemux_combine_flows), (gst_rmdemux_parse_packet):
* gst/realmedia/rmdemux.h:
Cleanups, use GstSegment for seeking.
Fix error handling.
Combine flow return from all streams.
2006-07-13 11:28:32 +00:00
|
|
|
gst_rmdemux_parse_mdpr (rmdemux, data, rmdemux->size);
|
2011-11-10 17:25:38 +00:00
|
|
|
gst_adapter_unmap (rmdemux->adapter);
|
|
|
|
gst_adapter_flush (rmdemux->adapter, rmdemux->size);
|
2003-06-24 08:05:12 +00:00
|
|
|
|
2005-06-27 09:16:09 +00:00
|
|
|
rmdemux->state = RMDEMUX_STATE_HEADER;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case RMDEMUX_STATE_HEADER_CONT:
|
|
|
|
{
|
|
|
|
if (gst_adapter_available (rmdemux->adapter) < rmdemux->size)
|
|
|
|
goto unlock;
|
2003-06-24 08:05:12 +00:00
|
|
|
|
2011-10-05 11:18:45 +00:00
|
|
|
data = gst_adapter_map (rmdemux->adapter, rmdemux->size);
|
2005-06-27 09:16:09 +00:00
|
|
|
gst_rmdemux_parse_cont (rmdemux, data, rmdemux->size);
|
2011-11-10 17:25:38 +00:00
|
|
|
gst_adapter_unmap (rmdemux->adapter);
|
|
|
|
gst_adapter_flush (rmdemux->adapter, rmdemux->size);
|
2003-06-22 03:59:01 +00:00
|
|
|
|
2005-06-27 09:16:09 +00:00
|
|
|
rmdemux->state = RMDEMUX_STATE_HEADER;
|
|
|
|
break;
|
2004-03-14 22:34:30 +00:00
|
|
|
}
|
2005-06-27 09:16:09 +00:00
|
|
|
case RMDEMUX_STATE_HEADER_DATA:
|
|
|
|
{
|
2005-07-03 17:40:04 +00:00
|
|
|
/* If we haven't already done so then signal there are no more pads */
|
|
|
|
if (!rmdemux->have_pads) {
|
2007-05-16 19:07:45 +00:00
|
|
|
GST_LOG_OBJECT (rmdemux, "no more pads");
|
2005-07-03 17:40:04 +00:00
|
|
|
gst_element_no_more_pads (GST_ELEMENT (rmdemux));
|
|
|
|
rmdemux->have_pads = TRUE;
|
|
|
|
}
|
|
|
|
|
2005-06-27 09:16:09 +00:00
|
|
|
/* The actual header is only 8 bytes */
|
2005-08-10 08:33:19 +00:00
|
|
|
rmdemux->size = DATA_SIZE;
|
2011-11-21 21:02:07 +00:00
|
|
|
GST_LOG_OBJECT (rmdemux, "data available %" G_GSIZE_FORMAT,
|
2005-08-10 08:33:19 +00:00
|
|
|
gst_adapter_available (rmdemux->adapter));
|
2005-06-27 09:16:09 +00:00
|
|
|
if (gst_adapter_available (rmdemux->adapter) < rmdemux->size)
|
|
|
|
goto unlock;
|
2004-03-14 22:34:30 +00:00
|
|
|
|
2011-10-05 11:18:45 +00:00
|
|
|
data = gst_adapter_map (rmdemux->adapter, rmdemux->size);
|
2005-06-27 09:16:09 +00:00
|
|
|
gst_rmdemux_parse_data (rmdemux, data, rmdemux->size);
|
2011-11-10 17:25:38 +00:00
|
|
|
gst_adapter_unmap (rmdemux->adapter);
|
|
|
|
gst_adapter_flush (rmdemux->adapter, rmdemux->size);
|
2005-07-03 17:40:04 +00:00
|
|
|
|
2005-06-27 09:16:09 +00:00
|
|
|
rmdemux->state = RMDEMUX_STATE_DATA_PACKET;
|
|
|
|
break;
|
2004-03-14 22:34:30 +00:00
|
|
|
}
|
2005-06-27 09:16:09 +00:00
|
|
|
case RMDEMUX_STATE_HEADER_INDX:
|
|
|
|
{
|
|
|
|
if (gst_adapter_available (rmdemux->adapter) < rmdemux->size)
|
|
|
|
goto unlock;
|
2004-03-14 22:34:30 +00:00
|
|
|
|
2011-10-05 11:18:45 +00:00
|
|
|
data = gst_adapter_map (rmdemux->adapter, rmdemux->size);
|
2005-08-25 00:32:22 +00:00
|
|
|
rmdemux->size = gst_rmdemux_parse_indx (rmdemux, data, rmdemux->size);
|
|
|
|
/* Only flush the header */
|
2011-11-10 17:25:38 +00:00
|
|
|
gst_adapter_unmap (rmdemux->adapter);
|
|
|
|
gst_adapter_flush (rmdemux->adapter, HEADER_SIZE);
|
2005-08-25 00:32:22 +00:00
|
|
|
|
|
|
|
rmdemux->state = RMDEMUX_STATE_INDX_DATA;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case RMDEMUX_STATE_INDX_DATA:
|
|
|
|
{
|
|
|
|
/* There's not always an data to get... */
|
|
|
|
if (rmdemux->size > 0) {
|
|
|
|
if (gst_adapter_available (rmdemux->adapter) < rmdemux->size)
|
|
|
|
goto unlock;
|
|
|
|
|
2011-10-05 11:18:45 +00:00
|
|
|
data = gst_adapter_map (rmdemux->adapter, rmdemux->size);
|
2005-08-25 00:32:22 +00:00
|
|
|
gst_rmdemux_parse_indx_data (rmdemux, data, rmdemux->size);
|
2011-11-10 17:25:38 +00:00
|
|
|
gst_adapter_unmap (rmdemux->adapter);
|
|
|
|
gst_adapter_flush (rmdemux->adapter, rmdemux->size);
|
2005-08-25 00:32:22 +00:00
|
|
|
}
|
2005-06-27 09:16:09 +00:00
|
|
|
|
|
|
|
rmdemux->state = RMDEMUX_STATE_HEADER;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case RMDEMUX_STATE_DATA_PACKET:
|
|
|
|
{
|
2011-10-05 11:18:45 +00:00
|
|
|
guint8 header[4];
|
|
|
|
|
2005-06-27 09:16:09 +00:00
|
|
|
if (gst_adapter_available (rmdemux->adapter) < 2)
|
|
|
|
goto unlock;
|
|
|
|
|
2011-10-05 11:18:45 +00:00
|
|
|
gst_adapter_copy (rmdemux->adapter, header, 0, 2);
|
|
|
|
version = RMDEMUX_GUINT16_GET (header);
|
gst/realmedia/rmdemux.c: Descramble cook audio streams before sending them to the decoder. Fixes #347292.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_init), (gst_rmdemux_chain), (gst_rmdemux_add_stream),
(gst_rmdemux_parse_mdpr), (gst_rmdemux_parse_data),
(gst_rmdemux_stream_clear_cached_subpackets),
(gst_rmdemux_descramble_cook_audio),
(gst_rmdemux_descramble_dnet_audio),
(gst_rmdemux_handle_scrambled_packet), (gst_rmdemux_parse_packet):
Descramble cook audio streams before sending them to the
decoder. Fixes #347292.
Also miscellaneous clean-ups and log-level changes.
2006-07-27 20:34:25 +00:00
|
|
|
GST_LOG_OBJECT (rmdemux, "Data packet with version=%d", version);
|
2005-06-27 09:16:09 +00:00
|
|
|
|
|
|
|
if (version == 0 || version == 1) {
|
|
|
|
guint16 length;
|
|
|
|
|
|
|
|
if (gst_adapter_available (rmdemux->adapter) < 4)
|
|
|
|
goto unlock;
|
|
|
|
|
2011-10-05 11:18:45 +00:00
|
|
|
gst_adapter_copy (rmdemux->adapter, header, 0, 4);
|
|
|
|
|
|
|
|
length = RMDEMUX_GUINT16_GET (header + 2);
|
2007-08-07 10:57:09 +00:00
|
|
|
GST_LOG_OBJECT (rmdemux, "Got length %d", length);
|
|
|
|
|
2005-10-05 11:25:51 +00:00
|
|
|
if (length < 4) {
|
2007-08-07 10:57:09 +00:00
|
|
|
GST_LOG_OBJECT (rmdemux, "length too small, dropping");
|
2005-10-05 11:25:51 +00:00
|
|
|
/* Invalid, just drop it */
|
|
|
|
gst_adapter_flush (rmdemux->adapter, 4);
|
2005-06-27 09:16:09 +00:00
|
|
|
} else {
|
2007-08-07 10:57:09 +00:00
|
|
|
GstBuffer *buffer;
|
|
|
|
|
|
|
|
avail = gst_adapter_available (rmdemux->adapter);
|
|
|
|
if (avail < length)
|
2005-06-27 09:16:09 +00:00
|
|
|
goto unlock;
|
|
|
|
|
2007-08-07 10:57:09 +00:00
|
|
|
GST_LOG_OBJECT (rmdemux, "we have %u available and we needed %d",
|
|
|
|
avail, length);
|
|
|
|
|
|
|
|
/* flush version and length */
|
|
|
|
gst_adapter_flush (rmdemux->adapter, 4);
|
|
|
|
length -= 4;
|
2005-06-27 09:16:09 +00:00
|
|
|
|
2007-08-07 10:57:09 +00:00
|
|
|
buffer = gst_adapter_take_buffer (rmdemux->adapter, length);
|
|
|
|
|
|
|
|
ret = gst_rmdemux_parse_packet (rmdemux, buffer, version);
|
|
|
|
rmdemux->chunk_index++;
|
2005-06-27 09:16:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (rmdemux->chunk_index == rmdemux->n_chunks || length == 0)
|
|
|
|
rmdemux->state = RMDEMUX_STATE_HEADER;
|
|
|
|
} else {
|
|
|
|
/* Stream done */
|
|
|
|
gst_adapter_flush (rmdemux->adapter, 2);
|
2005-08-10 08:33:19 +00:00
|
|
|
|
2005-10-05 11:25:51 +00:00
|
|
|
if (rmdemux->data_offset == 0) {
|
|
|
|
GST_LOG_OBJECT (rmdemux,
|
|
|
|
"No further data, internal demux state EOS");
|
2005-08-10 08:33:19 +00:00
|
|
|
rmdemux->state = RMDEMUX_STATE_EOS;
|
2005-10-05 11:25:51 +00:00
|
|
|
} else
|
2005-08-10 08:33:19 +00:00
|
|
|
rmdemux->state = RMDEMUX_STATE_HEADER;
|
2005-06-27 09:16:09 +00:00
|
|
|
}
|
2005-08-10 08:33:19 +00:00
|
|
|
break;
|
2005-06-27 09:16:09 +00:00
|
|
|
}
|
2005-08-10 08:33:19 +00:00
|
|
|
case RMDEMUX_STATE_EOS:
|
2005-08-25 00:32:22 +00:00
|
|
|
gst_rmdemux_send_event (rmdemux, gst_event_new_eos ());
|
2005-08-10 08:33:19 +00:00
|
|
|
goto unlock;
|
|
|
|
default:
|
|
|
|
GST_WARNING_OBJECT (rmdemux, "Unhandled state %d", rmdemux->state);
|
|
|
|
goto unlock;
|
2004-03-14 22:34:30 +00:00
|
|
|
}
|
2003-06-22 03:59:01 +00:00
|
|
|
}
|
|
|
|
|
2005-06-27 09:16:09 +00:00
|
|
|
unlock:
|
|
|
|
return ret;
|
2003-06-22 03:59:01 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
static GstRMDemuxStream *
|
|
|
|
gst_rmdemux_get_stream_by_id (GstRMDemux * rmdemux, int id)
|
2003-06-22 03:59:01 +00:00
|
|
|
{
|
2007-04-12 10:10:22 +00:00
|
|
|
GSList *cur;
|
2003-06-22 03:59:01 +00:00
|
|
|
|
2007-04-12 10:10:22 +00:00
|
|
|
for (cur = rmdemux->streams; cur; cur = cur->next) {
|
|
|
|
GstRMDemuxStream *stream = cur->data;
|
2005-07-18 10:33:19 +00:00
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
if (stream->id == id) {
|
2003-06-22 03:59:01 +00:00
|
|
|
return stream;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2006-03-24 11:42:31 +00:00
|
|
|
static void
|
2005-07-18 10:33:19 +00:00
|
|
|
gst_rmdemux_send_event (GstRMDemux * rmdemux, GstEvent * event)
|
|
|
|
{
|
2007-04-12 10:10:22 +00:00
|
|
|
GSList *cur;
|
2005-07-18 10:33:19 +00:00
|
|
|
|
2007-04-12 10:10:22 +00:00
|
|
|
for (cur = rmdemux->streams; cur; cur = cur->next) {
|
|
|
|
GstRMDemuxStream *stream = cur->data;
|
2005-08-10 08:33:19 +00:00
|
|
|
|
2006-03-24 11:42:31 +00:00
|
|
|
GST_DEBUG_OBJECT (rmdemux, "Pushing %s event on pad %s",
|
|
|
|
GST_EVENT_TYPE_NAME (event), GST_PAD_NAME (stream->pad));
|
2005-08-22 07:33:00 +00:00
|
|
|
|
2008-05-19 10:23:46 +00:00
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
|
|
|
case GST_EVENT_FLUSH_STOP:
|
|
|
|
stream->last_ts = -1;
|
|
|
|
stream->next_ts = -1;
|
|
|
|
stream->last_seq = -1;
|
|
|
|
stream->next_seq = -1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2005-07-18 10:33:19 +00:00
|
|
|
gst_event_ref (event);
|
2006-03-24 11:42:31 +00:00
|
|
|
gst_pad_push_event (stream->pad, event);
|
2005-07-18 10:33:19 +00:00
|
|
|
}
|
|
|
|
gst_event_unref (event);
|
2006-03-24 11:42:31 +00:00
|
|
|
}
|
2005-07-18 10:33:19 +00:00
|
|
|
|
gst/realmedia/rmdemux.*: Cleanups, use GstSegment for seeking.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_finalize), (gst_rmdemux_src_event),
(find_seek_offset_time), (gst_rmdemux_perform_seek),
(gst_rmdemux_src_query), (gst_rmdemux_change_state),
(gst_rmdemux_loop), (gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream), (gst_rmdemux_parse_mdpr),
(gst_rmdemux_combine_flows), (gst_rmdemux_parse_packet):
* gst/realmedia/rmdemux.h:
Cleanups, use GstSegment for seeking.
Fix error handling.
Combine flow return from all streams.
2006-07-13 11:28:32 +00:00
|
|
|
static void
|
2004-03-14 22:34:30 +00:00
|
|
|
gst_rmdemux_add_stream (GstRMDemux * rmdemux, GstRMDemuxStream * stream)
|
2003-06-22 03:59:01 +00:00
|
|
|
{
|
2006-07-28 13:28:19 +00:00
|
|
|
GstCaps *stream_caps = NULL;
|
2006-03-24 19:47:37 +00:00
|
|
|
const gchar *codec_tag = NULL;
|
2010-10-24 12:22:39 +00:00
|
|
|
gchar *codec_name = NULL;
|
2012-08-05 16:30:52 +00:00
|
|
|
gchar *stream_id;
|
2004-10-03 15:54:31 +00:00
|
|
|
int version = 0;
|
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
if (stream->subtype == GST_RMDEMUX_STREAM_VIDEO) {
|
2011-11-04 15:40:59 +00:00
|
|
|
char *name = g_strdup_printf ("video_%u", rmdemux->n_video_streams);
|
2005-09-30 16:39:47 +00:00
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
stream->pad =
|
2006-03-24 11:42:31 +00:00
|
|
|
gst_pad_new_from_static_template (&gst_rmdemux_videosrc_template, name);
|
2005-09-30 16:39:47 +00:00
|
|
|
g_free (name);
|
|
|
|
|
2006-03-24 19:47:37 +00:00
|
|
|
codec_tag = GST_TAG_VIDEO_CODEC;
|
|
|
|
|
2004-10-03 11:50:11 +00:00
|
|
|
switch (stream->fourcc) {
|
2004-10-03 15:54:31 +00:00
|
|
|
case GST_RM_VDO_RV10:
|
|
|
|
version = 1;
|
|
|
|
break;
|
|
|
|
case GST_RM_VDO_RV20:
|
|
|
|
version = 2;
|
|
|
|
break;
|
|
|
|
case GST_RM_VDO_RV30:
|
|
|
|
version = 3;
|
|
|
|
break;
|
|
|
|
case GST_RM_VDO_RV40:
|
|
|
|
version = 4;
|
2004-10-03 11:50:11 +00:00
|
|
|
break;
|
|
|
|
default:
|
2006-08-07 19:01:40 +00:00
|
|
|
stream_caps = gst_caps_new_simple ("video/x-unknown-fourcc",
|
2011-10-05 11:18:45 +00:00
|
|
|
"fourcc", G_TYPE_UINT, stream->fourcc, NULL);
|
2006-08-07 19:01:40 +00:00
|
|
|
GST_WARNING_OBJECT (rmdemux,
|
|
|
|
"Unknown video FOURCC code \"%" GST_FOURCC_FORMAT "\" (%08x)",
|
|
|
|
GST_FOURCC_ARGS (stream->fourcc), stream->fourcc);
|
2004-10-03 11:50:11 +00:00
|
|
|
}
|
2005-06-27 09:16:09 +00:00
|
|
|
|
2004-10-03 15:54:31 +00:00
|
|
|
if (version) {
|
2006-07-28 13:28:19 +00:00
|
|
|
stream_caps =
|
2004-10-03 15:54:31 +00:00
|
|
|
gst_caps_new_simple ("video/x-pn-realvideo", "rmversion", G_TYPE_INT,
|
2005-06-27 09:16:09 +00:00
|
|
|
(int) version,
|
|
|
|
"format", G_TYPE_INT,
|
|
|
|
(int) stream->format,
|
|
|
|
"subformat", G_TYPE_INT, (int) stream->subformat, NULL);
|
2004-10-03 15:54:31 +00:00
|
|
|
}
|
|
|
|
|
2006-07-28 13:28:19 +00:00
|
|
|
if (stream_caps) {
|
|
|
|
gst_caps_set_simple (stream_caps,
|
2004-03-15 19:32:25 +00:00
|
|
|
"width", G_TYPE_INT, stream->width,
|
2005-06-27 09:16:09 +00:00
|
|
|
"height", G_TYPE_INT, stream->height,
|
gst/realmedia/rmdemux.c: Fractional framerates.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_sink_event),
(gst_rmdemux_src_event), (gst_rmdemux_validate_offset),
(find_seek_offset_bytes), (find_seek_offset_time),
(gst_rmdemux_perform_seek), (gst_rmdemux_src_query),
(gst_rmdemux_loop), (gst_rmdemux_fourcc_isplausible),
(gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream), (gst_rmdemux_parse_mdpr),
(gst_rmdemux_parse_packet):
Fractional framerates.
2005-11-23 00:26:42 +00:00
|
|
|
"framerate", GST_TYPE_FRACTION, stream->framerate_numerator,
|
|
|
|
stream->framerate_denominator, NULL);
|
2003-06-22 03:59:01 +00:00
|
|
|
}
|
|
|
|
rmdemux->n_video_streams++;
|
2005-06-27 09:16:09 +00:00
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
} else if (stream->subtype == GST_RMDEMUX_STREAM_AUDIO) {
|
2011-11-04 15:40:59 +00:00
|
|
|
char *name = g_strdup_printf ("audio_%u", rmdemux->n_audio_streams);
|
2005-09-30 16:39:47 +00:00
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
stream->pad =
|
2006-03-24 11:42:31 +00:00
|
|
|
gst_pad_new_from_static_template (&gst_rmdemux_audiosrc_template, name);
|
2005-10-05 11:25:51 +00:00
|
|
|
GST_LOG_OBJECT (rmdemux, "Created audio pad \"%s\"", name);
|
2005-09-30 16:39:47 +00:00
|
|
|
g_free (name);
|
2006-03-24 19:47:37 +00:00
|
|
|
|
|
|
|
codec_tag = GST_TAG_AUDIO_CODEC;
|
|
|
|
|
2004-10-03 11:50:11 +00:00
|
|
|
switch (stream->fourcc) {
|
2004-10-03 15:54:31 +00:00
|
|
|
/* Older RealAudio Codecs */
|
|
|
|
case GST_RM_AUD_14_4:
|
|
|
|
version = 1;
|
2004-10-04 16:10:41 +00:00
|
|
|
break;
|
|
|
|
|
2004-10-03 15:54:31 +00:00
|
|
|
case GST_RM_AUD_28_8:
|
|
|
|
version = 2;
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* DolbyNet (Dolby AC3, low bitrate) */
|
|
|
|
case GST_RM_AUD_DNET:
|
2006-07-28 13:28:19 +00:00
|
|
|
stream_caps =
|
2004-10-04 18:27:54 +00:00
|
|
|
gst_caps_new_simple ("audio/x-ac3", "rate", G_TYPE_INT,
|
|
|
|
(int) stream->rate, NULL);
|
gst/realmedia/rmdemux.c: Descramble cook audio streams before sending them to the decoder. Fixes #347292.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_init), (gst_rmdemux_chain), (gst_rmdemux_add_stream),
(gst_rmdemux_parse_mdpr), (gst_rmdemux_parse_data),
(gst_rmdemux_stream_clear_cached_subpackets),
(gst_rmdemux_descramble_cook_audio),
(gst_rmdemux_descramble_dnet_audio),
(gst_rmdemux_handle_scrambled_packet), (gst_rmdemux_parse_packet):
Descramble cook audio streams before sending them to the
decoder. Fixes #347292.
Also miscellaneous clean-ups and log-level changes.
2006-07-27 20:34:25 +00:00
|
|
|
stream->needs_descrambling = TRUE;
|
|
|
|
stream->subpackets_needed = 1;
|
|
|
|
stream->subpackets = NULL;
|
2004-10-03 15:54:31 +00:00
|
|
|
break;
|
|
|
|
|
2005-06-27 09:16:09 +00:00
|
|
|
/* MPEG-4 based */
|
2008-10-24 12:47:05 +00:00
|
|
|
case GST_RM_AUD_RAAC:
|
2004-10-03 15:54:31 +00:00
|
|
|
case GST_RM_AUD_RACP:
|
2006-07-28 13:28:19 +00:00
|
|
|
stream_caps =
|
2004-10-03 15:54:31 +00:00
|
|
|
gst_caps_new_simple ("audio/mpeg", "mpegversion", G_TYPE_INT,
|
2008-10-24 12:47:05 +00:00
|
|
|
(int) 4, "framed", G_TYPE_BOOLEAN, TRUE, NULL);
|
|
|
|
if (stream->extra_data_size > 0) {
|
|
|
|
/* strip off an unknown byte in the extra data */
|
|
|
|
stream->extra_data_size--;
|
|
|
|
stream->extra_data++;
|
|
|
|
}
|
|
|
|
stream->needs_descrambling = TRUE;
|
|
|
|
stream->subpackets_needed = 1;
|
|
|
|
stream->subpackets = NULL;
|
2004-10-03 15:54:31 +00:00
|
|
|
break;
|
|
|
|
|
2004-10-06 14:18:13 +00:00
|
|
|
/* Sony ATRAC3 */
|
|
|
|
case GST_RM_AUD_ATRC:
|
2011-11-04 16:32:58 +00:00
|
|
|
stream_caps = gst_caps_new_empty_simple ("audio/x-vnd.sony.atrac3");
|
2010-05-13 15:57:57 +00:00
|
|
|
stream->needs_descrambling = TRUE;
|
|
|
|
stream->subpackets_needed = stream->height;
|
|
|
|
stream->subpackets = NULL;
|
2004-10-06 14:18:13 +00:00
|
|
|
break;
|
|
|
|
|
2005-06-27 09:16:09 +00:00
|
|
|
/* RealAudio G2 audio */
|
2004-10-03 15:54:31 +00:00
|
|
|
case GST_RM_AUD_COOK:
|
2005-06-27 09:16:09 +00:00
|
|
|
version = 8;
|
gst/realmedia/rmdemux.c: Descramble cook audio streams before sending them to the decoder. Fixes #347292.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_init), (gst_rmdemux_chain), (gst_rmdemux_add_stream),
(gst_rmdemux_parse_mdpr), (gst_rmdemux_parse_data),
(gst_rmdemux_stream_clear_cached_subpackets),
(gst_rmdemux_descramble_cook_audio),
(gst_rmdemux_descramble_dnet_audio),
(gst_rmdemux_handle_scrambled_packet), (gst_rmdemux_parse_packet):
Descramble cook audio streams before sending them to the
decoder. Fixes #347292.
Also miscellaneous clean-ups and log-level changes.
2006-07-27 20:34:25 +00:00
|
|
|
stream->needs_descrambling = TRUE;
|
|
|
|
stream->subpackets_needed = stream->height;
|
|
|
|
stream->subpackets = NULL;
|
2005-06-27 09:16:09 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* RALF is lossless */
|
2004-10-03 15:54:31 +00:00
|
|
|
case GST_RM_AUD_RALF:
|
2005-09-29 13:44:15 +00:00
|
|
|
GST_DEBUG_OBJECT (rmdemux, "RALF");
|
2011-11-04 16:32:58 +00:00
|
|
|
stream_caps = gst_caps_new_empty_simple ("audio/x-ralf-mpeg4-generic");
|
2005-06-27 09:16:09 +00:00
|
|
|
break;
|
2004-10-03 15:54:31 +00:00
|
|
|
|
|
|
|
case GST_RM_AUD_SIPR:
|
2010-05-13 15:57:57 +00:00
|
|
|
|
|
|
|
if (stream->flavor > 3) {
|
|
|
|
GST_WARNING_OBJECT (rmdemux, "bad SIPR flavor %d, freeing it",
|
|
|
|
stream->flavor);
|
2015-07-16 09:11:37 +00:00
|
|
|
g_object_unref (stream->pad);
|
|
|
|
gst_rmdemux_free_stream (rmdemux, stream);
|
2010-05-13 15:57:57 +00:00
|
|
|
goto beach;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (rmdemux, "SIPR");
|
2011-11-04 16:32:58 +00:00
|
|
|
stream_caps = gst_caps_new_empty_simple ("audio/x-sipro");
|
2010-05-13 15:57:57 +00:00
|
|
|
stream->needs_descrambling = TRUE;
|
|
|
|
stream->subpackets_needed = stream->height;
|
|
|
|
stream->subpackets = NULL;
|
|
|
|
stream->leaf_size = sipr_subpk_size[stream->flavor];
|
|
|
|
|
2004-10-03 11:50:11 +00:00
|
|
|
break;
|
2004-10-03 15:54:31 +00:00
|
|
|
|
2004-10-03 11:50:11 +00:00
|
|
|
default:
|
2006-08-07 19:01:40 +00:00
|
|
|
stream_caps = gst_caps_new_simple ("video/x-unknown-fourcc",
|
2011-10-05 11:18:45 +00:00
|
|
|
"fourcc", G_TYPE_UINT, stream->fourcc, NULL);
|
2005-06-27 09:16:09 +00:00
|
|
|
GST_WARNING_OBJECT (rmdemux,
|
2006-08-07 19:01:40 +00:00
|
|
|
"Unknown audio FOURCC code \"%" GST_FOURCC_FORMAT "\" (%08x)",
|
|
|
|
GST_FOURCC_ARGS (stream->fourcc), stream->fourcc);
|
2004-10-04 16:10:41 +00:00
|
|
|
break;
|
2004-10-03 11:50:11 +00:00
|
|
|
}
|
2004-10-03 15:54:31 +00:00
|
|
|
|
|
|
|
if (version) {
|
2006-07-28 13:28:19 +00:00
|
|
|
stream_caps =
|
2004-10-03 15:54:31 +00:00
|
|
|
gst_caps_new_simple ("audio/x-pn-realaudio", "raversion", G_TYPE_INT,
|
|
|
|
(int) version, NULL);
|
|
|
|
}
|
|
|
|
|
2006-07-28 13:28:19 +00:00
|
|
|
if (stream_caps) {
|
|
|
|
gst_caps_set_simple (stream_caps,
|
2005-06-27 09:16:09 +00:00
|
|
|
"flavor", G_TYPE_INT, (int) stream->flavor,
|
2004-10-03 11:50:11 +00:00
|
|
|
"rate", G_TYPE_INT, (int) stream->rate,
|
2005-06-27 09:16:09 +00:00
|
|
|
"channels", G_TYPE_INT, (int) stream->n_channels,
|
|
|
|
"width", G_TYPE_INT, (int) stream->sample_width,
|
|
|
|
"leaf_size", G_TYPE_INT, (int) stream->leaf_size,
|
|
|
|
"packet_size", G_TYPE_INT, (int) stream->packet_size,
|
2010-06-05 12:11:30 +00:00
|
|
|
"bitrate", G_TYPE_INT, (int) stream->bitrate,
|
2005-06-27 09:16:09 +00:00
|
|
|
"height", G_TYPE_INT, (int) stream->height, NULL);
|
2004-10-03 11:50:11 +00:00
|
|
|
}
|
2003-06-22 03:59:01 +00:00
|
|
|
rmdemux->n_audio_streams++;
|
2004-03-14 22:34:30 +00:00
|
|
|
} else {
|
2005-12-15 17:06:10 +00:00
|
|
|
GST_WARNING_OBJECT (rmdemux, "not adding stream of type %d, freeing it",
|
2005-06-27 09:16:09 +00:00
|
|
|
stream->subtype);
|
2015-07-16 09:11:37 +00:00
|
|
|
gst_rmdemux_free_stream (rmdemux, stream);
|
2005-11-21 10:32:55 +00:00
|
|
|
goto beach;
|
2003-06-22 03:59:01 +00:00
|
|
|
}
|
|
|
|
|
2003-12-22 01:47:08 +00:00
|
|
|
GST_PAD_ELEMENT_PRIVATE (stream->pad) = stream;
|
2007-04-12 10:10:22 +00:00
|
|
|
rmdemux->streams = g_slist_append (rmdemux->streams, stream);
|
|
|
|
GST_LOG_OBJECT (rmdemux, "n_streams is now %d",
|
|
|
|
g_slist_length (rmdemux->streams));
|
2003-06-22 03:59:01 +00:00
|
|
|
|
2007-01-11 12:49:23 +00:00
|
|
|
GST_LOG ("stream->pad = %p, stream_caps = %" GST_PTR_FORMAT, stream->pad,
|
|
|
|
stream_caps);
|
|
|
|
|
2006-07-28 13:28:19 +00:00
|
|
|
if (stream->pad && stream_caps) {
|
2013-07-22 14:01:13 +00:00
|
|
|
GstEvent *event;
|
2006-03-24 19:06:41 +00:00
|
|
|
|
|
|
|
GST_LOG_OBJECT (rmdemux, "%d bytes of extra data for stream %s",
|
|
|
|
stream->extra_data_size, GST_PAD_NAME (stream->pad));
|
|
|
|
|
|
|
|
/* add codec_data if there is any */
|
|
|
|
if (stream->extra_data_size > 0) {
|
|
|
|
GstBuffer *buffer;
|
|
|
|
|
|
|
|
buffer = gst_buffer_new_and_alloc (stream->extra_data_size);
|
2011-10-05 11:18:45 +00:00
|
|
|
gst_buffer_fill (buffer, 0, stream->extra_data, stream->extra_data_size);
|
2006-03-24 19:06:41 +00:00
|
|
|
|
2006-07-28 13:28:19 +00:00
|
|
|
gst_caps_set_simple (stream_caps, "codec_data", GST_TYPE_BUFFER,
|
2006-03-24 19:06:41 +00:00
|
|
|
buffer, NULL);
|
|
|
|
|
|
|
|
gst_buffer_unref (buffer);
|
|
|
|
}
|
2003-06-22 03:59:01 +00:00
|
|
|
|
2006-07-28 13:28:19 +00:00
|
|
|
gst_pad_use_fixed_caps (stream->pad);
|
2003-06-22 03:59:01 +00:00
|
|
|
|
2005-08-10 08:33:19 +00:00
|
|
|
gst_pad_set_event_function (stream->pad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_rmdemux_src_event));
|
|
|
|
gst_pad_set_query_function (stream->pad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_rmdemux_src_query));
|
2005-07-03 17:40:04 +00:00
|
|
|
|
2006-03-24 11:42:31 +00:00
|
|
|
GST_DEBUG_OBJECT (rmdemux, "adding pad %s with caps %" GST_PTR_FORMAT
|
2006-07-28 13:28:19 +00:00
|
|
|
", stream_id=%d", GST_PAD_NAME (stream->pad), stream_caps, stream->id);
|
2006-10-10 17:02:05 +00:00
|
|
|
gst_pad_set_active (stream->pad, TRUE);
|
2012-08-05 16:30:52 +00:00
|
|
|
|
|
|
|
stream_id =
|
|
|
|
gst_pad_create_stream_id_printf (stream->pad,
|
2013-03-26 01:05:14 +00:00
|
|
|
GST_ELEMENT_CAST (rmdemux), "%03u", stream->id);
|
2013-07-22 14:01:13 +00:00
|
|
|
|
|
|
|
event =
|
|
|
|
gst_pad_get_sticky_event (rmdemux->sinkpad, GST_EVENT_STREAM_START, 0);
|
|
|
|
if (event) {
|
|
|
|
if (gst_event_parse_group_id (event, &rmdemux->group_id))
|
|
|
|
rmdemux->have_group_id = TRUE;
|
|
|
|
else
|
|
|
|
rmdemux->have_group_id = FALSE;
|
|
|
|
gst_event_unref (event);
|
|
|
|
} else if (!rmdemux->have_group_id) {
|
|
|
|
rmdemux->have_group_id = TRUE;
|
|
|
|
rmdemux->group_id = gst_util_group_id_next ();
|
|
|
|
}
|
|
|
|
|
|
|
|
event = gst_event_new_stream_start (stream_id);
|
|
|
|
if (rmdemux->have_group_id)
|
|
|
|
gst_event_set_group_id (event, rmdemux->group_id);
|
|
|
|
|
|
|
|
gst_pad_push_event (stream->pad, event);
|
2012-08-05 16:30:52 +00:00
|
|
|
g_free (stream_id);
|
|
|
|
|
2012-07-18 15:46:46 +00:00
|
|
|
gst_pad_set_caps (stream->pad, stream_caps);
|
2003-06-22 03:59:01 +00:00
|
|
|
|
2010-10-24 12:22:39 +00:00
|
|
|
codec_name = gst_pb_utils_get_codec_description (stream_caps);
|
|
|
|
|
2007-05-16 19:07:45 +00:00
|
|
|
/* save for later, we must send the tags after the newsegment event */
|
2010-10-24 12:22:39 +00:00
|
|
|
if (codec_tag != NULL && codec_name != NULL) {
|
2010-01-07 19:36:08 +00:00
|
|
|
if (stream->pending_tags == NULL)
|
2011-11-04 16:32:58 +00:00
|
|
|
stream->pending_tags = gst_tag_list_new_empty ();
|
2007-05-16 19:07:45 +00:00
|
|
|
gst_tag_list_add (stream->pending_tags, GST_TAG_MERGE_KEEP,
|
|
|
|
codec_tag, codec_name, NULL);
|
2010-10-24 12:22:39 +00:00
|
|
|
g_free (codec_name);
|
2006-03-24 19:47:37 +00:00
|
|
|
}
|
2012-08-05 16:30:52 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT_CAST (rmdemux), stream->pad);
|
2014-05-26 20:55:43 +00:00
|
|
|
gst_flow_combiner_add_pad (rmdemux->flowcombiner, stream->pad);
|
2005-06-27 09:16:09 +00:00
|
|
|
}
|
2005-11-21 10:32:55 +00:00
|
|
|
|
|
|
|
beach:
|
2006-07-28 13:28:19 +00:00
|
|
|
|
|
|
|
if (stream_caps)
|
|
|
|
gst_caps_unref (stream_caps);
|
2003-06-22 03:59:01 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
static int
|
2005-06-27 09:16:09 +00:00
|
|
|
re_skip_pascal_string (const guint8 * ptr)
|
2003-06-22 03:59:01 +00:00
|
|
|
{
|
|
|
|
int length;
|
|
|
|
|
|
|
|
length = ptr[0];
|
|
|
|
|
|
|
|
return length + 1;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
static void
|
2006-10-16 18:07:23 +00:00
|
|
|
gst_rmdemux_parse__rmf (GstRMDemux * rmdemux, const guint8 * data, int length)
|
2003-06-22 03:59:01 +00:00
|
|
|
{
|
2005-06-27 09:16:09 +00:00
|
|
|
GST_LOG_OBJECT (rmdemux, "file_version: %d", RMDEMUX_GUINT32_GET (data));
|
|
|
|
GST_LOG_OBJECT (rmdemux, "num_headers: %d", RMDEMUX_GUINT32_GET (data + 4));
|
2003-06-22 03:59:01 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
static void
|
2006-10-16 18:07:23 +00:00
|
|
|
gst_rmdemux_parse_prop (GstRMDemux * rmdemux, const guint8 * data, int length)
|
2005-06-27 09:16:09 +00:00
|
|
|
{
|
|
|
|
GST_LOG_OBJECT (rmdemux, "max bitrate: %d", RMDEMUX_GUINT32_GET (data));
|
|
|
|
GST_LOG_OBJECT (rmdemux, "avg bitrate: %d", RMDEMUX_GUINT32_GET (data + 4));
|
|
|
|
GST_LOG_OBJECT (rmdemux, "max packet size: %d",
|
|
|
|
RMDEMUX_GUINT32_GET (data + 8));
|
2005-08-10 08:33:19 +00:00
|
|
|
rmdemux->avg_packet_size = RMDEMUX_GUINT32_GET (data + 12);
|
|
|
|
GST_LOG_OBJECT (rmdemux, "avg packet size: %d", rmdemux->avg_packet_size);
|
|
|
|
rmdemux->num_packets = RMDEMUX_GUINT32_GET (data + 16);
|
|
|
|
GST_LOG_OBJECT (rmdemux, "number of packets: %d", rmdemux->num_packets);
|
2005-06-27 09:16:09 +00:00
|
|
|
|
|
|
|
GST_LOG_OBJECT (rmdemux, "duration: %d", RMDEMUX_GUINT32_GET (data + 20));
|
2005-08-22 07:33:00 +00:00
|
|
|
rmdemux->duration = RMDEMUX_GUINT32_GET (data + 20) * GST_MSECOND;
|
2005-06-27 09:16:09 +00:00
|
|
|
|
|
|
|
GST_LOG_OBJECT (rmdemux, "preroll: %d", RMDEMUX_GUINT32_GET (data + 24));
|
2005-08-10 08:33:19 +00:00
|
|
|
rmdemux->index_offset = RMDEMUX_GUINT32_GET (data + 28);
|
2005-06-27 09:16:09 +00:00
|
|
|
GST_LOG_OBJECT (rmdemux, "offset of INDX section: 0x%08x",
|
2005-08-10 08:33:19 +00:00
|
|
|
rmdemux->index_offset);
|
|
|
|
rmdemux->data_offset = RMDEMUX_GUINT32_GET (data + 32);
|
2005-06-27 09:16:09 +00:00
|
|
|
GST_LOG_OBJECT (rmdemux, "offset of DATA section: 0x%08x",
|
2005-08-10 08:33:19 +00:00
|
|
|
rmdemux->data_offset);
|
2005-06-27 09:16:09 +00:00
|
|
|
GST_LOG_OBJECT (rmdemux, "n streams: %d", RMDEMUX_GUINT16_GET (data + 36));
|
|
|
|
GST_LOG_OBJECT (rmdemux, "flags: 0x%04x", RMDEMUX_GUINT16_GET (data + 38));
|
2003-06-22 03:59:01 +00:00
|
|
|
}
|
|
|
|
|
gst/realmedia/rmdemux.*: Cleanups, use GstSegment for seeking.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_finalize), (gst_rmdemux_src_event),
(find_seek_offset_time), (gst_rmdemux_perform_seek),
(gst_rmdemux_src_query), (gst_rmdemux_change_state),
(gst_rmdemux_loop), (gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream), (gst_rmdemux_parse_mdpr),
(gst_rmdemux_combine_flows), (gst_rmdemux_parse_packet):
* gst/realmedia/rmdemux.h:
Cleanups, use GstSegment for seeking.
Fix error handling.
Combine flow return from all streams.
2006-07-13 11:28:32 +00:00
|
|
|
static void
|
2006-10-16 18:07:23 +00:00
|
|
|
gst_rmdemux_parse_mdpr (GstRMDemux * rmdemux, const guint8 * data, int length)
|
2003-06-22 03:59:01 +00:00
|
|
|
{
|
|
|
|
GstRMDemuxStream *stream;
|
|
|
|
char *stream1_type_string;
|
|
|
|
char *stream2_type_string;
|
2006-08-04 13:05:01 +00:00
|
|
|
guint str_len = 0;
|
2003-06-22 03:59:01 +00:00
|
|
|
int stream_type;
|
|
|
|
int offset;
|
2010-01-07 19:36:08 +00:00
|
|
|
guint32 max_bitrate;
|
|
|
|
guint32 avg_bitrate;
|
2003-06-22 03:59:01 +00:00
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
stream = g_new0 (GstRMDemuxStream, 1);
|
2003-06-22 03:59:01 +00:00
|
|
|
|
2005-06-27 09:16:09 +00:00
|
|
|
stream->id = RMDEMUX_GUINT16_GET (data);
|
2005-08-10 08:33:19 +00:00
|
|
|
stream->index = NULL;
|
2005-08-22 07:33:00 +00:00
|
|
|
stream->seek_offset = 0;
|
2008-05-06 17:53:26 +00:00
|
|
|
stream->last_ts = -1;
|
|
|
|
stream->next_ts = -1;
|
2008-08-27 09:47:17 +00:00
|
|
|
stream->discont = TRUE;
|
2007-08-07 10:57:09 +00:00
|
|
|
stream->adapter = gst_adapter_new ();
|
2005-06-27 09:16:09 +00:00
|
|
|
GST_LOG_OBJECT (rmdemux, "stream_number=%d", stream->id);
|
2003-06-22 03:59:01 +00:00
|
|
|
|
2010-01-07 19:36:08 +00:00
|
|
|
/* parse the bitrates */
|
|
|
|
max_bitrate = RMDEMUX_GUINT32_GET (data + 2);
|
|
|
|
avg_bitrate = RMDEMUX_GUINT32_GET (data + 6);
|
2010-06-05 12:11:30 +00:00
|
|
|
stream->bitrate = avg_bitrate;
|
2010-01-07 19:36:08 +00:00
|
|
|
GST_LOG_OBJECT (rmdemux, "Stream max bitrate=%u", max_bitrate);
|
|
|
|
GST_LOG_OBJECT (rmdemux, "Stream avg bitrate=%u", avg_bitrate);
|
|
|
|
if (max_bitrate != 0) {
|
|
|
|
if (stream->pending_tags == NULL)
|
2011-11-04 16:32:58 +00:00
|
|
|
stream->pending_tags = gst_tag_list_new_empty ();
|
2010-01-07 19:36:08 +00:00
|
|
|
gst_tag_list_add (stream->pending_tags, GST_TAG_MERGE_REPLACE,
|
|
|
|
GST_TAG_MAXIMUM_BITRATE, max_bitrate, NULL);
|
|
|
|
}
|
|
|
|
if (avg_bitrate != 0) {
|
|
|
|
if (stream->pending_tags == NULL)
|
2011-11-04 16:32:58 +00:00
|
|
|
stream->pending_tags = gst_tag_list_new_empty ();
|
2010-01-07 19:36:08 +00:00
|
|
|
gst_tag_list_add (stream->pending_tags, GST_TAG_MERGE_REPLACE,
|
|
|
|
GST_TAG_BITRATE, avg_bitrate, NULL);
|
|
|
|
}
|
|
|
|
|
2005-06-27 09:16:09 +00:00
|
|
|
offset = 30;
|
2006-08-04 13:05:01 +00:00
|
|
|
stream1_type_string = gst_rm_utils_read_string8 (data + offset,
|
|
|
|
length - offset, &str_len);
|
|
|
|
offset += str_len;
|
|
|
|
stream2_type_string = gst_rm_utils_read_string8 (data + offset,
|
|
|
|
length - offset, &str_len);
|
|
|
|
offset += str_len;
|
2004-10-04 18:27:54 +00:00
|
|
|
|
|
|
|
/* stream1_type_string for audio and video stream is a "put_whatever_you_want" field :
|
gst/realmedia/rmdemux.*: Cleanups, use GstSegment for seeking.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_finalize), (gst_rmdemux_src_event),
(find_seek_offset_time), (gst_rmdemux_perform_seek),
(gst_rmdemux_src_query), (gst_rmdemux_change_state),
(gst_rmdemux_loop), (gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream), (gst_rmdemux_parse_mdpr),
(gst_rmdemux_combine_flows), (gst_rmdemux_parse_packet):
* gst/realmedia/rmdemux.h:
Cleanups, use GstSegment for seeking.
Fix error handling.
Combine flow return from all streams.
2006-07-13 11:28:32 +00:00
|
|
|
* observed values :
|
|
|
|
* - "[The ]Video/Audio Stream" (File produced by an official Real encoder)
|
|
|
|
* - "RealVideoPremierePlugIn-VIDEO/AUDIO" (File produced by Abobe Premiere)
|
|
|
|
*
|
|
|
|
* so, we should not rely on it to know which stream type it is
|
2004-10-04 18:27:54 +00:00
|
|
|
*/
|
|
|
|
|
2005-06-27 09:16:09 +00:00
|
|
|
GST_LOG_OBJECT (rmdemux, "stream type: %s", stream1_type_string);
|
|
|
|
GST_LOG_OBJECT (rmdemux, "MIME type=%s", stream2_type_string);
|
|
|
|
|
2004-10-04 18:27:54 +00:00
|
|
|
if (strcmp (stream2_type_string, "video/x-pn-realvideo") == 0) {
|
2003-06-22 03:59:01 +00:00
|
|
|
stream_type = GST_RMDEMUX_STREAM_VIDEO;
|
gst/realmedia/: Added RDT depayloader.
Original commit message from CVS:
* gst/realmedia/Makefile.am:
* gst/realmedia/rdtdepay.c: (gst_rdt_depay_base_init),
(gst_rdt_depay_class_init), (gst_rdt_depay_init),
(gst_rdt_depay_setcaps), (gst_rdt_depay_chain),
(gst_rdt_depay_set_property), (gst_rdt_depay_get_property),
(gst_rdt_depay_change_state), (gst_rdt_depay_plugin_init):
* gst/realmedia/rdtdepay.h:
Added RDT depayloader.
* gst/realmedia/rmdemux.c: (gst_rmdemux_parse_mdpr),
(gst_rmdemux_plugin_init), (plugin_init):
Remove unused function.
Added some more mime-types.
2006-10-03 10:55:42 +00:00
|
|
|
} else if (strcmp (stream2_type_string,
|
|
|
|
"video/x-pn-multirate-realvideo") == 0) {
|
|
|
|
stream_type = GST_RMDEMUX_STREAM_VIDEO;
|
2004-10-04 18:27:54 +00:00
|
|
|
} else if (strcmp (stream2_type_string, "audio/x-pn-realaudio") == 0) {
|
2003-06-22 03:59:01 +00:00
|
|
|
stream_type = GST_RMDEMUX_STREAM_AUDIO;
|
gst/realmedia/: Added RDT depayloader.
Original commit message from CVS:
* gst/realmedia/Makefile.am:
* gst/realmedia/rdtdepay.c: (gst_rdt_depay_base_init),
(gst_rdt_depay_class_init), (gst_rdt_depay_init),
(gst_rdt_depay_setcaps), (gst_rdt_depay_chain),
(gst_rdt_depay_set_property), (gst_rdt_depay_get_property),
(gst_rdt_depay_change_state), (gst_rdt_depay_plugin_init):
* gst/realmedia/rdtdepay.h:
Added RDT depayloader.
* gst/realmedia/rmdemux.c: (gst_rmdemux_parse_mdpr),
(gst_rmdemux_plugin_init), (plugin_init):
Remove unused function.
Added some more mime-types.
2006-10-03 10:55:42 +00:00
|
|
|
} else if (strcmp (stream2_type_string,
|
|
|
|
"audio/x-pn-multirate-realaudio") == 0) {
|
|
|
|
stream_type = GST_RMDEMUX_STREAM_AUDIO;
|
|
|
|
} else if (strcmp (stream2_type_string,
|
|
|
|
"audio/x-pn-multirate-realaudio-live") == 0) {
|
|
|
|
stream_type = GST_RMDEMUX_STREAM_AUDIO;
|
2005-09-29 13:44:15 +00:00
|
|
|
} else if (strcmp (stream2_type_string, "audio/x-ralf-mpeg4-generic") == 0) {
|
|
|
|
/* Another audio type found in the real testsuite */
|
|
|
|
stream_type = GST_RMDEMUX_STREAM_AUDIO;
|
2004-03-14 22:34:30 +00:00
|
|
|
} else if (strcmp (stream1_type_string, "") == 0 &&
|
|
|
|
strcmp (stream2_type_string, "logical-fileinfo") == 0) {
|
2003-06-22 03:59:01 +00:00
|
|
|
stream_type = GST_RMDEMUX_STREAM_FILEINFO;
|
2004-03-14 22:34:30 +00:00
|
|
|
} else {
|
2003-06-22 03:59:01 +00:00
|
|
|
stream_type = GST_RMDEMUX_STREAM_UNKNOWN;
|
2005-06-27 09:16:09 +00:00
|
|
|
GST_WARNING_OBJECT (rmdemux, "unknown stream type \"%s\",\"%s\"",
|
|
|
|
stream1_type_string, stream2_type_string);
|
2003-06-22 03:59:01 +00:00
|
|
|
}
|
2004-03-14 22:34:30 +00:00
|
|
|
g_free (stream1_type_string);
|
|
|
|
g_free (stream2_type_string);
|
2003-06-22 03:59:01 +00:00
|
|
|
|
|
|
|
offset += 4;
|
|
|
|
|
|
|
|
stream->subtype = stream_type;
|
2004-03-14 22:34:30 +00:00
|
|
|
switch (stream_type) {
|
2004-10-03 15:54:31 +00:00
|
|
|
|
2003-06-22 03:59:01 +00:00
|
|
|
case GST_RMDEMUX_STREAM_VIDEO:
|
2004-10-03 11:50:11 +00:00
|
|
|
/* RV10/RV20/RV30/RV40 => video/x-pn-realvideo, version=1,2,3,4 */
|
2004-03-14 22:34:30 +00:00
|
|
|
stream->fourcc = RMDEMUX_FOURCC_GET (data + offset + 8);
|
|
|
|
stream->width = RMDEMUX_GUINT16_GET (data + offset + 12);
|
|
|
|
stream->height = RMDEMUX_GUINT16_GET (data + offset + 14);
|
|
|
|
stream->rate = RMDEMUX_GUINT16_GET (data + offset + 16);
|
2005-06-27 09:16:09 +00:00
|
|
|
stream->subformat = RMDEMUX_GUINT32_GET (data + offset + 26);
|
|
|
|
stream->format = RMDEMUX_GUINT32_GET (data + offset + 30);
|
2007-08-07 10:57:09 +00:00
|
|
|
stream->extra_data_size = length - (offset + 26);
|
|
|
|
stream->extra_data = (guint8 *) data + offset + 26;
|
gst/realmedia/rmdemux.c: Fractional framerates.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_sink_event),
(gst_rmdemux_src_event), (gst_rmdemux_validate_offset),
(find_seek_offset_bytes), (find_seek_offset_time),
(gst_rmdemux_perform_seek), (gst_rmdemux_src_query),
(gst_rmdemux_loop), (gst_rmdemux_fourcc_isplausible),
(gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream), (gst_rmdemux_parse_mdpr),
(gst_rmdemux_parse_packet):
Fractional framerates.
2005-11-23 00:26:42 +00:00
|
|
|
/* Natural way to represent framerates here requires unsigned 32 bit
|
|
|
|
* numerator, which we don't have. For the nasty case, approximate...
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
guint32 numerator = RMDEMUX_GUINT16_GET (data + offset + 22) * 65536 +
|
|
|
|
RMDEMUX_GUINT16_GET (data + offset + 24);
|
|
|
|
if (numerator > G_MAXINT) {
|
|
|
|
stream->framerate_numerator = (gint) (numerator >> 1);
|
|
|
|
stream->framerate_denominator = 32768;
|
|
|
|
} else {
|
|
|
|
stream->framerate_numerator = (gint) numerator;
|
|
|
|
stream->framerate_denominator = 65536;
|
|
|
|
}
|
|
|
|
}
|
2005-06-27 09:16:09 +00:00
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (rmdemux,
|
2005-11-21 14:08:45 +00:00
|
|
|
"Video stream with fourcc=%" GST_FOURCC_FORMAT
|
gst/realmedia/rmdemux.c: Fractional framerates.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_sink_event),
(gst_rmdemux_src_event), (gst_rmdemux_validate_offset),
(find_seek_offset_bytes), (find_seek_offset_time),
(gst_rmdemux_perform_seek), (gst_rmdemux_src_query),
(gst_rmdemux_loop), (gst_rmdemux_fourcc_isplausible),
(gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream), (gst_rmdemux_parse_mdpr),
(gst_rmdemux_parse_packet):
Fractional framerates.
2005-11-23 00:26:42 +00:00
|
|
|
" width=%d height=%d rate=%d framerate=%d/%d subformat=%x format=%x extra_data_size=%d",
|
2005-06-27 09:16:09 +00:00
|
|
|
GST_FOURCC_ARGS (stream->fourcc), stream->width, stream->height,
|
gst/realmedia/rmdemux.c: Fractional framerates.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_sink_event),
(gst_rmdemux_src_event), (gst_rmdemux_validate_offset),
(find_seek_offset_bytes), (find_seek_offset_time),
(gst_rmdemux_perform_seek), (gst_rmdemux_src_query),
(gst_rmdemux_loop), (gst_rmdemux_fourcc_isplausible),
(gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream), (gst_rmdemux_parse_mdpr),
(gst_rmdemux_parse_packet):
Fractional framerates.
2005-11-23 00:26:42 +00:00
|
|
|
stream->rate, stream->framerate_numerator,
|
|
|
|
stream->framerate_denominator, stream->subformat, stream->format,
|
2005-06-27 09:16:09 +00:00
|
|
|
stream->extra_data_size);
|
2003-06-22 03:59:01 +00:00
|
|
|
break;
|
2004-10-03 17:14:14 +00:00
|
|
|
case GST_RMDEMUX_STREAM_AUDIO:{
|
2005-06-27 09:16:09 +00:00
|
|
|
stream->version = RMDEMUX_GUINT16_GET (data + offset + 4);
|
gst/realmedia/rmdemux.c: Descramble cook audio streams before sending them to the decoder. Fixes #347292.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_init), (gst_rmdemux_chain), (gst_rmdemux_add_stream),
(gst_rmdemux_parse_mdpr), (gst_rmdemux_parse_data),
(gst_rmdemux_stream_clear_cached_subpackets),
(gst_rmdemux_descramble_cook_audio),
(gst_rmdemux_descramble_dnet_audio),
(gst_rmdemux_handle_scrambled_packet), (gst_rmdemux_parse_packet):
Descramble cook audio streams before sending them to the
decoder. Fixes #347292.
Also miscellaneous clean-ups and log-level changes.
2006-07-27 20:34:25 +00:00
|
|
|
GST_INFO ("stream version = %u", stream->version);
|
2005-06-27 09:16:09 +00:00
|
|
|
switch (stream->version) {
|
2006-08-07 19:01:40 +00:00
|
|
|
case 3:
|
|
|
|
stream->fourcc = GST_RM_AUD_14_4;
|
|
|
|
stream->packet_size = 20;
|
|
|
|
stream->rate = 8000;
|
|
|
|
stream->n_channels = 1;
|
|
|
|
stream->sample_width = 16;
|
|
|
|
stream->flavor = 1;
|
|
|
|
stream->leaf_size = 0;
|
|
|
|
stream->height = 0;
|
|
|
|
break;
|
2005-06-27 09:16:09 +00:00
|
|
|
case 4:
|
2006-08-07 19:01:40 +00:00
|
|
|
stream->flavor = RMDEMUX_GUINT16_GET (data + offset + 22);
|
|
|
|
stream->packet_size = RMDEMUX_GUINT32_GET (data + offset + 24);
|
|
|
|
/* stream->frame_size = RMDEMUX_GUINT32_GET (data + offset + 42); */
|
|
|
|
stream->leaf_size = RMDEMUX_GUINT16_GET (data + offset + 44);
|
|
|
|
stream->height = RMDEMUX_GUINT16_GET (data + offset + 40);
|
2005-06-27 09:16:09 +00:00
|
|
|
stream->rate = RMDEMUX_GUINT16_GET (data + offset + 48);
|
|
|
|
stream->sample_width = RMDEMUX_GUINT16_GET (data + offset + 52);
|
|
|
|
stream->n_channels = RMDEMUX_GUINT16_GET (data + offset + 54);
|
|
|
|
stream->fourcc = RMDEMUX_FOURCC_GET (data + offset + 62);
|
2006-12-12 10:24:40 +00:00
|
|
|
stream->extra_data_size = RMDEMUX_GUINT32_GET (data + offset + 69);
|
|
|
|
GST_DEBUG_OBJECT (rmdemux, "%u bytes of extra codec data",
|
|
|
|
stream->extra_data_size);
|
|
|
|
if (length - (offset + 73) >= stream->extra_data_size) {
|
|
|
|
stream->extra_data = (guint8 *) data + offset + 73;
|
|
|
|
} else {
|
|
|
|
GST_WARNING_OBJECT (rmdemux, "codec data runs beyond MDPR chunk");
|
|
|
|
stream->extra_data_size = 0;
|
|
|
|
}
|
2004-10-03 15:54:31 +00:00
|
|
|
break;
|
2005-06-27 09:16:09 +00:00
|
|
|
case 5:
|
2006-08-07 19:01:40 +00:00
|
|
|
stream->flavor = RMDEMUX_GUINT16_GET (data + offset + 22);
|
|
|
|
stream->packet_size = RMDEMUX_GUINT32_GET (data + offset + 24);
|
|
|
|
/* stream->frame_size = RMDEMUX_GUINT32_GET (data + offset + 42); */
|
|
|
|
stream->leaf_size = RMDEMUX_GUINT16_GET (data + offset + 44);
|
|
|
|
stream->height = RMDEMUX_GUINT16_GET (data + offset + 40);
|
2005-06-27 09:16:09 +00:00
|
|
|
stream->rate = RMDEMUX_GUINT16_GET (data + offset + 54);
|
|
|
|
stream->sample_width = RMDEMUX_GUINT16_GET (data + offset + 58);
|
|
|
|
stream->n_channels = RMDEMUX_GUINT16_GET (data + offset + 60);
|
|
|
|
stream->fourcc = RMDEMUX_FOURCC_GET (data + offset + 66);
|
|
|
|
stream->extra_data_size = RMDEMUX_GUINT32_GET (data + offset + 74);
|
2006-12-12 10:24:40 +00:00
|
|
|
GST_DEBUG_OBJECT (rmdemux, "%u bytes of extra codec data",
|
|
|
|
stream->extra_data_size);
|
|
|
|
if (length - (offset + 78) >= stream->extra_data_size) {
|
|
|
|
stream->extra_data = (guint8 *) data + offset + 78;
|
|
|
|
} else {
|
|
|
|
GST_WARNING_OBJECT (rmdemux, "codec data runs beyond MDPR chunk");
|
|
|
|
stream->extra_data_size = 0;
|
|
|
|
}
|
2004-10-03 15:54:31 +00:00
|
|
|
break;
|
2006-08-07 19:01:40 +00:00
|
|
|
default:{
|
|
|
|
GST_WARNING_OBJECT (rmdemux, "Unhandled audio stream version %d",
|
|
|
|
stream->version);
|
|
|
|
break;
|
|
|
|
}
|
2004-10-03 15:54:31 +00:00
|
|
|
}
|
|
|
|
/* 14_4, 28_8, cook, dnet, sipr, raac, racp, ralf, atrc */
|
2005-06-27 09:16:09 +00:00
|
|
|
GST_DEBUG_OBJECT (rmdemux,
|
|
|
|
"Audio stream with rate=%d sample_width=%d n_channels=%d",
|
|
|
|
stream->rate, stream->sample_width, stream->n_channels);
|
|
|
|
|
2003-06-22 03:59:01 +00:00
|
|
|
break;
|
2004-10-03 17:14:14 +00:00
|
|
|
}
|
2003-06-22 03:59:01 +00:00
|
|
|
case GST_RMDEMUX_STREAM_FILEINFO:
|
2004-03-14 22:34:30 +00:00
|
|
|
{
|
2004-10-03 01:37:11 +00:00
|
|
|
int element_nb;
|
2004-03-14 22:34:30 +00:00
|
|
|
|
2004-10-03 01:37:11 +00:00
|
|
|
/* Length of this section */
|
2005-06-27 09:16:09 +00:00
|
|
|
GST_DEBUG_OBJECT (rmdemux, "length2: 0x%08x",
|
|
|
|
RMDEMUX_GUINT32_GET (data + offset));
|
2004-03-14 22:34:30 +00:00
|
|
|
offset += 4;
|
2004-10-03 01:37:11 +00:00
|
|
|
|
|
|
|
/* Unknown : 00 00 00 00 */
|
|
|
|
offset += 4;
|
|
|
|
|
|
|
|
/* Number of variables that would follow (loop iterations) */
|
|
|
|
element_nb = RMDEMUX_GUINT32_GET (data + offset);
|
|
|
|
offset += 4;
|
|
|
|
|
|
|
|
while (element_nb) {
|
|
|
|
/* Category Id : 00 00 00 XX 00 00 */
|
2004-03-15 19:32:25 +00:00
|
|
|
offset += 6;
|
2004-10-03 01:37:11 +00:00
|
|
|
|
|
|
|
/* Variable Name */
|
2005-06-27 09:16:09 +00:00
|
|
|
offset += re_skip_pascal_string (data + offset);
|
2004-10-03 01:37:11 +00:00
|
|
|
|
|
|
|
/* Variable Value Type */
|
|
|
|
/* 00 00 00 00 00 => integer/boolean, preceded by length */
|
|
|
|
/* 00 00 00 02 00 => pascal string, preceded by length, no trailing \0 */
|
2004-03-15 19:32:25 +00:00
|
|
|
offset += 5;
|
2004-10-03 01:37:11 +00:00
|
|
|
|
|
|
|
/* Variable Value */
|
2005-06-27 09:16:09 +00:00
|
|
|
offset += re_skip_pascal_string (data + offset);
|
2004-10-03 01:37:11 +00:00
|
|
|
|
|
|
|
element_nb--;
|
2003-06-22 03:59:01 +00:00
|
|
|
}
|
2004-03-14 22:34:30 +00:00
|
|
|
}
|
2003-06-22 03:59:01 +00:00
|
|
|
break;
|
|
|
|
case GST_RMDEMUX_STREAM_UNKNOWN:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
gst/realmedia/rmdemux.*: Cleanups, use GstSegment for seeking.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_finalize), (gst_rmdemux_src_event),
(find_seek_offset_time), (gst_rmdemux_perform_seek),
(gst_rmdemux_src_query), (gst_rmdemux_change_state),
(gst_rmdemux_loop), (gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream), (gst_rmdemux_parse_mdpr),
(gst_rmdemux_combine_flows), (gst_rmdemux_parse_packet):
* gst/realmedia/rmdemux.h:
Cleanups, use GstSegment for seeking.
Fix error handling.
Combine flow return from all streams.
2006-07-13 11:28:32 +00:00
|
|
|
gst_rmdemux_add_stream (rmdemux, stream);
|
2003-06-22 03:59:01 +00:00
|
|
|
}
|
|
|
|
|
2005-08-25 00:32:22 +00:00
|
|
|
static guint
|
2006-10-16 18:07:23 +00:00
|
|
|
gst_rmdemux_parse_indx (GstRMDemux * rmdemux, const guint8 * data, int length)
|
2003-06-22 03:59:01 +00:00
|
|
|
{
|
|
|
|
int n;
|
|
|
|
int id;
|
|
|
|
|
2005-06-27 09:16:09 +00:00
|
|
|
n = RMDEMUX_GUINT32_GET (data);
|
|
|
|
id = RMDEMUX_GUINT16_GET (data + 4);
|
2005-08-10 08:33:19 +00:00
|
|
|
rmdemux->index_offset = RMDEMUX_GUINT32_GET (data + 6);
|
|
|
|
|
2005-08-25 00:32:22 +00:00
|
|
|
GST_DEBUG_OBJECT (rmdemux, "Number of indices=%d Stream ID=%d length=%d", n,
|
|
|
|
id, length);
|
|
|
|
|
|
|
|
/* Point to the next index_stream */
|
|
|
|
rmdemux->index_stream = gst_rmdemux_get_stream_by_id (rmdemux, id);
|
|
|
|
|
|
|
|
/* Return the length of the index */
|
|
|
|
return 14 * n;
|
|
|
|
}
|
2003-06-22 03:59:01 +00:00
|
|
|
|
2005-08-25 00:32:22 +00:00
|
|
|
static void
|
2006-10-16 18:07:23 +00:00
|
|
|
gst_rmdemux_parse_indx_data (GstRMDemux * rmdemux, const guint8 * data,
|
|
|
|
int length)
|
2005-08-25 00:32:22 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int n;
|
|
|
|
GstRMDemuxIndex *index;
|
|
|
|
|
|
|
|
/* The number of index records */
|
|
|
|
n = length / 14;
|
|
|
|
|
|
|
|
if (rmdemux->index_stream == NULL)
|
2005-06-27 09:16:09 +00:00
|
|
|
return;
|
2003-06-22 03:59:01 +00:00
|
|
|
|
2006-12-14 11:49:39 +00:00
|
|
|
/* don't parse the index a second time when operating pull-based and
|
|
|
|
* reaching the end of the file */
|
|
|
|
if (rmdemux->index_stream->index_length > 0) {
|
|
|
|
GST_DEBUG_OBJECT (rmdemux, "Already have an index for this stream");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
index = g_malloc (sizeof (GstRMDemuxIndex) * n);
|
2005-08-25 00:32:22 +00:00
|
|
|
rmdemux->index_stream->index = index;
|
|
|
|
rmdemux->index_stream->index_length = n;
|
2003-06-22 03:59:01 +00:00
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
for (i = 0; i < n; i++) {
|
2005-08-25 00:32:22 +00:00
|
|
|
index[i].timestamp = RMDEMUX_GUINT32_GET (data + 2) * GST_MSECOND;
|
|
|
|
index[i].offset = RMDEMUX_GUINT32_GET (data + 6);
|
2005-08-10 08:33:19 +00:00
|
|
|
|
2005-08-22 07:33:00 +00:00
|
|
|
GST_DEBUG_OBJECT (rmdemux, "Index found for timestamp=%f (at offset=%x)",
|
2007-02-11 13:42:45 +00:00
|
|
|
gst_guint64_to_gdouble (index[i].timestamp) / GST_SECOND,
|
|
|
|
index[i].offset);
|
2005-08-25 00:32:22 +00:00
|
|
|
data += 14;
|
2003-06-22 03:59:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
static void
|
2006-10-16 18:07:23 +00:00
|
|
|
gst_rmdemux_parse_data (GstRMDemux * rmdemux, const guint8 * data, int length)
|
2003-06-22 03:59:01 +00:00
|
|
|
{
|
2005-06-27 09:16:09 +00:00
|
|
|
rmdemux->n_chunks = RMDEMUX_GUINT32_GET (data);
|
2005-08-25 00:32:22 +00:00
|
|
|
rmdemux->data_offset = RMDEMUX_GUINT32_GET (data + 4);
|
2005-06-27 09:16:09 +00:00
|
|
|
rmdemux->chunk_index = 0;
|
gst/realmedia/rmdemux.c: Descramble cook audio streams before sending them to the decoder. Fixes #347292.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_init), (gst_rmdemux_chain), (gst_rmdemux_add_stream),
(gst_rmdemux_parse_mdpr), (gst_rmdemux_parse_data),
(gst_rmdemux_stream_clear_cached_subpackets),
(gst_rmdemux_descramble_cook_audio),
(gst_rmdemux_descramble_dnet_audio),
(gst_rmdemux_handle_scrambled_packet), (gst_rmdemux_parse_packet):
Descramble cook audio streams before sending them to the
decoder. Fixes #347292.
Also miscellaneous clean-ups and log-level changes.
2006-07-27 20:34:25 +00:00
|
|
|
GST_DEBUG_OBJECT (rmdemux, "Data chunk found with %d packets "
|
|
|
|
"(next data at 0x%08x)", rmdemux->n_chunks, rmdemux->data_offset);
|
2003-06-22 03:59:01 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:30 +00:00
|
|
|
static void
|
2006-10-16 18:07:23 +00:00
|
|
|
gst_rmdemux_parse_cont (GstRMDemux * rmdemux, const guint8 * data, int length)
|
2003-06-22 03:59:01 +00:00
|
|
|
{
|
2006-03-24 19:47:37 +00:00
|
|
|
GstTagList *tags;
|
|
|
|
|
2006-08-04 13:05:01 +00:00
|
|
|
tags = gst_rm_utils_read_tags (data, length, gst_rm_utils_read_string16);
|
2011-09-08 13:33:00 +00:00
|
|
|
|
2015-07-21 03:44:55 +00:00
|
|
|
if (tags) {
|
2015-07-21 10:10:04 +00:00
|
|
|
GstTagList *old_tags = rmdemux->pending_tags;
|
|
|
|
|
2015-07-21 03:44:55 +00:00
|
|
|
GST_LOG_OBJECT (rmdemux, "tags: %" GST_PTR_FORMAT, tags);
|
2011-09-08 13:33:00 +00:00
|
|
|
|
2015-07-21 03:44:55 +00:00
|
|
|
rmdemux->pending_tags =
|
2015-07-21 10:10:04 +00:00
|
|
|
gst_tag_list_merge (old_tags, tags, GST_TAG_MERGE_APPEND);
|
|
|
|
|
2015-07-21 03:44:55 +00:00
|
|
|
gst_tag_list_unref (tags);
|
2015-08-06 01:05:53 +00:00
|
|
|
if (old_tags)
|
|
|
|
gst_tag_list_unref (old_tags);
|
2015-07-21 10:13:27 +00:00
|
|
|
|
|
|
|
gst_tag_list_set_scope (rmdemux->pending_tags, GST_TAG_SCOPE_GLOBAL);
|
2015-07-21 03:44:55 +00:00
|
|
|
}
|
2003-06-22 03:59:01 +00:00
|
|
|
}
|
|
|
|
|
gst/realmedia/rmdemux.c: Descramble cook audio streams before sending them to the decoder. Fixes #347292.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_init), (gst_rmdemux_chain), (gst_rmdemux_add_stream),
(gst_rmdemux_parse_mdpr), (gst_rmdemux_parse_data),
(gst_rmdemux_stream_clear_cached_subpackets),
(gst_rmdemux_descramble_cook_audio),
(gst_rmdemux_descramble_dnet_audio),
(gst_rmdemux_handle_scrambled_packet), (gst_rmdemux_parse_packet):
Descramble cook audio streams before sending them to the
decoder. Fixes #347292.
Also miscellaneous clean-ups and log-level changes.
2006-07-27 20:34:25 +00:00
|
|
|
static void
|
|
|
|
gst_rmdemux_stream_clear_cached_subpackets (GstRMDemux * rmdemux,
|
|
|
|
GstRMDemuxStream * stream)
|
|
|
|
{
|
|
|
|
if (stream->subpackets == NULL || stream->subpackets->len == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (rmdemux, "discarding %u previously collected subpackets",
|
|
|
|
stream->subpackets->len);
|
|
|
|
g_ptr_array_foreach (stream->subpackets, (GFunc) gst_mini_object_unref, NULL);
|
|
|
|
g_ptr_array_set_size (stream->subpackets, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
2010-05-13 15:57:57 +00:00
|
|
|
gst_rmdemux_descramble_audio (GstRMDemux * rmdemux, GstRMDemuxStream * stream)
|
gst/realmedia/rmdemux.c: Descramble cook audio streams before sending them to the decoder. Fixes #347292.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_init), (gst_rmdemux_chain), (gst_rmdemux_add_stream),
(gst_rmdemux_parse_mdpr), (gst_rmdemux_parse_data),
(gst_rmdemux_stream_clear_cached_subpackets),
(gst_rmdemux_descramble_cook_audio),
(gst_rmdemux_descramble_dnet_audio),
(gst_rmdemux_handle_scrambled_packet), (gst_rmdemux_parse_packet):
Descramble cook audio streams before sending them to the
decoder. Fixes #347292.
Also miscellaneous clean-ups and log-level changes.
2006-07-27 20:34:25 +00:00
|
|
|
{
|
2011-01-06 12:15:17 +00:00
|
|
|
GstFlowReturn ret = GST_FLOW_ERROR;
|
gst/realmedia/rmdemux.c: Descramble cook audio streams before sending them to the decoder. Fixes #347292.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_init), (gst_rmdemux_chain), (gst_rmdemux_add_stream),
(gst_rmdemux_parse_mdpr), (gst_rmdemux_parse_data),
(gst_rmdemux_stream_clear_cached_subpackets),
(gst_rmdemux_descramble_cook_audio),
(gst_rmdemux_descramble_dnet_audio),
(gst_rmdemux_handle_scrambled_packet), (gst_rmdemux_parse_packet):
Descramble cook audio streams before sending them to the
decoder. Fixes #347292.
Also miscellaneous clean-ups and log-level changes.
2006-07-27 20:34:25 +00:00
|
|
|
GstBuffer *outbuf;
|
2012-01-25 06:24:59 +00:00
|
|
|
GstMapInfo outmap;
|
gst/realmedia/rmdemux.c: Descramble cook audio streams before sending them to the decoder. Fixes #347292.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_init), (gst_rmdemux_chain), (gst_rmdemux_add_stream),
(gst_rmdemux_parse_mdpr), (gst_rmdemux_parse_data),
(gst_rmdemux_stream_clear_cached_subpackets),
(gst_rmdemux_descramble_cook_audio),
(gst_rmdemux_descramble_dnet_audio),
(gst_rmdemux_handle_scrambled_packet), (gst_rmdemux_parse_packet):
Descramble cook audio streams before sending them to the
decoder. Fixes #347292.
Also miscellaneous clean-ups and log-level changes.
2006-07-27 20:34:25 +00:00
|
|
|
guint packet_size = stream->packet_size;
|
|
|
|
guint height = stream->subpackets->len;
|
|
|
|
guint leaf_size = stream->leaf_size;
|
|
|
|
guint p, x;
|
|
|
|
|
|
|
|
g_assert (stream->height == height);
|
|
|
|
|
|
|
|
GST_LOG ("packet_size = %u, leaf_size = %u, height= %u", packet_size,
|
|
|
|
leaf_size, height);
|
|
|
|
|
2010-12-24 10:12:19 +00:00
|
|
|
outbuf = gst_buffer_new_and_alloc (height * packet_size);
|
2012-01-25 06:24:59 +00:00
|
|
|
gst_buffer_map (outbuf, &outmap, GST_MAP_WRITE);
|
gst/realmedia/rmdemux.c: Descramble cook audio streams before sending them to the decoder. Fixes #347292.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_init), (gst_rmdemux_chain), (gst_rmdemux_add_stream),
(gst_rmdemux_parse_mdpr), (gst_rmdemux_parse_data),
(gst_rmdemux_stream_clear_cached_subpackets),
(gst_rmdemux_descramble_cook_audio),
(gst_rmdemux_descramble_dnet_audio),
(gst_rmdemux_handle_scrambled_packet), (gst_rmdemux_parse_packet):
Descramble cook audio streams before sending them to the
decoder. Fixes #347292.
Also miscellaneous clean-ups and log-level changes.
2006-07-27 20:34:25 +00:00
|
|
|
|
|
|
|
for (p = 0; p < height; ++p) {
|
|
|
|
GstBuffer *b = g_ptr_array_index (stream->subpackets, p);
|
2012-01-25 06:24:59 +00:00
|
|
|
GstMapInfo map;
|
|
|
|
|
|
|
|
gst_buffer_map (b, &map, GST_MAP_READ);
|
gst/realmedia/rmdemux.c: Descramble cook audio streams before sending them to the decoder. Fixes #347292.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_init), (gst_rmdemux_chain), (gst_rmdemux_add_stream),
(gst_rmdemux_parse_mdpr), (gst_rmdemux_parse_data),
(gst_rmdemux_stream_clear_cached_subpackets),
(gst_rmdemux_descramble_cook_audio),
(gst_rmdemux_descramble_dnet_audio),
(gst_rmdemux_handle_scrambled_packet), (gst_rmdemux_parse_packet):
Descramble cook audio streams before sending them to the
decoder. Fixes #347292.
Also miscellaneous clean-ups and log-level changes.
2006-07-27 20:34:25 +00:00
|
|
|
|
2012-09-13 11:49:33 +00:00
|
|
|
if (p == 0) {
|
|
|
|
GST_BUFFER_PTS (outbuf) = GST_BUFFER_PTS (b);
|
|
|
|
GST_BUFFER_DTS (outbuf) = GST_BUFFER_DTS (b);
|
|
|
|
}
|
gst/realmedia/rmdemux.c: Descramble cook audio streams before sending them to the decoder. Fixes #347292.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_init), (gst_rmdemux_chain), (gst_rmdemux_add_stream),
(gst_rmdemux_parse_mdpr), (gst_rmdemux_parse_data),
(gst_rmdemux_stream_clear_cached_subpackets),
(gst_rmdemux_descramble_cook_audio),
(gst_rmdemux_descramble_dnet_audio),
(gst_rmdemux_handle_scrambled_packet), (gst_rmdemux_parse_packet):
Descramble cook audio streams before sending them to the
decoder. Fixes #347292.
Also miscellaneous clean-ups and log-level changes.
2006-07-27 20:34:25 +00:00
|
|
|
|
|
|
|
for (x = 0; x < packet_size / leaf_size; ++x) {
|
|
|
|
guint idx;
|
|
|
|
|
|
|
|
idx = height * x + ((height + 1) / 2) * (p % 2) + (p / 2);
|
2011-10-05 11:18:45 +00:00
|
|
|
|
gst/realmedia/rmdemux.c: Descramble cook audio streams before sending them to the decoder. Fixes #347292.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_init), (gst_rmdemux_chain), (gst_rmdemux_add_stream),
(gst_rmdemux_parse_mdpr), (gst_rmdemux_parse_data),
(gst_rmdemux_stream_clear_cached_subpackets),
(gst_rmdemux_descramble_cook_audio),
(gst_rmdemux_descramble_dnet_audio),
(gst_rmdemux_handle_scrambled_packet), (gst_rmdemux_parse_packet):
Descramble cook audio streams before sending them to the
decoder. Fixes #347292.
Also miscellaneous clean-ups and log-level changes.
2006-07-27 20:34:25 +00:00
|
|
|
/* GST_LOG ("%3u => %3u", (height * p) + x, idx); */
|
2012-01-25 06:24:59 +00:00
|
|
|
memcpy (outmap.data + leaf_size * idx, map.data + leaf_size * x,
|
|
|
|
leaf_size);
|
gst/realmedia/rmdemux.c: Descramble cook audio streams before sending them to the decoder. Fixes #347292.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_init), (gst_rmdemux_chain), (gst_rmdemux_add_stream),
(gst_rmdemux_parse_mdpr), (gst_rmdemux_parse_data),
(gst_rmdemux_stream_clear_cached_subpackets),
(gst_rmdemux_descramble_cook_audio),
(gst_rmdemux_descramble_dnet_audio),
(gst_rmdemux_handle_scrambled_packet), (gst_rmdemux_parse_packet):
Descramble cook audio streams before sending them to the
decoder. Fixes #347292.
Also miscellaneous clean-ups and log-level changes.
2006-07-27 20:34:25 +00:00
|
|
|
}
|
2012-01-25 06:24:59 +00:00
|
|
|
gst_buffer_unmap (b, &map);
|
gst/realmedia/rmdemux.c: Descramble cook audio streams before sending them to the decoder. Fixes #347292.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_init), (gst_rmdemux_chain), (gst_rmdemux_add_stream),
(gst_rmdemux_parse_mdpr), (gst_rmdemux_parse_data),
(gst_rmdemux_stream_clear_cached_subpackets),
(gst_rmdemux_descramble_cook_audio),
(gst_rmdemux_descramble_dnet_audio),
(gst_rmdemux_handle_scrambled_packet), (gst_rmdemux_parse_packet):
Descramble cook audio streams before sending them to the
decoder. Fixes #347292.
Also miscellaneous clean-ups and log-level changes.
2006-07-27 20:34:25 +00:00
|
|
|
}
|
2012-01-25 06:24:59 +00:00
|
|
|
gst_buffer_unmap (outbuf, &outmap);
|
gst/realmedia/rmdemux.c: Descramble cook audio streams before sending them to the decoder. Fixes #347292.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_init), (gst_rmdemux_chain), (gst_rmdemux_add_stream),
(gst_rmdemux_parse_mdpr), (gst_rmdemux_parse_data),
(gst_rmdemux_stream_clear_cached_subpackets),
(gst_rmdemux_descramble_cook_audio),
(gst_rmdemux_descramble_dnet_audio),
(gst_rmdemux_handle_scrambled_packet), (gst_rmdemux_parse_packet):
Descramble cook audio streams before sending them to the
decoder. Fixes #347292.
Also miscellaneous clean-ups and log-level changes.
2006-07-27 20:34:25 +00:00
|
|
|
|
2007-05-16 19:15:13 +00:00
|
|
|
/* some decoders, such as realaudiodec, need to be fed in packet units */
|
|
|
|
for (p = 0; p < height; ++p) {
|
|
|
|
GstBuffer *subbuf;
|
|
|
|
|
2011-10-05 11:18:45 +00:00
|
|
|
subbuf =
|
|
|
|
gst_buffer_copy_region (outbuf, GST_BUFFER_COPY_ALL, p * packet_size,
|
|
|
|
packet_size);
|
2008-08-27 09:47:17 +00:00
|
|
|
|
2012-09-13 11:49:33 +00:00
|
|
|
GST_LOG_OBJECT (rmdemux, "pushing buffer dts %" GST_TIME_FORMAT ", pts %"
|
|
|
|
GST_TIME_FORMAT, GST_TIME_ARGS (GST_BUFFER_DTS (subbuf)),
|
|
|
|
GST_TIME_ARGS (GST_BUFFER_PTS (subbuf)));
|
2008-08-27 09:47:17 +00:00
|
|
|
|
|
|
|
if (stream->discont) {
|
|
|
|
GST_BUFFER_FLAG_SET (subbuf, GST_BUFFER_FLAG_DISCONT);
|
|
|
|
stream->discont = FALSE;
|
|
|
|
}
|
|
|
|
|
2007-05-16 19:15:13 +00:00
|
|
|
ret = gst_pad_push (stream->pad, subbuf);
|
|
|
|
if (ret != GST_FLOW_OK)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_buffer_unref (outbuf);
|
gst/realmedia/rmdemux.c: Descramble cook audio streams before sending them to the decoder. Fixes #347292.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_init), (gst_rmdemux_chain), (gst_rmdemux_add_stream),
(gst_rmdemux_parse_mdpr), (gst_rmdemux_parse_data),
(gst_rmdemux_stream_clear_cached_subpackets),
(gst_rmdemux_descramble_cook_audio),
(gst_rmdemux_descramble_dnet_audio),
(gst_rmdemux_handle_scrambled_packet), (gst_rmdemux_parse_packet):
Descramble cook audio streams before sending them to the
decoder. Fixes #347292.
Also miscellaneous clean-ups and log-level changes.
2006-07-27 20:34:25 +00:00
|
|
|
|
|
|
|
gst_rmdemux_stream_clear_cached_subpackets (rmdemux, stream);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
|
|
|
gst_rmdemux_descramble_dnet_audio (GstRMDemux * rmdemux,
|
|
|
|
GstRMDemuxStream * stream)
|
|
|
|
{
|
|
|
|
GstBuffer *buf;
|
|
|
|
|
|
|
|
buf = g_ptr_array_index (stream->subpackets, 0);
|
|
|
|
g_ptr_array_index (stream->subpackets, 0) = NULL;
|
|
|
|
g_ptr_array_set_size (stream->subpackets, 0);
|
|
|
|
|
2007-01-11 12:49:23 +00:00
|
|
|
buf = gst_rm_utils_descramble_dnet_buffer (buf);
|
2008-08-27 09:47:17 +00:00
|
|
|
|
|
|
|
if (stream->discont) {
|
|
|
|
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DISCONT);
|
|
|
|
stream->discont = FALSE;
|
|
|
|
}
|
gst/realmedia/rmdemux.c: Descramble cook audio streams before sending them to the decoder. Fixes #347292.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_init), (gst_rmdemux_chain), (gst_rmdemux_add_stream),
(gst_rmdemux_parse_mdpr), (gst_rmdemux_parse_data),
(gst_rmdemux_stream_clear_cached_subpackets),
(gst_rmdemux_descramble_cook_audio),
(gst_rmdemux_descramble_dnet_audio),
(gst_rmdemux_handle_scrambled_packet), (gst_rmdemux_parse_packet):
Descramble cook audio streams before sending them to the
decoder. Fixes #347292.
Also miscellaneous clean-ups and log-level changes.
2006-07-27 20:34:25 +00:00
|
|
|
return gst_pad_push (stream->pad, buf);
|
|
|
|
}
|
|
|
|
|
2008-10-24 12:47:05 +00:00
|
|
|
static GstFlowReturn
|
|
|
|
gst_rmdemux_descramble_mp4a_audio (GstRMDemux * rmdemux,
|
|
|
|
GstRMDemuxStream * stream)
|
|
|
|
{
|
|
|
|
GstFlowReturn res;
|
|
|
|
GstBuffer *buf, *outbuf;
|
|
|
|
guint frames, index, i;
|
2012-01-25 06:24:59 +00:00
|
|
|
GstMapInfo map;
|
2008-10-24 12:47:05 +00:00
|
|
|
GstClockTime timestamp;
|
|
|
|
|
|
|
|
res = GST_FLOW_OK;
|
|
|
|
|
|
|
|
buf = g_ptr_array_index (stream->subpackets, 0);
|
|
|
|
g_ptr_array_index (stream->subpackets, 0) = NULL;
|
|
|
|
g_ptr_array_set_size (stream->subpackets, 0);
|
|
|
|
|
2012-01-25 06:24:59 +00:00
|
|
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
2012-09-13 11:49:33 +00:00
|
|
|
timestamp = GST_BUFFER_PTS (buf);
|
2008-10-24 12:47:05 +00:00
|
|
|
|
2012-01-25 06:24:59 +00:00
|
|
|
frames = (map.data[1] & 0xf0) >> 4;
|
2008-10-24 12:47:05 +00:00
|
|
|
index = 2 * frames + 2;
|
|
|
|
|
|
|
|
for (i = 0; i < frames; i++) {
|
2012-01-25 06:24:59 +00:00
|
|
|
guint len = (map.data[i * 2 + 2] << 8) | map.data[i * 2 + 3];
|
2008-10-24 12:47:05 +00:00
|
|
|
|
2011-10-05 11:18:45 +00:00
|
|
|
outbuf = gst_buffer_copy_region (buf, GST_BUFFER_COPY_ALL, index, len);
|
2012-09-13 11:49:33 +00:00
|
|
|
if (i == 0) {
|
|
|
|
GST_BUFFER_PTS (outbuf) = timestamp;
|
|
|
|
GST_BUFFER_DTS (outbuf) = timestamp;
|
|
|
|
}
|
2008-10-24 12:47:05 +00:00
|
|
|
|
|
|
|
index += len;
|
|
|
|
|
|
|
|
if (stream->discont) {
|
|
|
|
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DISCONT);
|
|
|
|
stream->discont = FALSE;
|
|
|
|
}
|
|
|
|
res = gst_pad_push (stream->pad, outbuf);
|
|
|
|
if (res != GST_FLOW_OK)
|
|
|
|
break;
|
|
|
|
}
|
2012-01-25 06:24:59 +00:00
|
|
|
gst_buffer_unmap (buf, &map);
|
2008-10-24 12:47:05 +00:00
|
|
|
gst_buffer_unref (buf);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2010-05-13 15:57:57 +00:00
|
|
|
static GstFlowReturn
|
|
|
|
gst_rmdemux_descramble_sipr_audio (GstRMDemux * rmdemux,
|
|
|
|
GstRMDemuxStream * stream)
|
|
|
|
{
|
|
|
|
GstFlowReturn ret;
|
|
|
|
GstBuffer *outbuf;
|
2012-01-25 06:24:59 +00:00
|
|
|
GstMapInfo outmap;
|
2010-05-13 15:57:57 +00:00
|
|
|
guint packet_size = stream->packet_size;
|
|
|
|
guint height = stream->subpackets->len;
|
|
|
|
guint p;
|
|
|
|
|
|
|
|
g_assert (stream->height == height);
|
|
|
|
|
|
|
|
GST_LOG ("packet_size = %u, leaf_size = %u, height= %u", packet_size,
|
2010-06-24 17:03:21 +00:00
|
|
|
stream->leaf_size, height);
|
2010-05-13 15:57:57 +00:00
|
|
|
|
2010-12-24 10:12:19 +00:00
|
|
|
outbuf = gst_buffer_new_and_alloc (height * packet_size);
|
2012-01-25 06:24:59 +00:00
|
|
|
gst_buffer_map (outbuf, &outmap, GST_MAP_WRITE);
|
2010-05-13 15:57:57 +00:00
|
|
|
|
|
|
|
for (p = 0; p < height; ++p) {
|
|
|
|
GstBuffer *b = g_ptr_array_index (stream->subpackets, p);
|
|
|
|
|
2012-09-13 11:49:33 +00:00
|
|
|
if (p == 0) {
|
|
|
|
GST_BUFFER_DTS (outbuf) = GST_BUFFER_DTS (b);
|
|
|
|
GST_BUFFER_PTS (outbuf) = GST_BUFFER_PTS (b);
|
|
|
|
}
|
2010-05-13 15:57:57 +00:00
|
|
|
|
2012-01-25 06:24:59 +00:00
|
|
|
gst_buffer_extract (b, 0, outmap.data + packet_size * p, packet_size);
|
2010-05-13 15:57:57 +00:00
|
|
|
}
|
2012-01-25 06:24:59 +00:00
|
|
|
gst_buffer_unmap (outbuf, &outmap);
|
2010-05-13 15:57:57 +00:00
|
|
|
|
2012-09-13 11:49:33 +00:00
|
|
|
GST_LOG_OBJECT (rmdemux, "pushing buffer dts %" GST_TIME_FORMAT ", pts %"
|
|
|
|
GST_TIME_FORMAT, GST_TIME_ARGS (GST_BUFFER_DTS (outbuf)),
|
|
|
|
GST_TIME_ARGS (GST_BUFFER_PTS (outbuf)));
|
2010-05-13 15:57:57 +00:00
|
|
|
|
|
|
|
if (stream->discont) {
|
|
|
|
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
|
|
|
|
stream->discont = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
outbuf = gst_rm_utils_descramble_sipr_buffer (outbuf);
|
|
|
|
|
|
|
|
ret = gst_pad_push (stream->pad, outbuf);
|
|
|
|
|
|
|
|
gst_rmdemux_stream_clear_cached_subpackets (rmdemux, stream);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
gst/realmedia/rmdemux.c: Descramble cook audio streams before sending them to the decoder. Fixes #347292.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_init), (gst_rmdemux_chain), (gst_rmdemux_add_stream),
(gst_rmdemux_parse_mdpr), (gst_rmdemux_parse_data),
(gst_rmdemux_stream_clear_cached_subpackets),
(gst_rmdemux_descramble_cook_audio),
(gst_rmdemux_descramble_dnet_audio),
(gst_rmdemux_handle_scrambled_packet), (gst_rmdemux_parse_packet):
Descramble cook audio streams before sending them to the
decoder. Fixes #347292.
Also miscellaneous clean-ups and log-level changes.
2006-07-27 20:34:25 +00:00
|
|
|
static GstFlowReturn
|
|
|
|
gst_rmdemux_handle_scrambled_packet (GstRMDemux * rmdemux,
|
|
|
|
GstRMDemuxStream * stream, GstBuffer * buf, gboolean keyframe)
|
|
|
|
{
|
|
|
|
GstFlowReturn ret;
|
|
|
|
|
|
|
|
if (stream->subpackets == NULL)
|
2006-07-28 13:28:19 +00:00
|
|
|
stream->subpackets = g_ptr_array_sized_new (stream->subpackets_needed);
|
gst/realmedia/rmdemux.c: Descramble cook audio streams before sending them to the decoder. Fixes #347292.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_init), (gst_rmdemux_chain), (gst_rmdemux_add_stream),
(gst_rmdemux_parse_mdpr), (gst_rmdemux_parse_data),
(gst_rmdemux_stream_clear_cached_subpackets),
(gst_rmdemux_descramble_cook_audio),
(gst_rmdemux_descramble_dnet_audio),
(gst_rmdemux_handle_scrambled_packet), (gst_rmdemux_parse_packet):
Descramble cook audio streams before sending them to the
decoder. Fixes #347292.
Also miscellaneous clean-ups and log-level changes.
2006-07-27 20:34:25 +00:00
|
|
|
|
2011-11-21 21:02:07 +00:00
|
|
|
GST_LOG ("Got subpacket %u/%u, len=%" G_GSIZE_FORMAT ", key=%d",
|
|
|
|
stream->subpackets->len + 1, stream->subpackets_needed,
|
|
|
|
gst_buffer_get_size (buf), keyframe);
|
gst/realmedia/rmdemux.c: Descramble cook audio streams before sending them to the decoder. Fixes #347292.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_init), (gst_rmdemux_chain), (gst_rmdemux_add_stream),
(gst_rmdemux_parse_mdpr), (gst_rmdemux_parse_data),
(gst_rmdemux_stream_clear_cached_subpackets),
(gst_rmdemux_descramble_cook_audio),
(gst_rmdemux_descramble_dnet_audio),
(gst_rmdemux_handle_scrambled_packet), (gst_rmdemux_parse_packet):
Descramble cook audio streams before sending them to the
decoder. Fixes #347292.
Also miscellaneous clean-ups and log-level changes.
2006-07-27 20:34:25 +00:00
|
|
|
|
|
|
|
if (keyframe && stream->subpackets->len > 0) {
|
|
|
|
gst_rmdemux_stream_clear_cached_subpackets (rmdemux, stream);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_ptr_array_add (stream->subpackets, buf);
|
|
|
|
|
|
|
|
if (stream->subpackets->len < stream->subpackets_needed)
|
|
|
|
return GST_FLOW_OK;
|
|
|
|
|
|
|
|
g_assert (stream->subpackets->len >= 1);
|
|
|
|
|
|
|
|
switch (stream->fourcc) {
|
|
|
|
case GST_RM_AUD_DNET:
|
|
|
|
ret = gst_rmdemux_descramble_dnet_audio (rmdemux, stream);
|
|
|
|
break;
|
|
|
|
case GST_RM_AUD_COOK:
|
2010-05-13 15:57:57 +00:00
|
|
|
case GST_RM_AUD_ATRC:
|
|
|
|
ret = gst_rmdemux_descramble_audio (rmdemux, stream);
|
gst/realmedia/rmdemux.c: Descramble cook audio streams before sending them to the decoder. Fixes #347292.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_init), (gst_rmdemux_chain), (gst_rmdemux_add_stream),
(gst_rmdemux_parse_mdpr), (gst_rmdemux_parse_data),
(gst_rmdemux_stream_clear_cached_subpackets),
(gst_rmdemux_descramble_cook_audio),
(gst_rmdemux_descramble_dnet_audio),
(gst_rmdemux_handle_scrambled_packet), (gst_rmdemux_parse_packet):
Descramble cook audio streams before sending them to the
decoder. Fixes #347292.
Also miscellaneous clean-ups and log-level changes.
2006-07-27 20:34:25 +00:00
|
|
|
break;
|
2008-10-24 12:47:05 +00:00
|
|
|
case GST_RM_AUD_RAAC:
|
|
|
|
case GST_RM_AUD_RACP:
|
|
|
|
ret = gst_rmdemux_descramble_mp4a_audio (rmdemux, stream);
|
|
|
|
break;
|
2010-05-13 15:57:57 +00:00
|
|
|
case GST_RM_AUD_SIPR:
|
|
|
|
ret = gst_rmdemux_descramble_sipr_audio (rmdemux, stream);
|
|
|
|
break;
|
gst/realmedia/rmdemux.c: Descramble cook audio streams before sending them to the decoder. Fixes #347292.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_init), (gst_rmdemux_chain), (gst_rmdemux_add_stream),
(gst_rmdemux_parse_mdpr), (gst_rmdemux_parse_data),
(gst_rmdemux_stream_clear_cached_subpackets),
(gst_rmdemux_descramble_cook_audio),
(gst_rmdemux_descramble_dnet_audio),
(gst_rmdemux_handle_scrambled_packet), (gst_rmdemux_parse_packet):
Descramble cook audio streams before sending them to the
decoder. Fixes #347292.
Also miscellaneous clean-ups and log-level changes.
2006-07-27 20:34:25 +00:00
|
|
|
default:
|
2012-08-08 14:23:27 +00:00
|
|
|
ret = GST_FLOW_ERROR;
|
gst/realmedia/rmdemux.c: Descramble cook audio streams before sending them to the decoder. Fixes #347292.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_init), (gst_rmdemux_chain), (gst_rmdemux_add_stream),
(gst_rmdemux_parse_mdpr), (gst_rmdemux_parse_data),
(gst_rmdemux_stream_clear_cached_subpackets),
(gst_rmdemux_descramble_cook_audio),
(gst_rmdemux_descramble_dnet_audio),
(gst_rmdemux_handle_scrambled_packet), (gst_rmdemux_parse_packet):
Descramble cook audio streams before sending them to the
decoder. Fixes #347292.
Also miscellaneous clean-ups and log-level changes.
2006-07-27 20:34:25 +00:00
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-08-07 10:57:09 +00:00
|
|
|
#define PARSE_NUMBER(data, size, number, label) \
|
|
|
|
G_STMT_START { \
|
|
|
|
if (size < 2) \
|
|
|
|
goto label; \
|
|
|
|
number = GST_READ_UINT16_BE (data); \
|
|
|
|
if (!(number & 0xc000)) { \
|
|
|
|
if (size < 4) \
|
|
|
|
goto label; \
|
|
|
|
number = GST_READ_UINT32_BE (data); \
|
|
|
|
data += 4; \
|
|
|
|
size -= 4; \
|
|
|
|
} else { \
|
|
|
|
number &= 0x3fff; \
|
|
|
|
data += 2; \
|
|
|
|
size -= 2; \
|
|
|
|
} \
|
|
|
|
} G_STMT_END
|
|
|
|
|
|
|
|
static GstFlowReturn
|
|
|
|
gst_rmdemux_parse_video_packet (GstRMDemux * rmdemux, GstRMDemuxStream * stream,
|
|
|
|
GstBuffer * in, guint offset, guint16 version,
|
|
|
|
GstClockTime timestamp, gboolean key)
|
|
|
|
{
|
|
|
|
GstFlowReturn ret;
|
2012-01-25 06:24:59 +00:00
|
|
|
GstMapInfo map;
|
2011-10-05 11:18:45 +00:00
|
|
|
const guint8 *data;
|
|
|
|
gsize size;
|
|
|
|
|
2012-01-25 06:24:59 +00:00
|
|
|
gst_buffer_map (in, &map, GST_MAP_READ);
|
2007-08-07 10:57:09 +00:00
|
|
|
|
2012-01-25 06:24:59 +00:00
|
|
|
data = map.data + offset;
|
|
|
|
size = map.size - offset;
|
2011-10-05 11:18:45 +00:00
|
|
|
|
2008-05-13 09:33:09 +00:00
|
|
|
/* if size <= 2, we want this method to return the same GstFlowReturn as it
|
|
|
|
* was previously for that given stream. */
|
2014-05-26 20:55:43 +00:00
|
|
|
ret = GST_PAD_LAST_FLOW_RETURN (stream->pad);
|
2007-08-07 10:57:09 +00:00
|
|
|
|
|
|
|
while (size > 2) {
|
|
|
|
guint8 pkg_header;
|
|
|
|
guint pkg_offset;
|
|
|
|
guint pkg_length;
|
2007-10-08 17:51:33 +00:00
|
|
|
guint pkg_subseq = 0, pkg_seqnum = G_MAXUINT;
|
2007-08-07 10:57:09 +00:00
|
|
|
guint fragment_size;
|
|
|
|
GstBuffer *fragment;
|
|
|
|
|
|
|
|
pkg_header = *data++;
|
|
|
|
size--;
|
|
|
|
|
|
|
|
/* packet header
|
|
|
|
* bit 7: 1=last block in block chain
|
|
|
|
* bit 6: 1=short header (only one block?)
|
|
|
|
*/
|
|
|
|
if ((pkg_header & 0xc0) == 0x40) {
|
|
|
|
/* skip unknown byte */
|
|
|
|
data++;
|
|
|
|
size--;
|
|
|
|
pkg_offset = 0;
|
|
|
|
pkg_length = size;
|
|
|
|
} else {
|
|
|
|
if ((pkg_header & 0x40) == 0) {
|
|
|
|
pkg_subseq = (*data++) & 0x7f;
|
|
|
|
size--;
|
|
|
|
} else {
|
|
|
|
pkg_subseq = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* length */
|
|
|
|
PARSE_NUMBER (data, size, pkg_length, not_enough_data);
|
|
|
|
|
|
|
|
/* offset */
|
|
|
|
PARSE_NUMBER (data, size, pkg_offset, not_enough_data);
|
|
|
|
|
|
|
|
/* seqnum */
|
|
|
|
if (size < 1)
|
|
|
|
goto not_enough_data;
|
|
|
|
|
|
|
|
pkg_seqnum = *data++;
|
|
|
|
size--;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (rmdemux,
|
2011-11-21 21:02:07 +00:00
|
|
|
"seq %d, subseq %d, offset %d, length %d, size %" G_GSIZE_FORMAT
|
|
|
|
", header %02x", pkg_seqnum, pkg_subseq, pkg_offset, pkg_length, size,
|
|
|
|
pkg_header);
|
2007-08-07 10:57:09 +00:00
|
|
|
|
|
|
|
/* calc size of fragment */
|
|
|
|
if ((pkg_header & 0xc0) == 0x80) {
|
|
|
|
fragment_size = pkg_offset;
|
|
|
|
} else {
|
|
|
|
if ((pkg_header & 0xc0) == 0)
|
|
|
|
fragment_size = size;
|
|
|
|
else
|
|
|
|
fragment_size = pkg_length;
|
|
|
|
}
|
|
|
|
GST_DEBUG_OBJECT (rmdemux, "fragment size %d", fragment_size);
|
|
|
|
|
|
|
|
/* get the fragment */
|
2011-10-05 11:18:45 +00:00
|
|
|
fragment =
|
2012-01-25 06:24:59 +00:00
|
|
|
gst_buffer_copy_region (in, GST_BUFFER_COPY_ALL, data - map.data,
|
2011-10-05 11:18:45 +00:00
|
|
|
fragment_size);
|
2007-08-07 10:57:09 +00:00
|
|
|
|
|
|
|
if (pkg_subseq == 1) {
|
|
|
|
GST_DEBUG_OBJECT (rmdemux, "start new fragment");
|
|
|
|
gst_adapter_clear (stream->adapter);
|
|
|
|
stream->frag_current = 0;
|
|
|
|
stream->frag_count = 0;
|
|
|
|
stream->frag_length = pkg_length;
|
|
|
|
} else if (pkg_subseq == 0) {
|
|
|
|
GST_DEBUG_OBJECT (rmdemux, "non fragmented packet");
|
|
|
|
stream->frag_current = 0;
|
|
|
|
stream->frag_count = 0;
|
|
|
|
stream->frag_length = fragment_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* put fragment in adapter */
|
|
|
|
gst_adapter_push (stream->adapter, fragment);
|
|
|
|
stream->frag_offset[stream->frag_count] = stream->frag_current;
|
|
|
|
stream->frag_current += fragment_size;
|
|
|
|
stream->frag_count++;
|
|
|
|
|
|
|
|
if (stream->frag_count > MAX_FRAGS)
|
|
|
|
goto too_many_fragments;
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (rmdemux, "stored fragment in adapter %d/%d",
|
|
|
|
stream->frag_current, stream->frag_length);
|
|
|
|
|
|
|
|
/* flush fragment when complete */
|
|
|
|
if (stream->frag_current >= stream->frag_length) {
|
|
|
|
GstBuffer *out;
|
2012-01-25 06:24:59 +00:00
|
|
|
GstMapInfo outmap;
|
|
|
|
guint8 *outdata;
|
2007-08-07 10:57:09 +00:00
|
|
|
guint header_size;
|
2008-05-06 17:53:26 +00:00
|
|
|
gint i, avail;
|
2007-08-07 10:57:09 +00:00
|
|
|
|
|
|
|
/* calculate header size, which is:
|
|
|
|
* 1 byte for the number of fragments - 1
|
|
|
|
* for each fragment:
|
|
|
|
* 4 bytes 0x00000001 little endian
|
|
|
|
* 4 bytes fragment offset
|
|
|
|
*
|
|
|
|
* This is also the matroska header for realvideo, the decoder needs the
|
|
|
|
* fragment offsets, both in ffmpeg and real .so, so we just give it that
|
|
|
|
* in front of the data.
|
|
|
|
*/
|
|
|
|
header_size = 1 + (8 * (stream->frag_count));
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (rmdemux,
|
|
|
|
"fragmented completed. count %d, header_size %u", stream->frag_count,
|
|
|
|
header_size);
|
|
|
|
|
2008-05-06 17:53:26 +00:00
|
|
|
avail = gst_adapter_available (stream->adapter);
|
|
|
|
|
|
|
|
out = gst_buffer_new_and_alloc (header_size + avail);
|
2012-01-25 06:24:59 +00:00
|
|
|
gst_buffer_map (out, &outmap, GST_MAP_WRITE);
|
|
|
|
outdata = outmap.data;
|
2007-08-07 10:57:09 +00:00
|
|
|
|
|
|
|
/* create header */
|
|
|
|
*outdata++ = stream->frag_count - 1;
|
|
|
|
for (i = 0; i < stream->frag_count; i++) {
|
|
|
|
GST_WRITE_UINT32_LE (outdata, 0x00000001);
|
|
|
|
outdata += 4;
|
|
|
|
GST_WRITE_UINT32_LE (outdata, stream->frag_offset[i]);
|
|
|
|
outdata += 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* copy packet data after the header now */
|
2008-05-06 17:53:26 +00:00
|
|
|
gst_adapter_copy (stream->adapter, outdata, 0, avail);
|
|
|
|
gst_adapter_flush (stream->adapter, avail);
|
|
|
|
|
|
|
|
stream->frag_current = 0;
|
|
|
|
stream->frag_count = 0;
|
|
|
|
stream->frag_length = 0;
|
2007-08-07 10:57:09 +00:00
|
|
|
|
2008-08-27 15:55:05 +00:00
|
|
|
if (timestamp != -1) {
|
|
|
|
if (rmdemux->first_ts != -1 && timestamp > rmdemux->first_ts)
|
|
|
|
timestamp -= rmdemux->first_ts;
|
|
|
|
else
|
|
|
|
timestamp = 0;
|
2008-05-06 17:53:26 +00:00
|
|
|
|
2008-08-27 15:55:05 +00:00
|
|
|
if (rmdemux->base_ts != -1)
|
|
|
|
timestamp += rmdemux->base_ts;
|
|
|
|
}
|
2012-01-25 06:24:59 +00:00
|
|
|
gst_buffer_unmap (out, &outmap);
|
2011-10-05 11:18:45 +00:00
|
|
|
|
2012-09-13 11:49:33 +00:00
|
|
|
/* video has DTS */
|
|
|
|
GST_BUFFER_DTS (out) = timestamp;
|
|
|
|
GST_BUFFER_PTS (out) = GST_CLOCK_TIME_NONE;
|
2008-05-06 17:53:26 +00:00
|
|
|
|
2008-08-27 09:47:17 +00:00
|
|
|
GST_LOG_OBJECT (rmdemux, "pushing timestamp %" GST_TIME_FORMAT,
|
|
|
|
GST_TIME_ARGS (timestamp));
|
|
|
|
|
|
|
|
if (stream->discont) {
|
|
|
|
GST_BUFFER_FLAG_SET (out, GST_BUFFER_FLAG_DISCONT);
|
|
|
|
stream->discont = FALSE;
|
|
|
|
}
|
|
|
|
|
2010-12-12 17:54:35 +00:00
|
|
|
if (!key) {
|
|
|
|
GST_BUFFER_FLAG_SET (out, GST_BUFFER_FLAG_DELTA_UNIT);
|
|
|
|
}
|
|
|
|
|
2007-08-07 10:57:09 +00:00
|
|
|
ret = gst_pad_push (stream->pad, out);
|
2014-05-26 20:55:43 +00:00
|
|
|
ret = gst_flow_combiner_update_flow (rmdemux->flowcombiner, ret);
|
2008-05-13 09:33:09 +00:00
|
|
|
if (ret != GST_FLOW_OK)
|
|
|
|
break;
|
2007-08-07 11:50:44 +00:00
|
|
|
|
|
|
|
timestamp = GST_CLOCK_TIME_NONE;
|
2007-08-07 10:57:09 +00:00
|
|
|
}
|
|
|
|
data += fragment_size;
|
|
|
|
size -= fragment_size;
|
|
|
|
}
|
2011-11-21 21:02:07 +00:00
|
|
|
GST_DEBUG_OBJECT (rmdemux, "%" G_GSIZE_FORMAT " bytes left", size);
|
2007-08-07 10:57:09 +00:00
|
|
|
|
2011-10-05 11:18:45 +00:00
|
|
|
done:
|
2012-01-25 06:24:59 +00:00
|
|
|
gst_buffer_unmap (in, &map);
|
2007-08-07 10:57:09 +00:00
|
|
|
gst_buffer_unref (in);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
not_enough_data:
|
|
|
|
{
|
|
|
|
GST_ELEMENT_WARNING (rmdemux, STREAM, DECODE, ("Skipping bad packet."),
|
|
|
|
(NULL));
|
2011-10-05 11:18:45 +00:00
|
|
|
ret = GST_FLOW_OK;
|
|
|
|
goto done;
|
2007-08-07 10:57:09 +00:00
|
|
|
}
|
|
|
|
too_many_fragments:
|
|
|
|
{
|
|
|
|
GST_ELEMENT_ERROR (rmdemux, STREAM, DECODE,
|
|
|
|
("Got more fragments (%u) than can be handled (%u)",
|
|
|
|
stream->frag_count, MAX_FRAGS), (NULL));
|
2011-10-05 11:18:45 +00:00
|
|
|
ret = GST_FLOW_ERROR;
|
|
|
|
goto done;
|
2007-08-07 10:57:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
|
|
|
gst_rmdemux_parse_audio_packet (GstRMDemux * rmdemux, GstRMDemuxStream * stream,
|
|
|
|
GstBuffer * in, guint offset, guint16 version,
|
|
|
|
GstClockTime timestamp, gboolean key)
|
|
|
|
{
|
2010-12-24 10:12:19 +00:00
|
|
|
GstFlowReturn ret;
|
2007-08-07 10:57:09 +00:00
|
|
|
GstBuffer *buffer;
|
|
|
|
|
2011-10-05 11:18:45 +00:00
|
|
|
buffer = gst_buffer_copy_region (in, GST_BUFFER_COPY_MEMORY, offset, -1);
|
2008-05-06 17:53:26 +00:00
|
|
|
|
2008-08-27 09:47:17 +00:00
|
|
|
if (rmdemux->first_ts != -1 && timestamp > rmdemux->first_ts)
|
2008-05-06 17:53:26 +00:00
|
|
|
timestamp -= rmdemux->first_ts;
|
|
|
|
else
|
|
|
|
timestamp = 0;
|
|
|
|
|
2008-08-27 09:47:17 +00:00
|
|
|
if (rmdemux->base_ts != -1)
|
|
|
|
timestamp += rmdemux->base_ts;
|
|
|
|
|
2012-09-13 11:49:33 +00:00
|
|
|
GST_BUFFER_PTS (buffer) = timestamp;
|
|
|
|
GST_BUFFER_DTS (buffer) = timestamp;
|
2007-08-07 10:57:09 +00:00
|
|
|
|
|
|
|
if (stream->needs_descrambling) {
|
2008-08-27 09:47:17 +00:00
|
|
|
GST_LOG_OBJECT (rmdemux, "descramble timestamp %" GST_TIME_FORMAT,
|
|
|
|
GST_TIME_ARGS (timestamp));
|
2007-08-07 10:57:09 +00:00
|
|
|
ret = gst_rmdemux_handle_scrambled_packet (rmdemux, stream, buffer, key);
|
|
|
|
} else {
|
2008-08-27 09:47:17 +00:00
|
|
|
GST_LOG_OBJECT (rmdemux,
|
2011-11-21 21:02:07 +00:00
|
|
|
"Pushing buffer of size %" G_GSIZE_FORMAT ", timestamp %"
|
|
|
|
GST_TIME_FORMAT "to pad %s", gst_buffer_get_size (buffer),
|
|
|
|
GST_TIME_ARGS (timestamp), GST_PAD_NAME (stream->pad));
|
2008-08-27 09:47:17 +00:00
|
|
|
|
|
|
|
if (stream->discont) {
|
|
|
|
GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DISCONT);
|
|
|
|
stream->discont = FALSE;
|
|
|
|
}
|
2007-08-07 10:57:09 +00:00
|
|
|
ret = gst_pad_push (stream->pad, buffer);
|
|
|
|
}
|
2009-06-19 15:25:58 +00:00
|
|
|
|
|
|
|
gst_buffer_unref (in);
|
|
|
|
|
2007-08-07 10:57:09 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-10-05 11:25:51 +00:00
|
|
|
static GstFlowReturn
|
2007-08-07 10:57:09 +00:00
|
|
|
gst_rmdemux_parse_packet (GstRMDemux * rmdemux, GstBuffer * in, guint16 version)
|
2003-06-22 03:59:01 +00:00
|
|
|
{
|
2005-06-27 09:16:09 +00:00
|
|
|
guint16 id;
|
|
|
|
GstRMDemuxStream *stream;
|
2011-10-05 11:18:45 +00:00
|
|
|
gsize size, offset;
|
gst/realmedia/rmdemux.*: Cleanups, use GstSegment for seeking.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_finalize), (gst_rmdemux_src_event),
(find_seek_offset_time), (gst_rmdemux_perform_seek),
(gst_rmdemux_src_query), (gst_rmdemux_change_state),
(gst_rmdemux_loop), (gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream), (gst_rmdemux_parse_mdpr),
(gst_rmdemux_combine_flows), (gst_rmdemux_parse_packet):
* gst/realmedia/rmdemux.h:
Cleanups, use GstSegment for seeking.
Fix error handling.
Combine flow return from all streams.
2006-07-13 11:28:32 +00:00
|
|
|
GstFlowReturn cret, ret;
|
|
|
|
GstClockTime timestamp;
|
2007-08-07 10:57:09 +00:00
|
|
|
gboolean key;
|
2012-01-25 06:24:59 +00:00
|
|
|
GstMapInfo map;
|
|
|
|
guint8 *data;
|
2007-08-07 10:57:09 +00:00
|
|
|
guint8 flags;
|
2008-05-06 17:53:26 +00:00
|
|
|
guint32 ts;
|
2005-06-27 09:16:09 +00:00
|
|
|
|
2012-01-25 06:24:59 +00:00
|
|
|
gst_buffer_map (in, &map, GST_MAP_READ);
|
|
|
|
data = map.data;
|
|
|
|
size = map.size;
|
2007-08-07 10:57:09 +00:00
|
|
|
|
|
|
|
/* stream number */
|
2005-06-27 09:16:09 +00:00
|
|
|
id = RMDEMUX_GUINT16_GET (data);
|
2007-08-07 10:57:09 +00:00
|
|
|
|
|
|
|
stream = gst_rmdemux_get_stream_by_id (rmdemux, id);
|
|
|
|
if (!stream || !stream->pad)
|
|
|
|
goto unknown_stream;
|
|
|
|
|
gst/realmedia/rmdemux.*: Cleanups, use GstSegment for seeking.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_finalize), (gst_rmdemux_src_event),
(find_seek_offset_time), (gst_rmdemux_perform_seek),
(gst_rmdemux_src_query), (gst_rmdemux_change_state),
(gst_rmdemux_loop), (gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream), (gst_rmdemux_parse_mdpr),
(gst_rmdemux_combine_flows), (gst_rmdemux_parse_packet):
* gst/realmedia/rmdemux.h:
Cleanups, use GstSegment for seeking.
Fix error handling.
Combine flow return from all streams.
2006-07-13 11:28:32 +00:00
|
|
|
/* timestamp in Msec */
|
2008-05-06 17:53:26 +00:00
|
|
|
ts = RMDEMUX_GUINT32_GET (data + 2);
|
|
|
|
timestamp = ts * GST_MSECOND;
|
gst/realmedia/rmdemux.*: Cleanups, use GstSegment for seeking.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_finalize), (gst_rmdemux_src_event),
(find_seek_offset_time), (gst_rmdemux_perform_seek),
(gst_rmdemux_src_query), (gst_rmdemux_change_state),
(gst_rmdemux_loop), (gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream), (gst_rmdemux_parse_mdpr),
(gst_rmdemux_combine_flows), (gst_rmdemux_parse_packet):
* gst/realmedia/rmdemux.h:
Cleanups, use GstSegment for seeking.
Fix error handling.
Combine flow return from all streams.
2006-07-13 11:28:32 +00:00
|
|
|
|
2011-10-05 11:18:45 +00:00
|
|
|
rmdemux->segment.position = timestamp;
|
2005-06-27 09:16:09 +00:00
|
|
|
|
gst/realmedia/rmdemux.c: Descramble cook audio streams before sending them to the decoder. Fixes #347292.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_init), (gst_rmdemux_chain), (gst_rmdemux_add_stream),
(gst_rmdemux_parse_mdpr), (gst_rmdemux_parse_data),
(gst_rmdemux_stream_clear_cached_subpackets),
(gst_rmdemux_descramble_cook_audio),
(gst_rmdemux_descramble_dnet_audio),
(gst_rmdemux_handle_scrambled_packet), (gst_rmdemux_parse_packet):
Descramble cook audio streams before sending them to the
decoder. Fixes #347292.
Also miscellaneous clean-ups and log-level changes.
2006-07-27 20:34:25 +00:00
|
|
|
GST_LOG_OBJECT (rmdemux, "Parsing a packet for stream=%d, timestamp=%"
|
2011-11-21 21:02:07 +00:00
|
|
|
GST_TIME_FORMAT ", size %" G_GSIZE_FORMAT ", version=%d, ts=%u", id,
|
2008-05-06 17:53:26 +00:00
|
|
|
GST_TIME_ARGS (timestamp), size, version, ts);
|
2007-08-07 10:57:09 +00:00
|
|
|
|
|
|
|
if (rmdemux->first_ts == GST_CLOCK_TIME_NONE) {
|
|
|
|
GST_DEBUG_OBJECT (rmdemux, "First timestamp: %" GST_TIME_FORMAT,
|
|
|
|
GST_TIME_ARGS (timestamp));
|
|
|
|
rmdemux->first_ts = timestamp;
|
|
|
|
}
|
gst/realmedia/rmdemux.c: Descramble cook audio streams before sending them to the decoder. Fixes #347292.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_init), (gst_rmdemux_chain), (gst_rmdemux_add_stream),
(gst_rmdemux_parse_mdpr), (gst_rmdemux_parse_data),
(gst_rmdemux_stream_clear_cached_subpackets),
(gst_rmdemux_descramble_cook_audio),
(gst_rmdemux_descramble_dnet_audio),
(gst_rmdemux_handle_scrambled_packet), (gst_rmdemux_parse_packet):
Descramble cook audio streams before sending them to the
decoder. Fixes #347292.
Also miscellaneous clean-ups and log-level changes.
2006-07-27 20:34:25 +00:00
|
|
|
|
|
|
|
/* skip stream_id and timestamp */
|
2007-08-07 10:57:09 +00:00
|
|
|
data += (2 + 4);
|
|
|
|
size -= (2 + 4);
|
2003-06-22 03:59:01 +00:00
|
|
|
|
2009-02-18 11:55:16 +00:00
|
|
|
/* get flags */
|
|
|
|
flags = GST_READ_UINT8 (data + 1);
|
|
|
|
|
|
|
|
data += 2;
|
|
|
|
size -= 2;
|
|
|
|
|
|
|
|
/* version 1 has an extra byte */
|
|
|
|
if (version == 1) {
|
|
|
|
data += 1;
|
|
|
|
size -= 1;
|
2007-05-16 19:07:45 +00:00
|
|
|
}
|
2012-01-25 06:24:59 +00:00
|
|
|
offset = data - map.data;
|
|
|
|
gst_buffer_unmap (in, &map);
|
2011-10-05 11:18:45 +00:00
|
|
|
|
2007-08-07 10:57:09 +00:00
|
|
|
key = (flags & 0x02) != 0;
|
|
|
|
GST_DEBUG_OBJECT (rmdemux, "flags %d, Keyframe %d", flags, key);
|
2007-05-16 19:07:45 +00:00
|
|
|
|
|
|
|
if (rmdemux->need_newsegment) {
|
|
|
|
GstEvent *event;
|
|
|
|
|
2011-10-05 11:18:45 +00:00
|
|
|
event = gst_event_new_segment (&rmdemux->segment);
|
2007-05-16 19:07:45 +00:00
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (rmdemux, "sending NEWSEGMENT event, segment.start= %"
|
|
|
|
GST_TIME_FORMAT, GST_TIME_ARGS (rmdemux->segment.start));
|
|
|
|
|
|
|
|
gst_rmdemux_send_event (rmdemux, event);
|
|
|
|
rmdemux->need_newsegment = FALSE;
|
2011-09-08 13:33:00 +00:00
|
|
|
|
|
|
|
if (rmdemux->pending_tags != NULL) {
|
2011-11-04 16:32:58 +00:00
|
|
|
gst_rmdemux_send_event (rmdemux,
|
2012-07-27 22:28:27 +00:00
|
|
|
gst_event_new_tag (rmdemux->pending_tags));
|
2011-09-08 13:33:00 +00:00
|
|
|
rmdemux->pending_tags = NULL;
|
|
|
|
}
|
2007-05-16 19:07:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (stream->pending_tags != NULL) {
|
|
|
|
GST_LOG_OBJECT (stream->pad, "tags %" GST_PTR_FORMAT, stream->pending_tags);
|
2012-07-27 22:28:27 +00:00
|
|
|
gst_pad_push_event (stream->pad, gst_event_new_tag (stream->pending_tags));
|
2007-05-16 19:07:45 +00:00
|
|
|
stream->pending_tags = NULL;
|
|
|
|
}
|
|
|
|
|
2007-08-07 10:57:09 +00:00
|
|
|
if ((rmdemux->offset + size) <= stream->seek_offset) {
|
gst/realmedia/rmdemux.*: Cleanups, use GstSegment for seeking.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_finalize), (gst_rmdemux_src_event),
(find_seek_offset_time), (gst_rmdemux_perform_seek),
(gst_rmdemux_src_query), (gst_rmdemux_change_state),
(gst_rmdemux_loop), (gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream), (gst_rmdemux_parse_mdpr),
(gst_rmdemux_combine_flows), (gst_rmdemux_parse_packet):
* gst/realmedia/rmdemux.h:
Cleanups, use GstSegment for seeking.
Fix error handling.
Combine flow return from all streams.
2006-07-13 11:28:32 +00:00
|
|
|
GST_DEBUG_OBJECT (rmdemux,
|
2011-11-21 21:02:07 +00:00
|
|
|
"Stream %d is skipping: seek_offset=%d, offset=%d, size=%"
|
|
|
|
G_GSIZE_FORMAT, stream->id, stream->seek_offset, rmdemux->offset, size);
|
gst/realmedia/rmdemux.*: Cleanups, use GstSegment for seeking.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_finalize), (gst_rmdemux_src_event),
(find_seek_offset_time), (gst_rmdemux_perform_seek),
(gst_rmdemux_src_query), (gst_rmdemux_change_state),
(gst_rmdemux_loop), (gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream), (gst_rmdemux_parse_mdpr),
(gst_rmdemux_combine_flows), (gst_rmdemux_parse_packet):
* gst/realmedia/rmdemux.h:
Cleanups, use GstSegment for seeking.
Fix error handling.
Combine flow return from all streams.
2006-07-13 11:28:32 +00:00
|
|
|
cret = GST_FLOW_OK;
|
2011-10-05 11:18:45 +00:00
|
|
|
gst_buffer_unref (in);
|
2005-11-21 10:32:55 +00:00
|
|
|
goto beach;
|
2005-09-29 13:44:15 +00:00
|
|
|
}
|
|
|
|
|
2007-08-07 10:57:09 +00:00
|
|
|
/* do special headers */
|
|
|
|
if (stream->subtype == GST_RMDEMUX_STREAM_VIDEO) {
|
|
|
|
ret =
|
2011-10-05 11:18:45 +00:00
|
|
|
gst_rmdemux_parse_video_packet (rmdemux, stream, in, offset,
|
2007-08-07 10:57:09 +00:00
|
|
|
version, timestamp, key);
|
|
|
|
} else if (stream->subtype == GST_RMDEMUX_STREAM_AUDIO) {
|
|
|
|
ret =
|
2011-10-05 11:18:45 +00:00
|
|
|
gst_rmdemux_parse_audio_packet (rmdemux, stream, in, offset,
|
2007-08-07 10:57:09 +00:00
|
|
|
version, timestamp, key);
|
2011-10-05 11:18:45 +00:00
|
|
|
} else {
|
|
|
|
gst_buffer_unref (in);
|
2007-08-07 10:57:09 +00:00
|
|
|
ret = GST_FLOW_OK;
|
2011-10-05 11:18:45 +00:00
|
|
|
}
|
gst/realmedia/rmdemux.*: Cleanups, use GstSegment for seeking.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_finalize), (gst_rmdemux_src_event),
(find_seek_offset_time), (gst_rmdemux_perform_seek),
(gst_rmdemux_src_query), (gst_rmdemux_change_state),
(gst_rmdemux_loop), (gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream), (gst_rmdemux_parse_mdpr),
(gst_rmdemux_combine_flows), (gst_rmdemux_parse_packet):
* gst/realmedia/rmdemux.h:
Cleanups, use GstSegment for seeking.
Fix error handling.
Combine flow return from all streams.
2006-07-13 11:28:32 +00:00
|
|
|
|
2015-03-28 15:58:26 +00:00
|
|
|
cret = gst_flow_combiner_update_pad_flow (rmdemux->flowcombiner, stream->pad,
|
|
|
|
ret);
|
2005-11-21 10:32:55 +00:00
|
|
|
|
|
|
|
beach:
|
gst/realmedia/rmdemux.*: Cleanups, use GstSegment for seeking.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_finalize), (gst_rmdemux_src_event),
(find_seek_offset_time), (gst_rmdemux_perform_seek),
(gst_rmdemux_src_query), (gst_rmdemux_change_state),
(gst_rmdemux_loop), (gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream), (gst_rmdemux_parse_mdpr),
(gst_rmdemux_combine_flows), (gst_rmdemux_parse_packet):
* gst/realmedia/rmdemux.h:
Cleanups, use GstSegment for seeking.
Fix error handling.
Combine flow return from all streams.
2006-07-13 11:28:32 +00:00
|
|
|
return cret;
|
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
unknown_stream:
|
|
|
|
{
|
|
|
|
GST_WARNING_OBJECT (rmdemux, "No stream for stream id %d in parsing "
|
|
|
|
"data packet", id);
|
2012-01-25 06:24:59 +00:00
|
|
|
gst_buffer_unmap (in, &map);
|
2011-10-05 11:18:45 +00:00
|
|
|
gst_buffer_unref (in);
|
gst/realmedia/rmdemux.*: Cleanups, use GstSegment for seeking.
Original commit message from CVS:
* gst/realmedia/rmdemux.c: (gst_rmdemux_class_init),
(gst_rmdemux_finalize), (gst_rmdemux_src_event),
(find_seek_offset_time), (gst_rmdemux_perform_seek),
(gst_rmdemux_src_query), (gst_rmdemux_change_state),
(gst_rmdemux_loop), (gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream), (gst_rmdemux_parse_mdpr),
(gst_rmdemux_combine_flows), (gst_rmdemux_parse_packet):
* gst/realmedia/rmdemux.h:
Cleanups, use GstSegment for seeking.
Fix error handling.
Combine flow return from all streams.
2006-07-13 11:28:32 +00:00
|
|
|
return GST_FLOW_OK;
|
|
|
|
}
|
2003-06-22 03:59:01 +00:00
|
|
|
}
|
2006-04-01 09:54:39 +00:00
|
|
|
|
2009-02-20 14:53:34 +00:00
|
|
|
gboolean
|
gst/realmedia/: Added RDT depayloader.
Original commit message from CVS:
* gst/realmedia/Makefile.am:
* gst/realmedia/rdtdepay.c: (gst_rdt_depay_base_init),
(gst_rdt_depay_class_init), (gst_rdt_depay_init),
(gst_rdt_depay_setcaps), (gst_rdt_depay_chain),
(gst_rdt_depay_set_property), (gst_rdt_depay_get_property),
(gst_rdt_depay_change_state), (gst_rdt_depay_plugin_init):
* gst/realmedia/rdtdepay.h:
Added RDT depayloader.
* gst/realmedia/rmdemux.c: (gst_rmdemux_parse_mdpr),
(gst_rmdemux_plugin_init), (plugin_init):
Remove unused function.
Added some more mime-types.
2006-10-03 10:55:42 +00:00
|
|
|
gst_rmdemux_plugin_init (GstPlugin * plugin)
|
2006-04-01 09:54:39 +00:00
|
|
|
{
|
|
|
|
return gst_element_register (plugin, "rmdemux",
|
2009-02-20 14:53:34 +00:00
|
|
|
GST_RANK_PRIMARY, GST_TYPE_RMDEMUX);
|
gst/realmedia/: Added RDT depayloader.
Original commit message from CVS:
* gst/realmedia/Makefile.am:
* gst/realmedia/rdtdepay.c: (gst_rdt_depay_base_init),
(gst_rdt_depay_class_init), (gst_rdt_depay_init),
(gst_rdt_depay_setcaps), (gst_rdt_depay_chain),
(gst_rdt_depay_set_property), (gst_rdt_depay_get_property),
(gst_rdt_depay_change_state), (gst_rdt_depay_plugin_init):
* gst/realmedia/rdtdepay.h:
Added RDT depayloader.
* gst/realmedia/rmdemux.c: (gst_rmdemux_parse_mdpr),
(gst_rmdemux_plugin_init), (plugin_init):
Remove unused function.
Added some more mime-types.
2006-10-03 10:55:42 +00:00
|
|
|
}
|