| 1 |
/* |
| 2 |
* DASH demux plugin for GStreamer |
| 3 |
* |
| 4 |
* gstdashdemux.h |
| 5 |
* |
| 6 |
* Copyright (C) 2012 Orange |
| 7 |
* Authors: |
| 8 |
* David Corvoysier <[email protected]> |
| 9 |
* Hamid Zakari <[email protected]> |
| 10 |
* |
| 11 |
* Copyright (C) 2013 Smart TV Alliance |
| 12 |
* Author: Thiago Sousa Santos <[email protected]>, Collabora Ltd. |
| 13 |
* |
| 14 |
* Copyright (C) 2021 Centricular Ltd |
| 15 |
* Author: Edward Hervey <[email protected]> |
| 16 |
* Author: Jan Schmidt <[email protected]> |
| 17 |
* |
| 18 |
* This library is free software; you can redistribute it and/or |
| 19 |
* modify it under the terms of the GNU Library General Public |
| 20 |
* License as published by the Free Software Foundation; either |
| 21 |
* version 2.1 of the License, or (at your option) any later version. |
| 22 |
* |
| 23 |
* This library is distributed in the hope that it will be useful, |
| 24 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 25 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 26 |
* Library General Public License for more details. |
| 27 |
* |
| 28 |
* You should have received a copy of the GNU Library General Public |
| 29 |
* License along with this library (COPYING); if not, write to the |
| 30 |
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
| 31 |
* Boston, MA 02111-1307, USA. |
| 32 |
*/ |
| 33 |
|
| 34 |
#ifndef __GST_DASH_DEMUX_H__ |
| 35 |
#define __GST_DASH_DEMUX_H__ |
| 36 |
|
| 37 |
#include <gst/gst.h> |
| 38 |
#include <gst/base/gstadapter.h> |
| 39 |
#include <gst/base/gstdataqueue.h> |
| 40 |
|
| 41 |
#include "gstisoff.h" |
| 42 |
#include "gstadaptivedemux.h" |
| 43 |
|
| 44 |
#include "gstmpdclient.h" |
| 45 |
|
| 46 |
G_BEGIN_DECLS |
| 47 |
#define GST_TYPE_DASH_DEMUX2 \ |
| 48 |
(gst_dash_demux2_get_type()) |
| 49 |
#define GST_DASH_DEMUX(obj) \ |
| 50 |
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DASH_DEMUX2,GstDashDemux2)) |
| 51 |
#define GST_DASH_DEMUX_CLASS(klass) \ |
| 52 |
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_DASH_DEMUX2,GstDashDemux2Class)) |
| 53 |
#define GST_IS_DASH_DEMUX(obj) \ |
| 54 |
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DASH_DEMUX2)) |
| 55 |
#define GST_IS_DASH_DEMUX_CLASS(klass) \ |
| 56 |
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DASH_DEMUX2)) |
| 57 |
#define GST_DASH_DEMUX_CAST(obj) \ |
| 58 |
((GstDashDemux2 *)obj) |
| 59 |
|
| 60 |
#define GST_TYPE_DASH_DEMUX_STREAM \ |
| 61 |
(gst_dash_demux_stream_get_type()) |
| 62 |
#define GST_DASH_DEMUX_STREAM(obj) \ |
| 63 |
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DASH_DEMUX_STREAM,GstDashDemux2Stream)) |
| 64 |
#define GST_DASH_DEMUX_STREAM_CAST(obj) ((GstDashDemux2Stream *)obj) |
| 65 |
|
| 66 |
typedef struct _GstDashDemux2Stream GstDashDemux2Stream; |
| 67 |
typedef GstAdaptiveDemux2StreamClass GstDashDemux2StreamClass; |
| 68 |
|
| 69 |
typedef struct _GstDashDemux2ClockDrift GstDashDemux2ClockDrift; |
| 70 |
typedef struct _GstDashDemux2 GstDashDemux2; |
| 71 |
typedef struct _GstDashDemux2Class GstDashDemux2Class; |
| 72 |
|
| 73 |
struct _GstDashDemux2Stream |
| 74 |
{ |
| 75 |
GstAdaptiveDemux2Stream parent; |
| 76 |
|
| 77 |
gint index; |
| 78 |
GstActiveStream *active_stream; |
| 79 |
|
| 80 |
/* Track provided by this stream */ |
| 81 |
GstAdaptiveDemuxTrack *track; |
| 82 |
|
| 83 |
GstMediaFragmentInfo current_fragment; |
| 84 |
|
| 85 |
/* index parsing */ |
| 86 |
GstSidxParser sidx_parser; |
| 87 |
GstClockTime sidx_position; |
| 88 |
gint64 sidx_base_offset; |
| 89 |
gboolean allow_sidx; |
| 90 |
GstClockTime pending_seek_ts; |
| 91 |
|
| 92 |
GstAdapter *adapter; |
| 93 |
/* current offset of the first byte in the adapter / last byte we pushed or |
| 94 |
* dropped*/ |
| 95 |
guint64 current_offset; |
| 96 |
/* index = 1, header = 2, data = 3 */ |
| 97 |
guint current_index_header_or_data; |
| 98 |
|
| 99 |
/* ISOBMFF box parsing */ |
| 100 |
gboolean is_isobmff; |
| 101 |
struct { |
| 102 |
/* index = 1, header = 2, data = 3 */ |
| 103 |
guint32 current_fourcc; |
| 104 |
guint64 current_start_offset; |
| 105 |
guint64 current_size; |
| 106 |
} isobmff_parser; |
| 107 |
|
| 108 |
GstMoofBox *moof; |
| 109 |
guint64 moof_offset, moof_size; |
| 110 |
GArray *moof_sync_samples; |
| 111 |
guint current_sync_sample; |
| 112 |
|
| 113 |
guint64 moof_average_size; |
| 114 |
guint64 keyframe_average_size; |
| 115 |
guint64 keyframe_average_distance; |
| 116 |
gboolean first_sync_sample_after_moof, first_sync_sample_always_after_moof; |
| 117 |
|
| 118 |
/* Internal position value, at the keyframe/entry level */ |
| 119 |
GstClockTime actual_position; |
| 120 |
/* Timestamp of the beginning of the current fragment */ |
| 121 |
GstClockTime current_fragment_timestamp; |
| 122 |
GstClockTime current_fragment_duration; |
| 123 |
GstClockTime current_fragment_keyframe_distance; |
| 124 |
|
| 125 |
/* Average keyframe download time (only in trickmode-key-units) */ |
| 126 |
GstClockTime average_download_time; |
| 127 |
/* Cached target time (only in trickmode-key-units) */ |
| 128 |
GstClockTime target_time; |
| 129 |
/* Average skip-ahead time (only in trickmode-key-units) */ |
| 130 |
GstClockTime average_skip_size; |
| 131 |
|
| 132 |
gchar *last_representation_id; |
| 133 |
}; |
| 134 |
|
| 135 |
/** |
| 136 |
* GstDashDemux2: |
| 137 |
* |
| 138 |
* Opaque #GstDashDemux2 data structure. |
| 139 |
*/ |
| 140 |
struct _GstDashDemux2 |
| 141 |
{ |
| 142 |
GstAdaptiveDemux parent; |
| 143 |
|
| 144 |
GSList *next_periods; |
| 145 |
|
| 146 |
GstMPDClient2 *client; /* MPD client */ |
| 147 |
GMutex client_lock; |
| 148 |
|
| 149 |
GstDashDemux2ClockDrift *clock_drift; |
| 150 |
|
| 151 |
gboolean end_of_period; |
| 152 |
gboolean end_of_manifest; |
| 153 |
|
| 154 |
/* Properties */ |
| 155 |
gint max_video_width, max_video_height; |
| 156 |
gint max_video_framerate_n, max_video_framerate_d; |
| 157 |
gchar* default_presentation_delay; /* presentation time delay if MPD@suggestedPresentationDelay is not present */ |
| 158 |
guint start_bitrate; /* Initial bitrate to use before any bandwidth measurement */ |
| 159 |
|
| 160 |
gboolean allow_trickmode_key_units; |
| 161 |
}; |
| 162 |
|
| 163 |
struct _GstDashDemux2Class |
| 164 |
{ |
| 165 |
GstAdaptiveDemuxClass parent_class; |
| 166 |
}; |
| 167 |
|
| 168 |
GType gst_dash_demux2_get_type (void); |
| 169 |
GType gst_dash_demux_stream_get_type (void); |
| 170 |
|
| 171 |
G_END_DECLS |
| 172 |
#endif /* __GST_DASH_DEMUX_H__ */ |
| 173 |
|