pax_global_header00006660000000000000000000000064143501347010014510gustar00rootroot0000000000000052 comment=07c1391c52ebd2c762e983f6e23ac61a12a92fef msopenh264-5.2.0/000077500000000000000000000000001435013470100134215ustar00rootroot00000000000000msopenh264-5.2.0/.gitignore000066400000000000000000000002661435013470100154150ustar00rootroot00000000000000.deps .libs *.la *.lo aclocal.m4 autom4te.cache compile config.log config.status configure depcomp install-sh libtool ltmain.sh Makefile Makefile.in missing config.guess config.sub msopenh264-5.2.0/AUTHORS000066400000000000000000000000401435013470100144630ustar00rootroot00000000000000Belledonne Communications SARL. msopenh264-5.2.0/Android.mk000066400000000000000000000007501435013470100153340ustar00rootroot00000000000000LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := libmsopenh264 LOCAL_SRC_FILES = src/msopenh264.cpp src/msopenh264dec.cpp src/msopenh264enc.cpp LOCAL_C_INCLUDES += \ $(LOCAL_PATH)/../linphone/oRTP/include \ $(LOCAL_PATH)/../linphone/mediastreamer2/include \ $(LOCAL_PATH)/../externals/openh264/include LOCAL_CFLAGS += -DVERSION=\"android\" ifeq ($(ENABLE_OPENH264_DECODER), 1) LOCAL_CFLAGS += -DOPENH264_DECODER_ENABLED endif include $(BUILD_STATIC_LIBRARY) msopenh264-5.2.0/CMakeLists.txt000066400000000000000000000063131435013470100161640ustar00rootroot00000000000000############################################################################ # CMakeLists.txt # Copyright (C) 2014 Belledonne Communications, Grenoble France # ############################################################################ # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # ############################################################################ cmake_minimum_required(VERSION 3.0) project(msopenh264 VERSION 1.2.1 LANGUAGES CXX) set(PACKAGE "${PROJECT_NAME}") set(PACKAGE_NAME "${PROJECT_NAME}") set(PACKAGE_VERSION "${PROJECT_VERSION}") set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "support@belledonne-communications.com") set(PACKAGE_TARNAME "msopenh264") set(PACKAGE_URL "") set(VERSION "${PACKAGE_VERSION}") option(ENABLE_SHARED "Build shared library." YES) option(ENABLE_STATIC "Build static library." YES) option(ENABLE_DECODER "Enable the openh264 decoder" Yes) include(GNUInstallDirs) if(NOT CMAKE_INSTALL_RPATH AND CMAKE_INSTALL_PREFIX) set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}) message(STATUS "Setting install rpath to ${CMAKE_INSTALL_RPATH}") endif() list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") include(CheckIncludeFileCXX) check_include_file_cxx("stdbool.h" HAVE_STDBOOL_H) find_package(Mediastreamer2 CONFIG REQUIRED) find_package(ortp CONFIG REQUIRED) find_package(bctoolbox CONFIG REQUIRED) find_package(OpenH264 REQUIRED) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h) include_directories( ${MEDIASTREAMER2_INCLUDE_DIRS} ${OPENH264_INCLUDE_DIRS} src ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/src ) add_definitions(-DHAVE_CONFIG_H -std=c++11) if(NOT MSVC) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-error=unknown-pragmas") if(CMAKE_C_COMPILER_ID MATCHES "Clang") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=unknown-warning-option") if(NOT IOS) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Wextra") endif() elseif(CMAKE_C_COMPILER_ID STREQUAL "GNU") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Wextra -Wno-error=pragmas") endif() else() if(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /ZW /EHsc /await") endif() endif() add_subdirectory(src) # CPack settings set(CPACK_PACKAGE_NAME "msopenh264") set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION}) set(CPACK_SOURCE_GENERATOR "TGZ") set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}") set(CPACK_SOURCE_IGNORE_FILES "^${CMAKE_BINARY_DIR}" "/\\\\..+" ) include(CPack) msopenh264-5.2.0/COPYING000066400000000000000000000431221435013470100144560ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. msopenh264-5.2.0/ChangeLog000066400000000000000000000000001435013470100151610ustar00rootroot00000000000000msopenh264-5.2.0/INSTALL000066400000000000000000000366101435013470100144600ustar00rootroot00000000000000Installation Instructions ************************* Copyright (C) 1994-1996, 1999-2002, 2004-2013 Free Software Foundation, Inc. Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. This file is offered as-is, without warranty of any kind. Basic Installation ================== Briefly, the shell command `./configure && make && make install' should configure, build, and install this package. The following more-detailed instructions are generic; see the `README' file for instructions specific to this package. Some packages provide this `INSTALL' file but do not implement all of the features documented below. The lack of an optional feature in a given package is not necessarily a bug. More recommendations for GNU packages can be found in *note Makefile Conventions: (standards)Makefile Conventions. The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a `Makefile' in each directory of the package. It may also create one or more `.h' files containing system-dependent definitions. Finally, it creates a shell script `config.status' that you can run in the future to recreate the current configuration, and a file `config.log' containing compiler output (useful mainly for debugging `configure'). It can also use an optional file (typically called `config.cache' and enabled with `--cache-file=config.cache' or simply `-C') that saves the results of its tests to speed up reconfiguring. Caching is disabled by default to prevent problems with accidental use of stale cache files. If you need to do unusual things to compile the package, please try to figure out how `configure' could check whether to do them, and mail diffs or instructions to the address given in the `README' so they can be considered for the next release. If you are using the cache, and at some point `config.cache' contains results you don't want to keep, you may remove or edit it. The file `configure.ac' (or `configure.in') is used to create `configure' by a program called `autoconf'. You need `configure.ac' if you want to change it or regenerate `configure' using a newer version of `autoconf'. The simplest way to compile this package is: 1. `cd' to the directory containing the package's source code and type `./configure' to configure the package for your system. Running `configure' might take a while. While running, it prints some messages telling which features it is checking for. 2. Type `make' to compile the package. 3. Optionally, type `make check' to run any self-tests that come with the package, generally using the just-built uninstalled binaries. 4. Type `make install' to install the programs and any data files and documentation. When installing into a prefix owned by root, it is recommended that the package be configured and built as a regular user, and only the `make install' phase executed with root privileges. 5. Optionally, type `make installcheck' to repeat any self-tests, but this time using the binaries in their final installed location. This target does not install anything. Running this target as a regular user, particularly if the prior `make install' required root privileges, verifies that the installation completed correctly. 6. You can remove the program binaries and object files from the source code directory by typing `make clean'. To also remove the files that `configure' created (so you can compile the package for a different kind of computer), type `make distclean'. There is also a `make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution. 7. Often, you can also type `make uninstall' to remove the installed files again. In practice, not all packages have tested that uninstallation works correctly, even though it is required by the GNU Coding Standards. 8. Some packages, particularly those that use Automake, provide `make distcheck', which can by used by developers to test that all other targets like `make install' and `make uninstall' work correctly. This target is generally not run by end users. Compilers and Options ===================== Some systems require unusual options for compilation or linking that the `configure' script does not know about. Run `./configure --help' for details on some of the pertinent environment variables. You can give `configure' initial values for configuration parameters by setting variables in the command line or in the environment. Here is an example: ./configure CC=c99 CFLAGS=-g LIBS=-lposix *Note Defining Variables::, for more details. Compiling For Multiple Architectures ==================================== You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their own directory. To do this, you can use GNU `make'. `cd' to the directory where you want the object files and executables to go and run the `configure' script. `configure' automatically checks for the source code in the directory that `configure' is in and in `..'. This is known as a "VPATH" build. With a non-GNU `make', it is safer to compile the package for one architecture at a time in the source code directory. After you have installed the package for one architecture, use `make distclean' before reconfiguring for another architecture. On MacOS X 10.5 and later systems, you can create libraries and executables that work on multiple system types--known as "fat" or "universal" binaries--by specifying multiple `-arch' options to the compiler but only a single `-arch' option to the preprocessor. Like this: ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ CPP="gcc -E" CXXCPP="g++ -E" This is not guaranteed to produce working output in all cases, you may have to build one architecture at a time and combine the results using the `lipo' tool if you have problems. Installation Names ================== By default, `make install' installs the package's commands under `/usr/local/bin', include files under `/usr/local/include', etc. You can specify an installation prefix other than `/usr/local' by giving `configure' the option `--prefix=PREFIX', where PREFIX must be an absolute file name. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you pass the option `--exec-prefix=PREFIX' to `configure', the package uses PREFIX as the prefix for installing programs and libraries. Documentation and other data files still use the regular prefix. In addition, if you use an unusual directory layout you can give options like `--bindir=DIR' to specify different values for particular kinds of files. Run `configure --help' for a list of the directories you can set and what kinds of files go in them. In general, the default for these options is expressed in terms of `${prefix}', so that specifying just `--prefix' will affect all of the other directory specifications that were not explicitly provided. The most portable way to affect installation locations is to pass the correct locations to `configure'; however, many packages provide one or both of the following shortcuts of passing variable assignments to the `make install' command line to change installation locations without having to reconfigure or recompile. The first method involves providing an override variable for each affected directory. For example, `make install prefix=/alternate/directory' will choose an alternate location for all directory configuration variables that were expressed in terms of `${prefix}'. Any directories that were specified during `configure', but not in terms of `${prefix}', must each be overridden at install time for the entire installation to be relocated. The approach of makefile variable overrides for each directory variable is required by the GNU Coding Standards, and ideally causes no recompilation. However, some platforms have known limitations with the semantics of shared libraries that end up requiring recompilation when using this method, particularly noticeable in packages that use GNU Libtool. The second method involves providing the `DESTDIR' variable. For example, `make install DESTDIR=/alternate/directory' will prepend `/alternate/directory' before all installation names. The approach of `DESTDIR' overrides is not required by the GNU Coding Standards, and does not work on platforms that have drive letters. On the other hand, it does better at avoiding recompilation issues, and works well even when some directory options were not specified in terms of `${prefix}' at `configure' time. Optional Features ================= If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. Some packages pay attention to `--enable-FEATURE' options to `configure', where FEATURE indicates an optional part of the package. They may also pay attention to `--with-PACKAGE' options, where PACKAGE is something like `gnu-as' or `x' (for the X Window System). The `README' should mention any `--enable-' and `--with-' options that the package recognizes. For packages that use the X Window System, `configure' can usually find the X include and library files automatically, but if it doesn't, you can use the `configure' options `--x-includes=DIR' and `--x-libraries=DIR' to specify their locations. Some packages offer the ability to configure how verbose the execution of `make' will be. For these packages, running `./configure --enable-silent-rules' sets the default to minimal output, which can be overridden with `make V=1'; while running `./configure --disable-silent-rules' sets the default to verbose, which can be overridden with `make V=0'. Particular systems ================== On HP-UX, the default C compiler is not ANSI C compatible. If GNU CC is not installed, it is recommended to use the following options in order to use an ANSI C compiler: ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" and if that doesn't work, install pre-built binaries of GCC for HP-UX. HP-UX `make' updates targets which have the same time stamps as their prerequisites, which makes it generally unusable when shipped generated files such as `configure' are involved. Use GNU `make' instead. On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot parse its `' header file. The option `-nodtk' can be used as a workaround. If GNU CC is not installed, it is therefore recommended to try ./configure CC="cc" and if that doesn't work, try ./configure CC="cc -nodtk" On Solaris, don't put `/usr/ucb' early in your `PATH'. This directory contains several dysfunctional programs; working variants of these programs are available in `/usr/bin'. So, if you need `/usr/ucb' in your `PATH', put it _after_ `/usr/bin'. On Haiku, software installed for all users goes in `/boot/common', not `/usr/local'. It is recommended to use the following options: ./configure --prefix=/boot/common Specifying the System Type ========================== There may be some features `configure' cannot figure out automatically, but needs to determine by the type of machine the package will run on. Usually, assuming the package is built to be run on the _same_ architectures, `configure' can figure that out, but if it prints a message saying it cannot guess the machine type, give it the `--build=TYPE' option. TYPE can either be a short name for the system type, such as `sun4', or a canonical name which has the form: CPU-COMPANY-SYSTEM where SYSTEM can have one of these forms: OS KERNEL-OS See the file `config.sub' for the possible values of each field. If `config.sub' isn't included in this package, then this package doesn't need to know the machine type. If you are _building_ compiler tools for cross-compiling, you should use the option `--target=TYPE' to select the type of system they will produce code for. If you want to _use_ a cross compiler, that generates code for a platform different from the build platform, you should specify the "host" platform (i.e., that on which the generated programs will eventually be run) with `--host=TYPE'. Sharing Defaults ================ If you want to set default values for `configure' scripts to share, you can create a site shell script called `config.site' that gives default values for variables like `CC', `cache_file', and `prefix'. `configure' looks for `PREFIX/share/config.site' if it exists, then `PREFIX/etc/config.site' if it exists. Or, you can set the `CONFIG_SITE' environment variable to the location of the site script. A warning: not all `configure' scripts look for a site script. Defining Variables ================== Variables not defined in a site shell script can be set in the environment passed to `configure'. However, some packages may run configure again during the build, and the customized values of these variables may be lost. In order to avoid this problem, you should set them in the `configure' command line, using `VAR=value'. For example: ./configure CC=/usr/local2/bin/gcc causes the specified `gcc' to be used as the C compiler (unless it is overridden in the site shell script). Unfortunately, this technique does not work for `CONFIG_SHELL' due to an Autoconf limitation. Until the limitation is lifted, you can use this workaround: CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash `configure' Invocation ====================== `configure' recognizes the following options to control how it operates. `--help' `-h' Print a summary of all of the options to `configure', and exit. `--help=short' `--help=recursive' Print a summary of the options unique to this package's `configure', and exit. The `short' variant lists options used only in the top level, while the `recursive' variant lists options also present in any nested packages. `--version' `-V' Print the version of Autoconf used to generate the `configure' script, and exit. `--cache-file=FILE' Enable the cache: use and save the results of the tests in FILE, traditionally `config.cache'. FILE defaults to `/dev/null' to disable caching. `--config-cache' `-C' Alias for `--cache-file=config.cache'. `--quiet' `--silent' `-q' Do not print messages saying which checks are being made. To suppress all normal output, redirect it to `/dev/null' (any error messages will still be shown). `--srcdir=DIR' Look for the package's source code in directory DIR. Usually `configure' can determine that directory automatically. `--prefix=DIR' Use DIR as the installation prefix. *note Installation Names:: for more details, including other options available for fine-tuning the installation locations. `--no-create' `-n' Run the configure checks, but stop before creating any output files. `configure' also accepts some other, not widely useful, options. Run `configure --help' for more details. msopenh264-5.2.0/Makefile.am000066400000000000000000000027731435013470100154660ustar00rootroot00000000000000EXTRA_DIST= \ autogen.sh \ CMakeLists.txt \ cmake/FindOpenH264.cmake \ config.h.cmake \ src/CMakeLists.txt \ README.md SUBDIRS=src build INSTALLDIR=$(shell cd $(top_builddir) && pwd)/$(PACKAGE)-install INSTALLDIR_WITH_PREFIX=$(INSTALLDIR)/$(prefix) ZIPFILE=$(shell cd $(top_builddir) && pwd)/$(PACKAGE)-win32-$(VERSION).zip ZIP_EXCLUDED=include ISS_SCRIPT=msopenh264.iss ISS_SCRIPT_PATH=$(shell cd $(top_srcdir) && pwd)/$(ISS_SCRIPT) #path to Inno Setup 5 compiler ISCC=ISCC.exe PACKAGE_WIN32_FILELIST=$(PACKAGE)-win32.filelist setup.exe: zip cd $(INSTALLDIR_WITH_PREFIX) && \ rm -f $(PACKAGE_WIN32_FILELIST) && \ for file in `find` ; do \ if ! test -d $$file ; then \ echo "Source: $$file; Destdir: {app}\\`dirname $$file`; Flags: ignoreversion" \ >> $(PACKAGE_WIN32_FILELIST) ;\ fi \ done cp $(ISS_SCRIPT) $(INSTALLDIR_WITH_PREFIX)/. cd $(INSTALLDIR_WITH_PREFIX) && \ $(ISCC) $(ISS_SCRIPT) mv $(INSTALLDIR_WITH_PREFIX)/Output/setup.exe $(PACKAGE)-$(VERSION)-setup.exe rm -rf $(INSTALLDIR_WITH_PREFIX)/Output rm -f $(INSTALLDIR_WITH_PREFIX)/$(PACKAGE_WIN32_FILELIST) rm -f $(INSTALLDIR_WITH_PREFIX)/$(ISS_SCRIPT) zip: rm -f $(ZIPFILE) rm -rf $(INSTALLDIR) mkdir -p $(INSTALLDIR) make install DESTDIR=$(INSTALLDIR) cp -f $(top_srcdir)/README $(INSTALLDIR_WITH_PREFIX)/. cp -f $(top_srcdir)/COPYING $(INSTALLDIR_WITH_PREFIX)/. cd $(INSTALLDIR)/$(prefix) && rm -rf $(ZIP_EXCLUDED) && \ zip -r $(ZIPFILE) * clean-local: -rm -rf $(PACKAGE)-install -rm -f $(PACKAGE)-win32-$(VERSION).zip msopenh264-5.2.0/NEWS000066400000000000000000000006311435013470100141200ustar00rootroot00000000000000msopenh264-1.2.1 -- July 20th, 2017 * Bug fixes msopenh264-1.2.0 -- February 24th, 2017 * use the newest rfc3984 API msopenh264-1.1.2 -- June 2nd, 2016 * MSFactory usage. msopenh264-1.1.1 -- November 2nd, 2015 * Bug fixes msopenh264-1.1.0 -- June 4th, 2015 * Handle AVPF FIR and PLI * Request PLI on decoding error if AVPF is enabled msopenh264-1.0.0 -- June 4th, 2015 * First official release msopenh264-5.2.0/README.md000066400000000000000000000023301435013470100146760ustar00rootroot00000000000000MsOpenH264 ========== Overview -------- MsOpenH264 is an H.264 encoder/decoder plugin for mediastreamer2 based on the openh264 library. Compilation guide ----------------- ### Dependencies - *Mediastreamer[1]:* needed for its API - [OpenH264][openh264-website]: H264 encoder and decoder ### Build procedure The Autotools way is deprecated. Use [CMake][cmake-website] to configure the source code. cmake . -DCMAKE_INSTALL_PRFIX= -DCMAKE_PREFIX_PATH= make make install ### Build options - `CMAKE_INSTALL_PREFIX=` : installation prefix - `CMAKE_PREFIX_PATH=` : column-separated list of prefixes where to look for dependencies - `ENABLE_DECODER=NO` : disable H264 decoding feature ### Note for packagers Our CMake scripts may automatically add some paths into research paths of generated binaries. To ensure that the installed binaries are striped of any rpath, use `-DCMAKE_SKIP_INSTALL_RPATH=ON` while you invoke cmake. ----------------------------------- [1] Mediastreamer: git://git.linphone.org/mediastreamer2.git *or* [openh264-website]: http://www.openh264.org/ [cmake-website]: https://cmake.org msopenh264-5.2.0/autogen.sh000077500000000000000000000014511435013470100154230ustar00rootroot00000000000000#!/bin/sh srcdir=`dirname $0` test -z "$srcdir" && srcdir=. THEDIR=`pwd` cd $srcdir #AM_VERSION="1.10" if ! type aclocal-$AM_VERSION 1>/dev/null 2>&1; then # automake-1.10 (recommended) is not available on Fedora 8 AUTOMAKE=automake ACLOCAL=aclocal else ACLOCAL=aclocal-${AM_VERSION} AUTOMAKE=automake-${AM_VERSION} fi if test -f /opt/local/bin/glibtoolize ; then # darwin LIBTOOLIZE=/opt/local/bin/glibtoolize else LIBTOOLIZE=libtoolize fi if test -d /opt/local/share/aclocal ; then ACLOCAL_ARGS="-I /opt/local/share/aclocal" fi if test -d /share/aclocal ; then ACLOCAL_ARGS="-I /share/aclocal" fi echo "Generating build scripts in msopenh264..." set -x $LIBTOOLIZE --copy --force $ACLOCAL $ACLOCAL_ARGS autoheader $AUTOMAKE --force-missing --add-missing --copy autoconf cd $THEDIR msopenh264-5.2.0/build/000077500000000000000000000000001435013470100145205ustar00rootroot00000000000000msopenh264-5.2.0/build/Makefile.am000066400000000000000000000000141435013470100165470ustar00rootroot00000000000000SUBDIRS=vs msopenh264-5.2.0/build/osx/000077500000000000000000000000001435013470100153315ustar00rootroot00000000000000msopenh264-5.2.0/build/osx/Info.plist.in000066400000000000000000000025471435013470100177160ustar00rootroot00000000000000 CFBundleDevelopmentRegion English CFBundleExecutable msopenh264 CFBundleGetInfoString ${MACOSX_BUNDLE_INFO_STRING} CFBundleIconFile ${MACOSX_BUNDLE_ICON_FILE} CFBundleIdentifier ${MACOSX_FRAMEWORK_IDENTIFIER} LSMinimumSystemVersion ${MIN_OS} MinimumOSVersion ${MIN_OS} CFBundleInfoDictionaryVersion 6.0 CFBundleLongVersionString ${MACOSX_BUNDLE_LONG_VERSION_STRING} CFBundleName ${MACOSX_BUNDLE_BUNDLE_NAME} CFBundlePackageType FMWK CFBundleShortVersionString ${VERSION} CFBundleSignature ???? CFBundleVersion ${VERSION} CSResourcesFileMapped NSHumanReadableCopyright ${MACOSX_BUNDLE_COPYRIGHT} NSPrincipalClass NSApplication NSHighResolutionCapable True msopenh264-5.2.0/build/vs/000077500000000000000000000000001435013470100151505ustar00rootroot00000000000000msopenh264-5.2.0/build/vs/Makefile.am000066400000000000000000000000561435013470100172050ustar00rootroot00000000000000EXTRA_DIST= msopenh264.sln msopenh264.vcproj msopenh264-5.2.0/build/vs/msopenh264.sln000066400000000000000000000015651435013470100176020ustar00rootroot00000000000000 Microsoft Visual Studio Solution File, Format Version 10.00 # Visual Studio 2008 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "msopenh264", "msopenh264.vcproj", "{8A4A1340-5B83-4698-8F2A-B8DCCA0C3285}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Release|Win32 = Release|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {8A4A1340-5B83-4698-8F2A-B8DCCA0C3285}.Debug|Win32.ActiveCfg = Debug|Win32 {8A4A1340-5B83-4698-8F2A-B8DCCA0C3285}.Debug|Win32.Build.0 = Debug|Win32 {8A4A1340-5B83-4698-8F2A-B8DCCA0C3285}.Release|Win32.ActiveCfg = Release|Win32 {8A4A1340-5B83-4698-8F2A-B8DCCA0C3285}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal msopenh264-5.2.0/build/vs/msopenh264.vcproj000066400000000000000000000115051435013470100203040ustar00rootroot00000000000000 msopenh264-5.2.0/cmake/000077500000000000000000000000001435013470100145015ustar00rootroot00000000000000msopenh264-5.2.0/cmake/FindOpenH264.cmake000066400000000000000000000052511435013470100175540ustar00rootroot00000000000000############################################################################ # FindOpenH264.txt # Copyright (C) 2014 Belledonne Communications, Grenoble France # ############################################################################ # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # ############################################################################ # # - Find the openh264 include file and library # # OPENH264_FOUND - system has openh264 # OPENH264_INCLUDE_DIRS - the openh264 include directory # OPENH264_LIBRARIES - The libraries needed to use openh264 include(CMakePushCheckState) include(CheckCXXSymbolExists) set(_OPENH264_ROOT_PATHS ${WITH_OPENH264} ${CMAKE_INSTALL_PREFIX} ) find_path(OPENH264_INCLUDE_DIRS NAMES wels/codec_api.h HINTS _OPENH264_ROOT_PATHS PATH_SUFFIXES include ) if(OPENH264_INCLUDE_DIRS) set(HAVE_WELS_CODEC_API_H 1) endif() find_library(OPENH264_LIBRARIES NAMES openh264_dll openh264 HINTS _OPENH264_ROOT_PATHS PATH_SUFFIXES bin lib ) if(OPENH264_LIBRARIES) if( WIN32 OR ANDROID )#issue with check_cxx_symbol_exists on Windows (TODO: missing libraries in OPENH264_LIBRARIES?). If OPENH264_INCLUDE_DIRS, then decoder exists. set(OPENH264_FOUND TRUE) set(HAVE_WELS_CREATE_DECODER TRUE) else() # need pthread lib for check_cxx_symbol_exists find_library(PTHREAD_LIBRARY NAMES pthread ) list(APPEND OPENH264_LIBRARIES ${PTHREAD_LIBRARY}) cmake_push_check_state(RESET) list(APPEND CMAKE_REQUIRED_INCLUDES ${OPENH264_INCLUDE_DIRS}) list(APPEND CMAKE_REQUIRED_LIBRARIES ${OPENH264_LIBRARIES}) check_cxx_symbol_exists("WelsCreateDecoder" "wels/codec_api.h" HAVE_WELS_CREATE_DECODER) cmake_pop_check_state() if(HAVE_WELS_CREATE_DECODER) set(OPENH264_FOUND TRUE) endif() endif() endif() include(FindPackageHandleStandardArgs) find_package_handle_standard_args(OpenH264 DEFAULT_MSG OPENH264_INCLUDE_DIRS OPENH264_LIBRARIES HAVE_WELS_CODEC_API_H HAVE_WELS_CREATE_DECODER ) mark_as_advanced(OPENH264_INCLUDE_DIRS OPENH264_LIBRARIES HAVE_WELS_CODEC_API_H HAVE_WELS_CREATE_DECODER) msopenh264-5.2.0/config.h.cmake000066400000000000000000000030211435013470100161120ustar00rootroot00000000000000/*************************************************************************** * config.h.cmake * Copyright (C) 2014 Belledonne Communications, Grenoble France * **************************************************************************** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ****************************************************************************/ #cmakedefine PACKAGE "@PACKAGE@" #cmakedefine PACKAGE_NAME "@PACKAGE_NAME@" #cmakedefine PACKAGE_VERSION "@PACKAGE_VERSION@" #cmakedefine PACKAGE_STRING "@PACKAGE_STRING@" #cmakedefine PACKAGE_TARNAME "@PACKAGE_TARNAME@" #cmakedefine PACKAGE_BUGREPORT "@PACKAGE_BUGREPORT@" #cmakedefine PACKAGE_URL "@PACKAGE_URL@" #cmakedefine VERSION "@VERSION@" #ifndef HAVE_STDBOOL_H #cmakedefine HAVE_STDBOOL_H #endif #cmakedefine HAVE_MEDIASTREAMER2_MSCOMMON_H #cmakedefine HAVE_WELS_CODEC_API_H #cmakedefine HAVE_WELS_CREATE_DECODER msopenh264-5.2.0/configure.ac000066400000000000000000000074051435013470100157150ustar00rootroot00000000000000dnl Process this file with autoconf to produce a configure script. AC_INIT([msopenh264],[1.2.0]) AC_CANONICAL_SYSTEM AM_INIT_AUTOMAKE([tar-ustar foreign]) AC_CONFIG_HEADERS(config.h) AC_MSG_CHECKING([warning make an error on compilation]) AC_ARG_ENABLE(strict, [ --enable-strict Enable error on compilation warning [default=yes]], [wall_werror=$enableval], [wall_werror=yes] ) AC_ARG_ENABLE(decoder, [ --disable-decoder Disable decoder - encoder only configuration [default=no]], [decoder_enabled=$enableval], [decoder_enabled=yes] ) if test "$decoder_enabled" = "yes" ; then AC_DEFINE(OPENH264_DECODER_ENABLED, 1, [whether decoder is compiled]) fi dnl Checks for programs. AC_PROG_CXX AC_LIBTOOL_WIN32_DLL AC_DISABLE_STATIC AC_PROG_LIBTOOL case $target_os in *mingw*) mingw_found=yes ;; esac AM_CONDITIONAL(BUILD_WIN32, test x$mingw_found = xyes) AC_CONFIG_COMMANDS([libtool-hacking],[ if test "$mingw_found" = "yes" ; then AC_MSG_NOTICE([Hacking libtool to work with mingw...]) sed -e 's/\*\" \$a_deplib \"\*/\*/' < ./libtool > libtool.tmp cp -f ./libtool.tmp ./libtool rm -f ./libtool.tmp fi ],[mingw_found=$mingw_found]) CFLAGS="$CFLAGS -Wall" dnl Checks for header files. AC_HEADER_STDC dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_C_INLINE AC_HEADER_TIME AC_WORDS_BIGENDIAN if test x$ac_cv_c_bigendian = xyes ; then CFLAGS="$CFLAGS -D_BIGENDIAN" fi if test $GCC = yes && test $wall_werror = yes; then CFLAGS="$CFLAGS -Werror -Wextra " fi if test $GCC = yes ; then CFLAGS="$CFLAGS -pthread" LDFLAGS="$LDFLAGS -pthread" fi PKG_CHECK_MODULES(MEDIASTREAMER, mediastreamer >= 2.14.0) found_openh264=no AC_ARG_WITH(openh264, [AS_HELP_STRING([--with-openh264], [Sets the installation prefix of the openh264 library. (default=$prefix)])], [ openh264prefix=${withval}], [ openh264prefix=$prefix ] ) CPPFLAGS_save=$CPPFLAGS CPPFLAGS="$CPPFLAGS -I${openh264prefix}/include -L${openh264prefix}/lib" AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_CHECK_HEADERS([stdbool.h wels/codec_api.h], [ AC_CHECK_LIB(openh264, WelsCreateDecoder, [ OPENH264_LIBS="-lopenh264"; found_openh264=yes]) ], [], [[#ifdef HAVE_STDBOOL_H # include #endif ]] ) AC_SUBST(OPENH264_LIBS) AC_LANG_RESTORE CPPFLAGS=$CPPFLAGS_save if test "${found_openh264}" = "no"; then AC_MSG_ERROR([Could not find the openh264 library.]) fi LDFLAGS="$LDFLAGS -rdynamic " dnl define path of plugins: PACKAGE_PLUGINS_DIR="\$(libdir)/mediastreamer/plugins" AC_SUBST(PACKAGE_PLUGINS_DIR) dnl ################################################## dnl # Check for ESP Packager dnl ################################################## AC_PATH_PROG(EPM,epm,false) AC_PATH_PROG(MKEPMLIST,mkepmlist,false) AC_PATH_PROG(EPMINSTALL,epminstall,false) AM_CONDITIONAL(WITH_EPM,test $EPM != false && test $MKEPMLIST != false && test $EPMINSTALL != false) # Preferred packaging system, as per EPM terminology case $target in *-*-linux*) if test -f /etc/debian_version ; then EPM_PKG_EXT=deb else EPM_PKG_EXT=rpm fi ;; *-hp-hpux*) EPM_PKG_EXT=depot.gz;; *-dec-osf*) EPM_PKG_EXT=setld;; esac AC_SUBST(EPM_PKG_EXT) # System software User & Group names case $target in *-*-linux*) SYS_USER=root SYS_GROUP=root ;; *-*-hpux*|*-dec-osf*) SYS_USER=bin SYS_GROUP=bin ;; esac AC_SUBST(SYS_USER) AC_SUBST(SYS_GROUP) # CPU Architecture case $target_cpu in i?86) ARCH=i386;; *) ARCH=$target_cpu;; esac AC_SUBST(ARCH) # Various other packaging variables, that can be over-ridden ad `make # package' time SUMMARY="A H264 codec mediastreamer plugin" AC_SUBST(SUMMARY) PACKAGER=anonymous AC_SUBST(PACKAGER) LICENSE=GPL AC_SUBST(LICENSE) VENDOR=Linphone AC_SUBST(VENDOR) RELEASE=1 AC_SUBST(RELEASE) AC_OUTPUT( Makefile build/Makefile build/vs/Makefile src/Makefile msopenh264.iss ) msopenh264-5.2.0/msopenh264.iss.in000066400000000000000000000021751435013470100164600ustar00rootroot00000000000000; Script generated by the Inno Setup Script Wizard. ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! [Setup] AppName=msopenh264 AppVerName=msopenh264 version @VERSION@ , an H.264 plugin for linphone based on the openh264 library. AppPublisher=linphone.org AppPublisherURL=http://www.linphone.org AppSupportURL=http://www.linphone.org AppUpdatesURL=http://www.linphone.org DefaultDirName={pf}\Linphone DefaultGroupName=Linphone LicenseFile=COPYING InfoBeforeFile=README OutputBaseFilename=setup Compression=lzma SolidCompression=yes [Languages] Name: "english"; MessagesFile: "compiler:Default.isl" [Tasks] ;Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked [Files] #include "msopenh264-win32.filelist" [Icons] ;Name: "{group}\Linphone"; Filename: "{app}\linphone-wx.exe" ; WorkingDir: "{app}" ;Name: "{userdesktop}\Linphone"; Filename: "{app}\linphone-wx.exe"; WorkingDir: "{app}" ; Tasks: desktopicon [Run] ;Filename: "{app}\linphone-wx.exe"; Description: "{cm:LaunchProgram,Linphone}"; WorkingDir: "{app}" ; Flags: nowait postinstall skipifsilent msopenh264-5.2.0/src/000077500000000000000000000000001435013470100142105ustar00rootroot00000000000000msopenh264-5.2.0/src/CMakeLists.txt000066400000000000000000000060651435013470100167570ustar00rootroot00000000000000############################################################################ # CMakeLists.txt # Copyright (C) 2014 Belledonne Communications, Grenoble France # ############################################################################ # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # ############################################################################ set(LIBS ${MEDIASTREAMER2_LIBRARIES} ${ORTP_LIBRARIES} ${OPENH264_LIBRARIES} ${BCTOOLBOX_CORE_LIBRARIES} ) set(SOURCE_FILES msopenh264.cpp msopenh264dec.cpp msopenh264enc.cpp ) if(ENABLE_DECODER) add_definitions(-DOPENH264_DECODER_ENABLED) endif() set(MS2_PLUGINS_DIR "${MEDIASTREAMER2_PLUGINS_LOCATION}") if(ENABLE_STATIC) add_library(msopenh264-static STATIC ${SOURCE_FILES}) set_target_properties(msopenh264-static PROPERTIES OUTPUT_NAME msopenh264) target_link_libraries(msopenh264-static ${LIBS}) install(TARGETS msopenh264-static ARCHIVE DESTINATION "${MS2_PLUGINS_DIR}" PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) endif() if(ENABLE_SHARED) if(NOT APPLE) add_library(msopenh264 MODULE ${SOURCE_FILES}) else() add_library(msopenh264 SHARED ${SOURCE_FILES}) endif() target_link_libraries(msopenh264 ${LIBS}) if(APPLE) if(IOS) set(MIN_OS ${LINPHONE_IOS_DEPLOYMENT_TARGET}) else() set(MIN_OS ${CMAKE_OSX_DEPLOYMENT_TARGET}) endif() set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/build/osx/") set_target_properties(msopenh264 PROPERTIES FRAMEWORK TRUE MACOSX_FRAMEWORK_IDENTIFIER org.linphone.msopenh264 MACOSX_FRAMEWORK_INFO_PLIST Info.plist.in ) endif() if(MSVC) if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR} PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) endif() set_target_properties(msopenh264 PROPERTIES PREFIX "lib") if(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") set_target_properties(msopenh264 PROPERTIES VS_WINRT_COMPONENT TRUE) endif() endif() install(TARGETS msopenh264 RUNTIME DESTINATION "${MS2_PLUGINS_DIR}" LIBRARY DESTINATION "${MS2_PLUGINS_DIR}" ARCHIVE DESTINATION "${MS2_PLUGINS_DIR}" FRAMEWORK DESTINATION Frameworks PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) endif() msopenh264-5.2.0/src/Makefile.am000066400000000000000000000006671435013470100162550ustar00rootroot00000000000000pluginsdir=$(PACKAGE_PLUGINS_DIR) plugins_LTLIBRARIES=libmsopenh264.la libmsopenh264_la_SOURCES= \ msopenh264.cpp msopenh264.h \ msopenh264dec.cpp msopenh264dec.h \ msopenh264enc.cpp msopenh264enc.h libmsopenh264_la_CPPFLAGS= $(MEDIASTREAMER_CFLAGS) libmsopenh264_la_LIBADD=$(MEDIASTREAMER_LIBS) $(OPENH264_LIBS) libmsopenh264_la_LDFLAGS=-module -no-undefined AM_CPPFLAGS=$(MEDIASTREAMER_CFLAGS) AM_CFLAGS=$(MEDIASTREAMER_CFLAGS) msopenh264-5.2.0/src/msopenh264.cpp000066400000000000000000000232061435013470100166240ustar00rootroot00000000000000/* H.264 encoder/decoder plugin for mediastreamer2 based on the openh264 library. Copyright (C) 2006-2012 Belledonne Communications, Grenoble This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include "mediastreamer2/msfilter.h" #include "mediastreamer2/msvideo.h" #include "msopenh264dec.h" #include "msopenh264enc.h" #ifndef VERSION #define VERSION "0.1.0" #endif /****************************************************************************** * Implementation of the decoder * *****************************************************************************/ static void msopenh264_dec_init(MSFilter *f) { MSOpenH264Decoder *d = new MSOpenH264Decoder(f); f->data = d; } static void msopenh264_dec_preprocess(MSFilter *f) { MSOpenH264Decoder *d = static_cast(f->data); d->initialize(); } static void msopenh264_dec_process(MSFilter *f) { MSOpenH264Decoder *d = static_cast(f->data); d->feed(); } static void msopenh264_dec_uninit(MSFilter *f) { MSOpenH264Decoder *d = static_cast(f->data); d->uninitialize(); delete d; } /****************************************************************************** * Methods to configure the decoder * *****************************************************************************/ static int msopenh264_dec_add_fmtp(MSFilter *f, void *arg) { MSOpenH264Decoder *d = static_cast(f->data); const char *fmtp = static_cast(arg); char value[256]; if (fmtp_get_value(fmtp, "sprop-parameter-sets", value, sizeof(value))) { d->provideSpropParameterSets(value, sizeof(value)); } return 0; } static int msopenh264_dec_reset_first_image(MSFilter *f, void *arg) { MSOpenH264Decoder *d = static_cast(f->data); d->resetFirstImageDecoded(); return 0; } static int msopenh264_dec_enable_avpf(MSFilter *f, void *arg) { MSOpenH264Decoder *d = static_cast(f->data); d->enableAVPF(*((bool_t *)arg) ? true : false); return 0; } static int msopenh264_dec_get_size(MSFilter *f, void *arg) { MSOpenH264Decoder *d = static_cast(f->data); MSVideoSize *size = static_cast(arg); *size = d->getSize(); return 0; } static int msopenh264_dec_get_fps(MSFilter *f, void *arg){ MSOpenH264Decoder *d = static_cast(f->data); *(float*)arg=d->getFps(); return 0; } static int msopenh264_dec_get_out_fmt(MSFilter *f, void *arg){ MSOpenH264Decoder *d = static_cast(f->data); ((MSPinFormat*)arg)->pin=0; ((MSPinFormat*)arg)->fmt=d->getOutFmt(); return 0; } static MSFilterMethod msopenh264_dec_methods[] = { { MS_FILTER_ADD_FMTP, msopenh264_dec_add_fmtp }, { MS_VIDEO_DECODER_RESET_FIRST_IMAGE_NOTIFICATION, msopenh264_dec_reset_first_image }, { MS_VIDEO_DECODER_ENABLE_AVPF, msopenh264_dec_enable_avpf }, { MS_FILTER_GET_VIDEO_SIZE, msopenh264_dec_get_size }, { MS_FILTER_GET_FPS, msopenh264_dec_get_fps }, { MS_FILTER_GET_OUTPUT_FMT, msopenh264_dec_get_out_fmt }, { 0, NULL } }; /****************************************************************************** * Definition of the decoder * *****************************************************************************/ MSFilterDesc msopenh264_dec_desc = { MS_FILTER_PLUGIN_ID, /* id */ "MSOpenH264Dec", /* name */ "OpenH264 Video Codec provided by Cisco Systems, Inc.", /* text */ MS_FILTER_DECODER, /* category */ "H264", /* enc_fmt */ 1, /* ninputs */ 1, /* noutputs */ msopenh264_dec_init, /* init */ msopenh264_dec_preprocess, /* preprocess */ msopenh264_dec_process, /* process */ NULL, /* postprocess */ msopenh264_dec_uninit, /* uninit */ msopenh264_dec_methods, /* methods */ 0 /* flags */ }; /****************************************************************************** * Implementation of the encoder * *****************************************************************************/ static void msopenh264_enc_init(MSFilter *f) { MSOpenH264Encoder *e = new MSOpenH264Encoder(f); f->data = e; } static void msopenh264_enc_preprocess(MSFilter *f) { MSOpenH264Encoder *e = static_cast(f->data); e->initialize(); } static void msopenh264_enc_process(MSFilter *f) { MSOpenH264Encoder *e = static_cast(f->data); e->feed(); } static void msopenh264_enc_postprocess(MSFilter *f) { MSOpenH264Encoder *e = static_cast(f->data); e->uninitialize(); } static void msopenh264_enc_uninit(MSFilter *f) { MSOpenH264Encoder *e = static_cast(f->data); delete e; } /****************************************************************************** * Methods to configure the encoder * *****************************************************************************/ static int msopenh264_enc_add_fmtp(MSFilter *f, void *arg) { MSOpenH264Encoder *e = static_cast(f->data); const char *fmtp = static_cast(arg); e->addFmtp(fmtp); return 0; } static int msopenh264_enc_req_vfu(MSFilter *f, void *arg) { MSOpenH264Encoder *e = static_cast(f->data); e->requestVFU(); return 0; } static int msopenh264_enc_notify_pli(MSFilter *f, void *arg) { MSOpenH264Encoder *e = static_cast(f->data); e->notifyPLI(); return 0; } static int msopenh264_enc_notify_fir(MSFilter *f, void *arg) { MSOpenH264Encoder *e = static_cast(f->data); uint8_t seqnr = *((uint8_t *)arg); e->notifyFIR(seqnr); return 0; } static int msopenh264_enc_enable_avpf(MSFilter *f, void *arg) { MSOpenH264Encoder *e = static_cast(f->data); ms_message("%s: %s AVPF", f->desc->name, *(bool_t *)arg ? "enabling" : "disabling"); e->enableAVPF(*((bool_t *)arg) ? true : false); return 0; } static int msopenh264_enc_get_configuration_list(MSFilter *f, void *arg) { MSOpenH264Encoder *e = static_cast(f->data); const MSVideoConfiguration **vconf_list = static_cast(arg); *vconf_list = e->getConfigurationList(); return 0; } static int msopenh264_enc_get_configuration(MSFilter *f, void *arg) { MSOpenH264Encoder *e = static_cast(f->data); MSVideoConfiguration *vconf = static_cast(arg); *vconf = e->getConfiguration(); return 0; } static int msopenh264_enc_set_configuration(MSFilter *f, void *arg) { MSOpenH264Encoder *e = static_cast(f->data); MSVideoConfiguration *vconf = static_cast(arg); e->setConfiguration(*vconf); return 0; } static MSFilterMethod msopenh264_enc_methods[] = { { MS_FILTER_ADD_FMTP, msopenh264_enc_add_fmtp }, { MS_FILTER_REQ_VFU, msopenh264_enc_req_vfu }, { MS_VIDEO_ENCODER_REQ_VFU, msopenh264_enc_req_vfu }, { MS_VIDEO_ENCODER_NOTIFY_PLI, msopenh264_enc_notify_pli }, { MS_VIDEO_ENCODER_NOTIFY_FIR, msopenh264_enc_notify_fir }, { MS_VIDEO_ENCODER_ENABLE_AVPF, msopenh264_enc_enable_avpf }, { MS_VIDEO_ENCODER_GET_CONFIGURATION_LIST, msopenh264_enc_get_configuration_list }, { MS_VIDEO_ENCODER_GET_CONFIGURATION, msopenh264_enc_get_configuration }, { MS_VIDEO_ENCODER_SET_CONFIGURATION, msopenh264_enc_set_configuration }, { 0, NULL } }; /****************************************************************************** * Definition of the encoder * *****************************************************************************/ MSFilterDesc msopenh264_enc_desc = { MS_FILTER_PLUGIN_ID, /* id */ "MSOpenH264Enc", /* name */ "OpenH264 Video Codec provided by Cisco Systems, Inc.", /* text */ MS_FILTER_ENCODER, /* category */ "H264", /* enc_fmt */ 1, /* ninputs */ 1, /* noutputs */ msopenh264_enc_init, /* init */ msopenh264_enc_preprocess, /* preprocess */ msopenh264_enc_process, /* process */ msopenh264_enc_postprocess, /* postprocess */ msopenh264_enc_uninit, /* uninit */ msopenh264_enc_methods, /* methods */ 0 /* flags */ }; #ifdef _MSC_VER #define MS_PLUGIN_DECLARE(type) extern "C" __declspec(dllexport) type #else #define MS_PLUGIN_DECLARE(type) extern "C" type #endif MS_PLUGIN_DECLARE(void) libmsopenh264_init(MSFactory *factory){ #ifdef OPENH264_DECODER_ENABLED ms_factory_register_filter(factory, &msopenh264_dec_desc); #endif ms_factory_register_filter(factory, &msopenh264_enc_desc); ms_message("msopenh264-" VERSION " plugin registered."); } msopenh264-5.2.0/src/msopenh264.h000066400000000000000000000015311435013470100162660ustar00rootroot00000000000000/* H.264 encoder/decoder plugin for mediastreamer2 based on the openh264 library. Copyright (C) 2006-2012 Belledonne Communications, Grenoble This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #define MSOPENH264_DEBUG 0 msopenh264-5.2.0/src/msopenh264dec.cpp000066400000000000000000000234521435013470100173030ustar00rootroot00000000000000/* H.264 encoder/decoder plugin for mediastreamer2 based on the openh264 library. Copyright (C) 2006-2012 Belledonne Communications, Grenoble This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "msopenh264dec.h" #include "mediastreamer2/msticker.h" #include "ortp/b64.h" #include "wels/codec_ver.h" static void decoder_log(void* context, int level, const char* message){ ms_message("OpenH264 decoder: %s", message); } MSOpenH264Decoder::MSOpenH264Decoder(MSFilter *f) : mFilter(f), mDecoder(0), mUnpacker(0), mSPS(0), mPPS(0), mYUVMsg(0), mBitstream(0), mBitstreamSize(65536), mLastErrorReportTime(0), mWidth(MS_VIDEO_SIZE_UNKNOWN_W), mHeight(MS_VIDEO_SIZE_UNKNOWN_H), mInitialized(false), mFirstImageDecoded(false) { long ret = WelsCreateDecoder(&mDecoder); if (ret != 0) { ms_error("OpenH264 decoder: Failed to create decoder: %li", ret); } else { mBitstream = static_cast(ms_malloc0(mBitstreamSize)); WelsTraceCallback cb = &decoder_log; mDecoder->SetOption(DECODER_OPTION_TRACE_CALLBACK, (void*)&cb); int logLevel = WELS_LOG_WARNING; mDecoder->SetOption(DECODER_OPTION_TRACE_LEVEL, &logLevel); } } MSOpenH264Decoder::~MSOpenH264Decoder() { if (mBitstream != 0) { ms_free(mBitstream); } if (mDecoder != 0) { WelsDestroyDecoder(mDecoder); } } void MSOpenH264Decoder::initialize() { if (!mInitialized) { mFirstImageDecoded = false; mUnpacker=rfc3984_new_with_factory(mFilter->factory); if (mDecoder != 0) { SDecodingParam params = { 0 }; #if (OPENH264_MAJOR == 1) && (OPENH264_MINOR <6) params.eOutputColorFormat = videoFormatI420; #endif params.uiTargetDqLayer = (unsigned char) -1; params.eEcActiveIdc = ERROR_CON_FRAME_COPY_CROSS_IDR; params.sVideoProperty.size = sizeof(params.sVideoProperty); params.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_AVC; long ret = mDecoder->Initialize(¶ms); if (ret != 0) { ms_error("OpenH264 decoder: Failed to initialize: %li", ret); } else { ms_average_fps_init(&mFPS, "OpenH264 decoder: FPS=%f"); mInitialized = true; } } } } void MSOpenH264Decoder::feed() { if (!isInitialized()){ ms_error("MSOpenH264Decoder::feed(): not initialized"); ms_queue_flush(mFilter->inputs[0]); return; } MSQueue nalus; ms_queue_init(&nalus); mblk_t *im; bool requestPLI = false; while ((im = ms_queue_get(mFilter->inputs[0])) != NULL) { unsigned int ret; if ((getIDRPicId() == 0) && (mSPS != 0) && (mPPS != 0)) { // Push the sps/pps given in sprop-parameter-sets if any rfc3984_unpack_out_of_band_sps_pps(mUnpacker, mSPS, mPPS); mSPS = NULL; mPPS = NULL; } ret = rfc3984_unpack2(mUnpacker, im, &nalus); if (ret & Rfc3984FrameAvailable) { void * pData[3] = { 0 }; SBufferInfo sDstBufInfo = { 0 }; int len = nalusToFrame(&nalus); if (ret & Rfc3984FrameCorrupted) requestPLI = true; DECODING_STATE state = mDecoder->DecodeFrame2(mBitstream, len, (uint8_t**)pData, &sDstBufInfo); if (state != dsErrorFree) { ms_error("OpenH264 decoder: DecodeFrame2 failed: 0x%x", (int)state); requestPLI = true; } if (sDstBufInfo.iBufferStatus == 1) { uint8_t * pDst[3] = { 0 }; pDst[0] = (uint8_t *)pData[0]; pDst[1] = (uint8_t *)pData[1]; pDst[2] = (uint8_t *)pData[2]; // Update video size and (re)allocate YUV buffer if needed if ((mWidth != sDstBufInfo.UsrData.sSystemBuffer.iWidth) || (mHeight != sDstBufInfo.UsrData.sSystemBuffer.iHeight)) { if (mYUVMsg) { freemsg(mYUVMsg); } mWidth = sDstBufInfo.UsrData.sSystemBuffer.iWidth; mHeight = sDstBufInfo.UsrData.sSystemBuffer.iHeight; mYUVMsg = ms_yuv_buf_alloc(&mOutbuf, mWidth, mHeight); ms_filter_notify_no_arg(mFilter,MS_FILTER_OUTPUT_FMT_CHANGED); } // Scale/copy frame to destination mblk_t for (int i = 0; i < 3; i++) { uint8_t *dst = mOutbuf.planes[i]; uint8_t *src = pDst[i]; int h = mHeight >> (( i > 0) ? 1 : 0); for(int j = 0; j < h; j++) { memcpy(dst, src, mOutbuf.strides[i]); dst += mOutbuf.strides[i]; src += sDstBufInfo.UsrData.sSystemBuffer.iStride[(i == 0) ? 0 : 1]; } } ms_queue_put(mFilter->outputs[0], dupmsg(mYUVMsg)); // Update average FPS if (ms_average_fps_update(&mFPS, mFilter->ticker->time)) { ms_message("OpenH264 decoder: Frame size: %dx%d", mWidth, mHeight); } // Notify first decoded image if (!mFirstImageDecoded) { mFirstImageDecoded = true; ms_filter_notify_no_arg(mFilter, MS_VIDEO_DECODER_FIRST_IMAGE_DECODED); } #if MSOPENH264_DEBUG ms_message("OpenH264 decoder: IDR pic id: %d, Frame num: %d, Temporal id: %d, VCL NAL: %d", getIDRPicId(), getFrameNum(), getTemporalId(), getVCLNal()); #endif } } } if (requestPLI) { if (mAVPFEnabled){ ms_filter_notify_no_arg(mFilter, MS_VIDEO_DECODER_SEND_PLI); }else if (((mFilter->ticker->time - mLastErrorReportTime) > 5000) || (mLastErrorReportTime == 0)) { mLastErrorReportTime = mFilter->ticker->time; ms_filter_notify_no_arg(mFilter, MS_VIDEO_DECODER_DECODING_ERRORS); } } } void MSOpenH264Decoder::uninitialize() { if (mSPS != 0) { freemsg(mSPS); mSPS=NULL; } if (mPPS != 0) { freemsg(mPPS); mPPS=NULL; } if (mYUVMsg != 0) { freemsg(mYUVMsg); mYUVMsg=NULL; } if (mDecoder != 0) { mDecoder->Uninitialize(); } if (mUnpacker){ rfc3984_destroy(mUnpacker); mUnpacker=NULL; } mInitialized = false; } void MSOpenH264Decoder::provideSpropParameterSets(char *value, int valueSize) { char *b64_sps = value; char *b64_pps = strchr(value, ','); if (b64_pps) { *b64_pps = '\0'; ++b64_pps; ms_message("OpenH264 decoder: Got sprop-parameter-sets sps=%s, pps=%s", b64_sps, b64_pps); mSPS = allocb(valueSize, 0); mSPS->b_wptr += b64::b64_decode(b64_sps, strlen(b64_sps), mSPS->b_wptr, valueSize); mPPS = allocb(valueSize, 0); mPPS->b_wptr += b64::b64_decode(b64_pps, strlen(b64_pps), mPPS->b_wptr, valueSize); } } void MSOpenH264Decoder::resetFirstImageDecoded() { mFirstImageDecoded = false; mWidth = MS_VIDEO_SIZE_UNKNOWN_W; mHeight = MS_VIDEO_SIZE_UNKNOWN_H; } MSVideoSize MSOpenH264Decoder::getSize() const { MSVideoSize size; size.width = mWidth; size.height = mHeight; return size; } float MSOpenH264Decoder::getFps()const{ return ms_average_fps_get(&mFPS); } const MSFmtDescriptor * MSOpenH264Decoder::getOutFmt()const{ MSVideoSize vsize={mWidth,mHeight}; return ms_factory_get_video_format(mFilter->factory,"YUV420P",vsize,0,NULL); } int MSOpenH264Decoder::nalusToFrame(MSQueue *nalus) { mblk_t *im; uint8_t *dst = mBitstream; uint8_t *end = mBitstream + mBitstreamSize; bool startPicture = true; while ((im = ms_queue_get(nalus)) != NULL) { uint8_t *src = im->b_rptr; int nalLen = im->b_wptr - src; if ((dst + nalLen + 128) > end) { int pos = dst - mBitstream; enlargeBitstream(mBitstreamSize + nalLen + 128); dst = mBitstream + pos; end = mBitstream + mBitstreamSize; } if ((src[0] == 0) && (src[1] == 0) && (src[2] == 0) && (src[3] == 1)) { // Workaround for stupid RTP H264 sender that includes nal markers #if MSOPENH264_DEBUG ms_warning("OpenH264 decoder: stupid RTP H264 encoder"); #endif int size = im->b_wptr - src; memcpy(dst, src, size); dst += size; } else { uint8_t naluType = *src & 0x1f; #if MSOPENH264_DEBUG if ((naluType != 1) && (naluType != 7) && (naluType != 8)) { ms_message("OpenH264 decoder: naluType=%d", naluType); } if (naluType == 7) { ms_message("OpenH264 decoder: Got SPS"); } if (naluType == 8) { ms_message("OpenH264 decoder: Got PPS"); } #endif if (startPicture || (naluType == 6) // SEI || (naluType == 7) // SPS || (naluType == 8) // PPS || ((naluType >= 14) && (naluType <= 18))) { // Reserved *dst++ = 0; startPicture = false; } // Prepend nal marker *dst++ = 0; *dst++ = 0; *dst++ = 1; *dst++ = *src++; while (src < (im->b_wptr - 3)) { if ((src[0] == 0) && (src[1] == 0) && (src[2] < 3)) { *dst++ = 0; *dst++ = 0; *dst++ = 3; src += 2; } *dst++ = *src++; } while (src < im->b_wptr) { *dst++ = *src++; } } freemsg(im); } return dst - mBitstream; } void MSOpenH264Decoder::enlargeBitstream(int newSize) { mBitstreamSize = newSize; mBitstream = static_cast(ms_realloc(mBitstream, mBitstreamSize)); } int32_t MSOpenH264Decoder::getFrameNum() { int32_t frameNum = -1; int ret = mDecoder->GetOption(DECODER_OPTION_FRAME_NUM, &frameNum); if (ret != 0) { ms_error("OpenH264 decoder: Failed getting frame number: %d", ret); } return frameNum; } int32_t MSOpenH264Decoder::getIDRPicId() { int32_t IDRPicId = -1; int ret = mDecoder->GetOption(DECODER_OPTION_IDR_PIC_ID, &IDRPicId); if (ret != 0) { ms_error("OpenH264 decoder: Failed getting IDR pic id: %d", ret); } return IDRPicId; } int32_t MSOpenH264Decoder::getTemporalId() { int32_t temporalId = -1; int ret = mDecoder->GetOption(DECODER_OPTION_TEMPORAL_ID, &temporalId); if (ret != 0) { ms_error("OpenH264 decoder: Failed getting temporal id: %d", ret); } return temporalId; } int32_t MSOpenH264Decoder::getVCLNal() { int32_t vclNal = -1; int ret = mDecoder->GetOption(DECODER_OPTION_VCL_NAL, &vclNal); if (ret != 0) { ms_error("OpenH264 decoder: Failed getting VCL NAL: %d", ret); } return vclNal; } msopenh264-5.2.0/src/msopenh264dec.h000066400000000000000000000036411435013470100167460ustar00rootroot00000000000000/* H.264 encoder/decoder plugin for mediastreamer2 based on the openh264 library. Copyright (C) 2006-2012 Belledonne Communications, Grenoble This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "mediastreamer2/msfilter.h" #include "mediastreamer2/msvideo.h" #include "mediastreamer2/rfc3984.h" #include "wels/codec_api.h" #include "msopenh264.h" class MSOpenH264Decoder { public: MSOpenH264Decoder(MSFilter *f); virtual ~MSOpenH264Decoder(); bool isInitialized() const { return mInitialized; } void initialize(); void feed(); void uninitialize(); void provideSpropParameterSets(char *value, int valueSize); void resetFirstImageDecoded(); void enableAVPF(bool enable) { mAVPFEnabled = enable; } MSVideoSize getSize() const; float getFps()const; const MSFmtDescriptor *getOutFmt()const; private: int nalusToFrame(MSQueue *nalus); void enlargeBitstream(int newSize); int32_t getFrameNum(); int32_t getIDRPicId(); int32_t getTemporalId(); int32_t getVCLNal(); MSFilter *mFilter; ISVCDecoder *mDecoder; Rfc3984Context *mUnpacker; MSPicture mOutbuf; MSAverageFPS mFPS; mblk_t *mSPS; mblk_t *mPPS; mblk_t *mYUVMsg; uint8_t *mBitstream; int mBitstreamSize; uint64_t mLastErrorReportTime; int mWidth; int mHeight; bool mInitialized; bool mFirstImageDecoded; bool mAVPFEnabled; }; msopenh264-5.2.0/src/msopenh264enc.cpp000066400000000000000000000272521435013470100173170ustar00rootroot00000000000000/* H.264 encoder/decoder plugin for mediastreamer2 based on the openh264 library. Copyright (C) 2006-2012 Belledonne Communications, Grenoble This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "msopenh264enc.h" #include "mediastreamer2/msticker.h" #include "wels/codec_app_def.h" #include "wels/codec_ver.h" //static const int RC_MARGIN = 10000; // bits per sec #if MSOPENH264_DEBUG static int debugLevel = 4; #else static int debugLevel = 1; #endif #if defined(__ANDROID__) || (TARGET_OS_IPHONE == 1) || defined(__arm__) #define MS_OPENH264_CONF(required_bitrate, bitrate_limit, resolution, fps_pc, cpus_pc, fps_mobile, cpus_mobile) \ { required_bitrate, bitrate_limit, { MS_VIDEO_SIZE_ ## resolution ## _W, MS_VIDEO_SIZE_ ## resolution ## _H },fps_mobile, cpus_mobile, NULL } #else #define MS_OPENH264_CONF(required_bitrate, bitrate_limit, resolution, fps_pc, cpus_pc, fps_mobile, cpus_mobile) \ { required_bitrate, bitrate_limit, { MS_VIDEO_SIZE_ ## resolution ## _W, MS_VIDEO_SIZE_ ## resolution ## _H },fps_pc, cpus_pc, NULL } #endif static const MSVideoConfiguration openh264_conf_list[] = { MS_OPENH264_CONF(2048000, 5000000, UXGA, 25, 4, 12, 2), /*1200p*/ MS_OPENH264_CONF(1536000, 3000000, SXGA_MINUS, 25, 4, 12, 2), MS_OPENH264_CONF(1024000, 2048000, 720P, 25, 4, 12, 2), MS_OPENH264_CONF( 850000, 2048000, XGA, 20, 4, 12, 2), MS_OPENH264_CONF( 750000, 1024000, SVGA, 20, 2, 12, 2), MS_OPENH264_CONF( 600000, 3000000, VGA, 30, 2, 12, 2), MS_OPENH264_CONF( 400000, 800000, VGA, 15, 2, 12, 2), /*480p*/ MS_OPENH264_CONF( 128000, 512000, CIF, 15, 1, 12, 2), MS_OPENH264_CONF( 100000, 380000, QVGA, 15, 1, 15, 2), /*240p*/ MS_OPENH264_CONF( 100000, 380000, QVGA, 15, 1, 12, 1), MS_OPENH264_CONF( 128000, 170000, QCIF, 10, 1, 10, 1), MS_OPENH264_CONF( 64000, 128000, QCIF, 10, 1, 7, 1), MS_OPENH264_CONF( 0, 64000, QCIF, 10, 1, 5, 1) }; MSOpenH264Encoder::MSOpenH264Encoder(MSFilter *f) : mFilter(f), mPacker(0), mPacketisationMode(0), mVConfList(openh264_conf_list), mFrameCount(0), mInitialized(false), mPacketisationModeSet(false), mAVPFEnabled(false) { long ret = WelsCreateSVCEncoder(&mEncoder); if (ret != 0) { ms_error("OpenH264 encoder: Failed to create encoder: %li", ret); } } MSOpenH264Encoder::~MSOpenH264Encoder() { if (mEncoder != 0) { WelsDestroySVCEncoder(mEncoder); } } void MSOpenH264Encoder::initialize() { mFrameCount = 0; mPacker = rfc3984_new_with_factory(mFilter->factory); if (mPacketisationModeSet) rfc3984_set_mode(mPacker, mPacketisationMode); else rfc3984_set_mode(mPacker, 1); // in absence of explicit directive from the other end, allow mode 1 because it allows to send big slices which is necessary for large images rfc3984_enable_stap_a(mPacker, FALSE); if (mEncoder != 0) { SEncParamExt params; int ret = mEncoder->GetDefaultParams(¶ms); if (ret != 0) { ms_error("OpenH264 encoder: Failed getting default params: %d", ret); } else { int targetBitrate, maxBitrate; calcBitrates(targetBitrate, maxBitrate); params.iUsageType = CAMERA_VIDEO_REAL_TIME; //params.iInputCsp = videoFormatI420; params.iPicWidth = mVConf.vsize.width; params.iPicHeight = mVConf.vsize.height; params.iTargetBitrate = targetBitrate; params.iMaxBitrate = maxBitrate; params.iRCMode = RC_BITRATE_MODE; params.fMaxFrameRate = mVConf.fps; params.uiIntraPeriod = mAVPFEnabled ? (mVConf.fps * 40) :(mVConf.fps*10); //params.bEnableRc = true; params.bEnableFrameSkip = true; params.bPrefixNalAddingCtrl = false; params.uiMaxNalSize = ms_factory_get_payload_max_size(mFilter->factory); params.iMultipleThreadIdc = ms_factory_get_cpu_count(mFilter->factory); params.bEnableDenoise = false; params.bEnableBackgroundDetection = true; params.bEnableAdaptiveQuant = false; params.bEnableSceneChangeDetect = false; params.bEnableLongTermReference = false; params.iSpatialLayerNum=1; params.eSpsPpsIdStrategy = CONSTANT_ID; params.sSpatialLayers[0].iVideoWidth = mVConf.vsize.width; params.sSpatialLayers[0].iVideoHeight = mVConf.vsize.height; params.sSpatialLayers[0].fFrameRate = mVConf.fps; params.sSpatialLayers[0].iSpatialBitrate = targetBitrate; params.sSpatialLayers[0].iMaxSpatialBitrate = maxBitrate; #if (OPENH264_MAJOR == 1) && (OPENH264_MINOR <6) params.sSpatialLayers[0].sSliceCfg.uiSliceMode = SM_DYN_SLICE; params.sSpatialLayers[0].sSliceCfg.sSliceArgument.uiSliceSizeConstraint = ms_factory_get_payload_max_size(mFilter->factory); #else params.sSpatialLayers[0].sSliceArgument.uiSliceMode = SM_SIZELIMITED_SLICE; params.sSpatialLayers[0].sSliceArgument.uiSliceSizeConstraint = ms_factory_get_payload_max_size(mFilter->factory); #endif //params.sSpatialLayers[0].sSliceCfg.uiSliceMode = SM_AUTO_SLICE; ret = mEncoder->InitializeExt(¶ms); if (ret != 0) { ms_error("OpenH264 encoder: Failed to initialize: %d", ret); } else { ret = mEncoder->SetOption(ENCODER_OPTION_TRACE_LEVEL, &debugLevel); if (ret != 0) { ms_error("OpenH264 encoder: Failed setting trace level: %d", ret); } mInitialized = true; } } } if (!mAVPFEnabled && (mFrameCount == 0)) { ms_video_starter_init(&mVideoStarter); } ms_iframe_requests_limiter_init(&mIFrameLimiter, 1000); } void MSOpenH264Encoder::feed() { if (!isInitialized()){ ms_queue_flush(mFilter->inputs[0]); return; } mblk_t *im; MSQueue nalus; ms_queue_init(&nalus); long long int ts = mFilter->ticker->time * 90LL; if ((im = ms_queue_peek_last(mFilter->inputs[0])) != NULL) { MSPicture pic; if (ms_yuv_buf_init_from_mblk(&pic, im) == 0) { bool generateKeyFrame = false; SFrameBSInfo sFbi = { 0 }; SSourcePicture srcPic = { 0 }; srcPic.iColorFormat = videoFormatI420; srcPic.iPicWidth = pic.w; srcPic.iPicHeight = pic.h; for (int i = 0; i < 3; i++) { srcPic.iStride[i] = pic.strides[i]; srcPic.pData[i] = pic.planes[i]; } srcPic.uiTimeStamp = mFilter->ticker->time; if (!mAVPFEnabled && ms_video_starter_need_i_frame(&mVideoStarter, mFilter->ticker->time)) { generateKeyFrame = true; } if (ms_iframe_requests_limiter_iframe_requested(&mIFrameLimiter, mFilter->ticker->time)){ generateKeyFrame = true; } if (generateKeyFrame){ generateKeyframe(); } int ret = mEncoder->EncodeFrame(&srcPic, &sFbi); if (ret == cmResultSuccess) { if ((sFbi.eFrameType != videoFrameTypeSkip) && (sFbi.eFrameType != videoFrameTypeInvalid)) { if (sFbi.eFrameType == videoFrameTypeIDR) { ms_iframe_requests_limiter_notify_iframe_sent(&mIFrameLimiter, mFilter->ticker->time); ms_message("MSOpenH264Encoder: sending IDR"); }else if (sFbi.eFrameType == videoFrameTypeI){ ms_message("MSOpenH264Encoder: sending I (but not IDR) frame"); } mFrameCount++; if (!mAVPFEnabled && (mFrameCount == 1)) { ms_video_starter_first_frame(&mVideoStarter, mFilter->ticker->time); } fillNalusQueue(sFbi, &nalus); rfc3984_pack(mPacker, &nalus, mFilter->outputs[0], ts); } } else { ms_error("OpenH264 encoder: Frame encoding failed: %d", ret); } } } ms_queue_flush(mFilter->inputs[0]); } void MSOpenH264Encoder::uninitialize() { if (mPacker != 0) { rfc3984_destroy(mPacker); mPacker = 0; } if (mEncoder != 0) { mEncoder->Uninitialize(); } mInitialized = false; } void MSOpenH264Encoder::addFmtp(const char *fmtp) { char value[12]; if (fmtp_get_value(fmtp, "packetization-mode", value, sizeof(value))) { mPacketisationMode = atoi(value); mPacketisationModeSet = true; ms_message("packetization-mode set to %i", mPacketisationMode); } } void MSOpenH264Encoder::setConfiguration(MSVideoConfiguration conf) { MSVideoSize vsize = mVConf.vsize; mVConf = conf; if (mVConf.required_bitrate > mVConf.bitrate_limit) mVConf.required_bitrate = mVConf.bitrate_limit; if (isInitialized()) { /* Do not change video size if encoder is running */ if (!ms_video_size_equal(mVConf.vsize, vsize)) { ms_warning("Video configuration: cannot change video size when encoder is running, actual=%dx%d, wanted=%dx%d", vsize.width, vsize.height, mVConf.vsize.width, mVConf.vsize.height); mVConf.vsize = vsize; } ms_filter_lock(mFilter); applyBitrate(); ms_filter_unlock(mFilter); return; } ms_message("OpenH264 encoder: Video configuration set: bitrate=%dbits/s, fps=%f, vsize=%dx%d", mVConf.required_bitrate, mVConf.fps, mVConf.vsize.width, mVConf.vsize.height); } void MSOpenH264Encoder::requestVFU() { // If we receive a VFU request, stop the video starter ms_video_starter_deactivate(&mVideoStarter); ms_filter_lock(mFilter); ms_iframe_requests_limiter_request_iframe(&mIFrameLimiter); ms_filter_unlock(mFilter); } void MSOpenH264Encoder::notifyPLI() { ms_message("OpenH264: PLI requested"); requestVFU(); } void MSOpenH264Encoder::notifyFIR(uint8_t seqnr) { requestVFU(); } void MSOpenH264Encoder::generateKeyframe() { int ret=0; if (mFrameCount>0){ ms_message("Requesting OpenH264 to generate a keyframe"); ret = mEncoder->ForceIntraFrame(true); }else ms_message("ForceIntraFrame() ignored since no frame has been generated yet."); if (ret != 0) { ms_error("OpenH264 encoder: Failed forcing intra-frame: %d", ret); } } void MSOpenH264Encoder::fillNalusQueue(SFrameBSInfo &sFbi, MSQueue *nalus) { for (int i = 0; i < sFbi.iLayerNum; i++) { SLayerBSInfo *layerBsInfo = &sFbi.sLayerInfo[i]; if (layerBsInfo != NULL) { mblk_t *m; unsigned char *ptr = layerBsInfo->pBsBuf; for (int j = 0; j < layerBsInfo->iNalCount; j++) { // Skip the NAL markers (first 4 bytes) int len = layerBsInfo->pNalLengthInByte[j] - 4; m = allocb(len, 0); memcpy(m->b_wptr, ptr + 4, len); m->b_wptr += len; ptr += layerBsInfo->pNalLengthInByte[j]; ms_queue_put(nalus, m); } } } } void MSOpenH264Encoder::calcBitrates(int &targetBitrate, int &maxBitrate) const { /* targetBitrate = mVConf.required_bitrate * 0.92; if (targetBitrate > RC_MARGIN) targetBitrate = targetBitrate - RC_MARGIN; maxBitrate = targetBitrate + RC_MARGIN / 2; */ targetBitrate = mVConf.required_bitrate*0.95; maxBitrate = mVConf.required_bitrate; } void MSOpenH264Encoder::applyBitrate() { int targetBitrate, maxBitrate; calcBitrates(targetBitrate, maxBitrate); SBitrateInfo targetBitrateInfo, maxBitrateInfo; targetBitrateInfo.iLayer = maxBitrateInfo.iLayer = SPATIAL_LAYER_0; targetBitrateInfo.iBitrate = targetBitrate; maxBitrateInfo.iBitrate = maxBitrate; int ret = mEncoder->SetOption(ENCODER_OPTION_MAX_BITRATE, &maxBitrateInfo); if (ret != 0) { ms_error("OpenH264 encoder: Failed setting maximum bitrate: %d", ret); } ret = mEncoder->SetOption(ENCODER_OPTION_BITRATE, &targetBitrateInfo); if (ret != 0) { ms_error("OpenH264 encoder: Failed setting bitrate: %d", ret); } float frameRate = mVConf.fps; ret = mEncoder->SetOption(ENCODER_OPTION_FRAME_RATE, &frameRate); if (ret != 0) { ms_error("OpenH264 encoder: failed setting frame rate %d", ret); } ms_message("OpenH264 encoder applyBitrate done"); } msopenh264-5.2.0/src/msopenh264enc.h000066400000000000000000000040761435013470100167630ustar00rootroot00000000000000/* H.264 encoder/decoder plugin for mediastreamer2 based on the openh264 library. Copyright (C) 2006-2012 Belledonne Communications, Grenoble This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "mediastreamer2/msfilter.h" #include "mediastreamer2/msvideo.h" #include "mediastreamer2/rfc3984.h" #include "mediastreamer2/mscodecutils.h" #include "wels/codec_api.h" #include "msopenh264.h" class MSOpenH264Encoder { public: MSOpenH264Encoder(MSFilter *f); virtual ~MSOpenH264Encoder(); void initialize(); bool isInitialized() const { return mInitialized; } void feed(); void uninitialize(); void addFmtp(const char *fmtp); const MSVideoConfiguration *getConfigurationList() const { return mVConfList; } void setConfiguration(MSVideoConfiguration conf); MSVideoConfiguration getConfiguration() { return mVConf; } void requestVFU(); void enableAVPF(bool enable) { mAVPFEnabled = enable; } void notifyPLI(); void notifyFIR(uint8_t seqnr); private: void generateKeyframe(); void fillNalusQueue(SFrameBSInfo& sFbi, MSQueue* nalus); void calcBitrates(int &targetBitrate, int &maxBitrate) const; void applyBitrate(); MSFilter *mFilter; Rfc3984Context *mPacker; int mPacketisationMode; ISVCEncoder *mEncoder; const MSVideoConfiguration *mVConfList; MSVideoConfiguration mVConf; MSVideoStarter mVideoStarter; MSIFrameRequestsLimiterCtx mIFrameLimiter; uint64_t mFrameCount; bool mInitialized; bool mPacketisationModeSet; bool mAVPFEnabled; };