GPAC
Open Source Multimedia Framework. For more information, check out http://gpac.wp.mines-telecom.fr
|
#include <gpac/thread.h>
#include <gpac/network.h>
#include <gpac/dash.h>
#include <gpac/internal/mpd.h>
#include <gpac/internal/m3u8.h>
#include <gpac/internal/isomedia_dev.h>
#include <string.h>
#include <time.h>
Data Structures | |
struct | GF_DashClient |
struct | segment_cache_entry |
struct | GF_DASH_Group |
Macros | |
#define | M3U8_TO_MPD_USE_TEMPLATE 0 |
#define | GET_REP_ATTR(_a) _a = rep->_a; if (!_a) _a = set->_a; |
Functions | |
static void | gf_dash_seek_group (GF_DashClient *dash, GF_DASH_Group *group) |
static const char * | gf_dash_get_mime_type (GF_MPD_SubRepresentation *subrep, GF_MPD_Representation *rep, GF_MPD_AdaptationSet *set) |
static void | gf_dash_buffer_off (GF_DASH_Group *group, GF_DashClient *dash) |
static void | gf_dash_buffer_on (GF_DASH_Group *group, GF_DashClient *dash) |
static u64 | dash_get_fetch_time (GF_DashClient *dash) |
static u32 | gf_dash_group_count_rep_needed (GF_DASH_Group *group) |
void | gf_dash_get_buffer_info_buffering (GF_DashClient *dash, u32 *total_buffer, u32 *media_buffered) |
static void | gf_dash_update_buffering (GF_DASH_Group *group, GF_DashClient *dash) |
Bool | gf_dash_check_mpd_root_type (const char *local_url) |
static void | gf_dash_group_timeline_setup (GF_MPD *mpd, GF_DASH_Group *group, u64 fetch_time) |
static Bool | gf_dash_is_dash_mime (const char *mime) |
static Bool | gf_dash_is_m3u8_mime (const char *url, const char *mime) |
GF_Err | gf_dash_group_check_bandwidth (GF_DashClient *dash, u32 idx) |
GF_Err | gf_dash_download_resource (GF_DASHFileIO *dash_io, GF_DASHFileIOSession *sess, const char *url, u64 start_range, u64 end_range, u32 persistent_mode, GF_DASH_Group *group) |
static void | gf_dash_get_timeline_duration (GF_MPD_SegmentTimeline *timeline, u32 *nb_segments, Double *max_seg_duration) |
static void | gf_dash_get_segment_duration (GF_MPD_Representation *rep, GF_MPD_AdaptationSet *set, GF_MPD_Period *period, GF_MPD *mpd, u32 *nb_segments, Double *max_seg_duration) |
static u64 | gf_dash_segment_timeline_start (GF_MPD_SegmentTimeline *timeline, u32 segment_index, u64 *segment_duration) |
static Double | gf_dash_get_segment_start_time (GF_DASH_Group *group, Double *segment_duration) |
u64 | gf_dash_get_segment_availability_start_time (GF_MPD *mpd, GF_DASH_Group *group, u32 segment_index, u32 *seg_dur_ms) |
static void | gf_dash_resolve_duration (GF_MPD_Representation *rep, GF_MPD_AdaptationSet *set, GF_MPD_Period *period, u64 *out_duration, u32 *out_timescale, u64 *out_pts_offset, GF_MPD_SegmentTimeline **out_segment_timeline) |
static GF_Err | gf_dash_merge_segment_timeline (GF_MPD_SegmentList *old_list, GF_MPD_SegmentTemplate *old_template, GF_MPD_SegmentList *new_list, GF_MPD_SegmentTemplate *new_template, Double min_start_time) |
static u32 | gf_dash_purge_segment_timeline (GF_DASH_Group *group, Double min_start_time) |
static GF_Err | gf_dash_update_manifest (GF_DashClient *dash) |
static void | gf_dash_set_group_representation (GF_DASH_Group *group, GF_MPD_Representation *rep) |
static void | gf_dash_switch_group_representation (GF_DashClient *mpd, GF_DASH_Group *group) |
static GF_Err | gf_dash_resolve_url (GF_MPD *mpd, GF_MPD_Representation *rep, GF_DASH_Group *group, const char *mpd_url, GF_DASHURLResolveType resolve_type, u32 item_index, char **out_url, u64 *out_range_start, u64 *out_range_end, u64 *segment_duration, Bool *is_in_base_url) |
static GF_Err | gf_dash_download_init_segment (GF_DashClient *dash, GF_DASH_Group *group) |
static void | gf_dash_skip_disabled_representation (GF_DASH_Group *group, GF_MPD_Representation *rep) |
static void | gf_dash_reset_groups (GF_DashClient *dash) |
GF_Err | gf_dash_setup_groups (GF_DashClient *dash) |
static GF_Err | gf_dash_load_sidx (GF_BitStream *bs, GF_MPD_Representation *rep, Bool seperate_index, u64 sidx_offset) |
static GF_Err | gf_dash_load_representation_sidx (GF_DASH_Group *group, GF_MPD_Representation *rep, const char *cache_name, Bool seperate_index, Bool needs_mov_range) |
static GF_Err | dash_load_box_type (const char *cache_name, u32 offset, u32 *box_type, u32 *box_size) |
static GF_Err | gf_dash_setup_single_index_mode (GF_DASH_Group *group) |
static GF_Err | gf_dash_setup_period (GF_DashClient *dash) |
static void | dash_do_rate_adaptation (GF_DashClient *dash, GF_DASH_Group *group, GF_MPD_Representation *rep) |
static u32 | dash_main_thread_proc (void *par) |
static u32 | gf_dash_period_index_from_time (GF_DashClient *dash, u32 time) |
static void | gf_dash_download_stop (GF_DashClient *dash) |
Bool | gf_dash_seek_periods (GF_DashClient *dash) |
void | gf_dash_seek_groups (GF_DashClient *dash) |
static GF_Err | http_ifce_get (GF_FileDownload *getter, char *url) |
static void | http_ifce_clean (GF_FileDownload *getter) |
static const char * | http_ifce_cache_name (GF_FileDownload *getter) |
GF_Err | gf_dash_open (GF_DashClient *dash, const char *manifest_url) |
void | gf_dash_close (GF_DashClient *dash) |
GF_DashClient * | gf_dash_new (GF_DASHFileIO *dash_io, u32 max_cache_duration, u32 auto_switch_count, Bool keep_files, Bool disable_switching, GF_DASHInitialSelectionMode first_select_mode, Bool enable_buffering, u32 initial_time_shift_percent) |
void | gf_dash_del (GF_DashClient *dash) |
void | gf_dash_set_idle_interval (GF_DashClient *dash, u32 idle_time_ms) |
void | gf_dash_enable_utc_drift_compensation (GF_DashClient *dash, Bool estimate_utc_drift) |
u32 | gf_dash_get_group_count (GF_DashClient *dash) |
void * | gf_dash_get_group_udta (GF_DashClient *dash, u32 idx) |
GF_Err | gf_dash_set_group_udta (GF_DashClient *dash, u32 idx, void *udta) |
Bool | gf_dash_is_group_selected (GF_DashClient *dash, u32 idx) |
void | gf_dash_get_info (GF_DashClient *dash, const char **title, const char **source) |
void | gf_dash_switch_quality (GF_DashClient *dash, Bool switch_up, Bool immediate_switch) |
Double | gf_dash_get_duration (GF_DashClient *dash) |
const char * | gf_dash_get_url (GF_DashClient *dash) |
const char * | gf_dash_group_get_segment_mime (GF_DashClient *dash, u32 idx) |
const char * | gf_dash_group_get_segment_init_url (GF_DashClient *dash, u32 idx, u64 *start_range, u64 *end_range) |
void | gf_dash_group_select (GF_DashClient *dash, u32 idx, Bool select) |
void | gf_dash_groups_set_language (GF_DashClient *dash, const char *lang_3cc) |
Bool | gf_dash_is_running (GF_DashClient *dash) |
u32 | gf_dash_get_period_switch_status (GF_DashClient *dash) |
void | gf_dash_request_period_switch (GF_DashClient *dash) |
Bool | gf_dash_in_last_period (GF_DashClient *dash) |
Bool | gf_dash_in_period_setup (GF_DashClient *dash) |
u32 | gf_dash_group_get_max_segments_in_cache (GF_DashClient *dash, u32 idx) |
u32 | gf_dash_group_get_num_segments_ready (GF_DashClient *dash, u32 idx, Bool *group_is_done) |
void | gf_dash_group_discard_segment (GF_DashClient *dash, u32 idx) |
void | gf_dash_set_group_done (GF_DashClient *dash, u32 idx, Bool done) |
GF_Err | gf_dash_group_get_presentation_time_offset (GF_DashClient *dash, u32 idx, u64 *presentation_time_offset, u32 *timescale) |
GF_Err | gf_dash_group_get_next_segment_location (GF_DashClient *dash, u32 idx, u32 dependent_representation_index, const char **url, u64 *start_range, u64 *end_range, s32 *switching_index, const char **switching_url, u64 *switching_start_range, u64 *switching_end_range, const char **original_url, Bool *has_next_segment) |
GF_Err | gf_dash_group_probe_current_download_segment_location (GF_DashClient *dash, u32 idx, const char **url, s32 *switching_index, const char **switching_url, const char **original_url, Bool *switched) |
void | gf_dash_seek (GF_DashClient *dash, Double start_range) |
Double | gf_dash_get_playback_start_range (GF_DashClient *dash) |
Bool | gf_dash_group_segment_switch_forced (GF_DashClient *dash, u32 idx) |
Double | gf_dash_group_current_segment_start_time (GF_DashClient *dash, u32 idx) |
void | gf_dash_set_utc_shift (GF_DashClient *dash, s32 shift_utc_sec) |
GF_Err | gf_dash_group_get_video_info (GF_DashClient *dash, u32 idx, u32 *max_width, u32 *max_height) |
GF_Err | gf_dash_group_get_representation_info (GF_DashClient *dash, u32 idx, u32 representation_idx, u32 *width, u32 *height, u32 *audio_samplerate, u32 *bandwidth, const char **codecs) |
Bool | gf_dash_group_loop_detected (GF_DashClient *dash, u32 idx) |
Double | gf_dash_group_get_start_range (GF_DashClient *dash, u32 idx) |
Bool | gf_dash_is_dynamic_mpd (GF_DashClient *dash) |
u32 | gf_dash_get_min_buffer_time (GF_DashClient *dash) |
static u32 | gf_dash_get_start_number (GF_DASH_Group *group, GF_MPD_Representation *rep) |
GF_Err | gf_dash_resync_to_segment (GF_DashClient *dash, const char *latest_segment_name, const char *earliest_segment_name) |
GF_Err | gf_dash_set_max_resolution (GF_DashClient *dash, u32 width, u32 height) |
struct __dash_client |
Data Fields | ||
---|---|---|
GF_DASHFileIO * | dash_io | |
GF_FileDownload | getter | |
char * | base_url | |
u32 | max_cache_duration | |
u32 | max_width | |
u32 | max_height | |
u32 | auto_switch_count | |
Bool | keep_files | |
Bool | disable_switching | |
Bool | allow_local_mpd_update | |
Bool | enable_buffering | |
Bool | estimate_utc_drift | |
Bool | is_m3u8 | |
u64 | mpd_fetch_time | |
GF_DASHInitialSelectionMode | first_select_mode | |
GF_DASHFileIOSession | mpd_dnload | |
GF_MPD * | mpd | |
u32 | reload_count | |
u32 | last_update_time | |
u8 | lastMPDSignature[20] | |
char * | mimeTypeForM3U8Segments | |
u32 | active_period_index | |
u32 | request_period_switch | |
u64 | start_time_in_active_period | |
Bool | ignore_mpd_duration | |
u32 | initial_time_shift_percent | |
GF_List * | groups | |
GF_Thread * | dash_thread | |
GF_Mutex * | dl_mutex | |
GF_DASH_STATE | dash_state | |
Bool | mpd_stop_request | |
Bool | in_period_setup | |
u32 | nb_buffering | |
u32 | idle_interval | |
s32 | utc_drift_estimate | |
s32 | utc_shift | |
Double | playback_start_range | |
Double | start_range_in_segment_at_next_period |
struct segment_cache_entry |
struct __dash_group |
Data Fields | ||
---|---|---|
GF_DashClient * | dash | |
GF_MPD_AdaptationSet * | adaptation_set | |
GF_MPD_Period * | period | |
u32 | active_rep_index | |
u32 | prev_active_rep_index | |
Bool | timeline_setup | |
GF_DASHGroupSelection | selection | |
u32 | time_shift_buffer_depth | |
Bool | bitstream_switching | |
Bool | dont_delete_first_segment | |
Bool | done | |
Bool | force_switch_bandwidth | |
Bool | min_bandwidth_selected | |
u32 | download_start_time | |
u32 | active_bitrate | |
u32 | max_bitrate | |
u32 | min_bitrate | |
u32 | min_representation_bitrate | |
u32 | nb_segments_in_rep | |
Double | segment_duration | |
Double | start_playback_range | |
u32 | start_number | |
u32 | start_number_override | |
Bool | was_segment_base | |
Bool | local_files | |
u32 | download_segment_index | |
u32 | nb_segments_purged | |
u32 | nb_retry_on_last_segment | |
u32 | start_number_at_last_ast | |
u64 | ast_at_init | |
char * | urlToDeleteNext | |
volatile u32 | max_cached_segments | |
volatile u32 | nb_cached_segments | |
volatile u32 | max_buffer_segments | |
segment_cache_entry * | cached | |
GF_DASHFileIOSession | segment_download | |
const char * | segment_local_url | |
u64 | local_url_start_range | |
u64 | local_url_end_range | |
u32 | nb_segments_done | |
u32 | last_segment_time | |
Bool | segment_must_be_streamed | |
Bool | broken_timing | |
Bool | buffering | |
u32 | maybe_end_of_stream | |
u32 | cache_duration | |
u32 | time_at_first_reload_required | |
u32 | force_representation_idx_plus_one | |
Bool | force_segment_switch | |
Bool | is_downloading | |
Bool | download_aborted | |
Bool | loop_detected | |
u32 | time_at_first_failure | |
Bool | prev_segment_ok | |
Bool | segment_in_valid_range | |
u32 | nb_consecutive_fail | |
u32 | force_wait | |
u64 | current_downloaded_segment_duration | |
char * | service_mime | |
u32 | base_rep_index_plus_one | |
u32 | force_max_rep_index | |
void * | udta |
#define M3U8_TO_MPD_USE_TEMPLATE 0 |
#define GET_REP_ATTR | ( | _a | ) | _a = rep->_a; if (!_a) _a = set->_a; |
enum GF_DASH_STATE |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
void gf_dash_get_buffer_info_buffering | ( | GF_DashClient * | dash, |
u32 * | total_buffer, | ||
u32 * | media_buffered | ||
) |
|
static |
Bool gf_dash_check_mpd_root_type | ( | const char * | local_url | ) |
|
static |
|
static |
Returns true if given mime type is a MPD file
mime | the mime-type to check |
|
static |
Returns true if mime type of a given URL is an M3U8 mime-type
url | The url to check |
mime | The mime-type to check |
GF_Err gf_dash_download_resource | ( | GF_DASHFileIO * | dash_io, |
GF_DASHFileIOSession * | sess, | ||
const char * | url, | ||
u64 | start_range, | ||
u64 | end_range, | ||
u32 | persistent_mode, | ||
GF_DASH_Group * | group | ||
) |
Download a file with possible retry if GF_IP_CONNECTION_FAILURE|GF_IP_NETWORK_FAILURE (I discovered that with my WIFI connection, I had many issues with BFM-TV downloads) Similar to gf_term_download_new() and gf_dm_sess_process(). Parameters are identical to the ones of gf_term_download_new.
|
static |
|
static |
|
static |
|
static |
u64 gf_dash_get_segment_availability_start_time | ( | GF_MPD * | mpd, |
GF_DASH_Group * | group, | ||
u32 | segment_index, | ||
u32 * | seg_dur_ms | ||
) |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
GF_Err gf_dash_setup_groups | ( | GF_DashClient * | dash | ) |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Bool gf_dash_seek_periods | ( | GF_DashClient * | dash | ) |
void gf_dash_seek_groups | ( | GF_DashClient * | dash | ) |
|
static |
|
static |
|
static |
GF_Err gf_dash_open | ( | GF_DashClient * | dash, |
const char * | manifest_url | ||
) |
void gf_dash_close | ( | GF_DashClient * | dash | ) |
GF_DashClient* gf_dash_new | ( | GF_DASHFileIO * | dash_io, |
u32 | max_cache_duration, | ||
u32 | auto_switch_count, | ||
Bool | keep_files, | ||
Bool | disable_switching, | ||
GF_DASHInitialSelectionMode | first_select_mode, | ||
Bool | enable_buffering, | ||
u32 | initial_time_shift_percent | ||
) |
void gf_dash_del | ( | GF_DashClient * | dash | ) |
void gf_dash_set_idle_interval | ( | GF_DashClient * | dash, |
u32 | idle_time_ms | ||
) |
void gf_dash_enable_utc_drift_compensation | ( | GF_DashClient * | dash, |
Bool | estimate_utc_drift | ||
) |
u32 gf_dash_get_group_count | ( | GF_DashClient * | dash | ) |
void* gf_dash_get_group_udta | ( | GF_DashClient * | dash, |
u32 | idx | ||
) |
void gf_dash_get_info | ( | GF_DashClient * | dash, |
const char ** | title, | ||
const char ** | source | ||
) |
Double gf_dash_get_duration | ( | GF_DashClient * | dash | ) |
const char* gf_dash_get_url | ( | GF_DashClient * | dash | ) |
const char* gf_dash_group_get_segment_mime | ( | GF_DashClient * | dash, |
u32 | idx | ||
) |
const char* gf_dash_group_get_segment_init_url | ( | GF_DashClient * | dash, |
u32 | idx, | ||
u64 * | start_range, | ||
u64 * | end_range | ||
) |
void gf_dash_groups_set_language | ( | GF_DashClient * | dash, |
const char * | lang_3cc | ||
) |
Bool gf_dash_is_running | ( | GF_DashClient * | dash | ) |
u32 gf_dash_get_period_switch_status | ( | GF_DashClient * | dash | ) |
void gf_dash_request_period_switch | ( | GF_DashClient * | dash | ) |
Bool gf_dash_in_last_period | ( | GF_DashClient * | dash | ) |
Bool gf_dash_in_period_setup | ( | GF_DashClient * | dash | ) |
void gf_dash_group_discard_segment | ( | GF_DashClient * | dash, |
u32 | idx | ||
) |
GF_Err gf_dash_group_get_presentation_time_offset | ( | GF_DashClient * | dash, |
u32 | idx, | ||
u64 * | presentation_time_offset, | ||
u32 * | timescale | ||
) |
GF_Err gf_dash_group_get_next_segment_location | ( | GF_DashClient * | dash, |
u32 | idx, | ||
u32 | dependent_representation_index, | ||
const char ** | url, | ||
u64 * | start_range, | ||
u64 * | end_range, | ||
s32 * | switching_index, | ||
const char ** | switching_url, | ||
u64 * | switching_start_range, | ||
u64 * | switching_end_range, | ||
const char ** | original_url, | ||
Bool * | has_next_segment | ||
) |
GF_Err gf_dash_group_probe_current_download_segment_location | ( | GF_DashClient * | dash, |
u32 | idx, | ||
const char ** | url, | ||
s32 * | switching_index, | ||
const char ** | switching_url, | ||
const char ** | original_url, | ||
Bool * | switched | ||
) |
void gf_dash_seek | ( | GF_DashClient * | dash, |
Double | start_range | ||
) |
Double gf_dash_get_playback_start_range | ( | GF_DashClient * | dash | ) |
void gf_dash_set_utc_shift | ( | GF_DashClient * | dash, |
s32 | shift_utc_sec | ||
) |
GF_Err gf_dash_group_get_video_info | ( | GF_DashClient * | dash, |
u32 | idx, | ||
u32 * | max_width, | ||
u32 * | max_height | ||
) |
GF_Err gf_dash_group_get_representation_info | ( | GF_DashClient * | dash, |
u32 | idx, | ||
u32 | representation_idx, | ||
u32 * | width, | ||
u32 * | height, | ||
u32 * | audio_samplerate, | ||
u32 * | bandwidth, | ||
const char ** | codecs | ||
) |
Bool gf_dash_is_dynamic_mpd | ( | GF_DashClient * | dash | ) |
u32 gf_dash_get_min_buffer_time | ( | GF_DashClient * | dash | ) |
|
static |
GF_Err gf_dash_resync_to_segment | ( | GF_DashClient * | dash, |
const char * | latest_segment_name, | ||
const char * | earliest_segment_name | ||
) |