📄 terminal_dev.h
字号:
/* * GPAC - Multimedia Framework C SDK * * Copyright (c) Jean Le Feuvre 2000-2005 * All rights reserved * * This file is part of GPAC / Stream Management sub-project * * GPAC is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * GPAC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; see the file COPYING. If not, write to * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * */#ifndef _GF_TERMINAL_DEV_H_#define _GF_TERMINAL_DEV_H_#ifdef __cplusplusextern "C" {#endif#include <gpac/terminal.h>#include <gpac/mpeg4_odf.h>#include <gpac/modules/service.h>#include <gpac/modules/codec.h>#include <gpac/modules/ipmp.h>#include <gpac/mediaobject.h>#include <gpac/thread.h>typedef struct _inline_scene GF_InlineScene;typedef struct _media_manager GF_MediaManager;typedef struct _object_clock GF_Clock;typedef struct _es_channel GF_Channel;typedef struct _generic_codec GF_Codec;typedef struct _composition_memory GF_CompositionMemory;struct _net_service{ /*the module handling this service - must be declared first to typecast with GF_DownlaodSession upon deletion*/ GF_InputService *ifce; /*the terminal*/ struct _tag_terminal *term; /*service url*/ char *url; /*struct _od_manager owning service, NULL for services created for remote channels*/ struct _od_manager *owner; /*number of attached remote channels ODM (ESD URLs)*/ u32 nb_ch_users; /*number of attached remote ODM (OD URLs)*/ u32 nb_odm_users; /*clock objects. Kept at service level since ESID namespace is the service one*/ GF_List *Clocks; /*all downloaders objects used in this service*/ GF_List *dnloads; /*cache asscoiated with service, if any*/ GF_StreamingCache *cache;};/*opens service - performs URL concatenation if parent service specified*/GF_ClientService *gf_term_service_new(GF_Terminal *term, GF_ObjectManager *owner, const char *url, GF_ClientService *parent_service, GF_Err *ret_code);/*destroy service*/void gf_term_service_del(GF_ClientService *nets);/*access to the module interfaces - cf net_api.h GF_InputService for details*/GF_Err gf_term_service_command(GF_ClientService *ns, GF_NetworkCommand *com);Bool gf_term_service_can_handle_url(GF_ClientService *ns, char *url);GF_Err gf_term_channel_get_sl_packet(GF_ClientService *ns, LPNETCHANNEL channel, char **out_data_ptr, u32 *out_data_size, GF_SLHeader *out_sl_hdr, Bool *is_compressed, GF_Err *out_reception_status, Bool *is_new_data);GF_Err gf_term_channel_release_sl_packet(GF_ClientService *ns, LPNETCHANNEL channel);/*cache open/close*/GF_Err gf_term_service_cache_load(GF_ClientService *ns);GF_Err gf_term_service_cache_close(GF_ClientService *ns, Bool no_save);/*forwards all clocks of the given amount of time. Can only be used when terminal is in paused modethis is mainly designed for movie dumping in MP4Client*/GF_Err gf_term_step_clocks(GF_Terminal * term, u32 ms_diff);/* Inline scene stuff*/struct _inline_scene{ /*root OD of the subscene, ALWAYS namespace of the parent scene*/ struct _od_manager *root_od; /*scene codec: top level decoder decoding/generating the scene - can be BIFS, VRML parser, etc*/ struct _generic_codec *scene_codec; /*OD codec - specific to MPEG-4, only present at the inline level (media ressources are always scoped here)*/ struct _generic_codec *od_codec; /*struct _od_managers used, namespace of this scene. The chain does not have the root_od it only contains OD sent through OD UPDATE in the OD stream(s) attached to this scene. Remote ODs are not added, only there parents are*/ GF_List *ODlist; /*list of MOs (links between OD and nodes)*/ GF_List *media_objects; /*list of externproto libraries*/ GF_List *extern_protos; /*list of nodes using this inline*/ GF_List *inline_nodes; /*list of extra scene graphs (text streams, generic OSDs, ...)*/ GF_List *extra_scenes; /*inline scene graph*/ GF_SceneGraph *graph; /*graph state - if not attached, no traversing of inline 0: not attached 1: attached 2: temp graph attached. The temp graph is generated when waiting for the first scene AU to be processed */ u32 graph_attached; /*togles inline restart - needed because the restart may be triggered from inside the scene or from parent scene, hence 2 render passes must be used special value 2 means scene URL changes (for anchor navigation*/ u32 needs_restart; /*duration of inline scene*/ u64 duration; /*if not 0, all objects in the scene will run on this clock. Needed in GPAC when clock references do not respect object graph (eg IOD depending on external stream for clock)*/ u16 force_sub_clock_id; /*world info node or title node*/ void *world_info; Bool is_dynamic_scene; /*clock for dynamic scene - current assumption is that all selected streams are synchronized in the dyn scene*/ GF_Clock *dyn_ck; /*URLs of current video, audio and subs (we can't store objects since they may be destroyed when seeking)*/ SFURL visual_url, audio_url, text_url; /*set to 1 when single time-line presentation with ONE OD AU is detected - the goal is to prevent OD shutdown/startup when seeking. This will also remove unneeded net traffic for AddChannel/RemoveChannel like RTSP TEARDOWN/SETUP*/ Bool static_media_ressources;};GF_InlineScene *gf_is_new(GF_InlineScene *parentScene);void gf_is_del(GF_InlineScene *is);struct _od_manager *gf_is_find_odm(GF_InlineScene *is, u16 OD_ID);void gf_is_disconnect(GF_InlineScene *is, Bool for_shutdown);void gf_is_remove_object(GF_InlineScene *is, GF_ObjectManager *odm, Bool for_shutdown);/*browse all (media) channels and send buffering info to the app*/void gf_is_buffering_info(GF_InlineScene *is);void gf_is_attach_to_renderer(GF_InlineScene *is);struct _mediaobj *gf_is_get_media_object(GF_InlineScene *is, MFURL *url, u32 obj_type_hint, Bool lock_timelines);struct _mediaobj *gf_is_get_media_object_ex(GF_InlineScene *is, MFURL *url, u32 obj_type_hint, Bool lock_timelines, struct _mediaobj *sync_ref);void gf_is_setup_object(GF_InlineScene *is, GF_ObjectManager *odm);/*restarts inline scene - care has to be taken not to remove the scene while it is traversed*/void gf_is_restart(GF_InlineScene *is);/*updates scene duration based on settings*/void gf_is_set_duration(GF_InlineScene *is);/*locate media object by ODID (non dynamic ODs) or URL (dynamic ODs)*/struct _mediaobj *gf_is_find_object(GF_InlineScene *is, u16 ODID, char *url);/*returns scene time in sec - exact meaning of time depends on standard used*/Double gf_is_get_time(void *_is);/*returns true if the given node DEF name is the url target view (eg blabla#myview)*/Bool gf_is_default_scene_viewpoint(GF_Node *node);/*register extra scene graph for on-screen display*/void gf_is_register_extra_graph(GF_InlineScene *is, GF_SceneGraph *extra_scene, Bool do_remove);/*forces scene size info (without changing pixel metrics) - this may be needed by modules using extra graphs (like timedtext)*/void gf_is_force_scene_size(GF_InlineScene *is, u32 width, u32 height);/*regenerate a scene graph based on available objects - can only be called for dynamic OD streams*/void gf_is_regenerate(GF_InlineScene *is);/*selects given ODM for dynamic scenes*/void gf_is_select_object(GF_InlineScene *is, GF_ObjectManager *odm);/*restarts dynamic scene from given time: scene graph is not reseted, objects are just restartedinstead of closed and reopened. If a media control is present on inline, from_time is overriden by MC range*/void gf_is_restart_dynamic(GF_InlineScene *is, u64 from_time);/*owner inline node has been modified*/void gf_is_on_modified(GF_Node *node);/*returns scene graph associated with an externProto lib - exported for VRML/X3D loaded*/GF_SceneGraph *gf_is_get_proto_lib(void *_is, MFURL *lib_url);/*exported for renderers: handles filtering of "self" parameter indicating anchor only acts on container inline scenenot root one. Returns 1 if handled (cf user.h, navigate event)*/Bool gf_is_process_anchor(GF_Node *caller, GF_Event *evt);/*extern proto fetcher*/GF_SceneGraph *gf_is_get_proto_lib(void *SceneCallback, MFURL *lib_url);void gf_is_force_scene_size_video(GF_InlineScene *is, GF_MediaObject *mo);/*compares object URL with another URL - ONLY USE THIS WITH DYNAMIC ODs*/Bool gf_mo_is_same_url(GF_MediaObject *obj, MFURL *inline_url);enum{ /*threading up to decoder*/ GF_TERM_THREAD_FREE, /*single thread for all decoders*/ GF_TERM_THREAD_SINGLE, /*all media (image, video, audio) decoders are threaded*/ GF_TERM_THREAD_MULTI,};enum{ GF_TERM_RUNNING= 1, GF_TERM_DEAD = 1<<1, GF_TERM_SINGLE_THREAD = 1<<2, GF_TERM_MULTI_THREAD = 1<<3, GF_TERM_SYSDEC_RESYNC = 1<<4, GF_TERM_SINGLE_CLOCK = 1<<5, GF_TERM_RENDER_FRAME = 1<<6};struct _tag_terminal{ u32 flags; /*callback to user application*/ GF_User *user; /*scene renderer*/ struct __tag_base_renderer *renderer; /*file downloader*/ GF_DownloadManager *downloader; /*top level scene*/ GF_InlineScene *root_scene; /*Media manager*/ GF_List *codecs; /*mutex for decoder access*/ GF_Mutex *mm_mx; /*decoding thread*/ GF_Thread *mm_thread; /*thread priority*/ s32 priority; u32 cumulated_priority; /*frame duration*/ u32 frame_duration; /*net services*/ GF_List *net_services; /*net services to be destroyed*/ GF_List *net_services_to_remove; /*channels waiting for service CONNECT ack to be setup*/ GF_List *channels_pending; /*media objects pending for stop/play*/ GF_List *media_queue; /*network lock*/ GF_Mutex *net_mx; /*all X3D key/mouse/string sensors*/ GF_List *x3d_sensors; /*all input stream decoders*/ GF_List *input_streams; /*options (cf config doc)*/ Bool enable_cache; /*data timeout for network buffering in ms - if no data is recieved within this timeout the initial buffering aborts. */ u32 net_data_timeout; u32 play_state; u32 reload_state; char *reload_url; /*special list used by nodes needing a call to RenderNode but not in the traverese scene graph (VRML/MPEG-4 protos only). For these nodes, the traverse effect passed will be NULL. This is only used by InputSensor node at the moment*/ GF_List *nodes_pending;};GF_Err gf_term_init_scheduler(GF_Terminal *term, u32 threading_mode);void gf_term_stop_scheduler(GF_Terminal *term);void gf_term_add_codec(GF_Terminal *term, GF_Codec *codec);void gf_term_remove_codec(GF_Terminal *term, GF_Codec *codec);void gf_term_start_codec(GF_Codec *codec);void gf_term_stop_codec(GF_Codec *codec);void gf_term_set_threading(GF_Terminal *term, u32 mode);void gf_term_set_priority(GF_Terminal *term, s32 Priority);/*error report function*/void gf_term_message(GF_Terminal *app, const char *service, const char *message, GF_Err error);/*creates service for given OD / URL*/void gf_term_connect_object(GF_Terminal *app, GF_ObjectManager *odm, char *serviceURL, GF_ClientService *ParentService);/*creates service for given channel / URL*/GF_Err gf_term_connect_remote_channel(GF_Terminal *app, GF_Channel *ch, char *URL);/*called by media manager to perform service maintenance:servive shutdown: this is needed because service handler may be asynchronousobject Play: this is needed to properly handle multiplexed sources (all channels must be connected before play)service restart*/void gf_term_handle_services(GF_Terminal *app);/*close service and queue for delete*/void gf_term_close_services(GF_Terminal *app, GF_ClientService *service);/*locks net manager*/void gf_term_lock_net(GF_Terminal *app, Bool LockIt);/*locks scene renderer*/void gf_term_lock_renderer(GF_Terminal *app, Bool LockIt);/*get scene renderer time*/u32 gf_term_get_time(GF_Terminal *term);/*forces scene retraversal*/void gf_term_invalidate_renderer(GF_Terminal *term);/*callbacks for scene graph library so that all related ESM nodes are properly instanciated*/void gf_term_node_callback(void *_is, u32 type, GF_Node *node, void *param);/*add/rem node requiring a call to render without being present in traversed graph (VRML/MPEG-4 protos). For these nodes, the traverse effect passed will be NULL.*/void gf_term_add_render_node(GF_Terminal *term, GF_Node *node);void gf_term_rem_render_node(GF_Terminal *term, GF_Node *node);/*clock*/struct _object_clock { u16 clockID; GF_Terminal *term; GF_Mutex *mx; /*no_time_ctrl : set if ANY stream running on this clock has no time control capabilities - this avoids applying mediaControl and others that would break stream dependencies*/ Bool use_ocr, clock_init, has_seen_eos, no_time_ctrl; u32 init_time, StartTime, PauseTime, Paused; /*the number of streams buffering on this clock*/ u32 Buffering; /*associated media control if any*/ struct _media_control *mc; /*for MC only (no FlexTime)*/ Fixed speed; u32 discontinuity_time; s32 drift;};/*destroys clock*/void gf_clock_del(GF_Clock *ck);/*finds a clock by ID or by ES_ID*/GF_Clock *gf_clock_find(GF_List *Clocks, u16 clockID, u16 ES_ID);/*attach clock returns a new clock or the clock this stream (ES_ID) depends on (OCR_ES_ID)hasOCR indicates whether the stream being attached carries object clock references@clocks: list of clocks in ES namespace (service)@is: inline scene to solve clock dependencies*/GF_Clock *gf_clock_attach(GF_List *clocks, GF_InlineScene *is, u16 OCR_ES_ID, u16 ES_ID, s32 hasOCR);/*reset clock (only called by channel owning clock)*/void gf_clock_reset(GF_Clock *ck);/*stops clock (only called for scene clock)*/void gf_clock_stop(GF_Clock *ck);/*return clock time in ms*/u32 gf_clock_time(GF_Clock *ck);/*sets clock time - FIXME: drift updates for OCRs*/void gf_clock_set_time(GF_Clock *ck, u32 TS);/*return clock time in ms without drift adjustment - used by audio objects only*/u32 gf_clock_real_time(GF_Clock *ck);/*pause the clock*/void gf_clock_pause(GF_Clock *ck);/*resume the clock*/void gf_clock_resume(GF_Clock *ck);/*returns true if clock started*/Bool gf_clock_is_started(GF_Clock *ck);/*toggles buffering on (clock is paused at the first stream buffering) */void gf_clock_buffer_on(GF_Clock *ck);/*toggles buffering off (clock is paused at the last stream restarting) */void gf_clock_buffer_off(GF_Clock *ck);/*set clock speed scaling factor*/void gf_clock_set_speed(GF_Clock *ck, Fixed speed);/*set clock drift - used to resync audio*/void gf_clock_adjust_drift(GF_Clock *ck, s32 ms_drift);enum{ /*channel is setup and waits for connection request*/ GF_ESM_ES_SETUP = 0, /*waiting for server reply*/ GF_ESM_ES_WAIT_FOR_ACK, /*connection OK*/ GF_ESM_ES_CONNECTED, /*data exchange on this service/channel*/ GF_ESM_ES_RUNNING, /*deconnection OK - a download channel can automatically disconnect when download is done*/ GF_ESM_ES_DISCONNECTED, /*service/channel is not (no longer) available/found and should be removed*/ GF_ESM_ES_UNAVAILABLE};/*data channel (elementary stream)*/struct _es_channel {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -