2011-02-14 17:51:32 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 2010 Marc-Andre Lureau <marcandre.lureau@gmail.com>
|
|
|
|
* Copyright (C) 2010 Andoni Morales Alastruey <ylatuya@gmail.com>
|
|
|
|
*
|
|
|
|
* gsthlsdemux.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:38:00 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2011-02-14 17:51:32 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef __GST_HLS_DEMUX_H__
|
|
|
|
#define __GST_HLS_DEMUX_H__
|
|
|
|
|
|
|
|
#include <gst/gst.h>
|
|
|
|
#include "m3u8.h"
|
2012-03-15 18:42:44 +00:00
|
|
|
#include "gstfragmented.h"
|
2013-05-15 07:20:45 +00:00
|
|
|
#include <gst/uridownloader/gsturidownloader.h>
|
2014-08-27 19:26:19 +00:00
|
|
|
#include <gst/adaptivedemux/gstadaptivedemux.h>
|
2014-08-22 21:18:59 +00:00
|
|
|
#if defined(HAVE_OPENSSL)
|
|
|
|
#include <openssl/evp.h>
|
|
|
|
#elif defined(HAVE_NETTLE)
|
2014-04-08 20:31:32 +00:00
|
|
|
#include <nettle/aes.h>
|
|
|
|
#include <nettle/cbc.h>
|
|
|
|
#else
|
|
|
|
#include <gcrypt.h>
|
|
|
|
#endif
|
2011-02-14 17:51:32 +00:00
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
#define GST_TYPE_HLS_DEMUX \
|
|
|
|
(gst_hls_demux_get_type())
|
|
|
|
#define GST_HLS_DEMUX(obj) \
|
|
|
|
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_HLS_DEMUX,GstHLSDemux))
|
|
|
|
#define GST_HLS_DEMUX_CLASS(klass) \
|
|
|
|
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_HLS_DEMUX,GstHLSDemuxClass))
|
|
|
|
#define GST_IS_HLS_DEMUX(obj) \
|
|
|
|
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_HLS_DEMUX))
|
|
|
|
#define GST_IS_HLS_DEMUX_CLASS(klass) \
|
|
|
|
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_HLS_DEMUX))
|
2012-04-12 12:17:14 +00:00
|
|
|
#define GST_HLS_DEMUX_GET_CLASS(obj) \
|
|
|
|
(G_TYPE_INSTANCE_GET_CLASS ((obj),GST_TYPE_HLS_DEMUX,GstHLSDemuxClass))
|
2014-04-29 18:19:51 +00:00
|
|
|
#define GST_HLS_DEMUX_CAST(obj) \
|
|
|
|
((GstHLSDemux *)obj)
|
2011-02-14 17:51:32 +00:00
|
|
|
typedef struct _GstHLSDemux GstHLSDemux;
|
|
|
|
typedef struct _GstHLSDemuxClass GstHLSDemuxClass;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GstHLSDemux:
|
|
|
|
*
|
|
|
|
* Opaque #GstHLSDemux data structure.
|
|
|
|
*/
|
|
|
|
struct _GstHLSDemux
|
|
|
|
{
|
2014-08-27 19:26:19 +00:00
|
|
|
GstAdaptiveDemux parent;
|
2011-02-14 17:51:32 +00:00
|
|
|
|
2014-02-12 17:27:21 +00:00
|
|
|
gint srcpad_counter;
|
2012-03-15 18:42:44 +00:00
|
|
|
|
2011-02-15 20:49:20 +00:00
|
|
|
GstCaps *input_caps;
|
2012-03-15 18:42:44 +00:00
|
|
|
GstUriDownloader *downloader;
|
2014-04-28 07:32:54 +00:00
|
|
|
gchar *uri; /* Original playlist URI */
|
2011-02-14 17:51:32 +00:00
|
|
|
GstM3U8Client *client; /* M3U8 client */
|
2012-05-10 14:11:18 +00:00
|
|
|
gboolean do_typefind; /* Whether we need to typefind the next buffer */
|
2014-04-29 18:17:00 +00:00
|
|
|
gboolean new_playlist; /* Whether a new playlist is about to start and pads should be switched */
|
2011-02-14 17:51:32 +00:00
|
|
|
|
|
|
|
|
2012-03-15 22:21:58 +00:00
|
|
|
/* Streaming task */
|
2014-02-17 08:19:32 +00:00
|
|
|
gint64 next_download;
|
2011-02-14 17:51:32 +00:00
|
|
|
|
2014-02-12 09:59:38 +00:00
|
|
|
/* Cache for the last key */
|
|
|
|
gchar *key_url;
|
|
|
|
GstFragment *key_fragment;
|
2014-03-09 17:41:28 +00:00
|
|
|
|
2014-04-08 20:31:32 +00:00
|
|
|
/* decryption tooling */
|
2014-08-22 21:18:59 +00:00
|
|
|
#if defined(HAVE_OPENSSL)
|
|
|
|
EVP_CIPHER_CTX aes_ctx;
|
|
|
|
#elif defined(HAVE_NETTLE)
|
2014-04-08 20:31:32 +00:00
|
|
|
struct CBC_CTX (struct aes_ctx, AES_BLOCK_SIZE) aes_ctx;
|
|
|
|
#else
|
|
|
|
gcry_cipher_hd_t aes_ctx;
|
|
|
|
#endif
|
2014-10-02 16:37:57 +00:00
|
|
|
gchar *current_key;
|
|
|
|
guint8 *current_iv;
|
2014-04-08 20:31:32 +00:00
|
|
|
GstBuffer *pending_buffer; /* decryption scenario:
|
|
|
|
* the last buffer can only be pushed when
|
|
|
|
* resized, so need to store and wait for
|
|
|
|
* EOS to know it is the last */
|
2014-06-20 18:38:59 +00:00
|
|
|
|
|
|
|
gboolean reset_pts;
|
2011-02-14 17:51:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _GstHLSDemuxClass
|
|
|
|
{
|
2014-08-27 19:26:19 +00:00
|
|
|
GstAdaptiveDemuxClass parent_class;
|
2011-02-14 17:51:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
GType gst_hls_demux_get_type (void);
|
|
|
|
|
|
|
|
G_END_DECLS
|
|
|
|
#endif /* __GST_HLS_DEMUX_H__ */
|