2 * GPAC - Multimedia Framework C SDK
\r
4 * Copyright (c) Jean Le Feuvre 2000-2005
\r
5 * All rights reserved
\r
7 * This file is part of GPAC / Authoring Tools sub-project
\r
9 * GPAC is free software; you can redistribute it and/or modify
\r
10 * it under the terms of the GNU Lesser General Public License as published by
\r
11 * the Free Software Foundation; either version 2, or (at your option)
\r
12 * any later version.
\r
14 * GPAC is distributed in the hope that it will be useful,
\r
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
17 * GNU Lesser General Public License for more details.
\r
19 * You should have received a copy of the GNU Lesser General Public
\r
20 * License along with this library; see the file COPYING. If not, write to
\r
21 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
\r
25 #ifndef _GF_MEDIA_H_
\r
26 #define _GF_MEDIA_H_
\r
33 #include <gpac/isomedia.h>
\r
34 #include <gpac/avparse.h>
\r
39 All these can import a file into a dedicated track. If esd is NULL the track is blindly added
\r
40 otherwise it is added with the requested ESID if non-0, otherwise the new trackID is stored in ESID
\r
41 if use_data_ref is set, data is only referenced in the file
\r
42 if duration is not 0, only the first duration seconds are imported
\r
43 NOTE: if an ESD is specified, its decoderSpecificInfo is also updated
\r
45 /*track importer flags*/
\r
48 /*references data rather than copy, whenever possible*/
\r
49 GF_IMPORT_USE_DATAREF = 1,
\r
50 /*for AVI video: imports at constant FPS (eg imports N-Vops due to encoder drops)*/
\r
51 GF_IMPORT_NO_FRAME_DROP = 1<<1,
\r
52 /*for CMP ASP only: forces treating the input as packed bitsream and discards all n-vops*/
\r
53 GF_IMPORT_FORCE_PACKED = 1<<2,
\r
54 /*for AAC audio: forces SBR mode with implicit signaling (backward compatible)*/
\r
55 GF_IMPORT_SBR_IMPLICIT = 1<<3,
\r
56 /*for AAC audio: forces SBR mode with explicit signaling (non-backward compatible).
\r
57 Will override GF_IMPORT_SBR_IMPLICIT flag when set*/
\r
58 GF_IMPORT_SBR_EXPLICIT = 1<<4,
\r
59 /*forces MPEG-4 import - some 3GP2 streams have both native IsoMedia sample description and MPEG-4 one possible*/
\r
60 GF_IMPORT_FORCE_MPEG4 = 1<<5,
\r
61 /*special flag for text import at run time (never set on probe), indicates to leave the text box empty
\r
62 so that we dynamically adapt to display size*/
\r
63 GF_IMPORT_SKIP_TXT_BOX = 1<<6,
\r
64 /*indicates to keep unknown tracks from .MOV/.IsoMedia files*/
\r
65 GF_IMPORT_KEEP_ALL_TRACKS = 1<<7,
\r
66 /*uses compact size in .MOV/.IsoMedia files*/
\r
67 GF_IMPORT_USE_COMPACT_SIZE = 1<<8,
\r
69 /*when set, only updates tracks info and return*/
\r
70 GF_IMPORT_PROBE_ONLY = 1<<20,
\r
71 /*only set when probing, signals several frames per sample possible*/
\r
72 GF_IMPORT_3GPP_AGGREGATION = 1<<21,
\r
73 /*only set when probing, signals video FPS overridable*/
\r
74 GF_IMPORT_OVERRIDE_FPS = 1<<22,
\r
75 /*only set when probing, signals duration not usable*/
\r
76 GF_IMPORT_NO_DURATION = 1<<23,
\r
77 /*when set by user during import, will abort*/
\r
78 GF_IMPORT_DO_ABORT = 1<<31
\r
81 #define GF_IMPORT_MAX_TRACKS 100
\r
82 struct __track_video_info
\r
84 u32 width, height, par;
\r
87 struct __track_audio_info
\r
89 u32 sample_rate, nb_channels;
\r
92 struct __track_import_info
\r
95 /*track type (GF_ISOM_MEDIA_****)*/
\r
97 /*media type ('MPG1', 'MPG2', ISO 4CC, AVI 4CC)*/
\r
99 /*possible import flags*/
\r
101 /*media format info*/
\r
102 struct __track_video_info video_info;
\r
103 struct __track_audio_info audio_info;
\r
106 /*for MPEG2 TS: program number*/
\r
110 struct __program_import_info
\r
117 typedef struct __track_import
\r
121 MP4/ISO media: trackID
\r
123 0: first video and first audio,
\r
125 2->any: audio track(s)
\r
126 MPEG-PS files with N video streams:
\r
127 0: first video and first audio
\r
129 N+1->any: audio track
\r
130 TrackNums can be obtain with probing
\r
133 /*media source - selects importer type based on extension*/
\r
135 /*import duration if any*/
\r
139 /*if non 0, force video FPS (CMP, AVI, OGG, H264) - also used by SUB import*/
\r
143 /*optional format indication for media source (used in IM1)*/
\r
144 char *streamFormat;
\r
145 /*frame per sample cumulation (3GP media only) - MAX 15, ignored in data ref*/
\r
146 u32 frames_per_sample;
\r
147 /*track ID of imported media in destination file*/
\r
150 /*for MP4 import only*/
\r
153 /*for text import*/
\r
157 /*number of tracks after probing - may be set to 0, in which case no track
\r
158 selection can be performed. It may also be inaccurate if probing doesn't
\r
159 detect all available tracks (cf ogg import)*/
\r
161 /*track info after probing (GF_IMPORT_PROBE_ONLY set).*/
\r
162 struct __track_import_info tk_info[GF_IMPORT_MAX_TRACKS];
\r
164 /*for MPEG-TS and similar: program names*/
\r
166 struct __program_import_info pg_info[GF_IMPORT_MAX_TRACKS];
\r
169 } GF_MediaImporter;
\r
171 GF_Err gf_media_import(GF_MediaImporter *importer);
\r
175 /*track dumper types are formatted as flags for conveniency for
\r
176 authoring tools, but never used as a OR'ed set*/
\r
177 /*native format (JPG, PNG, MP3, etc) if supported*/
\r
178 GF_EXPORT_NATIVE = 1,
\r
179 /*raw samples (including hint tracks for rtp)*/
\r
180 GF_EXPORT_RAW_SAMPLES = (1<<1),
\r
181 /*NHNT format (any MPEG-4 media)*/
\r
182 GF_EXPORT_NHNT = (1<<2),
\r
183 /*AVI (MPEG4 video and AVC tracks only)*/
\r
184 GF_EXPORT_AVI = (1<<3),
\r
185 /*MP4 (all except OD)*/
\r
186 GF_EXPORT_MP4 = (1<<4),
\r
187 /*AVI->RAW to dump video (trackID=1) or audio (trackID>=2)*/
\r
188 GF_EXPORT_AVI_NATIVE = (1<<5),
\r
189 /*NHML format (any media)*/
\r
190 GF_EXPORT_NHML = (1<<6),
\r
192 GF_EXPORT_SAF = (1<<7),
\r
194 /*following ones are real flags*/
\r
196 for MP4 extraction, indicates track should be added to dest file if any
\r
197 for raw extraction, indicates data shall be appended at the end of output file if present
\r
199 GF_EXPORT_MERGE = (1<<10),
\r
200 /*indicates QCP file format possible as well as native (EVRC and SMV audio only)*/
\r
201 GF_EXPORT_USE_QCP = (1<<11),
\r
202 /*indicates full NHML dump*/
\r
203 GF_EXPORT_NHML_FULL = (1<<11),
\r
204 /*ony probes extraction format*/
\r
205 GF_EXPORT_PROBE_ONLY = (1<<30),
\r
206 /*when set by user during export, will abort*/
\r
207 GF_EXPORT_DO_ABORT = (1<<31),
\r
211 typedef struct __track_exporter
\r
215 /*sample number to export for GF_EXPORT_RAW_SAMPLES only*/
\r
217 /*out name WITHOUT extension*/
\r
221 /*non-IsoMedia file (AVI)*/
\r
223 } GF_MediaExporter;
\r
225 /*if error returns same value as error signaled in message*/
\r
226 GF_Err gf_media_export(GF_MediaExporter *dump);
\r
231 RTP IsoMedia file hinting
\r
233 typedef struct __tag_isom_hinter GF_RTPHinter;
\r
235 GF_RTPHinter *gf_hinter_track_new(GF_ISOFile *file, u32 TrackNum,
\r
236 u32 Path_MTU, u32 max_ptime, u32 default_rtp_rate, u32 hint_flags, u8 PayloadID,
\r
237 Bool copy_media, u32 InterleaveGroupID, u8 InterleaveGroupPriority, GF_Err *e);
\r
238 /*delete the track hinter*/
\r
239 void gf_hinter_track_del(GF_RTPHinter *tkHinter);
\r
240 /*hints all samples in the media track*/
\r
241 GF_Err gf_hinter_track_process(GF_RTPHinter *tkHint);
\r
242 /*returns media bandwidth in kbps*/
\r
243 u32 gf_hinter_track_get_bandwidth(GF_RTPHinter *tkHinter);
\r
244 /*retrieves hinter flags*/
\r
245 u32 gf_hinter_track_get_flags(GF_RTPHinter *tkHinter);
\r
246 /*retrieves rtp payload name
\r
247 @payloadName: static buffer for retrieval, minimum 30 bytes
\r
249 void gf_hinter_track_get_payload_name(GF_RTPHinter *tkHint, char *payloadName);
\r
251 /*finalizes hinting process for the track (setup flags, write SDP for RTP, ...)
\r
252 @AddSystemInfo: if non-0, systems info are duplicated in the SDP (decoder cfg, PL IDs ..)
\r
254 GF_Err gf_hinter_track_finalize(GF_RTPHinter *tkHint, Bool AddSystemInfo);
\r
259 /*no IOD included*/
\r
260 GF_SDP_IOD_NONE = 0,
\r
261 /*base64 encoding of the regular MPEG-4 IOD*/
\r
262 GF_SDP_IOD_REGULAR,
\r
263 /*base64 encoding of IOD containing BIFS and OD tracks (one AU only) - this is used for ISMA 1.0 profiles
\r
264 note that the "hinted" file will loose all systems info*/
\r
266 /*same as ISMA but removes all clock references from IOD*/
\r
267 GF_SDP_IOD_ISMA_STRICT,
\r
270 /*finalizes hinting process for the file (setup flags, write SDP for RTP, ...)
\r
271 @IOD_Profile: see above
\r
272 @bandwidth: total bandwidth in kbps of all hinted tracks, 0 means no bandwidth info at session level
\r
274 GF_Err gf_hinter_finalize(GF_ISOFile *file, u32 IOD_Profile, u32 bandwidth);
\r
277 /*returns TRUE if the encoded data fits in an ESD url - streamType is the systems stream type needed to
\r
278 signal data mime-type (OD, BIFS or any) */
\r
279 Bool gf_hinter_can_embbed_data(char *data, u32 data_size, u32 streamType);
\r
281 /*save file as fragmented movie*/
\r
282 GF_Err gf_media_fragment_file(GF_ISOFile *input, char *output_file, Double MaxFragmentDuration);
\r
284 /*adds chapter info contained in file - import_fps is optional (most formats don't use it), defaults to 25*/
\r
285 GF_Err gf_media_import_chapters(GF_ISOFile *file, char *chap_file, Double import_fps);
\r
288 /*make the file ISMA compliant: creates ISMA BIFS / OD tracks if needed, and update audio/video IDs
\r
289 the file should not contain more than one audio and one video track
\r
290 @keepImage: if set, generates system info if image is found - only used for image imports
\r
292 GF_Err gf_media_make_isma(GF_ISOFile *mp4file, Bool keepESIDs, Bool keepImage, Bool no_ocr);
\r
294 /*make the file 3GP compliant && sets profile
\r
296 GF_Err gf_media_make_3gpp(GF_ISOFile *mp4file);
\r
298 /*make the file playable on a PSP
\r
300 GF_Err gf_media_make_psp(GF_ISOFile *mp4file);
\r
302 /*creates (if needed) a GF_ESD for the given track - THIS IS RESERVED for local playback
\r
303 only, since the OTI used when emulated is not standard...*/
\r
304 GF_ESD *gf_media_map_esd(GF_ISOFile *mp4, u32 track);
\r
306 /*changes pixel aspect ratio for visual tracks if supported. Negative values remove any PAR info*/
\r
307 GF_Err gf_media_change_par(GF_ISOFile *file, u32 track, s32 ar_num, s32 ar_den);
\r
310 /*SAF Multiplexer object. The multiplexer supports concurencial (multi-threaded) access*/
\r
311 typedef struct __saf_muxer GF_SAFMuxer;
\r
312 /*SAF Multiplexer constructor*/
\r
313 GF_SAFMuxer *gf_saf_mux_new();
\r
314 /*SAF Multiplexer destructor*/
\r
315 void gf_saf_mux_del(GF_SAFMuxer *mux);
\r
316 /*adds a new stream in the SAF multiplex*/
\r
317 GF_Err gf_saf_mux_stream_add(GF_SAFMuxer *mux, u32 stream_id, u32 ts_res, u32 buffersize_db, u8 stream_type, u8 object_type, char *mime_type, char *dsi, u32 dsi_len, char *remote_url);
\r
318 /*removes a stream from the SAF multiplex*/
\r
319 GF_Err gf_saf_mux_stream_rem(GF_SAFMuxer *mux, u32 stream_id);
\r
320 /*adds an AU to the given stream. !!AU data will be freed by the multiplexer!!
\r
321 AUs are not reinterleaved based on their CTS, in order to enable audio interleaving
\r
323 GF_Err gf_saf_mux_add_au(GF_SAFMuxer *mux, u32 stream_id, u32 CTS, char *data, u32 data_len, Bool is_rap);
\r
324 /*gets the content of the multiplexer for the given time.
\r
325 if force_end_of_session is set, this flushes the SAF Session - no more operations will be allowed on the muxer*/
\r
326 GF_Err gf_saf_mux_for_time(GF_SAFMuxer *mux, u32 time_ms, Bool force_end_of_session, char **out_data, u32 *out_size);
\r
334 #endif /*_GF_MEDIA_H_*/
\r