hlsdemux: Set Referer in requests to the playlist URI
[platform/upstream/gstreamer.git] / ext / hls / gsthlsdemux.h
1 /* GStreamer
2  * Copyright (C) 2010 Marc-Andre Lureau <marcandre.lureau@gmail.com>
3  * Copyright (C) 2010 Andoni Morales Alastruey <ylatuya@gmail.com>
4  *
5  * gsthlsdemux.h:
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public
18  * License along with this library; if not, write to the
19  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21  */
22
23
24 #ifndef __GST_HLS_DEMUX_H__
25 #define __GST_HLS_DEMUX_H__
26
27 #include <gst/gst.h>
28 #include <gst/base/gstadapter.h>
29 #include "m3u8.h"
30 #include "gstfragmented.h"
31 #include <gst/uridownloader/gsturidownloader.h>
32
33 G_BEGIN_DECLS
34 #define GST_TYPE_HLS_DEMUX \
35   (gst_hls_demux_get_type())
36 #define GST_HLS_DEMUX(obj) \
37   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_HLS_DEMUX,GstHLSDemux))
38 #define GST_HLS_DEMUX_CLASS(klass) \
39   (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_HLS_DEMUX,GstHLSDemuxClass))
40 #define GST_IS_HLS_DEMUX(obj) \
41   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_HLS_DEMUX))
42 #define GST_IS_HLS_DEMUX_CLASS(klass) \
43   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_HLS_DEMUX))
44 #define GST_HLS_DEMUX_GET_CLASS(obj) \
45   (G_TYPE_INSTANCE_GET_CLASS ((obj),GST_TYPE_HLS_DEMUX,GstHLSDemuxClass))
46 typedef struct _GstHLSDemux GstHLSDemux;
47 typedef struct _GstHLSDemuxClass GstHLSDemuxClass;
48
49 /**
50  * GstHLSDemux:
51  *
52  * Opaque #GstHLSDemux data structure.
53  */
54 struct _GstHLSDemux
55 {
56   GstElement parent;
57
58   GstPad *sinkpad;
59   GstPad *srcpad;
60   gint srcpad_counter;
61
62   gboolean have_group_id;
63   guint group_id;
64
65   GstBuffer *playlist;
66   GstCaps *input_caps;
67   GstUriDownloader *downloader;
68   gchar *uri;                   /* Original playlist URI */
69   GstM3U8Client *client;        /* M3U8 client */
70   gboolean do_typefind;         /* Whether we need to typefind the next buffer */
71
72   /* Properties */
73   guint fragments_cache;        /* number of fragments needed to be cached to start playing */
74   gfloat bitrate_limit;         /* limit of the available bitrate to use */
75   guint connection_speed;       /* Network connection speed in kbps (0 = unknown) */
76
77   /* Streaming task */
78   GstTask *stream_task;
79   GRecMutex stream_lock;
80   gboolean stop_stream_task;
81   GMutex download_lock;         /* Used for protecting queue and the two conds */
82   GCond download_cond;          /* Signalled when something is added to the queue */
83   gboolean end_of_playlist;
84   gint download_failed_count;
85   gint64 next_download;
86
87   /* Updates task */
88   GstTask *updates_task;
89   GRecMutex updates_lock;
90   gint64 next_update;           /* Time of the next update */
91   gboolean stop_updates_task;
92   GMutex updates_timed_lock;
93   GCond updates_timed_cond;     /* Signalled when the playlist should be updated */
94
95   /* Position in the stream */
96   GstSegment segment;
97   gboolean need_segment;
98   gboolean discont;
99
100   /* Cache for the last key */
101   gchar *key_url;
102   GstFragment *key_fragment;
103
104   /* Current download rate (bps) */
105   gint current_download_rate;
106 };
107
108 struct _GstHLSDemuxClass
109 {
110   GstElementClass parent_class;
111 };
112
113 GType gst_hls_demux_get_type (void);
114
115 G_END_DECLS
116 #endif /* __GST_HLS_DEMUX_H__ */