| 1 |
/* GStreamer |
| 2 |
* |
| 3 |
* Copyright (C) 2019 Collabora Ltd. |
| 4 |
* Author: Stéphane Cerveau <[email protected]> |
| 5 |
* |
| 6 |
* This library is free software; you can redistribute it and/or |
| 7 |
* modify it under the terms of the GNU Library General Public |
| 8 |
* License as published by the Free Software Foundation; either |
| 9 |
* version 2.1 of the License, or (at your option) any later version. |
| 10 |
* |
| 11 |
* This library is distributed in the hope that it will be useful, |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 |
* Library General Public License for more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU Library General Public |
| 17 |
* License along with this library (COPYING); if not, write to the |
| 18 |
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
| 19 |
* Boston, MA 02111-1307, USA. |
| 20 |
*/ |
| 21 |
#ifndef __GST_MPDCLIENT_H__ |
| 22 |
#define __GST_MPDCLIENT_H__ |
| 23 |
|
| 24 |
#include "gstmpdparser.h" |
| 25 |
#include "downloadhelper.h" |
| 26 |
|
| 27 |
G_BEGIN_DECLS |
| 28 |
|
| 29 |
#define GST_TYPE_MPD_CLIENT gst_mpd_client2_get_type () |
| 30 |
G_DECLARE_FINAL_TYPE (GstMPDClient2, gst_mpd_client2, GST, MPD_CLIENT, GstObject) |
| 31 |
|
| 32 |
struct _GstMPDClient2 |
| 33 |
{ |
| 34 |
GstObject parent_instance; |
| 35 |
GstMPDRootNode *mpd_root_node; /* mpd root node */ |
| 36 |
|
| 37 |
GList *periods; /* list of GstStreamPeriod */ |
| 38 |
guint period_idx; /* index of current Period */ |
| 39 |
|
| 40 |
GList *active_streams; /* list of GstActiveStream */ |
| 41 |
|
| 42 |
guint update_failed_count; |
| 43 |
gchar *mpd_uri; /* manifest file URI */ |
| 44 |
gchar *mpd_base_uri; /* base URI for resolving relative URIs. |
| 45 |
* this will be different for redirects */ |
| 46 |
|
| 47 |
/* profiles */ |
| 48 |
gboolean profile_isoff_ondemand; |
| 49 |
|
| 50 |
DownloadHelper *download_helper; |
| 51 |
}; |
| 52 |
|
| 53 |
/* Basic initialization/deinitialization functions */ |
| 54 |
|
| 55 |
GstMPDClient2 *gst_mpd_client2_new (void); |
| 56 |
GstMPDClient2 *gst_mpd_client2_new_static (void); |
| 57 |
|
| 58 |
void gst_mpd_client2_active_streams_free (GstMPDClient2 * client); |
| 59 |
void gst_mpd_client2_free (GstMPDClient2 * client); |
| 60 |
|
| 61 |
/* main mpd parsing methods from xml data */ |
| 62 |
gboolean gst_mpd_client2_parse (GstMPDClient2 * client, const gchar * data, gint size); |
| 63 |
|
| 64 |
/* xml generator */ |
| 65 |
gboolean gst_mpd_client2_get_xml_content (GstMPDClient2 * client, gchar ** data, gint * size); |
| 66 |
|
| 67 |
void gst_mpd_client2_set_download_helper (GstMPDClient2 * client, DownloadHelper *dh); |
| 68 |
void gst_mpd_client2_check_profiles (GstMPDClient2 * client); |
| 69 |
void gst_mpd_client2_fetch_on_load_external_resources (GstMPDClient2 * client); |
| 70 |
|
| 71 |
/* Streaming management */ |
| 72 |
gboolean gst_mpd_client2_setup_media_presentation (GstMPDClient2 *client, GstClockTime time, gint period_index, const gchar *period_id); |
| 73 |
gboolean gst_mpd_client2_setup_streaming (GstMPDClient2 * client, GstMPDAdaptationSetNode * adapt_set, gint64 max_bandwidth, gint max_video_width, gint max_video_height, gint max_video_framerate_n, gint max_video_framerate_d); |
| 74 |
gboolean gst_mpd_client2_setup_representation (GstMPDClient2 *client, GstActiveStream *stream, GstMPDRepresentationNode *representation); |
| 75 |
|
| 76 |
GstClockTime gst_mpd_client2_get_next_fragment_duration (GstMPDClient2 * client, GstActiveStream * stream); |
| 77 |
GstClockTime gst_mpd_client2_get_media_presentation_duration (GstMPDClient2 *client); |
| 78 |
GstClockTime gst_mpd_client2_get_maximum_segment_duration (GstMPDClient2 * client); |
| 79 |
gboolean gst_mpd_client2_get_last_fragment_timestamp_end (GstMPDClient2 * client, guint stream_idx, GstClockTime * ts); |
| 80 |
gboolean gst_mpd_client2_get_next_fragment_timestamp (GstMPDClient2 * client, guint stream_idx, GstClockTime * ts); |
| 81 |
gboolean gst_mpd_client2_get_next_fragment (GstMPDClient2 *client, guint indexStream, GstMediaFragmentInfo * fragment); |
| 82 |
gboolean gst_mpd_client2_get_next_header (GstMPDClient2 *client, gchar **uri, guint stream_idx, gint64 * range_start, gint64 * range_end); |
| 83 |
gboolean gst_mpd_client2_get_next_header_index (GstMPDClient2 *client, gchar **uri, guint stream_idx, gint64 * range_start, gint64 * range_end); |
| 84 |
gboolean gst_mpd_client2_is_live (GstMPDClient2 * client); |
| 85 |
gboolean gst_mpd_client2_stream_seek (GstMPDClient2 * client, GstActiveStream * stream, gboolean forward, GstSeekFlags flags, GstClockTime ts, GstClockTime * final_ts); |
| 86 |
gboolean gst_mpd_client2_seek_to_time (GstMPDClient2 * client, GDateTime * time); |
| 87 |
GstClockTime gst_mpd_client2_get_stream_presentation_offset (GstMPDClient2 *client, guint stream_idx); |
| 88 |
gchar** gst_mpd_client2_get_utc_timing_sources (GstMPDClient2 *client, guint methods, GstMPDUTCTimingType *selected_method); |
| 89 |
GstClockTime gst_mpd_client2_get_period_start_time (GstMPDClient2 *client); |
| 90 |
|
| 91 |
GstCaps *gst_mpd_client2_get_codec_caps (GstActiveStream *stream); |
| 92 |
|
| 93 |
/* Period selection */ |
| 94 |
guint gst_mpd_client2_get_period_index_at_time (GstMPDClient2 * client, GstDateTime * time); |
| 95 |
gboolean gst_mpd_client2_set_period_index (GstMPDClient2 *client, guint period_idx); |
| 96 |
gboolean gst_mpd_client2_set_period_id (GstMPDClient2 *client, const gchar * period_id); |
| 97 |
guint gst_mpd_client2_get_period_index (GstMPDClient2 *client); |
| 98 |
const gchar *gst_mpd_client2_get_period_id (GstMPDClient2 *client); |
| 99 |
gboolean gst_mpd_client2_has_next_period (GstMPDClient2 *client); |
| 100 |
gboolean gst_mpd_client2_has_previous_period (GstMPDClient2 * client); |
| 101 |
|
| 102 |
/* Representation selection */ |
| 103 |
gint gst_mpd_client2_get_rep_idx_with_max_bandwidth (GList *Representations, gint64 max_bandwidth, gint max_video_width, gint max_video_height, gint max_video_framerate_n, gint max_video_framerate_d); |
| 104 |
gint gst_mpd_client2_get_rep_idx_with_min_bandwidth (GList * Representations); |
| 105 |
GstMPDRepresentationNode* gst_mpd_client2_get_representation_with_id (GList * representations, gchar * rep_id); |
| 106 |
|
| 107 |
GstDateTime * |
| 108 |
gst_mpd_client2_get_availability_start_time (GstMPDClient2 * client); |
| 109 |
|
| 110 |
/* URL management */ |
| 111 |
const gchar *gst_mpd_client2_get_baseURL (GstMPDClient2 *client, guint indexStream); |
| 112 |
gchar *gst_mpd_client2_parse_baseURL (GstMPDClient2 * client, GstActiveStream * stream, gchar ** query); |
| 113 |
|
| 114 |
/* Active stream */ |
| 115 |
guint gst_mpd_client2_get_nb_active_stream (GstMPDClient2 *client); |
| 116 |
GstActiveStream *gst_mpd_client2_get_active_stream_by_index (GstMPDClient2 *client, guint stream_idx); |
| 117 |
gboolean gst_mpd_client2_active_stream_contains_subtitles (GstActiveStream * stream); |
| 118 |
|
| 119 |
/* AdaptationSet */ |
| 120 |
guint gst_mpd_client2_get_nb_adaptationSet (GstMPDClient2 *client); |
| 121 |
GList * gst_mpd_client2_get_adaptation_sets (GstMPDClient2 * client); |
| 122 |
|
| 123 |
/* Segment */ |
| 124 |
gboolean gst_mpd_client2_has_next_segment (GstMPDClient2 * client, GstActiveStream * stream, gboolean forward); |
| 125 |
GstFlowReturn gst_mpd_client2_advance_segment (GstMPDClient2 * client, GstActiveStream * stream, gboolean forward); |
| 126 |
void gst_mpd_client2_seek_to_first_segment (GstMPDClient2 * client); |
| 127 |
GstDateTime *gst_mpd_client2_get_next_segment_availability_start_time (GstMPDClient2 * client, GstActiveStream * stream); |
| 128 |
|
| 129 |
/* Get audio/video stream parameters (caps, width, height, rate, number of channels) */ |
| 130 |
GstCaps * gst_mpd_client2_get_stream_caps (GstActiveStream * stream); |
| 131 |
gboolean gst_mpd_client2_get_bitstream_switching_flag (GstActiveStream * stream); |
| 132 |
guint gst_mpd_client2_get_video_stream_width (GstActiveStream * stream); |
| 133 |
guint gst_mpd_client2_get_video_stream_height (GstActiveStream * stream); |
| 134 |
gboolean gst_mpd_client2_get_video_stream_framerate (GstActiveStream * stream, gint * fps_num, gint * fps_den); |
| 135 |
guint gst_mpd_client2_get_audio_stream_rate (GstActiveStream * stream); |
| 136 |
guint gst_mpd_client2_get_audio_stream_num_channels (GstActiveStream * stream); |
| 137 |
|
| 138 |
/* Support multi language */ |
| 139 |
guint gst_mpd_client2_get_list_and_nb_of_audio_language (GstMPDClient2 *client, GList **lang); |
| 140 |
|
| 141 |
GstClockTimeDiff gst_mpd_client2_calculate_time_difference (const GstDateTime * t1, const GstDateTime * t2); |
| 142 |
GstDateTime *gst_mpd_client2_add_time_difference (GstDateTime * t1, GstClockTimeDiff diff); |
| 143 |
gint64 gst_mpd_client2_parse_default_presentation_delay(GstMPDClient2 * client, const gchar * default_presentation_delay); |
| 144 |
|
| 145 |
/* profiles */ |
| 146 |
gboolean gst_mpd_client2_has_isoff_ondemand_profile (GstMPDClient2 *client); |
| 147 |
|
| 148 |
/* add/set node methods */ |
| 149 |
gboolean gst_mpd_client2_set_root_node (GstMPDClient2 * client, |
| 150 |
const gchar * property_name, |
| 151 |
...); |
| 152 |
gchar * gst_mpd_client2_set_period_node (GstMPDClient2 * client, |
| 153 |
gchar * period_id, |
| 154 |
const gchar * property_name, |
| 155 |
...); |
| 156 |
guint gst_mpd_client2_set_adaptation_set_node (GstMPDClient2 * client, |
| 157 |
gchar * period_id, |
| 158 |
guint adap_set_id, |
| 159 |
const gchar * property_name, |
| 160 |
...); |
| 161 |
gchar * gst_mpd_client2_set_representation_node (GstMPDClient2 * client, |
| 162 |
gchar * period_id, |
| 163 |
guint adap_set_id, |
| 164 |
gchar * rep_id, |
| 165 |
const gchar * property_name, |
| 166 |
...); |
| 167 |
gboolean gst_mpd_client2_set_segment_list (GstMPDClient2 * client, |
| 168 |
gchar * period_id, |
| 169 |
guint adap_set_id, |
| 170 |
gchar * rep_id, |
| 171 |
const gchar * property_name, |
| 172 |
...); |
| 173 |
gboolean gst_mpd_client2_set_segment_template (GstMPDClient2 * client, |
| 174 |
gchar * period_id, |
| 175 |
guint adap_set_id, |
| 176 |
gchar * rep_id, |
| 177 |
const gchar * property_name, |
| 178 |
...); |
| 179 |
|
| 180 |
/* create a new node */ |
| 181 |
gboolean gst_mpd_client2_add_baseurl_node (GstMPDClient2 * client, |
| 182 |
const gchar * property_name, |
| 183 |
...); |
| 184 |
gboolean gst_mpd_client2_add_segment_url (GstMPDClient2 * client, |
| 185 |
gchar * period_id, |
| 186 |
guint adap_set_id, |
| 187 |
gchar * rep_id, |
| 188 |
const gchar * property_name, |
| 189 |
...); |
| 190 |
G_END_DECLS |
| 191 |
|
| 192 |
#endif /* __GST_MPDCLIENT_H__ */ |