2009-10-29 10:21:36 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
* 2003 Colin Walters <cwalters@gnome.org>
|
|
|
|
* 2000,2005,2007 Wim Taymans <wim.taymans@gmail.com>
|
|
|
|
* 2007 Thiago Sousa Santos <thiagoss@lcc.ufcg.edu.br>
|
|
|
|
*
|
|
|
|
* gstqueue2.h:
|
|
|
|
*
|
|
|
|
* 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:44:48 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2009-10-29 10:21:36 +00:00
|
|
|
*/
|
|
|
|
#ifndef __GST_QUEUE2_H__
|
|
|
|
#define __GST_QUEUE2_H__
|
|
|
|
|
|
|
|
#include <gst/gst.h>
|
2009-11-03 15:30:14 +00:00
|
|
|
#include <stdio.h>
|
2009-10-29 10:21:36 +00:00
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
2009-10-29 10:30:11 +00:00
|
|
|
#define GST_TYPE_QUEUE2 \
|
|
|
|
(gst_queue2_get_type())
|
|
|
|
#define GST_QUEUE2(obj) \
|
|
|
|
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_QUEUE2,GstQueue2))
|
|
|
|
#define GST_QUEUE2_CLASS(klass) \
|
|
|
|
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_QUEUE2,GstQueue2Class))
|
|
|
|
#define GST_IS_QUEUE2(obj) \
|
|
|
|
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_QUEUE2))
|
|
|
|
#define GST_IS_QUEUE2_CLASS(klass) \
|
|
|
|
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_QUEUE2))
|
|
|
|
#define GST_QUEUE2_CAST(obj) \
|
|
|
|
((GstQueue2 *)(obj))
|
|
|
|
|
|
|
|
typedef struct _GstQueue2 GstQueue2;
|
|
|
|
typedef struct _GstQueue2Size GstQueue2Size;
|
|
|
|
typedef struct _GstQueue2Class GstQueue2Class;
|
2010-03-23 18:25:29 +00:00
|
|
|
typedef struct _GstQueue2Range GstQueue2Range;
|
2009-10-29 10:30:11 +00:00
|
|
|
|
|
|
|
/* used to keep track of sizes (current and max) */
|
|
|
|
struct _GstQueue2Size
|
|
|
|
{
|
|
|
|
guint buffers;
|
|
|
|
guint bytes;
|
|
|
|
guint64 time;
|
|
|
|
guint64 rate_time;
|
|
|
|
};
|
|
|
|
|
2010-03-23 18:25:29 +00:00
|
|
|
struct _GstQueue2Range
|
|
|
|
{
|
|
|
|
GstQueue2Range *next;
|
|
|
|
|
2010-05-07 07:30:44 +00:00
|
|
|
guint64 offset; /* offset of range start in source */
|
|
|
|
guint64 rb_offset; /* offset of range start in ring buffer */
|
|
|
|
guint64 writing_pos; /* writing position in source */
|
|
|
|
guint64 rb_writing_pos; /* writing position in ring buffer */
|
|
|
|
guint64 reading_pos; /* reading position in source */
|
|
|
|
guint64 max_reading_pos; /* latest requested offset in source */
|
2010-03-23 18:25:29 +00:00
|
|
|
};
|
|
|
|
|
2009-10-29 10:30:11 +00:00
|
|
|
struct _GstQueue2
|
2009-10-29 10:21:36 +00:00
|
|
|
{
|
|
|
|
GstElement element;
|
|
|
|
|
|
|
|
/*< private > */
|
|
|
|
GstPad *sinkpad;
|
|
|
|
GstPad *srcpad;
|
|
|
|
|
2010-10-31 19:47:25 +00:00
|
|
|
/* upstream size in bytes (if downstream is operating in pull mode) */
|
|
|
|
guint64 upstream_size;
|
|
|
|
|
2009-10-29 10:21:36 +00:00
|
|
|
/* segments to keep track of timestamps */
|
|
|
|
GstSegment sink_segment;
|
|
|
|
GstSegment src_segment;
|
|
|
|
|
2010-10-19 15:40:13 +00:00
|
|
|
/* Position of src/sink */
|
|
|
|
GstClockTime sinktime, srctime;
|
|
|
|
/* TRUE if either position needs to be recalculated */
|
|
|
|
gboolean sink_tainted, src_tainted;
|
2015-11-11 14:14:34 +00:00
|
|
|
/* Bitrates taken from tags */
|
|
|
|
guint sink_tags_bitrate;
|
|
|
|
guint src_tags_bitrate;
|
2010-10-19 15:40:13 +00:00
|
|
|
|
2009-10-29 10:21:36 +00:00
|
|
|
/* flowreturn when srcpad is paused */
|
|
|
|
GstFlowReturn srcresult;
|
2010-03-24 17:18:13 +00:00
|
|
|
GstFlowReturn sinkresult;
|
2009-10-29 10:21:36 +00:00
|
|
|
gboolean is_eos;
|
|
|
|
gboolean unexpected;
|
|
|
|
|
|
|
|
/* the queue of data we're keeping our hands on */
|
2011-11-03 08:47:20 +00:00
|
|
|
GQueue queue;
|
2009-10-29 10:21:36 +00:00
|
|
|
|
2013-05-24 17:22:22 +00:00
|
|
|
GCond query_handled;
|
|
|
|
gboolean last_query; /* result of last serialized query */
|
|
|
|
|
2009-10-29 10:30:11 +00:00
|
|
|
GstQueue2Size cur_level; /* currently in the queue */
|
|
|
|
GstQueue2Size max_level; /* max. amount of data allowed in the queue */
|
2009-10-29 10:21:36 +00:00
|
|
|
gboolean use_buffering;
|
2015-11-11 14:14:34 +00:00
|
|
|
gboolean use_tags_bitrate;
|
2009-10-29 10:21:36 +00:00
|
|
|
gboolean use_rate_estimate;
|
|
|
|
GstClockTime buffering_interval;
|
2016-08-03 13:20:20 +00:00
|
|
|
|
|
|
|
/* low/high watermarks for buffering */
|
|
|
|
gint low_watermark;
|
|
|
|
gint high_watermark;
|
2009-10-29 10:21:36 +00:00
|
|
|
|
|
|
|
/* current buffering state */
|
|
|
|
gboolean is_buffering;
|
2010-03-25 16:36:45 +00:00
|
|
|
gint buffering_percent;
|
2009-10-29 10:21:36 +00:00
|
|
|
|
|
|
|
/* for measuring input/output rates */
|
|
|
|
GTimer *in_timer;
|
|
|
|
gboolean in_timer_started;
|
2015-02-23 03:16:19 +00:00
|
|
|
gdouble last_update_in_rates_elapsed;
|
2009-10-29 10:21:36 +00:00
|
|
|
gdouble last_in_elapsed;
|
|
|
|
guint64 bytes_in;
|
|
|
|
gdouble byte_in_rate;
|
2011-04-19 18:05:07 +00:00
|
|
|
gdouble byte_in_period;
|
2009-10-29 10:21:36 +00:00
|
|
|
|
|
|
|
GTimer *out_timer;
|
|
|
|
gboolean out_timer_started;
|
|
|
|
gdouble last_out_elapsed;
|
|
|
|
guint64 bytes_out;
|
|
|
|
gdouble byte_out_rate;
|
|
|
|
|
2012-01-19 08:27:04 +00:00
|
|
|
GMutex qlock; /* lock for queue (vs object lock) */
|
2009-10-29 10:21:36 +00:00
|
|
|
gboolean waiting_add;
|
2012-01-19 08:27:04 +00:00
|
|
|
GCond item_add; /* signals buffers now available for reading */
|
2009-10-29 10:21:36 +00:00
|
|
|
gboolean waiting_del;
|
2012-01-19 08:27:04 +00:00
|
|
|
GCond item_del; /* signals space now available for writing */
|
2009-10-29 10:21:36 +00:00
|
|
|
|
|
|
|
/* temp location stuff */
|
|
|
|
gchar *temp_template;
|
|
|
|
gboolean temp_location_set;
|
|
|
|
gchar *temp_location;
|
2010-01-22 16:55:39 +00:00
|
|
|
gboolean temp_remove;
|
2009-10-29 10:21:36 +00:00
|
|
|
FILE *temp_file;
|
2010-03-23 18:25:29 +00:00
|
|
|
/* list of downloaded areas and the current area */
|
|
|
|
GstQueue2Range *ranges;
|
|
|
|
GstQueue2Range *current;
|
2009-10-29 10:21:36 +00:00
|
|
|
/* we need this to send the first new segment event of the stream
|
|
|
|
* because we can't save it on the file */
|
|
|
|
gboolean segment_event_received;
|
|
|
|
GstEvent *starting_segment;
|
2012-04-10 09:20:09 +00:00
|
|
|
gboolean seeking;
|
2010-05-05 08:21:55 +00:00
|
|
|
|
2012-01-27 11:33:32 +00:00
|
|
|
GstEvent *stream_start_event;
|
|
|
|
|
2010-05-07 07:30:44 +00:00
|
|
|
guint64 ring_buffer_max_size;
|
2010-06-18 15:43:40 +00:00
|
|
|
guint8 * ring_buffer;
|
2014-04-16 14:17:04 +00:00
|
|
|
|
|
|
|
volatile gint downstream_may_block;
|
2014-09-19 15:02:46 +00:00
|
|
|
|
|
|
|
GstBufferingMode mode;
|
|
|
|
gint64 buffering_left;
|
|
|
|
gint avg_in;
|
|
|
|
gint avg_out;
|
|
|
|
gboolean percent_changed;
|
|
|
|
GMutex buffering_post_lock; /* assures only one posted at a time */
|
2009-10-29 10:21:36 +00:00
|
|
|
};
|
|
|
|
|
2009-10-29 10:30:11 +00:00
|
|
|
struct _GstQueue2Class
|
2009-10-29 10:21:36 +00:00
|
|
|
{
|
|
|
|
GstElementClass parent_class;
|
|
|
|
};
|
|
|
|
|
2012-07-14 19:00:30 +00:00
|
|
|
G_GNUC_INTERNAL GType gst_queue2_get_type (void);
|
2009-10-29 10:30:11 +00:00
|
|
|
|
2009-10-29 10:21:36 +00:00
|
|
|
G_END_DECLS
|
|
|
|
|
|
|
|
#endif /* __GST_QUEUE2_H__ */
|