📄 isomedia.h
字号:
/*Use this function to do the shadowing if you use shadowing.the sample to be shadowed MUST be a non-sync sample (ignored if not)the sample shadowing must be a Sync sample (error if not)*/GF_Err gf_isom_set_sync_shadow(GF_ISOFile *the_file, u32 trackNumber, u32 sampleNumber, u32 syncSample);/*set the GroupID of a track (only used for optimized interleaving). By setting GroupIDsyou can specify the storage order for media data of a group of streams. This is usefullfor BIFS presentation so that static resources of the scene can be downloaded before BIFS*/GF_Err gf_isom_set_track_group(GF_ISOFile *the_file, u32 trackNumber, u32 GroupID);/*set the priority of a track within a Group (used for optimized interleaving and hinting). This allows tracks to be stored before other within a same group, for instance the hint track data can be stored just before the media data, reducing disk seekingfor a same time, within a group of tracks, the track with the lowest inversePriority will be written first*/GF_Err gf_isom_set_track_priority_in_group(GF_ISOFile *the_file, u32 trackNumber, u32 InversePriority);/*set the max SamplesPerChunk (for file optimization, mainly in FLAT and STREAMABLE modes)*/GF_Err gf_isom_set_max_samples_per_chunk(GF_ISOFile *the_file, u32 trackNumber, u32 maxSamplesPerChunk);/*associate a given SL config with a given ESD while extracting the OD informationall the SL params must be fixed by the calling app!The SLConfig is stored by the API for further use. A NULL pointer will resultin using the default SLConfig (predefined = 2) remapped to predefined = 0This is usefull while reading the IOD / OD stream of an MP4 file. Note however thatonly full AUs are extracted, therefore the calling application must SL-packetize the streams*/GF_Err gf_isom_set_extraction_slc(GF_ISOFile *the_file, u32 trackNumber, u32 StreamDescriptionIndex, GF_SLConfig *slConfig);GF_Err gf_isom_get_extraction_slc(GF_ISOFile *the_file, u32 trackNumber, u32 StreamDescriptionIndex, GF_SLConfig **slConfig);u32 gf_isom_get_track_group(GF_ISOFile *the_file, u32 trackNumber);u32 gf_isom_get_track_priority_in_group(GF_ISOFile *the_file, u32 trackNumber);/*stores movie config (storage mode, interleave time, track groupIDs, priorities and names) in UDTA(kept on disk)if @remove_all is set, removes all stored info, otherwise recompute all stored info*/GF_Err gf_isom_store_movie_config(GF_ISOFile *the_file, Bool remove_all);/*restores movie config (storage mode, interleave time, track groupIDs, priorities and names) if found*/GF_Err gf_isom_load_movie_config(GF_ISOFile *the_file);/*setup interleaving for storage (shortcut for storeage mode + interleave_time)*/GF_Err gf_isom_make_interleave(GF_ISOFile *mp4file, Double TimeInSec);/****************************************************************** GENERIC HINTING WRITING API******************************************************************//*supported hint formats - ONLY RTP now*/enum{ GF_ISOM_HINT_RTP = GF_4CC('r', 't', 'p', ' '),};/*Setup the resources based on the hint formatThis function MUST be called after creating a new hint track and beforeany other calls on this track*/GF_Err gf_isom_setup_hint_track(GF_ISOFile *the_file, u32 trackNumber, u32 HintType);/*Create a HintDescription for the HintTrackthe rely flag indicates whether a reliable transport protocol is desired/requiredfor data transport 0: not desired (UDP/IP). NB: most RTP streaming servers only support UDP/IP for data 1: preferable (TCP/IP if possible or UDP/IP) 2: required (TCP/IP only)The HintDescriptionIndex is set, to be used when creating a HINT sample*/GF_Err gf_isom_new_hint_description(GF_ISOFile *the_file, u32 trackNumber, s32 HintTrackVersion, s32 LastCompatibleVersion, u8 Rely, u32 *HintDescriptionIndex);/*Starts a new sample for the hint track. A sample is just a collection of packetsthe transmissionTime is indicated in the media timeScale of the hint track*/GF_Err gf_isom_begin_hint_sample(GF_ISOFile *the_file, u32 trackNumber, u32 HintDescriptionIndex, u32 TransmissionTime);/*stores the hint sample in the file once all your packets for this sample are doneset IsRandomAccessPoint if you want to indicate that this is a random access point in the stream*/GF_Err gf_isom_end_hint_sample(GF_ISOFile *the_file, u32 trackNumber, u8 IsRandomAccessPoint);/****************************************************************** PacketHandling functions Data can be added at the end or at the beginning of the current packet by setting AtBegin to 1 the data will be added at the begining This allows constructing the packet payload before any meta-data******************************************************************//*adds a blank chunk of data in the sample that is skipped while streaming*/GF_Err gf_isom_hint_blank_data(GF_ISOFile *the_file, u32 trackNumber, u8 AtBegin);/*adds a chunk of data in the packet that is directly copied while streamingNOTE: dataLength MUST BE <= 14 bytes, and you should only use this functionto add small blocks of data (encrypted parts, specific headers, ...)*/GF_Err gf_isom_hint_direct_data(GF_ISOFile *the_file, u32 trackNumber, char *data, u32 dataLength, u8 AtBegin);/*adds a reference to some sample data in the packetSourceTrackID: the ID of the track where the referenced sample isSampleNumber: the sample number containing the data to be addedDataLength: the length of bytes to copy in the packetoffsetInSample: the offset in bytes in the sample at which to begin copying dataextra_data: only used when the sample is actually the sample that will contain this packet(usefull to store en encrypted version of a packet only available while streaming) In this case, set SourceTrackID to the HintTrack ID and SampleNumber to 0 In this case, the DataOffset MUST BE NULL and length will indicate the extra_data sizeNote that if you want to reference a previous HintSample in the hintTrack, you will have to parse the sample yourself ...*/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);/*adds a reference to some stream description data in the packet (headers, ...)SourceTrackID: the ID of the track where the referenced sample isStreamDescriptionIndex: the index of the stream description in the desired trackDataLength: the length of bytes to copy in the packetoffsetInDescription: the offset in bytes in the description at which to begin copying dataSince it is far from being obvious what this offset is, we recommend not using this function. The ISO Media Format specification is currently being updated to solvethis issue*/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******************************************************************//*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 repeatedpackets, you have to set the sequence number yourself.*/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);/*set the flags of the RTP packet*/GF_Err gf_isom_rtp_packet_set_flags(GF_ISOFile *the_file, u32 trackNumber, u8 PackingBit, u8 eXtensionBit, u8 MarkerBit, u8 disposable_packet, u8 IsRepeatedPacket);/*set the time offset of this packet. This enables packets to be placed in the hint track in decoding order, but have their presentation time-stamp in the transmitted packet in a different order. Typically used for MPEG video with B-frames*/GF_Err gf_isom_rtp_packet_set_offset(GF_ISOFile *the_file, u32 trackNumber, s32 timeOffset); /*set some specific info in the HintDescription for RTP*//*sets the RTP TimeScale that the server use to send packetssome RTP payloads may need a specific timeScale that is not the timeScale in the file formatthe default timeScale choosen by the API is the MediaTimeScale of the hint track*/GF_Err gf_isom_rtp_set_timescale(GF_ISOFile *the_file, u32 trackNumber, u32 HintDescriptionIndex, u32 TimeScale);/*sets the RTP TimeOffset that the server will add to the packetsif not set, the server adds a random offset*/GF_Err gf_isom_rtp_set_time_offset(GF_ISOFile *the_file, u32 trackNumber, u32 HintDescriptionIndex, u32 TimeOffset);/*sets the RTP SequenceNumber Offset that the server will add to the packetsif not set, the server adds a random offset*/GF_Err gf_isom_rtp_set_time_sequence_offset(GF_ISOFile *the_file, u32 trackNumber, u32 HintDescriptionIndex, u32 SequenceNumberOffset);/****************************************************************** SDP SPECIFIC WRITING API******************************************************************//*add an SDP line to the SDP container at the track level (media-specific SDP info)NOTE: the \r\n end of line for SDP is automatically inserted*/GF_Err gf_isom_sdp_add_track_line(GF_ISOFile *the_file, u32 trackNumber, const char *text);/*remove all SDP info at the track level*/GF_Err gf_isom_sdp_clean_track(GF_ISOFile *the_file, u32 trackNumber);/*add an SDP line to the SDP container at the movie level (presentation SDP info)NOTE: the \r\n end of line for SDP is automatically inserted*/GF_Err gf_isom_sdp_add_line(GF_ISOFile *the_file, const char *text);/*remove all SDP info at the movie level*/GF_Err gf_isom_sdp_clean(GF_ISOFile *the_file);#endif /*GPAC_READ_ONLY*//*Get SDP info at the movie level*/GF_Err gf_isom_sdp_get(GF_ISOFile *the_file, const char **sdp, u32 *length);/*Get SDP info at the track level*/GF_Err gf_isom_sdp_track_get(GF_ISOFile *the_file, u32 trackNumber, const char **sdp, u32 *length);u32 gf_isom_get_payt_count(GF_ISOFile *the_file, u32 trackNumber);const char *gf_isom_get_payt_info(GF_ISOFile *the_file, u32 trackNumber, u32 index, u32 *payID);/*dumps file structures into XML trace file */GF_Err gf_isom_dump(GF_ISOFile *file, FILE *trace);/*dumps RTP hint samples structure into XML trace file @trackNumber, @SampleNum: hint track and hint sample number @trace: output*/GF_Err gf_isom_dump_hint_sample(GF_ISOFile *the_file, u32 trackNumber, u32 SampleNum, FILE * trace);/*small hint reader - performs data caching*//*resets hint reading parameters, returns an error if the hint type is not supported for readingpacket sequence number is always reseted to 0@sample_start: indicates from where the packets should be read (regular 1-based sample number)@ts_offset: constant offset for timestamps, must be expressed in media timescale (which is the hint timescale). usually 0 (no offset)@sn_offset: offset for packet sequence number (first packet will have a SN of 1 + sn_offset) usually 0@ssrc: sync source identifier for RTP*/GF_Err gf_isom_reset_hint_reader(GF_ISOFile *the_file, u32 trackNumber, u32 sample_start, u32 ts_offset, u32 sn_offset, u32 ssrc);/*reads next hint packet. ALl packets are read in transmission (decoding) orderreturns an error if not supported, or GF_EOS when no more packets are availablecurrently only RTP reader is supported@pck_data, @pck_size: output packet data (must be freed by caller) - contains all info to be sent on the wire, eg for RTP contains the RTP header and the data@disposable (optional): indicates that the packet can be droped when late (B-frames & co)@repeated (optional): indicates this is a repeated packet (same one has already been sent)@trans_ts (optional): indicates the transmission time of the packet, expressed in hint timescale, taking into accountthe ts_offset specified in gf_isom_reset_hint_reader. Depending on packets this may not be the sameas the hint sample timestamp + ts_offset, some packets may need to be sent earlier (B-frames)@sample_num (optional): indicates hint sample number the packet belongs to*/GF_Err gf_isom_next_hint_packet(GF_ISOFile *the_file, u32 trackNumber, char **pck_data, u32 *pck_size, Bool *disposable, Bool *repeated, u32 *trans_ts, u32 *sample_num);/* 3GPP specific extensions NOTE: MPEG-4 OD Framework cannot be used with 3GPP files. Stream Descriptions are not GF_ESD, just generic config options as specified in this file*//*Generic 3GP/3GP2 config record*/typedef struct { /*GF_4CC record type, one fo the above GF_ISOM_SUBTYPE_3GP_ * subtypes*/ u32 type; /*4CC vendor name*/ u32 vendor; /*codec version*/ u8 decoder_version; /*number of sound frames per IsoMedia sample, >0 and <=15. The very last sample may contain less frames. */ u8 frames_per_sample; /*H263 ONLY - Level and profile*/ u8 H263_level, H263_profile; /*AMR(WB) ONLY - num of mode for the codec*/ u16 AMR_mode_set; /*AMR(WB) ONLY - changes in codec mode per sample*/ u8 AMR_mode_change_period;} GF_3GPConfig;/*return the 3GP config for this tream description, NULL if not a 3GPP track*/GF_3GPConfig *gf_isom_3gp_config_get(GF_ISOFile *the_file, u32 trackNumber, u32 StreamDescriptionIndex);#ifndef GPAC_READ_ONLY/*create the track config*/GF_Err gf_isom_3gp_config_new(GF_ISOFile *the_file, u32 trackNumber, GF_3GPConfig *config, char *URLname, char *URNname, u32 *outDescriptionIndex);/*update the track config - subtypes shall NOT differ*/GF_Err gf_isom_3gp_config_update(GF_ISOFile *the_file, u32 trackNumber, GF_3GPConfig *config, u32 DescriptionIndex);#endif /*GPAC_READ_ONLY*//*AVC/H264 extensions - GF_AVCConfig is defined in mpeg4_odf.h*//*gets uncompressed AVC config - user is responsible for deleting it*/GF_AVCConfig *gf_isom_avc_config_get(GF_ISOFile *the_file, u32 trackNumber, u32 DescriptionIndex);#ifndef GPAC_READ_ONLY/*creates new AVC config*/GF_Err gf_isom_avc_config_new(GF_ISOFile *the_file, u32 trackNumber, GF_AVCConfig *cfg, char *URLname, char *URNname, u32 *outDescriptionIndex);/*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -