libgpac
Documentation of the core library of GPAC
Scene Manager

Scene management for importing/encoding of BIFS, XMT, LASeR scenes. More...

+ Collaboration diagram for Scene Manager:

Data Structures

struct  GF_AUContext
 
struct  GF_StreamContext
 
struct  GF_SceneManager
 
struct  GF_SceneLoader
 
struct  GF_SMEncodeOptions
 
struct  GF_NodeStats
 
struct  GF_SceneStatistics
 

Typedefs

typedef struct _scenedump GF_SceneDumper
 
typedef struct _statman GF_StatManager
 

Enumerations

enum  { GF_SM_AU_RAP = 1 , GF_SM_AU_NOT_AGGREGATED = 1<<1 , GF_SM_AU_MODIFIED = 1<<2 , GF_SM_AU_CAROUSEL = 1<<3 }
 
enum  {
  GF_SM_SWF_STATIC_DICT = 1 , GF_SM_SWF_NO_TEXT = (1<<1) , GF_SM_SWF_NO_FONT = (1<<2) , GF_SM_SWF_QUAD_CURVE = (1<<3) ,
  GF_SM_SWF_NO_LINE = (1<<4) , GF_SM_SWF_SCALABLE_LINE = (1<<5) , GF_SM_SWF_NO_GRADIENT = (1<<6) , GF_SM_SWF_SPLIT_TIMELINE = (1<<7) ,
  GF_SM_SWF_REUSE_APPEARANCE = (1<<9) , GF_SM_SWF_USE_IC2D = (1<<10) , GF_SM_SWF_USE_SVG = (1<<11)
}
 
enum  {
  GF_SM_LOAD_MPEG4_STRICT = 1 , GF_SM_LOAD_FOR_PLAYBACK = 1<<1 , GF_SM_LOAD_CONTEXT_READY = 1<<2 , GF_SM_LOAD_CONTEXT_STREAMING = 1<<3 ,
  GF_SM_LOAD_EMBEDS_RES = 1<<4
}
 
enum  GF_SceneManager_LoadType {
  GF_SM_LOAD_BT = 1 , GF_SM_LOAD_VRML , GF_SM_LOAD_X3DV , GF_SM_LOAD_XMTA ,
  GF_SM_LOAD_X3D , GF_SM_LOAD_SVG , GF_SM_LOAD_XSR , GF_SM_LOAD_DIMS ,
  GF_SM_LOAD_SWF , GF_SM_LOAD_QT , GF_SM_LOAD_MP4
}
 
enum  { GF_SM_ENCODE_USE_NAMES = 1 , GF_SM_ENCODE_RAP_INBAND = 2 , GF_SM_ENCODE_RAP_SHADOW = 4 }
 
enum  GF_SceneDumpFormat {
  GF_SM_DUMP_BT = 0 , GF_SM_DUMP_XMTA , GF_SM_DUMP_VRML , GF_SM_DUMP_X3D_VRML ,
  GF_SM_DUMP_X3D_XML , GF_SM_DUMP_LASER , GF_SM_DUMP_SVG , GF_SM_DUMP_XML ,
  GF_SM_DUMP_AUTO_TXT , GF_SM_DUMP_AUTO_XML , GF_SM_DUMP_NONE
}
 

Functions

Bool gf_node_in_table (GF_Node *node, u32 NDTType)
 
GF_SceneManagergf_sm_new (GF_SceneGraph *scene_graph)
 
void gf_sm_del (GF_SceneManager *sman)
 
GF_StreamContextgf_sm_stream_new (GF_SceneManager *sman, u16 ES_ID, u8 streamType, u32 codec_id)
 
GF_StreamContextgf_sm_stream_find (GF_SceneManager *sman, u16 ES_ID)
 
GF_AUContextgf_sm_stream_au_new (GF_StreamContext *stream, u64 timing, Double time_ms, Bool isRap)
 
GF_MuxInfogf_sm_get_mux_info (GF_ESD *src)
 
GF_Err gf_sm_aggregate (GF_SceneManager *sman, u16 ESID)
 
GF_Err gf_sm_import_bifs_subtitle (GF_SceneManager *sman, GF_ESD *src, GF_MuxInfo *mux)
 
GF_Err gf_sm_load_init (GF_SceneLoader *sload)
 
GF_Err gf_sm_load_run (GF_SceneLoader *sload)
 
void gf_sm_load_done (GF_SceneLoader *sload)
 
GF_Err gf_sm_load_string (GF_SceneLoader *sload, const char *str, Bool clean_at_end)
 
GF_Err gf_sm_encode_to_file (GF_SceneManager *sman, GF_ISOFile *mp4, GF_SMEncodeOptions *opt)
 
GF_Err gf_sm_dump (GF_SceneManager *sman, char *rad_name, Bool is_final_name, GF_SceneDumpFormat dump_mode)
 
GF_SceneDumpergf_sm_dumper_new (GF_SceneGraph *graph, char *rad_name, Bool is_final_name, char indent_char, GF_SceneDumpFormat dump_mode)
 
void gf_sm_dumper_del (GF_SceneDumper *sdump)
 
void gf_sm_dumper_set_extra_graph (GF_SceneDumper *sdump, GF_SceneGraph *extra)
 
char * gf_sm_dump_get_name (GF_SceneDumper *sdump)
 
GF_Err gf_sm_dump_command_list (GF_SceneDumper *sdump, GF_List *comList, u32 indent, Bool skip_first_replace)
 
GF_Err gf_sm_dump_graph (GF_SceneDumper *sdump, Bool skip_proto, Bool skip_routes)
 
GF_StatManagergf_sm_stats_new ()
 
void gf_sm_stats_del (GF_StatManager *sstat)
 
void gf_sm_stats_reset (GF_StatManager *sstat)
 
const GF_SceneStatisticsgf_sm_stats_get (GF_StatManager *sstat)
 
GF_Err gf_sm_stats_for_graph (GF_StatManager *sstat, GF_SceneGraph *sg)
 
GF_Err gf_sm_stats_for_scene (GF_StatManager *sstat, GF_SceneManager *sman)
 
GF_Err gf_sm_stats_for_command (GF_StatManager *sstat, GF_Command *com)
 

Detailed Description

This section documents the Scene manager used for importing/encoding of BIFS, XMT, LASeR scenes.


Data Structure Documentation

◆ GF_AUContext

struct GF_AUContext

Generic systems access unit context

Data Fields
u64 timing
Double timing_sec
GF_List * commands
u32 flags
struct _stream_context * owner

◆ GF_StreamContext

struct GF_StreamContext

Generic stream context

Data Fields
u16 ESID
char * name
u8 streamType
u32 codec_id
u32 timeScale
GF_List * AUs
u64 last_au_time
Bool in_root_od
u32 current_au_count
u8 * dec_cfg
u32 dec_cfg_len
u64 imp_exp_time
u16 aggregate_on_esid
u32 carousel_period
Bool disable_aggregation

◆ GF_SceneManager

struct GF_SceneManager

Generic presentation context

+ Collaboration diagram for GF_SceneManager:
Data Fields
GF_SceneGraph * scene_graph
GF_List * streams
GF_ObjectDescriptor * root_od
u32 scene_width
u32 scene_height
Bool is_pixel_metrics
u32 max_node_id
u32 max_route_id
u32 max_proto_id

◆ GF_SceneLoader

struct GF_SceneLoader

Scenegraph loader

+ Collaboration diagram for GF_SceneLoader:
Data Fields
GF_SceneManager_LoadType type

loader type, one of the above value. If not set, detected based on file extension

GF_SceneGraph * scene_graph

scene graph worked on - may be NULL if ctx is present

struct _gf_scene * is

inline scene

GF_SceneManager * ctx

context manager to load (MUST BE RESETED BEFORE if needed) - may be NULL for loaders not using commands, in which case the graph will be directly updated

const char * fileName

file to import except IsoMedia files

const char * src_url original URL for the file or NULL if same as fileName
GF_ISOFile * isom

IsoMedia file to import (we need to be able to load from an opened file for scene stats)

u32 swf_import_flags

swf import flags

Float swf_flatten_limit

swf flatten limit: angle limit below which 2 lines are considered as aligned, in which case the lines are merged as one. If 0, no flattening happens

const char * localPath

swf extraction path: if set, swf media (mp3, jpeg) are extracted to this path. If not set media are extracted to original file directory

const char * svgOutFile

carrying svgOutFile when the loader is used by a SceneDumper

u32 flags

loader flags

u16 force_es_id

force stream ID

◆ GF_SMEncodeOptions

struct GF_SMEncodeOptions

Scenegraph Encoder options

Data Fields
u32 flags
u32 rap_freq
char * mediaSource
s32 resolution
u32 coord_bits
u32 scale_bits
u32 auto_quant
const char * src_url

◆ GF_NodeStats

struct GF_NodeStats

Node statistics object

Data Fields
u32 tag
const char * name
u32 nb_created
u32 nb_used
u32 nb_del

◆ GF_SceneStatistics

struct GF_SceneStatistics

Scene statistics object

+ Collaboration diagram for GF_SceneStatistics:
Data Fields
GF_List * node_stats
GF_List * proto_stats
SFVec2f max_2d
SFVec2f min_2d
u32 int_res_2d
u32 frac_res_2d
u32 scale_int_res_2d
u32 scale_frac_res_2d
Fixed max_fixed
Fixed min_fixed
u32 count_2d
u32 rem_2d
SFVec3f max_3d
SFVec3f min_3d
u32 count_3d
u32 rem_3d
u32 count_float
u32 rem_float
u32 count_color
u32 rem_color
u32 count_2f
u32 count_3f
u32 nb_svg_attributes
GF_StreamContext * base_layer

Typedef Documentation

◆ GF_SceneDumper

typedef struct _scenedump GF_SceneDumper

Scenegraph dumper

◆ GF_StatManager

typedef struct _statman GF_StatManager

Scenegraph statistics manager

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Scene manager AU flags

◆ anonymous enum

anonymous enum

SWF to MPEG-4 flags

◆ anonymous enum

anonymous enum

general loader flags

◆ GF_SceneManager_LoadType

loader type, usually detected based on file ext

◆ anonymous enum

anonymous enum

encoding flags

◆ GF_SceneDumpFormat

Scenegraph dump mode

Function Documentation

◆ gf_node_in_table()

Bool gf_node_in_table ( GF_Node node,
u32  NDTType 
)

Node data type check. This handles prototype nodes, and assumes undefined nodes always belong to the desired NDT

Parameters
nodethe node to check
NDTTypethe parent NDT type
Returns
GF_TRUE if node belongs to given NDT.

◆ gf_sm_new()

GF_SceneManager* gf_sm_new ( GF_SceneGraph scene_graph)

scene manager constructor

Parameters
scene_graphscene graph used by the manager
Returns
a new scene manager object

◆ gf_sm_del()

void gf_sm_del ( GF_SceneManager sman)

scene manager destructor - does not destroy the attached scene graph

Parameters
smanthe target scene manager

◆ gf_sm_stream_new()

GF_StreamContext* gf_sm_stream_new ( GF_SceneManager sman,
u16  ES_ID,
u8  streamType,
u32  codec_id 
)

retrive or create a stream context in the presentation context

Warning
if a stream with the same streamType and no ESID already exists in the context, it is assigned the requested ES_ID - this is needed to solve base layer
Parameters
smanthe target scene manager
ES_IDID of the new stream
streamTypestream type of the new stream
codec_idcodec ID of the new stream
Returns
a new scene manager stream context

◆ gf_sm_stream_find()

GF_StreamContext* gf_sm_stream_find ( GF_SceneManager sman,
u16  ES_ID 
)

locates a stream based on its id

Parameters
smanthe target scene manager
ES_IDID of the new stream
Returns
the stream context or NULL if not found

◆ gf_sm_stream_au_new()

GF_AUContext* gf_sm_stream_au_new ( GF_StreamContext stream,
u64  timing,
Double  time_ms,
Bool  isRap 
)

create a new AU context in the given stream context

Parameters
streamthe traget stream context
timingthe timing in stream timescale
time_msthe timing in ms
isRapindicates of the AU is a RAP or not
Returns
a new scene manager AU context

◆ gf_sm_get_mux_info()

GF_MuxInfo* gf_sm_get_mux_info ( GF_ESD src)

locates a MuxInfo descriptor in an EDD

Parameters
srcthe target ESD
Returns
a mux info descriptor or NULL if none found

◆ gf_sm_aggregate()

GF_Err gf_sm_aggregate ( GF_SceneManager sman,
u16  ESID 
)

applies all commands in all streams (only BIFS for now): the context manager will only have maximum one AU per stream, this AU being a random access for the stream

Parameters
smanthe target scene manager
ESIDif set, aggregation is only performed on the given stream, otherwise on all streams
Returns
error if any

◆ gf_sm_import_bifs_subtitle()

GF_Err gf_sm_import_bifs_subtitle ( GF_SceneManager sman,
GF_ESD src,
GF_MuxInfo mux 
)

translates SRT/SUB (TTXT not supported) source into BIFS command stream source

Parameters
smanthe target scene manager
srcGF_ESD of new stream (MUST be created before to store TS resolution)
muxGF_MuxInfo of src stream - shall contain a valid file, and at least the textNode member set
Returns
error if any

◆ gf_sm_load_init()

GF_Err gf_sm_load_init ( GF_SceneLoader sload)

initializes the context loader - this will load any IOD and the first frame of the main scene

Parameters
sloada preallocated, uninitialized loader
Returns
error if any

◆ gf_sm_load_run()

GF_Err gf_sm_load_run ( GF_SceneLoader sload)

completely loads context

Parameters
sloadthe target scene loader
Returns
error if any

◆ gf_sm_load_done()

void gf_sm_load_done ( GF_SceneLoader sload)

terminates the context loader

Parameters
sloadthe target scene loader

◆ gf_sm_load_string()

GF_Err gf_sm_load_string ( GF_SceneLoader sload,
const char *  str,
Bool  clean_at_end 
)

parses memory scene (any textural format) into the context

Warning
LOADER TYPE MUST BE ASSIGNED (BT/WRL/XMT/X3D/SVG only)
Parameters
sloadthe target scene loader
strthe string to load; MUST be at least 4 bytes long in order to detect BOM (unicode encoding); can be either UTF-8 or UTF-16 data
clean_at_endif GF_TRUE, associated parser is terminated. Otherwise, a call to gf_sm_load_done must be done to clean resources (needed for SAX progressive loading)
Returns
error if any

◆ gf_sm_encode_to_file()

GF_Err gf_sm_encode_to_file ( GF_SceneManager sman,
GF_ISOFile mp4,
GF_SMEncodeOptions opt 
)

encodes scene context into a destination MP4 file

Parameters
smanthe target scene manager
mp4the destination ISOBMFF file
optthe encoding options
Returns
error if any

◆ gf_sm_dump()

GF_Err gf_sm_dump ( GF_SceneManager sman,
char *  rad_name,
Bool  is_final_name,
GF_SceneDumpFormat  dump_mode 
)

dumps scene context to a given format

Parameters
smanthe target scene manager
rad_namefile name & loc without extension - if NULL dump will happen in stdout
is_final_nameif set, no extension is added to the filename
dump_modescene dum mode
Returns
error if any

◆ gf_sm_dumper_new()

GF_SceneDumper* gf_sm_dumper_new ( GF_SceneGraph graph,
char *  rad_name,
Bool  is_final_name,
char  indent_char,
GF_SceneDumpFormat  dump_mode 
)

creates a scene dumper

Parameters
graphscene graph being dumped
rad_namefile radical (NULL for stdout) - if not NULL MUST BE GF_MAX_PATH length
is_final_nameif set, rad_name is the final name (no extension added)
indent_charindent format
dump_modeif set, dumps in XML format otherwise regular text
Returns
a new scene dumper object, or NULL if error

◆ gf_sm_dumper_del()

void gf_sm_dumper_del ( GF_SceneDumper sdump)

destroys a scene dumper

Parameters
sdumpthe target scene dumper

◆ gf_sm_dumper_set_extra_graph()

void gf_sm_dumper_set_extra_graph ( GF_SceneDumper sdump,
GF_SceneGraph extra 
)

adds extra graph to scene dumper (all graphs will be dumped)

Parameters
sdumpthe target scene dumper
extrascene graph to be added

◆ gf_sm_dump_get_name()

char* gf_sm_dump_get_name ( GF_SceneDumper sdump)

gets a pointer to the filename (rad+ext) of the dumped file

Parameters
sdumpthe target scene dumper
Returns
null if no file has been dumped

◆ gf_sm_dump_command_list()

GF_Err gf_sm_dump_command_list ( GF_SceneDumper sdump,
GF_List comList,
u32  indent,
Bool  skip_first_replace 
)

dumps commands list

Parameters
sdumpthe target scene dumper
comListlist of commands to dump
indentindent to use
skip_first_replaceif GF_TRUE and dumping in BT mode, the initial REPLACE SCENE header is skipped
Returns
error if any

◆ gf_sm_dump_graph()

GF_Err gf_sm_dump_graph ( GF_SceneDumper sdump,
Bool  skip_proto,
Bool  skip_routes 
)

dumps complete graph

Parameters
sdumpthe target scene dumper
skip_protoproto declarations are skipped
skip_routesroutes are not dumped
Returns
error if any

◆ gf_sm_stats_new()

GF_StatManager* gf_sm_stats_new ( )

creates new statitistics manager

Returns
a new statitistics manager

◆ gf_sm_stats_del()

void gf_sm_stats_del ( GF_StatManager sstat)

destroys a statitistics manager

Parameters
sstatthe target statitistics manager

◆ gf_sm_stats_reset()

void gf_sm_stats_reset ( GF_StatManager sstat)

resets statistics

Parameters
sstatthe target statitistics manager

◆ gf_sm_stats_get()

const GF_SceneStatistics* gf_sm_stats_get ( GF_StatManager sstat)

gets statistics report

Parameters
sstatthe target statitistics manager
Returns
a scene statistic report or NULL if error

◆ gf_sm_stats_for_graph()

GF_Err gf_sm_stats_for_graph ( GF_StatManager sstat,
GF_SceneGraph sg 
)

computes statistitics for a complete graph

Parameters
sstatthe target statitistics manager
sgthe scene graph to analyze
Returns
error if any

◆ gf_sm_stats_for_scene()

GF_Err gf_sm_stats_for_scene ( GF_StatManager sstat,
GF_SceneManager sman 
)

computes statistitics for the full scene

Parameters
sstatthe target statitistics manager
smanthe scene manager to analyze
Returns
error if any

◆ gf_sm_stats_for_command()

GF_Err gf_sm_stats_for_command ( GF_StatManager sstat,
GF_Command com 
)

computes statistitics for the given command

Parameters
sstatthe target statitistics manager
comthe scene command to analyze
Returns
error if any