increase version up
[framework/multimedia/libmm-player.git] / src / include / mm_player_m3u8.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  * m3u8.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., 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22
23 /* This source code is taken from m3u8.c, which is licensed by GNU Library General Public License.
24  * AES-128 bit decryption features are changed from m3u8.c.
25  * - gst_m3u8_update and gst_m3u8_media_file_new are modified.
26  * - gst_m3u8_getIV_from_mediasequence is added.
27  * For convenience,
28  * - gst_m3u8_client_get_next_fragment is modified.
29  * - gst_m3u8_client_check_next_fragment is added.
30  * File name is changed to mm_player_m3u8.c
31  */
32
33
34 #ifndef __MM_PLAYER_M3U8_H__
35 #define __MM_PLAYER_M3U8_H__
36
37 #include <glib.h>
38
39 G_BEGIN_DECLS typedef struct _GstM3U8 GstM3U8;
40 typedef struct _GstM3U8MediaFile GstM3U8MediaFile;
41 typedef struct _GstM3U8Client GstM3U8Client;
42
43 #define GST_M3U8_MEDIA_FILE(f) ((GstM3U8MediaFile*)f)
44
45 struct _GstM3U8
46 {
47   gchar *uri;
48
49   gboolean endlist;             /* if ENDLIST has been reached */
50   gint version;                 /* last EXT-X-VERSION */
51   gint targetduration;          /* last EXT-X-TARGETDURATION */
52   gchar *allowcache;            /* last EXT-X-ALLOWCACHE */
53
54   gint bandwidth;
55   gint program_id;
56   gchar *codecs;
57   gint width;
58   gint height;
59   GList *files;
60
61   /*< private > */
62   gchar *last_data;
63   GList *lists;                 /* list of GstM3U8 from the main playlist */
64   GstM3U8 *parent;              /* main playlist (if any) */
65   guint mediasequence;          /* EXT-X-MEDIA-SEQUENCE & increased with new media file */
66 };
67
68 struct _GstM3U8MediaFile
69 {
70   gchar *title;
71   gint duration;
72   gchar *uri;
73   guint sequence;               /* the sequence nb of this file */
74
75   gchar *key_url;
76   unsigned char key[16];
77   unsigned char iv[16];
78   
79 };
80
81 struct _GstM3U8Client
82 {
83   GstM3U8 *main;                /* main playlist */
84   GstM3U8 *current;
85   guint update_failed_count;
86   gint sequence;                /* the next sequence for this client */
87 };
88
89
90 GstM3U8Client *gst_m3u8_client_new (const gchar * uri);
91 void gst_m3u8_client_free (GstM3U8Client * client);
92 gboolean gst_m3u8_client_update (GstM3U8Client * client, gchar * data);
93 void gst_m3u8_client_set_current (GstM3U8Client * client, GstM3U8 * m3u8);
94 const GstM3U8MediaFile *gst_m3u8_client_get_next_fragment (GstM3U8Client * client,  gboolean * discontinuity);
95 #define gst_m3u8_client_get_uri(Client) ((Client)->main->uri)
96 #define gst_m3u8_client_has_variant_playlist(Client) ((Client)->main->lists)
97 #define gst_m3u8_client_is_live(Client) (!(Client)->current->endlist)
98 #define gst_m3u8_client_allow_cache(Client) ((Client)->current->allowcache)
99
100 const gboolean gst_m3u8_client_check_next_fragment (GstM3U8Client * client);
101
102 G_END_DECLS
103 #endif /* __MM_PLAYER_M3U8_H__ */