2 * Copyright (C) 2014 Wim Taymans <wim.taymans@gmail.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
21 #ifndef __GST_DOWNLOAD_BUFFER_H__
22 #define __GST_DOWNLOAD_BUFFER_H__
27 #include "gstsparsefile.h"
31 #define GST_TYPE_DOWNLOAD_BUFFER \
32 (gst_download_buffer_get_type())
33 #define GST_DOWNLOAD_BUFFER(obj) \
34 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DOWNLOAD_BUFFER,GstDownloadBuffer))
35 #define GST_DOWNLOAD_BUFFER_CLASS(klass) \
36 (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_DOWNLOAD_BUFFER,GstDownloadBufferClass))
37 #define GST_IS_DOWNLOAD_BUFFER(obj) \
38 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DOWNLOAD_BUFFER))
39 #define GST_IS_DOWNLOAD_BUFFER_CLASS(klass) \
40 (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DOWNLOAD_BUFFER))
41 #define GST_DOWNLOAD_BUFFER_CAST(obj) \
42 ((GstDownloadBuffer *)(obj))
44 typedef struct _GstDownloadBuffer GstDownloadBuffer;
45 typedef struct _GstDownloadBufferClass GstDownloadBufferClass;
46 typedef struct _GstDownloadBufferSize GstDownloadBufferSize;
48 /* used to keep track of sizes (current and max) */
49 struct _GstDownloadBufferSize
55 struct _GstDownloadBuffer
63 /* upstream size in bytes (if downstream is operating in pull mode) */
64 guint64 upstream_size;
66 /* flowreturn when srcpad is paused */
67 GstFlowReturn srcresult;
68 GstFlowReturn sinkresult;
71 /* the queue of data we're keeping our hands on */
77 GstDownloadBufferSize cur_level;
78 GstDownloadBufferSize max_level;
79 gint low_percent; /* low/high watermarks for buffering */
82 /* current buffering state */
83 gboolean is_buffering;
84 gint buffering_percent;
86 /* for measuring input/output rates */
88 gboolean in_timer_started;
89 gdouble last_in_elapsed;
92 gdouble byte_in_period;
95 gboolean out_timer_started;
96 gdouble last_out_elapsed;
98 gdouble byte_out_rate;
100 GMutex qlock; /* lock for queue (vs object lock) */
101 gboolean waiting_add;
102 GCond item_add; /* signals buffers now available for reading */
103 guint64 waiting_offset;
105 /* temp location stuff */
106 gchar *temp_template;
107 gboolean temp_location_set;
108 gchar *temp_location;
109 gboolean temp_remove;
113 GstEvent *stream_start_event;
114 GstEvent *segment_event;
117 struct _GstDownloadBufferClass
119 GstElementClass parent_class;
122 G_GNUC_INTERNAL GType gst_download_buffer_get_type (void);
126 #endif /* __GST_DOWNLOAD_BUFFER_H__ */