libgpac
Documentation of the core library of GPAC
m3u8.c File Reference
#include <gpac/internal/m3u8.h>
#include <gpac/network.h>
+ Include dependency graph for m3u8.c:

Data Structures

struct  s_accumulated_attributes
 
struct  HLS_LLChunk
 

Macros

#define _GNU_SOURCE
 
#define GROUP_ID_TO_PROGRAM_ID(type, group_id)
 
#define M3U8_COMPATIBILITY_VERSION(v)
 
#define M3U8_BUF_SIZE   2048
 
#define RST_ATTR(_name)   if (attribs->_name) { gf_free(attribs->_name); attribs->_name = NULL; }
 
#define _CLEANUP
 

Functions

GF_Err playlist_element_del (PlaylistElement *e)
 
static GF_Err cleanup_list_of_elements (GF_List *list)
 
static PlaylistElement * playlist_element_new (PlaylistElementType element_type, const char *url, s_accumulated_attributes *attribs)
 
static Stream * stream_new (int stream_id)
 
static GF_Err stream_del (Stream *stream)
 
static GFINLINE int string2num (const char *s)
 
static Bool safe_start_equals (const char *attribute, const char *line)
 
static void reset_attributes (s_accumulated_attributes *attributes)
 
static char ** extract_attributes (const char *name, const char *line, const int num_attributes)
 
static void free_attrs (char **attributes)
 
static char ** parse_attributes (const char *line, s_accumulated_attributes *attributes)
 
MasterPlaylist * master_playlist_new ()
 
GF_Err gf_m3u8_master_playlist_del (MasterPlaylist **playlist)
 
static Stream * master_playlist_find_matching_stream (const MasterPlaylist *pl, const u32 stream_id)
 
GF_EXPORT GF_Err gf_m3u8_parse_master_playlist (const char *file, MasterPlaylist **playlist, const char *baseURL)
 
GF_Err declare_sub_playlist (char *currentLine, const char *baseURL, s_accumulated_attributes *attribs, PlaylistElement *sub_playlist, MasterPlaylist **playlist, Stream *in_stream)
 
static void reset_attribs (s_accumulated_attributes *attribs, Bool is_cleanup)
 
GF_Err gf_m3u8_parse_sub_playlist (const char *m3u8_file, MasterPlaylist **playlist, const char *baseURL, Stream *in_stream, PlaylistElement *sub_playlist, Bool is_master)
 

Data Structure Documentation

◆ s_accumulated_attributes

struct s_accumulated_attributes
Data Fields
char * title
char * mediaURL
double duration_in_seconds
int bandwidth
int width
int height
int stream_id
char * codecs
char * language
char * name
u32 channels
MediaType type
char * group_audio
char * group_video
char * group_subtitle
char * group_closed_captions
Bool forced
int target_duration_in_seconds
int min_media_sequence
int current_media_seq
u32 version
u32 compatibility_version
Bool is_master_playlist
Bool is_media_segment
Bool is_playlist_ended
Bool is_default
Bool is_autoselect
u64 playlist_utc_timestamp
u64 byte_range_start
u64 byte_range_end
u64 init_byte_range_start
u64 init_byte_range_end
PlaylistElementDRMMethod key_method
char * init_url
char * key_url
bin128 key_iv
Bool has_iv
Bool independent_segments
Bool low_latency
Bool independent_part
u32 discontinuity

◆ HLS_LLChunk

struct HLS_LLChunk
Data Fields
char * name
u64 start
u32 size
Double duration

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE

◆ GROUP_ID_TO_PROGRAM_ID

#define GROUP_ID_TO_PROGRAM_ID (   type,
  group_id 
)
Value:
(\
MEDIA_TYPE_##type + \
string2num(group_id) \
) \

◆ M3U8_COMPATIBILITY_VERSION

#define M3U8_COMPATIBILITY_VERSION (   v)
Value:
if (v > attributes->compatibility_version) \
attributes->compatibility_version = v;

◆ M3U8_BUF_SIZE

#define M3U8_BUF_SIZE   2048

◆ RST_ATTR

#define RST_ATTR (   _name)    if (attribs->_name) { gf_free(attribs->_name); attribs->_name = NULL; }

◆ _CLEANUP

#define _CLEANUP
Value:
reset_attribs(&attribs, GF_TRUE);\
if (f) gf_fclose(f); \
else if (release_blob) gf_blob_release(m3u8_file);
s32 gf_fclose(FILE *file)
file closing
Definition: os_file.c:1658
@ GF_TRUE
Definition: setup.h:474
static void reset_attribs(s_accumulated_attributes *attribs, Bool is_cleanup)
Definition: m3u8.c:1118
GF_Err gf_blob_release(const char *blob_url)
Definition: os_divers.c:1351

Function Documentation

◆ playlist_element_del()

GF_Err playlist_element_del ( PlaylistElement *  e)

Deletes an Playlist element

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cleanup_list_of_elements()

static GF_Err cleanup_list_of_elements ( GF_List *  list)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ playlist_element_new()

static PlaylistElement* playlist_element_new ( PlaylistElementType  element_type,
const char *  url,
s_accumulated_attributes attribs 
)
static

Creates an Playlist element. This element can be either a playlist of a stream according to first parameter.

Returns
The PlaylistElement or NULL if it could not be created. Elements will be deleted recursively.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stream_new()

static Stream* stream_new ( int  stream_id)
static

Creates a new stream properly initialized

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stream_del()

static GF_Err stream_del ( Stream *  stream)
static

Deletes the specified stream

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ string2num()

static GFINLINE int string2num ( const char *  s)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ safe_start_equals()

static Bool safe_start_equals ( const char *  attribute,
const char *  line 
)
static
+ Here is the caller graph for this function:

◆ reset_attributes()

static void reset_attributes ( s_accumulated_attributes attributes)
static
+ Here is the caller graph for this function:

◆ extract_attributes()

static char** extract_attributes ( const char *  name,
const char *  line,
const int  num_attributes 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ free_attrs()

static void free_attrs ( char **  attributes)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parse_attributes()

static char** parse_attributes ( const char *  line,
s_accumulated_attributes attributes 
)
static

Parses the attributes and accumulate into the attributes structure

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ master_playlist_new()

MasterPlaylist* master_playlist_new ( )

Creates a new MasterPlaylist

Returns
NULL if MasterPlaylist element could not be allocated
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_m3u8_master_playlist_del()

GF_Err gf_m3u8_master_playlist_del ( MasterPlaylist **  playlist)

Deletes the given MasterPlaylist and all of its sub elements

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ master_playlist_find_matching_stream()

static Stream* master_playlist_find_matching_stream ( const MasterPlaylist *  pl,
const u32  stream_id 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_m3u8_parse_master_playlist()

GF_EXPORT GF_Err gf_m3u8_parse_master_playlist ( const char *  file,
MasterPlaylist **  playlist,
const char *  baseURL 
)

Parse the given m3u8 playlist file

Parameters
fileThe file from cache to parse
playlistThe playlist to fill. If argument is null, and file is valid, playlist will be allocated
baseURLThe base URL of the playlist
Returns
GF_OK if playlist valid
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ declare_sub_playlist()

GF_Err declare_sub_playlist ( char *  currentLine,
const char *  baseURL,
s_accumulated_attributes attribs,
PlaylistElement *  sub_playlist,
MasterPlaylist **  playlist,
Stream *  in_stream 
)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reset_attribs()

static void reset_attribs ( s_accumulated_attributes attribs,
Bool  is_cleanup 
)
static
+ Here is the caller graph for this function:

◆ gf_m3u8_parse_sub_playlist()

GF_Err gf_m3u8_parse_sub_playlist ( const char *  file,
MasterPlaylist **  playlist,
const char *  baseURL,
Stream *  in_program,
PlaylistElement *  sub_playlist,
Bool  is_master 
)

Parse the given playlist file as a subplaylist of an existing playlist

Parameters
fileThe file from cache to parse
playlistThe playlist to fill.
baseURLbase URL of the playlist
in_programin which the playlist is parsed
sub_playlistexisting subplaylist element in the playlist in which the playlist is parsed
is_masterset to true to indicate if this is the root playlist
Returns
GF_OK if playlist valid
+ Here is the call graph for this function:
+ Here is the caller graph for this function: