libgpac
Documentation of the core library of GPAC
Loading...
Searching...
No Matches
m3u8.c File Reference
#include <gpac/internal/m3u8.h>
#include <gpac/network.h>

Data Structures

struct  s_accumulated_attributes
 
struct  HLS_LLChunk
 
union  s_accumulated_attributes.group
 

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 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
union s_accumulated_attributes.group group
int target_duration_in_seconds
int min_media_sequence
int current_media_seq
int version
int 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

◆ s_accumulated_attributes.group

union s_accumulated_attributes.group
Data Fields
char * audio
char * video
char * subtitle
char * closed_captions

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:1479
@ GF_TRUE
Definition setup.h:435
static void reset_attribs(s_accumulated_attributes *attribs, Bool is_cleanup)
Definition m3u8.c:1073
GF_Err gf_blob_release(const char *blob_url)
Definition os_divers.c:1262

Function Documentation

◆ playlist_element_del()

GF_Err playlist_element_del ( PlaylistElement *  e)

Deletes an Playlist element

◆ cleanup_list_of_elements()

static GF_Err cleanup_list_of_elements ( GF_List *  list)
static

◆ 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.

◆ stream_new()

static Stream * stream_new ( int  stream_id)
static

Creates a new stream properly initialized

◆ stream_del()

static GF_Err stream_del ( Stream *  stream)
static

Deletes the specified stream

◆ string2num()

static GFINLINE int string2num ( const char *  s)
static

◆ safe_start_equals()

static Bool safe_start_equals ( const char *  attribute,
const char *  line 
)
static

◆ reset_attributes()

static void reset_attributes ( s_accumulated_attributes attributes)
static

◆ extract_attributes()

static char ** extract_attributes ( const char *  name,
const char *  line,
const int  num_attributes 
)
static

◆ parse_attributes()

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

Parses the attributes and accumulate into the attributes structure

◆ master_playlist_new()

MasterPlaylist * master_playlist_new ( )

Creates a new MasterPlaylist

Parameters
NULLif MasterPlaylist element could not be allocated

◆ gf_m3u8_master_playlist_del()

GF_Err gf_m3u8_master_playlist_del ( MasterPlaylist **  playlist)

Deletes the given MasterPlaylist and all of its sub elements

◆ master_playlist_find_matching_stream()

static Stream * master_playlist_find_matching_stream ( const MasterPlaylist *  pl,
const u32  stream_id 
)
static

◆ 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
GF_OKif playlist valid

◆ 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 
)

◆ reset_attribs()

static void reset_attribs ( s_accumulated_attributes attribs,
Bool  is_cleanup 
)
static

◆ 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
GF_OKif playlist valid