gpac头文件阅读记录

依目录察看头文件: GPAC/GPAC4_0/gpac/include/gpac/
avparse.h
对象:
u       GF_AC3Header
u       GF_M4AdecSpecInfo
u       GF_M4VdecSpecInfo
u       GF_M4Vparser
struct __tag_m4v_parser
{
       GF_BitStream *bs;
       u32 current_object_type;
       u32 current_object_start;
       u32 tc_dec, prev_tc_dec, tc_disp, prev_tc_disp;
};
u       GF_VorbisParser
 
方法:
¨         GF_M4VParser *gf_m4v_parser_new(unsigned char *data, u32 data_size);
tmp = malloc(sizeof(GF_M4VParser));
tmp->bs = gf_bs_new(data, data_size, GF_BITSTREAM_READ);
//gf_bs_new 无甚花头,仅为开辟 GF_BitStream 型内存,设置读写模式和缓冲区之类操作
¨         void gf_m4v_parser_del(GF_M4VParser *m4v);
¨         GF_Err gf_m4v_parse_config(GF_M4VParser *m4v, GF_M4VDecSpecInfo *dsi);
// 由参数 GF_M4VParser *m4v bs 字段,读取相关设置
¨         GF_Err gf_m4v_parse_frame(GF_M4VParser *m4v, GF_M4VDecSpecInfo dsi, u8 *frame_type, u32 *time_inc, u32 *size, u32 *start, Bool *is_coded);
 
自第 00342 行起:
while (gf_bs_read_int(m4v->bs, 1) != 0)
              secs ++;
              /*no support for B frames in parsing*/
              secs += (dsi.enh_layer || *frame_type!=2) ? m4v->tc_dec : m4v->tc_disp;
       /*marker*/
       gf_bs_read_int(m4v->bs, 1);
       /*vop_time_inc*/
              if (dsi.NumBitsTimeIncrement)
              vop_inc = gf_bs_read_int(m4v->bs, dsi.NumBitsTimeIncrement);
             
       m4v->prev_tc_dec = m4v->tc_dec;
       m4v->prev_tc_disp = m4v->tc_disp;
              if (dsi.enh_layer || *frame_type!=2) {
              m4v->tc_disp = m4v->tc_dec;
              m4v->tc_dec = secs;
              }
                     *time_inc = secs * dsi.clock_rate + vop_inc;
到第 00358 行止。
以上 m4v 各个字段的属性尚不熟悉,有待进一步察看
¨         Bool gf_ac3_parser(u8 *buffer, u32 buffer_size, u32 *pos, GF_AC3Header *out_hdr);
Base_coding.h
¨         u32 gf_base64_encode(unsigned char *in_buffer, u32 in_buffer_size, unsigned char *out_buffer, u32 out_buffer_size);
//Base64 编码, MIME 相关
¨         u32 gf_base64_decode(unsigned char *in_buffer, u32 in_buffer_size, unsigned char *out_buffer, u32 out_buffer_size);
¨         u32 gf_base16_encode(unsigned char *in_buffer, u32 in_buffer_size, unsigned char *out_buffer, u32 out_buffer_size);
¨         u32 gf_base16_decode(unsigned char *in_buffer, u32 in_buffer_size, unsigned char *out_buffer, u32 out_buffer_size);
Bifs.h
 
对象:
u       typedef struct __tag_bifs_enc GF_BifsEncoder;
/*BIFS encoding*/
u       typedef struct __tag_bifs_dec GF_BifsDecoder;
定义于 bifs_dev.h
// 开始自 00070
// 结束于 00114
 
相关方法概述:
设置、创建和删除 decoder ,根据 GF_SceneGraph
设置、创建和删除 decoder ,根据 GF_SceneGraph
 
方法:
¨         GF_Err gf_bifs_decode_au(GF_BifsDecoder *codec, u16 ESID, char *data, u32 data_length);
/*decode a BIFS AU and applies it to the graph (non-memory mode only)*/
¨         GF_Err gf_bifs_encode_au(GF_BifsEncoder *codec, u16 ESID, GF_List *command_list, char **out_data, u32 *out_data_length);
/*encodes a list of commands for the given stream in the output buffer - data is dynamically allocated for output
the scenegraph used is the one described in SceneReplace command, hence scalable streams shall be encoded in time order
*/
主要经络:
……
e = gf_bifs_enc_commands(codec, command_list, bs);
// 解出命令序列,并对 bs 的内部数据的结构进行作用
……
gf_bs_align(bs);// 读写不满 u8 的,对齐之……
gf_bs_get_content(bs, (unsigned char **) out_data, out_data_length);
//     调用了
//       BS_CutBuffer(bs);
//     *output = (unsigned char*)bs->original;
//     *outSize = (u32) bs->size;//读出原始数据
/*
对于每个 AU ,似乎都对应有一组命令,该函数将其读出,并且对该 AU 执行
*/
gf_bs_del(bs);
……
Bifsengine.h
对象:
u       typedef struct __tag_bitstream GF_BitStream;
定义于 Bitstream.c
struct __tag_bitstream
{
       /*original stream data*/
       FILE *stream;
 
       /*original data*/
       char *original;//看上去像是缓冲区,从第一个字段指向的文件交换数据
       /*the size of our buffer*/
       u64 size;
       /*current position in BYTES*/
       u64 position;
       /*the byte readen/written */
       u32 current;
       /*the number of bits in the current byte*/
       u32 nbBits;
       /*the bitstream mode*/
       u32 bsmode;
 
       void (*EndOfStream)(void *par);
       void *par;
};
 
相关方法:
¨         GF_BitStream *gf_bs_new(unsigned char *buffer, u64 size, u32 mode);
//New 一个 GF_BitStream ,设置相关字段
 
¨         GF_BitStream *gf_bs_from_file(FILE *f, u32 mode);
由文件创建一个 GF_BitStream ,并且读取文件的 size ,填入返回参数的相关字段
 
¨         void gf_bs_del(GF_BitStream *bs);
 
¨         u32 gf_bs_read_data(GF_BitStream *bs, unsigned char *data, u32 nbBytes);
 
¨         u8 gf_bs_align(GF_BitStream *bs);
利用读写 int 型( gf_bs_read_int/gf_bs_write_int )的函数,处理 bs 数据掉多出一个字节的部分
对象:
typedef struct __tag_bifs_engine GF_BifsEngine;
定义于 Encode_cbk.c
 
有关方法:
GF_BifsEngine *gf_beng_init(void *calling_object, char *inputContext, void *extension);
……
00347 行起:
e = gf_sm_load_init(&(codec->load));
       if (!e) e = gf_sm_load_run(&(codec->load));
       gf_sm_load_done(&(codec->load));
/*
以上三个函数分别针对 BT/XMT/SWF/QT/MP4 ,调用相关的 gf_sm_load_init_**,gf_sm_load_run_**,gf_sm_load_done_** ,若对 mp4 文件的读写进行最终时,可重点察看这里!
*/
00349 行止。
……
 
void gf_beng_get_stream_config(GF_BifsEngine *beng, char **config, u32 *config_len);
// 以后面两个参数返回第一个参数结构体的相关字段
 
GF_Err gf_beng_encode_context(GF_BifsEngine *beng, GF_Err (*AUCallback)(void *, char *data, u32 size, u32 ts), void *extension);
/*
调用 gf_sm_live_encode_bifs_au(codec, 0, AUCallback);
后者遍历 codec->sc->Aus 下的各个 Au 并调用相关函数 encode
e = gf_bifs_encode_au(codec->bifsenc, codec->sc->ESID, au->commands, &data, &size);
AUCallback(codec->calling_object, data, size, au->timing);
*/
 
GF_Err gf_beng_encode_from_file(GF_BifsEngine *beng, char *auFile, GF_Err (*AUCallback)(void *, char *data, u32 size, u32 ts), void *extension);
/*
遍历当前 GF_BifsEngine ctx (即 context )下所有 Stream ,并且找出其下唯一的 BIFS (假设有且只有一个)
以下面的三行函数调用处理之:
e = gf_sm_load_init(&codec->load);
       if (!e) e = gf_sm_load_run(&codec->load);
       gf_sm_load_done(&codec->load);
*/
 
GF_Err gf_beng_encode_from_string(GF_BifsEngine *beng, char *auString, GF_Err (*AUCallback)(void *, char *data, u32 size, u32 ts), void *extension);
/*
类似上面的函数,区别仅在以如下函数处理之:
e = gf_sm_load_from_string(&codec->load, auString);
*/
 
GF_Err gf_beng_save_context(GF_BifsEngine *beng, char *ctxFileName, void *extension);
/*
xmt 或者 xmta 格式可直接 dump
e = gf_sm_dump(codec->ctx, szF, d_mode);
mp4 格式需要 encode
e = gf_sm_encode_to_file(codec->ctx, mp4, NULL, NULL, 0, 0);
*/
 
GF_Err gf_beng_aggregate_context(GF_BifsEngine *beng, void *extension);
/*
/*make random access for storage*/
e = gf_sm_make_random_access(codec->ctx);
上面这个函数,执行 codec->ctx context 中所有 stream 的所有 AU commands
并且把 commands 都去掉
重新创建 Scene replace
*/
 
void gf_beng_terminate(GF_BifsEngine *beng);
 
config.h
对象:
u       typedef struct __tag_config GF_Config;
与其相关的方法:
插入命名创建修改删除等
 
constants.h
诸多常量的定义
 
crypt.h
对象:
GF_Crypt
 
方法:
algorithm 的一系列设置
形如 gf_crypt_**
 
download.h
对象:
u       GF_DownloadManager
u       GF_DownloadSession
 
相关方法:
download manager 的管理,形如: gf_dm_**
download session 的管理,形如: gf_dm_sess_**
 
ietf.h
对象:
u       定义了 RTSP NOTIF CODES enum 类型,形如: NC_RTSP_**
 
u       GF_RTSPRange;
¨         相关方法:该结构体的创建、解析、删除
 
u       GF_RTSPTransport;
记录相关的 multi-cast 信息,如:端口范围, server/client 的端口范围,以及传输协议
¨         相关方法:该结构体的 Clone delete
 
u       GF_RTSPCommand;
大量 char* 及其他类型变量定义 RTSP 内置属性( interleaved )。
Char* 型的 body of the command control string userdata
Char* servicenane;//full URL of the command
相关方法:
¨         该结构体的 new del 以及 reset
 
u       GF_RTPInfo
 
u       GF_RTSPResponse
//response 反响,响应。
//response code
//header fields
//header extentions
//body
相关方法:
¨         该对象 new del reset
 
u       GF_RTSPSession
相关方法:
¨         new delete id port…
¨         GF_Err gf_rtsp_get_response(GF_RTSPSession *sess, GF_RTSPResponse *rsp);
/*Fetch an RTSP response from the server the GF_RTSPResponse will be reseted before fetch*/
return gf_rtsp_get_response(sess, rsp);
¨         其他方法:发送命令、注册回调函数、注册 / 注销 interleaved 函数
¨         GF_RTSPSession *gf_rtsp_session_new_server(GF_Socket *rtsp_listener);
¨         GF_Err gf_rtsp_get_command(GF_RTSPSession *sess, GF_RTSPCommand *com);
 
u       GF_RTPHeader
u       GF_RTPMap
u       GF_RTPChannel
相关方法:
¨         RTP/RTCP 的一些读写发送命令
¨         GF_Err gf_rtp_send_packet(GF_RTPChannel *ch, GF_RTPHeader *rtp_hdr, char *extra_header, u32 extra_header_size, char *pck, u32 pck_size);
¨         GF_Err gf_rtp_send_packet(GF_RTPChannel *ch, GF_RTPHeader *rtp_hdr, char *extra_header, u32 extra_header_size, char *pck, u32 pck_size);
/*send RTP packet*/
调用 gf_sk_send_to(…)
 
SDP 相关结构体以及方法:
 
u       RTP Pakitizer(非常重要!!!!!)
¨         GF_Err gp_rtp_builder_process(GP_RTPPacketizer *builder, char *data, u32 data_size, u8 IsAUEnd, u32 FullAUSize, u32 duration, u8 descIndex)
gp_rtp_builder_do_mpeg4(builder, data, data_size, IsAUEnd, FullAUSize);
追踪至 isom_hinter.c 文件中的:第 00539 行止:
tmp->rtp_p = gp_rtp_builder_new(hintType, &my_sl, flags, tmp,
Ismacryp.h
u       gf_ismacryp_encrypt_track
u       gf_ismacryp_Decrypt_trach
其他方法:
 
Isomedia.h
结构体:
u       GF_ISOSample (注意这个 sample directshow 中的有什么关系)
相关方法:
¨         GF_ISOSample *gf_isom_sample_new();
¨         void gf_isom_sample_del(GF_ISOSample **samp);
 
enume 类型的诸多常量: FILE FORMAT CONSTANTS
 
 
 
GENERAL API FUNCTIONS
¨         GF_ISOFile *gf_isom_open(const char *fileName, u8 OpenMode)
调用 e = gf_isom_datamap_new(fileName, NULL, GF_ISOM_DATA_MAP_READ_ONLY, &mov->movieFileMap);
 
 
 
STREAMING API FUNCTIONS
/*open a movie that can be uncomplete in READ_ONLY mode
to use for http streaming & co
 
NOTE: you must buffer the data to a local file, this mode DOES NOT handle
http/ftp/... streaming
*/
这很可能就是流媒体昭示如下几点:
1、  流媒体的特性——下载部分就可以播放
2、  远端流媒体下载后需要在本地 buffer ,是否就意味着 media map 的作用
3、  破损或者不完全的媒体也能够被播放
¨         GF_Err gf_isom_open_progressive(const char *fileName, GF_ISOFile **the_file, u64 *BytesMissing);
调用了: e = gf_isom_datamap_new(fileName, NULL, GF_ISOM_DATA_MAP_READ, &movie->movieFileMap);
而后者调用了: *outDataMap = gf_isom_fdm_new_temp(parentPath);
 
¨         GF_ISOSample *gf_isom_get_sample(GF_ISOFile *the_file, u32 trackNumber, u32 sampleNumber, u32 *StreamDescriptionIndex);
/*return a sample given its number, and set the StreamDescIndex of this sample
this index allows to retrieve the stream description if needed (2 media in 1 track)
return NULL if error*/
依次调用:
       trak = gf_isom_get_track_from_file(the_file, trackNumber);
       e = Media_GetSample(trak->Media, sampleNumber, &samp, &descIndex, 0, NULL);
 
¨         GF_Err gf_isom_get_sample_for_media_time(GF_ISOFile *the_file, u32 trackNumber, u32 desiredTime, u32 *StreamDescriptionIndex, u8 SearchMode, GF_ISOSample **sample, u32 *SampleNum);
/*gets a sample given a desired decoding time IN MEDIA TIME SCALE
and set the StreamDescIndex of this sample
this index allows to retrieve the stream description if needed (2 media in 1 track)
return GF_EOS if the desired time exceeds the media duration
WARNING: the sample may not be sync even though the sync was requested (depends on the media and the editList)
the SampleNum is optional. If non-NULL, will contain the sampleNumber*/
依次调用:
       trak = gf_isom_get_track_from_file(the_file, trackNumber);
       e = findEntryForTime(stbl, desiredTime, 1, &sampleNumber, &prevSampleNumber);
e = Media_FindSyncSample(trak->Media->information->sampleTable,
                                          sampleNumber, &syncNum, GF_ISOM_SEARCH_SYNC_BACKWARD);
// 多个分支,具体参数略有不同
 
¨         GF_Err gf_isom_get_sample_for_movie_time(GF_ISOFile *the_file, u32 trackNumber, u32 movieTime, u32 *StreamDescriptionIndex, u8 SearchMode, GF_ISOSample **sample, u32 *sampleNumber);
/*return a sample given a desired time in the movie. MovieTime is IN MEDIA TIME SCALE , handles edit list.
and set the StreamDescIndex of this sample
this index allows to retrieve the stream description if needed (2 media in 1 track)
sample must be set to NULL before calling.
 
result Sample is NULL if an error occured
if no sample is playing, an empty sample is returned with no data and a DTS set to MovieTime when serching in sync modes
if no sample is playing, the closest sample in the edit time-line is returned when serching in regular modes
 
WARNING: the sample may not be sync even though the sync was requested (depends on the media and the editList)
 
Note: this function will handle re-timestamping the sample according to the mapping of the media time-line
on the track time-line. The sample TSs (DTS / CTS offset) are expressed in MEDIA TIME SCALE
(to match the media stream TS resolution as indicated in media header / SLConfig)
 
sampleNumber is optional and gives the number of the sample in the media
*/
递归调用如下函数,具体参数可能有所不同:
                     return gf_isom_get_sample_for_movie_time(the_file, trackNumber, (u32) mediaTime, StreamDescriptionIndex, GF_ISOM_SEARCH_SYNC_FORWARD, sample, sampleNumber);
或者调用:
       e = gf_isom_get_sample_for_media_time(the_file, trackNumber, (u32) mediaTime, StreamDescriptionIndex, SearchMode, sample, &sampNum);
 
MPEG-4 Systems extensions
GENERIC HINTING WRITING API
¨         GF_Err gf_isom_setup_hint_track(GF_ISOFile *the_file, u32 trackNumber, u32 HintType);
调用了:
e = udta_AddBox(udta, gf_isom_box_new(GF_ISOM_BOX_TYPE_HNTI));
 
¨         GF_Err gf_isom_hint_sample_data(GF_ISOFile *the_file, u32 trackNumber, u32 SourceTrackID, u32 SampleNumber, u16 DataLength, u32 offsetInSample, char *extra_data, u8 AtBegin);
调用了:
       return gf_isom_hint_pck_add_dte(entry->hint_sample->HintType, pck, (GF_GenericDTE *)dte, AtBegin);
 
¨         GF_Err gf_isom_hint_sample_description_data(GF_ISOFile *the_file, u32 trackNumber, u32 SourceTrackID, u32 StreamDescriptionIndex, u16 DataLength, u32 offsetInDescription, u8 AtBegin);
所调用函数同上
 
RTP SPECIFIC WRITING API
¨         GF_Err gf_isom_rtp_packet_begin(GF_ISOFile *the_file, u32 trackNumber, s32 relativeTime, u8 PackingBit, u8 eXtensionBit, u8 MarkerBit, u8 PayloadType, u8 B_frame, u8 IsRepeatedPacket, u16 SequenceNumber);
/*Creates a new RTP packet in the HintSample. If a previous packet was created,
it is stored in the hint sample and a new packet is created.
- relativeTime: RTP time offset of this packet in the HintSample if any - in hint track
time scale. Used for data smoothing by servers.
- PackingBit: the 'P' bit of the RTP packet header
- eXtensionBit: the'X' bit of the RTP packet header
- MarkerBit: the 'M' bit of the RTP packet header
- PayloadType: the payload type, on 7 bits, format 0x0XXXXXXX
- B_frame: indicates if this is a B-frame packet. Can be skipped by a server
- IsRepeatedPacket: indicates if this is a duplicate packet of a previous one.
Can be skipped by a server
- SequenceNumber: the RTP base sequence number of the packet. Because of support for repeated
packets, you have to set the sequence number yourself.*/
依次调用:
       pck = (GF_RTPPacket *) gf_isom_hint_pck_new(entry->hint_sample->HintType);
       return gf_list_add(entry->hint_sample->packetTable, pck);
 
¨         类似关于 Hint 的函数,处理方法雷同

你可能感兴趣的:(其他技术类文章,buffer,extension,stream,file,header,command)