2 * Copyright (C) 2010 Marc-Andre Lureau <marcandre.lureau@gmail.com>
3 * Copyright (C) 2010 Andoni Morales Alastruey <ylatuya@gmail.com>
4 * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
28 #include <openssl/evp.h>
31 G_BEGIN_DECLS typedef struct _GstM3U8 GstM3U8;
32 typedef struct _GstM3U8MediaFile GstM3U8MediaFile;
33 typedef struct _GstM3U8Key GstM3U8Key;
34 typedef struct _GstM3U8Client GstM3U8Client;
36 #define GST_M3U8(m) ((GstM3U8*)m)
37 #define GST_M3U8_KEY(k) ((GstM3U8Key*)k)
38 #define GST_M3U8_MEDIA_FILE(f) ((GstM3U8MediaFile*)f)
40 #define GST_M3U8_CLIENT_LOCK(c) g_mutex_lock (c->lock);
41 #define GST_M3U8_CLIENT_UNLOCK(c) g_mutex_unlock (c->lock);
43 #define GST_M3U8_IV_LEN 16
45 GST_DEBUG_CATEGORY_EXTERN (hlsdemux2_m3u8_debug);
48 GST_M3U8_ENCRYPTED_NONE,
49 GST_M3U8_ENCRYPTED_AES_128,
50 } GstM3U8EncryptionMethod;
56 gboolean endlist; /* if ENDLIST has been reached */
57 gint version; /* last EXT-X-VERSION */
58 GstClockTime targetduration; /* last EXT-X-TARGETDURATION */
59 gchar *allowcache; /* last EXT-X-ALLOWCACHE */
70 GList *lists; /* list of GstM3U8 from the main playlist */
71 GList *current_variant; /* Current variant playlist used */
72 GstM3U8 *parent; /* main playlist (if any) */
73 guint mediasequence; /* EXT-X-MEDIA-SEQUENCE & increased with new media file */
76 struct _GstM3U8MediaFile
79 GstClockTime duration;
81 guint sequence; /* the sequence nb of this file */
89 GstM3U8EncryptionMethod method;
98 GstM3U8 *main; /* main playlist */
100 guint update_failed_count;
101 gint sequence; /* the next sequence for this client */
103 EVP_CIPHER_CTX cipher_ctx;
107 GstM3U8Client *gst_m3u8_client_new (const gchar * uri);
108 void gst_m3u8_client_free (GstM3U8Client * client);
109 gboolean gst_m3u8_client_update (GstM3U8Client * client, gchar * data);
110 void gst_m3u8_client_set_current (GstM3U8Client * client, GstM3U8 * m3u8);
111 gboolean gst_m3u8_client_get_next_fragment (GstM3U8Client * client, GstClockTime cur_running_time,
112 gboolean * discontinuity, const gchar ** uri, GstClockTime * duration,
113 GstClockTime * timestamp, gchar **key_uri, gchar **iv);
114 void gst_m3u8_client_get_current_position (GstM3U8Client * client,
115 GstClockTime * timestamp);
116 GstClockTime gst_m3u8_client_get_duration (GstM3U8Client * client);
117 GstClockTime gst_m3u8_client_get_target_duration (GstM3U8Client * client);
118 const gchar *gst_m3u8_client_get_uri(GstM3U8Client * client);
119 const gchar *gst_m3u8_client_get_current_uri(GstM3U8Client * client);
120 gboolean gst_m3u8_client_has_variant_playlist(GstM3U8Client * client);
121 gboolean gst_m3u8_client_is_live(GstM3U8Client * client);
122 GList * gst_m3u8_client_get_playlist_for_bitrate (GstM3U8Client * client,
124 gboolean gst_m3u8_client_decrypt_init (GstM3U8Client * client, unsigned char *key, gchar *iv);
125 gboolean gst_m3u8_client_decrypt_update (GstM3U8Client * client,
126 guint8 * out_data, gint * out_size, guint8 * in_data, gint in_size);
127 gboolean gst_m3u8_client_is_playlist_download_needed (GstM3U8Client * self);
128 GstClockTime gst_m3u8_client_get_last_fragment_duration (GstM3U8Client * client);
129 gint gst_m3u8_client_get_current_bandwidth (GstM3U8Client * client);
130 gboolean gst_m3u8_client_decrypt_final (GstM3U8Client * client, guint8 * out_data, gint * out_size);
131 gboolean gst_m3u8_client_decrypt_deinit (GstM3U8Client * client);
132 void gst_m3u8_client_decrement_sequence (GstM3U8Client * client);
133 GList *gst_m3u8_client_get_next_higher_bw_playlist (GstM3U8Client * client);
134 GList *gst_m3u8_client_get_next_lower_bw_playlist (GstM3U8Client * client);
137 #endif /* __M3U8_H__ */