├── include └── gpac │ ├── revision.h │ ├── internal │ ├── avilib.h │ ├── odf_parse_common.h │ └── ogg.h │ ├── version.h │ ├── base_coding.h │ ├── utf.h │ ├── sync_layer.h │ ├── configuration.h │ ├── list.h │ ├── config_file.h │ ├── avparse.h │ └── setup.h ├── BUGS ├── Changelog ├── doc ├── gpac.mp4 ├── osmo4.ico ├── GPAC UPnP.doc ├── ipmpx_syntax.bt ├── man │ ├── mp42avi.1 │ ├── dashcast.1 │ ├── mp42ts.1 │ └── mp4client.1 ├── INSTALL.symbian ├── SceneGenerators ├── INSTALL.gpe ├── CODING_STYLE ├── INSTALL.gcc ├── INSTALL.wCE └── INSTALL.w32 ├── src ├── avilib.c ├── error.c ├── Makefile ├── base_encoding.c ├── box_code_apple.c ├── url.c ├── qos.c └── configfile.c ├── TODO ├── .gitattributes ├── AUTHORS ├── Makefile ├── .github └── ISSUE_TEMPLATE.md ├── .gitignore ├── README.md ├── INSTALLME └── .travis.yml /include/gpac/revision.h: -------------------------------------------------------------------------------- 1 | #define GPAC_GIT_REVISION "1166-g517222a-master" 2 | -------------------------------------------------------------------------------- /BUGS: -------------------------------------------------------------------------------- 1 | BUGS 2 | 3 | A bug tracker is available at https://github.com/gpac/gpac/issues 4 | -------------------------------------------------------------------------------- /Changelog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/comcast/gpac-caption-extractor/master/Changelog -------------------------------------------------------------------------------- /doc/gpac.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/comcast/gpac-caption-extractor/master/doc/gpac.mp4 -------------------------------------------------------------------------------- /src/avilib.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/comcast/gpac-caption-extractor/master/src/avilib.c -------------------------------------------------------------------------------- /src/error.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/comcast/gpac-caption-extractor/master/src/error.c -------------------------------------------------------------------------------- /doc/osmo4.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/comcast/gpac-caption-extractor/master/doc/osmo4.ico -------------------------------------------------------------------------------- /doc/GPAC UPnP.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/comcast/gpac-caption-extractor/master/doc/GPAC UPnP.doc -------------------------------------------------------------------------------- /doc/ipmpx_syntax.bt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/comcast/gpac-caption-extractor/master/doc/ipmpx_syntax.bt -------------------------------------------------------------------------------- /include/gpac/internal/avilib.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/comcast/gpac-caption-extractor/master/include/gpac/internal/avilib.h -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | cf https://github.com/gpac/gpac/issues for ongoing tasks and bugs. 2 | 3 | When filing a request there, please tag it as feature-request. 4 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | 3 | *.c text 4 | *.cpp text 5 | *.h text 6 | *.ttx text 7 | Makefile text 8 | 9 | #unix 10 | *.sh text eol=lf 11 | configure text eol=lf 12 | 13 | #windows 14 | *.bat text eol=crlf 15 | *.sln text eol=crlf 16 | *.vcproj text eol=crlf 17 | *.vcxproj text eol=crlf 18 | *.dsp text eol=crlf 19 | *.dsw text eol=crlf 20 | 21 | #tests 22 | tests/media/xmlin4/input.txt text eol=crlf 23 | tests/media/xmlin4/input.xml text eol=lf 24 | tests/media/laser/*.xml text eol=lf 25 | tests/media/ttml/ebu-ttd_sample.ttml text eol=lf 26 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Author: 2 | ======= 3 | Jean Le Feuvre 4 | 5 | Contributors: 6 | ============= 7 | Cyril Concolato 8 | Romain Bouqueau 9 | Pierre Souchay 10 | Viet Tran Trung Nguyen 11 | Emmanouil Potetsianakis 12 | Rodolphe Fouquet 13 | Jérôme Gorin 14 | Arash Shafiei 15 | Ivan Vecera 16 | Jean-Claude Moissinac 17 | Jean-Claude Dufourd 18 | Benoit Pellan 19 | Philippe de Cuetos 20 | Jonathan Sillan 21 | Harlina Daud 22 | Daniel Comalrena 23 | Stanislas Selle 24 | Stéphane Thomas 25 | Ayodeji Aribuki 26 | Yi-Zhen Zhang 27 | Berthele Rodriguez 28 | Yen Chi Hsuan 29 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # # 3 | # M A K E F I L E # 4 | # # 5 | ################################################################################ 6 | 7 | all: 8 | cd src ; make gpac 9 | 10 | gpac: 11 | cd src ; make gpac 12 | 13 | install: 14 | cd src ; make install 15 | 16 | clean: 17 | cd src ; make clean 18 | 19 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Thanks for reporting your issue. Please make sure these boxes are checked before submitting your issue - thank you! 2 | 3 | - [ ] I looked for a similar issue and couldn't find any. 4 | - [ ] I tried with the latest version of GPAC. Installers available at http://gpac.io/downloads/gpac-nightly-builds/ 5 | - [ ] I give enough information for contributors to reproduce my issue (meaningful title, github labels, platform and compiler, command-line ...). I can share files anonymously with this dropbox: https://www.mediafire.com/filedrop/filedrop_hosted.php?drop=eec9e058a9486fe4e99c33021481d9e1826ca9dbc242a6cfaab0fe95da5e5d95 6 | 7 | Detailed guidelines: http://gpac.io/2013/07/16/how-to-file-a-bug-properly/ 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.suo 3 | *.user 4 | *.userosscache 5 | *.sln.docstates 6 | *.userprefs 7 | *_i.c 8 | *_p.c 9 | *_i.h 10 | *.ilk 11 | *.meta 12 | *.obj 13 | *.pch 14 | *.pdb 15 | *.pgc 16 | *.pgd 17 | *.rsp 18 | *.sbr 19 | *.tlb 20 | *.tli 21 | *.tlh 22 | *.tmp 23 | *.tmp_proj 24 | *.log 25 | *.vspscc 26 | *.vssscc 27 | .builds 28 | *.pidb 29 | *.svclog 30 | *.scc 31 | *.aps 32 | *.ncb 33 | *.opensdf 34 | *.sdf 35 | *.cachefile 36 | *~ 37 | *.plg 38 | *.opt 39 | *.gcno 40 | *.gcda 41 | *.gcov 42 | *.DS_Store 43 | 44 | [Dd]ebug/ 45 | [Dd]ebugPublic/ 46 | [Rr]elease/ 47 | [Rr]eleases/ 48 | x64/ 49 | x86/ 50 | build/ 51 | bld/ 52 | [Bb]in/ 53 | [Oo]bj/ 54 | 55 | 56 | .DS_Store .AppleDouble .LSOverride 57 | 58 | *.class 59 | 60 | *.so 61 | *.dylib 62 | *.dll 63 | *.lai 64 | *.la 65 | *.a 66 | *.lib 67 | *.exe 68 | *.out 69 | *.app 70 | *.apk 71 | *.dmg 72 | *.gz 73 | *.deb 74 | 75 | .depend 76 | .deps/ 77 | 78 | .idea/ 79 | 80 | #GPAC specific 81 | config.h 82 | include/gpac/revision.h.new 83 | extra_lib/lib/ 84 | extra_lib/include/SDL/ 85 | extra_lib/include/ios/ 86 | config.mak 87 | configure-stamp 88 | gpac.pc 89 | tests/external_media/ 90 | tests/results/ 91 | 92 | -------------------------------------------------------------------------------- /include/gpac/version.h: -------------------------------------------------------------------------------- 1 | /* 2 | * GPAC - Multimedia Framework C SDK 3 | * 4 | * Authors: Jean Le Feuvre 5 | * Copyright (c) Telecom ParisTech 2012 6 | * All rights reserved 7 | * 8 | * This file is part of GPAC 9 | * 10 | * GPAC is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU Lesser General Public License as published by 12 | * the Free Software Foundation; either version 2, or (at your option) 13 | * any later version. 14 | * 15 | * GPAC is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Lesser General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public 21 | * License along with this library; see the file COPYING. If not, write to 22 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 23 | * 24 | */ 25 | 26 | #ifndef _GF_VERSION_H 27 | 28 | /*! \file "gpac/version.h" 29 | * \brief GPAC version. 30 | * 31 | */ 32 | 33 | /*! 34 | * \ingroup utils_grp 35 | * \brief GPAC version definition. 36 | * 37 | * @{ 38 | */ 39 | 40 | /*! 41 | * \brief GPAC Version 42 | * \hideinitializer 43 | * 44 | * Macro giving GPAC version expressed as a printable string 45 | */ 46 | /* KEEP SPACE SEPARATORS FOR MAKE / GREP (SEE MAIN MAKEFILE & CONFIGURE & CO) 47 | * NO SPACE in GPAC_VERSION / GPAC_FULL_VERSION for proper install 48 | * SONAME versions must be digits (not strings) 49 | */ 50 | #define GPAC_VERSION "0.6.2-DEV" 51 | #define GPAC_VERSION_MAJOR 7 52 | #define GPAC_VERSION_MINOR 5 53 | #define GPAC_VERSION_MICRO 0 54 | 55 | #include "gpac/revision.h" 56 | #define GPAC_FULL_VERSION GPAC_VERSION "-rev" GPAC_GIT_REVISION 57 | 58 | /*! @} */ 59 | 60 | #endif //_GF_VERSION_H 61 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | GPAC 2 | ==== 3 | 4 | GPAC is a multimedia framework oriented towards rich media and distributed under the LGPL license (see COPYING). 5 | 6 | GPAC supports many multimedia formats, from simple audiovisual containers (avi, mov, mpg) to complex 7 | presentation formats (MPEG-4 Systems, SVG Tiny 1.2, VRML/X3D) and 360 videos. GPAC supports presentation scripting for MPEG4/VRML/X3D through mozilla SpiderMonkey javascript engine. 8 | 9 | GPAC currently supports local playback, http progressive download, Adaptive HTTP Streaming (MPEG-DASH, HLS), RTP/RTSP streaming over UDP (unicast or multicast) or TCP and TS demuxing (from file, IP or DVB4Linux). 10 | 11 | GPAC also features MP4Box, a multimedia swiss-army knife for the prompt, and MP42TS, a fast TS multiplexer from MP4 and RTP sources. 12 | 13 | For more information, visit the GPAC website: http://gpac.io 14 | 15 | This Fork of GPAC 16 | ----------------- 17 | This fork of GPAC creates a purpose built shared library that can be leveraged to strip closed captions from Quicktime MOV Assets. 18 | 19 | To download and use the officially supported version of GPAC please visit the official Github Page: https://github.com/gpac/gpac 20 | 21 | Building the GPAC Shared Library 22 | -------------------------------- 23 | To build the shared library use the command `make gpac`. This will create a shared library called `libgpac.so` in this directory. 24 | 25 | ``` 26 | make gpac 27 | ls libgpac.so 28 | ``` 29 | To install the shared library and include files on your machine so that they can be leveraged by another app use the command `make install`. 30 | This will build the shared library as above and then move it to your `/usr/local/lib` directory. Additionally it will move the include files 31 | to your `/usr/local/include` directory. 32 | 33 | ``` 34 | make install 35 | ls /usr/local/lib | grep libgpac.so 36 | find /usr/local/include/gpac 37 | ``` 38 | 39 | To clean all of the artifacts which were generated by this build, including the ones in `/usr/local/lib` and `/usr/local/include` use the command `make clean`. 40 | 41 | 42 | ``` 43 | make clean 44 | ls /usr/local/lib | grep libgpac.so 45 | find /usr/local/include/gpac 46 | ls obj 47 | ``` 48 | 49 | -------------------------------------------------------------------------------- /doc/man/mp42avi.1: -------------------------------------------------------------------------------- 1 | .TH "MP42AVI" 1 "March 2005" "MP42AVI" "GPAC" 2 | . 3 | .SH NAME 4 | .LP 5 | MP42AVI \- MPEG-4 BIFS to Video converter 6 | .SH "SYNOPSIS" 7 | .LP 8 | .B MP42AVI 9 | .RI [options] \ file\ 10 | .br 11 | . 12 | .SH "DESCRIPTION" 13 | .LP 14 | MP42AVI is a tool to convert a pure MPEG-4 BIFS presentation (no audio, no image, no video) to an uncompressed sequence of images or an uncompressed RGB avi file. 15 | . 16 | . 17 | .SH OPTIONS 18 | .P 19 | .TP 20 | .B \-fps Framerate 21 | specifies extraction framerate. If not set the framerate is computed from the BIFS track duration. 22 | .TP 23 | .B \-size WxH 24 | forces BIFS scene size to the given resolution 25 | .TP 26 | .B \-raw [frame] 27 | uses raw format for output. If frame is specified, only the given frame is dumped. Otherwise, all samples are dumped into raw files. 28 | .TP 29 | .B \-bmp [frame] 30 | uses BMP format for output. If frame is specified, only the given frame is dumped. Otherwise, all samples are dumped into BMP files. 31 | .TP 32 | .B \-outpath path 33 | specifies output directory to dump frames/movie. 34 | .TP 35 | .B \-cfg 36 | specifies path to GPAC config file. 37 | .TP 38 | .B \-v 39 | prints build version. 40 | .TP 41 | .B \-h 42 | prints this message 43 | . 44 | .SH SPECIAL CONSIDERATIONS 45 | .TP 46 | .B Frame Dumping 47 | When dumping a frame, either the frame number (sample number) can be specified or the frame time 48 | in the format hh:mm:ss:xFz where hh, mm, ss are hours, minutes, seconds, x the number 49 | of the frame in the seconds and z the frame rate used to express the time 50 | .TP 51 | .br 52 | .B Input Files 53 | The current version of MP42AVI is only designed to handle pure BIFS presentation. If the input BIFS scene uses audio or visual media, these are ignored during the dump. It may even crash MP42AVI. 54 | .TP 55 | .B GPAC Config File 56 | MP42AVI needs the GPAC configuration file in order to locate the different plugins used for rasterization. You must therefore have launched successfully MP4Client before trying to use MP42AVI 57 | . 58 | .SH "FILES" 59 | .LP 60 | .B GPAC Configuration File: 61 | ~/.gpacrc 62 | . 63 | .SH "AUTHORS" 64 | .LP 65 | Jean Le Feuvre - GPAC (c) 2000-2005 66 | . 67 | .SH "SEE ALSO" 68 | .LP 69 | MP4Client(1), MP4Box(1), GPAC(1) 70 | -------------------------------------------------------------------------------- /include/gpac/internal/odf_parse_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * GPAC - Multimedia Framework C SDK 3 | * 4 | * Authors: Jean Le Feuvre 5 | * Copyright (c) Telecom ParisTech 2000-2012 6 | * All rights reserved 7 | * 8 | * This file is part of GPAC / MPEG-4 ObjectDescriptor sub-project 9 | * 10 | * GPAC is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU Lesser General Public License as published by 12 | * the Free Software Foundation; either version 2, or (at your option) 13 | * any later version. 14 | * 15 | * GPAC is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Lesser General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public 21 | * License along with this library; see the file COPYING. If not, write to 22 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 23 | * 24 | */ 25 | 26 | 27 | #ifndef _GF_OD_PARSE_COMMON_H_ 28 | #define _GF_OD_PARSE_COMMON_H_ 29 | #include "gpac/setup.h" 30 | 31 | #define GET_U8(field) { u32 d; if (strstr(val, "0x")) { ret += sscanf(val, "%x", &d); if (ret) field = (u8) d; } else { ret += sscanf(val, "%u", &d); if (ret) field = (u8) d; } } 32 | #define GET_U16(field) { u16 d; if (strstr(val, "0x")) { ret += sscanf(val, "%hx", &d); if (ret) field = d; } else { ret += sscanf(val, "%hu", &d); if (ret) field = d; } } 33 | #define GET_S16(field) { s16 d; if (strstr(val, "0x")) { ret += sscanf(val, "%hx", (u16*)&d); if (ret) field = d; } else { ret += sscanf(val, "%hd", &d); if (ret) field = d; } } 34 | #define GET_U32(field) { u32 d; if (strstr(val, "0x")) { ret += sscanf(val, "%x", &d); if (ret) field = d; } else { ret += sscanf(val, "%ud", &d); if (ret) field = d; } } 35 | #define GET_S32(field) { s32 d; if (strstr(val, "0x")) { ret += sscanf(val, "%x", (u32*)&d); if (ret) field = d; } else { ret += sscanf(val, "%d", &d); if (ret) field = d; } } 36 | #define GET_BOOL(field) { ret = 1; field = (!stricmp(val, "true") || !stricmp(val, "1")) ? GF_TRUE : GF_FALSE; } 37 | #define GET_U64(field) { u64 d; if (strstr(val, "0x")) { ret += sscanf(val, LLX, &d); if (ret) field = d; } else { ret += sscanf(val, LLU, &d); if (ret) field = d; } } 38 | 39 | #define GET_DOUBLE(field) { Float v; ret = 1; sscanf(val, "%f", &v); field = (Double) v;} 40 | #define GET_STRING(field) { ret = 1; field = gf_strdup(val); if (val[0] == '"') strcpy(field, val+1); if (field[strlen(field)-1] == '"') field[strlen(field)-1] = 0; } 41 | 42 | 43 | #endif /* _GF_OD_PARSE_COMMON_H_ */ 44 | 45 | -------------------------------------------------------------------------------- /INSTALLME: -------------------------------------------------------------------------------- 1 | Installation instructions for latest GPAC GIT version - March 2015: 2 | 3 | For Windows, Linux and Mac OS X versions, follow the instructions on http://gpac.io/downloads/ 4 | 5 | For Android, follow the instructions in gpac/build/android/README 6 | 7 | (WindowsMobile platform is no longer maintained) 8 | For WindowsMobile platform, get the latest package of gpac extra libs available here: 9 | 10 | https://sourceforge.net/p/gpac/code/HEAD/tree/trunk/gpac_extra_libs/ 11 | 12 | and follow the instructions in gpac/doc/INSTALL.wCE 13 | 14 | 15 | 16 | Other Installation instructions for GPAC 17 | 18 | 19 | * Foreword 20 | 21 | GPAC may be compiled without any third party libraries, but in this case its functionalities are very 22 | limited (no still image, no audio, no video, no text, no scripting). It is therefore recommended to download the 23 | extra lib package available at http://sourceforge.net/projects/gpac. Compilation instructions for these libraries 24 | are provided per library in the package. 25 | 26 | The current extra_lib package to use with gpac is gpac_extra_libs available here: 27 | http://download.tsi.telecom-paristech.fr/gpac/gpac_extra_libs.zip 28 | 29 | In case you have some of these libs already installed on your system, the detailed list of dependencies is 30 | * freetype2 from version 2.1.4 on. 31 | * SpiderMonkey v1.7 (libjs from mozilla). 32 | * libjpg version 6b 33 | * Libpng version 1.2.33 (older versions should work) 34 | * MAD version 0.15.1b (older versions should work) 35 | * xvid version 1.0 (0.9.0 / .1 / .2 should also work) 36 | * ffmpeg (latest stable API version checked was 17 February 2016 snapshot, you may need to change a few things with current versions) 37 | * libogg 1.1, libvorbis 1.1 and libtheora 1.0 from Xiph.org (newer versions work) 38 | * faad2, version 2.0 or above (2.6.1 working) 39 | * liba52, version 0.7.4 40 | * OpenJPEG, version 1.3 41 | * OpenSVCDecoder, version 1.3 42 | 43 | * Installing GPAC 44 | 45 | /!\ GPAC won't compile if the 'git' command is not in your path /!\ 46 | 47 | !! WARNING !! 48 | The following instructions may not be completely up to data 49 | You should use online instructions which may be more up-to-date: 50 | http://gpac.io/2011/04/18/command-line-gpac-compiling-on-windows-x86-using-free-microsoft-visual-c/ 51 | 52 | Detailed instruction for Win32 MSVC Compilation are available in gpac/doc/INSTALL.w32 53 | 54 | Detailed instruction for WinCE eVC Compilation are available in gpac/doc/INSTALL.wCE 55 | 56 | Detailed instruction for GCC Compilation are available in gpac/doc/INSTALL.gcc 57 | 58 | Detailed instruction for GCC cross-compilation for familiar+GPE systems are available in gpac/doc/INSTALL.gpe 59 | 60 | Detailed instruction for GCCE/Symbian cross-compilation for Symbian v9.1 systems are available in gpac/doc/INSTALL.symbian 61 | 62 | Detailed instruction for iOS Compilation are available in gpac/build/xcode/README_IOS.txt 63 | 64 | * Configuring GPAC 65 | 66 | GPAC's client configuration is documented in gpac/doc/configuration.html 67 | MP4Box documentation is available online at http://gpac.sourceforge.net 68 | -------------------------------------------------------------------------------- /src/Makefile: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # # 3 | # M A K E F I L E # 4 | # # 5 | ################################################################################ 6 | 7 | GPACLIB_NAME = libgpac.so 8 | 9 | UNAME := $(shell uname) 10 | 11 | OBJS = av_parsers.o \ 12 | avc_ext.o \ 13 | avilib.o \ 14 | base_encoding.o \ 15 | bitstream.o \ 16 | box_code_3gpp.o \ 17 | box_code_adobe.o \ 18 | box_code_apple.o \ 19 | box_code_base.o \ 20 | box_code_drm.o \ 21 | box_code_meta.o \ 22 | box_funcs.o \ 23 | configfile.o \ 24 | data_map.o \ 25 | desc_private.o \ 26 | descriptors.o \ 27 | drm_sample.o \ 28 | error.o \ 29 | gpac_ogg.o \ 30 | hinting.o \ 31 | ipmpx_code.o \ 32 | ipmpx_parse.o \ 33 | isom_intern.o \ 34 | isom_read.o \ 35 | isom_store.o \ 36 | isom_write.o \ 37 | list.o \ 38 | math.o \ 39 | media.o \ 40 | media_odf.o \ 41 | meta.o \ 42 | movie_fragments.o \ 43 | odf_code.o \ 44 | odf_codec.o \ 45 | odf_command.o \ 46 | os_config_init.o \ 47 | os_divers.o \ 48 | os_file.o \ 49 | qos.o \ 50 | sample_descs.o \ 51 | slc.o \ 52 | stbl_read.o \ 53 | stbl_write.o \ 54 | track.o \ 55 | tx3g.o \ 56 | url.o \ 57 | utf.o 58 | OBJS_WITH_PATH = $(foreach OBJS, $(OBJS), ./$(OBJS)) 59 | OBJS_IN_OBJ_DIR = $(foreach OBJS, $(OBJS), ../obj/$(OBJS)) 60 | 61 | ifeq ($(UNAME), Linux) 62 | C_FLAGS = -Wpedantic -Wno-deprecated-declarations -Wall -fno-strict-aliasing -fPIC -DPIC -DGPAC_CONFIG_LINUX -DGPAC_DISABLE_3D -DGPAC_64_BITS 63 | SO_FLAGS = -shared -W -L/usr/local/lib 64 | LD_FLAGS = -L/usr/local/lib -lm -lz 65 | else 66 | C_FLAGS = -Wpedantic -Wno-deprecated-declarations -DGPAC_CONFIG_DARWIN -D_FILE_OFFSET_BITS=64 -DVERSION_FILE_PRESENT -Dfopen64=fopen -Dopen64=open -Dlseek64=lseek 67 | SO_FLAGS = -dynamiclib -undefined suppress -flat_namespace -L/usr/local/lib 68 | LD_FLAGS = -L/usr/local/lib -lz 69 | endif 70 | 71 | -include ../obj/$(OBJS:.o=.d) 72 | 73 | all: gpac 74 | 75 | gpac: $(OBJS_WITH_PATH) 76 | clang $(SO_FLAGS) -o ../${GPACLIB_NAME} $(OBJS_IN_OBJ_DIR) 77 | 78 | install: gpac 79 | cp ../${GPACLIB_NAME} /usr/local/lib/${GPACLIB_NAME} 80 | cp -r ../include/gpac /usr/local/include 81 | 82 | clean: 83 | @echo "*** Cleaning Target Files. ***" 84 | rm -f ../$(GPACLIB_NAME) 85 | rm -f /usr/local/lib/$(GPACLIB_NAME) 86 | rm -rf /usr/local/include/gpac 87 | @echo "\n*** Cleaning Object Files. ***" 88 | for i in $(OBJS) ; do ( rm -f ../obj/$$i ) ; done 89 | @echo "\n*** Cleaning Dependency Files. ***" 90 | for i in $(OBJS:.o=.d) ; do ( rm -f ../obj/$$i ) ; done 91 | 92 | %.o: %.c 93 | @if ! [ -d "../obj" ]; then mkdir ../obj; fi 94 | clang -c $(C_FLAGS) -I ../include $*.c -o ../obj/$(notdir $*.o) 95 | clang -MM $(C_FLAGS) -I ../include $*.c > ../obj/$(notdir $*.d) 96 | -------------------------------------------------------------------------------- /include/gpac/base_coding.h: -------------------------------------------------------------------------------- 1 | /* 2 | * GPAC - Multimedia Framework C SDK 3 | * 4 | * Authors: Jean Le Feuvre 5 | * Copyright (c) Telecom ParisTech 2000-2012 6 | * All rights reserved 7 | * 8 | * This file is part of GPAC / common tools sub-project 9 | * 10 | * GPAC is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU Lesser General Public License as published by 12 | * the Free Software Foundation; either version 2, or (at your option) 13 | * any later version. 14 | * 15 | * GPAC is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Lesser General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public 21 | * License along with this library; see the file COPYING. If not, write to 22 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 23 | * 24 | */ 25 | 26 | #ifndef _GF_BASE_CODING_H_ 27 | #define _GF_BASE_CODING_H_ 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | /*! 34 | * \file 35 | * \brief Base 16 and 64 coding. 36 | */ 37 | 38 | /*! 39 | * \addtogroup bascod_grp Base coding 40 | * \ingroup utils_grp 41 | * \brief Base 16 and 64 coding 42 | * 43 | * This section documents the base encoding and decoding functions of the GPAC framework. 44 | * @{ 45 | */ 46 | 47 | #include "gpac/tools.h" 48 | 49 | #ifndef GPAC_DISABLE_CORE_TOOLS 50 | 51 | /*! 52 | *\brief base64 encoder 53 | * 54 | *Encodes a data buffer to Base64 55 | *\param in_buffer input data buffer 56 | *\param in_buffer_size input data buffer size 57 | *\param out_buffer output Base64 buffer location 58 | *\param out_buffer_size output Base64 buffer allocated size 59 | *\return size of the encoded Base64 buffer 60 | *\note the encoded data buffer is not NULL-terminated. 61 | */ 62 | u32 gf_base64_encode(const char *in_buffer, u32 in_buffer_size, char *out_buffer, u32 out_buffer_size); 63 | /*! 64 | *\brief base64 decoder 65 | * 66 | *Decodes a Base64 buffer to data 67 | *\param in_buffer input Base64 buffer 68 | *\param in_buffer_size input Base64 buffer size 69 | *\param out_buffer output data buffer location 70 | *\param out_buffer_size output data buffer allocated size 71 | *\return size of the decoded buffer 72 | */ 73 | u32 gf_base64_decode(char *in_buffer, u32 in_buffer_size, char *out_buffer, u32 out_buffer_size); 74 | 75 | /*! 76 | *\brief base16 encoder 77 | * 78 | *Encodes a data buffer to Base16 79 | *\param in_buffer input data buffer 80 | *\param in_buffer_size input data buffer size 81 | *\param out_buffer output Base16 buffer location 82 | *\param out_buffer_size output Base16 buffer allocated size 83 | *\return size of the encoded Base16 buffer 84 | *\note the encoded data buffer is not NULL-terminated. 85 | */ 86 | u32 gf_base16_encode(char *in_buffer, u32 in_buffer_size, char *out_buffer, u32 out_buffer_size); 87 | 88 | /*! 89 | *\brief base16 decoder 90 | * 91 | *Decodes a Base16 buffer to data 92 | *\param in_buffer input Base16 buffer 93 | *\param in_buffer_size input Base16 buffer size 94 | *\param out_buffer output data buffer location 95 | *\param out_buffer_size output data buffer allocated size 96 | *\return size of the decoded buffer 97 | */ 98 | u32 gf_base16_decode(char *in_buffer, u32 in_buffer_size, char *out_buffer, u32 out_buffer_size); 99 | 100 | /*! @} */ 101 | 102 | #ifdef __cplusplus 103 | } 104 | #endif 105 | 106 | #endif /*GPAC_DISABLE_CORE_TOOLS*/ 107 | 108 | #endif /*_GF_BASE_CODING_H_*/ 109 | -------------------------------------------------------------------------------- /include/gpac/utf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * GPAC - Multimedia Framework C SDK 3 | * 4 | * Authors: Jean Le Feuvre 5 | * Copyright (c) Telecom ParisTech 2000-2012 6 | * All rights reserved 7 | * 8 | * This file is part of GPAC / common tools sub-project 9 | * 10 | * GPAC is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU Lesser General Public License as published by 12 | * the Free Software Foundation; either version 2, or (at your option) 13 | * any later version. 14 | * 15 | * GPAC is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Lesser General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public 21 | * License along with this library; see the file COPYING. If not, write to 22 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 23 | * 24 | */ 25 | 26 | #ifndef _GF_UTF_H_ 27 | #define _GF_UTF_H_ 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | /*! 34 | * \file 35 | * \brief UTF functions. 36 | */ 37 | 38 | /*! 39 | * \addtogroup uni_grp 40 | * \ingroup utfuni_grp 41 | * \brief UTF encoding functions 42 | * 43 | *This section documents the UTF functions of the GPAC framework.\n 44 | *The wide characters in GPAC are unsignad shorts, in other words GPAC only supports UTF8 and UTF16 coding styles. 45 | *\note these functions are just ports of libutf8 library tools into GPAC. 46 | * @{ 47 | */ 48 | 49 | #include "gpac/tools.h" 50 | 51 | /*! 52 | *\brief wide-char to multibyte conversion 53 | * 54 | *Converts a wide-char string to a multibyte string 55 | *\param dst multibyte destination buffer 56 | *\param dst_len multibyte destination buffer size 57 | *\param srcp address of the wide-char string. This will be set to the next char to be converted in the input buffer if not enough space in the destination, or NULL if conversion was completed. 58 | *\return length (in byte) of the multibyte string or -1 if error. 59 | */ 60 | size_t gf_utf8_wcstombs(char* dst, size_t dst_len, const unsigned short** srcp); 61 | /*converts UTF8 string to wide char string - returns (-1) if error. set @srcp to next char to be 62 | converted if not enough space*/ 63 | /*! 64 | *\brief multibyte to wide-char conversion 65 | * 66 | *Converts a multibyte string to a wide-char string 67 | *\param dst wide-char destination buffer 68 | *\param dst_len wide-char destination buffer size 69 | *\param srcp address of the multibyte character buffer. This will be set to the next char to be converted in the input buffer if not enough space in the destination, or NULL if conversion was completed. 70 | *\return length (in unsigned short) of the wide-char string or -1 if error. 71 | */ 72 | size_t gf_utf8_mbstowcs(unsigned short* dst, size_t dst_len, const char** srcp); 73 | /*! 74 | *\brief wide-char string length 75 | * 76 | *Returns the length in character of a wide-char string 77 | *\param s the wide-char string 78 | *\return the wide-char string length 79 | */ 80 | size_t gf_utf8_wcslen(const unsigned short *s); 81 | 82 | /*! 83 | *\brief string bidi reordering 84 | * 85 | *Performs a simple reordering of words in the string based on each word direction, so that glyphs are sorted in display order. 86 | *\param utf_string the wide-char string 87 | *\param len the len of the wide-char string 88 | *\return 1 if the main direction is right-to-left, 0 otherwise 89 | */ 90 | Bool gf_utf8_reorder_bidi(u16 *utf_string, u32 len); 91 | 92 | static const size_t UTF8_MAX_BYTES_PER_CHAR = 4; 93 | 94 | /*! @} */ 95 | 96 | #ifdef __cplusplus 97 | } 98 | #endif 99 | 100 | 101 | #endif /*_GF_UTF_H_*/ 102 | 103 | -------------------------------------------------------------------------------- /doc/INSTALL.symbian: -------------------------------------------------------------------------------- 1 | Installation instructions for GPAC 0.4.5 on Symbian 9.1 (S60 3rd Edition) platform 2 | last modified: December 2008 3 | 4 | 0 Foreword 5 | ! GPAC versions later than 0.4.5 are no longer supported on Symbian ! 6 | 7 | Compilation has only been tested with GCCE & Nokia S60 SDK 8 | In order to fully compile, you must get: 9 | - the complete S60 3rd edition SDK (maintainance release) 10 | - the MMF SDK update 11 | 12 | IMPORTANT NOTE: 13 | You must install the SDK and the code you will compile with it (be it GPAC or anything else) 14 | !! ON THE SAME LOGICAL DRIVE !! 15 | If you do not do so, compilation will simply fail due to some misbehavior of the SDK's environment variables. 16 | 17 | 18 | What is currently supported on symbian: 19 | * all GPAC core, with audio and video output 20 | * MP4 demux, AAC demux, MP3 demux, AMR demux 21 | * native audio media codec from the phone through MMF: AAC and AMR 22 | * MPEG-4 ASP video decoding through xvid 23 | * JPEG and PNG decoding through libjpeg and libpng 24 | * MP3 decoding through MAD 25 | * TrueType fonts through FreeType 26 | * Scripting with JS32 (not fully tested yet) 27 | * FFMPEG (not really stable, random crashes) 28 | 29 | What is currently NOT supported on symbian: 30 | * networking 31 | 32 | TIP: 33 | Global compiler options are located in SDKRoot\Epoc32\tools\compilation_config\ - you may edit the default C++ rules to remove some 34 | warnings during C compil. 35 | 36 | Side notes: 37 | several SDKs may coexist on the drive. 38 | * To see the list of SDKs, at DOS prompt, c:\devices 39 | * To change the default SDK, at DOS prompt, c:\devices -setdefault @sdk_name 40 | you may need to exit prompt and start a new one in order to refresh environment variables. 41 | GPAC should compile on EKA2 (Symbian OS v8.0b, v8.1b). 42 | GPAC CANNOT COMPILE ON EKA1 (Symbian OS v6.1, v7.0, v7.0s, v8.0a v8.1a) because EKA1 does not support writable static data in DLLs 43 | 44 | I Extra lib installation 45 | Please follow the instructions in gpac_extra_lib/00_README_FIRST 46 | 47 | II GPAC compilation 48 | 49 | Go to gpac/build/symbian 50 | 51 | II.1 Configuring extra libs 52 | * If you don't have libjs, libpng or libjpeg for symbian, comment indicated lines in libgpac.mmp (change #if 1 into #if 0) 53 | * If you don't have OpenGL ES for symbian, comment indicated lines in libgpac.mmp (change #if 1 into #if 0) 54 | * If you don't have freetype for symbian, comment ft_font.mmp in file bld.inf 55 | * If you don't have ffmpeg for symbian, comment ffmpeg_in.mmp in file bld.inf 56 | * If you don't have libmad for symbian, comment indicated lines in mp3_in.mmp 57 | * If you don't have libopenjpeg (JPEG 2000) for symbian, comment indicated lines in img_in.mmp (change #if 1 into #if 0) 58 | 59 | II.2 Compiling GPAC 60 | cd gpac/build/symbian 61 | bldmake bldfiles 62 | * for GCCE 63 | abld build gcce urel 64 | * for thumb 65 | abld build thumb urel 66 | cd sis 67 | set EPOCROOT=\path\to\epoc\root\ 68 | * for GCCE 69 | makesis -d%EPOCROOT% osmo4_gcce.pkg 70 | signsis osmo4_gcce.SIS osmo4_gcce.SIS gpac.cer gpac.key password 71 | * for THUMB 72 | makesis -d%EPOCROOT% osmo4_thumb.pkg 73 | 74 | Note: If you need to sign the SIS with your own certificate, you may generate one with openssl: 75 | openssl req -new -x509 -nodes -sha1 -days 3650 -key gpac.key > gpac.cer 76 | 77 | You will get a .SIS package that installs properly on a symbian device. 78 | NOTES: 79 | * The app and plugins are all installed in \sys\bin on the device. DO NOT change this path, since it won't work otherwise (due to symbian 9.1 caged data stuff) 80 | * If you create/succeed to compile a new plugin for GPAC, you must: 81 | - edit build/symbian/sis/osmo4_gcce.pkg to add your plugin in the installer 82 | - edit build/symbian/sis/GPAC.cfg to instruct the player of this new plugin (enumeration of DLLs on Symbian 9.1 is just not possible without a good amount of $$) 83 | 84 | 85 | -------------------------------------------------------------------------------- /doc/SceneGenerators: -------------------------------------------------------------------------------- 1 | GPAC Scene Graph generator documentation - v0.4.0 2 | 3 | Last Modified: July 2005 4 | 5 | 6 | 7 | 0 - Foreword 8 | 9 | 10 | 11 | The sets (MPEG4, X3D and SVG) of nodes handled by the GPAC are genrated through "Scene Generators" applications: 12 | 13 | applications/generators/MPEG4 for MPEG4 along with the official MPEG-4 template files needed to generate nodes and their encoding tables. 14 | 15 | applications/generators/X3D for X3D along with the X3D template file needed to generate nodes. 16 | 17 | applications/generators/SVG for SVG along with the SVG template. 18 | 19 | 20 | 21 | MPEG-4 Template files are numbered by versions of amendments to the MPEG-4 systems standard. 22 | 23 | X3D and SVG templates do not have versionning. 24 | 25 | 26 | 27 | 1 - Regenerating the scene graph 28 | 29 | 30 | 31 | First recompile the appropriated scene generator application. You don't need to recompile GPAC to recompile it. 32 | 33 | The generators DIRECTLY overwrites source code files in the GPAC distribution, you MUST NOT try to run it from a different 34 | 35 | location than gpac/applications/generators/* 36 | 37 | 38 | 39 | For MPEG-4 you must provide MPEG4Gen with the set of template files. For example, if you're planning to use only nodes defined in the 40 | 41 | first version of the standard (1998) described in templates1.txt file, just type: 42 | 43 | 44 | 45 | MPEG4Gen templates1.txt 46 | 47 | 48 | 49 | Template files MUST be fed in order, and versions cannot be skipped: you SHALL NOT try to generate version1 and version3 without version2. 50 | 51 | To generate a scene graph handling v1 to v3 of the BIFS system, type: 52 | 53 | MPEG4Gen templates1.txt templates2.txt templates3.txt 54 | 55 | 56 | 57 | For X3D, simply run X3DGen, it will automatically load the "templates_X3D.txt" file 58 | 59 | For SVG, simply run SVGGen completesvgt12rng.xml 60 | 61 | 62 | 63 | 64 | 65 | 2 - Customizing the scene graph 66 | 67 | 68 | 69 | As of 0.2.2, all nodes in current gpac version are supported by renderers and cannot be removed. You will therefore have to REMOVE some code in the renderers 70 | 71 | and the scene graph in order to recompile GPAC. You should therefore not try to customize the scene graph unless you know what you're doing. 72 | 73 | 74 | 75 | 2.1 - Customizing the MPEG-4 scene graph 76 | 77 | 78 | 79 | As said above, it is not possible to skip a BIFS version when regenerating the scene graph since this will break binary encoding of the nodes. 80 | 81 | However MPEG4Gen allows you to specify which nodes should be supported or not in the scene graph. This is currently specified 82 | 83 | with a simple text file where unwanted nodes are listed one by line ('#' acting as a line comment). The file is specified by 84 | 85 | the "-p " switch 86 | 87 | 88 | 89 | For example, generating a scene graph for BIFS V1 without support for the BIFS audio nodes will be: 90 | 91 | MPEG4Gen -p skip_audio.txt templates1.txt 92 | 93 | 94 | 95 | and the content of skip_audio.txt file will be 96 | 97 | 98 | 99 | AudioBuffer 100 | 101 | AudioClip 102 | 103 | AudioDelay 104 | 105 | AudioFX 106 | 107 | AudioMix 108 | 109 | AudioSwitch 110 | 111 | AudioSource 112 | 113 | 114 | 115 | 2.2 - Customizing the X3D scene graph 116 | 117 | 118 | 119 | X3DGen uses the same mechanism as MPEG4Gen for node skinpping, eg: X3DGen skipfile 120 | 121 | 122 | 123 | 2.3 - Customizing the SVG scene graph 124 | 125 | 126 | 127 | This is undocumented and probably not supported 128 | 129 | 130 | 131 | 3 - Advanced Manupulations 132 | 133 | 134 | 135 | It is possible to develop custom templates. The resulting encoding/decoding will not be compliant with MPEG-4 BIFS but it can 136 | 137 | be interesting to see how a single-version mechanism with only the desired nodes reduces applications and bitstreams sizes 138 | 139 | To write your own templates, you must: 140 | 141 | follow the syntax of regular templates 142 | 143 | make sure the SFWorldNode type is defined and used by all nodes (needed for BIFS updates) 144 | 145 | make sure at least one node will be of type SFTopNode (needed for BIFS Scene Replace command) 146 | 147 | 148 | 149 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | compiler: gcc 3 | os: 4 | - linux 5 | - osx 6 | before_install: 7 | - if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get -y update -qq ; fi 8 | install: 9 | - if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get -y install build-essential fakeroot dpkg-dev devscripts ccache debhelper pkg-config g++ mesa-utils ; fi 10 | - if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get -y install -y zlib1g-dev libfreetype6-dev libjpeg62-dev libpng12-dev libopenjpeg-dev libmad0-dev libfaad-dev libogg-dev libvorbis-dev libtheora-dev liba52-0.7.4-dev libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libavdevice-dev libxv-dev x11proto-video-dev libgl1-mesa-dev x11proto-gl-dev linux-sound-base libxvidcore-dev libssl-dev libjack-dev libasound2-dev libpulse-dev libsdl1.2-dev dvb-apps libavcodec-extra libavutil-dev libmozjs185-dev ; fi 11 | - if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get -y install -y gcc-mingw-w64-i686 g++-mingw-w64-i686 binutils-mingw-w64-i686 gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 binutils-mingw-w64-x86-64 mingw-w64-x86-64-dev ; fi 12 | - if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get -qq -y install lcov time; fi 13 | # - if [ "$TRAVIS_OS_NAME" == "osx" ]; then sudo chown -R "$USER":admin /usr/local; fi 14 | - if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew update; fi 15 | - if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew install gnu-time gnu-sed gnu-tar xz lcov ; fi 16 | - if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew install faad2 sdl freetype libvorbis theora openjpeg libmad xvid libogg spidermonkey ffmpeg ; fi 17 | env: 18 | - GPAC_CONFIGURE_OPTIONS="--prefix=build/mp4box --enable-debug --static-mp4box" GPAC_CONFIGURE_ECFLAGS="" DOINSTALL="make install" DOTRAVIS="" 19 | - GPAC_CONFIGURE_OPTIONS="--enable-debug --static-modules" GPAC_CONFIGURE_ECFLAGS="" DOINSTALL="" DOTRAVIS="" 20 | - GPAC_CONFIGURE_OPTIONS="--enable-debug --enable-static-bin" GPAC_CONFIGURE_ECFLAGS="" DOINSTALL="" DOTRAVIS="" 21 | matrix: 22 | include: 23 | - os: linux 24 | before_script: 25 | - "export DISPLAY=:99.0" 26 | - "sh -e /etc/init.d/xvfb start" 27 | - sleep 3 # give xvfb some time to start 28 | - glxinfo # check glx status 29 | env: GPAC_CONFIGURE_OPTIONS="--enable-mem-track --enable-gcov" GPAC_CONFIGURE_ECFLAGS="" DOINSTALL="sudo make install" DOTRAVIS="make travis" AUDIODEV=null 30 | - os: linux 31 | env: GPAC_CONFIGURE_OPTIONS="--prefix=build/x86_64-w64-mingw32 --enable-debug --static-mp4box --use-zlib=no --target-os=mingw32 --cross-prefix=i686-w64-mingw32- --extra-ldflags=-Lbuild/x86_64-w64-mingw32/lib" GPAC_CONFIGURE_ECFLAGS="-Ibuild/x86_64-w64-mingw32/include -w -fPIC" DOINSTALL="" DOTRAVIS="" 32 | - os: linux 33 | env: GPAC_CONFIGURE_OPTIONS="--prefix=build/x86_64-w64-mingw32 --enable-debug --static-mp4box --use-zlib=no --target-os=mingw32 --cross-prefix=x86_64-w64-mingw32- --extra-ldflags=-Lbuild/x86_64-w64-mingw32/lib" GPAC_CONFIGURE_ECFLAGS="-Ibuild/x86_64-w64-mingw32/include -w -fPIC" DOINSTALL="" DOTRAVIS="" 34 | - os: linux 35 | env: GPAC_CONFIGURE_OPTIONS="--prefix=build/all --enable-debug --disable-all" GPAC_CONFIGURE_ECFLAGS="" DOINSTALL="make install" DOTRAVIS="" 36 | - os: linux 37 | env: GPAC_CONFIGURE_OPTIONS="--enable-debug --use-js=no --use-mad=no --use-xvid=no --use-ogg=no --use-vorbis=no --use-theora=no --use-openjpeg=no --disable-streaming --disable-isoff-frag --disable-isoff-hint --disable-isoff-write --disable-loader-xmt --disable-loader-bt --disable-loader-isoff --disable-scene-encode --disable-mcrypt --disable-od-dump --disable-scene-dump --disable-scene-stats --disable-swf --disable-export --disable-import --disable-m2ps --disable-ogg -disable-avi --disable-qtvr --disable-seng --disable-smgr --disable-x3d --disable-3d --disable-ssl --disable-jack --disable-pulse --use-a52=no --disable-odf --disable-isoff --disable-m2ts-mux --disable-dvbx --disable-saf --disable-vobsub --disable-ttxt --disable-od-parse --disable-atsc" GPAC_CONFIGURE_ECFLAGS="" DOINSTALL="" DOTRAVIS="" 38 | - os: osx 39 | env: GPAC_CONFIGURE_OPTIONS="--enable-mem-track" GPAC_CONFIGURE_ECFLAGS="" DOINSTALL="sudo make install" DOTRAVIS="" AUDIODEV=null 40 | script: 41 | - ./configure --extra-cflags=''"$GPAC_CONFIGURE_ECFLAGS"'' $GPAC_CONFIGURE_OPTIONS && make && $DOINSTALL && $DOTRAVIS 42 | after_success: 43 | - if [ "$TRAVIS_OS_NAME" == "linux" ]; then bash <(curl -s https://codecov.io/bash) ; fi 44 | 45 | notifications: 46 | email: 47 | recipients: 48 | - travisci@gpac.io 49 | 50 | -------------------------------------------------------------------------------- /doc/man/dashcast.1: -------------------------------------------------------------------------------- 1 | .TH DASHCAST "1" "July 2015" "DashCast" "GPAC" 2 | 3 | .SH NAME 4 | DashCast - MPEG-4 Systems Framework and Software Development Kit 5 | 6 | .SH SYNOPSIS 7 | .B DashCast 8 | .RI [options] 9 | 10 | .SH OPTIONS 11 | .SS "General options" 12 | .TP 13 | \fB\-log-file \fRfilename 14 | set output log file. Also works with -lf 15 | .TP 16 | \fB\-logs \fRLOGS 17 | set log tools and levels, formatted as a ':'-separated list of toolX[:toolZ]@levelX 18 | .TP 19 | \fB\-conf \fRfilename 20 | set the configuration file name (default: dashcast.conf) 21 | .TP 22 | \fB\-switch-source \fRfilename 23 | set the configuration file name for source switching 24 | 25 | .SS "Live options" 26 | .TP 27 | \fB\-live 28 | system is live and input is a camera 29 | .TP 30 | \fB\-live-media 31 | system is live and input is a media file 32 | .TP 33 | \fB\-no-loop 34 | system does not loop on the input media file when live 35 | .TP 36 | \fB\-dynamic-ast 37 | changes segment availability start time at each MPD generation (old behaviour but not allowed in most profiles) 38 | .TP 39 | \fB\-insert-utc 40 | inserts UTC clock at the start of each segment 41 | 42 | .SS "Source options" 43 | .TP 44 | \fB\-npts 45 | use frame counting for timestamps (not error-free) instead of source timing (default) 46 | .TP 47 | \fB\-av \fRstring 48 | set the source name for a multiplexed audio and video input. 49 | If this option is present, neither '-a' nor '-v' shall be present. 50 | .TP 51 | \fB\-v \fRstring 52 | set the source name for a video input. 53 | If input is from a webcam, use "/dev/video[x]" where x is the video device number. 54 | If input is the screen video, use ":0.0+[x],[y]" which captures from upper-left at x,y. 55 | If input is from stdin, use "pipe:". 56 | .TP 57 | \fB\-vf \fRstring 58 | set the input video format. 59 | To capture from a webcam, set video4linux2. 60 | To capture the screen, set x11grab. 61 | .TP 62 | \fB\-v4l2f \fRinv4l2f 63 | inv4l2f is the input format for webcam acquisition. 64 | It can be mjpeg, yuyv422, etc. 65 | .TP 66 | \fB\-pixf \fRFMT 67 | set the input pixel format 68 | .TP 69 | \fB\-vfr \fRN 70 | force the input video framerate 71 | .TP 72 | \fB\-vres \fRWxH 73 | force the video resolution (e.g. 640x480) 74 | .TP 75 | \fB\-vcrop \fRXxY 76 | crop the source video from X pixels left and Y pixels top. Must be used with -vres. 77 | .TP 78 | \fB\-a \fRstring 79 | set the source name for an audio input. 80 | If input is from microphone, use "plughw:[x],[y]" where x is the card number and y is the device number 81 | .TP 82 | \fB\-af \fRstring 83 | set the input audio format 84 | 85 | .SS "Output options" 86 | .TP 87 | \fB\-vcodec \fRstring 88 | set the output video codec (default: h264) 89 | .TP 90 | \fB\-vcustom \fRstring 91 | send custom parameters directly to the video encoder 92 | .TP 93 | \fB\-gdr 94 | use Gradual Decoder Refresh feature for video encoding (h264 codec only) 95 | .TP 96 | \fB\-gop 97 | specify GOP size in frames - default is framerate (1 sec gop) 98 | .TP 99 | \fB\-low-delay 100 | specify that low delay settings should be used (no B-frames, fast encoding) 101 | .TP 102 | \fB\-acodec \fRstring 103 | set the output audio codec (default: aac) 104 | .TP 105 | \fB\-acustom \fRstring 106 | send custom parameters directly to the audio encoder 107 | 108 | .SS "DASH options" 109 | .TP 110 | \fB\-seg-dur \fRdur:int 111 | set the segment duration in millisecond (default value: 1000) 112 | .TP 113 | \fB\-frag \fRdur:int 114 | set the fragment duration in millisecond (default value: 1000) (same as -frag-dur) 115 | .TP 116 | \fB\-seg-marker \fRmarker:4cc 117 | add a marker box named marker at the end of DASH segment 118 | .TP 119 | \fB\-out \fRoutdir:str 120 | outdir is the output data directory (default: output) 121 | .TP 122 | \fB\-mpd \fRmpdname:str 123 | mpdname is the MPD file name (default: dashcast.mpd) 124 | .TP 125 | \fB\-ast-offset \fRdur:int 126 | dur is the MPD availabilityStartTime shift in milliseconds (default value: 0) 127 | .TP 128 | \fB\-mpd-refresh \fRdur:int 129 | dur is the MPD minimumUpdatePeriod in seconds 130 | .TP 131 | \fB\-time-shift \fRdur:int 132 | dur is the MPD TimeShiftBufferDepth in seconds. 133 | The default value is 10. Specify -1 to keep all files. 134 | .TP 135 | \fB\-min-buffer \fRdur:float 136 | dur is the MPD minBufferTime in seconds (default value: 1.0) 137 | .TP 138 | \fB\-base-url \fRbaseurl:str 139 | baseurl is the MPD BaseURL 140 | 141 | .SH EXAMPLES 142 | DashCast -av test.avi -live-media 143 | .PP 144 | DashCast -a test_audio.mp3 -v test_audio.mp4 -live-media 145 | .PP 146 | DashCast -vf video4linux2 -vres 1280x720 -vfr 24 -v4l2f mjpeg -v /dev/video0 -af alsa -a plughw:1,0 -live 147 | .PP 148 | DashCast -vf x11grab -vres 800x600 -vfr 25 -v :0.0 -live 149 | 150 | .SH BUGS and OTHER HELP 151 | For bug reports, more information on BT or XMT-A formats or GPAC TTXT files or ISMACryp, 152 | MPEG-4 Systems usage and more help on DashCast please visit the GPAC web site http://www.gpac.io 153 | 154 | .SH "AUTHORS" 155 | Arash Shafiei. 156 | Copyright \(co Telecom ParisTech 2000-2013. 157 | 158 | .SH "SEE ALSO" 159 | .BR GPAC (1), 160 | .BR MP4Box (1), 161 | .BR MP4Client (1) 162 | -------------------------------------------------------------------------------- /include/gpac/sync_layer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * GPAC - Multimedia Framework C SDK 3 | * 4 | * Authors: Jean Le Feuvre 5 | * Copyright (c) Telecom ParisTech 2000-2012 6 | * All rights reserved 7 | * 8 | * This file is part of GPAC / SL header file 9 | * 10 | * GPAC is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU Lesser General Public License as published by 12 | * the Free Software Foundation; either version 2, or (at your option) 13 | * any later version. 14 | * 15 | * GPAC is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Lesser General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public 21 | * License along with this library; see the file COPYING. If not, write to 22 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 23 | * 24 | */ 25 | 26 | #ifndef _GF_SYNC_LAYER_H_ 27 | #define _GF_SYNC_LAYER_H_ 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | /*! 34 | * \file 35 | * \brief MPEG-4 Object Descriptor Framework Sync Layer. 36 | */ 37 | 38 | /*! 39 | * \ingroup odf_grp 40 | * \brief MPEG-4 Object Descriptor Framework Sync Layer 41 | * 42 | *This section documents the MPEG-4 OD Sync Layer used in GPAC. 43 | * @{ 44 | */ 45 | 46 | /*the Sync Layer config descriptor*/ 47 | typedef struct 48 | { 49 | /*base descriptor*/ 50 | u8 tag; 51 | 52 | u8 predefined; 53 | u8 useAccessUnitStartFlag; 54 | u8 useAccessUnitEndFlag; 55 | u8 useRandomAccessPointFlag; 56 | u8 hasRandomAccessUnitsOnlyFlag; 57 | u8 usePaddingFlag; 58 | u8 useTimestampsFlag; 59 | u8 useIdleFlag; 60 | u8 durationFlag; 61 | u32 timestampResolution; 62 | u32 OCRResolution; 63 | u8 timestampLength; 64 | u8 OCRLength; 65 | u8 AULength; 66 | u8 instantBitrateLength; 67 | u8 degradationPriorityLength; 68 | u8 AUSeqNumLength; 69 | u8 packetSeqNumLength; 70 | u32 timeScale; 71 | u16 AUDuration; 72 | u16 CUDuration; 73 | u64 startDTS; 74 | u64 startCTS; 75 | 76 | Bool no_dts_signaling; 77 | } GF_SLConfig; 78 | 79 | /*************************************** 80 | SLConfig Tag 81 | ***************************************/ 82 | enum 83 | { 84 | SLPredef_Null = 0x01, 85 | SLPredef_MP4 = 0x02, 86 | /*intern to GPAC, means NO SL at all (for streams unable to handle AU reconstruction a timing)*/ 87 | SLPredef_SkipSL = 0xF0 88 | }; 89 | 90 | /*set SL predefined (assign all fields according to sl->predefined value)*/ 91 | GF_Err gf_odf_slc_set_pref(GF_SLConfig *sl); 92 | 93 | 94 | typedef struct 95 | { 96 | u8 accessUnitStartFlag; 97 | u8 accessUnitEndFlag; 98 | u8 paddingFlag; 99 | u8 randomAccessPointFlag; 100 | u8 OCRflag; 101 | u8 idleFlag; 102 | u8 decodingTimeStampFlag; 103 | u8 compositionTimeStampFlag; 104 | u8 instantBitrateFlag; 105 | u8 degradationPriorityFlag; 106 | 107 | u8 paddingBits; 108 | u16 packetSequenceNumber; 109 | u64 objectClockReference; 110 | u16 AU_sequenceNumber; 111 | u64 decodingTimeStamp; 112 | u64 compositionTimeStamp; 113 | u16 accessUnitLength; 114 | u32 instantBitrate; 115 | u16 degradationPriority; 116 | 117 | /*Everything below this comment is internal to GPAC*/ 118 | 119 | /*this is NOT part of standard SL, only used internally: signals duration of access unit if known 120 | this is useful for streams with very random updates, to prevent buffering for instance a subtitle stream 121 | which is likely to have no updates during the first minutes... expressed in media timescale*/ 122 | u32 au_duration; 123 | /*ISMACryp extensions*/ 124 | u8 isma_encrypted; 125 | u64 isma_BSO; 126 | /*CENC extensions*/ 127 | u8 cenc_encrypted; 128 | char *sai; 129 | u8 IV_size; 130 | u32 saiz; 131 | //for CENC pattern encryption mode 132 | u8 crypt_byte_block, skip_byte_block; 133 | u8 constant_IV_size; 134 | bin128 constant_IV; 135 | /*version_number are pushed from m2ts sections to the mpeg4sl layer so as to handle mpeg4 stream dependencies*/ 136 | u8 m2ts_version_number_plus_one; 137 | //0: not mpeg-2 TS PCR, 1: MEPG-2 TS PCR, 2: MPEG-2 TS PCR with discontinuity 138 | u8 m2ts_pcr; 139 | /* HTML5 MSE Packet info */ 140 | s64 timeStampOffset; 141 | //ntp at sender/producer side for this packet, 0 otherwise 142 | u64 sender_ntp; 143 | //set for AUs which should be decodedd but not presented during seek 144 | u8 seekFlag; 145 | } GF_SLHeader; 146 | 147 | 148 | /*packetize SL-PDU. If PDU is NULL or size 0, only writes the SL header*/ 149 | void gf_sl_packetize(GF_SLConfig* slConfig, GF_SLHeader *Header, char *PDU, u32 size, char **outPacket, u32 *OutSize); 150 | /*gets SL header size in bytes*/ 151 | u32 gf_sl_get_header_size(GF_SLConfig* slConfig, GF_SLHeader *Header); 152 | 153 | /*depacketize SL-PDU*/ 154 | void gf_sl_depacketize(GF_SLConfig *slConfig, GF_SLHeader *Header, const char *PDU, u32 PDULength, u32 *HeaderLen); 155 | 156 | /*! @} */ 157 | 158 | #ifdef __cplusplus 159 | } 160 | #endif 161 | 162 | #endif /*_GF_SYNC_LAYER_H_*/ 163 | -------------------------------------------------------------------------------- /doc/man/mp42ts.1: -------------------------------------------------------------------------------- 1 | .TH MP42TS "1" "July 2015" "MP42TS" "GPAC" 2 | 3 | .SH NAME 4 | MP42TS - MPEG-4 Systems Framework and Software Development Kit 5 | 6 | .SH SYNOPSIS 7 | .B MP42TS 8 | .RI [options] 9 | 10 | .SH OPTIONS 11 | .SS "Inputs" 12 | .TP 13 | \fB\-src \fRfilename[:OPTS] 14 | specifies an input file used for a TS service: 15 | .br 16 | * currently only supports ISO files and SDP files 17 | .br 18 | * can be used several times, once for each program 19 | .br 20 | By default each source is a program in a TS. 21 | Source options are colon-separated list of options, as follows: 22 | .br 23 | 24 | .br 25 | \fBID\fR=\fBN \fRspecifies the program ID for this source. 26 | All sources with the same ID will be added to the same program 27 | .br 28 | \fBname\fR=\fBSTR \fRprogram name, as used in DVB service description table 29 | .br 30 | \fBprovider\fR=\fBSTR \fRprovider name, as used in DVB service description table 31 | 32 | .TP 33 | \fB\-prog filename 34 | same as "-src filename" 35 | 36 | .SS "Destinations" 37 | Several destinations may be specified as follows, at least one is mandatory: 38 | .TP 39 | \fB\-dst-udp \fRUDP_address:port (multicast or unicast) 40 | .TP 41 | \fB\-dst-rtp \fRRTP_address:port 42 | .TP 43 | \fB\-dst-file \fRfilename 44 | 45 | The following parameters may be specified when -dst-file is used: 46 | .TP 47 | \fB\-segment-dir \fRdir 48 | server local directory to store segments (ends with a '/') 49 | .TP 50 | \fB\-segment-duration \fRdur 51 | segment duration in seconds 52 | .TP 53 | \fB\-segment-manifest \fRfile 54 | m3u8 file basename 55 | .TP 56 | \fB\-segment-http-prefix \fRp 57 | client address for accessing server segments 58 | .TP 59 | \fB\-segment-number \fRn 60 | number of segments to list in the manifest 61 | 62 | .SS "Basic options" 63 | .TP 64 | \fB\-rate \fRR 65 | specifies target rate in kbps of the multiplex (optional) 66 | .TP 67 | \fB\-real-time 68 | specifies the muxer will work in real-time mode 69 | .br 70 | * if not specified, the muxer will generate the TS as quickly as possible 71 | .br 72 | * automatically set for SDP or BT input 73 | .TP 74 | \fB\-pcr-init \fRV 75 | sets initial value V for PCR - if not set, random value is used 76 | .TP 77 | \fB\-pcr-offset \fRV 78 | offsets all timestamps from PCR by V, in 90kHz. Default value is computed based on input media. 79 | .TP 80 | \fB\-psi-rate \fRV 81 | sets PSI refresh rate V in ms (default 100ms). 82 | .br 83 | * If 0, PSI data is only send once at the beginning or before each IDR when -rap option is set. 84 | .br 85 | * This should be set to 0 for DASH streams. 86 | .TP 87 | \fB\-time \fRn 88 | request the muxer to stop after n ms 89 | .TP 90 | \fB\-single-au 91 | forces 1 PES = 1 AU (disabled by default) 92 | .TP 93 | \fB\-rap 94 | forces RAP/IDR to be aligned with PES start for video streams (disabled by default). 95 | In this mode, PAT, PMT and PCR will be inserted before the first TS packet of the RAP PES. 96 | .TP 97 | \fB\-flush-rap 98 | same as -rap but flushes all other streams (sends remaining PES packets) before inserting PAT/PMT 99 | .TP 100 | \fB\-nb-pack \fRN 101 | specifies to pack up to N TS packets together before sending on network or writing to file 102 | .TP 103 | \fB\-pcr-ms \fRN 104 | sets max interval in ms between 2 PCR. Default is 100 ms 105 | .TP 106 | \fB\-ttl \fRN 107 | specifies Time-To-Live for multicast. Default is 1. 108 | .TP 109 | \fB\-ifce \fRIPIFCE 110 | specifies default IP interface to use. Default is IF_ANY. 111 | .TP 112 | \fB\-temi \fR[URL] 113 | Inserts TEMI time codes in adaptation field. URL is optional 114 | .TP 115 | \fB\-temi-delay \fRDelayMS 116 | Specifies delay between two TEMI url descriptors (default is 1000) 117 | .TP 118 | \fB\-temi-offset \fROffsetMS 119 | Specifies an offset in ms to add to TEMI (by default TEMI starts at 0) 120 | .TP 121 | \fB\-temi-noloop 122 | Do not restart the TEMI timeline at the end of the source 123 | .TP 124 | \fB\-sdt-rate \fRMS 125 | Gives the SDT carrousel rate in milliseconds. If 0 (default), SDT is not sent 126 | 127 | .SS "MPEG-4/T-DMB options" 128 | .TP 129 | \fB\-bifs-src \fRfilename 130 | update file: must be either an .sdp or a .bt file 131 | .TP 132 | \fB\-audio \fRurl 133 | may be mp3/udp or aac/http (shoutcast/icecast) 134 | .TP 135 | \fB\-video \fRurl 136 | shall be a raw h264 frame 137 | .TP 138 | \fB\-mpeg4-carousel \fRn 139 | carousel period in ms 140 | .TP 141 | \fB\-mpeg4\fR,\fB \-4on2 142 | forces usage of MPEG-4 signaling (IOD and SL Config) 143 | .TP 144 | \fB\-4over2 145 | same as -4on2 and uses PMT to carry OD Updates 146 | .TP 147 | \fB\-bifs-pes 148 | carries BIFS over PES instead of sections 149 | .TP 150 | \fB\-bifs-pes-ex 151 | carries BIFS over PES without writing timestamps in SL 152 | 153 | .SS "Misc options" 154 | .TP 155 | \fB\-logs 156 | set log tools and levels, formatted as a ':'-separated list of toolX[:toolZ]@levelX 157 | .TP 158 | \fB\-h\fR,\fB \-help 159 | print this screen 160 | 161 | .SH BUGS and OTHER HELP 162 | For bug reports, more information on BT or XMT-A formats or GPAC TTXT files or ISMACryp, 163 | MPEG-4 Systems usage and more help on MP42TS please visit the GPAC web site http://www.gpac.io 164 | 165 | .SH "AUTHORS" 166 | Jean Le Feuvre, Cyril Concolato, Romain Bouqueau. 167 | Copyright \(co Telecom ParisTech 2005-2012. 168 | 169 | .SH "SEE ALSO" 170 | .BR GPAC (1), 171 | .BR MP4Box (1), 172 | .BR MP4Client (1) 173 | -------------------------------------------------------------------------------- /doc/INSTALL.gpe: -------------------------------------------------------------------------------- 1 | Installation instructions for GPAC on Familiar+GPE platforms 2 | last modified: December 2008 3 | 4 | 0 Foreword 5 | This file is about installing the GPAC framework on an arm device running Linux familiar (cf http://www.handhelds.org) 6 | 7 | Compilation has only been tested for familiar+GPE platforms ( http://gpe.handhelds.org). 8 | The GPE version enables GPAC to use X11 video output directly, including shared memory extensions. 9 | 10 | The output directory for all plugins and applications is gpac/bin/gcc 11 | 12 | As of 0.2.2, GPAC cannot be compiled without ZLIB. You'd better make sure it is installed on your system (zlib is provided in gpac_extra_libs package) 13 | 14 | To install the arm cross-compilation environement on your linux system, refer to: 15 | * http://www.handhelds.org 16 | * we're currently using the following tool-chain for Familiar+GPE compil http://www.roebling.de/embedded.html, with X11 and GTK+ support, 17 | already compiled. 18 | 19 | Do not forget to update your environment variables according to your toolchain. 20 | 21 | I Extra lib installation 22 | It is recommended to install all extra libs needed by gpac not installed on your system. 23 | 24 | II GPAC compilation 25 | 26 | II.1 SDL Support 27 | GPAC can use SDL for audio/video output. If SDL is not installed on your system, you may indicate configure to build with a local copy: 28 | --sdl-cfg=path/to/local/sdlcfg/ 29 | (make sure to update the local sdl-cfg according to your needs) 30 | 31 | If you can't get SDL and don't have OSS audio nor X11 video support on your system, you won't be able to play any presentation with GPAC, 32 | but you can still use MP4Box. 33 | 34 | II.2 wxWidgets Support 35 | GPAC comes with a GUI player called Osmo4. To compile this player you will need wxWidgets 2.6.0 (2.5.2 should work) installed on your system. 36 | NOTE: Osmo4+wxWidgets is quite slow on familiar+GPE, and is therefore not recommended at the time being. 37 | You can always use GPAC command-line player MP4Client. 38 | 39 | II.3 OpenGL ES support 40 | OpenGL ES is not yet supported on Familiar-GPE. However, GPAC renderer supports OpenGL ES API. Porting the 3D module only requires modifying the X11 output (modules/x11_out) for 41 | OpenGL ES. 42 | 43 | II.4 Building GPAC 44 | go to root of gpac distribution. Note: you may need to "chmod +x" the configure file. 45 | (./configure --help for options) 46 | ./configure --prefix=/usr/local/arm/3.3.2 --cpu=armv4l --enable-fixed-point 47 | Note: this assume the cross-compilation tool-chain is located in /usr/local/arm/3.3.2 48 | Note: you may also specify any other option supported by configure. It is not recommended to use the floating-point version of GPAC for ARM-based architectures. 49 | make 50 | 51 | II.5 Installing GPAC 52 | copy all files to your device, possibly creating a dedicated directory for modules 53 | edit or create ~/.gpacrc to have at least the following lines: 54 | [General] 55 | ModulesDirectory=AbsolutePathToTheModules 56 | 57 | For more information on GPAC configuration file, cf man GPAC of gpac/doc/configuration.html 58 | 59 | III Running GPAC 60 | 61 | III.1 MP4Client 62 | MP4Client is a command-line interface to GPAC. Note that the player cannot work without video support (so you'd better get SDL) 63 | 64 | You need a GPAC configuration file to run MP4Client, and you will need it each time. 65 | 66 | First launch of MP4Client 67 | go to gpac/bin/gcc if not using the install. 68 | type MP4Client 69 | the prompt will ask for 70 | 1- GPAC plugin dir: enter the path from / to gpac/bin/gcc. This is skipped when using the install version of MP4Client (the plugin path is hardcoded to 71 | the plugins install location on the system) 72 | 2- Font directory: enter the path to a truetype font directory on your system (note that if you don't have compiled with freetype any directory will do) 73 | 3- cache directory: any directory with write access 74 | You now have a valid config file for GPAC, more info on this try "man GPAC" or check gpac/doc/configuration.html. 75 | 76 | The config file is called ".gpacrc" and is located in the user home directory. You may run the client with a different config file by using the "-c" option. 77 | 78 | *If you don't see any output window, check the config file doesn't use raw_out.so as a video renderer (or simply remove raw_out.so). 79 | 80 | III.2 Osmo4 81 | Osmo4 is the GUI frontend to GPAC. If you have installed Osmo4 on your system, the first launch of the player should ask you to locate a 82 | directory with TrueType fonts and a cache directory for internet downloads if no configuration file is found. 83 | 84 | III.3 MP4Box 85 | MP4Box is a tool to encode, decode and manipulate MPEG-4 systems data. It does not need a configuration file. 86 | Help for MP4Box is available on GPAC web site, with man MP4Box and with 'MP4Box -h' 87 | 88 | IV Configuration 89 | 90 | IV.0 Foreword 91 | All configuration information is described in gpac/doc/configuration.html, or man gpac. 92 | 93 | IV.1 OpenGL 94 | OpenGL is badly known for performing quite poorly as far as high data rate texturing is involved. This is a big issue when displaying a typical movie and you will likely find the GPAC 3D Renderer very slow on your system. If your GPU supports non power of 2 texturing or rectangular texturing (most Win32 drivers do) 95 | you shouldn't have any problem with video. Otherwise here are some tips to configure GPAC on your system: 96 | 1- set the "BitmapCopyPixels" option on: some cards perform rather well at direct pixel transfer. If no improvement, set it off. 97 | 2- set the "BitmapCopyPixels" option off and the "EmulatePOW2" option on. This will trick the GL texturing by using only Power Of 2 textures when converting from YUV to RGB. 98 | 3- If this does not improve video playback, you're only chance is through discussion forums & co to gather info about your system, your GL implementation and how to fine-tune it. 99 | 100 | 101 | -------------------------------------------------------------------------------- /include/gpac/configuration.h: -------------------------------------------------------------------------------- 1 | /* 2 | * GPAC - Multimedia Framework C SDK 3 | * 4 | * Authors: Jean Le Feuvre 5 | * Copyright (c) Telecom ParisTech 2008-2012 6 | * All rights reserved 7 | * 8 | * This file is part of GPAC 9 | * 10 | * GPAC is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU Lesser General Public License as published by 12 | * the Free Software Foundation; either version 2, or (at your option) 13 | * any later version. 14 | * 15 | * GPAC is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Lesser General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public 21 | * License along with this library; see the file COPYING. If not, write to 22 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 23 | * 24 | */ 25 | 26 | 27 | #ifndef _GF_CONFIG_H_ 28 | #define _GF_CONFIG_H_ 29 | 30 | #define GPAC_CONFIGURATION "(static configuration file)" 31 | 32 | /*this file defines all common macros for libgpac compilation 33 | except for symbian32 which uses .mmp directives ... */ 34 | #if defined(WIN32) || defined(_WIN32_WCE) || defined(GPAC_CONFIG_DARWIN) /*visual studio and xcode*/ 35 | 36 | /*enables GPAC fixed point*/ 37 | //#define GPAC_FIXED_POINT 38 | 39 | /*automatic tracking is disabled by default, causes too many problems when reusing parts of gpac*/ 40 | #if 0 41 | /*enables GPAC memory tracking*/ 42 | #if defined(DEBUG) || defined(_DEBUG) 43 | #define GPAC_MEMORY_TRACKING 44 | #endif 45 | #endif 46 | 47 | /*platform is big endian*/ 48 | //#define GPAC_BIG_ENDIAN 49 | 50 | /*SSL enabled*/ 51 | #ifdef WIN32 52 | #define GPAC_HAS_SSL 53 | #endif 54 | 55 | /*spidermonkey enabled*/ 56 | #define GPAC_HAS_SPIDERMONKEY 57 | #ifdef GPAC_CONFIG_DARWIN 58 | #define MOZILLA_1_8_BRANCH 59 | #endif 60 | 61 | /*libjpeg enabled*/ 62 | #define GPAC_HAS_JPEG 63 | 64 | /*pnj enabled*/ 65 | #define GPAC_HAS_PNG 66 | 67 | /*IPv6 enabled - for win32, this is evaluated at compile time, !! do not uncomment !!*/ 68 | //#define GPAC_HAS_IPV6 69 | 70 | /*3D compositor disabled*/ 71 | #ifdef GPAC_CONFIG_DARWIN 72 | #define GPAC_DISABLE_3D 73 | #endif 74 | 75 | /*use TinyGL instead of OpenGL*/ 76 | //#define GPAC_USE_TINYGL 77 | 78 | /*use OpenGL ES instead of OpenGL*/ 79 | #ifdef GPAC_CONFIG_DARWIN 80 | #define GPAC_USE_OGL_ES 81 | #endif 82 | 83 | 84 | #if defined(_WIN32_WCE) 85 | 86 | #ifndef GPAC_FIXED_POINT 87 | #define GPAC_FIXED_POINT 88 | #endif 89 | 90 | /*use intel fixed-point*/ 91 | //#define GPAC_USE_IGPP 92 | /*use intel fixed-point with high precision*/ 93 | //#define GPAC_USE_IGPP_HP 94 | 95 | #if defined(GPAC_USE_IGPP) && defined(GPAC_USE_IGPP_HP) 96 | #error "Only one of GPAC_USE_IGPP and GPAC_USE_IGPP_HP can be defined" 97 | #endif 98 | 99 | #if !defined(GPAC_DISABLE_3D) && !defined(GPAC_USE_TINYGL) && !defined(GPAC_USE_OGL_ES) 100 | #define GPAC_USE_OGL_ES 101 | #endif 102 | 103 | #endif /*_WIN32_WCE*/ 104 | 105 | 106 | 107 | #endif /*defined(WIN32) || defined(_WIN32_WCE)*/ 108 | 109 | 110 | #if defined(__SYMBIAN32__) 111 | 112 | #ifndef GPAC_FIXED_POINT 113 | #define GPAC_FIXED_POINT 114 | #endif 115 | 116 | #endif 117 | 118 | #if defined(_WIN32_WCE) 119 | /*comment this line if you don't have a GLU32 version for Windows Mobile*/ 120 | //#define GPAC_HAS_GLU 121 | #elif defined(WIN32) 122 | #define GPAC_HAS_GLU 123 | #endif 124 | 125 | 126 | /*disables SVG scene graph*/ 127 | //#define GPAC_DISABLE_SVG 128 | 129 | /*disables VRML/BIFS scene graphs*/ 130 | //#define GPAC_DISABLE_VRML 131 | 132 | /*disables X3D scene graphs*/ 133 | //#define GPAC_DISABLE_X3D 134 | 135 | /*disables MPEG-4 OD Framework - this only minimalize the set of OD features used, however all cannot be removed*/ 136 | //#define GPAC_MINIMAL_ODF 137 | 138 | /*disables BIFS coding*/ 139 | //#define GPAC_DISABLE_BIFS 140 | 141 | /*disables LASeR coder*/ 142 | //#define GPAC_DISABLE_LASER 143 | 144 | /*disables BIFS Engine support - TODO - merge DIMS and LASeR into BENG and rename it*/ 145 | //#define GPAC_DISABLE_SENG 146 | 147 | /*disables Cubic QTVR importing*/ 148 | //#define GPAC_DISABLE_QTVR 149 | 150 | /*disables AVILib support*/ 151 | //#define GPAC_DISABLE_AVILIB 152 | 153 | /*disables OGG support*/ 154 | //#define GPAC_DISABLE_OGG 155 | 156 | /*disables MPEG2 PS support*/ 157 | //#define GPAC_DISABLE_MPEG2PS 158 | 159 | /*disables MPEG2 TS demux support*/ 160 | //#define GPAC_DISABLE_MPEG2TS 161 | 162 | /*disables MPEG2 TS Mux support*/ 163 | //#define GPAC_DISABLE_MPEG2TS_MUX 164 | 165 | /*disables all media import functions*/ 166 | //#define GPAC_DISABLE_MEDIA_IMPORT 167 | 168 | /*disable all AV parsing functions*/ 169 | //#define GPAC_DISABLE_AV_PARSERS 170 | 171 | /*disables all media export functions*/ 172 | //#define GPAC_DISABLE_MEDIA_EXPORT 173 | 174 | /*disables SWF importer*/ 175 | //#define GPAC_DISABLE_SWF_IMPORT 176 | 177 | /*disables all media export functions*/ 178 | //#define GPAC_DISABLE_SCENE_STATS 179 | 180 | /*disables scene -> MP4 encoder*/ 181 | //#define GPAC_DISABLE_SCENE_ENCODER 182 | 183 | /*disables ISOM -> scene decoder*/ 184 | //#define GPAC_DISABLE_LOADER_ISOM 185 | 186 | /*disables BT/WRL/X3DV -> scene decoder*/ 187 | //#define GPAC_DISABLE_LOADER_BT 188 | 189 | /*disables XMTA/X3D -> scene decoder*/ 190 | //#define GPAC_DISABLE_LOADER_XMT 191 | 192 | /*disables mcrypt*/ 193 | //#define GPAC_DISABLE_MCRYPT 194 | 195 | /*disables all ISO FF*/ 196 | //#define GPAC_DISABLE_ISOM 197 | 198 | /*disables ISO FF hint tracks*/ 199 | //#define GPAC_DISABLE_ISOM_HINTING 200 | 201 | /*disables ISO FF writing*/ 202 | //#define GPAC_DISABLE_ISOM_WRITE 203 | 204 | /*disables ISO FF fragments*/ 205 | //#define GPAC_DISABLE_ISOM_FRAGMENTS 206 | 207 | /*disables scene graph textual dump*/ 208 | //#define GPAC_DISABLE_SCENE_DUMP 209 | 210 | /*disables OD graph textual dump*/ 211 | //#define GPAC_DISABLE_OD_DUMP 212 | 213 | /*disables OD graph textual dump*/ 214 | //#define GPAC_DISABLE_ISOM_DUMP 215 | 216 | /*disables IETF RTP/SDP/RTSP*/ 217 | //#define GPAC_DISABLE_STREAMING 218 | 219 | #endif /*_GF_CONFIG_H_*/ 220 | 221 | -------------------------------------------------------------------------------- /doc/CODING_STYLE: -------------------------------------------------------------------------------- 1 | GPAC coding style 2 | 3 | Introduction 4 | coding styles only concern the GPAC library (M4Systems in GPAC<=0.3.0, libgpac now), and, although recommended, are not mandatory for plugins 5 | or applications development. 6 | 7 | AStyle is a code beautifier tool. Code should be compliant with the following pattern provided by AStyle : 8 | AStyle -r --indent=tab '*.c' '*.h' '*.cpp' '*.hpp' 9 | 10 | 1 Exported symbols 11 | 12 | 1.0 Informative note 13 | The GF_ or gf_ stands for "gpac framework" 14 | 15 | 1.1 typedef of structures - typedef of base types - typedef of functions 16 | 17 | All symbols defined within libgpac library and exported for application development purposes shall begin be named GF_* 18 | with the first character of "*" being in capital, regardless of their functionality. 19 | For example, GF_Thread (structure), GF_Err (redefined type), GF_LineCap (enum typedef) 20 | 21 | All structure typedefs, whether defined (declaration exported through ehaders) or not (declaration intern to the GPAC core lib), must follow 22 | this principle. 23 | Furthermore, typedef of non exported structure shall only apply to the structure itself, not a pointer to it. 24 | typedef struct _my_gpac_thingy *GF_LPMYGPACSTUFF; /*this is FORBIDDEN*/ 25 | typedef struct _my_gpac_thingy GF_MyGPACStuff; /*this is OK*/ 26 | This will allow easy exporting of structure declaration if needed at some point in the development. 27 | 28 | 29 | 1.2 constants 30 | 31 | All constants (whether #defines or enums) shall be in capital letters and begin with "GF_" and use "_" for word separation 32 | For example, error code GF_BAD_PARAM. 33 | 34 | Enums names shall refer to the main module they are used in through a keyword right after the GF_ . 35 | For example, 36 | * enums refering to file format (isomedia) will be prefixed by GF_ISOM_ 37 | * enums refering to MPEG-4 OD tools (odf) will be prefixed by GF_ODF_ 38 | 39 | 1.3 functions 40 | 41 | All exported functions and pointer to functions shall begin with "gf_". The name shall refer to the main module they are sued in 42 | through a keyword right after the gf_ when reasonable (gf_isom_, gf_odf_, gf_term_), or to the tool they refer to (gf_bs_, gf_url, ...) 43 | 44 | 2 Miscalleanous 45 | 46 | All exported functions' names shall be in lower case exclusively. 47 | All exported functions' parameters should be in lower case exclusively. 48 | Exported structures may use case in any fashion as long as they respect the rules expressed in section 1 above. 49 | Exported structures member should preferably all be lower case - this may not be feasible for scene graph nodes & like... 50 | 51 | All exported header files shall be in lower case 52 | All source files within the gpac core shall be in lower case 53 | 54 | All comments should be C-like ones (/**/) not C++ ones (//) 55 | All exported headers documentation should be written with dowygen syntax 56 | All constructor-like functions should be of style gf_zzz_new 57 | All destructor like functions should be of style gf_zzz_del 58 | 59 | 3 Rearchitecture of the GPAC repository 60 | 61 | This recaps the changes between gpac 0.3.0 and gpac 0.4.0 as far as the core architecture is concerned. 62 | 63 | 64 | The former M4Systems library is now simply libGPAC (eg libgpac.lib, libgpac.dll, libgpac.so, libgpac.a) 65 | Currently no decision has been taken regarding splitting of this library in smaller packages, this still needs discussion. 66 | 67 | directory architecture: 68 | /gpac 69 | /gpac/applications/ 70 | former Applications/, misc renames 71 | /gpac/applications/generators: former SceneGenerators 72 | /gpac/applications/testapps: added for apps testing some features of gpac (currently only BIFSEngine tester) 73 | /gpac/bin 74 | rename of directories: 75 | arm_debug -> arm_ppc02_deb 76 | arm_release -> arm_ppc02_rel 77 | Debug -> w32_deb 78 | Release -> w32_rel 79 | /gpac/build: former IDEs directory, with project files for MS eVC*/VC* 80 | /gpac/doc 81 | /gpac/doc/libgpac: future place for doc of all exported functions from libgpac 82 | /gpac/extra_lib 83 | /gpac/extra_lib/include 84 | unchanged 85 | /gpac/extra_lib/lib 86 | rename of directories: 87 | arm_debug -> arm_ppc02_deb 88 | arm_release -> arm_ppc02_rel 89 | w32_debug -> w32_deb 90 | w32_release -> w32_rel 91 | 92 | 93 | /gpac/src: former M4Systems directory, source for the gpac core lib 94 | /gpac/src/utils: 95 | former Tools - function names: gf_* 96 | /gpac/src/isomedia: 97 | former MP4 - code for isomedia - function names: gf_isom_* 98 | /gpac/src/odf: 99 | former OD - code for MPEG-4 OD Framework - function names: gf_odf_* 100 | /gpac/src/ietf: 101 | former IETF - code for IETF SDP/RTP/RTCP/RTSP protocols - function names: (or gf_sdp_*, gf_rtp_*, gf_rtsp_*) 102 | moved packetizers in this place since payloads are quite related to IETF... 103 | /gpac/src/bifs: 104 | former BIFS - code for BIFS encoding and decoding - exported function names: gf_bifs_* 105 | /gpac/src/terminal: 106 | former ESM - code for terminal module - exported function names: gf_term_* 107 | /gpac/src/crypto: 108 | unchanged - function names: gf_crypt_* 109 | /gpac/src/renderer: 110 | former renderer - function names: gf_sr_* 111 | /gpac/src/scenegraph: 112 | former SceneGraph - function names: gf_sg_* for all common code (base nodes and graph handling), 113 | gf_sg_vrml_*: MPEG4, VRML, X3D related 114 | gf_sg_svg_*: SVG related (maybe laser-related) 115 | 116 | /gpac/src/media_tools: 117 | former authoring on media import/export and IsoMedia file stuff. function names: gf_media_*, gf_hinter_ 118 | 119 | /gpac/src/scene_manager: 120 | former authoring on scene manager. function names: gf_sm_* 121 | 122 | 123 | /gpac/include 124 | /gpac/include/gpac: 125 | splitting of former m4_tools.h into dedicated headers, and for some other modules too (media parsers, ...) 126 | 127 | /gpac/include/gpac/internal: 128 | former intern , no big changes 129 | 130 | /gpac/modules: 131 | former Plugins directory. 132 | 133 | 134 | -------------------------------------------------------------------------------- /doc/INSTALL.gcc: -------------------------------------------------------------------------------- 1 | Installation instructions for GPAC on GCC-powered platforms 2 | last modified: December 2008 3 | 4 | 0 Foreword 5 | The output directory for all plugins and applications is gpac/bin/gcc 6 | 7 | As of 0.2.2, GPAC cannot be compiled without ZLIB. You'd better make sure it is installed on your system (zlib is provided in gpac_extra_libs package) 8 | 9 | I Extra lib installation 10 | It is recommended to install (source or package) all extra libs needed by gpac not installed on your system. 11 | Libraries found on the system are indicated as an output of the configure script 12 | 13 | 14 | II GPAC compilation 15 | 16 | II.1 SDL Support 17 | GPAC can use SDL for audio/video output. If SDL is not installed on your system, you may indicate configure to build with a local copy: 18 | --sdl-cfg=path/to/local/sdlcfg/ 19 | (make sure to update the local sdl-cfg according to your needs) 20 | 21 | If you can't get SDL and don't have OSS or WAV audio nor DirectX or X11 video support on your system, you won't be able to play any presentation with GPAC, 22 | but you can still use MP4Box. 23 | 24 | II.2 wxWidgets Support 25 | GPAC comes with a GUI player called Osmo4. To compile this player you will need wxWidgets 2.6.0 (2.5.2 should work) installed on your system. 26 | Both unicode and ANSI versions of wxWidgets should be supported. 27 | If you don't use wxWidgets, you can always use GPAC command-line player MP4Client. 28 | 29 | II.3 MinGW DirectX support 30 | When building GPAC under MinGW, it is also possible to compile the DirectX plugin. You will need the MinGW versions of DX libs 31 | (available at http://alleg.sourceforge.net/files/). Get dx70_mgw or dx80_mgw (dx8 is provided in gpac_extra_libs package) 32 | copy the archive content in your MSys tree (for ex, /usr/local/DirectX) and configure gpac with the option --dxsdk-path=/usr/local/DirectX 33 | ** you must keep include and lib folders under the same directory for the configure script to detect DirectX ** 34 | 35 | II.4 Building GPAC 36 | go to root of gpac distribution 37 | ./configure (--help for options) - you may need to "chmod +x" this file... 38 | make 39 | 40 | any fixes to configure are welcome :) 41 | 42 | II.5 Installing GPAC 43 | get root 44 | type "make install" in gpac/ 45 | 46 | This will install MP4Client, Osmo4 if configured, MP4Box and all plugins as well as GPAC documentation man: MP4Box(1), MP4Client(1) and GPAC(1). 47 | type "make uninstall" to remove gpac from your system 48 | 49 | II.6 Installing GPAC SDK 50 | get root 51 | type "make install-lib" in gpac/ 52 | 53 | This will install gpac base headers (), gpac development headers ( and libgpac_static - the static version of libgpac shared library. 54 | type "make uninstall-lib" to remove gpac from your system 55 | There is no documentation regarding headers/SDK for now, you will have to rely on function descriptions in each header. 56 | 57 | III Running GPAC 58 | 59 | III.1 MP4Client 60 | MP4Client is a command-line interface to GPAC. Note that the player cannot work without video support 61 | 62 | You need a GPAC configuration file to run MP4Client, and you will need it each time. 63 | 64 | First launch of MP4Client 65 | go to gpac/bin/gcc if not using the install. 66 | type MP4Client 67 | the prompt will ask for 68 | 1- GPAC plugin dir: enter the path from / to gpac/bin/gcc. This is skipped when using the install version of MP4Client (the plugin path is hardcoded to 69 | the plugins install location on the system) 70 | 2- Font directory: enter the path to a truetype font directory on your system (note that if you don't have compiled with freetype any directory will do) 71 | 3- cache directory: any directory with write access 72 | You now have a valid config file for GPAC, more info on this try "man GPAC" or check gpac/doc/configuration.html. 73 | 74 | The config file is called ".gpacrc" and is located in the user home directory. You may run the client with a different config file by using the "-c" option. 75 | 76 | *If you don't see any output window, check the config file doesn't use gm_raw_out.so as a video renderer (or simply remove gm_raw_out.so). 77 | 78 | MINGW USERS: there are known and terrible bugs with MSys rxvt stdio buffering, do NOT use it to run MP4Client unless you want to understand 79 | these bugs. Use w32 CMD.exe instead. Other GPAC apps are no pb for MSys rxvt. 80 | 81 | III.2 Osmo4 82 | Osmo4 is the GUI frontend to GPAC. If you have installed Osmo4 on your system, the first launch of the player should ask you to locate a 83 | directory with TrueType fonts and a cache directory for internet downloads if no configuration file is found. 84 | 85 | III.3 MP4Box 86 | MP4Box is a tool to encode, decode and manipulate MPEG-4 systems data. It does not need a configuration file. 87 | Help for MP4Box is available on GPAC web site, with man MP4Box (except on MinGW) and with 'MP4Box -h' 88 | 89 | III.4 Osmozilla 90 | Osmozilla is GPAC plugin for Mozilla-based browsers. It is by default installed to the user mozilla directory ~/.mozilla 91 | To install the plugin on the system 92 | * get root 93 | * ./configure --mozdir=/path/to/mozilla 94 | for example --mozdir=/usr/lib/mozilla-firefox 95 | * make -C applications/osmozilla install 96 | 97 | * OR you may copy by hand bin/gcc/nposmozilla.so to /usr/lib/moz**/plugins and bin/gcc/nposmozilla.xpt to /usr/lib/moz**/components 98 | 99 | IV Configuration 100 | 101 | IV.0 Foreword 102 | All configuration information is described in gpac/doc/configuration.html, or man gpac. 103 | 104 | IV.1 OpenGL 105 | OpenGL is badly known for performing quite poorly as far as high data rate texturing is involved. This is a big issue when displaying a typical movie and you will likely find the GPAC 3D Rendering very slow on your system. If your GPU supports non power of 2 texturing or rectangular texturing (most Win32 drivers do) 106 | you shouldn't have any problem with video. Otherwise here are some tips to configure GPAC on your system: 107 | 1- set the "BitmapCopyPixels" option on: some cards perform rather well at direct pixel transfer. If no improvement, set it off. 108 | 2- set the "BitmapCopyPixels" option off and the "EmulatePOW2" option on. This will trick the GL texturing by using only Power Of 2 textures when converting from YUV to RGB. 109 | 3- If this does not improve video playback, you're only chance is through discussion forums & co to gather info about your system, your GL implementation and how to fine-tune it. 110 | 111 | V Misc 112 | 113 | There is a demo 2D authoring tool called V4Studio. No makefiles available yet but should compile without pbs (only needs libgpac 114 | and wxWidgets ). It is not usable to design content but is a funny toy. 115 | 116 | 117 | -------------------------------------------------------------------------------- /include/gpac/list.h: -------------------------------------------------------------------------------- 1 | /* 2 | * GPAC - Multimedia Framework C SDK 3 | * 4 | * Authors: Jean Le Feuvre 5 | * Copyright (c) Telecom ParisTech 2000-2012 6 | * All rights reserved 7 | * 8 | * This file is part of GPAC / common tools sub-project 9 | * 10 | * GPAC is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU Lesser General Public License as published by 12 | * the Free Software Foundation; either version 2, or (at your option) 13 | * any later version. 14 | * 15 | * GPAC is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Lesser General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public 21 | * License along with this library; see the file COPYING. If not, write to 22 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 23 | * 24 | */ 25 | 26 | #ifndef _GF_LIST_H_ 27 | #define _GF_LIST_H_ 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | /*! 34 | * \file 35 | * \brief Generic list of objects. 36 | */ 37 | 38 | /*! 39 | * \addtogroup list_grp List 40 | * \ingroup utils_grp 41 | * \brief List object 42 | * 43 | * This section documents the list object of the GPAC framework. 44 | * @{ 45 | */ 46 | 47 | #include "gpac/tools.h" 48 | 49 | typedef struct _tag_array GF_List; 50 | 51 | /*! 52 | * \brief list constructor 53 | * 54 | * Constructs a new list object 55 | * \return new list object 56 | */ 57 | GF_List *gf_list_new(); 58 | 59 | /*! 60 | * \brief list destructor 61 | * 62 | * Destructs a list object 63 | * \param ptr list object to destruct 64 | * \note It is the caller responsability to destroy the content of the list if needed 65 | */ 66 | void gf_list_del(GF_List *ptr); 67 | 68 | /*! 69 | * \brief get count 70 | * 71 | * Returns number of items in the list 72 | * \param ptr target list object 73 | * \return number of items in the list 74 | */ 75 | u32 gf_list_count(const GF_List *ptr); 76 | 77 | /*! 78 | * \brief add item 79 | * 80 | * Adds an item at the end of the list 81 | * \param ptr target list object 82 | * \param item item to add 83 | */ 84 | GF_Err gf_list_add(GF_List *ptr, void* item); 85 | 86 | /*! 87 | * \brief inserts item 88 | * 89 | * Insert an item in the list 90 | * \param ptr target list object 91 | * \param item item to add 92 | * \param position insertion position. It is expressed between 0 and gf_list_count-1, and any bigger value is equivalent to gf_list_add 93 | */ 94 | GF_Err gf_list_insert(GF_List *ptr, void *item, u32 position); 95 | 96 | /*! 97 | * \brief removes item 98 | * 99 | * Removes an item from the list given its position 100 | * \param ptr target list object 101 | * \param position position of the item to remove. It is expressed between 0 and gf_list_count-1. 102 | * \note It is the caller responsability to destroy the content of the list if needed 103 | */ 104 | GF_Err gf_list_rem(GF_List *ptr, u32 position); 105 | 106 | /*! 107 | * \brief gets item 108 | * 109 | * Gets an item from the list given its position 110 | * \param ptr target list object 111 | * \param position position of the item to get. It is expressed between 0 and gf_list_count-1. 112 | */ 113 | void *gf_list_get(GF_List *ptr, u32 position); 114 | 115 | /*! 116 | * \brief finds item 117 | * 118 | * Finds an item in the list 119 | * \param ptr target list object. 120 | * \param item the item to find. 121 | * \return 0-based item position in the list, or -1 if the item could not be found. 122 | */ 123 | s32 gf_list_find(GF_List *ptr, void *item); 124 | 125 | /*! 126 | * \brief deletes item 127 | * 128 | * Deletes an item from the list 129 | * \param ptr target list object. 130 | * \param item the item to find. 131 | * \return 0-based item position in the list before removal, or -1 if the item could not be found. 132 | */ 133 | s32 gf_list_del_item(GF_List *ptr, void *item); 134 | 135 | /*! 136 | * \brief resets list 137 | * 138 | * Resets the content of the list 139 | * \param ptr target list object. 140 | * \note It is the caller responsability to destroy the content of the list if needed 141 | */ 142 | void gf_list_reset(GF_List *ptr); 143 | 144 | /*! 145 | * \brief gets last item 146 | * 147 | * Gets last item o fthe list 148 | * \param ptr target list object 149 | */ 150 | void *gf_list_last(GF_List *ptr); 151 | 152 | /*! 153 | * \brief reverses the order of the elements in the list container. 154 | * 155 | * reverses the order of the elements in the list container. 156 | * \param ptr target list object 157 | */ 158 | void gf_list_reverse(GF_List *ptr); 159 | 160 | /*! 161 | * \brief removes last item 162 | * 163 | * Removes the last item of the list 164 | * \param ptr target list object 165 | * \note It is the caller responsability to destroy the content of the list if needed 166 | */ 167 | GF_Err gf_list_rem_last(GF_List *ptr); 168 | 169 | 170 | /*! 171 | * \brief list enumerator 172 | * 173 | * Retrieves given list item and increment current position 174 | * \param ptr target list object 175 | * \param pos target item position. The position is automatically incremented regardless of the return value 176 | * \note A typical enumeration will start with a value of 0 until NULL is returned. 177 | */ 178 | void *gf_list_enum(GF_List *ptr, u32 *pos); 179 | 180 | /*! 181 | * \brief list enumerator in reversed order 182 | * 183 | * Retrieves the given list item in reversed order and update current position 184 | * \param ptr target list object 185 | * \param pos target item position. The position is automatically decrelented regardless of the return value 186 | * \note A typical enumeration in reversed order will start with a value of 0 until NULL is returned. 187 | */ 188 | void *gf_list_rev_enum(GF_List *ptr, u32 *pos); 189 | 190 | /*! 191 | * \brief list swap 192 | * 193 | * Swaps content of two lists 194 | * \param l1 first list object 195 | * \param l2 second list object 196 | */ 197 | GF_Err gf_list_swap(GF_List *l1, GF_List *l2); 198 | 199 | /*! 200 | * \brief list transfer 201 | * 202 | * Transfer content between lists 203 | * \param l1 destination list object 204 | * \param l2 source list object 205 | */ 206 | GF_Err gf_list_transfer(GF_List *l1, GF_List *l2); 207 | 208 | /*! 209 | * \brief clone list 210 | * 211 | * Returns a new list as an exact copy of the given list 212 | * \param ptr the list to clone 213 | * \return the cloned list 214 | */ 215 | GF_List* gf_list_clone(GF_List *ptr); 216 | 217 | /*! 218 | * \brief Pop the first element in the list 219 | * 220 | * Removes the first element in the list container, effectively reducing its size by one 221 | * and returns the popped element. 222 | * \param ptr the list to pop 223 | * \return the popped element 224 | */ 225 | void* gf_list_pop_front(GF_List *ptr); 226 | 227 | /*! 228 | * \brief Pop the last element in the list 229 | * 230 | * Removes the last element in the list container, effectively reducing the container size by one 231 | * and return the popped element. 232 | * \param ptr the list to pop 233 | * \return the popped element 234 | */ 235 | void* gf_list_pop_back(GF_List *ptr); 236 | 237 | /*! @} */ 238 | 239 | #ifdef __cplusplus 240 | } 241 | #endif 242 | 243 | 244 | #endif /*_GF_LIST_H_*/ 245 | 246 | -------------------------------------------------------------------------------- /include/gpac/internal/ogg.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | * * 3 | * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * 4 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * 5 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * 6 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * 7 | * * 8 | * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 * 9 | * by the Xiph.Org Foundation http://www.xiph.org/ * 10 | * * 11 | ******************************************************************** 12 | 13 | function: code raw [Vorbis] packets into framed OggSquish stream and 14 | decode Ogg streams back into raw packets 15 | 16 | note: The CRC code is directly derived from public domain code by 17 | Ross Williams (ross@guest.adelaide.edu.au). See docs/framing.html 18 | for details. 19 | 20 | ********************************************************************/ 21 | 22 | 23 | #ifndef _GF_OGG_H_ 24 | #define _GF_OGG_H_ 25 | 26 | #include "gpac/tools.h" 27 | 28 | #ifndef GPAC_DISABLE_OGG 29 | 30 | /*DON'T CLASH WITH OFFICIAL OGG IF ALREADY INCLUDED*/ 31 | #ifndef _OGG_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | typedef struct { 38 | s32 endbyte; 39 | s32 endbit; 40 | 41 | unsigned char *buffer; 42 | unsigned char *ptr; 43 | s32 storage; 44 | } oggpack_buffer; 45 | 46 | /* ogg_page is used to encapsulate the data in one Ogg bitstream page *****/ 47 | 48 | typedef struct { 49 | unsigned char *header; 50 | s32 header_len; 51 | unsigned char *body; 52 | s32 body_len; 53 | } ogg_page; 54 | 55 | /* ogg_stream_state contains the current encode/decode state of a logical 56 | Ogg bitstream **********************************************************/ 57 | 58 | typedef struct { 59 | unsigned char *body_data; /* bytes from packet bodies */ 60 | s32 body_storage; /* storage elements allocated */ 61 | s32 body_fill; /* elements stored; fill mark */ 62 | s32 body_returned; /* elements of fill returned */ 63 | 64 | 65 | s32 *lacing_vals; /* The values that will go to the segment table */ 66 | s64 *granule_vals; /* granulepos values for headers. Not compact 67 | this way, but it is simple coupled to the 68 | lacing fifo */ 69 | s32 lacing_storage; 70 | s32 lacing_fill; 71 | s32 lacing_packet; 72 | s32 lacing_returned; 73 | 74 | unsigned char header[282]; /* working space for header encode */ 75 | s32 header_fill; 76 | 77 | s32 e_o_s; /* set when we have buffered the last packet in the 78 | logical bitstream */ 79 | s32 b_o_s; /* set after we've written the initial page 80 | of a logical bitstream */ 81 | s32 serialno; 82 | s32 pageno; 83 | s64 packetno; /* sequence number for decode; the framing 84 | knows where there's a hole in the data, 85 | but we need coupling so that the codec 86 | (which is in a seperate abstraction 87 | layer) also knows about the gap */ 88 | s64 granulepos; 89 | 90 | } ogg_stream_state; 91 | 92 | /* ogg_packet is used to encapsulate the data and metadata belonging 93 | to a single raw Ogg/Vorbis packet *************************************/ 94 | 95 | typedef struct { 96 | unsigned char *packet; 97 | s32 bytes; 98 | s32 b_o_s; 99 | s32 e_o_s; 100 | 101 | s64 granulepos; 102 | 103 | s64 packetno; /* sequence number for decode; the framing 104 | knows where there's a hole in the data, 105 | but we need coupling so that the codec 106 | (which is in a seperate abstraction 107 | layer) also knows about the gap */ 108 | } ogg_packet; 109 | 110 | typedef struct { 111 | unsigned char *data; 112 | s32 storage; 113 | s32 fill; 114 | s32 returned; 115 | 116 | s32 unsynced; 117 | s32 headerbytes; 118 | s32 bodybytes; 119 | } ogg_sync_state; 120 | 121 | 122 | 123 | /* Ogg BITSTREAM PRIMITIVES: bitstream ************************/ 124 | 125 | void oggpack_writeinit(oggpack_buffer *b); 126 | void oggpack_writetrunc(oggpack_buffer *b, s32 bits); 127 | void oggpack_writealign(oggpack_buffer *b); 128 | void oggpack_writecopy(oggpack_buffer *b, void *source, s32 bits); 129 | void oggpack_reset(oggpack_buffer *b); 130 | void oggpack_writeclear(oggpack_buffer *b); 131 | void oggpack_readinit(oggpack_buffer *b, unsigned char *buf, s32 bytes); 132 | void oggpack_write(oggpack_buffer *b, u32 value, s32 bits); 133 | s32 oggpack_look(oggpack_buffer *b, s32 bits); 134 | s32 oggpack_look1(oggpack_buffer *b); 135 | void oggpack_adv(oggpack_buffer *b, s32 bits); 136 | void oggpack_adv1(oggpack_buffer *b); 137 | s32 oggpack_read(oggpack_buffer *b, s32 bits); 138 | s32 oggpack_read1(oggpack_buffer *b); 139 | s32 oggpack_bytes(oggpack_buffer *b); 140 | s32 oggpack_bits(oggpack_buffer *b); 141 | unsigned char *oggpack_get_buffer(oggpack_buffer *b); 142 | 143 | void oggpackB_writeinit(oggpack_buffer *b); 144 | void oggpackB_writetrunc(oggpack_buffer *b, s32 bits); 145 | void oggpackB_writealign(oggpack_buffer *b); 146 | void oggpackB_writecopy(oggpack_buffer *b, void *source, s32 bits); 147 | void oggpackB_reset(oggpack_buffer *b); 148 | void oggpackB_writeclear(oggpack_buffer *b); 149 | void oggpackB_readinit(oggpack_buffer *b, unsigned char *buf, s32 bytes); 150 | void oggpackB_write(oggpack_buffer *b, u32 value, s32 bits); 151 | s32 oggpackB_look(oggpack_buffer *b, s32 bits); 152 | s32 oggpackB_look1(oggpack_buffer *b); 153 | void oggpackB_adv(oggpack_buffer *b, s32 bits); 154 | void oggpackB_adv1(oggpack_buffer *b); 155 | s32 oggpackB_read(oggpack_buffer *b, s32 bits); 156 | s32 oggpackB_read1(oggpack_buffer *b); 157 | s32 oggpackB_bytes(oggpack_buffer *b); 158 | s32 oggpackB_bits(oggpack_buffer *b); 159 | unsigned char *oggpackB_get_buffer(oggpack_buffer *b); 160 | 161 | /* Ogg BITSTREAM PRIMITIVES: encoding **************************/ 162 | 163 | s32 ogg_stream_packetin(ogg_stream_state *os, ogg_packet *op); 164 | s32 ogg_stream_pageout(ogg_stream_state *os, ogg_page *og); 165 | s32 ogg_stream_flush(ogg_stream_state *os, ogg_page *og); 166 | 167 | /* Ogg BITSTREAM PRIMITIVES: decoding **************************/ 168 | 169 | s32 ogg_sync_init(ogg_sync_state *oy); 170 | s32 ogg_sync_clear(ogg_sync_state *oy); 171 | s32 ogg_sync_reset(ogg_sync_state *oy); 172 | s32 ogg_sync_destroy(ogg_sync_state *oy); 173 | 174 | char *ogg_sync_buffer(ogg_sync_state *oy, s32 size); 175 | s32 ogg_sync_wrote(ogg_sync_state *oy, s32 bytes); 176 | s32 ogg_sync_pageseek(ogg_sync_state *oy, ogg_page *og); 177 | s32 ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og); 178 | s32 ogg_stream_pagein(ogg_stream_state *os, ogg_page *og); 179 | s32 ogg_stream_packetout(ogg_stream_state *os, ogg_packet *op); 180 | s32 ogg_stream_packetpeek(ogg_stream_state *os, ogg_packet *op); 181 | 182 | /* Ogg BITSTREAM PRIMITIVES: general ***************************/ 183 | 184 | s32 ogg_stream_init(ogg_stream_state *os, s32 serialno); 185 | s32 ogg_stream_clear(ogg_stream_state *os); 186 | s32 ogg_stream_reset(ogg_stream_state *os); 187 | s32 ogg_stream_reset_serialno(ogg_stream_state *os, s32 serialno); 188 | s32 ogg_stream_destroy(ogg_stream_state *os); 189 | s32 ogg_stream_eos(ogg_stream_state *os); 190 | void ogg_page_checksum_set(ogg_page *og); 191 | s32 ogg_page_version(ogg_page *og); 192 | s32 ogg_page_continued(ogg_page *og); 193 | s32 ogg_page_bos(ogg_page *og); 194 | s32 ogg_page_eos(ogg_page *og); 195 | s64 ogg_page_granulepos(ogg_page *og); 196 | s32 ogg_page_serialno(ogg_page *og); 197 | s32 ogg_page_pageno(ogg_page *og); 198 | s32 ogg_page_packets(ogg_page *og); 199 | 200 | void ogg_packet_clear(ogg_packet *op); 201 | 202 | 203 | #ifdef __cplusplus 204 | } 205 | #endif 206 | 207 | 208 | #endif /*_OGG_H*/ 209 | 210 | #endif /*GPAC_DISABLE_OGG*/ 211 | 212 | #endif /*_GF_OGG_H_*/ 213 | 214 | -------------------------------------------------------------------------------- /doc/INSTALL.wCE: -------------------------------------------------------------------------------- 1 | Installation instructions for GPAC on windows CE platform 2 | last modified: Mai 2012 3 | 4 | 0 Foreword 5 | 6 | ** GPAC IS NO LONGER MAINTAINED ON PocketPC 2002/eVC3 PLATFORMS ** 7 | 8 | Compilation has only been tested with evc4 and ARM platforms 9 | 10 | GPAC should be stable on most devices running PocketPC/SmartPhone 2003. It has know bugs with higher versions 11 | of the Windows Mobile OS, but should still be stable. 12 | 13 | The output directory for all plugins and applications for Windows PocketPC 2003 is 14 | gpac/bin/Smartphone 2003/Debug in debug mode 15 | gpac/bin/Smartphone 2003/Release in release mode 16 | 17 | As of 0.2.2, GPAC cannot be compiled without ZLIB. You'd better make sure it is installed locally or on your system (zlib is provided in gpac_extra_libs package) 18 | 19 | I Extra lib installation 20 | It is recommended to download and compile all extra libs needed by gpac on winCE. 21 | In case you don't do so, you will need to to modify project settings. 22 | 23 | 24 | II GPAC compilation 25 | open /build/msvc8/gpac.sln (GPAC workspace) with MSVC 2005 26 | open /build/msvc9/gpac.sln (GPAC workspace) with MSVC 2008 27 | 28 | NEVER ATTEMPT TO LOAD A PROJECT OUTSIDE THIS WORKSPACE 29 | 30 | II.1 Setting up libgpac 31 | libgpac is the core library of the GPAC framework used by all GPAC applications 32 | 33 | If you have not installed the SpiderMonkey (JavaScript, libjs), JPEG or PNG libraries, remove the indicated macros in the file gpac/include/gpac/internal/config_static.h 34 | 35 | If you are compiling for PocketPC 2003 OS, and wish to use the Intel GPP library, uncomment the desired macro in 36 | the file gpac/include/gpac/internal/config_static.h 37 | 38 | 3D Rendering 39 | GPAC can use OpenGL ES for 3D rendering on embedded devices, but you will need development files of OpenGL ES. 40 | GPAC has been tested with 2 implementations of OpenGL ES: 41 | * HybridGraphics one (cf http://www.hybrid.fi/), by far the most efficient one tested, available for evc4/PockePC 2003 only 42 | * Vincent3D (aka ogl-es, cf http://ogl-es.sourceforge.net/), slower but with good visual results 43 | 44 | To setup OpenGL ES, get one of these libraries, configure the IDE to locate the include and lib files (or copy them in gpac/extra_lib/ which is setup by default) 45 | The GL ES lib shall be named "libGLES_CM.lib" or "libGLES_CL.lib" for the OpenGL-ES Light profile, and the GL ES include files shall be located in a "GLES" directory, the include path pointing to its parent directory. 46 | 47 | NOTE 1: The Klimt library (cf http://studierstube.org/klimt/), which is not 100% OpenGL_ES compliant, may be used but needs some code rewrite here and there, 48 | mainly in gapi video output. 49 | 50 | NOTE 2: If you do not plan to support 3D rendering, uncomment the related macro in the file gpac/include/gpac/internal/config_static.h 51 | 52 | 53 | II.2 Checking Plugins 54 | 55 | Before compiling GPAC plugins, you must make sure the projects are configured with the right libraries 56 | * aac_in 57 | If you have not installed faad2 library, remove the GPAC_HAS_FAAD preprocessor variable from the aac_in project settings. 58 | Note that if no aac decoder is installed for gpac you may as well remove the "aac_in" project from the workspace (DEL). 59 | 60 | * ac3_in 61 | If you have not installed liba52 library, remove the GPAC_HAS_LIBA52 preprocessor variable from the ac3_in project settings. 62 | Note that if no ac3 decoder is installed for gpac you may as well remove the "ac3_in" project from the workspace (DEL). 63 | 64 | * mp3_in 65 | If you have not installed mad library, remove the GPAC_HAS_MAD preprocessor variable from the mp3_in project settings. 66 | Note that if no mp3 decoder is installed for gpac you may as well remove the "mp3_in" project from the workspace (DEL). 67 | 68 | * amr_nb 69 | This plugin handles speech coded data using AMR Narrow Band format. It uses the decoder of the 3GPP consortium (TS26.073) available 70 | from http://www.3gpp.org/ftp/Specs/archive/26_series/26.073/26073-700.zip. 71 | It is the same version included in gpac_extra_libs/AMR_NB with a slight header modifcation. 72 | To compile this plugin, copy the source code to modules/amr_dec/amr_nb WITHOUT OVERWRITING typedefs.h file. 73 | Otherwise, remove the "amr_dec" project from the workspace (DEL). 74 | 75 | * img_in: 76 | If you have not installed libopenjpeg, remove the GPAC_HAS_JP2 preprocessor variable from the img_in project settings 77 | and the relevant library from the link settings 78 | If none of the above lib is installed, you can simply remove the img_in project from the workspace (DEL). 79 | 80 | * ft_font 81 | if you have not installed freetype, remove the project dependecies to freetype in project Osmo4 and MP4Client 82 | NOTE: if you have not installed freetype, you won't have text support at all in GPAC. 83 | 84 | * ogg 85 | if you have not installed libogg library, remove the "ogg" project from the workspace (DEL). 86 | if you have not installed libvorbis library, remove the GPAC_HAS_VORBIS preprocessor variable from the ogg project settings 87 | if you have not installed libtheora library, remove the GPAC_HAS_THEORA preprocessor variable from the ogg project settings 88 | Note that if you have only installed libogg you can also remove the "ogg" project from the workspace, it won't be any usefull. 89 | 90 | * gapi: 91 | you must make sure you have installed the GAPI SDK for windows (also known as GX) before compiling - cf gpac_extra_libs/ReadMe 92 | 93 | II.3 Recompiling 94 | select the target platform (PocketPC or Smartphone) 95 | Rebuild all (Build->Batch Build->Rebuild All) 96 | 97 | Note: 98 | Osmo4 build will fail for smartphone devices, the GPAC GUI available on this platform is Osmophone 99 | 100 | II.4 Launching Osmo4 or Osmophone 101 | Osmo4/Osmophone will automatically create a config file in the Osmo4/Osmophone executable directory if needed. You must copy all plugins to this 102 | directory (recommended), or edit by hand the config file "ModulesDirectory" key to point to the modules directory, otherwise Osmo4/Osmophone will not 103 | launch. You can then launch Osmo4/Osmophone (cf Misc section below) 104 | 105 | III GPAC Installer for WinCE 106 | 107 | The GPAC installer uses MS installer and EZSetup to get an Osmo4/Osmophone installer on PocketPC 2003 Systems 108 | Install scripts are located in gpac/bin/arm_ppc02_rel/install and gpac/bin/arm_ppc03_rel/install 109 | THIS INSTALLER IS ONLY INTENDED FOR STRONGARM BASED DEVICES 110 | 111 | * compile GPAC for PocketPC 2003 112 | * make sure the js.dll is copied in the release build directory if you have compiled GPAC with SpiderMonkey support, otherwise comment lines "js.dll" in gpac.inf 113 | * make sure the libGLES_CM.dll (or libGLES_CL.dll ) is copied in the release build directory if you have compiled with OpenGL ES support, otherwise comment lines "libGLES_CM.dll" and "gm_render3d.dll" in gpac.inf 114 | * make sure the libxml2.dll is copied in the release build directory if you have compiled the svg loader, otherwise comment lines "libxml2.dll" in gpac.inf 115 | * remove any lines in gpac.inf that refer to plugins you have not built. 116 | * if you have built the smartphone version, change AppName and ExeName accordingly in gpac.inf 117 | * get MS PocketPC Cabwizard (search for Cabwiz.exe in your ActiveSync distribution) 118 | * copy cabwiz.exe, cabwiz.ddf and MAKECAB.exe in the install directory 119 | * if needed copy gx.dll in the install directory (download from microsoft, or use gpac extra libs version) 120 | * get Ezsetup from http://www.eskimo.com/~scottlu/win/, and copy it in this directory 121 | * run do.bat file 122 | 123 | IV Misc 124 | 125 | IV.1 Note on Video 126 | As of 0.2.3, the OpenDivx plugin is no longer included in GPAC. A new, modified version of XviD 1.0 for ARM is included (cf gpac/modules/xvid_dec/xvid_wce/ReadMe.txt) 127 | 128 | IV.2 Note on Network 129 | Ipaq devices under WindowsCE below Windows CE .NET 4.1 (and maybe other devices) have a small default UDP buffer size, and this buffer size cannot 130 | be changed through WinSock (software) calls. To increase it, you must manually edit the registry and set (add a DWORD key if not present): 131 | HKEY_LOCAL_MACHINE\Comm\Afd\DgramBuffer 16 132 | 16 is the maximum value possible, DON'T TRY TO SPECIFY MORE. 133 | The device MUST be reseted (soft reset, cf your manual) for the parameter to be taken into account. 134 | 135 | -------------------------------------------------------------------------------- /include/gpac/config_file.h: -------------------------------------------------------------------------------- 1 | /* 2 | * GPAC - Multimedia Framework C SDK 3 | * 4 | * Authors: Jean Le Feuvre 5 | * Copyright (c) Telecom ParisTech 2000-2012 6 | * All rights reserved 7 | * 8 | * This file is part of GPAC / common tools sub-project 9 | * 10 | * GPAC is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU Lesser General Public License as published by 12 | * the Free Software Foundation; either version 2, or (at your option) 13 | * any later version. 14 | * 15 | * GPAC is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Lesser General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public 21 | * License along with this library; see the file COPYING. If not, write to 22 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 23 | * 24 | */ 25 | 26 | #ifndef _GF_CONFIG_FILE_H_ 27 | #define _GF_CONFIG_FILE_H_ 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | /*! 34 | * \file 35 | * \brief configuration file. 36 | */ 37 | 38 | /*! 39 | * \addtogroup cfg_grp Configuration File 40 | * \ingroup utils_grp 41 | * \brief Configuration File object 42 | * 43 | * This section documents the configuration file object of the GPAC framework. 44 | * This file is formatted as the INI file mode of WIN32 in sections and keys.\n 45 | *\note For more information on the GPAC configuration file itself, please refer to the GPAC configuration help provided with GPAC. 46 | * @{ 47 | */ 48 | 49 | #include "gpac/tools.h" 50 | 51 | 52 | typedef struct __tag_config GF_Config; 53 | 54 | /*! 55 | * \brief configuration file initialization 56 | * 57 | * Constructs a configuration file from fileName. If fileName is NULL, the default GPAC configuration file is loaded with the 58 | * proper module directory, font directory and other default options. If fileName is non-NULL no configuration file is found, 59 | * a "light" default configuration file is created. 60 | *\param file name of the configuration file, or NULL for default file 61 | *\param new_cfg Boolean set to true if a new configuration file has been created 62 | *\return the configuration file object, NULL if the file could not be created 63 | */ 64 | GF_Config *gf_cfg_init(const char *file, Bool *new_cfg); 65 | 66 | /*! 67 | * \brief configuration file constructor 68 | * 69 | * Constructs a configuration file. 70 | *\param filePath directory the file is located in 71 | *\param fileName name of the configuration file 72 | *\return the configuration file object, NULL if the file does not exist 73 | */ 74 | GF_Config *gf_cfg_new(const char *filePath, const char *fileName); 75 | /*! 76 | * \brief alternative configuration file constructor 77 | * 78 | * Constructs a configuration file. If file does not exist, configuration will be still created 79 | *\param filePath directory the file is located in 80 | *\param fileName name of the configuration file 81 | *\return the configuration file object, never NULL, even if file does not exist 82 | */ 83 | GF_Config *gf_cfg_force_new(const char *filePath, const char *fileName); 84 | /*! 85 | * \brief configuration file destructor 86 | * 87 | *Destroys the configuration file and saves it if needed. 88 | *\param cfgFile the target configuration file 89 | */ 90 | void gf_cfg_del(GF_Config *cfgFile); 91 | /*! 92 | * \brief configuration file destructor 93 | * 94 | *Destroys the configuration file and removes the file from disk. 95 | *\param cfgFile the target configuration file 96 | */ 97 | void gf_cfg_remove(GF_Config *cfgFile); 98 | /*! 99 | * \brief configuration saving 100 | * 101 | *Saves the configuration file if modified. 102 | *\param cfgFile the target configuration file 103 | */ 104 | GF_Err gf_cfg_save(GF_Config *cfgFile); 105 | /*! 106 | * \brief key value query 107 | * 108 | *Gets a key value from its section and name. 109 | *\param cfgFile the target configuration file 110 | *\param secName the desired key parent section name 111 | *\param keyName the desired key name 112 | *\return the desired key value if found, NULL otherwise. 113 | */ 114 | const char *gf_cfg_get_key(GF_Config *cfgFile, const char *secName, const char *keyName); 115 | /*! 116 | * \brief key value query ignoring case 117 | * 118 | *Gets a key value from its section and name. Comparison is performed while ignoring case. 119 | *\param cfgFile the target configuration file 120 | *\param secName the desired key parent section name (case ignored) 121 | *\param keyName the desired key name (case ignored) 122 | *\return the desired key value if found, NULL otherwise. 123 | */ 124 | const char *gf_cfg_get_ikey(GF_Config *cfgFile, const char *secName, const char *keyName); 125 | /*! 126 | * \brief key value update 127 | * 128 | *Sets a key value from its section and name. 129 | *\param cfgFile the target configuration file 130 | *\param secName the desired key parent section name 131 | *\param keyName the desired key name 132 | *\param keyValue the desired key value 133 | *\note this will also create both section and key if they are not found in the configuration file 134 | */ 135 | GF_Err gf_cfg_set_key(GF_Config *cfgFile, const char *secName, const char *keyName, const char *keyValue); 136 | /*! 137 | * \brief section count query 138 | * 139 | *Gets the number of sections in the configuration file 140 | *\param cfgFile the target configuration file 141 | *\return the number of sections 142 | */ 143 | u32 gf_cfg_get_section_count(GF_Config *cfgFile); 144 | /*! 145 | * \brief section name query 146 | * 147 | *Gets a section name based on its index 148 | *\param cfgFile the target configuration file 149 | *\param secIndex 0-based index of the section to query 150 | *\return the section name if found, NULL otherwise 151 | */ 152 | const char *gf_cfg_get_section_name(GF_Config *cfgFile, u32 secIndex); 153 | /*! 154 | * \brief key count query 155 | * 156 | *Gets the number of keys in a section of the configuration file 157 | *\param cfgFile the target configuration file 158 | *\param secName the target section 159 | *\return the number of keys in the section 160 | */ 161 | u32 gf_cfg_get_key_count(GF_Config *cfgFile, const char *secName); 162 | /*! 163 | * \brief key count query 164 | * 165 | *Gets the number of keys in a section of the configuration file 166 | *\param cfgFile the target configuration file 167 | *\param secName the target section 168 | *\param keyIndex 0-based index of the key in the section 169 | *\return the key name if found, NULL otherwise 170 | */ 171 | const char *gf_cfg_get_key_name(GF_Config *cfgFile, const char *secName, u32 keyIndex); 172 | 173 | /*! 174 | * \brief key insertion 175 | * 176 | *Inserts a new key in a given section. Returns an error if a key with the given name 177 | *already exists in the section 178 | *\param cfgFile the target configuration file 179 | *\param secName the target section 180 | *\param keyName the name of the target key 181 | *\param keyValue the value for the new key 182 | *\param index the 0-based index position of the new key 183 | */ 184 | GF_Err gf_cfg_insert_key(GF_Config *cfgFile, const char *secName, const char *keyName, const char *keyValue, u32 index); 185 | 186 | /*! 187 | * \brief section destrouction 188 | * 189 | *Removes all entries in the given section 190 | *\param cfgFile the target configuration file 191 | *\param secName the target section 192 | */ 193 | void gf_cfg_del_section(GF_Config *cfgFile, const char *secName); 194 | 195 | /*! 196 | * get a sub key (separator is ':') in a given key in a given section. Returns an error if the key does not exist 197 | *\param cfgFile the target configuration file 198 | *\param secName the target section 199 | *\param keyName the name of the target key 200 | *\param sub_index the 0-based index position of the sub key*/ 201 | const char *gf_cfg_get_sub_key(GF_Config *cfgFile, const char *secName, const char *keyName, u32 sub_index); 202 | 203 | /*! 204 | * Get the full filename associated with this config file 205 | * The caller is responsible for freeing memory 206 | * \param iniFile The Configuration 207 | * \return a newly allocated filename 208 | */ 209 | char * gf_cfg_get_filename(GF_Config *iniFile); 210 | 211 | /*! 212 | * Set the full filename associated with this config file 213 | * \param iniFile The Configuration 214 | * \param fileName new filename for the config 215 | * \return erroro code 216 | */ 217 | GF_Err gf_cfg_set_filename(GF_Config *iniFile, const char * fileName); 218 | 219 | 220 | /*! 221 | * Do not save results to file 222 | * \param iniFile The Configuration 223 | * \return error code 224 | */ 225 | GF_Err gf_cfg_discard_changes(GF_Config *iniFile); 226 | 227 | /*! @} */ 228 | 229 | #ifdef __cplusplus 230 | } 231 | #endif 232 | 233 | 234 | #endif /*_GF_CONFIG_FILE_H_*/ 235 | 236 | -------------------------------------------------------------------------------- /src/base_encoding.c: -------------------------------------------------------------------------------- 1 | /* 2 | * GPAC - Multimedia Framework C SDK 3 | * 4 | * Authors: Jean Le Feuvre 5 | * Copyright (c) Telecom ParisTech 2000-2012 6 | * All rights reserved 7 | * 8 | * This file is part of GPAC / common tools sub-project 9 | * 10 | * GPAC is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU Lesser General Public License as published by 12 | * the Free Software Foundation; either version 2, or (at your option) 13 | * any later version. 14 | * 15 | * GPAC is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Lesser General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public 21 | * License along with this library; see the file COPYING. If not, write to 22 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 23 | * 24 | */ 25 | 26 | #include "gpac/base_coding.h" 27 | #include "gpac/constants.h" 28 | 29 | #ifndef GPAC_DISABLE_CORE_TOOLS 30 | 31 | static const char base_64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; 32 | 33 | GF_EXPORT 34 | u32 gf_base64_encode(const char *_in, u32 inSize, char *_out, u32 outSize) 35 | { 36 | s32 padding; 37 | u32 i = 0, j = 0; 38 | unsigned char *in = (unsigned char *)_in; 39 | unsigned char *out = (unsigned char *)_out; 40 | 41 | if (outSize < (inSize * 4 / 3)) return 0; 42 | 43 | while (i < inSize) { 44 | padding = 3 - (inSize - i); 45 | if (padding == 2) { 46 | out[j] = base_64[in[i] >> 2]; 47 | out[j + 1] = base_64[(in[i] & 0x03) << 4]; 48 | out[j + 2] = '='; 49 | out[j + 3] = '='; 50 | } 51 | else if (padding == 1) { 52 | out[j] = base_64[in[i] >> 2]; 53 | out[j + 1] = base_64[((in[i] & 0x03) << 4) | ((in[i + 1] & 0xf0) >> 4)]; 54 | out[j + 2] = base_64[(in[i + 1] & 0x0f) << 2]; 55 | out[j + 3] = '='; 56 | } 57 | else { 58 | out[j] = base_64[in[i] >> 2]; 59 | out[j + 1] = base_64[((in[i] & 0x03) << 4) | ((in[i + 1] & 0xf0) >> 4)]; 60 | out[j + 2] = base_64[((in[i + 1] & 0x0f) << 2) | ((in[i + 2] & 0xc0) >> 6)]; 61 | out[j + 3] = base_64[in[i + 2] & 0x3f]; 62 | } 63 | i += 3; 64 | j += 4; 65 | } 66 | return j; 67 | } 68 | 69 | static const unsigned char index_64[128] = { 70 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 71 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 72 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 62, 0xff, 0xff, 0xff, 63, 73 | 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 74 | 0xff, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 75 | 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0xff, 0xff, 0xff, 0xff, 0xff, 76 | 0xff, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 77 | 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 0xff, 0xff, 0xff, 0xff, 0xff 78 | }; 79 | 80 | #define char64(c) ((c > 127) ? (char) 0xff : index_64[(c)]) 81 | 82 | /*denoise input*/ 83 | u32 load_block(char *in, u32 size, u32 pos, char *out) 84 | { 85 | u32 i, len; 86 | u8 c; 87 | len = i = 0; 88 | while ((len<4) && ((pos + i)= 'A') && (c <= 'Z')) 91 | || ((c >= 'a') && (c <= 'z')) 92 | || ((c >= '0') && (c <= '9')) 93 | || (c == '=') || (c == '+') || (c == '/') 94 | ) { 95 | out[len] = c; 96 | len++; 97 | } 98 | i++; 99 | } 100 | while (len<4) { 101 | out[len] = (char)0xFF; 102 | len++; 103 | } 104 | return pos + i; 105 | } 106 | 107 | GF_EXPORT 108 | u32 gf_base64_decode(char *in_buf, u32 inSize, char *out, u32 outSize) 109 | { 110 | u32 i = 0, j = 0, padding; 111 | unsigned char c[4], in[4]; 112 | 113 | if (outSize < (inSize * 3 / 4)) return 0; 114 | 115 | while ((i + 3) < inSize) { 116 | padding = 0; 117 | i = load_block(in_buf, inSize, i, (char*)in); 118 | c[0] = char64(in[0]); 119 | padding += (c[0] == 0xff); 120 | c[1] = char64(in[1]); 121 | padding += (c[1] == 0xff); 122 | c[2] = char64(in[2]); 123 | padding += (c[2] == 0xff); 124 | c[3] = char64(in[3]); 125 | padding += (c[3] == 0xff); 126 | if (padding == 2) { 127 | out[j++] = (c[0] << 2) | ((c[1] & 0x30) >> 4); 128 | out[j] = (c[1] & 0x0f) << 4; 129 | } 130 | else if (padding == 1) { 131 | out[j++] = (c[0] << 2) | ((c[1] & 0x30) >> 4); 132 | out[j++] = ((c[1] & 0x0f) << 4) | ((c[2] & 0x3c) >> 2); 133 | out[j] = (c[2] & 0x03) << 6; 134 | } 135 | else { 136 | out[j++] = (c[0] << 2) | ((c[1] & 0x30) >> 4); 137 | out[j++] = ((c[1] & 0x0f) << 4) | ((c[2] & 0x3c) >> 2); 138 | out[j++] = ((c[2] & 0x03) << 6) | (c[3] & 0x3f); 139 | } 140 | //i += 4; 141 | } 142 | return j; 143 | } 144 | 145 | static const char base_16[] = "0123456789abcdef"; 146 | 147 | GF_EXPORT 148 | u32 gf_base16_encode(char *_in, u32 inSize, char *_out, u32 outSize) 149 | { 150 | u32 i = 0; 151 | unsigned char *in = (unsigned char *)_in; 152 | unsigned char *out = (unsigned char *)_out; 153 | 154 | if (outSize < (inSize * 2) + 1) return 0; 155 | 156 | for (i = 0; i> 4)]; 158 | out[2 * i + 1] = base_16[(in[i] & 0x0f)]; 159 | } 160 | out[(inSize * 2)] = 0; 161 | 162 | return i; 163 | } 164 | 165 | #define char16(nb) (((nb) < 97) ? ((nb)-48) : ((nb)-87)) 166 | 167 | GF_EXPORT 168 | u32 gf_base16_decode(char *in, u32 inSize, char *out, u32 outSize) 169 | { 170 | u32 j = 0; 171 | u32 c[2] = { 0,0 }; 172 | 173 | if (outSize < (inSize / 2)) return 0; 174 | if ((inSize % 2) != 0) return 0; 175 | 176 | for (j = 0; j 190 | 191 | #define ZLIB_COMPRESS_SAFE 4 192 | 193 | GF_EXPORT 194 | GF_Err gf_gz_compress_payload(char **data, u32 data_len, u32 *max_size) 195 | { 196 | z_stream stream; 197 | int err; 198 | char *dest = (char *)gf_malloc(sizeof(char)*data_len*ZLIB_COMPRESS_SAFE); 199 | stream.next_in = (Bytef*)(*data); 200 | stream.avail_in = (uInt)data_len; 201 | stream.next_out = (Bytef*)dest; 202 | stream.avail_out = (uInt)data_len*ZLIB_COMPRESS_SAFE; 203 | stream.zalloc = (alloc_func)NULL; 204 | stream.zfree = (free_func)NULL; 205 | stream.opaque = (voidpf)NULL; 206 | 207 | err = deflateInit(&stream, 9); 208 | if (err != Z_OK) { 209 | gf_free(dest); 210 | return GF_IO_ERR; 211 | } 212 | 213 | err = deflate(&stream, Z_FINISH); 214 | if (err != Z_STREAM_END) { 215 | deflateEnd(&stream); 216 | gf_free(dest); 217 | return GF_IO_ERR; 218 | } 219 | if (data_len size) { 44 | /*if no ilst type coded, break*/ 45 | sub_type = gf_bs_peek_bits(bs, 32, 0); 46 | if (sub_type) { 47 | e = gf_isom_parse_box(&a, bs); 48 | if (e) return e; 49 | if (ptr->sizesize) return GF_ISOM_INVALID_FILE; 50 | ptr->size -= a->size; 51 | gf_list_add(ptr->other_boxes, a); 52 | } 53 | else { 54 | gf_bs_read_u32(bs); 55 | ptr->size -= 4; 56 | } 57 | } 58 | return GF_OK; 59 | } 60 | 61 | GF_Box *ilst_New() 62 | { 63 | ISOM_DECL_BOX_ALLOC(GF_ItemListBox, GF_ISOM_BOX_TYPE_ILST); 64 | tmp->other_boxes = gf_list_new(); 65 | return (GF_Box *)tmp; 66 | } 67 | 68 | #ifndef GPAC_DISABLE_ISOM_WRITE 69 | 70 | GF_Err ilst_Write(GF_Box *s, GF_BitStream *bs) 71 | { 72 | GF_Err e; 73 | // GF_ItemListBox *ptr = (GF_ItemListBox *)s; 74 | 75 | e = gf_isom_box_write_header(s, bs); 76 | if (e) return e; 77 | 78 | return GF_OK; 79 | } 80 | 81 | 82 | GF_Err ilst_Size(GF_Box *s) 83 | { 84 | GF_Err e; 85 | // GF_ItemListBox *ptr = (GF_ItemListBox *)s; 86 | 87 | e = gf_isom_box_get_size(s); 88 | if (e) return e; 89 | 90 | return GF_OK; 91 | } 92 | 93 | #endif /*GPAC_DISABLE_ISOM_WRITE*/ 94 | 95 | void ListItem_del(GF_Box *s) 96 | { 97 | GF_ListItemBox *ptr = (GF_ListItemBox *)s; 98 | if (ptr == NULL) return; 99 | if (ptr->data != NULL) { 100 | if (ptr->data->data) gf_free(ptr->data->data); 101 | gf_free(ptr->data); 102 | } 103 | gf_free(ptr); 104 | } 105 | 106 | GF_Err ListItem_Read(GF_Box *s, GF_BitStream *bs) 107 | { 108 | GF_Err e; 109 | u32 sub_type; 110 | GF_Box *a = NULL; 111 | GF_ListItemBox *ptr = (GF_ListItemBox *)s; 112 | 113 | /*iTunes way: there's a data atom containing the data*/ 114 | sub_type = gf_bs_peek_bits(bs, 32, 4); 115 | if (sub_type == GF_ISOM_BOX_TYPE_DATA) { 116 | e = gf_isom_parse_box(&a, bs); 117 | if (e) return e; 118 | if (ptr->sizesize) return GF_ISOM_INVALID_FILE; 119 | ptr->size -= a->size; 120 | 121 | if (a && ptr->data) gf_isom_box_del((GF_Box *)ptr->data); 122 | ptr->data = (GF_DataBox *)a; 123 | } 124 | /*QT way*/ 125 | else { 126 | ptr->data->type = 0; 127 | ptr->data->dataSize = gf_bs_read_u16(bs); 128 | gf_bs_read_u16(bs); 129 | ptr->data->data = (char *)gf_malloc(sizeof(char)*(ptr->data->dataSize + 1)); 130 | gf_bs_read_data(bs, ptr->data->data, ptr->data->dataSize); 131 | ptr->data->data[ptr->data->dataSize] = 0; 132 | ptr->size -= ptr->data->dataSize; 133 | } 134 | return GF_OK; 135 | } 136 | 137 | GF_Box *ListItem_New(u32 type) 138 | { 139 | ISOM_DECL_BOX_ALLOC(GF_ListItemBox, type); 140 | 141 | tmp->data = (GF_DataBox *)gf_isom_box_new(GF_ISOM_BOX_TYPE_DATA); 142 | 143 | if (tmp->data == NULL) { 144 | gf_free(tmp); 145 | return NULL; 146 | } 147 | 148 | return (GF_Box *)tmp; 149 | } 150 | 151 | #ifndef GPAC_DISABLE_ISOM_WRITE 152 | 153 | GF_Err ListItem_Write(GF_Box *s, GF_BitStream *bs) 154 | { 155 | GF_Err e; 156 | GF_ListItemBox *ptr = (GF_ListItemBox *)s; 157 | 158 | e = gf_isom_box_write_header(s, bs); 159 | if (e) return e; 160 | 161 | /*iTune way*/ 162 | if (ptr->data->type) return gf_isom_box_write((GF_Box*)ptr->data, bs); 163 | /*QT way*/ 164 | gf_bs_write_u16(bs, ptr->data->dataSize); 165 | gf_bs_write_u16(bs, 0); 166 | gf_bs_write_data(bs, ptr->data->data, ptr->data->dataSize); 167 | return GF_OK; 168 | } 169 | 170 | GF_Err ListItem_Size(GF_Box *s) 171 | { 172 | GF_Err e; 173 | GF_ListItemBox *ptr = (GF_ListItemBox *)s; 174 | 175 | e = gf_isom_box_get_size(s); 176 | if (e) return e; 177 | 178 | /*iTune way*/ 179 | if (ptr->data && ptr->data->type) { 180 | e = gf_isom_box_size((GF_Box *)ptr->data); 181 | if (e) return e; 182 | ptr->size += ptr->data->size; 183 | } 184 | /*QT way*/ 185 | else if (ptr->data) { 186 | ptr->size += ptr->data->dataSize + 4; 187 | } 188 | return GF_OK; 189 | } 190 | 191 | #endif /*GPAC_DISABLE_ISOM_WRITE*/ 192 | 193 | void data_del(GF_Box *s) 194 | { 195 | GF_DataBox *ptr = (GF_DataBox *)s; 196 | if (ptr == NULL) return; 197 | if (ptr->data) 198 | gf_free(ptr->data); 199 | gf_free(ptr); 200 | 201 | } 202 | 203 | GF_Err data_Read(GF_Box *s, GF_BitStream *bs) 204 | { 205 | GF_Err e; 206 | GF_DataBox *ptr = (GF_DataBox *)s; 207 | 208 | e = gf_isom_full_box_read(s, bs); 209 | if (e) return e; 210 | ptr->reserved = gf_bs_read_int(bs, 32); 211 | ptr->size -= 4; 212 | if (ptr->size) { 213 | ptr->dataSize = (u32)ptr->size; 214 | ptr->data = (char*)gf_malloc(ptr->dataSize * sizeof(ptr->data[0]) + 1); 215 | if (ptr->data == NULL) return GF_OUT_OF_MEM; 216 | ptr->data[ptr->dataSize] = 0; 217 | gf_bs_read_data(bs, ptr->data, ptr->dataSize); 218 | } 219 | 220 | return GF_OK; 221 | } 222 | 223 | GF_Box *data_New() 224 | { 225 | ISOM_DECL_BOX_ALLOC(GF_DataBox, GF_ISOM_BOX_TYPE_DATA); 226 | 227 | gf_isom_full_box_init((GF_Box *)tmp); 228 | 229 | return (GF_Box *)tmp; 230 | } 231 | 232 | #ifndef GPAC_DISABLE_ISOM_WRITE 233 | 234 | GF_Err data_Write(GF_Box *s, GF_BitStream *bs) 235 | { 236 | GF_Err e; 237 | GF_DataBox *ptr = (GF_DataBox *)s; 238 | 239 | e = gf_isom_full_box_write(s, bs); 240 | if (e) return e; 241 | gf_bs_write_int(bs, ptr->reserved, 32); 242 | if (ptr->data != NULL && ptr->dataSize > 0) { 243 | gf_bs_write_data(bs, ptr->data, ptr->dataSize); 244 | } 245 | return GF_OK; 246 | } 247 | 248 | GF_Err data_Size(GF_Box *s) 249 | { 250 | GF_Err e; 251 | GF_DataBox *ptr = (GF_DataBox *)s; 252 | e = gf_isom_full_box_get_size(s); 253 | if (e) return e; 254 | ptr->size += 4; 255 | if (ptr->data != NULL && ptr->dataSize > 0) { 256 | ptr->size += ptr->dataSize; 257 | } 258 | return GF_OK; 259 | } 260 | 261 | #endif /*GPAC_DISABLE_ISOM_WRITE*/ 262 | 263 | GF_MetaBox *gf_isom_apple_get_meta_extensions(GF_ISOFile *mov) 264 | { 265 | u32 i; 266 | GF_MetaBox *meta; 267 | GF_UserDataMap *map; 268 | 269 | if (!mov || !mov->moov) return NULL; 270 | 271 | if (!mov->moov->udta) return NULL; 272 | map = udta_getEntry(mov->moov->udta, GF_ISOM_BOX_TYPE_META, NULL); 273 | if (!map) return NULL; 274 | 275 | for (i = 0; i < gf_list_count(map->other_boxes); i++) { 276 | meta = (GF_MetaBox*)gf_list_get(map->other_boxes, i); 277 | 278 | if (meta != NULL && meta->handler != NULL && meta->handler->handlerType == GF_ISOM_HANDLER_TYPE_MDIR) return meta; 279 | } 280 | 281 | return NULL; 282 | } 283 | 284 | #ifndef GPAC_DISABLE_ISOM_WRITE 285 | GF_MetaBox *gf_isom_apple_create_meta_extensions(GF_ISOFile *mov) 286 | { 287 | GF_Err e; 288 | u32 i; 289 | GF_MetaBox *meta; 290 | GF_UserDataMap *map; 291 | 292 | if (!mov || !mov->moov) return NULL; 293 | 294 | if (!mov->moov->udta) { 295 | e = moov_AddBox((GF_Box*)mov->moov, gf_isom_box_new(GF_ISOM_BOX_TYPE_UDTA)); 296 | if (e) return NULL; 297 | } 298 | 299 | map = udta_getEntry(mov->moov->udta, GF_ISOM_BOX_TYPE_META, NULL); 300 | if (map) { 301 | for (i = 0; i < gf_list_count(map->other_boxes); i++) { 302 | meta = (GF_MetaBox*)gf_list_get(map->other_boxes, i); 303 | 304 | if (meta != NULL && meta->handler != NULL && meta->handler->handlerType == GF_ISOM_HANDLER_TYPE_MDIR) return meta; 305 | } 306 | } 307 | 308 | meta = (GF_MetaBox *)gf_isom_box_new(GF_ISOM_BOX_TYPE_META); 309 | 310 | if (meta != NULL) { 311 | meta->handler = (GF_HandlerBox *)gf_isom_box_new(GF_ISOM_BOX_TYPE_HDLR); 312 | if (meta->handler == NULL) { 313 | gf_isom_box_del((GF_Box *)meta); 314 | return NULL; 315 | } 316 | meta->handler->handlerType = GF_ISOM_HANDLER_TYPE_MDIR; 317 | if (!meta->other_boxes) meta->other_boxes = gf_list_new(); 318 | gf_list_add(meta->other_boxes, gf_isom_box_new(GF_ISOM_BOX_TYPE_ILST)); 319 | udta_AddBox(mov->moov->udta, (GF_Box *)meta); 320 | } 321 | 322 | return meta; 323 | } 324 | #endif /*GPAC_DISABLE_ISOM_WRITE*/ 325 | 326 | 327 | #endif /*GPAC_DISABLE_ISOM*/ 328 | -------------------------------------------------------------------------------- /doc/man/mp4client.1: -------------------------------------------------------------------------------- 1 | .TH "MP4Client" 1 "March 2005" "MP4Client" "GPAC" 2 | . 3 | .SH NAME 4 | .LP 5 | MP4Client \- GPAC MPEG-4 command-line Player 6 | .SH "SYNOPSIS" 7 | .LP 8 | .B MP4Client 9 | .RI [options] \ [file] 10 | .br 11 | . 12 | .SH "DESCRIPTION" 13 | .LP 14 | MP4Client is GPAC command-line player. It supports all GPAC playback features (2D and 3D support, local playback, RTP streaming, HTTP faststart, many audio and video codecs ...). MP4Client also supports visual extraction to BMP, RAW or AVI (no compression, no audio). 15 | . 16 | . 17 | .SH STARTUP OPTIONS 18 | .P 19 | .TP 20 | .B \-c file 21 | specifies config file to use. Default config file is located in user home directory and created if not found. 22 | .TP 23 | .B \-rti file 24 | logs run-time information to file. Information logged is: FPS, CPU, Memory usage. 25 | .TP 26 | .B \-quiet 27 | removes script message, buffering and downloading status. 28 | .TP 29 | .B \-strict-error 30 | exits after the first error is reported. 31 | .TP 32 | .B \-log-file FILE 33 | specifies where to write logs. Default is stdout. Same as -lf. 34 | .TP 35 | .B \-logs TOOLS 36 | sets log tools and levels, formatted as a ':'-separated list of toolX[:toolZ]@level. By default all errors are logged. level can be one of quiet, error, warning, info or debug. tool can be: 37 | .br 38 | core: libgpac core 39 | .br 40 | coding: bitstream formats (audio, video, scene) 41 | .br 42 | container: container formats (ISO File, MPEG-2 TS, AVI, ...) 43 | .br 44 | network: network data exept RTP trafic 45 | .br 46 | rtp: rtp trafic 47 | .br 48 | author: authoring tools (hint, import, export) 49 | .br 50 | sync: terminal sync layer 51 | .br 52 | codec: terminal codec messages 53 | .br 54 | parser: scene parsers (svg, xmt, bt) and other 55 | .br 56 | media: terminal media object management 57 | .br 58 | scene: scene graph and scene manager 59 | .br 60 | script: scripting engine messages 61 | .br 62 | interact: interaction engine (events, scripts, etc) 63 | .br 64 | smil: SMIL timing engine 65 | .br 66 | compose: composition engine (2D, 3D, etc) 67 | .br 68 | mmio: Audio/Video HW I/O management 69 | .br 70 | rti: various run-time stats 71 | .br 72 | cache: HTTP cache subsystem 73 | .br 74 | audio: Audio renderer and mixers 75 | .br 76 | mem: GPAC memory tracker 77 | .br 78 | module: GPAC modules debugging 79 | .br 80 | mutex: mutex 81 | .br 82 | none: no tool logged 83 | .br 84 | all: all tools logged - other tools can be specified afterwards. 85 | .br 86 | . 87 | .SH PLAYBACK OPTIONS 88 | A file can be controled during playback by typing one of the following key at prompt. 89 | .TP 90 | .B o 91 | connects to a new URL entered at prompt by user. 92 | .TP 93 | .B r 94 | restarts the current presentation 95 | .TP 96 | .B p 97 | plays/pauses the current presentation 98 | .TP 99 | .B s 100 | step one frame ahead in the current presentation 101 | .TP 102 | .B z 103 | seek into presentation. Seek percentage is entered at prompt 104 | .TP 105 | .B t 106 | prints current timing of the main timeline of the presentation 107 | .TP 108 | .B w 109 | prints world info of the current presentation 110 | .TP 111 | .B v 112 | prints list of all GF_ObjectDescriptor used in current presentation. 113 | .TP 114 | .B i 115 | prints information of a given OD. Object ID is entered at prompt. 116 | .TP 117 | .B b 118 | prints all objects timing and buffering info. 119 | .TP 120 | .B m 121 | prints all objects buffering and memory info. 122 | .TP 123 | .B d 124 | dumps current presentation scene graph to file or stdout. 125 | .TP 126 | .B k 127 | Turns stress mode on/off. 128 | .TP 129 | .B n 130 | Changes current navigation mode if possible/allowed. When a Layer3D is selected, sets layer3D navigation if allowed. 131 | .TP 132 | .B x 133 | Reset to last active viewpoint. When a layer3D is selected, resets layer3D viewpoint. 134 | .TP 135 | .B 2 136 | Reload MPEG-4 Client with GPAC 2D Renderer. 137 | .TP 138 | .B 3 139 | Reload MPEG-4 Client with GPAC 3D Renderer. 140 | .TP 141 | .B 4 142 | forces 4/3 Aspect Ratio. 143 | .TP 144 | .B 5 145 | forces 16/9 Aspect Ratio. 146 | .TP 147 | .B 6 148 | forces no aspect ratio (always fill screen). 149 | .TP 150 | .B 7 151 | forces original Aspect Ratio (default mode). 152 | .TP 153 | .B l 154 | prints the list of available plugins. 155 | .TP 156 | .B c 157 | prints some GPAC configuration info. 158 | .TP 159 | .B q 160 | quits the application. 161 | .TP 162 | .B C 163 | enables streaming cache. 164 | .TP 165 | .B S 166 | stops streaming cache and record it. 167 | .TP 168 | .B A 169 | stops streaming cache and discard it. 170 | .TP 171 | .B h 172 | prints list of available commands. 173 | . 174 | .SH WINDOW SHORTCUTS 175 | When MP4Client window has the focus, the following shortcuts are available 176 | .TP 177 | .B Alt + right 178 | Seeks 5% ahead from current time. 179 | .TP 180 | .B Alt + left 181 | Seeks 5% before the current time 182 | .TP 183 | .B Alt + up 184 | Increases volume by 5% 185 | .TP 186 | .B Alt + down 187 | Decreases volume by 5% 188 | .TP 189 | .B HOME 190 | Resets navigation to last bound viewpoint/viewport 191 | .TP 192 | .B 4, 5, 6, 7 193 | Same as non-window values 194 | .TP 195 | .B ESCAPE , alt+return, doubleclick 196 | Toggles fullscreen on/off. 197 | .TP 198 | .B ctrl + 'f' 199 | Prints current rendering framerate. 200 | .TP 201 | .B ctrl + 'R' 202 | Sends a redraw message (complete scene state recompute). 203 | .TP 204 | .B ctrl + 'P' 205 | Play/Pause. 206 | .TP 207 | .B ctrl + 'S' 208 | Step one frame ahead. 209 | . 210 | .SH CONFIGURATION FILE 211 | When launched for the first time, MP4Client will ask for a font directory and a cache directory. 212 | .TP 213 | .B Font Directory 214 | Indicates the absolute path to a directory containing a TrueType font repository. In case this directory is not specified or does not contain valid TrueType fonts, text will be disabled. 215 | .TP 216 | .B Cache Directory 217 | Indicates the absolute path to a directory with write access to store files retrieved through HTTP downloads. In case this directory is not specified or has no write access HTTP downloads won't work. 218 | . 219 | .SH NAVIGATION 220 | Navigation with MP4Client depends on the renderer type (2D or 3D) and also on content - some content may disable user selectable navigation. 221 | .TP 222 | .B Walk & Fly modes 223 | Mouse: Horizontal move: Horizontal pan - Vertical move: Z-translate - Vertical move+CTRL or Wheel: Vertical pan - Right Click (Walk mode only): Jump 224 | Keys: left/right: Horizontal pan - left/right+CTRL: Horizontal translate - up/down: Z-translate - up/down+CTRL: Vertical pan 225 | .TP 226 | .B Pan mode 227 | Mouse: Horizontal move: Horizontal pan - Vertical move: Vertical pan - Vertical move+CTRL or Wheel: Z-translate 228 | Keys: left/right: Horizontal pan - left/right+CTRL: Horizontal translate - up/down: Vertical pan - up/down+CTRL: Z-translate 229 | .TP 230 | .B Slide mode 231 | Mouse: Horizontal move: Horizontal translate - Vertical move: Vertical translate - Vertical move+CTRL or Wheel: Z-translate 232 | Keys: left/right: Horizontal translate - left/right+CTRL: Horizontal pan - up/down: Vertical translate - up/down+CTRL: Z-translate 233 | .TP 234 | .B Examine & Orbit mode 235 | Mouse: Horizontal move: Y-Axis rotate - Horizontal move+CTRL: No move - Vertical move: X-Axis rotate - Vertical move+CTRL or Wheel: Z-translate 236 | Keys: left/right: Y-Axis rotate - left/right+CTRL: Horizontal translate - up/down: X-Axis rotate - up/down+CTRL: Y-translate 237 | .TP 238 | .B Game mode (press END to escape) 239 | Mouse: Horizontal move: H pan - Vertical move: Vertical pan 240 | Keys: left/right: Horizontal translate - up/down: Z-translate 241 | .TP 242 | .B All 3D modes 243 | CTRL+PGUP/PGDOWN will zoom in/out camera (field of view) 244 | .TP 245 | .B Slide Mode in 2D 246 | Mouse: Horizontal move: Horizontal translate - Vertical move: Vertical translate - V move+CTRL: zoom 247 | Keys: left/right: Horizontal translate - up/down: Vertical translate - up/down+CTRL: zoom 248 | .TP 249 | .B Examine Mode in 2D (3D renderer only) 250 | Mouse: Horizontal move: Y-Axis rotate - Vertical move: X-Axis rotate 251 | Keys: left/right: Y-Axis rotate - up/down: X-Axis rotate 252 | .TP 253 | .B SHIFT 254 | Speeds up movement 255 | . 256 | .SH VISUAL EXTRACTION OPTIONS 257 | When used to dump a visual presentation, the client is no longer interactive. All GPAC features are supported during capture, except audio-related ones. The following options can be passed at prompt: 258 | .P 259 | .TP 260 | .B \-bmp [times] 261 | dumps the specified frames to BMP format. If no time is specified, capture is made at t=0s. time is given in millisecond, as an SMPTE time code or as HH:MM:SS:MS time code. You may specify several frame times by using a dash-separated list of times (eg, '0-10-15'). 262 | .TP 263 | .B \-raw [times] 264 | dumps the specified frames to RAW format. If no time is specified, cpature is made at t=0s. 265 | .TP 266 | .B \-avi start:end 267 | dumps the specified segment to uncompressed AVI format. 268 | .TP 269 | .B \-fps rate 270 | specifies frame rate for AVI dumping. Default frame rate is 25.0. 271 | .TP 272 | .B \-size WxH 273 | specifies frame size for dumping. Default frame size is the scene size. 274 | .TP 275 | .B \-fill 276 | uses fill aspect ratio. By default, the scene aspect ratio is preserved when dumping. 277 | .TP 278 | .B \-show 279 | show window while dumping the content. By default, the window is hidden during capture. 280 | .TP 281 | .B \-2d 282 | forces usage of 2D renderer. By default, MP4Client uses the renderer indicated in GPAC configuration file. 283 | .TP 284 | .B \-3d 285 | forces usage of 3D renderer. By default, MP4Client uses the renderer indicated in GPAC configuration file. 286 | .TP 287 | .B \-quiet 288 | removes script message, buffering and downloading status. 289 | . 290 | .SH "FILES" 291 | .LP 292 | .B GPAC Configuration File: 293 | ~/.gpacrc 294 | . 295 | .SH "AUTHORS" 296 | .LP 297 | Jean Le Feuvre - GPAC (c) 2000-2005 - ENST 2005-200X 298 | . 299 | .SH "SEE ALSO" 300 | .LP 301 | GPAC(1), MP4Box(1) 302 | -------------------------------------------------------------------------------- /src/url.c: -------------------------------------------------------------------------------- 1 | /* 2 | * GPAC - Multimedia Framework C SDK 3 | * 4 | * Authors: Jean Le Feuvre 5 | * Copyright (c) Telecom ParisTech 2000-2012 6 | * All rights reserved 7 | * 8 | * This file is part of GPAC / common tools sub-project 9 | * 10 | * GPAC is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU Lesser General Public License as published by 12 | * the Free Software Foundation; either version 2, or (at your option) 13 | * any later version. 14 | * 15 | * GPAC is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Lesser General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public 21 | * License along with this library; see the file COPYING. If not, write to 22 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 23 | * 24 | */ 25 | 26 | #include "gpac/network.h" 27 | 28 | /* the length of the URL separator ("://" || "|//") */ 29 | #define URL_SEP_LENGTH 3 30 | 31 | /* our supported protocol types */ 32 | enum 33 | { 34 | /*absolute path to file*/ 35 | GF_URL_TYPE_FILE = 0, 36 | /*relative URL*/ 37 | GF_URL_TYPE_RELATIVE, 38 | /*any other URL*/ 39 | GF_URL_TYPE_ANY 40 | }; 41 | 42 | /*resolve the protocol type, for a std URL: http:// or ftp:// ...*/ 43 | static u32 URL_GetProtocolType(const char *pathName) 44 | { 45 | char *begin; 46 | if (!pathName) return GF_URL_TYPE_ANY; 47 | 48 | /* URL with the data scheme are not relative to avoid concatenation */ 49 | if (!strnicmp(pathName, "data:", 5)) return GF_URL_TYPE_ANY; 50 | 51 | if ((pathName[0] == '/') || (pathName[0] == '\\') 52 | || (pathName[1] == ':') 53 | || ((pathName[0] == ':') && (pathName[1] == ':')) 54 | ) return GF_URL_TYPE_FILE; 55 | 56 | begin = strstr(pathName, "://"); 57 | if (!begin) begin = strstr(pathName, "|//"); 58 | if (!begin) return GF_URL_TYPE_RELATIVE; 59 | if (!strnicmp(pathName, "file", 4)) return GF_URL_TYPE_FILE; 60 | return GF_URL_TYPE_ANY; 61 | } 62 | 63 | /*gets protocol type*/ 64 | Bool gf_url_is_local(const char *pathName) 65 | { 66 | u32 mode = URL_GetProtocolType(pathName); 67 | return (mode == GF_URL_TYPE_ANY) ? GF_FALSE : GF_TRUE; 68 | } 69 | 70 | char *gf_url_get_absolute_path(const char *pathName, const char *parentPath) 71 | { 72 | u32 prot_type = URL_GetProtocolType(pathName); 73 | 74 | /*abs path name*/ 75 | if (prot_type == GF_URL_TYPE_FILE) { 76 | /*abs path*/ 77 | if (!strstr(pathName, "://") && !strstr(pathName, "|//")) return gf_strdup(pathName); 78 | pathName += 6; 79 | /*not sure if "file:///C:\..." is std, but let's handle it anyway*/ 80 | if ((pathName[0] == '/') && (pathName[2] == ':')) pathName += 1; 81 | return gf_strdup(pathName); 82 | } 83 | if (prot_type == GF_URL_TYPE_ANY) return NULL; 84 | if (!parentPath) return gf_strdup(pathName); 85 | 86 | /*try with the parent URL*/ 87 | prot_type = URL_GetProtocolType(parentPath); 88 | /*if abs parent path concatenate*/ 89 | if (prot_type == GF_URL_TYPE_FILE) return gf_url_concatenate(parentPath, pathName); 90 | if (prot_type != GF_URL_TYPE_RELATIVE) return NULL; 91 | /*if we are here, parentPath is also relative... return the original PathName*/ 92 | return gf_strdup(pathName); 93 | } 94 | 95 | GF_EXPORT 96 | char *gf_url_concatenate(const char *parentName, const char *pathName) 97 | { 98 | u32 pathSepCount, i, prot_type; 99 | char *outPath, *name, *rad, *tmp2; 100 | char tmp[GF_MAX_PATH]; 101 | 102 | if (!pathName && !parentName) return NULL; 103 | if (!pathName) return gf_strdup(parentName); 104 | if (!parentName) return gf_strdup(pathName); 105 | 106 | if (!strncmp(pathName, "data:", 5)) return gf_strdup(pathName); 107 | 108 | if ((strlen(parentName) > GF_MAX_PATH) || (strlen(pathName) > GF_MAX_PATH)) { 109 | GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("URL too long for concatenation: \n%s\n", pathName)); 110 | return NULL; 111 | } 112 | 113 | prot_type = URL_GetProtocolType(pathName); 114 | if (prot_type != GF_URL_TYPE_RELATIVE) { 115 | char *sep = NULL; 116 | if (pathName[0] == '/') sep = strstr(parentName, "://"); 117 | if (sep) sep = strchr(sep + 3, '/'); 118 | if (sep) { 119 | u32 len; 120 | sep[0] = 0; 121 | len = (u32)strlen(parentName); 122 | outPath = (char*)gf_malloc(sizeof(char)*(len + 1 + strlen(pathName))); 123 | strcpy(outPath, parentName); 124 | strcat(outPath, pathName); 125 | sep[0] = '/'; 126 | } 127 | else { 128 | outPath = gf_strdup(pathName); 129 | } 130 | goto check_spaces; 131 | } 132 | 133 | /*old upnp addressing a la Platinum*/ 134 | rad = strstr(parentName, "%3fpath="); 135 | if (!rad) rad = strstr(parentName, "%3Fpath="); 136 | if (!rad) rad = strstr(parentName, "?path="); 137 | if (rad) { 138 | char *the_path; 139 | rad = strchr(rad, '='); 140 | rad[0] = 0; 141 | the_path = gf_strdup(rad + 1); 142 | i = 0; 143 | while (1) { 144 | if (the_path[i] == 0) break; 145 | if (!strnicmp(the_path + i, "%5c", 3) || !strnicmp(the_path + i, "%2f", 3)) { 146 | the_path[i] = '/'; 147 | memmove(the_path + i + 1, the_path + i + 3, strlen(the_path + i + 3) + 1); 148 | } 149 | else if (!strnicmp(the_path + i, "%05c", 4) || !strnicmp(the_path + i, "%02f", 4)) { 150 | the_path[i] = '/'; 151 | memmove(the_path + i + 1, the_path + i + 4, strlen(the_path + i + 4) + 1); 152 | } 153 | i++; 154 | } 155 | name = gf_url_concatenate(the_path, pathName); 156 | outPath = (char*)gf_malloc(strlen(parentName) + strlen(name) + 2); 157 | sprintf(outPath, "%s=%s", parentName, name); 158 | rad[0] = '='; 159 | gf_free(name); 160 | gf_free(the_path); 161 | return outPath; 162 | } 163 | 164 | /*rewrite path to use / not % encoding*/ 165 | rad = strchr(parentName, '%'); 166 | if (rad && (!strnicmp(rad, "%5c", 3) || !strnicmp(rad, "%05c", 4) || !strnicmp(rad, "%2f", 3) || !strnicmp(rad, "%02f", 4))) { 167 | char *the_path = gf_strdup(parentName); 168 | i = 0; 169 | while (1) { 170 | if (the_path[i] == 0) break; 171 | if (!strnicmp(the_path + i, "%5c", 3) || !strnicmp(the_path + i, "%2f", 3)) { 172 | the_path[i] = '/'; 173 | memmove(the_path + i + 1, the_path + i + 3, strlen(the_path + i + 3) + 1); 174 | } 175 | else if (!strnicmp(the_path + i, "%05c", 4) || !strnicmp(the_path + i, "%02f", 4)) { 176 | the_path[i] = '/'; 177 | memmove(the_path + i + 1, the_path + i + 4, strlen(the_path + i + 4) + 1); 178 | } 179 | i++; 180 | } 181 | name = gf_url_concatenate(the_path, pathName); 182 | gf_free(the_path); 183 | return name; 184 | } 185 | 186 | 187 | pathSepCount = 0; 188 | name = NULL; 189 | if (pathName[0] == '.') { 190 | if (!strcmp(pathName, "..")) { 191 | pathSepCount = 1; 192 | name = ""; 193 | } 194 | if (!strcmp(pathName, "./")) { 195 | pathSepCount = 0; 196 | name = ""; 197 | } 198 | for (i = 0; i< strlen(pathName) - 2; i++) { 199 | /*current dir*/ 200 | if ((pathName[i] == '.') 201 | && ((pathName[i + 1] == GF_PATH_SEPARATOR) || (pathName[i + 1] == '/'))) { 202 | i++; 203 | continue; 204 | } 205 | /*parent dir*/ 206 | if ((pathName[i] == '.') && (pathName[i + 1] == '.') 207 | && ((pathName[i + 2] == GF_PATH_SEPARATOR) || (pathName[i + 2] == '/')) 208 | ) { 209 | pathSepCount++; 210 | i += 2; 211 | name = (char *)&pathName[i + 1]; 212 | } 213 | else { 214 | name = (char *)&pathName[i]; 215 | break; 216 | } 217 | } 218 | } 219 | if (!name) name = (char *)pathName; 220 | 221 | strcpy(tmp, parentName); 222 | while (strchr(" \r\n\t", tmp[strlen(tmp) - 1])) { 223 | tmp[strlen(tmp) - 1] = 0; 224 | } 225 | //strip query part or fragment part 226 | rad = strchr(tmp, '?'); 227 | if (rad) rad[0] = 0; 228 | tmp2 = strrchr(tmp, '/'); 229 | if (!tmp2) tmp2 = strrchr(tmp, '\\'); 230 | if (!tmp2) tmp2 = tmp; 231 | rad = strchr(tmp2, '#'); 232 | if (rad) rad[0] = 0; 233 | 234 | /*remove the last /*/ 235 | for (i = (u32)strlen(tmp); i > 0; i--) { 236 | //break our path at each separator 237 | if ((tmp[i - 1] == GF_PATH_SEPARATOR) || (tmp[i - 1] == '/')) { 238 | tmp[i - 1] = 0; 239 | if (!pathSepCount) break; 240 | pathSepCount--; 241 | } 242 | } 243 | //if i==0, the parent path was relative, just return the pathName 244 | if (!i) { 245 | tmp[i] = 0; 246 | while (pathSepCount) { 247 | strcat(tmp, "../"); 248 | pathSepCount--; 249 | } 250 | } 251 | else { 252 | strcat(tmp, "/"); 253 | } 254 | 255 | i = (u32)strlen(tmp); 256 | outPath = (char *)gf_malloc(i + strlen(name) + 1); 257 | sprintf(outPath, "%s%s", tmp, name); 258 | 259 | /*cleanup paths sep for win32*/ 260 | for (i = 0; i> 7) { 323 | count += 2; 324 | } 325 | } 326 | if (!count) return gf_strdup(path); 327 | outpath = (char*)gf_malloc(sizeof(char) * (len + count + 1)); 328 | strcpy(outpath, path); 329 | 330 | count = 0; 331 | for (i = 0; i> 7) { 341 | do_enc = GF_TRUE; 342 | } 343 | 344 | if (do_enc) { 345 | char szChar[3]; 346 | sprintf(szChar, "%02X", c); 347 | outpath[i + count] = '%'; 348 | outpath[i + count + 1] = szChar[0]; 349 | outpath[i + count + 2] = szChar[1]; 350 | count += 2; 351 | } 352 | else { 353 | outpath[i + count] = c; 354 | } 355 | } 356 | outpath[i + count] = 0; 357 | return outpath; 358 | } 359 | 360 | GF_EXPORT 361 | const char *gf_url_get_resource_name(const char *sURL) 362 | { 363 | char *sep; 364 | if (!sURL) return NULL; 365 | sep = strrchr(sURL, '/'); 366 | if (!sep) sep = strrchr(sURL, '\\'); 367 | if (sep) return sep + 1; 368 | return sURL; 369 | } 370 | 371 | GF_EXPORT 372 | Bool gf_url_get_resource_path(const char *sURL, char *res_path) 373 | { 374 | char *sep; 375 | strcpy(res_path, sURL); 376 | sep = strrchr(res_path, '/'); 377 | if (!sep) sep = strrchr(res_path, '\\'); 378 | if (sep) { 379 | sep[1] = 0; 380 | return GF_TRUE; 381 | } 382 | return GF_FALSE; 383 | } 384 | 385 | 386 | GF_EXPORT 387 | Bool gf_url_remove_last_delimiter(const char *sURL, char *res_path) 388 | { 389 | strcpy(res_path, sURL); 390 | if (sURL[strlen(sURL) - 1] == GF_PATH_SEPARATOR) { 391 | res_path[strlen(sURL) - 1] = 0; 392 | return GF_TRUE; 393 | } 394 | 395 | return GF_FALSE; 396 | } 397 | 398 | GF_EXPORT 399 | const char* gf_url_get_ressource_extension(const char *sURL) { 400 | const char *dot = strrchr(sURL, '.'); 401 | if (!dot || dot == sURL) return ""; 402 | return dot + 1; 403 | } 404 | -------------------------------------------------------------------------------- /include/gpac/avparse.h: -------------------------------------------------------------------------------- 1 | /* 2 | * GPAC - Multimedia Framework C SDK 3 | * 4 | * Authors: Jean Le Feuvre 5 | * Copyright (c) Telecom ParisTech 2000-2012 6 | * All rights reserved 7 | * 8 | * This file is part of GPAC / Authoring Tools sub-project 9 | * 10 | * GPAC is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU Lesser General Public License as published by 12 | * the Free Software Foundation; either version 2, or (at your option) 13 | * any later version. 14 | * 15 | * GPAC is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Lesser General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public 21 | * License along with this library; see the file COPYING. If not, write to 22 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 23 | * 24 | */ 25 | 26 | #ifndef _GF_PARSERS_AV_H_ 27 | #define _GF_PARSERS_AV_H_ 28 | 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | /*! 35 | * \file 36 | * \brief Utility tools for audio and video raw media parsing. 37 | */ 38 | 39 | /*! \defgroup media_grp Media Tools 40 | * You will find in this module the documentation of all media tools in GPAC. 41 | */ 42 | 43 | 44 | /*! 45 | * \addtogroup avp_grp AV Parsing 46 | * \ingroup media_grp 47 | * \brief Utility tools for audio and video raw media parsing. 48 | * 49 | *This section documents the audio and video parsing functions of the GPAC framework. 50 | * @{ 51 | */ 52 | 53 | 54 | #include "gpac/bitstream.h" 55 | 56 | 57 | 58 | /*! 59 | Reduces input width/height to common aspect ration num/denum values 60 | \param width width of the aspect ratio 61 | \param height height of the aspect ratio 62 | */ 63 | void gf_media_reduce_aspect_ratio(u32 *width, u32 *height); 64 | 65 | /*! 66 | Reduces input FPS to a more compact value (eg 25000/1000 -> 25/1) 67 | \param timescale timescale of the aspect ratio 68 | \param sample_dur sample duration of the aspect ratio in the given timescale 69 | */ 70 | void gf_media_get_reduced_frame_rate(u32 *timescale, u32 *sample_dur); 71 | 72 | 73 | /*basic MPEG (1,2,4) visual object parser (DSI extraction and timing/framing)*/ 74 | typedef struct 75 | { 76 | /*video PL*/ 77 | u8 VideoPL; 78 | u8 RAP_stream, objectType, has_shape, enh_layer; 79 | /*video resolution*/ 80 | u16 width, height; 81 | /*pixel aspect ratio*/ 82 | u8 par_num, par_den; 83 | 84 | u16 clock_rate; 85 | u8 NumBitsTimeIncrement; 86 | u32 time_increment; 87 | /*for MPEG 1/2*/ 88 | Double fps; 89 | 90 | u32 next_object_start; 91 | } GF_M4VDecSpecInfo; 92 | 93 | 94 | typedef struct __tag_m4v_parser GF_M4VParser; 95 | 96 | #ifndef GPAC_DISABLE_AV_PARSERS 97 | 98 | GF_M4VParser *gf_m4v_parser_new(char *data, u64 data_size, Bool mpeg12video); 99 | GF_M4VParser *gf_m4v_parser_bs_new(GF_BitStream *bs, Bool mpeg12video); 100 | void gf_m4v_parser_del(GF_M4VParser *m4v); 101 | GF_Err gf_m4v_parse_config(GF_M4VParser *m4v, GF_M4VDecSpecInfo *dsi); 102 | 103 | /*get a frame (can contain GOP). The parser ALWAYS resync on the next object in the bitstream 104 | thus you can seek the bitstream to copy the payload without re-seeking it */ 105 | GF_Err gf_m4v_parse_frame(GF_M4VParser *m4v, GF_M4VDecSpecInfo dsi, u8 *frame_type, u32 *time_inc, u64 *size, u64 *start, Bool *is_coded); 106 | /*returns current object start in bitstream*/ 107 | u64 gf_m4v_get_object_start(GF_M4VParser *m4v); 108 | /*returns 1 if current object is a valid MPEG-4 Visual object*/ 109 | Bool gf_m4v_is_valid_object_type(GF_M4VParser *m4v); 110 | /*decodes DSI/VOSHeader for MPEG4*/ 111 | GF_Err gf_m4v_get_config(char *rawdsi, u32 rawdsi_size, GF_M4VDecSpecInfo *dsi); 112 | /*decodes DSI/VOSHeader for MPEG12*/ 113 | GF_Err gf_mpegv12_get_config(char *rawdsi, u32 rawdsi_size, GF_M4VDecSpecInfo *dsi); 114 | 115 | /*rewrites PL code in DSI*/ 116 | void gf_m4v_rewrite_pl(char **io_dsi, u32 *io_dsi_len, u8 PL); 117 | /*rewrites PAR code in DSI. Negative values will remove the par*/ 118 | GF_Err gf_m4v_rewrite_par(char **o_data, u32 *o_dataLen, s32 par_n, s32 par_d); 119 | 120 | #endif /*GPAC_DISABLE_AV_PARSERS*/ 121 | 122 | /*returns readable description of profile*/ 123 | const char *gf_m4v_get_profile_name(u8 video_pl); 124 | 125 | #ifndef GPAC_DISABLE_AV_PARSERS 126 | s32 gf_mv12_next_start_code(unsigned char *pbuffer, u32 buflen, u32 *optr, u32 *scode); 127 | s32 gf_mv12_next_slice_start(unsigned char *pbuffer, u32 startoffset, u32 buflen, u32 *slice_offset); 128 | 129 | #endif /* GPAC_DISABLE_AV_PARSERS*/ 130 | 131 | #ifndef GPAC_DISABLE_AV_PARSERS 132 | 133 | /*MP3 tools*/ 134 | u8 gf_mp3_num_channels(u32 hdr); 135 | u16 gf_mp3_sampling_rate(u32 hdr); 136 | u16 gf_mp3_window_size(u32 hdr); 137 | u32 gf_mp3_bit_rate(u32 hdr); 138 | u8 gf_mp3_object_type_indication(u32 hdr); 139 | u8 gf_mp3_layer(u32 hdr); 140 | u16 gf_mp3_frame_size(u32 hdr); 141 | u32 gf_mp3_get_next_header(FILE* in); 142 | u32 gf_mp3_get_next_header_mem(const char *buffer, u32 size, u32 *pos); 143 | 144 | #endif /*GPAC_DISABLE_AV_PARSERS*/ 145 | 146 | u8 gf_mp3_version(u32 hdr); 147 | const char *gf_mp3_version_name(u32 hdr); 148 | 149 | 150 | 151 | #if !defined(GPAC_DISABLE_AV_PARSERS) && !defined (GPAC_DISABLE_OGG) 152 | 153 | /*vorbis tools*/ 154 | typedef struct 155 | { 156 | u32 sample_rate, channels, version; 157 | s32 max_r, avg_r, low_r; 158 | u32 min_block, max_block; 159 | 160 | /*do not touch, parser private*/ 161 | Bool is_init; 162 | u32 modebits; 163 | Bool mode_flag[64]; 164 | } GF_VorbisParser; 165 | 166 | /*call with vorbis header packets - you MUST initialize the structure to 0 before!! 167 | returns 1 if success, 0 if error.*/ 168 | Bool gf_vorbis_parse_header(GF_VorbisParser *vp, char *data, u32 data_len); 169 | /*returns 0 if init error or not a vorbis frame, otherwise returns the number of audio samples 170 | in this frame*/ 171 | u32 gf_vorbis_check_frame(GF_VorbisParser *vp, char *data, u32 data_length); 172 | 173 | #endif /*!defined(GPAC_DISABLE_AV_PARSERS) && !defined (GPAC_DISABLE_OGG)*/ 174 | 175 | 176 | enum 177 | { 178 | GF_M4A_AAC_MAIN = 1, 179 | GF_M4A_AAC_LC = 2, 180 | GF_M4A_AAC_SSR = 3, 181 | GF_M4A_AAC_LTP = 4, 182 | GF_M4A_AAC_SBR = 5, 183 | GF_M4A_AAC_SCALABLE = 6, 184 | GF_M4A_TWINVQ = 7, 185 | GF_M4A_CELP = 8, 186 | GF_M4A_HVXC = 9, 187 | GF_M4A_TTSI = 12, 188 | GF_M4A_MAIN_SYNTHETIC = 13, 189 | GF_M4A_WAVETABLE_SYNTHESIS = 14, 190 | GF_M4A_GENERAL_MIDI = 15, 191 | GF_M4A_ALGO_SYNTH_AUDIO_FX = 16, 192 | GF_M4A_ER_AAC_LC = 17, 193 | GF_M4A_ER_AAC_LTP = 19, 194 | GF_M4A_ER_AAC_SCALABLE = 20, 195 | GF_M4A_ER_TWINVQ = 21, 196 | GF_M4A_ER_BSAC = 22, 197 | GF_M4A_ER_AAC_LD = 23, 198 | GF_M4A_ER_CELP = 24, 199 | GF_M4A_ER_HVXC = 25, 200 | GF_M4A_ER_HILN = 26, 201 | GF_M4A_ER_PARAMETRIC = 27, 202 | GF_M4A_SSC = 28, 203 | GF_M4A_AAC_PS = 29, 204 | GF_M4A_LAYER1 = 32, 205 | GF_M4A_LAYER2 = 33, 206 | GF_M4A_LAYER3 = 34, 207 | GF_M4A_DST = 35, 208 | GF_M4A_ALS = 36 209 | }; 210 | 211 | #ifndef GPAC_DISABLE_AV_PARSERS 212 | 213 | static const u32 GF_M4ASampleRates[] = 214 | { 215 | 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 216 | 16000, 12000, 11025, 8000, 7350, 0, 0, 0 217 | }; 218 | 219 | /*new values should now be defined in 23001-8*/ 220 | static const u32 GF_M4ANumChannels[] = 221 | { 222 | 1, 2, 3, 4, 5, 6, 8, 2, 3, 4, 7, 8, 24, 8, 12, 10, 12, 14 223 | }; 224 | 225 | /*returns channel config value (as written in AAC DSI) for the given number of channels*/ 226 | u32 gf_m4a_get_channel_cfg(u32 nb_chan); 227 | 228 | /*get Audio type from dsi. return audio codec type:*/ 229 | typedef struct 230 | { 231 | u32 nb_chan; 232 | u32 base_object_type, base_sr, base_sr_index; 233 | /*SBR*/ 234 | Bool has_sbr; 235 | u32 sbr_object_type, sbr_sr, sbr_sr_index; 236 | /*PS*/ 237 | Bool has_ps; 238 | /*PL indication*/ 239 | u8 audioPL; 240 | 241 | /*program config element*/ 242 | Bool program_config_element_present, mono_mixdown_present, stereo_mixdown_present, matrix_mixdown_idx_present, pseudo_surround_enable; 243 | u8 element_instance_tag, object_type, sampling_frequency_index, num_front_channel_elements, num_side_channel_elements, num_back_channel_elements, num_lfe_channel_elements, num_assoc_data_elements, num_valid_cc_elements; 244 | u8 mono_mixdown_element_number, stereo_mixdown_element_number, matrix_mixdown_idx; 245 | 246 | u8 front_element_is_cpe[15], front_element_tag_select[15]; 247 | u8 side_element_is_cpe[15], side_element_tag_select[15]; 248 | u8 back_element_is_cpe[15], back_element_tag_select[15]; 249 | u8 lfe_element_tag_select[15]; 250 | u8 assoc_data_element_tag_select[15]; 251 | u8 cc_element_is_ind_sw[15], valid_cc_element_tag_select[15]; 252 | u8 comment_field_bytes; 253 | u8 comments[255]; 254 | } GF_M4ADecSpecInfo; 255 | 256 | /*parses dsi and updates audioPL*/ 257 | GF_Err gf_m4a_get_config(char *dsi, u32 dsi_size, GF_M4ADecSpecInfo *cfg); 258 | /*gets audioPL for given cfg*/ 259 | u32 gf_m4a_get_profile(GF_M4ADecSpecInfo *cfg); 260 | 261 | GF_Err gf_m4a_write_config(GF_M4ADecSpecInfo *cfg, char **dsi, u32 *dsi_size); 262 | GF_Err gf_m4a_write_config_bs(GF_BitStream *bs, GF_M4ADecSpecInfo *cfg); 263 | GF_Err gf_m4a_parse_config(GF_BitStream *bs, GF_M4ADecSpecInfo *cfg, Bool size_known); 264 | 265 | #endif /*GPAC_DISABLE_AV_PARSERS*/ 266 | 267 | const char *gf_m4a_object_type_name(u32 objectType); 268 | const char *gf_m4a_get_profile_name(u8 audio_pl); 269 | 270 | #ifndef GPAC_DISABLE_AV_PARSERS 271 | 272 | 273 | typedef struct 274 | { 275 | u32 bitrate; 276 | u32 sample_rate; 277 | u32 framesize; 278 | u32 channels; 279 | u16 substreams; //bit-mask, used for channel map > 5.1 280 | /*only set if full parse*/ 281 | u8 fscod, bsid, bsmod, acmod, lfon, brcode; 282 | } GF_AC3Header; 283 | 284 | Bool gf_ac3_parser(u8 *buffer, u32 buffer_size, u32 *pos, GF_AC3Header *out_hdr, Bool full_parse); 285 | Bool gf_ac3_parser_bs(GF_BitStream *bs, GF_AC3Header *hdr, Bool full_parse); 286 | Bool gf_eac3_parser_bs(GF_BitStream *bs, GF_AC3Header *hdr, Bool full_parse); 287 | u32 gf_ac3_get_channels(u32 acmod); 288 | u32 gf_ac3_get_bitrate(u32 brcode); 289 | 290 | GF_Err gf_avc_get_sps_info(char *sps, u32 sps_size, u32 *sps_id, u32 *width, u32 *height, s32 *par_n, s32 *par_d); 291 | GF_Err gf_avc_get_pps_info(char *pps, u32 pps_size, u32 *pps_id, u32 *sps_id); 292 | 293 | //hevc_state is optional but shall be used for layer extensions since all size info is in VPS and not SPS 294 | GF_Err gf_hevc_get_sps_info(char *sps_data, u32 sps_size, u32 *sps_id, u32 *width, u32 *height, s32 *par_n, s32 *par_d); 295 | #endif /*GPAC_DISABLE_AV_PARSERS*/ 296 | 297 | //get chroma format name from chroma format (1: 420, 2: 422, 3: 444 298 | const char * gf_avc_hevc_get_chroma_format_name(u8 chroma_format); 299 | /*get AVC profile name from profile indication*/ 300 | const char *gf_avc_get_profile_name(u8 profile_idc); 301 | /*returns true if given profile is in range extensions*/ 302 | Bool gf_avc_is_rext_profile(u8 profile_idc); 303 | /*get HEVC profile name from profile indication*/ 304 | const char *gf_hevc_get_profile_name(u8 profile_idc); 305 | 306 | 307 | /*gets image size (bs must contain the whole image) 308 | @OTI: image type (JPEG=0x6C, PNG=0x6D) 309 | @width, height: image resolution - for jpeg max size if thumbnail included*/ 310 | void gf_img_parse(GF_BitStream *bs, u8 *OTI, u32 *mtype, u32 *width, u32 *height, char **dsi, u32 *dsi_len); 311 | 312 | GF_Err gf_img_jpeg_dec(char *jpg, u32 jpg_size, u32 *width, u32 *height, u32 *pixel_format, char *dst, u32 *dst_size, u32 dst_nb_comp); 313 | 314 | GF_Err gf_img_png_dec(char *png, u32 png_size, u32 *width, u32 *height, u32 *pixel_format, char *dst, u32 *dst_size); 315 | GF_Err gf_img_file_dec(char *png_file, u32 *oti, u32 *width, u32 *height, u32 *pixel_format, char **dst, u32 *dst_size); 316 | GF_Err gf_img_png_enc(char *data, u32 width, u32 height, s32 stride, u32 pixel_format, char *dst, u32 *dst_size); 317 | GF_Err gf_img_png_enc_file(char *data, u32 width, u32 height, s32 stride, u32 pixel_format, char *dst_file); 318 | 319 | /*! @} */ 320 | 321 | #ifdef __cplusplus 322 | } 323 | #endif 324 | 325 | 326 | #endif /*_GF_PARSERS_AV_H_*/ 327 | 328 | -------------------------------------------------------------------------------- /src/qos.c: -------------------------------------------------------------------------------- 1 | /* 2 | * GPAC - Multimedia Framework C SDK 3 | * 4 | * Authors: Jean Le Feuvre 5 | * Copyright (c) Telecom ParisTech 2000-2012 6 | * All rights reserved 7 | * 8 | * This file is part of GPAC / MPEG-4 ObjectDescriptor sub-project 9 | * 10 | * GPAC is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU Lesser General Public License as published by 12 | * the Free Software Foundation; either version 2, or (at your option) 13 | * any later version. 14 | * 15 | * GPAC is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Lesser General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public 21 | * License along with this library; see the file COPYING. If not, write to 22 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 23 | * 24 | */ 25 | 26 | #include "gpac/internal/odf_dev.h" 27 | 28 | #ifndef GPAC_MINIMAL_ODF 29 | 30 | /************************************************************ 31 | QoSQualifiers Functions 32 | ************************************************************/ 33 | 34 | GF_EXPORT 35 | GF_QoS_Default *gf_odf_qos_new(u8 tag) 36 | { 37 | 38 | GF_QoS_Default *NewQoS(u8 tag); 39 | 40 | GF_QoS_Default *qos; 41 | 42 | qos = NewQoS(tag); 43 | return qos; 44 | } 45 | 46 | GF_EXPORT 47 | GF_Err gf_odf_qos_del(GF_QoS_Default **qos) 48 | { 49 | if (*qos) gf_odf_delete_qos_qual(*qos); 50 | *qos = NULL; 51 | return GF_OK; 52 | } 53 | 54 | 55 | //same function, but for QoS, as a Qualifier IS NOT a descriptor 56 | GF_EXPORT 57 | GF_Err gf_odf_qos_add_qualif(GF_QoS_Descriptor *desc, GF_QoS_Default *qualif) 58 | { 59 | u32 i; 60 | GF_QoS_Default *def; 61 | 62 | if (desc->tag != GF_ODF_QOS_TAG) return GF_BAD_PARAM; 63 | if (desc->predefined) return GF_ODF_FORBIDDEN_DESCRIPTOR; 64 | 65 | i = 0; 66 | while ((def = (GF_QoS_Default *)gf_list_enum(desc->QoS_Qualifiers, &i))) { 67 | //if same Qualifier, not allowed... 68 | if (def->tag == qualif->tag) return GF_ODF_FORBIDDEN_DESCRIPTOR; 69 | } 70 | return gf_list_add(desc->QoS_Qualifiers, qualif); 71 | } 72 | 73 | void gf_odf_delete_qos_qual(GF_QoS_Default *qos) 74 | { 75 | switch (qos->tag) { 76 | case QoSMaxDelayTag: 77 | case QoSPrefMaxDelayTag: 78 | case QoSLossProbTag: 79 | case QoSMaxGapLossTag: 80 | case QoSMaxAUSizeTag: 81 | case QoSAvgAUSizeTag: 82 | case QoSMaxAURateTag: 83 | gf_free(qos); 84 | return; 85 | 86 | default: 87 | if (((GF_QoS_Private *)qos)->DataLength) 88 | gf_free(((GF_QoS_Private *)qos)->Data); 89 | gf_free((GF_QoS_Private *)qos); 90 | return; 91 | } 92 | } 93 | 94 | 95 | GF_Err gf_odf_size_qos_qual(GF_QoS_Default *qos) 96 | { 97 | if (!qos) return GF_BAD_PARAM; 98 | qos->size = 0; 99 | 100 | switch (qos->tag) { 101 | case QoSMaxDelayTag: 102 | case QoSPrefMaxDelayTag: 103 | case QoSLossProbTag: 104 | case QoSMaxGapLossTag: 105 | case QoSMaxAUSizeTag: 106 | case QoSAvgAUSizeTag: 107 | case QoSMaxAURateTag: 108 | qos->size += 4; 109 | return GF_OK; 110 | 111 | case 0x00: 112 | case 0xFF: 113 | return GF_ODF_FORBIDDEN_DESCRIPTOR; 114 | 115 | default: 116 | qos->size += ((GF_QoS_Private *)qos)->DataLength; 117 | } 118 | return GF_OK; 119 | } 120 | 121 | GF_Err gf_odf_write_qos_qual(GF_BitStream *bs, GF_QoS_Default *qos) 122 | { 123 | GF_Err e; 124 | if (!bs || !qos) return GF_BAD_PARAM; 125 | 126 | e = gf_odf_size_qos_qual(qos); 127 | if (e) return e; 128 | e = gf_odf_write_base_descriptor(bs, qos->tag, qos->size); 129 | if (e) return e; 130 | 131 | switch (qos->tag) { 132 | case QoSMaxDelayTag: 133 | gf_bs_write_int(bs, ((GF_QoS_MaxDelay *)qos)->MaxDelay, 32); 134 | break; 135 | 136 | case QoSPrefMaxDelayTag: 137 | gf_bs_write_int(bs, ((GF_QoS_PrefMaxDelay *)qos)->PrefMaxDelay, 32); 138 | break; 139 | 140 | case QoSLossProbTag: 141 | //FLOAT (double on 4 bytes) 142 | gf_bs_write_float(bs, ((GF_QoS_LossProb *)qos)->LossProb); 143 | break; 144 | 145 | case QoSMaxGapLossTag: 146 | gf_bs_write_int(bs, ((GF_QoS_MaxGapLoss *)qos)->MaxGapLoss, 32); 147 | break; 148 | 149 | case QoSMaxAUSizeTag: 150 | gf_bs_write_int(bs, ((GF_QoS_MaxAUSize *)qos)->MaxAUSize, 32); 151 | break; 152 | 153 | case QoSAvgAUSizeTag: 154 | gf_bs_write_int(bs, ((GF_QoS_AvgAUSize *)qos)->AvgAUSize, 32); 155 | break; 156 | 157 | case QoSMaxAURateTag: 158 | gf_bs_write_int(bs, ((GF_QoS_MaxAURate *)qos)->MaxAURate, 32); 159 | break; 160 | 161 | case 0x00: 162 | case 0xFF: 163 | return GF_ODF_FORBIDDEN_DESCRIPTOR; 164 | 165 | default: 166 | //we defined the private qos... 167 | gf_bs_write_data(bs, ((GF_QoS_Private *)qos)->Data, ((GF_QoS_Private *)qos)->DataLength); 168 | break; 169 | } 170 | return GF_OK; 171 | } 172 | 173 | 174 | 175 | GF_Err gf_odf_parse_qos(GF_BitStream *bs, GF_QoS_Default **qos_qual, u32 *qual_size) 176 | { 177 | u32 tag, qos_size, val, bytesParsed, sizeHeader; 178 | GF_QoS_Default *newQoS; 179 | 180 | //tag 181 | tag = gf_bs_read_int(bs, 8); 182 | bytesParsed = 1; 183 | //size of instance 184 | qos_size = 0; 185 | sizeHeader = 0; 186 | do { 187 | val = gf_bs_read_int(bs, 8); 188 | sizeHeader++; 189 | qos_size <<= 7; 190 | qos_size |= val & 0x7F; 191 | } while (val & 0x80); 192 | bytesParsed += sizeHeader; 193 | 194 | //Payload 195 | switch (tag) { 196 | case QoSMaxDelayTag: 197 | newQoS = (GF_QoS_Default *)gf_malloc(sizeof(GF_QoS_MaxDelay)); 198 | ((GF_QoS_MaxDelay *)newQoS)->MaxDelay = gf_bs_read_int(bs, 32); 199 | bytesParsed += 4; 200 | break; 201 | 202 | case QoSPrefMaxDelayTag: 203 | newQoS = (GF_QoS_Default *)gf_malloc(sizeof(GF_QoS_PrefMaxDelay)); 204 | ((GF_QoS_PrefMaxDelay *)newQoS)->PrefMaxDelay = gf_bs_read_int(bs, 32); 205 | bytesParsed += 4; 206 | break; 207 | 208 | case QoSLossProbTag: 209 | newQoS = (GF_QoS_Default *)gf_malloc(sizeof(GF_QoS_LossProb)); 210 | ((GF_QoS_LossProb *)newQoS)->LossProb = gf_bs_read_float(bs); 211 | bytesParsed += 4; 212 | break; 213 | 214 | case QoSMaxGapLossTag: 215 | newQoS = (GF_QoS_Default *)gf_malloc(sizeof(GF_QoS_MaxGapLoss)); 216 | ((GF_QoS_MaxGapLoss *)newQoS)->MaxGapLoss = gf_bs_read_int(bs, 32); 217 | bytesParsed += 4; 218 | break; 219 | 220 | case QoSMaxAUSizeTag: 221 | newQoS = (GF_QoS_Default *)gf_malloc(sizeof(GF_QoS_MaxAUSize)); 222 | ((GF_QoS_MaxAUSize *)newQoS)->MaxAUSize = gf_bs_read_int(bs, 32); 223 | bytesParsed += 4; 224 | break; 225 | 226 | case QoSAvgAUSizeTag: 227 | newQoS = (GF_QoS_Default *)gf_malloc(sizeof(GF_QoS_AvgAUSize)); 228 | ((GF_QoS_AvgAUSize *)newQoS)->AvgAUSize = gf_bs_read_int(bs, 32); 229 | bytesParsed += 4; 230 | break; 231 | 232 | case QoSMaxAURateTag: 233 | newQoS = (GF_QoS_Default *)gf_malloc(sizeof(GF_QoS_MaxAURate)); 234 | ((GF_QoS_MaxAURate *)newQoS)->MaxAURate = gf_bs_read_int(bs, 32); 235 | bytesParsed += 4; 236 | break; 237 | 238 | case 0x00: 239 | case 0xFF: 240 | return GF_ODF_FORBIDDEN_DESCRIPTOR; 241 | 242 | default: 243 | //we defined the private qos... 244 | newQoS = (GF_QoS_Default *)gf_malloc(sizeof(GF_QoS_Private)); 245 | ((GF_QoS_Private *)newQoS)->DataLength = qos_size; 246 | gf_bs_read_data(bs, ((GF_QoS_Private *)newQoS)->Data, ((GF_QoS_Private *)newQoS)->DataLength); 247 | bytesParsed += ((GF_QoS_Private *)newQoS)->DataLength; 248 | break; 249 | } 250 | newQoS->size = qos_size; 251 | newQoS->tag = tag; 252 | if (bytesParsed != 1 + qos_size + sizeHeader) { 253 | gf_odf_delete_qos_qual(newQoS); 254 | return GF_ODF_INVALID_DESCRIPTOR; 255 | } 256 | *qos_qual = newQoS; 257 | *qual_size = bytesParsed; 258 | return GF_OK; 259 | } 260 | 261 | 262 | GF_QoS_Default *NewQoS(u8 tag) 263 | { 264 | GF_QoS_Default *newQoS; 265 | 266 | switch (tag) { 267 | case QoSMaxDelayTag: 268 | newQoS = (GF_QoS_Default *)gf_malloc(sizeof(GF_QoS_MaxDelay)); 269 | ((GF_QoS_MaxDelay *)newQoS)->MaxDelay = 0; 270 | ((GF_QoS_MaxDelay *)newQoS)->size = 4; 271 | break; 272 | 273 | case QoSPrefMaxDelayTag: 274 | newQoS = (GF_QoS_Default *)gf_malloc(sizeof(GF_QoS_PrefMaxDelay)); 275 | ((GF_QoS_PrefMaxDelay *)newQoS)->PrefMaxDelay = 0; 276 | ((GF_QoS_PrefMaxDelay *)newQoS)->size = 4; 277 | break; 278 | 279 | case QoSLossProbTag: 280 | newQoS = (GF_QoS_Default *)gf_malloc(sizeof(GF_QoS_LossProb)); 281 | ((GF_QoS_LossProb *)newQoS)->LossProb = 0; 282 | ((GF_QoS_LossProb *)newQoS)->size = 4; 283 | break; 284 | 285 | case QoSMaxGapLossTag: 286 | newQoS = (GF_QoS_Default *)gf_malloc(sizeof(GF_QoS_MaxGapLoss)); 287 | ((GF_QoS_MaxGapLoss *)newQoS)->MaxGapLoss = 0; 288 | ((GF_QoS_MaxGapLoss *)newQoS)->size = 4; 289 | break; 290 | 291 | case QoSMaxAUSizeTag: 292 | newQoS = (GF_QoS_Default *)gf_malloc(sizeof(GF_QoS_MaxAUSize)); 293 | ((GF_QoS_MaxAUSize *)newQoS)->MaxAUSize = 0; 294 | ((GF_QoS_MaxAUSize *)newQoS)->size = 0; 295 | break; 296 | 297 | case QoSAvgAUSizeTag: 298 | newQoS = (GF_QoS_Default *)gf_malloc(sizeof(GF_QoS_AvgAUSize)); 299 | ((GF_QoS_AvgAUSize *)newQoS)->AvgAUSize = 0; 300 | ((GF_QoS_AvgAUSize *)newQoS)->size = 4; 301 | break; 302 | 303 | case QoSMaxAURateTag: 304 | newQoS = (GF_QoS_Default *)gf_malloc(sizeof(GF_QoS_MaxAURate)); 305 | ((GF_QoS_MaxAURate *)newQoS)->MaxAURate = 0; 306 | ((GF_QoS_MaxAURate *)newQoS)->size = 4; 307 | break; 308 | 309 | case 0x00: 310 | case 0xFF: 311 | return NULL; 312 | 313 | default: 314 | //we defined the private qos... 315 | newQoS = (GF_QoS_Default *)gf_malloc(sizeof(GF_QoS_Private)); 316 | ((GF_QoS_Private *)newQoS)->DataLength = 0; 317 | ((GF_QoS_Private *)newQoS)->Data = NULL; 318 | break; 319 | } 320 | newQoS->tag = tag; 321 | return newQoS; 322 | } 323 | 324 | // 325 | // Constructor 326 | // 327 | GF_Descriptor *gf_odf_new_qos() 328 | { 329 | GF_QoS_Descriptor *newDesc = (GF_QoS_Descriptor *)gf_malloc(sizeof(GF_QoS_Descriptor)); 330 | if (!newDesc) return NULL; 331 | newDesc->QoS_Qualifiers = gf_list_new(); 332 | newDesc->predefined = 0; 333 | newDesc->tag = GF_ODF_QOS_TAG; 334 | return (GF_Descriptor *)newDesc; 335 | } 336 | 337 | // 338 | // Desctructor 339 | // 340 | GF_Err gf_odf_del_qos(GF_QoS_Descriptor *qos) 341 | { 342 | if (!qos) return GF_BAD_PARAM; 343 | 344 | while (gf_list_count(qos->QoS_Qualifiers)) { 345 | GF_QoS_Default *tmp = (GF_QoS_Default*)gf_list_get(qos->QoS_Qualifiers, 0); 346 | gf_odf_delete_qos_qual(tmp); 347 | gf_list_rem(qos->QoS_Qualifiers, 0); 348 | } 349 | gf_list_del(qos->QoS_Qualifiers); 350 | return GF_OK; 351 | } 352 | 353 | 354 | // 355 | // Reader 356 | // 357 | GF_Err gf_odf_read_qos(GF_BitStream *bs, GF_QoS_Descriptor *qos, u32 DescSize) 358 | { 359 | GF_Err e; 360 | GF_QoS_Default *tmp; 361 | u32 tmp_size, nbBytes = 0; 362 | if (!qos) return GF_BAD_PARAM; 363 | 364 | qos->predefined = gf_bs_read_int(bs, 8); 365 | nbBytes += 1; 366 | 367 | if (qos->predefined) { 368 | if (nbBytes != DescSize) return GF_ODF_INVALID_DESCRIPTOR; 369 | return GF_OK; 370 | } 371 | 372 | while (nbBytes < DescSize) { 373 | tmp = NULL; 374 | e = gf_odf_parse_qos(bs, &tmp, &tmp_size); 375 | if (e) return e; 376 | if (!tmp) return GF_ODF_INVALID_DESCRIPTOR; 377 | e = gf_list_add(qos->QoS_Qualifiers, tmp); 378 | if (e) return e; 379 | nbBytes += tmp_size; 380 | } 381 | if (nbBytes != DescSize) return GF_ODF_INVALID_DESCRIPTOR; 382 | return GF_OK; 383 | } 384 | 385 | 386 | 387 | 388 | // 389 | // Size 390 | // 391 | GF_Err gf_odf_size_qos(GF_QoS_Descriptor *qos, u32 *outSize) 392 | { 393 | GF_Err e; 394 | u32 i; 395 | GF_QoS_Default *tmp; 396 | 397 | if (!qos) return GF_BAD_PARAM; 398 | 399 | *outSize = 1; 400 | 401 | i = 0; 402 | while ((tmp = (GF_QoS_Default *)gf_list_enum(qos->QoS_Qualifiers, &i))) { 403 | e = gf_odf_size_qos_qual(tmp); 404 | if (e) return e; 405 | *outSize += tmp->size + gf_odf_size_field_size(tmp->size); 406 | } 407 | return GF_OK; 408 | } 409 | 410 | // 411 | // Writer 412 | // 413 | GF_Err gf_odf_write_qos(GF_BitStream *bs, GF_QoS_Descriptor *qos) 414 | { 415 | GF_Err e; 416 | u32 size, i; 417 | GF_QoS_Default *tmp; 418 | if (!qos) return GF_BAD_PARAM; 419 | 420 | e = gf_odf_size_descriptor((GF_Descriptor *)qos, &size); 421 | if (e) return e; 422 | e = gf_odf_write_base_descriptor(bs, qos->tag, size); 423 | if (e) return e; 424 | 425 | gf_bs_write_int(bs, qos->predefined, 8); 426 | 427 | if (!qos->predefined) { 428 | i = 0; 429 | while ((tmp = (GF_QoS_Default *)gf_list_enum(qos->QoS_Qualifiers, &i))) { 430 | e = gf_odf_write_qos_qual(bs, tmp); 431 | if (e) return e; 432 | } 433 | } 434 | return GF_OK; 435 | } 436 | 437 | 438 | #endif /*GPAC_MINIMAL_ODF*/ 439 | 440 | -------------------------------------------------------------------------------- /doc/INSTALL.w32: -------------------------------------------------------------------------------- 1 | Installation instructions for GPAC on windows platform 2 | last modified: May 2012 3 | 4 | 0 Foreword 5 | For any question on the installation procedure, please refer to http://gpac.sourceforge.net/home_download.php 6 | 7 | The output directory for all plugins and applications is 8 | gpac/bin/win32/debug in debug mode 9 | gpac/bin/win32/release in release mode 10 | 11 | As of 0.2.2, GPAC cannot be compiled without ZLIB. You'd better make sure it is installed locally or on your system (zlib is provided in gpac_extra_libs package) 12 | 13 | I Extra lib installation 14 | 15 | It is recommended to download and compile all extra libs needed by gpac on windows. Please read carefull the ReadMe file included in the gpac_extra_libs package 16 | 17 | 18 | II GPAC compilation 19 | 20 | open the GPAC workspace: 21 | gpac/build/msvc6/GPAC.dsw with MSVC6 22 | gpac/build/msvc8/gpac.sln with VS2005 23 | gpac/build/msvc9/gpac.sln with VS2008 24 | 25 | NEVER ATTEMPT TO LOAD A PROJECT OUTSIDE THIS WORKSPACE, AS DEPENDENCY RULES WILL BE BROKEN 26 | 27 | II.1 Recompiling GPAC 28 | libgpac is the core library of the GPAC framework used by all GPAC applications. It is available as a static library and as a dynamic one 29 | Set the "libgpac_dll" project as the active one 30 | If you have not installed the SpiderMonkey (JavaScript, libjs), JPEG or PNG libraries, remove the indicated macros in the file gpac/include/gpac/internal/config_static.h 31 | recompile (libgpac_dll compilation will fail if zlib is not found) 32 | 33 | Note: If you wish to build the fixed-point version of GPAC (not recommended), you will have to modify by hand the file gpac/include/gpac/maths.h 34 | and replace the line 35 | #define GPAC_NO_FIXED_POINT 36 | by the line 37 | #define GPAC_FIXED_POINT 38 | 39 | !!Do not attempts to enable fixed-point compilation in any other way!! 40 | 41 | II.2 Recompiling MP4Box 42 | MP4Box is GPAC command-line tool for content authoring. 43 | Set the "MP4Box" project as the active one 44 | Recompile 45 | 46 | II.3 Plugins check 47 | Before compiling other applications in GPAC you must make sure the projects are configured with the right libraries 48 | 49 | * aac_in 50 | If you have not installed faad2 library, remove the GPAC_HAS_FAAD preprocessor variable from the aac_in project settings. 51 | Note that if no aac decoder is installed for gpac you may as well remove the "aac_in" project from the workspace (DEL). 52 | 53 | * ac3_in 54 | If you have not installed liba52 library, remove the GPAC_HAS_LIBA52 preprocessor variable from the ac3_in project settings. 55 | Note that if no ac3 decoder is installed for gpac you may as well remove the "ac3_in" project from the workspace (DEL). 56 | 57 | * mp3_in 58 | If you have not installed mad library, remove the GPAC_HAS_MAD preprocessor variable from the mp3_in project settings. 59 | Note that if no mp3 decoder is installed for gpac you may as well remove the "mp3_in" project from the workspace (DEL). 60 | 61 | * xvid_dec 62 | if you have not installed xvid library, remove the "xvid_dec" project from the workspace (DEL). 63 | 64 | * img_in: 65 | If you have not installed libopenjpeg, remove the GPAC_HAS_JP2 preprocessor variable from the img_in project settings 66 | and the relevant library from the link settings 67 | If you have not installed any of the above libraries, you may remove the "img_in" project from the workspace (DEL). 68 | 69 | * amr_float_dec 70 | This plugin handles speech coded data using AMR Narrow Band and Wide Band formats. It uses two decoders from the 3GPP consortium available at: 71 | AMR Narrowband decoder: http://www.3gpp.org/ftp/Specs/archive/26_series/26.104/26104-700.zip 72 | AMR Wideband decoder: http://www.3gpp.org/ftp/Specs/archive/26_series/26.204/26204-710.zip 73 | 74 | (The same versions are included in gpac_extra_libs/AMR_NB_FT and gpac_extra_libs/AMR_WB_FT ) 75 | 76 | To compile this plugin, copy the source code to modules/amr_float_dec/amr_nb_ft and modules/amr_float_dec/amr_wb_ft respectively, WITHOUT OVERWRITING typedefs.h files. 77 | You may as well compile with only one of these libraries installed: 78 | If you have not installed AMR NB, remove the GPAC_HAS_AMR_FT preprocessor variable from the amr_float_dec project settings 79 | If you have not installed AMR WB, remove the GPAC_HAS_AMR_FT_WB preprocessor variable from the amr_float_dec project settings 80 | Otherwise, remove the "amr_float_dec" project from the workspace (DEL). 81 | 82 | * amr_dec 83 | This plugin handles speech coded data using AMR Narrow Band format with a fixed-point decoder (suited for embedded platforms). 84 | It uses the decoder of the 3GPP consortium (TS26.073) available from http://www.3gpp.org/ftp/Specs/archive/26_series/26.073/26073-700.zip. 85 | It is the same version included in gpac_extra_libs/AMR_NB with a slight header modifcation. 86 | To compile this plugin, copy the source code to modules/amr_dec/amr_nb WITHOUT OVERWRITING typedefs.h file. 87 | Otherwise, remove the "amr_dec" project from the workspace (DEL). Note you usually won't need this plugin, the float version of the decoders being much faster. 88 | 89 | * ffmpeg_in 90 | To install ffmpeg libraries, cf gpac_extra_libs/ReadMe 91 | if you have not installed ffmpeg libraries (avcodec.lib/dll, avformat.lib/dll, avutil.lib/dll), remove the "ffmpeg_in" project from the workspace (DEL). 92 | 93 | * ft_font 94 | if you have not installed freetype, simply remove the "ft_font" project from the workspace (DEL). 95 | 96 | * gdip_rend 97 | To install GDIPLus, either get Microsft PlatformSDK (http://www.microsoft.com/msdownload/platformsdk/sdkupdate/) or read gpac_extra_libs/GDIPlus/install.txt 98 | if you have not installed GDIPlus or WindowsSDK, remove the "gdip_rend" project from the workspace (DEL). 99 | 100 | * ogg 101 | if you have not installed libogg library, remove the "ogg" project from the workspace (DEL). 102 | if you have not installed libvorbis library, remove the GPAC_HAS_VORBIS preprocessor variable from the ogg project settings 103 | if you have not installed libtheora library, remove the GPAC_HAS_THEORA preprocessor variable from the ogg project settings 104 | Note that if you have only installed libogg you can also remove the "ogg" project from the workspace, it won't be any usefull. 105 | 106 | * sdl_out: 107 | GPAC can use SDL library for audio (all clients) and video (MP4Client and wxOsmo4) output. 108 | You will need to get SDL 1.2 for windows. Get it at http://www.libsdl.org/download-1.2.php. You need the DEVELOPMENT LIBRARY SDL-devel-1.2.7-VC6.zip 109 | Unpack and setup your path or VisualC++ for SDL include and lib directories (you may need to restart VisualC++) 110 | You will need to modify your VC settings to look for libxml headers and library directories. 111 | If you don't want to install libSDL or don't plan to use MP4Client or wxOsmo4, simply remove the "sdl_out" project from the workspace (DEL). 112 | NOTE: SDL is not needed at all on windows, you will still have audio and video support without SDL. The SDL plugin is much slower than the directX plugin 113 | when dealing with video since it uses software YUV to RGB conversion. 114 | 115 | NOTE: if you have not installed GDIPlus nor freetype, you won't have text support at all in GPAC. 116 | 117 | 118 | II.4 Recompiling Osmo4 119 | Osmo4 is the GUI MPEG-4 player of GPAC for the windows platform. 120 | Set Osmo4 as the active project 121 | recompile (enabled plugins will be recompiled in the process) 122 | 123 | II.5 Recompiling MP4Client 124 | MP4Client is the command MPEG-4 player of GPAC. 125 | Set MP4Client as the active project 126 | recompile (enabled plugins will be recompiled in the process) 127 | 128 | II.6 Recompiling Osmo4/wxWidgets 129 | Osmo4 / wxWidgets is the cross-platform GUI MPEG-4 player of GPAC. You must have wxWidgets 2.6.0 installed and configured on your system (this may be tricky. Please 130 | make sure you can recompile some sample wxWidgets applications from wxWidgets distribution first). 131 | Set wxOsmo4 as the active project 132 | recompile (some plugins may be recompiled in the process). You may need to change the linker settings, depending on your wxWidgets version and config 133 | 134 | II.7 Recompiling Osmozilla 135 | Osmozilla is GPAC plugin for Mozilla-based browsers, enabling embedding all GPAC supported contents in a web page. Recompile it only if you think it may 136 | be helpful. 137 | * Get the gecko sdk (http://ftp.mozilla.org/pub/mozilla.org/mozilla/releases/mozilla1.7.13/gecko-sdk-i586-pc-msvc-1.7.13.zip or in the gpac_extra_libs package) 138 | * Extract it to gpac/extra_lib/include/gecko-sdk 139 | * Set Osmozilla as the active project and recompile 140 | 141 | II.7 Recompiling GPAX 142 | GPAX is GPAC ActiveX control, only usable as an Internet Explorer plugin for now, enabling to embed all GPAC supported contents in a web page. Recompile it only if you think it may 143 | be helpful (Set as the active project and recompile) 144 | 145 | III Launching the applications 146 | 147 | If you have compiled libgpac with SpiderMonkey (JavaScript) enabled, copy the JS32.dll file in the output directory. 148 | 149 | Some applications need to locate the GPAC configuration file called GPAC.cfg. This file is automatically generated by Osmo4 in its directory. It is recommended 150 | to first launch Osmo4 to get a working config file. 151 | For more information regarding the config file, cf gpac/doc/configuration.html 152 | 153 | You can launch Osmo4 as is, the application should start and be operational right away. 154 | 155 | You can use MP4Box as is. 156 | 157 | MP4Client needs GPAC configuration file to run. It will by default search for the file in the current directory, and some hardcoded directories that will likely not work. 158 | If the config file is not found, a new one is created in the current directory. You can pass a given config file as a parameter (MP4Client -c config_path). 159 | You can also modify the hardcoded path in MP4Client (gpac/Applications/MP4Client/main.c) to point to gpac output directory and recompile. 160 | 161 | 162 | Osmozilla cannot be launched without a mozilla-based web browser. You should not try to install it in any other way than with the GPAC installer 163 | (cf below). Once installed, you may try any test in an html page viewed with your browser, for example: 164 | 165 | 166 | 167 | To make sure your browser has loaded the osmozilla plugin and to check the mime types supported, try typing "about:plugins" in your browser address bar. 168 | 169 | GPAX cannot be launched without Internet Explorer. You should not try to install it in any other way than with the GPAC installer 170 | (cf below). Once installed, you may try any test in an html page viewed with your browser, for instance: 171 | 172 | 173 | 174 | 175 | 176 | IV Configuration 177 | 178 | IV.0 Foreword 179 | All configuration information is described in gpac/doc/configuration.html, or man gpac. 180 | 181 | IV.1 OpenGL 182 | OpenGL is badly known for performing quite poorly as far as high data rate texturing is involved. This is a big issue when displaying a typical movie and you 183 | will likely find the GPAC 3D Renderer very slow on your system. If your GPU supports non power of 2 texturing or rectangular texturing (most Win32 drivers do) 184 | you shouldn't have any problem with video. Otherwise here are some tips to configure GPAC on your system: 185 | 1- set the "BitmapCopyPixels" option on: some cards perform rather well at direct pixel transfer. If no improvement, set it off. 186 | 2- set the "BitmapCopyPixels" option off and the "EmulatePOW2" option on. This will trick the GL texturing by using only Power Of 2 textures when converting 187 | from YUV to RGB. 188 | 3- If this does not improve video playback, you're only chance is through discussion forums & co to gather info about your system, your GL implementation 189 | and how to fine-tune it. 190 | 191 | V Misc 192 | 193 | V.1 Scene Generators 194 | In gpac/applications/generators you will find the code generators for MPEG-4, X3D and SVG scene graphs used in gpac. 195 | If you want to modify the set of nodes understood by GPAC in encoding/decoding/rendering, you will need those. 196 | The Scene generators can be recompiled without dependencies to extra libraries nor libgpac library. 197 | To recompile them, open the related project files (.dsp) and recompile. 198 | To use them, cf gpac/doc/SceneGenerators 199 | 200 | VI.2 V4Studio 201 | V4Studio is a very simple authoring tool for 2D content. It is not usable but may interest developers. 202 | For Installation instructions cf gpac/Applications/V4Studio/install 203 | 204 | VI.3 GPAC Installer 205 | The GPAC installer uses the NSIS installing system. The installation script is gpac/bin/w32_rel/install/GPAC_Install.nsi 206 | - Before building the installer 207 | * get NullSoft installer (nsis.sourceforge.net), at least version 2.0 208 | * make sure the js32.dll is copied in the gpac/bin/w32_rel dir if you have compiled GPAC with SpiderMonkey support, otherwise comment 209 | out "..\js32.dll" line from the install script 210 | * copy gdiplus.dll to gpac/bin/w32_rel/install 211 | * make sure avcodec.dll and avformat.dll are copied in gpac/bin/w32_rel if you have built ffmpeg plugin 212 | * make sure iconv.dll, libxml2.dll, zlib1.dll in gpac/bin/w32_rel if you have compiled libxml2 213 | 214 | - Building GPAC installer 215 | The installer includes Osmo4, MP4Box, Osmozilla and all modules except SDL_out and raw_out. To install, right click on "GPAC_Install.nsi" and compile 216 | For other configurations, modify the script "GPAC_Install.nsi" to comment out unwanted features 217 | 218 | -------------------------------------------------------------------------------- /src/configfile.c: -------------------------------------------------------------------------------- 1 | /* 2 | * GPAC - Multimedia Framework C SDK 3 | * 4 | * Authors: Jean Le Feuvre 5 | * Copyright (c) Telecom ParisTech 2000-2012 6 | * All rights reserved 7 | * 8 | * This file is part of GPAC / common tools sub-project 9 | * 10 | * GPAC is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU Lesser General Public License as published by 12 | * the Free Software Foundation; either version 2, or (at your option) 13 | * any later version. 14 | * 15 | * GPAC is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Lesser General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public 21 | * License along with this library; see the file COPYING. If not, write to 22 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 23 | * 24 | */ 25 | 26 | #include "gpac/config_file.h" 27 | #include "gpac/list.h" 28 | 29 | #define MAX_INI_LINE 2046 30 | 31 | typedef struct 32 | { 33 | char *name; 34 | char *value; 35 | } IniKey; 36 | 37 | typedef struct 38 | { 39 | char *section_name; 40 | GF_List *keys; 41 | } IniSection; 42 | 43 | struct __tag_config 44 | { 45 | char *fileName; 46 | GF_List *sections; 47 | Bool hasChanged, skip_changes; 48 | }; 49 | 50 | 51 | static void DelSection(IniSection *ptr) 52 | { 53 | IniKey *k; 54 | if (!ptr) return; 55 | if (ptr->keys) { 56 | while (gf_list_count(ptr->keys)) { 57 | k = (IniKey *)gf_list_get(ptr->keys, 0); 58 | if (k->value) gf_free(k->value); 59 | if (k->name) gf_free(k->name); 60 | gf_free(k); 61 | gf_list_rem(ptr->keys, 0); 62 | } 63 | gf_list_del(ptr->keys); 64 | } 65 | if (ptr->section_name) gf_free(ptr->section_name); 66 | gf_free(ptr); 67 | } 68 | 69 | /*! 70 | * \brief Clear the structure 71 | * \param iniFile The structure to clear 72 | */ 73 | static void gf_cfg_clear(GF_Config * iniFile) { 74 | IniSection *p; 75 | if (!iniFile) return; 76 | if (iniFile->sections) { 77 | while (gf_list_count(iniFile->sections)) { 78 | p = (IniSection *)gf_list_get(iniFile->sections, 0); 79 | DelSection(p); 80 | gf_list_rem(iniFile->sections, 0); 81 | } 82 | gf_list_del(iniFile->sections); 83 | } 84 | if (iniFile->fileName) 85 | gf_free(iniFile->fileName); 86 | memset((void *)iniFile, 0, sizeof(GF_Config)); 87 | } 88 | 89 | /*! 90 | * \brief Parses the config file if any and clears the existing structure 91 | */ 92 | GF_Err gf_cfg_parse_config_file(GF_Config * tmp, const char * filePath, const char * file_name) 93 | { 94 | IniSection *p; 95 | IniKey *k; 96 | FILE *file; 97 | char *ret; 98 | char *line; 99 | u32 line_alloc = MAX_INI_LINE; 100 | char fileName[GF_MAX_PATH]; 101 | 102 | gf_cfg_clear(tmp); 103 | 104 | if (filePath && ((filePath[strlen(filePath) - 1] == '/') || (filePath[strlen(filePath) - 1] == '\\'))) { 105 | strcpy(fileName, filePath); 106 | strcat(fileName, file_name); 107 | } 108 | else if (filePath) { 109 | sprintf(fileName, "%s%c%s", filePath, GF_PATH_SEPARATOR, file_name); 110 | } 111 | else { 112 | strcpy(fileName, file_name); 113 | } 114 | 115 | tmp->fileName = gf_strdup(fileName); 116 | tmp->sections = gf_list_new(); 117 | file = gf_fopen(fileName, "rt"); 118 | if (!file) 119 | return GF_IO_ERR; 120 | /* load the file */ 121 | p = NULL; 122 | line = (char*)gf_malloc(sizeof(char)*line_alloc); 123 | memset(line, 0, sizeof(char)*line_alloc); 124 | 125 | while (!feof(file)) { 126 | u32 read, nb_pass; 127 | ret = fgets(line, line_alloc, file); 128 | read = (u32)strlen(line); 129 | nb_pass = 1; 130 | while (read + nb_pass == line_alloc) { 131 | line_alloc += MAX_INI_LINE; 132 | line = (char*)gf_realloc(line, sizeof(char)*line_alloc); 133 | ret = fgets(line + read, MAX_INI_LINE, file); 134 | read = (u32)strlen(line); 135 | nb_pass++; 136 | } 137 | if (!ret) continue; 138 | 139 | /* get rid of the end of line stuff */ 140 | while (1) { 141 | u32 len = (u32)strlen(line); 142 | if (!len) break; 143 | if ((line[len - 1] != '\n') && (line[len - 1] != '\r')) break; 144 | line[len - 1] = 0; 145 | } 146 | if (!strlen(line)) continue; 147 | if (line[0] == '#') continue; 148 | 149 | 150 | /* new section */ 151 | if (line[0] == '[') { 152 | p = (IniSection *)gf_malloc(sizeof(IniSection)); 153 | p->keys = gf_list_new(); 154 | p->section_name = gf_strdup(line + 1); 155 | p->section_name[strlen(line) - 2] = 0; 156 | while (p->section_name[strlen(p->section_name) - 1] == ']' || p->section_name[strlen(p->section_name) - 1] == ' ') p->section_name[strlen(p->section_name) - 1] = 0; 157 | gf_list_add(tmp->sections, p); 158 | } 159 | else if (strlen(line) && (strchr(line, '=') != NULL)) { 160 | if (!p) { 161 | gf_list_del(tmp->sections); 162 | gf_free(tmp->fileName); 163 | gf_free(tmp); 164 | gf_fclose(file); 165 | gf_free(line); 166 | return GF_IO_ERR; 167 | } 168 | 169 | k = (IniKey *)gf_malloc(sizeof(IniKey)); 170 | memset((void *)k, 0, sizeof(IniKey)); 171 | ret = strchr(line, '='); 172 | if (ret) { 173 | ret[0] = 0; 174 | k->name = gf_strdup(line); 175 | while (k->name[strlen(k->name) - 1] == ' ') k->name[strlen(k->name) - 1] = 0; 176 | ret[0] = '='; 177 | ret += 1; 178 | while (ret[0] == ' ') ret++; 179 | if (ret[0] != 0) { 180 | k->value = gf_strdup(ret); 181 | while (k->value[strlen(k->value) - 1] == ' ') k->value[strlen(k->value) - 1] = 0; 182 | } 183 | else { 184 | k->value = gf_strdup(""); 185 | } 186 | } 187 | gf_list_add(p->keys, k); 188 | } 189 | } 190 | gf_free(line); 191 | gf_fclose(file); 192 | return GF_OK; 193 | } 194 | 195 | GF_EXPORT 196 | GF_Config *gf_cfg_force_new(const char *filePath, const char* file_name) { 197 | GF_Config *tmp = (GF_Config *)gf_malloc(sizeof(GF_Config)); 198 | memset((void *)tmp, 0, sizeof(GF_Config)); 199 | gf_cfg_parse_config_file(tmp, filePath, file_name); 200 | return tmp; 201 | } 202 | 203 | 204 | GF_EXPORT 205 | GF_Config *gf_cfg_new(const char *filePath, const char* file_name) 206 | { 207 | GF_Config *tmp = (GF_Config *)gf_malloc(sizeof(GF_Config)); 208 | memset((void *)tmp, 0, sizeof(GF_Config)); 209 | if (!filePath && !file_name) { 210 | tmp->sections = gf_list_new(); 211 | return tmp; 212 | } 213 | 214 | if (gf_cfg_parse_config_file(tmp, filePath, file_name)) { 215 | gf_cfg_clear(tmp); 216 | gf_free(tmp); 217 | tmp = NULL; 218 | } 219 | return tmp; 220 | } 221 | 222 | GF_EXPORT 223 | char * gf_cfg_get_filename(GF_Config *iniFile) 224 | { 225 | if (!iniFile) 226 | return NULL; 227 | return iniFile->fileName ? gf_strdup(iniFile->fileName) : NULL; 228 | } 229 | 230 | GF_EXPORT 231 | GF_Err gf_cfg_save(GF_Config *iniFile) 232 | { 233 | u32 i, j; 234 | IniSection *sec; 235 | IniKey *key; 236 | FILE *file; 237 | 238 | if (!iniFile->hasChanged) return GF_OK; 239 | if (iniFile->skip_changes) return GF_OK; 240 | if (!iniFile->fileName) return GF_OK; 241 | 242 | file = gf_fopen(iniFile->fileName, "wt"); 243 | if (!file) return GF_IO_ERR; 244 | 245 | i = 0; 246 | while ((sec = (IniSection *)gf_list_enum(iniFile->sections, &i))) { 247 | /*Temporary sections are not saved*/ 248 | if (!strnicmp(sec->section_name, "Temp", 4)) continue; 249 | 250 | fprintf(file, "[%s]\n", sec->section_name); 251 | j = 0; 252 | while ((key = (IniKey *)gf_list_enum(sec->keys, &j))) { 253 | fprintf(file, "%s=%s\n", key->name, key->value); 254 | } 255 | /* end of section */ 256 | fprintf(file, "\n"); 257 | } 258 | gf_fclose(file); 259 | return GF_OK; 260 | } 261 | 262 | GF_EXPORT 263 | GF_Err gf_cfg_discard_changes(GF_Config *iniFile) 264 | { 265 | if (!iniFile) return GF_BAD_PARAM; 266 | iniFile->skip_changes = GF_TRUE; 267 | return GF_OK; 268 | } 269 | 270 | GF_EXPORT 271 | void gf_cfg_del(GF_Config *iniFile) 272 | { 273 | if (!iniFile) return; 274 | gf_cfg_save(iniFile); 275 | gf_cfg_clear(iniFile); 276 | gf_free(iniFile); 277 | } 278 | 279 | void gf_cfg_remove(GF_Config *iniFile) 280 | { 281 | if (!iniFile) return; 282 | gf_delete_file(iniFile->fileName); 283 | gf_cfg_clear(iniFile); 284 | gf_free(iniFile); 285 | } 286 | 287 | 288 | GF_EXPORT 289 | const char *gf_cfg_get_key(GF_Config *iniFile, const char *secName, const char *keyName) 290 | { 291 | u32 i; 292 | IniSection *sec; 293 | IniKey *key; 294 | 295 | i = 0; 296 | while ((sec = (IniSection *)gf_list_enum(iniFile->sections, &i))) { 297 | if (!strcmp(secName, sec->section_name)) goto get_key; 298 | } 299 | return NULL; 300 | 301 | get_key: 302 | i = 0; 303 | while ((key = (IniKey *)gf_list_enum(sec->keys, &i))) { 304 | if (!strcmp(key->name, keyName)) return key->value; 305 | } 306 | return NULL; 307 | } 308 | 309 | GF_EXPORT 310 | const char *gf_cfg_get_ikey(GF_Config *iniFile, const char *secName, const char *keyName) 311 | { 312 | u32 i; 313 | IniSection *sec; 314 | IniKey *key; 315 | 316 | i = 0; 317 | while ((sec = (IniSection *)gf_list_enum(iniFile->sections, &i))) { 318 | if (!stricmp(secName, sec->section_name)) goto get_key; 319 | } 320 | return NULL; 321 | 322 | get_key: 323 | i = 0; 324 | while ((key = (IniKey *)gf_list_enum(sec->keys, &i))) { 325 | if (!stricmp(key->name, keyName)) return key->value; 326 | } 327 | return NULL; 328 | } 329 | 330 | 331 | GF_EXPORT 332 | GF_Err gf_cfg_set_key(GF_Config *iniFile, const char *secName, const char *keyName, const char *keyValue) 333 | { 334 | u32 i; 335 | Bool has_changed = GF_TRUE; 336 | IniSection *sec; 337 | IniKey *key; 338 | 339 | if (!iniFile || !secName || !keyName) return GF_BAD_PARAM; 340 | 341 | if (!strnicmp(secName, "temp", 4)) has_changed = GF_FALSE; 342 | 343 | i = 0; 344 | while ((sec = (IniSection *)gf_list_enum(iniFile->sections, &i))) { 345 | if (!strcmp(secName, sec->section_name)) goto get_key; 346 | } 347 | /* need a new key */ 348 | sec = (IniSection *)gf_malloc(sizeof(IniSection)); 349 | sec->section_name = gf_strdup(secName); 350 | sec->keys = gf_list_new(); 351 | if (has_changed) iniFile->hasChanged = GF_TRUE; 352 | gf_list_add(iniFile->sections, sec); 353 | 354 | get_key: 355 | i = 0; 356 | while ((key = (IniKey *)gf_list_enum(sec->keys, &i))) { 357 | if (!strcmp(key->name, keyName)) goto set_value; 358 | } 359 | if (!keyValue) return GF_OK; 360 | /* need a new key */ 361 | key = (IniKey *)gf_malloc(sizeof(IniKey)); 362 | key->name = gf_strdup(keyName); 363 | key->value = gf_strdup(""); 364 | if (has_changed) iniFile->hasChanged = GF_TRUE; 365 | gf_list_add(sec->keys, key); 366 | 367 | set_value: 368 | if (!keyValue) { 369 | gf_list_del_item(sec->keys, key); 370 | if (key->name) gf_free(key->name); 371 | if (key->value) gf_free(key->value); 372 | gf_free(key); 373 | if (has_changed) iniFile->hasChanged = GF_TRUE; 374 | return GF_OK; 375 | } 376 | /* same value, don't update */ 377 | if (!strcmp(key->value, keyValue)) return GF_OK; 378 | 379 | if (key->value) gf_free(key->value); 380 | key->value = gf_strdup(keyValue); 381 | if (has_changed) iniFile->hasChanged = GF_TRUE; 382 | return GF_OK; 383 | } 384 | 385 | GF_EXPORT 386 | u32 gf_cfg_get_section_count(GF_Config *iniFile) 387 | { 388 | return gf_list_count(iniFile->sections); 389 | } 390 | 391 | GF_EXPORT 392 | const char *gf_cfg_get_section_name(GF_Config *iniFile, u32 secIndex) 393 | { 394 | IniSection *is = (IniSection *)gf_list_get(iniFile->sections, secIndex); 395 | if (!is) return NULL; 396 | return is->section_name; 397 | } 398 | 399 | GF_EXPORT 400 | u32 gf_cfg_get_key_count(GF_Config *iniFile, const char *secName) 401 | { 402 | u32 i = 0; 403 | IniSection *sec; 404 | while ((sec = (IniSection *)gf_list_enum(iniFile->sections, &i))) { 405 | if (!strcmp(secName, sec->section_name)) return gf_list_count(sec->keys); 406 | } 407 | return 0; 408 | } 409 | 410 | GF_EXPORT 411 | const char *gf_cfg_get_key_name(GF_Config *iniFile, const char *secName, u32 keyIndex) 412 | { 413 | u32 i = 0; 414 | IniSection *sec; 415 | while ((sec = (IniSection *)gf_list_enum(iniFile->sections, &i))) { 416 | if (!strcmp(secName, sec->section_name)) { 417 | IniKey *key = (IniKey *)gf_list_get(sec->keys, keyIndex); 418 | return key ? key->name : NULL; 419 | } 420 | } 421 | return NULL; 422 | } 423 | 424 | GF_EXPORT 425 | void gf_cfg_del_section(GF_Config *iniFile, const char *secName) 426 | { 427 | u32 i; 428 | IniSection *p; 429 | if (!iniFile) return; 430 | 431 | i = 0; 432 | while ((p = (IniSection*)gf_list_enum(iniFile->sections, &i))) { 433 | if (!strcmp(secName, p->section_name)) { 434 | DelSection(p); 435 | gf_list_rem(iniFile->sections, i - 1); 436 | iniFile->hasChanged = GF_TRUE; 437 | return; 438 | } 439 | } 440 | } 441 | 442 | GF_EXPORT 443 | GF_Err gf_cfg_insert_key(GF_Config *iniFile, const char *secName, const char *keyName, const char *keyValue, u32 index) 444 | { 445 | u32 i; 446 | IniSection *sec; 447 | IniKey *key; 448 | 449 | if (!iniFile || !secName || !keyName || !keyValue) return GF_BAD_PARAM; 450 | 451 | i = 0; 452 | while ((sec = (IniSection *)gf_list_enum(iniFile->sections, &i))) { 453 | if (!strcmp(secName, sec->section_name)) break; 454 | } 455 | if (!sec) return GF_BAD_PARAM; 456 | 457 | i = 0; 458 | while ((key = (IniKey *)gf_list_enum(sec->keys, &i))) { 459 | if (!strcmp(key->name, keyName)) return GF_BAD_PARAM; 460 | } 461 | 462 | key = (IniKey *)gf_malloc(sizeof(IniKey)); 463 | key->name = gf_strdup(keyName); 464 | key->value = gf_strdup(keyValue); 465 | gf_list_insert(sec->keys, key, index); 466 | iniFile->hasChanged = GF_TRUE; 467 | return GF_OK; 468 | } 469 | 470 | GF_EXPORT 471 | const char *gf_cfg_get_sub_key(GF_Config *iniFile, const char *secName, const char *keyName, u32 sub_index) 472 | { 473 | u32 j; 474 | char *subKeyValue, *returnKey; 475 | char *keyValue; 476 | 477 | 478 | keyValue = gf_strdup(gf_cfg_get_key(iniFile, secName, keyName)); 479 | if (!keyValue) { 480 | return NULL; 481 | } 482 | 483 | j = 0; 484 | subKeyValue = strtok((char*)keyValue, ";"); 485 | while (subKeyValue != NULL) { 486 | if (j == sub_index) { 487 | returnKey = gf_strdup(subKeyValue); 488 | gf_free(keyValue); 489 | return returnKey; 490 | } 491 | j++; 492 | subKeyValue = strtok(NULL, ";"); 493 | } 494 | gf_free(keyValue); 495 | return NULL; 496 | } 497 | 498 | GF_EXPORT 499 | GF_Err gf_cfg_set_filename(GF_Config *iniFile, const char * fileName) 500 | { 501 | if (!fileName) return GF_OK; 502 | if (iniFile->fileName) gf_free(iniFile->fileName); 503 | iniFile->fileName = gf_strdup(fileName); 504 | return iniFile->fileName ? GF_OK : GF_OUT_OF_MEM; 505 | } 506 | -------------------------------------------------------------------------------- /include/gpac/setup.h: -------------------------------------------------------------------------------- 1 | /* 2 | * GPAC - Multimedia Framework C SDK 3 | * 4 | * Authors: Jean Le Feuvre 5 | * Copyright (c) Telecom ParisTech 2000-2012 6 | * All rights reserved 7 | * 8 | * This file is part of GPAC / general OS configuration file 9 | * 10 | * GPAC is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU Lesser General Public License as published by 12 | * the Free Software Foundation; either version 2, or (at your option) 13 | * any later version. 14 | * 15 | * GPAC is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Lesser General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public 21 | * License along with this library; see the file COPYING. If not, write to 22 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 23 | * 24 | */ 25 | 26 | #ifndef _GF_SETUP_H_ 27 | #define _GF_SETUP_H_ 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | 34 | /*! \file "gpac/setup.h" 35 | * \brief base data types of GPAC. 36 | * 37 | * This file contains the base data types of GPAC, depending on the platform. 38 | */ 39 | 40 | /*! \addtogroup setup_grp base data types 41 | * \ingroup utils_grp 42 | * \brief Base data types of GPAC. 43 | * 44 | * This section documents the base data types of GPAC. 45 | * @{ 46 | */ 47 | 48 | 49 | /*This is to handle cases where config.h is generated at the root of the gpac build tree (./configure) 50 | This is only needed when building libgpac and modules when libgpac is not installed*/ 51 | #ifdef GPAC_HAVE_CONFIG_H 52 | # include "config.h" 53 | #else 54 | # include "gpac/configuration.h" 55 | #endif 56 | 57 | 58 | /*WIN32 and WinCE config*/ 59 | #if defined(WIN32) || defined(_WIN32_WCE) 60 | 61 | /*common win32 parts*/ 62 | #include 63 | #include 64 | 65 | #if defined(_WIN64) && !defined(GPAC_64_BITS) 66 | #define GPAC_64_BITS 67 | #endif 68 | 69 | typedef unsigned __int64 u64; 70 | typedef unsigned int u32; 71 | typedef unsigned short u16; 72 | typedef unsigned char u8; 73 | typedef __int64 s64; 74 | typedef int s32; 75 | typedef short s16; 76 | typedef char s8; 77 | 78 | #if defined(__GNUC__) 79 | #define GFINLINE inline 80 | #else 81 | #define GFINLINE __inline 82 | #endif 83 | 84 | #define GF_PATH_SEPARATOR '\\' 85 | #define GF_MAX_PATH 1024 86 | 87 | /*WINCE config*/ 88 | #if defined(_WIN32_WCE) 89 | 90 | /*win32 assert*/ 91 | #ifndef assert 92 | 93 | void CE_Assert(u32 valid, char *file, u32 line); 94 | 95 | #ifndef NDEBUG 96 | #define assert( t ) CE_Assert((unsigned int) (t), __FILE__, __LINE__ ) 97 | #else 98 | #define assert(t) 99 | #endif 100 | 101 | #endif 102 | 103 | 104 | /*performs wide->char and char->wide conversion on a buffer GF_MAX_PATH long*/ 105 | void CE_WideToChar(unsigned short *w_str, char *str); 106 | void CE_CharToWide(char *str, unsigned short *w_str); 107 | 108 | 109 | #define strdup _strdup 110 | #define stricmp _stricmp 111 | #define strnicmp strnicmp 112 | #define strupr _strupr 113 | #define mkdir _mkdir 114 | #define snprintf _snprintf 115 | #define memccpy _memccpy 116 | 117 | 118 | #ifndef _PTRDIFF_T_DEFINED 119 | typedef int ptrdiff_t; 120 | #define PTRDIFF(p1, p2, type) ((p1) - (p2)) 121 | #define _PTRDIFF_T_DEFINED 122 | #endif 123 | 124 | #ifndef _SIZE_T_DEFINED 125 | typedef unsigned int size_t; 126 | #define _SIZE_T_DEFINED 127 | #endif 128 | 129 | #ifndef offsetof 130 | #define offsetof(s,m) ((size_t)&(((s*)0)->m)) 131 | #endif 132 | 133 | #ifndef getenv 134 | #define getenv(a) 0L 135 | #endif 136 | 137 | #define strupr _strupr 138 | #define strlwr _strlwr 139 | 140 | /* 141 | #define GPAC_DISABLE_LOG 142 | */ 143 | #else /*END WINCE*/ 144 | 145 | /*WIN32 not-WinCE*/ 146 | #include 147 | #include 148 | #include 149 | #include 150 | #include 151 | #include 152 | 153 | #define snprintf _snprintf 154 | 155 | #endif /*END WIN32 non win-ce*/ 156 | /*end WIN32 config*/ 157 | 158 | /*start SYMBIAN config*/ 159 | #elif defined(__SYMBIAN32__) 160 | 161 | #define GFINLINE inline 162 | #define GF_PATH_SEPARATOR '\\' 163 | 164 | /*we must explicitely export our functions...*/ 165 | #define GF_EXPORT EXPORT_C 166 | 167 | #include 168 | #include 169 | #include 170 | #include 171 | #include 172 | #include 173 | #include 174 | 175 | #ifdef __SERIES60_3X__ 176 | 177 | typedef unsigned __int64 u64; 178 | typedef __int64 s64; 179 | 180 | #else 181 | 182 | /*FIXME - we don't have 64bit support here we should get rid of all 64bits divisions*/ 183 | /* 184 | typedef unsigned long long u64; 185 | typedef long long s64; 186 | */ 187 | 188 | typedef unsigned int u64; 189 | typedef signed int s64; 190 | 191 | #endif /*symbian 8*/ 192 | 193 | 194 | typedef unsigned int u32; 195 | typedef unsigned short u16; 196 | typedef unsigned char u8; 197 | typedef int s32; 198 | typedef short s16; 199 | typedef signed char s8; 200 | 201 | #pragma mpwc_relax on 202 | 203 | #define GF_MAX_PATH 260 204 | 205 | /*sorry this was developed under w32 :)*/ 206 | #define stricmp strcasecmp 207 | #define strnicmp strncasecmp 208 | 209 | #ifndef strupr 210 | char * my_str_upr(char *str); 211 | #define strupr my_str_upr 212 | #endif 213 | 214 | #ifndef strlwr 215 | char * my_str_lwr(char *str); 216 | #define strlwr my_str_lwr 217 | #endif 218 | 219 | #ifndef DBL_MAX 220 | #include 221 | #define DBL_MAX (__IEEE_DBL_MAXPOWTWO) 222 | #endif 223 | 224 | #ifndef FLT_MAX 225 | #include 226 | #define FLT_MAX (__IEEE_FLT_MAXPOWTWO) 227 | #endif 228 | 229 | #ifndef FLT_EPSILON 230 | #define FLT_EPSILON 1 231 | #endif 232 | 233 | /*end SYMBIAN config*/ 234 | 235 | #else 236 | 237 | /*UNIX likes*/ 238 | 239 | /*force large file support*/ 240 | #ifndef _FILE_OFFSET_BITS 241 | #define _FILE_OFFSET_BITS 64 242 | #endif 243 | #ifndef _LARGEFILE_SOURCE 244 | #define _LARGEFILE_SOURCE 245 | #endif 246 | #ifndef _LARGEFILE64_SOURCE 247 | #define _LARGEFILE64_SOURCE 248 | #endif 249 | 250 | #include 251 | #include 252 | #include 253 | #include 254 | #include 255 | #include 256 | #include 257 | #include 258 | #include 259 | 260 | #if __APPLE__ && defined GPAC_IPHONE 261 | #include 262 | #endif 263 | 264 | typedef uint64_t u64; 265 | typedef uint32_t u32; 266 | typedef uint16_t u16; 267 | typedef uint8_t u8; 268 | typedef int64_t s64; 269 | typedef int32_t s32; 270 | typedef int16_t s16; 271 | typedef int8_t s8; 272 | 273 | #define GFINLINE inline 274 | 275 | /*sorry this was developed under w32 :)*/ 276 | #define stricmp strcasecmp 277 | #define strnicmp strncasecmp 278 | 279 | #ifndef strupr 280 | char * my_str_upr(char *str); 281 | #define strupr my_str_upr 282 | #endif 283 | 284 | #ifndef strlwr 285 | char * my_str_lwr(char *str); 286 | #define strlwr my_str_lwr 287 | #endif 288 | 289 | #define GF_PATH_SEPARATOR '/' 290 | 291 | #ifdef PATH_MAX 292 | #define GF_MAX_PATH PATH_MAX 293 | #else 294 | /*PATH_MAX not defined*/ 295 | #define GF_MAX_PATH 1023 296 | #endif 297 | 298 | 299 | #endif /* end platform specific Win32/WinCE/UNIX*/ 300 | 301 | /*define what's missing*/ 302 | #ifndef NULL 303 | #define NULL 0 304 | #endif 305 | 306 | 307 | typedef double Double; 308 | typedef float Float; 309 | /* 128 bit IDs */ 310 | typedef u8 bin128[16]; 311 | 312 | #define GF_MAX_DOUBLE DBL_MAX 313 | #define GF_MIN_DOUBLE -GF_MAX_DOUBLE 314 | #define GF_MAX_FLOAT FLT_MAX 315 | #define GF_MIN_FLOAT -GF_MAX_FLOAT 316 | #define GF_EPSILON_FLOAT FLT_EPSILON 317 | #define GF_SHORT_MAX SHRT_MAX 318 | #define GF_SHORT_MIN SHRT_MIN 319 | #define GF_UINT_MAX UINT_MAX 320 | #define GF_INT_MAX INT_MAX 321 | #define GF_INT_MIN INT_MIN 322 | 323 | #ifndef MIN 324 | #define MIN(X, Y) ((X)<(Y)?(X):(Y)) 325 | #endif 326 | #ifndef MAX 327 | #define MAX(X, Y) ((X)>(Y)?(X):(Y)) 328 | #endif 329 | 330 | #define ABSDIFF(a, b) ( ( (a) > (b) ) ? ((a) - (b)) : ((b) - (a)) ) 331 | 332 | #ifndef ABS 333 | #define ABS(a) ( ( (a) > 0 ) ? (a) : - (a) ) 334 | #endif 335 | 336 | #ifndef Bool 337 | typedef enum { 338 | GF_FALSE = 0, 339 | GF_TRUE 340 | } Bool; 341 | #endif 342 | 343 | 344 | /*GPAC memory tracking*/ 345 | #if defined(GPAC_MEMORY_TRACKING) 346 | 347 | void *gf_mem_malloc(size_t size, const char *filename, int line); 348 | void *gf_mem_calloc(size_t num, size_t size_of, const char *filename, int line); 349 | void *gf_mem_realloc(void *ptr, size_t size, const char *filename, int line); 350 | void gf_mem_free(void *ptr, const char *filename, int line); 351 | char *gf_mem_strdup(const char *str, const char *filename, int line); 352 | void gf_memory_print(void); /*prints the state of current allocations*/ 353 | u64 gf_memory_size(); /*gets memory allocated in bytes*/ 354 | 355 | #define gf_free(ptr) gf_mem_free(ptr, __FILE__, __LINE__) 356 | #define gf_malloc(size) gf_mem_malloc(size, __FILE__, __LINE__) 357 | #define gf_calloc(num, size_of) gf_mem_calloc(num, size_of, __FILE__, __LINE__) 358 | #define gf_strdup(s) gf_mem_strdup(s, __FILE__, __LINE__) 359 | #define gf_realloc(ptr1, size) gf_mem_realloc(ptr1, size, __FILE__, __LINE__) 360 | 361 | #else 362 | 363 | #define gf_malloc malloc 364 | #define gf_calloc calloc 365 | #define gf_realloc realloc 366 | #define gf_free free 367 | #define gf_strdup strdup 368 | 369 | #endif 370 | 371 | 372 | /*end GPAC memory tracking*/ 373 | 374 | #if (defined (WIN32) || defined (_WIN32_WCE)) && (defined(__MINGW32__) || !defined(__GNUC__)) 375 | 376 | #define LLD "%I64d" 377 | #define LLU "%I64u" 378 | #define LLX "%I64x" 379 | #define LLXPAD( pad ) "%" pad "I64x" 380 | #define LLD_CAST 381 | #define LLU_CAST 382 | #ifdef _WIN64 383 | #define PTR_TO_U_CAST (u64) 384 | #else 385 | #define PTR_TO_U_CAST (u32) 386 | #endif 387 | 388 | #elif defined (__SYMBIAN32__) 389 | 390 | #define LLD "%d" 391 | #define LLU "%u" 392 | #define LLX "%x" 393 | #define LLXPAD( pad ) "%" pad "x" 394 | #define LLD_CAST (u32) 395 | #define LLU_CAST (s32) 396 | #define PTR_TO_U_CAST (u32) 397 | 398 | /*seems that even though _LP64 is defined in OSX, %ll modifiers are still needed*/ 399 | #elif defined(__DARWIN__) || defined(__APPLE__) 400 | 401 | #define LLD "%lld" 402 | #define LLU "%llu" 403 | #define LLX "%llx" 404 | #define LLXPAD( pad ) "%" pad "llx" 405 | 406 | #ifdef __LP64__ /* Mac OS 64 bits */ 407 | #define PTR_TO_U_CAST (u64) 408 | #else 409 | #define PTR_TO_U_CAST (u32) 410 | #endif 411 | 412 | #elif defined(_LP64) /*Unix 64 bits*/ 413 | 414 | #define LLD "%ld" 415 | #define LLU "%lu" 416 | #define LLX "%lx" 417 | #define LLXPAD( pad ) "%" pad "lx" 418 | #define PTR_TO_U_CAST (u64) 419 | 420 | #else /*Unix 32 bits*/ 421 | 422 | #define LLD "%lld" 423 | #define LLU "%llu" 424 | #define LLX "%llx" 425 | #define LLXPAD( pad ) "%" pad "llx" 426 | #define PTR_TO_U_CAST (u32) 427 | 428 | #endif 429 | 430 | #ifndef LLD_CAST 431 | #define LLD_CAST 432 | #endif 433 | 434 | #ifndef LLU_CAST 435 | #define LLU_CAST 436 | #endif 437 | 438 | #ifndef PTR_TO_U_CAST 439 | #define PTR_TO_U_CAST 440 | #endif 441 | 442 | #if !defined(GF_EXPORT) 443 | #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(GPAC_IPHONE) 444 | #define GF_EXPORT __attribute__((visibility("default"))) 445 | #else 446 | /*use def files for windows or let compiler decide*/ 447 | #define GF_EXPORT 448 | #endif 449 | #endif 450 | 451 | #if defined(GPAC_IPHONE) 452 | #define GPAC_STATIC_MODULES 453 | #endif 454 | 455 | /*safety checks on macros*/ 456 | 457 | #ifdef GPAC_DISABLE_ZLIB 458 | # define GPAC_DISABLE_LOADER_BT 459 | # define GPAC_DISABLE_SWF_IMPORT 460 | #endif 461 | 462 | #ifdef GPAC_DISABLE_VRML 463 | # ifndef GPAC_DISABLE_BIFS 464 | # define GPAC_DISABLE_BIFS 465 | # endif 466 | # ifndef GPAC_DISABLE_QTVR 467 | # define GPAC_DISABLE_QTVR 468 | # endif 469 | # ifndef GPAC_DISABLE_X3D 470 | # define GPAC_DISABLE_X3D 471 | # endif 472 | # ifndef GPAC_DISABLE_LOADER_BT 473 | # define GPAC_DISABLE_LOADER_BT 474 | # endif 475 | # ifndef GPAC_DISABLE_LOADER_XMT 476 | # define GPAC_DISABLE_LOADER_XMT 477 | # endif 478 | #endif 479 | 480 | #ifdef GPAC_DISABLE_SVG 481 | # ifndef GPAC_DISABLE_LASER 482 | # define GPAC_DISABLE_LASER 483 | # endif 484 | #endif 485 | 486 | 487 | #ifdef GPAC_DISABLE_AV_PARSERS 488 | # ifndef GPAC_DISABLE_MPEG2PS 489 | # define GPAC_DISABLE_MPEG2PS 490 | # endif 491 | # ifndef GPAC_DISABLE_ISOM_HINTING 492 | # define GPAC_DISABLE_ISOM_HINTING 493 | # endif 494 | # ifndef GPAC_DISABLE_MEDIA_IMPORT 495 | # define GPAC_DISABLE_MEDIA_IMPORT 496 | # endif 497 | # ifndef GPAC_DISABLE_MPEG2TS_MUX 498 | # define GPAC_DISABLE_MPEG2TS_MUX 499 | # endif 500 | #endif 501 | 502 | #ifdef GPAC_DISABLE_ISOM 503 | # ifndef GPAC_DISABLE_ISOM_WRITE 504 | # define GPAC_DISABLE_ISOM_WRITE 505 | # endif 506 | # ifndef GPAC_DISABLE_ISOM_HINTING 507 | # define GPAC_DISABLE_ISOM_HINTING 508 | # endif 509 | # ifndef GPAC_DISABLE_ISOM_FRAGMENTS 510 | # define GPAC_DISABLE_ISOM_FRAGMENTS 511 | # endif 512 | # ifndef GPAC_DISABLE_SCENE_ENCODER 513 | # define GPAC_DISABLE_SCENE_ENCODER 514 | # endif 515 | # ifndef GPAC_DISABLE_ISOM_DUMP 516 | # define GPAC_DISABLE_ISOM_DUMP 517 | # endif 518 | # ifndef GPAC_DISABLE_LOADER_ISOM 519 | # define GPAC_DISABLE_LOADER_ISOM 520 | # endif 521 | # ifndef GPAC_DISABLE_MEDIA_EXPORT 522 | # define GPAC_DISABLE_MEDIA_EXPORT 523 | # endif 524 | #endif 525 | 526 | #ifdef GPAC_DISABLE_ISOM_WRITE 527 | # ifndef GPAC_DISABLE_MEDIA_IMPORT 528 | # define GPAC_DISABLE_MEDIA_IMPORT 529 | # endif 530 | # ifndef GPAC_DISABLE_QTVR 531 | # define GPAC_DISABLE_QTVR 532 | # endif 533 | # ifndef GPAC_DISABLE_ISOM_HINTING 534 | # define GPAC_DISABLE_ISOM_HINTING 535 | # endif 536 | # ifndef GPAC_DISABLE_SCENE_ENCODER 537 | # define GPAC_DISABLE_SCENE_ENCODER 538 | # endif 539 | #endif 540 | 541 | #ifdef GPAC_DISABLE_STREAMING 542 | # ifndef GPAC_DISABLE_ISOM_HINTING 543 | # define GPAC_DISABLE_ISOM_HINTING 544 | # endif 545 | #endif 546 | 547 | #ifdef GPAC_DISABLE_BIFS 548 | # ifndef GPAC_DISABLE_BIFS_ENC 549 | # define GPAC_DISABLE_BIFS_ENC 550 | # endif 551 | #endif 552 | 553 | #if defined(GPAC_DISABLE_BIFS_ENC) && defined(GPAC_DISABLE_LASER) 554 | # ifndef GPAC_DISABLE_LOADER_ISOM 555 | # define GPAC_DISABLE_LOADER_ISOM 556 | # endif 557 | # ifndef GPAC_DISABLE_SENG 558 | # define GPAC_DISABLE_SENG 559 | # endif 560 | #endif 561 | 562 | #if !defined(GPAC_HAS_SPIDERMONKEY) || defined(GPAC_DISABLE_SVG) 563 | # ifndef GPAC_DISABLE_MSE 564 | # define GPAC_DISABLE_MSE 565 | # endif 566 | #endif 567 | 568 | /*! @} */ 569 | 570 | #ifdef __cplusplus 571 | } 572 | #endif 573 | 574 | #endif /*_GF_SETUP_H_*/ 575 | --------------------------------------------------------------------------------