Merge pull request #3280 from Carbenium/drop-xenial

Drop Ubuntu Xenial support
This commit is contained in:
Isaac Connor 2021-06-05 15:33:13 -04:00 committed by GitHub
commit dc6c00ba88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
63 changed files with 119 additions and 2174 deletions

View File

@ -1,31 +0,0 @@
name: CI Xenial
on:
push:
branches:
- '*'
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-16.04
steps:
- name: Update packages
run: sudo apt-get -qq update && sudo apt-get -qq upgrade
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Install dependencies
run: >
sudo apt-get -qq install libavcodec-dev libavformat-dev libavutil-dev libswresample-dev libswscale-dev
libcurl4-gnutls-dev libvlc-dev libvncserver-dev
libdate-manip-perl libdbd-mysql-perl libsys-mmap-perl
libpolkit-gobject-1-dev
- name: Prepare
run: mkdir build
- name: Configure
run: cd build && cmake --version && cmake .. -DBUILD_MAN=0 -DENABLE_WERROR=1
- name: Build
run: cd build && make -j3 | grep --line-buffered -Ev '^(cp lib\/|Installing.+\.pm)' && (exit ${PIPESTATUS[0]})

View File

@ -438,7 +438,7 @@ else()
message(FATAL_ERROR "ZoneMinder requires mysqlclient but it was not found on your system") message(FATAL_ERROR "ZoneMinder requires mysqlclient but it was not found on your system")
endif() endif()
find_package(FFMPEG REQUIRED find_package(FFMPEG 55.34.100 REQUIRED
COMPONENTS COMPONENTS
avcodec avcodec
avformat avformat

View File

@ -1,10 +0,0 @@
zoneminder (1.28.1-1) unstable; urgency=low
This version is no longer automatically initialize or upgrade database.
See README.Debian for details.
Changed installation paths (please correct your web server configuration):
/usr/share/zoneminder --> /usr/share/zoneminder/www
/usr/lib/cgi-bin --> /usr/lib/zoneminder/cgi-bin
-- Dmitry Smirnov <onlyjob@debian.org> Tue, 31 Mar 2015 15:12:17 +1100

View File

@ -1,130 +0,0 @@
Zoneminder for Debian
---------------------
Initializing database
---------------------
pv /usr/share/zoneminder/db/zm_create.sql | sudo mysql --defaults-file=/etc/mysql/debian.cnf
OR
cat /usr/share/zoneminder/db/zm_create.sql | sudo mysql --defaults-file=/etc/mysql/debian.cnf
echo 'grant lock tables,alter,create,index,select,insert,update,delete on zm.* to 'zmuser'@localhost identified by "zmpass";'\
| sudo mysql --defaults-file=/etc/mysql/debian.cnf mysql
Hint: generate secure password with `pwgen` and update "/etc/zm/zm.conf"
accordingly.
The following command can help to ensure that zoneminder can read its
configuration file:
chgrp -c www-data /etc/zm/zm.conf
Upgrading database
------------------
The database is updated automatically on installation. You should not need to take this step.
Assuming that database is on "localhost" then the following command can be
used to upgrade "zm" database:
zmupdate.pl
Additional permissions may be required to perform upgrade:
echo 'grant lock tables, create, alter on zm.* to 'zmuser'@localhost identified by "zmpass";'\
| sudo mysql --defaults-file=/etc/mysql/debian.cnf mysql
The following command prints the current version of zoneminder database:
echo 'select Value from Config where Name = "ZM_DYN_CURR_VERSION";' \
| sudo mysql --defaults-file=/etc/mysql/debian.cnf --skip-column-names zm
Enabling service
----------------
By default Zoneminder service is not automatically started and needs to be
manually enabled once database is configured:
sudo systemctl enable zoneminder.service
Web server set-up
-----------------
There are few manual steps to get the web interface working:
## Apache2
Apache can be configured as folder "/zm" using sample .conf:
sudo a2enconf zoneminder
Alternatively Apache web site configuration template can be used to setup
zoneminder as "http://zoneminder":
sudo cp -v /usr/share/doc/zoneminder/examples/apache.conf /etc/apache2/sites-available/
sudo a2ensite zoneminder.conf
Common configuration steps for Apache2:
sudo a2enmod cgi
sudo service apache2 reload
## nginx / fcgiwrap
Nginx needs "php-fpm" package to support PHP and "fcgiwrap" package
for binary "cgi-bin" applications:
sudo apt-get install php-fpm fcgiwrap
To enable a URL alias that makes Zoneminder available from
http://yourserver/zm
the following line is to be added to "server" section of a web site
configuration:
include /usr/share/doc/zoneminder/examples/nginx.conf;
For "default" web site it would be sufficient to include the above
statement to the file
/etc/nginx/sites-enabled/default
To avoid problems with feeds from multiple cameras "fcgiwrap" should be
configured to start at least as many processes as there are cameras.
It can be done by adjusting DAEMON_OPTS in "/etc/default/fcgiwrap".
Systemd users may be affected by the following bug:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=792705
## Note:
When Zoneminder web site is running it may be necessary to set
Options/Paths/PATH_ZMS to "/zm/cgi-bin/nph-zms" or according to chosen web
site configuration.
Changing the location for images and events
-------------------------------------------
ZoneMinder is now able to be configured to use an alternative location for storing
events and images at compile time. This package makes use of that, so symlinks in
/usr/share/zoneminder/www are no longer necessary.
Access to /dev/video*
---------------------
For cameras which require access to /dev/video*, zoneminder may need the
www-data user added to the video group in order to see those cameras:
adduser www-data video
Note that all web applications running on the zoneminder server will then have
access to all video devices on the system.
-- Vagrant Cascadian <vagrant@debian.org> Sun, 27 Mar 2011 13:06:56 -0700

View File

@ -1,12 +0,0 @@
## Separate substantial /usr/share into its own arch-all package.
## Decide how to handle database updates.
* Consider possibility that database may be on another machine (#469239).
* Consider dbconfig-common? Probably not (what if database is not on localhost?).
### Run `zmupdate.pl` from service control scripts (init.d, service) on start?
Automatic upgrade will break "one DB, many zoneminders" setup (unimportant?).

View File

@ -1,3 +0,0 @@
zoneminder (1.35.6~20200825.27-xenial) xenial; urgency=low
*
-- Isaac Connor <isaac@zoneminder.com> Tue, 25 Aug 2020 09:28:18 -0400

View File

@ -1,3 +0,0 @@
.gitattributes
web/api/.gitattributes
web/api/.gitignore

View File

@ -1 +0,0 @@
9

View File

@ -1,57 +0,0 @@
# Remember to enable cgi mod (i.e. "a2enmod cgi").
ScriptAlias /zm/cgi-bin "/usr/lib/zoneminder/cgi-bin"
<Directory "/usr/lib/zoneminder/cgi-bin">
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
AllowOverride All
Require all granted
</Directory>
# Order matters. This alias must come first.
Alias /zm/cache /var/cache/zoneminder/cache
<Directory /var/cache/zoneminder/cache>
Options -Indexes +FollowSymLinks
AllowOverride None
<IfModule mod_authz_core.c>
# Apache 2.4
Require all granted
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order deny,allow
Allow from all
</IfModule>
</Directory>
Alias /zm /usr/share/zoneminder/www
<Directory /usr/share/zoneminder/www>
Options -Indexes +FollowSymLinks
<IfModule mod_dir.c>
DirectoryIndex index.php
</IfModule>
</Directory>
# For better visibility, the following directives have been migrated from the
# default .htaccess files included with the CakePHP project.
# Parameters not set here are inherited from the parent directive above.
<Directory "/usr/share/zoneminder/www/api">
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
RewriteBase /zm/api
</Directory>
<Directory "/usr/share/zoneminder/www/api/app">
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
RewriteBase /zm/api
</Directory>
<Directory "/usr/share/zoneminder/www/api/app/webroot">
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
RewriteBase /zm/api
</Directory>

View File

@ -1,163 +0,0 @@
Source: zoneminder
Section: net
Priority: optional
Maintainer: Isaac Connor <isaac@zoneminder.com>
Uploaders: Isaac Connor <isaac@zoneminder.com>
Build-Depends: debhelper (>= 9), dh-systemd, python3-sphinx, apache2-dev, dh-linktree, dh-systemd, dh-apache2
,cmake
,libavcodec-dev (>= 6:10~)
,libavformat-dev (>= 6:10~)
,libavutil-dev (>= 6:10~)
,libswresample-dev
,libswscale-dev (>= 6:10~)
,ffmpeg | libav-tools
,net-tools
,libbz2-dev
,libcurl4-gnutls-dev
,libgnutls-openssl-dev
,libjpeg8-dev | libjpeg9-dev | libjpeg62-turbo-dev
,default-libmysqlclient-dev | libmysqlclient-dev | libmariadbclient-dev-compat
,libpcre3-dev
,libpolkit-gobject-1-dev
,libv4l-dev (>= 0.8.3) [!hurd-any]
,libvlc-dev
,libdate-manip-perl
,libdbd-mysql-perl
,libphp-serialization-perl
,libsys-mmap-perl [!hurd-any]
,libwww-perl
,libdata-uuid-perl
,libssl-dev
,libcrypt-eksblowfish-perl
,libdata-entropy-perl
,libvncserver-dev
Standards-Version: 3.9.8
Homepage: http://www.zoneminder.com/
Vcs-Browser: http://anonscm.debian.org/cgit/collab-maint/zoneminder.git
Vcs-Git: git://anonscm.debian.org/collab-maint/zoneminder.git
Package: zoneminder
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends}
,javascript-common
,libswscale-ffmpeg3|libswscale4|libswscale3|libswscale5
,libswresample2|libswresample3|libswresample24|libswresample-ffmpeg1
,ffmpeg | libav-tools
,libdate-manip-perl, libmime-lite-perl, libmime-tools-perl
,libdbd-mysql-perl
,libphp-serialization-perl
,libmodule-load-conditional-perl
,libnet-sftp-foreign-perl
,libarchive-zip-perl
,libdbd-mysql-perl
,libdevice-serialport-perl
,libimage-info-perl
,libjson-maybexs-perl
,libsys-mmap-perl [!hurd-any]
,liburi-encode-perl
,libwww-perl, liburi-perl
,libdata-dump-perl
,libdatetime-perl
,libclass-std-fast-perl
,libsoap-wsdl-perl
,libio-socket-multicast-perl
,libdigest-sha-perl
,libsys-cpu-perl, libsys-meminfo-perl
,libdata-uuid-perl
,libnumber-bytes-human-perl
,libfile-slurp-perl
,mysql-client | mariadb-client | virtual-mysql-client
,perl-modules
,php5-mysql | php-mysql, php5-gd | php-gd , php5-apcu | php-apcu , php-apc | php-apcu-bc, php-json | php5-json
,policykit-1
,rsyslog | system-log-daemon
,zip
,libpcre3
,libssl | libssl1.0.0 | libssl1.1
,libcrypt-eksblowfish-perl
,libdata-entropy-perl
,libvncclient1|libvncclient0
Recommends: ${misc:Recommends}
,libapache2-mod-php5 | libapache2-mod-php | php5-fpm | php-fpm
,mysql-server | mariadb-server | virtual-mysql-server
,zoneminder-doc (>= ${source:Version})
,ffmpeg
Suggests: fcgiwrap, logrotate
Description: video camera security and surveillance solution
ZoneMinder is intended for use in single or multi-camera video security
applications, including commercial or home CCTV, theft prevention and child
or family member or home monitoring and other care scenarios. It
supports capture, analysis, recording, and monitoring of video data coming
from one or more video or network cameras attached to a Linux system.
ZoneMinder also support web and semi-automatic control of Pan/Tilt/Zoom
cameras using a variety of protocols. It is suitable for use as a home
video security system and for commercial or professional video security
and surveillance. It can also be integrated into a home automation system
via X.10 or other protocols.
#Package: libzoneminder-perl
#Section: perl
#Architecture: all
#Multi-Arch: foreign
#Depends: ${misc:Depends}, ${perl:Depends}
# ,libarchive-zip-perl
# ,libdbd-mysql-perl
# ,libdevice-serialport-perl
# ,libimage-info-perl
# ,libjson-maybexs-perl
# ,libsys-mmap-perl [!hurd-any]
# ,liburi-encode-perl
# ,libwww-perl
#Description: ZoneMinder Perl libraries
# ZoneMinder is intended for use in single or multi-camera video security
# applications, including commercial or home CCTV, theft prevention and child
# or family member or home monitoring and other care scenarios. It
# supports capture, analysis, recording, and monitoring of video data coming
# from one or more video or network cameras attached to a Linux system.
# ZoneMinder also support web and semi-automatic control of Pan/Tilt/Zoom
# cameras using a variety of protocols. It is suitable for use as a home
# video security system and for commercial or professional video security
# and surveillance. It can also be integrated into a home automation system
# via X.10 or other protocols.
# .
# This package provides ZoneMinder Perl libraries; it can be used to
# write custom interfaces as well.
Package: zoneminder-doc
Section: doc
Architecture: all
Multi-Arch: foreign
Depends: ${misc:Depends}, ${sphinxdoc:Depends}, python3-sphinx-rtd-theme
Suggests: www-browser
Description: ZoneMinder documentation
ZoneMinder is intended for use in single or multi-camera video security
applications, including commercial or home CCTV, theft prevention and child
or family member or home monitoring and other care scenarios. It
supports capture, analysis, recording, and monitoring of video data coming
from one or more video or network cameras attached to a Linux system.
ZoneMinder also support web and semi-automatic control of Pan/Tilt/Zoom
cameras using a variety of protocols. It is suitable for use as a home
video security system and for commercial or professional video security
and surveillance. It can also be integrated into a home automation system
via X.10 or other protocols.
.
This package provides ZoneMinder documentation in HTML format.
Package: zoneminder-dbg
Section: debug
Priority: extra
Architecture: any
Depends: zoneminder (= ${binary:Version}), ${misc:Depends}
Description: Zoneminder -- debugging symbols
ZoneMinder is intended for use in single or multi-camera video security
applications, including commercial or home CCTV, theft prevention and child
or family member or home monitoring and other care scenarios. It
supports capture, analysis, recording, and monitoring of video data coming
from one or more video or network cameras attached to a Linux system.
ZoneMinder also support web and semi-automatic control of Pan/Tilt/Zoom
cameras using a variety of protocols. It is suitable for use as a home
video security system and for commercial or professional video security
and surveillance. It can also be integrated into a home automation system
via X.10 or other protocols.
.
This package provides debugging symbols

View File

@ -1,167 +0,0 @@
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: ZoneMinder
Upstream-Contact: Philip Coombes <philip.coombes@zoneminder.com>
Source: https://github.com/ZoneMinder/ZoneMinder
Comment:
This package was originally debianized by matrix <matrix@cecilia>
on Mon, 7 Mar 2005 02:07:57 -0500.
It was re-done for submission to the Debian project by Peter Howard
<pjh@northern-ridge.com.au> on Fri, 8 Dec 2006 10:19:43 +1100
Files-Excluded:
web/skins/*/js/jquery-*
Files: *
Copyright: 2001-2014 Philip Coombes <philip.coombes@zoneminder.com>
2008 Brian Rudy <brudyNO@SPAMpraecogito.com>
2014 Vincent Giovannone
2013 Tim Craig <timcraigNO@SPAMsonic.net>
2003-2008 Corey DeLasaux
2001-2010 Chris Kistner
License: GPL-2+
Files: distros/*
Copyright: 2001-2008 Philip Coombes <philip.coombes@zoneminder.com>
2014 Isaac Connor <iconnor@connortechnology.com>
2005 Serg Oskin
License: GPL-2+
Files: web/skins/*/js/jquery-*
Copyright: 2010 John Resig
2010 The Dojo Foundation
License: GPL-2 or Expat
Comment:
Dual licensed under the MIT or GPL Version 2 licenses.
http://jquery.org/license
.
Includes Sizzle.js http://sizzlejs.com/
Released under the MIT, BSD, and GPL Licenses.
Files: web/api/*
Copyright: 2005-2013 Cake Software Foundation, Inc. (http://cakefoundation.org)
License: Expat
Files:
cmake/Modules/FindGLIB2.cmake
cmake/Modules/FindPolkit.cmake
cmake/Modules/GNUInstallDirs.cmake
Copyright:
2005-2011 Kitware, Inc.
2010-2011 Andreas Schneider <asn@cryptomilk.org>
2009 Dario Freddi <drf@kde.org>
2008 Laurent Montel, <montel@kde.org>
2011 Nikita Krupen'ko <krnekit@gmail.com>
License: BSD-3-clause
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
.
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
.
* The names of Kitware, Inc., the Insight Consortium, or the names of
any consortium members, or of any contributors, may not be used to
endorse or promote products derived from this software without
specific prior written permission.
.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Files: cmake/Modules/FindPerlModules.cmake
Copyright: 2012 Iowa State University
License: Boost-1.0
Boost Software License - Version 1.0 - August 17th, 2003
.
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
.
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
Files: debian/*
Copyright: 2015 Dmitry Smirnov <onlyjob@debian.org>
2007-2014 Peter Howard <pjh@northern-ridge.com.au>
2010-2012 Vagrant Cascadian <vagrant@debian.org>
2001-2008 Philip Coombes <philip.coombes@zoneminder.com>
License: GPL-2+
License: Expat
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
License: GPL-2+
This package 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 package 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 package; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
.
The complete text of the GNU General Public License version 2
can be found in "/usr/share/common-licenses/GPL-2".
License: GPL-2
This package 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; version 2 of the License.
.
This package 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 package; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
.
The complete text of the GNU General Public License version 2
can be found in "/usr/share/common-licenses/GPL-2".

View File

@ -1,32 +0,0 @@
location /zm/cgi-bin {
gzip off;
alias /usr/lib/zoneminder/cgi-bin;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
}
location /zm {
# if ($scheme ~ ^http:){
# rewrite ^(.*)$ https://$host$1 permanent;
# }
gzip off;
alias /usr/share/zoneminder/www;
index index.php;
location ~ \.php$ {
if (!-f $request_filename) { return 404; }
expires epoch;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_index index.php;
fastcgi_pass unix:/var/run/php5-fpm.sock;
}
location ~ \.(jpg|jpeg|gif|png|ico)$ {
access_log off;
expires 33d;
}
}

View File

@ -1,7 +0,0 @@
[dch]
id-length = 0
[import-orig]
pristine-tar = False
merge = False

View File

@ -1,2 +0,0 @@
usr/share/man/man3
usr/share/perl5

View File

@ -1,96 +0,0 @@
#!/usr/bin/make -f
# -*- makefile -*-
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_LDFLAGS_MAINT_APPEND += -Wl,--as-needed
ifeq ($(DEB_BUILD_ARCH_OS),hurd)
ARGS:= -DZM_NO_MMAP=ON
endif
%:
dh $@ --parallel --buildsystem=cmake --builddirectory=dbuild \
--with systemd,sphinxdoc,apache2,linktree
override_dh_auto_configure:
dh_auto_configure -- $(ARGS) \
-DCMAKE_VERBOSE_MAKEFILE=ON \
-DCMAKE_BUILD_TYPE=Release \
-DZM_CONFIG_DIR="/etc/zm" \
-DZM_CONFIG_SUBDIR="/etc/zm/conf.d" \
-DZM_RUNDIR="/run/zm" \
-DZM_SOCKDIR="/run/zm" \
-DZM_TMPDIR="/tmp/zm" \
-DZM_CGIDIR="/usr/lib/zoneminder/cgi-bin" \
-DZM_CACHEDIR="/var/cache/zoneminder/cache" \
-DZM_DIR_EVENTS="/var/cache/zoneminder/events" \
-DZM_PATH_SHUTDOWN="/sbin/shutdown" \
-DZM_PATH_ZMS="/zm/cgi-bin/nph-zms"
override_dh_clean:
dh_clean $(MANPAGES1)
$(RM) -r docs/_build
build-indep:
#$(MAKE) -C docs text
$(MAKE) -C docs html
MANPAGES1 = dbuild/scripts/zmupdate.pl.1
$(MANPAGES1):
# generate man page(s):
pod2man -s1 --stderr --utf8 $(patsubst %.1, %, $@) $@
## reproducible build:
LAST_CHANGE=$(shell dpkg-parsechangelog -S Date)
BUILD_DATE=$(shell LC_ALL=C date -u "+%B %d, %Y" -d "$(LAST_CHANGE)")
override_dh_installman: $(MANPAGES1)
$(MAKE) -C docs man SPHINXOPTS="-D today=\"$(BUILD_DATE)\""
dh_installman --language=C $(MANPAGES1)
override_dh_auto_install:
dh_auto_install --destdir=$(CURDIR)/debian/tmp
# remove worthless files:
$(RM) -v $(CURDIR)/debian/tmp/usr/share/perl5/*/*/*/.packlist
$(RM) -v $(CURDIR)/debian/tmp/usr/share/perl5/*/*.in
# remove empty directories:
find $(CURDIR)/debian/tmp/usr -type d -empty -delete -printf 'removed %p\n'
# remove extra-license-file:
$(RM) -v $(CURDIR)/debian/tmp/usr/share/zoneminder/www/api/lib/Cake/LICENSE.txt
override_dh_fixperms:
dh_fixperms
#
# As requested by the Debian Webapps Policy Manual §3.2.1
chown root:www-data $(CURDIR)/debian/zoneminder/etc/zm/zm.conf
chmod 640 $(CURDIR)/debian/zoneminder/etc/zm/zm.conf
override_dh_systemd_start:
dh_systemd_start --no-start
override_dh_systemd_enable:
dh_systemd_enable --no-enable
override_dh_apache2:
dh_apache2 --noenable
override_dh_strip:
[ -d "$(CURDIR)/debian/zoneminder-dbg" ] \
&& dh_strip --dbg-package=zoneminder-dbg \
|| dh_strip
#%:
# dh $@ --parallel --buildsystem=autoconf --with autoreconf
#
#override_dh_auto_configure:
# dh_auto_configure -- \
# --sysconfdir=/etc/zm \
# --with-mysql=/usr \
# --with-webdir=/usr/share/zoneminder \
# --with-ffmpeg=/usr \
# --with-cgidir=/usr/lib/cgi-bin \
# --with-webuser=www-data \
# --with-webgroup=www-data \
# --enable-mmap=yes

View File

@ -1 +0,0 @@
3.0 (quilt)

View File

@ -1,5 +0,0 @@
## We're using "libjs-jquery" instead.
source-is-missing web/skins/*/js/jquery-3.5.1.min.js
## Acknowledged, will repack eventually.
source-contains-prebuilt-javascript-object web/skins/*/js/jquery-3.5.1.min.js

View File

@ -1,8 +0,0 @@
Document: zoneminder-doc
Title: Zoneminder documentation
Abstract: This document describes how to use Zoneminder.
Section: System/Administration
Format: HTML
Index: /usr/share/doc/zoneminder-doc/html/index.html
Files: /usr/share/doc/zoneminder-doc/html/*

View File

@ -1 +0,0 @@
docs/_build/html usr/share/doc/zoneminder-doc/

View File

@ -1,2 +0,0 @@
## Convenience symlink:
/usr/share/doc/zoneminder-doc/html /usr/share/doc/zoneminder/html

View File

@ -1 +0,0 @@
conf debian/conf/apache2/zoneminder.conf nginx

View File

@ -1,5 +0,0 @@
Unless bug is specific to Debian please consider reporting it directly to
upstream developer(s):
https://github.com/ZoneMinder/ZoneMinder/issues

View File

@ -1,10 +0,0 @@
var/log/zm
var/lib/zm
var/cache/zoneminder/events
var/cache/zoneminder/images
var/cache/zoneminder/temp
var/cache/zoneminder/cache
usr/share/zoneminder/db
usr/share/zoneminder/fonts
etc/zm/
etc/zm/conf.d

View File

@ -1 +0,0 @@
README.md

View File

@ -1,2 +0,0 @@
debian/examples/*
dbuild/misc/apache.conf

View File

@ -1,12 +0,0 @@
etc/zm/zm.conf
etc/zm/conf.d/*
usr/bin
usr/lib/zoneminder
usr/share/polkit-1
usr/share/zoneminder/db
usr/share/zoneminder/www
usr/share/zoneminder/fonts
# libzoneminder-perl files:
usr/share/man/man3
usr/share/perl5

View File

@ -1 +0,0 @@
/var/tmp /usr/share/zoneminder/www/api/app/tmp

View File

@ -1,6 +0,0 @@
## cakephp
#replace /usr/share/php/Cake /usr/share/zoneminder/www/api/lib/Cake
## libjs-jquery
#replace /usr/share/javascript/jquery/jquery.min.js /usr/share/zoneminder/www/skins/classic/js/jquery-3.5.1.min.js
#replace /usr/share/javascript/jquery/jquery.min.js /usr/share/zoneminder/www/skins/flat/js/jquery-3.5.1.min.js

View File

@ -1,14 +0,0 @@
# Depends: policykit-1
unusual-interpreter usr/bin/zmsystemctl.pl #!/usr/bin/pkexec
# Intentionally not others-readable, #637685.
non-standard-file-perm etc/zm/zm.conf 0640 != 0644
# Bundled Cake PHP framework, not intended for direct execution:
script-not-executable usr/share/zoneminder/www/api/*
# Annoying but seems to be too much troubles to fix; should be fixed upstream:
script-with-language-extension usr/bin/*.pl
# dh-linktree:
package-contains-broken-symlink usr/share/zoneminder/www/api/lib/Cake/*

View File

@ -1,13 +0,0 @@
/var/log/zm/*.log {
missingok
notifempty
sharedscripts
delaycompress
compress
postrotate
/usr/bin/zmpkg.pl logrot >>/dev/null 2>&1 || :
endscript
daily
rotate 7
maxage 7
}

View File

@ -1 +0,0 @@
rm_conffile /etc/zm/apache.conf 1.28.1-5~

View File

@ -1 +0,0 @@
docs/_build/man/*.1

View File

@ -1,101 +0,0 @@
#! /bin/sh
set +e
if [ "$1" = "configure" ]; then
. /etc/zm/zm.conf
for CONFFILE in /etc/zm/conf.d/*.conf; do
. "$CONFFILE"
done
# The logs can contain passwords, etc... so by setting group root, only www-data can read them, not people in the www-data group
chown www-data:root /var/log/zm
chown www-data:www-data /var/lib/zm
chown www-data:www-data /var/cache/zoneminder /var/cache/zoneminder/*
if [ ! -e "/etc/apache2/mods-enabled/cgi.load" ] && [ "$(command -v a2enmod)" != "" ]; then
echo "The cgi module is not enabled in apache2. I am enabling it using a2enmod cgi."
a2enmod cgi
fi
if [ ! -e "/etc/apache2/mods-enabled/rewrite.load" ] && [ "$(command -v a2enmod)" != "" ]; then
echo "The rewrite module is not enabled in apache2. I am enabling it using a2enmod rewrite."
a2enmod rewrite
fi
if [ "$ZM_DB_HOST" = "localhost" ]; then
if [ -e "/lib/systemd/system/mysql.service" ] || [ -e "/lib/systemd/system/mariadb.service" ] || [ -e "/etc/init.d/mysql" ]; then
# Ensure zoneminder is stopped
deb-systemd-invoke stop zoneminder.service || exit $?
#
# Get mysql started if it isn't running
#
if [ -e "/lib/systemd/system/mariadb.service" ]; then
DBSERVICE="mariadb.service"
else
DBSERVICE="mysql.service"
fi
echo "Detected db service is $DBSERVICE"
if systemctl is-failed --quiet $DBSERVICE; then
echo "$DBSERVICE is in a failed state; it will not be started."
echo "If you have already resolved the problem preventing $DBSERVICE from running,"
echo "run sudo systemctl restart $DBSERVICE then run sudo dpkg-reconfigure zoneminder."
exit 1
fi
if ! systemctl is-active --quiet mysql.service mariadb.service; then
# Due to /etc/init.d service autogeneration, mysql.service always returns the status of mariadb.service
# However, mariadb.service will not return the status of mysql.service.
deb-systemd-invoke start $DBSERVICE
fi
# Make sure systemctl status exit code is 0; i.e. the DB is running
if systemctl is-active --quiet "$DBSERVICE"; then
mysqladmin --defaults-file=/etc/mysql/debian.cnf -f reload
# test if database if already present...
if ! $(echo quit | mysql --defaults-file=/etc/mysql/debian.cnf zm > /dev/null 2> /dev/null) ; then
echo "Creating zm db"
cat /usr/share/zoneminder/db/zm_create.sql | mysql --defaults-file=/etc/mysql/debian.cnf
if [ $? -ne 0 ]; then
echo "Error creating db."
exit 1;
fi
# This creates the user.
echo "CREATE USER '${ZM_DB_USER}'@localhost IDENTIFIED BY '${ZM_DB_PASS}';" | mysql --defaults-file=/etc/mysql/debian.cnf mysql
fi
echo "Updating permissions for user ${ZM_DB_USER}@localhost"
echo "GRANT LOCK TABLES,ALTER,DROP,SELECT,INSERT,UPDATE,DELETE,CREATE,INDEX,ALTER ROUTINE,CREATE ROUTINE, TRIGGER,EXECUTE,REFERENCES ON ${ZM_DB_NAME}.* TO '${ZM_DB_USER}'@localhost;" | mysql --defaults-file=/etc/mysql/debian.cnf mysql
zmupdate.pl -s --nointeractive
if [ $? -ne 0 ]; then
echo "Error updating db."
exit 1;
fi
zmupdate.pl --nointeractive -f
if [ $? -ne 0 ]; then
echo "Error updating config."
exit 1;
fi
# Add any new PTZ control configurations to the database (will not overwrite)
zmcamtool.pl --import >/dev/null 2>&1
echo "Done Updating; starting ZoneMinder."
else
echo 'NOTE: MySQL/MariaDB not running; please start mysql and run dpkg-reconfigure zoneminder when it is running.'
fi
else
echo 'MySQL/MariaDB not found; assuming remote server.'
fi
else
echo "Not doing database upgrade due to remote db server ($ZM_DB_HOST)."
fi
echo "Done Updating; starting ZoneMinder."
deb-systemd-invoke restart zoneminder.service
fi
#DEBHELPER#

View File

@ -1,14 +0,0 @@
#! /bin/sh
set -e
if [ "$1" = "purge" ]; then
echo "
Reminder: to completely remove \"zoneminder\" it may be necessary
* to delete database using the following sample command:
sudo mysqladmin --defaults-file=/etc/mysql/debian.cnf -f drop zm
* to delete remaining data files in "/var/cache/zoneminder".
"
fi
#DEBHELPER#

View File

@ -1,11 +0,0 @@
#!/bin/sh
set -e
## Remove obsolete symlink which is in the way of dh_apache2:
ol="/etc/apache2/conf-available/zoneminder.conf"
if [ -h "${ol}" ]; then
[ "$(readlink ${ol})" = "/etc/zm/apache.conf" ] && rm -f "${ol}"
fi
#DEBHELPER#

View File

@ -1,23 +0,0 @@
# ZoneMinder systemd unit file
# This file is intended to work with Debian distributions
[Unit]
Description=ZoneMinder CCTV recording and surveillance system
After=network.target mysql.service
# Remarked out so that it will start ZM on machines that don't have mysql installed
#Requires=mysql.service
[Service]
#User=www-data
Type=forking
ExecStart=/usr/bin/zmpkg.pl start
ExecReload=/usr/bin/zmpkg.pl restart
ExecStop=/usr/bin/zmpkg.pl stop
PIDFile=/run/zm/zm.pid
Restart=always
RestartSec=10
Environment=TZ=:/etc/localtime
TimeoutSec=600
[Install]
WantedBy=multi-user.target

View File

@ -1,4 +0,0 @@
d /run/zm 0755 www-data www-data
d /tmp/zm 0755 www-data www-data
d /var/tmp/zm 0755 www-data www-data
d /var/cache/zoneminder/cache 0755 www-data www-data

View File

@ -85,7 +85,7 @@ Where <distroname> is the name of the distro you wish to build on, such as fedor
:: ::
OS=ubuntu DIST=xenial utils/packpack/startpackpack.sh OS=ubuntu DIST=hirsute utils/packpack/startpackpack.sh
Once you enter the appropriate command, go get a coffee while a ZoneMinder package is built. When the build finished, you can find the resulting packages under a subfolder called "build". Once you enter the appropriate command, go get a coffee while a ZoneMinder package is built. When the build finished, you can find the resulting packages under a subfolder called "build".
@ -93,13 +93,13 @@ Note that this will build packages with x86_64 architecture. This build method c
:: ::
OS=ubuntu DIST=xenial ARCH=i386 utils/packpack/startpackpack.sh OS=ubuntu DIST=hirsute ARCH=i386 utils/packpack/startpackpack.sh
For advanced users who really want to go out into uncharted waters, it is theoretically possible to build arm packages as well, as long as the host architecture is compatible. For advanced users who really want to go out into uncharted waters, it is theoretically possible to build arm packages as well, as long as the host architecture is compatible.
:: ::
OS=ubuntu DIST=xenial ARCH=armhfp utils/packpack/startpackpack.sh OS=ubuntu DIST=hirsute ARCH=armhfp utils/packpack/startpackpack.sh
Building arm packages in this manner has not been tested by us, however. Building arm packages in this manner has not been tested by us, however.

View File

@ -176,175 +176,6 @@ CTRL+x to exit
PPA install may need some tweaking of ZMS_PATH in ZoneMinder options. `Socket_sendto or no live streaming`_ PPA install may need some tweaking of ZMS_PATH in ZoneMinder options. `Socket_sendto or no live streaming`_
Easy Way: Ubuntu 16.04 (Xenial)
-------------------------------
These instructions are for a brand new ubuntu 16.04 system which does not have ZM
installed.
It is recommended that you use an Ubuntu Server install and select the LAMP option
during install to install Apache, MySQL and PHP. If you failed to do this you can
achieve the same result by running:
::
sudo tasksel install lamp-server
During installation it will ask you to set up a master/root password for the MySQL.
Installing LAMP is not ZoneMinder specific so you will find plenty of resources to
guide you with a quick search.
**Step 1:** Either run commands in this install using sudo or use the below to become root
::
sudo -i
**Step 2:** Update Repos
.. topic :: Latest Release
ZoneMinder is now part of the current standard Ubuntu repository, but
sometimes the official repository can lag behind. To find out check our
`releases page <https://github.com/ZoneMinder/zoneminder/releases>`_ for
the latest release.
Alternatively, the ZoneMinder project team maintains a `PPA <https://askubuntu.com/questions/4983/what-are-ppas-and-how-do-i-use-them>`_, which is updated immediately
following a new release of ZoneMinder. To use this repository instead of the
official Ubuntu repository, enter the following from the command line:
::
add-apt-repository ppa:iconnor/zoneminder
add-apt-repository ppa:iconnor/zoneminder-1.32
Update repo and upgrade.
::
apt-get update
apt-get upgrade
apt-get dist-upgrade
**Step 3:** Configure MySQL
.. sidebar :: Note
The MySQL default configuration file (/etc/mysql/mysql.cnf)is read through
several symbolic links beginning with /etc/mysql/my.cnf as follows:
| /etc/mysql/my.cnf -> /etc/alternatives/my.cnf
| /etc/alternatives/my.cnf -> /etc/mysql/mysql.cnf
| /etc/mysql/mysql.cnf is a basic file
Certain new defaults in MySQL 5.7 cause some issues with ZoneMinder < 1.32.0,
the workaround is to modify the sql_mode setting of MySQL. Please note that these
changes are NOT required for ZoneMinder 1.32.0 and some people have reported them
causing problems in 1.32.0.
To better manage the MySQL server it is recommended to copy the sample config file and
replace the default my.cnf symbolic link.
::
rm /etc/mysql/my.cnf (this removes the current symbolic link)
cp /etc/mysql/mysql.conf.d/mysqld.cnf /etc/mysql/my.cnf
To change MySQL settings:
::
nano /etc/mysql/my.cnf
In the [mysqld] section add the following
::
sql_mode = NO_ENGINE_SUBSTITUTION
CTRL+o then [Enter] to save
CTRL+x to exit
Restart MySQL
::
systemctl restart mysql
**Step 4:** Install ZoneMinder
::
apt-get install zoneminder
**Step 5:** Configure the ZoneMinder Database
This step should not be required on ZoneMinder 1.32.0.
::
mysql -uroot -p < /usr/share/zoneminder/db/zm_create.sql
mysql -uroot -p -e "grant lock tables,alter,drop,select,insert,update,delete,create,index,alter routine,create routine, trigger,execute on zm.* to 'zmuser'@localhost identified by 'zmpass';"
**Step 6:** Set permissions
Set /etc/zm/zm.conf to root:www-data 740 and www-data access to content
::
chmod 740 /etc/zm/zm.conf
chown root:www-data /etc/zm/zm.conf
chown -R www-data:www-data /usr/share/zoneminder/
**Step 7:** Configure Apache correctly:
::
a2enmod cgi
a2enmod rewrite
a2enconf zoneminder
You may also want to enable to following modules to improve caching performance
::
a2enmod expires
a2enmod headers
**Step 8:** Enable and start Zoneminder
::
systemctl enable zoneminder
systemctl start zoneminder
**Step 10:** Reload Apache service
::
systemctl reload apache2
**Step 11:** Making sure ZoneMinder works
1. Open up a browser and go to ``http://hostname_or_ip/zm`` - should bring up ZoneMinder Console
2. (Optional API Check)Open up a tab in the same browser and go to ``http://hostname_or_ip/zm/api/host/getVersion.json``
If it is working correctly you should get version information similar to the example below:
::
{
"version": "1.34.0",
"apiversion": "1.34.0.1"
}
**Congratulations** Your installation is complete
PPA install may need some tweaking of ZMS_PATH in ZoneMinder options. `Socket_sendto or no live streaming`_
Harder Way: Build Package From Source Harder Way: Build Package From Source
------------------------------------- -------------------------------------
@ -382,7 +213,7 @@ To build the latest stable release:
Note that the distribution will be guessed using ``lsb_release -a 2>/dev/null | grep Codename | awk '{print $2}'`` Note that the distribution will be guessed using ``lsb_release -a 2>/dev/null | grep Codename | awk '{print $2}'``
which simply extracts your distribution name - like "xenial", "bionic" etc. You which simply extracts your distribution name - like "bionic", "hirsute" etc. You
can always specify it using --distro=your distro name if you know it. As far as the script can always specify it using --distro=your distro name if you know it. As far as the script
goes, it checks if your distro is "trusty" in which case it pulls in pre-systemd goes, it checks if your distro is "trusty" in which case it pulls in pre-systemd
release configurations and if its not "trusty" it assumes its based on systemd release configurations and if its not "trusty" it assumes its based on systemd

View File

@ -90,20 +90,12 @@ AVStream *Camera::getVideoStream() {
mVideoStream = avformat_new_stream(mFormatContext, nullptr); mVideoStream = avformat_new_stream(mFormatContext, nullptr);
if ( mVideoStream ) { if ( mVideoStream ) {
mVideoStream->time_base = (AVRational){1, 1000000}; // microseconds as base frame rate mVideoStream->time_base = (AVRational){1, 1000000}; // microseconds as base frame rate
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
mVideoStream->codecpar->width = width; mVideoStream->codecpar->width = width;
mVideoStream->codecpar->height = height; mVideoStream->codecpar->height = height;
mVideoStream->codecpar->format = GetFFMPEGPixelFormat(colours, subpixelorder); mVideoStream->codecpar->format = GetFFMPEGPixelFormat(colours, subpixelorder);
mVideoStream->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; mVideoStream->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
mVideoStream->codecpar->codec_id = AV_CODEC_ID_NONE; mVideoStream->codecpar->codec_id = AV_CODEC_ID_NONE;
Debug(1, "Allocating avstream %p %p %d", mVideoStream, mVideoStream->codecpar, mVideoStream->codecpar->codec_id); Debug(1, "Allocating avstream %p %p %d", mVideoStream, mVideoStream->codecpar, mVideoStream->codecpar->codec_id);
#else
mVideoStream->codec->width = width;
mVideoStream->codec->height = height;
mVideoStream->codec->pix_fmt = GetFFMPEGPixelFormat(colours, subpixelorder);
mVideoStream->codec->codec_type = AVMEDIA_TYPE_VIDEO;
mVideoStream->codec->codec_id = AV_CODEC_ID_NONE;
#endif
} else { } else {
Error("Can't create video stream"); Error("Can't create video stream");
} }

View File

@ -99,20 +99,8 @@ public:
unsigned int Pixels() const { return pixels; } unsigned int Pixels() const { return pixels; }
unsigned long long ImageSize() const { return imagesize; } unsigned long long ImageSize() const { return imagesize; }
unsigned int Bytes() const { return bytes; }; unsigned int Bytes() const { return bytes; };
int getFrequency() { int getFrequency() { return mAudioStream ? mAudioStream->codecpar->sample_rate : -1; }
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0) int getChannels() { return mAudioStream ? mAudioStream->codecpar->channels : -1; }
return mAudioStream ? mAudioStream->codecpar->sample_rate : -1;
#else
return mAudioStream ? mAudioStream->codec->sample_rate : -1;
#endif
}
int getChannels() {
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
return mAudioStream ? mAudioStream->codecpar->channels : -1;
#else
return mAudioStream ? mAudioStream->codec->channels : -1;
#endif
}
virtual int Brightness( int/*p_brightness*/=-1 ) { return -1; } virtual int Brightness( int/*p_brightness*/=-1 ) { return -1; }
virtual int Hue( int/*p_hue*/=-1 ) { return -1; } virtual int Hue( int/*p_hue*/=-1 ) { return -1; }

View File

@ -139,55 +139,6 @@ enum _AVPIXELFORMAT GetFFMPEGPixelFormat(unsigned int p_colours, unsigned p_subp
return pf; return pf;
} }
/* The following is copied directly from newer ffmpeg. */
#if LIBAVUTIL_VERSION_CHECK(52, 7, 0, 17, 100)
#else
static int parse_key_value_pair(AVDictionary **pm, const char **buf,
const char *key_val_sep, const char *pairs_sep,
int flags)
{
char *key = av_get_token(buf, key_val_sep);
char *val = nullptr;
int ret;
if (key && *key && strspn(*buf, key_val_sep)) {
(*buf)++;
val = av_get_token(buf, pairs_sep);
}
if (key && *key && val && *val)
ret = av_dict_set(pm, key, val, flags);
else
ret = AVERROR(EINVAL);
av_freep(&key);
av_freep(&val);
return ret;
}
int av_dict_parse_string(AVDictionary **pm, const char *str,
const char *key_val_sep, const char *pairs_sep,
int flags) {
if (!str)
return 0;
/* ignore STRDUP flags */
flags &= ~(AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL);
while (*str) {
int ret;
if ( (ret = parse_key_value_pair(pm, &str, key_val_sep, pairs_sep, flags)) < 0)
return ret;
if (*str)
str++;
}
return 0;
}
#endif
#if LIBAVUTIL_VERSION_CHECK(56, 0, 0, 17, 100) #if LIBAVUTIL_VERSION_CHECK(56, 0, 0, 17, 100)
int64_t av_rescale_delta(AVRational in_tb, int64_t in_ts, AVRational fs_tb, int duration, int64_t *last, AVRational out_tb){ int64_t av_rescale_delta(AVRational in_tb, int64_t in_ts, AVRational fs_tb, int duration, int64_t *last, AVRational out_tb){
@ -227,7 +178,6 @@ static void zm_log_fps(double d, const char *postfix) {
} }
} }
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
void zm_dump_codecpar(const AVCodecParameters *par) { void zm_dump_codecpar(const AVCodecParameters *par) {
Debug(1, "Dumping codecpar codec_type %d %s codec_id %d %s codec_tag %" PRIu32 Debug(1, "Dumping codecpar codec_type %d %s codec_id %d %s codec_tag %" PRIu32
" width %d height %d bit_rate%" PRIu64 " bpcs %d bprs %d format%d %s" " width %d height %d bit_rate%" PRIu64 " bpcs %d bprs %d format%d %s"
@ -260,7 +210,6 @@ void zm_dump_codecpar(const AVCodecParameters *par) {
static_cast<int>(par->video_delay) static_cast<int>(par->video_delay)
); );
} }
#endif
void zm_dump_codec(const AVCodecContext *codec) { void zm_dump_codec(const AVCodecContext *codec) {
Debug(1, "Dumping codec_context codec_type %d %s codec_id %d %s width %d height %d timebase %d/%d format %s profile %d level %d " Debug(1, "Dumping codec_context codec_type %d %s codec_id %d %s width %d height %d timebase %d/%d format %s profile %d level %d "
@ -273,11 +222,7 @@ void zm_dump_codec(const AVCodecContext *codec) {
codec->height, codec->height,
codec->time_base.num, codec->time_base.num,
codec->time_base.den, codec->time_base.den,
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
(codec->pix_fmt == AV_PIX_FMT_NONE ? "none" : av_get_pix_fmt_name(codec->pix_fmt)), (codec->pix_fmt == AV_PIX_FMT_NONE ? "none" : av_get_pix_fmt_name(codec->pix_fmt)),
#else
"unsupported on avconv",
#endif
codec->profile, codec->profile,
codec->level, codec->level,
codec->gop_size, codec->gop_size,
@ -302,11 +247,7 @@ void zm_dump_stream_format(AVFormatContext *ic, int i, int index, int is_output)
int flags = (is_output ? ic->oformat->flags : ic->iformat->flags); int flags = (is_output ? ic->oformat->flags : ic->iformat->flags);
AVStream *st = ic->streams[i]; AVStream *st = ic->streams[i];
AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", nullptr, 0); AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", nullptr, 0);
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
AVCodecParameters *codec = st->codecpar; AVCodecParameters *codec = st->codecpar;
#else
AVCodecContext *codec = st->codec;
#endif
Debug(1, " Stream #%d:%d", index, i); Debug(1, " Stream #%d:%d", index, i);
@ -321,16 +262,10 @@ void zm_dump_stream_format(AVFormatContext *ic, int i, int index, int is_output)
st->time_base.num, st->time_base.den st->time_base.num, st->time_base.den
); );
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
Debug(1, "codec: %s %s", Debug(1, "codec: %s %s",
avcodec_get_name(st->codecpar->codec_id), avcodec_get_name(st->codecpar->codec_id),
av_get_media_type_string(st->codecpar->codec_type) av_get_media_type_string(st->codecpar->codec_type)
); );
#else
char buf[256];
avcodec_string(buf, sizeof(buf), st->codec, is_output);
Debug(1, "codec: %s", buf);
#endif
if (st->sample_aspect_ratio.num && // default if (st->sample_aspect_ratio.num && // default
av_cmp_q(st->sample_aspect_ratio, codec->sample_aspect_ratio) av_cmp_q(st->sample_aspect_ratio, codec->sample_aspect_ratio)
@ -419,127 +354,37 @@ enum AVPixelFormat fix_deprecated_pix_fmt(enum AVPixelFormat fmt) {
} }
} }
#if LIBAVCODEC_VERSION_CHECK(56, 8, 0, 60, 100)
#else
unsigned int zm_av_packet_ref(AVPacket *dst, AVPacket *src) {
av_new_packet(dst,src->size);
memcpy(dst->data, src->data, src->size);
dst->flags = src->flags;
dst->pts = src->pts;
dst->dts = src->dts;
dst->duration = src->duration;
dst->stream_index = src->stream_index;
return 0;
}
const char *avcodec_get_name(enum AVCodecID id) {
const AVCodecDescriptor *cd;
if ( id == AV_CODEC_ID_NONE)
return "none";
cd = avcodec_descriptor_get(id);
if (cd)
return cd->name;
AVCodec *codec;
codec = avcodec_find_decoder(id);
if (codec)
return codec->name;
codec = avcodec_find_encoder(id);
if (codec)
return codec->name;
return "unknown codec";
}
void av_packet_rescale_ts(
AVPacket *pkt,
AVRational src_tb,
AVRational dst_tb
) {
if ( pkt->pts != AV_NOPTS_VALUE)
pkt->pts = av_rescale_q(pkt->pts, src_tb, dst_tb);
if ( pkt->dts != AV_NOPTS_VALUE)
pkt->dts = av_rescale_q(pkt->dts, src_tb, dst_tb);
if ( pkt->duration != AV_NOPTS_VALUE)
pkt->duration = av_rescale_q(pkt->duration, src_tb, dst_tb);
}
#endif
bool is_video_stream(const AVStream * stream) { bool is_video_stream(const AVStream * stream) {
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0) if (stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
if (stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
#else
#if (LIBAVCODEC_VERSION_CHECK(52, 64, 0, 64, 0) || LIBAVUTIL_VERSION_CHECK(50, 14, 0, 14, 0))
if (stream->codec->codec_type == AVMEDIA_TYPE_VIDEO)
#else
if (stream->codec->codec_type == CODEC_TYPE_VIDEO)
#endif
#endif
{
return true; return true;
} }
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
Debug(2, "Not a video type %d != %d", stream->codecpar->codec_type, AVMEDIA_TYPE_VIDEO);
#endif
Debug(2, "Not a video type %d != %d", stream->codecpar->codec_type, AVMEDIA_TYPE_VIDEO);
return false; return false;
} }
bool is_video_context(const AVCodecContext *codec_context) { bool is_video_context(const AVCodecContext *codec_context) {
return return codec_context->codec_type == AVMEDIA_TYPE_VIDEO;
#if (LIBAVCODEC_VERSION_CHECK(52, 64, 0, 64, 0) || LIBAVUTIL_VERSION_CHECK(50, 14, 0, 14, 0))
(codec_context->codec_type == AVMEDIA_TYPE_VIDEO);
#else
(codec_context->codec_type == CODEC_TYPE_VIDEO);
#endif
} }
bool is_audio_stream(const AVStream * stream) { bool is_audio_stream(const AVStream *stream) {
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0) return stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO;
if (stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
#else
#if (LIBAVCODEC_VERSION_CHECK(52, 64, 0, 64, 0) || LIBAVUTIL_VERSION_CHECK(50, 14, 0, 14, 0))
if (stream->codec->codec_type == AVMEDIA_TYPE_AUDIO)
#else
if (stream->codec->codec_type == CODEC_TYPE_AUDIO)
#endif
#endif
{
return true;
}
return false;
} }
bool is_audio_context(const AVCodecContext *codec_context) { bool is_audio_context(const AVCodecContext *codec_context) {
return return codec_context->codec_type == AVMEDIA_TYPE_AUDIO;
#if (LIBAVCODEC_VERSION_CHECK(52, 64, 0, 64, 0) || LIBAVUTIL_VERSION_CHECK(50, 14, 0, 14, 0))
(codec_context->codec_type == AVMEDIA_TYPE_AUDIO);
#else
(codec_context->codec_type == CODEC_TYPE_AUDIO);
#endif
} }
int zm_receive_packet(AVCodecContext *context, AVPacket &packet) { int zm_receive_packet(AVCodecContext *context, AVPacket &packet) {
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
int ret = avcodec_receive_packet(context, &packet); int ret = avcodec_receive_packet(context, &packet);
if ((ret < 0) and (AVERROR_EOF != ret)) { if ((ret < 0) and (AVERROR_EOF != ret)) {
Error("Error encoding (%d) (%s)", ret, av_err2str(ret)); Error("Error encoding (%d) (%s)", ret, av_err2str(ret));
} }
return ret; // 1 or 0 return ret; // 1 or 0
#else
int got_packet = 0;
int ret = avcodec_encode_audio2(context, &packet, nullptr, &got_packet);
if (ret < 0) {
Error("Error encoding (%d) (%s)", ret, av_err2str(ret));
return ret;
}
return got_packet; // 1
#endif
} // end int zm_receive_packet(AVCodecContext *context, AVPacket &packet) } // end int zm_receive_packet(AVCodecContext *context, AVPacket &packet)
int zm_send_packet_receive_frame( int zm_send_packet_receive_frame(AVCodecContext *context, AVFrame *frame, AVPacket &packet) {
AVCodecContext *context,
AVFrame *frame,
AVPacket &packet) {
int ret; int ret;
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
if ((ret = avcodec_send_packet(context, &packet)) < 0) { if ((ret = avcodec_send_packet(context, &packet)) < 0) {
Error("Unable to send packet %s, continuing", Error("Unable to send packet %s, continuing",
av_make_error_string(ret).c_str()); av_make_error_string(ret).c_str());
@ -558,74 +403,41 @@ int zm_send_packet_receive_frame(
} }
// In this api the packet is always consumed, so return packet.bytes // In this api the packet is always consumed, so return packet.bytes
return packet.size; return packet.size;
# else
int frameComplete = 0;
if (is_video_context(context)) {
ret = zm_avcodec_decode_video(context, frame, &frameComplete, &packet);
Debug(2, "ret from decode_video %d, framecomplete %d", ret, frameComplete);
} else {
ret = avcodec_decode_audio4(context, frame, &frameComplete, &packet);
Debug(2, "ret from decode_audio %d, framecomplete %d", ret, frameComplete);
}
if (ret < 0) {
Error("Unable to decode frame: %s", av_make_error_string(ret).c_str());
return ret;
}
return frameComplete ? ret : 0;
#endif
} // end int zm_send_packet_receive_frame(AVCodecContext *context, AVFrame *frame, AVPacket &packet) } // end int zm_send_packet_receive_frame(AVCodecContext *context, AVFrame *frame, AVPacket &packet)
/* Returns < 0 on error, 0 if codec not ready, 1 on success /* Returns < 0 on error, 0 if codec not ready, 1 on success
*/ */
int zm_send_frame_receive_packet(AVCodecContext *ctx, AVFrame *frame, AVPacket &packet) { int zm_send_frame_receive_packet(AVCodecContext *ctx, AVFrame *frame, AVPacket &packet) {
int ret; int ret;
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0) if (((ret = avcodec_send_frame(ctx, frame)) < 0) and frame) {
if (( (ret = avcodec_send_frame(ctx, frame)) < 0 ) and frame) { Error("Could not send frame (error '%s')",
Error("Could not send frame (error '%s')", av_make_error_string(ret).c_str());
av_make_error_string(ret).c_str()); return ret;
return ret; }
}
if ((ret = avcodec_receive_packet(ctx, &packet)) < 0) { if ((ret = avcodec_receive_packet(ctx, &packet)) < 0) {
if (AVERROR(EAGAIN) == ret) { if (AVERROR(EAGAIN) == ret) {
// The codec may need more samples than it has, perfectly valid // The codec may need more samples than it has, perfectly valid
Debug(2, "Codec not ready to give us a packet"); Debug(2, "Codec not ready to give us a packet");
return 0;
} else if (frame) {
// May get EOF if frame is NULL because it signals flushing
Error("Could not recieve packet (error %d = '%s')", ret,
av_make_error_string(ret).c_str());
}
zm_av_packet_unref(&packet);
return ret;
}
#else
int data_present;
if ((ret = avcodec_encode_audio2(
ctx, &packet, frame, &data_present)) < 0) {
Error("Could not encode frame (error '%s')",
av_make_error_string(ret).c_str());
zm_av_packet_unref(&packet);
return ret;
}
if (!data_present) {
Debug(2, "Not ready to out a frame yet.");
zm_av_packet_unref(&packet);
return 0; return 0;
} else if (frame) {
// May get EOF if frame is NULL because it signals flushing
Error("Could not recieve packet (error %d = '%s')", ret,
av_make_error_string(ret).c_str());
} }
#endif zm_av_packet_unref(&packet);
return ret;
}
return 1; return 1;
} // end int zm_send_frame_receive_packet } // end int zm_send_frame_receive_packet
void zm_free_codec(AVCodecContext **ctx) { void zm_free_codec(AVCodecContext **ctx) {
if (*ctx) { if (*ctx) {
avcodec_close(*ctx); avcodec_close(*ctx);
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
// We allocate and copy in newer ffmpeg, so need to free it // We allocate and copy in newer ffmpeg, so need to free it
avcodec_free_context(ctx); avcodec_free_context(ctx);
#endif *ctx = nullptr;
*ctx = NULL; }
} // end if
} }
void zm_packet_copy_rescale_ts(const AVPacket *ipkt, AVPacket *opkt, const AVRational src_tb, const AVRational dst_tb) { void zm_packet_copy_rescale_ts(const AVPacket *ipkt, AVPacket *opkt, const AVRational src_tb, const AVRational dst_tb) {

View File

@ -34,6 +34,7 @@ extern "C" {
#include <libavutil/avstring.h> #include <libavutil/avstring.h>
#include <libavutil/audio_fifo.h> #include <libavutil/audio_fifo.h>
#include <libavutil/imgutils.h> #include <libavutil/imgutils.h>
#include <libavutil/opt.h>
#if HAVE_LIBAVUTIL_HWCONTEXT_H #if HAVE_LIBAVUTIL_HWCONTEXT_H
#include <libavutil/hwcontext.h> #include <libavutil/hwcontext.h>
#endif #endif
@ -47,64 +48,7 @@ extern "C" {
( (LIBAVUTIL_VERSION_MICRO < 100 && LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(a, b, c) ) || \ ( (LIBAVUTIL_VERSION_MICRO < 100 && LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(a, b, c) ) || \
(LIBAVUTIL_VERSION_MICRO >= 100 && LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(a, d, e) ) ) (LIBAVUTIL_VERSION_MICRO >= 100 && LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(a, d, e) ) )
#if LIBAVUTIL_VERSION_CHECK(50, 29, 0, 29, 0) #define _AVPIXELFORMAT AVPixelFormat
#include <libavutil/opt.h>
#else
#include <libavcodec/opt.h>
#endif
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
#include <libavutil/imgutils.h>
#endif
#if LIBAVUTIL_VERSION_CHECK(51, 42, 0, 74, 100)
#define _AVPIXELFORMAT AVPixelFormat
#else
#define _AVPIXELFORMAT PixelFormat
#define AV_PIX_FMT_NONE PIX_FMT_NONE
#define AV_PIX_FMT_RGB444 PIX_FMT_RGB444
#define AV_PIX_FMT_RGB555 PIX_FMT_RGB555
#define AV_PIX_FMT_RGB565 PIX_FMT_RGB565
#define AV_PIX_FMT_BGR24 PIX_FMT_BGR24
#define AV_PIX_FMT_RGB24 PIX_FMT_RGB24
#define AV_PIX_FMT_BGRA PIX_FMT_BGRA
#define AV_PIX_FMT_ARGB PIX_FMT_ARGB
#define AV_PIX_FMT_ABGR PIX_FMT_ABGR
#define AV_PIX_FMT_RGBA PIX_FMT_RGBA
#define AV_PIX_FMT_GRAY8 PIX_FMT_GRAY8
#define AV_PIX_FMT_YUYV422 PIX_FMT_YUYV422
#define AV_PIX_FMT_YUV422P PIX_FMT_YUV422P
#define AV_PIX_FMT_YUV411P PIX_FMT_YUV411P
#define AV_PIX_FMT_YUV444P PIX_FMT_YUV444P
#define AV_PIX_FMT_YUV410P PIX_FMT_YUV410P
#define AV_PIX_FMT_YUV420P PIX_FMT_YUV420P
#define AV_PIX_FMT_YUVJ444P PIX_FMT_YUVJ444P
#define AV_PIX_FMT_UYVY422 PIX_FMT_UYVY422
#define AV_PIX_FMT_YUVJ420P PIX_FMT_YUVJ420P
#define AV_PIX_FMT_YUVJ422P PIX_FMT_YUVJ422P
#define AV_PIX_FMT_UYVY422 PIX_FMT_UYVY422
#define AV_PIX_FMT_UYYVYY411 PIX_FMT_UYYVYY411
#define AV_PIX_FMT_BGR565 PIX_FMT_BGR565
#define AV_PIX_FMT_BGR555 PIX_FMT_BGR555
#define AV_PIX_FMT_BGR8 PIX_FMT_BGR8
#define AV_PIX_FMT_BGR4 PIX_FMT_BGR4
#define AV_PIX_FMT_BGR4_BYTE PIX_FMT_BGR4_BYTE
#define AV_PIX_FMT_RGB8 PIX_FMT_RGB8
#define AV_PIX_FMT_RGB4 PIX_FMT_RGB4
#define AV_PIX_FMT_RGB4_BYTE PIX_FMT_RGB4_BYTE
#define AV_PIX_FMT_NV12 PIX_FMT_NV12
#define AV_PIX_FMT_NV21 PIX_FMT_NV21
#define AV_PIX_FMT_RGB32_1 PIX_FMT_RGB32_1
#define AV_PIX_FMT_BGR32_1 PIX_FMT_BGR32_1
#define AV_PIX_FMT_GRAY16BE PIX_FMT_GRAY16BE
#define AV_PIX_FMT_GRAY16LE PIX_FMT_GRAY16LE
#define AV_PIX_FMT_YUV440P PIX_FMT_YUV440P
#define AV_PIX_FMT_YUVJ440P PIX_FMT_YUVJ440P
#define AV_PIX_FMT_YUVA420P PIX_FMT_YUVA420P
//#define AV_PIX_FMT_VDPAU_H264 PIX_FMT_VDPAU_H264
//#define AV_PIX_FMT_VDPAU_MPEG1 PIX_FMT_VDPAU_MPEG1
//#define AV_PIX_FMT_VDPAU_MPEG2 PIX_FMT_VDPAU_MPEG2
#endif
// AVCODEC // AVCODEC
#include <libavcodec/avcodec.h> #include <libavcodec/avcodec.h>
@ -119,11 +63,7 @@ extern "C" {
( (LIBAVCODEC_VERSION_MICRO < 100 && LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(a, b, c) ) || \ ( (LIBAVCODEC_VERSION_MICRO < 100 && LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(a, b, c) ) || \
(LIBAVCODEC_VERSION_MICRO >= 100 && LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(a, d, e) ) ) (LIBAVCODEC_VERSION_MICRO >= 100 && LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(a, d, e) ) )
#if LIBAVCODEC_VERSION_CHECK(54, 25, 0, 51, 100) #define _AVCODECID AVCodecID
#define _AVCODECID AVCodecID
#else
#define _AVCODECID CodecID
#endif
// AVFORMAT // AVFORMAT
#include <libavformat/avformat.h> #include <libavformat/avformat.h>
@ -150,40 +90,12 @@ extern "C" {
} }
#if !LIBAVFORMAT_VERSION_CHECK(52, 107, 0, 107, 0)
#if defined(AVIO_WRONLY)
#define AVIO_FLAG_WRITE AVIO_WRONLY
#else
#define AVIO_FLAG_WRITE URL_WRONLY
#endif
#endif
/* A single function to initialize ffmpeg, to avoid multiple initializations */ /* A single function to initialize ffmpeg, to avoid multiple initializations */
void FFMPEGInit(); void FFMPEGInit();
void FFMPEGDeInit(); void FFMPEGDeInit();
enum _AVPIXELFORMAT GetFFMPEGPixelFormat(unsigned int p_colours, unsigned p_subpixelorder); enum _AVPIXELFORMAT GetFFMPEGPixelFormat(unsigned int p_colours, unsigned p_subpixelorder);
#if !LIBAVCODEC_VERSION_CHECK(54, 25, 0, 51, 100)
#define AV_CODEC_ID_NONE CODEC_ID_NONE
#define AV_CODEC_ID_PCM_MULAW CODEC_ID_PCM_MULAW
#define AV_CODEC_ID_PCM_ALAW CODEC_ID_PCM_ALAW
#define AV_CODEC_ID_PCM_S16BE CODEC_ID_PCM_S16BE
#define AV_CODEC_ID_QCELP CODEC_ID_QCELP
#define AV_CODEC_ID_MP2 CODEC_ID_MP2
#define AV_CODEC_ID_MP3 CODEC_ID_MP3
#define AV_CODEC_ID_MJPEG CODEC_ID_MJPEG
#define AV_CODEC_ID_H261 CODEC_ID_H261
#define AV_CODEC_ID_MPEG1VIDEO CODEC_ID_MPEG1VIDEO
#define AV_CODEC_ID_MPEG2VIDEO CODEC_ID_MPEG2VIDEO
#define AV_CODEC_ID_MPEG2TS CODEC_ID_MPEG2TS
#define AV_CODEC_ID_H263 CODEC_ID_H263
#define AV_CODEC_ID_H264 CODEC_ID_H264
#define AV_CODEC_ID_MPEG4 CODEC_ID_MPEG4
#define AV_CODEC_ID_AAC CODEC_ID_AAC
#define AV_CODEC_ID_AMR_NB CODEC_ID_AMR_NB
#endif
/* /*
* Some versions of libav does not contain this definition. * Some versions of libav does not contain this definition.
*/ */
@ -197,25 +109,13 @@ enum _AVPIXELFORMAT GetFFMPEGPixelFormat(unsigned int p_colours, unsigned p_subp
*/ */
inline static const std::string av_make_error_string(int errnum) { inline static const std::string av_make_error_string(int errnum) {
static char errbuf[AV_ERROR_MAX_STRING_SIZE]; static char errbuf[AV_ERROR_MAX_STRING_SIZE];
#if LIBAVUTIL_VERSION_CHECK(50, 13, 0, 13, 0)
av_strerror(errnum, errbuf, AV_ERROR_MAX_STRING_SIZE); av_strerror(errnum, errbuf, AV_ERROR_MAX_STRING_SIZE);
#else
snprintf(errbuf, AV_ERROR_MAX_STRING_SIZE, "libav error %d", errnum);
#endif
return (std::string)errbuf; return (std::string)errbuf;
} }
#undef av_err2str #undef av_err2str
#define av_err2str(errnum) av_make_error_string(errnum).c_str() #define av_err2str(errnum) av_make_error_string(errnum).c_str()
/* The following is copied directly from newer ffmpeg */
#if LIBAVUTIL_VERSION_CHECK(52, 7, 0, 17, 100)
#else
int av_dict_parse_string(AVDictionary **pm, const char *str,
const char *key_val_sep, const char *pairs_sep,
int flags);
#endif
#ifndef av_rescale_delta #ifndef av_rescale_delta
/** /**
* Rescale a timestamp while preserving known durations. * Rescale a timestamp while preserving known durations.
@ -243,9 +143,8 @@ static av_always_inline av_const int64_t av_clip64_c(int64_t a, int64_t amin, in
void zm_dump_stream_format(AVFormatContext *ic, int i, int index, int is_output); void zm_dump_stream_format(AVFormatContext *ic, int i, int index, int is_output);
void zm_dump_codec(const AVCodecContext *codec); void zm_dump_codec(const AVCodecContext *codec);
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
void zm_dump_codecpar(const AVCodecParameters *par); void zm_dump_codecpar(const AVCodecParameters *par);
#endif
#define zm_dump_frame(frame, text) Debug(1, "%s: format %d %s sample_rate %" PRIu32 " nb_samples %d" \ #define zm_dump_frame(frame, text) Debug(1, "%s: format %d %s sample_rate %" PRIu32 " nb_samples %d" \
" layout %" PRIu64 " pts %" PRId64, \ " layout %" PRIu64 " pts %" PRId64, \
text, \ text, \
@ -257,7 +156,6 @@ void zm_dump_codecpar(const AVCodecParameters *par);
frame->pts \ frame->pts \
); );
#if LIBAVUTIL_VERSION_CHECK(54, 4, 0, 74, 100)
#define zm_dump_video_frame(frame, text) Debug(1, "%s: format %d %s %dx%d linesize:%dx%d pts: %" PRId64 " keyframe: %d", \ #define zm_dump_video_frame(frame, text) Debug(1, "%s: format %d %s %dx%d linesize:%dx%d pts: %" PRId64 " keyframe: %d", \
text, \ text, \
frame->format, \ frame->format, \
@ -269,35 +167,10 @@ void zm_dump_codecpar(const AVCodecParameters *par);
frame->key_frame \ frame->key_frame \
); );
#else
#define zm_dump_video_frame(frame,text) Debug(1, "%s: format %d %s %dx%d linesize:%dx%d pts: %" PRId64, \
text, \
frame->format, \
"unsupported", \
frame->width, \
frame->height, \
frame->linesize[0], frame->linesize[1], \
frame->pts \
);
#endif
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
# define AV_PACKET_DURATION_FMT PRId64 # define AV_PACKET_DURATION_FMT PRId64
#else
# define AV_PACKET_DURATION_FMT "d"
#endif
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
#define CODEC_TYPE(stream) stream->codecpar->codec_type #define CODEC_TYPE(stream) stream->codecpar->codec_type
#else
#define CODEC_TYPE(stream) stream->codec->codec_type
#endif
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
#define CODEC(stream) stream->codecpar #define CODEC(stream) stream->codecpar
#else
#define CODEC(stream) stream->codec
#endif
#ifndef DBG_OFF #ifndef DBG_OFF
# define ZM_DUMP_PACKET(pkt, text) \ # define ZM_DUMP_PACKET(pkt, text) \
@ -339,39 +212,10 @@ void zm_dump_codecpar(const AVCodecParameters *par);
# define ZM_DUMP_STREAM_PACKET(stream, pkt, text) # define ZM_DUMP_STREAM_PACKET(stream, pkt, text)
#endif #endif
#if LIBAVCODEC_VERSION_CHECK(56, 8, 0, 60, 100) #define zm_av_packet_unref(packet) av_packet_unref(packet)
#define zm_av_packet_unref(packet) av_packet_unref(packet) #define zm_av_packet_ref(dst, src) av_packet_ref(dst, src)
#define zm_av_packet_ref(dst, src) av_packet_ref(dst, src)
#else
unsigned int zm_av_packet_ref( AVPacket *dst, AVPacket *src );
#define zm_av_packet_unref( packet ) av_free_packet( packet )
const char *avcodec_get_name(AVCodecID id);
void av_packet_rescale_ts(AVPacket *pkt, AVRational src_tb, AVRational dst_tb); #define zm_av_frame_alloc() av_frame_alloc()
#endif
#if LIBAVCODEC_VERSION_CHECK(57, 24, 1, 45, 101)
#define zm_avcodec_decode_video(context, rawFrame, frameComplete, packet) \
avcodec_send_packet(context, packet); \
avcodec_receive_frame(context, rawFrame);
#else
#if LIBAVCODEC_VERSION_CHECK(52, 23, 0, 23, 0)
#define zm_avcodec_decode_video(context, rawFrame, frameComplete, packet) \
avcodec_decode_video2(context, rawFrame, frameComplete, packet)
#else
#define zm_avcodec_decode_video(context, rawFrame, frameComplete, packet) \
avcodec_decode_video(context, rawFrame, frameComplete, packet->data, packet->size)
#endif
#endif
#if LIBAVCODEC_VERSION_CHECK(55, 28, 1, 45, 101)
#define zm_av_frame_alloc() av_frame_alloc()
#else
#define zm_av_frame_alloc() avcodec_alloc_frame()
#endif
#if ! LIBAVCODEC_VERSION_CHECK(55, 28, 1, 45, 101)
#define av_frame_free( input_avframe ) av_freep( input_avframe )
#endif
int check_sample_fmt(AVCodec *codec, enum AVSampleFormat sample_fmt); int check_sample_fmt(AVCodec *codec, enum AVSampleFormat sample_fmt);
enum AVPixelFormat fix_deprecated_pix_fmt(enum AVPixelFormat ); enum AVPixelFormat fix_deprecated_pix_fmt(enum AVPixelFormat );

View File

@ -231,11 +231,8 @@ int FfmpegCamera::Capture(std::shared_ptr<ZMPacket> &zm_packet) {
AVStream *stream = formatContextPtr->streams[packet.stream_index]; AVStream *stream = formatContextPtr->streams[packet.stream_index];
ZM_DUMP_STREAM_PACKET(stream, packet, "ffmpeg_camera in"); ZM_DUMP_STREAM_PACKET(stream, packet, "ffmpeg_camera in");
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
zm_packet->codec_type = stream->codecpar->codec_type; zm_packet->codec_type = stream->codecpar->codec_type;
#else
zm_packet->codec_type = stream->codec->codec_type;
#endif
bytes += packet.size; bytes += packet.size;
zm_packet->set_packet(&packet); zm_packet->set_packet(&packet);
zm_packet->stream = stream; zm_packet->stream = stream;
@ -268,10 +265,6 @@ int FfmpegCamera::OpenFfmpeg() {
error_count = 0; error_count = 0;
// Open the input, not necessarily a file
#if !LIBAVFORMAT_VERSION_CHECK(53, 2, 0, 4, 0)
if (av_open_input_file(&mFormatContext, mPath.c_str(), nullptr, 0, nullptr) != 0)
#else
// Handle options // Handle options
AVDictionary *opts = nullptr; AVDictionary *opts = nullptr;
ret = av_dict_parse_string(&opts, Options().c_str(), "=", ",", 0); ret = av_dict_parse_string(&opts, Options().c_str(), "=", ",", 0);
@ -312,18 +305,14 @@ int FfmpegCamera::OpenFfmpeg() {
ret = avformat_open_input(&mFormatContext, mPath.c_str(), nullptr, &opts); ret = avformat_open_input(&mFormatContext, mPath.c_str(), nullptr, &opts);
if ( ret != 0 ) if ( ret != 0 )
#endif
{ {
Error("Unable to open input %s due to: %s", mPath.c_str(), Error("Unable to open input %s due to: %s", mPath.c_str(),
av_make_error_string(ret).c_str()); av_make_error_string(ret).c_str());
#if !LIBAVFORMAT_VERSION_CHECK(53, 17, 0, 25, 0)
av_close_input_file(mFormatContext);
#else
if ( mFormatContext ) { if ( mFormatContext ) {
avformat_close_input(&mFormatContext); avformat_close_input(&mFormatContext);
mFormatContext = nullptr; mFormatContext = nullptr;
} }
#endif
av_dict_free(&opts); av_dict_free(&opts);
return -1; return -1;
@ -335,11 +324,8 @@ int FfmpegCamera::OpenFfmpeg() {
av_dict_free(&opts); av_dict_free(&opts);
Debug(1, "Finding stream info"); Debug(1, "Finding stream info");
#if !LIBAVFORMAT_VERSION_CHECK(53, 6, 0, 6, 0)
ret = av_find_stream_info(mFormatContext);
#else
ret = avformat_find_stream_info(mFormatContext, nullptr); ret = avformat_find_stream_info(mFormatContext, nullptr);
#endif
if ( ret < 0 ) { if ( ret < 0 ) {
Error("Unable to find stream info from %s due to: %s", Error("Unable to find stream info from %s due to: %s",
mPath.c_str(), av_make_error_string(ret).c_str()); mPath.c_str(), av_make_error_string(ret).c_str());
@ -380,13 +366,7 @@ int FfmpegCamera::OpenFfmpeg() {
mVideoStreamId, mAudioStreamId); mVideoStreamId, mAudioStreamId);
AVCodec *mVideoCodec = nullptr; AVCodec *mVideoCodec = nullptr;
if (mVideoStream-> if (mVideoStream->codecpar->codec_id == AV_CODEC_ID_H264) {
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
codecpar
#else
codec
#endif
->codec_id == AV_CODEC_ID_H264) {
if ((mVideoCodec = avcodec_find_decoder_by_name("h264_mmal")) == nullptr) { if ((mVideoCodec = avcodec_find_decoder_by_name("h264_mmal")) == nullptr) {
Debug(1, "Failed to find decoder (h264_mmal)"); Debug(1, "Failed to find decoder (h264_mmal)");
} else { } else {
@ -395,13 +375,7 @@ int FfmpegCamera::OpenFfmpeg() {
} }
if (!mVideoCodec) { if (!mVideoCodec) {
mVideoCodec = avcodec_find_decoder(mVideoStream-> mVideoCodec = avcodec_find_decoder(mVideoStream->codecpar->codec_id);
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
codecpar
#else
codec
#endif
->codec_id);
if (!mVideoCodec) { if (!mVideoCodec) {
// Try and get the codec from the codec context // Try and get the codec from the codec context
Error("Can't find codec for video stream from %s", mPath.c_str()); Error("Can't find codec for video stream from %s", mPath.c_str());
@ -409,13 +383,9 @@ int FfmpegCamera::OpenFfmpeg() {
} }
} }
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
mVideoCodecContext = avcodec_alloc_context3(mVideoCodec); mVideoCodecContext = avcodec_alloc_context3(mVideoCodec);
avcodec_parameters_to_context(mVideoCodecContext, avcodec_parameters_to_context(mVideoCodecContext, mFormatContext->streams[mVideoStreamId]->codecpar);
mFormatContext->streams[mVideoStreamId]->codecpar);
#else
mVideoCodecContext = mFormatContext->streams[mVideoStreamId]->codec;
#endif
#ifdef CODEC_FLAG2_FAST #ifdef CODEC_FLAG2_FAST
mVideoCodecContext->flags2 |= CODEC_FLAG2_FAST | CODEC_FLAG_LOW_DELAY; mVideoCodecContext->flags2 |= CODEC_FLAG2_FAST | CODEC_FLAG_LOW_DELAY;
#endif #endif
@ -499,11 +469,8 @@ int FfmpegCamera::OpenFfmpeg() {
#endif #endif
} // end if hwaccel_name } // end if hwaccel_name
#if !LIBAVFORMAT_VERSION_CHECK(53, 8, 0, 8, 0)
ret = avcodec_open(mVideoCodecContext, mVideoCodec);
#else
ret = avcodec_open2(mVideoCodecContext, mVideoCodec, &opts); ret = avcodec_open2(mVideoCodecContext, mVideoCodec, &opts);
#endif
e = nullptr; e = nullptr;
while ((e = av_dict_get(opts, "", e, AV_DICT_IGNORE_SUFFIX)) != nullptr) { while ((e = av_dict_get(opts, "", e, AV_DICT_IGNORE_SUFFIX)) != nullptr) {
Warning("Option %s not recognized by ffmpeg", e->key); Warning("Option %s not recognized by ffmpeg", e->key);
@ -529,33 +496,15 @@ int FfmpegCamera::OpenFfmpeg() {
if ( mAudioStreamId >= 0 ) { if ( mAudioStreamId >= 0 ) {
AVCodec *mAudioCodec = nullptr; AVCodec *mAudioCodec = nullptr;
if ( (mAudioCodec = avcodec_find_decoder( if (!(mAudioCodec = avcodec_find_decoder(mAudioStream->codecpar->codec_id))) {
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
mAudioStream->codecpar->codec_id
#else
mAudioStream->codec->codec_id
#endif
)) == nullptr ) {
Debug(1, "Can't find codec for audio stream from %s", mPath.c_str()); Debug(1, "Can't find codec for audio stream from %s", mPath.c_str());
} else { } else {
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
mAudioCodecContext = avcodec_alloc_context3(mAudioCodec); mAudioCodecContext = avcodec_alloc_context3(mAudioCodec);
avcodec_parameters_to_context( avcodec_parameters_to_context(mAudioCodecContext, mAudioStream->codecpar);
mAudioCodecContext,
mAudioStream->codecpar
);
#else
mAudioCodecContext = mAudioStream->codec;
#endif
zm_dump_stream_format((mSecondFormatContext?mSecondFormatContext:mFormatContext), mAudioStreamId, 0, 0); zm_dump_stream_format((mSecondFormatContext?mSecondFormatContext:mFormatContext), mAudioStreamId, 0, 0);
// Open the codec // Open the codec
#if !LIBAVFORMAT_VERSION_CHECK(53, 8, 0, 8, 0) if (avcodec_open2(mAudioCodecContext, mAudioCodec, nullptr) < 0) {
if ( avcodec_open(mAudioCodecContext, mAudioCodec) < 0 )
#else
if ( avcodec_open2(mAudioCodecContext, mAudioCodec, nullptr) < 0 )
#endif
{
Error("Unable to open codec for audio stream from %s", mPath.c_str()); Error("Unable to open codec for audio stream from %s", mPath.c_str());
return -1; return -1;
} // end if opened } // end if opened
@ -581,16 +530,12 @@ int FfmpegCamera::Close() {
if ( mVideoCodecContext ) { if ( mVideoCodecContext ) {
avcodec_close(mVideoCodecContext); avcodec_close(mVideoCodecContext);
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
avcodec_free_context(&mVideoCodecContext); avcodec_free_context(&mVideoCodecContext);
#endif
mVideoCodecContext = nullptr; // Freed by av_close_input_file mVideoCodecContext = nullptr; // Freed by av_close_input_file
} }
if ( mAudioCodecContext ) { if ( mAudioCodecContext ) {
avcodec_close(mAudioCodecContext); avcodec_close(mAudioCodecContext);
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
avcodec_free_context(&mAudioCodecContext); avcodec_free_context(&mAudioCodecContext);
#endif
mAudioCodecContext = nullptr; // Freed by av_close_input_file mAudioCodecContext = nullptr; // Freed by av_close_input_file
} }
@ -601,11 +546,7 @@ int FfmpegCamera::Close() {
#endif #endif
if ( mFormatContext ) { if ( mFormatContext ) {
#if !LIBAVFORMAT_VERSION_CHECK(53, 17, 0, 25, 0)
av_close_input_file(mFormatContext);
#else
avformat_close_input(&mFormatContext); avformat_close_input(&mFormatContext);
#endif
mFormatContext = nullptr; mFormatContext = nullptr;
} }

View File

@ -89,12 +89,8 @@ int FFmpeg_Input::Open(const char *filepath) {
} }
streams[i].frame_count = 0; streams[i].frame_count = 0;
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
streams[i].context = avcodec_alloc_context3(nullptr); streams[i].context = avcodec_alloc_context3(nullptr);
avcodec_parameters_to_context(streams[i].context, input_format_context->streams[i]->codecpar); avcodec_parameters_to_context(streams[i].context, input_format_context->streams[i]->codecpar);
#else
streams[i].context = input_format_context->streams[i]->codec;
#endif
if ( !(streams[i].codec = avcodec_find_decoder(streams[i].context->codec_id)) ) { if ( !(streams[i].codec = avcodec_find_decoder(streams[i].context->codec_id)) ) {
Error("Could not find input codec"); Error("Could not find input codec");
@ -108,9 +104,7 @@ int FFmpeg_Input::Open(const char *filepath) {
if ( error < 0 ) { if ( error < 0 ) {
Error("Could not open input codec (error '%s')", Error("Could not open input codec (error '%s')",
av_make_error_string(error).c_str()); av_make_error_string(error).c_str());
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
avcodec_free_context(&streams[i].context); avcodec_free_context(&streams[i].context);
#endif
avformat_close_input(&input_format_context); avformat_close_input(&input_format_context);
input_format_context = nullptr; input_format_context = nullptr;
return error; return error;
@ -129,21 +123,15 @@ int FFmpeg_Input::Close( ) {
if ( streams ) { if ( streams ) {
for ( unsigned int i = 0; i < input_format_context->nb_streams; i += 1 ) { for ( unsigned int i = 0; i < input_format_context->nb_streams; i += 1 ) {
avcodec_close(streams[i].context); avcodec_close(streams[i].context);
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
avcodec_free_context(&streams[i].context); avcodec_free_context(&streams[i].context);
streams[i].context = nullptr; streams[i].context = nullptr;
#endif
} }
delete[] streams; delete[] streams;
streams = nullptr; streams = nullptr;
} }
if ( input_format_context ) { if ( input_format_context ) {
#if !LIBAVFORMAT_VERSION_CHECK(53, 17, 0, 25, 0)
av_close_input_file(input_format_context);
#else
avformat_close_input(&input_format_context); avformat_close_input(&input_format_context);
#endif
input_format_context = nullptr; input_format_context = nullptr;
} }
return 1; return 1;

View File

@ -52,12 +52,8 @@ int FFmpeg_Output::Open( const char *filepath ) {
} }
streams[i].frame_count = 0; streams[i].frame_count = 0;
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0) streams[i].context = avcodec_alloc_context3(nullptr);
streams[i].context = avcodec_alloc_context3( NULL ); avcodec_parameters_to_context(streams[i].context, input_format_context->streams[i]->codecpar);
avcodec_parameters_to_context( streams[i].context, input_format_context->streams[i]->codecpar );
#else
streams[i].context = input_format_context->streams[i]->codec;
#endif
if ( !(streams[i].codec = avcodec_find_decoder(streams[i].context->codec_id)) ) { if ( !(streams[i].codec = avcodec_find_decoder(streams[i].context->codec_id)) ) {
Error( "Could not find input codec\n"); Error( "Could not find input codec\n");
@ -70,9 +66,7 @@ int FFmpeg_Output::Open( const char *filepath ) {
if ((error = avcodec_open2( streams[i].context, streams[i].codec, NULL)) < 0) { if ((error = avcodec_open2( streams[i].context, streams[i].codec, NULL)) < 0) {
Error( "Could not open input codec (error '%s')\n", Error( "Could not open input codec (error '%s')\n",
av_make_error_string(error).c_str() ); av_make_error_string(error).c_str() );
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
avcodec_free_context( &streams[i].context ); avcodec_free_context( &streams[i].context );
#endif
avformat_close_input(&input_format_context); avformat_close_input(&input_format_context);
return error; return error;
} }
@ -117,7 +111,6 @@ AVFrame *FFmpeg_Output::get_frame( int stream_id ) {
AVCodecContext *context = streams[packet.stream_index].context; AVCodecContext *context = streams[packet.stream_index].context;
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
ret = avcodec_send_packet( context, &packet ); ret = avcodec_send_packet( context, &packet );
if ( ret < 0 ) { if ( ret < 0 ) {
av_strerror( ret, errbuf, AV_ERROR_MAX_STRING_SIZE ); av_strerror( ret, errbuf, AV_ERROR_MAX_STRING_SIZE );
@ -160,15 +153,6 @@ AVFrame *FFmpeg_Output::get_frame( int stream_id ) {
#endif #endif
frameComplete = 1; frameComplete = 1;
# else
ret = zm_avcodec_decode_video( streams[packet.stream_index].context, frame, &frameComplete, &packet );
if ( ret < 0 ) {
av_strerror( ret, errbuf, AV_ERROR_MAX_STRING_SIZE );
Error( "Unable to decode frame at frame %d: %s, continuing", streams[packet.stream_index].frame_count, errbuf );
zm_av_packet_unref( &packet );
continue;
}
#endif
} // end if it's the right stream } // end if it's the right stream
zm_av_packet_unref( &packet ); zm_av_packet_unref( &packet );

View File

@ -226,14 +226,9 @@ Image::Image(const AVFrame *frame) {
imagePixFormat = AV_PIX_FMT_RGBA; imagePixFormat = AV_PIX_FMT_RGBA;
//(AVPixelFormat)frame->format; //(AVPixelFormat)frame->format;
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
size = av_image_get_buffer_size(AV_PIX_FMT_RGBA, width, height, 32); size = av_image_get_buffer_size(AV_PIX_FMT_RGBA, width, height, 32);
// av_image_get_linesize isn't aligned, so we have to do that. // av_image_get_linesize isn't aligned, so we have to do that.
linesize = FFALIGN(av_image_get_linesize(AV_PIX_FMT_RGBA, width, 0), 32); linesize = FFALIGN(av_image_get_linesize(AV_PIX_FMT_RGBA, width, 0), 32);
#else
linesize = FFALIGN(av_image_get_linesize(AV_PIX_FMT_RGBA, width, 0), 1);
size = avpicture_get_size(AV_PIX_FMT_RGB0, width, height);
#endif
padding = 0; padding = 0;
buffer = nullptr; buffer = nullptr;
@ -259,7 +254,7 @@ int Image::PopulateFrame(AVFrame *frame) {
Warning("Failed to create av_buffer"); Warning("Failed to create av_buffer");
} }
frame->buf[0] = ref; frame->buf[0] = ref;
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
// From what I've read, we should align the linesizes to 32bit so that ffmpeg can use SIMD instructions too. // From what I've read, we should align the linesizes to 32bit so that ffmpeg can use SIMD instructions too.
int size = av_image_fill_arrays( int size = av_image_fill_arrays(
frame->data, frame->linesize, frame->data, frame->linesize,
@ -271,10 +266,7 @@ int Image::PopulateFrame(AVFrame *frame) {
av_make_error_string(size).c_str()); av_make_error_string(size).c_str());
return size; return size;
} }
#else
avpicture_fill((AVPicture *)frame, buffer,
imagePixFormat, width, height);
#endif
frame->width = width; frame->width = width;
frame->height = height; frame->height = height;
frame->format = imagePixFormat; frame->format = imagePixFormat;

View File

@ -10,11 +10,12 @@
// Older versions of libvncserver defined a max macro in rfb/rfbproto.h // Older versions of libvncserver defined a max macro in rfb/rfbproto.h
// Undef it here so it doesn't collide with std::max // Undef it here so it doesn't collide with std::max
// TODO: Remove this once xenial support is dropped // TODO: Remove this once CentOS 7 support is dropped
#ifdef max #ifdef max
#undef max #undef max
#endif #endif
// Used by vnc callbacks // Used by vnc callbacks
struct VncPrivateData { struct VncPrivateData {
uint8_t *buffer; uint8_t *buffer;

View File

@ -375,7 +375,6 @@ LocalCamera::LocalCamera(
Panic("Unexpected colours: %u",colours); Panic("Unexpected colours: %u",colours);
} }
if ( capture ) { if ( capture ) {
#if LIBSWSCALE_VERSION_CHECK(0, 8, 0, 8, 0)
if ( !sws_isSupportedInput(capturePixFormat) ) { if ( !sws_isSupportedInput(capturePixFormat) ) {
Error("swscale does not support the used capture format: %d", capturePixFormat); Error("swscale does not support the used capture format: %d", capturePixFormat);
conversion_type = 2; /* Try ZM format conversions */ conversion_type = 2; /* Try ZM format conversions */
@ -384,7 +383,6 @@ LocalCamera::LocalCamera(
Error("swscale does not support the target format: 0x%d", imagePixFormat); Error("swscale does not support the target format: 0x%d", imagePixFormat);
conversion_type = 2; /* Try ZM format conversions */ conversion_type = 2; /* Try ZM format conversions */
} }
#endif
} }
/* Our YUYV->Grayscale conversion is a lot faster than swscale's */ /* Our YUYV->Grayscale conversion is a lot faster than swscale's */
if ( colours == ZM_COLOUR_GRAY8 && palette == V4L2_PIX_FMT_YUYV ) { if ( colours == ZM_COLOUR_GRAY8 && palette == V4L2_PIX_FMT_YUYV ) {
@ -445,19 +443,13 @@ LocalCamera::LocalCamera(
/* Initialize swscale stuff */ /* Initialize swscale stuff */
if ( capture and (conversion_type == 1) ) { if ( capture and (conversion_type == 1) ) {
#if LIBAVCODEC_VERSION_CHECK(55, 28, 1, 45, 101)
tmpPicture = av_frame_alloc(); tmpPicture = av_frame_alloc();
#else
tmpPicture = avcodec_alloc_frame();
#endif
if ( !tmpPicture ) if ( !tmpPicture )
Fatal("Could not allocate temporary picture"); Fatal("Could not allocate temporary picture");
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
unsigned int pSize = av_image_get_buffer_size(imagePixFormat, width, height, 1); unsigned int pSize = av_image_get_buffer_size(imagePixFormat, width, height, 1);
#else
unsigned int pSize = avpicture_get_size(imagePixFormat, width, height);
#endif
if ( pSize != imagesize ) { if ( pSize != imagesize ) {
Fatal("Image size mismatch. Required: %d Available: %llu", pSize, imagesize); Fatal("Image size mismatch. Required: %d Available: %llu", pSize, imagesize);
} }
@ -699,14 +691,11 @@ void LocalCamera::Initialise() {
Fatal("Can't map video buffer %u (%u bytes) to memory: %s(%d)", Fatal("Can't map video buffer %u (%u bytes) to memory: %s(%d)",
i, vid_buf.length, strerror(errno), errno); i, vid_buf.length, strerror(errno), errno);
#if LIBAVCODEC_VERSION_CHECK(55, 28, 1, 45, 101)
capturePictures[i] = av_frame_alloc(); capturePictures[i] = av_frame_alloc();
#else
capturePictures[i] = avcodec_alloc_frame();
#endif
if ( !capturePictures[i] ) if ( !capturePictures[i] )
Fatal("Could not allocate picture"); Fatal("Could not allocate picture");
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
av_image_fill_arrays( av_image_fill_arrays(
capturePictures[i]->data, capturePictures[i]->data,
capturePictures[i]->linesize, capturePictures[i]->linesize,
@ -715,15 +704,6 @@ void LocalCamera::Initialise() {
v4l2_data.fmt.fmt.pix.width, v4l2_data.fmt.fmt.pix.width,
v4l2_data.fmt.fmt.pix.height, v4l2_data.fmt.fmt.pix.height,
1); 1);
#else
avpicture_fill(
(AVPicture *)capturePictures[i],
(uint8_t*)v4l2_data.buffers[i].start,
capturePixFormat,
v4l2_data.fmt.fmt.pix.width,
v4l2_data.fmt.fmt.pix.height
);
#endif
} // end foreach request buf } // end foreach request buf
Debug(3, "Configuring video source"); Debug(3, "Configuring video source");
@ -769,12 +749,8 @@ void LocalCamera::Terminate() {
Debug(3, "Unmapping video buffers"); Debug(3, "Unmapping video buffers");
for ( unsigned int i = 0; i < v4l2_data.reqbufs.count; i++ ) { for ( unsigned int i = 0; i < v4l2_data.reqbufs.count; i++ ) {
/* Free capture pictures */
#if LIBAVCODEC_VERSION_CHECK(55, 28, 1, 45, 101)
av_frame_free(&capturePictures[i]); av_frame_free(&capturePictures[i]);
#else
av_freep(&capturePictures[i]);
#endif
if ( munmap(v4l2_data.buffers[i].start, v4l2_data.buffers[i].length) < 0 ) if ( munmap(v4l2_data.buffers[i].start, v4l2_data.buffers[i].length) < 0 )
Error("Failed to munmap buffer %d: %s", i, strerror(errno)); Error("Failed to munmap buffer %d: %s", i, strerror(errno));
} }
@ -1462,14 +1438,10 @@ int LocalCamera::Capture(std::shared_ptr<ZMPacket> &zm_packet) {
if (conversion_type == 1) { if (conversion_type == 1) {
Debug(9, "Calling sws_scale to perform the conversion"); Debug(9, "Calling sws_scale to perform the conversion");
/* Use swscale to convert the image directly into the shared memory */ /* Use swscale to convert the image directly into the shared memory */
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
av_image_fill_arrays(tmpPicture->data, av_image_fill_arrays(tmpPicture->data,
tmpPicture->linesize, directbuffer, tmpPicture->linesize, directbuffer,
imagePixFormat, width, height, 1); imagePixFormat, width, height, 1);
#else
avpicture_fill( (AVPicture *)tmpPicture, directbuffer,
imagePixFormat, width, height );
#endif
sws_scale( sws_scale(
imgConversionContext, imgConversionContext,
capturePictures[capture_frame]->data, capturePictures[capture_frame]->data,

View File

@ -2519,13 +2519,11 @@ int Monitor::Capture() {
if ( packet->keyframe ) { if ( packet->keyframe ) {
// avcodec strips out important nals that describe the stream and // avcodec strips out important nals that describe the stream and
// stick them in extradata. Need to send them along with keyframes // stick them in extradata. Need to send them along with keyframes
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
AVStream *stream = camera->getVideoStream(); AVStream *stream = camera->getVideoStream();
video_fifo->write( video_fifo->write(
static_cast<unsigned char *>(stream->codecpar->extradata), static_cast<unsigned char *>(stream->codecpar->extradata),
stream->codecpar->extradata_size, stream->codecpar->extradata_size,
packet->pts); packet->pts);
#endif
} }
video_fifo->writePacket(*packet); video_fifo->writePacket(*packet);
} }
@ -3011,28 +3009,20 @@ int Monitor::PrimeCapture() {
if (rtsp_server) { if (rtsp_server) {
if (video_stream_id >= 0) { if (video_stream_id >= 0) {
AVStream *videoStream = camera->getVideoStream(); AVStream *videoStream = camera->getVideoStream();
snprintf(shared_data->video_fifo_path, sizeof(shared_data->video_fifo_path)-1, "%s/video_fifo_%u.%s", snprintf(shared_data->video_fifo_path, sizeof(shared_data->video_fifo_path) - 1, "%s/video_fifo_%u.%s",
staticConfig.PATH_SOCKS.c_str(), staticConfig.PATH_SOCKS.c_str(),
id, id,
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0) avcodec_get_name(videoStream->codecpar->codec_id)
avcodec_get_name(videoStream->codecpar->codec_id) );
#else
avcodec_get_name(videoStream->codec->codec_id)
#endif
);
video_fifo = new Fifo(shared_data->video_fifo_path, true); video_fifo = new Fifo(shared_data->video_fifo_path, true);
} }
if (record_audio and (audio_stream_id >= 0)) { if (record_audio and (audio_stream_id >= 0)) {
AVStream *audioStream = camera->getAudioStream(); AVStream *audioStream = camera->getAudioStream();
if (audioStream && CODEC(audioStream)) { if (audioStream && CODEC(audioStream)) {
snprintf(shared_data->audio_fifo_path, sizeof(shared_data->audio_fifo_path)-1, "%s/audio_fifo_%u.%s", snprintf(shared_data->audio_fifo_path, sizeof(shared_data->audio_fifo_path) - 1, "%s/audio_fifo_%u.%s",
staticConfig.PATH_SOCKS.c_str(), id, staticConfig.PATH_SOCKS.c_str(), id,
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0) avcodec_get_name(audioStream->codecpar->codec_id)
avcodec_get_name(audioStream->codecpar->codec_id) );
#else
avcodec_get_name(audioStream->codec->codec_id)
#endif
);
audio_fifo = new Fifo(shared_data->audio_fifo_path, true); audio_fifo = new Fifo(shared_data->audio_fifo_path, true);
} else { } else {
Warning("No audioStream %p or codec?", audioStream); Warning("No audioStream %p or codec?", audioStream);

View File

@ -46,59 +46,8 @@ void VideoStream::Initialise( ) {
void VideoStream::SetupFormat( ) { void VideoStream::SetupFormat( ) {
/* allocate the output media context */ /* allocate the output media context */
ofc = nullptr; ofc = nullptr;
#if (LIBAVFORMAT_VERSION_CHECK(53, 2, 0, 2, 0) && (LIBAVFORMAT_VERSION_MICRO >= 100))
avformat_alloc_output_context2(&ofc, nullptr, format, filename); avformat_alloc_output_context2(&ofc, nullptr, format, filename);
#else
AVFormatContext *s = avformat_alloc_context();
if ( !s ) {
Fatal("avformat_alloc_context failed %d \"%s\"", (size_t)ofc, av_err2str((size_t)ofc));
return;
}
AVOutputFormat *oformat;
if ( format ) {
#if LIBAVFORMAT_VERSION_CHECK(52, 45, 0, 45, 0)
oformat = av_guess_format(format, nullptr, nullptr);
#else
oformat = guess_format(format, nullptr, nullptr);
#endif
if ( !oformat ) {
Fatal("Requested output format '%s' is not a suitable output format", format);
}
} else {
#if LIBAVFORMAT_VERSION_CHECK(52, 45, 0, 45, 0)
oformat = av_guess_format(nullptr, filename, nullptr);
#else
oformat = guess_format(nullptr, filename, nullptr);
#endif
if ( !oformat ) {
Fatal("Unable to find a suitable output format for '%s'", format);
}
}
s->oformat = oformat;
if ( s->oformat->priv_data_size > 0 ) {
s->priv_data = av_mallocz(s->oformat->priv_data_size);
if ( !(s->priv_data) ) {
Fatal("Could not allocate private data for output format.");
}
#if LIBAVFORMAT_VERSION_CHECK(52, 92, 0, 92, 0)
if ( s->oformat->priv_class ) {
*(const AVClass**)s->priv_data = s->oformat->priv_class;
av_opt_set_defaults(s->priv_data);
}
#endif
} else {
Debug(1, "No allocating priv_data");
s->priv_data = nullptr;
}
if ( filename ) {
snprintf(s->filename, sizeof(s->filename), "%s", filename);
}
ofc = s;
#endif
if ( !ofc ) { if ( !ofc ) {
Fatal("avformat_alloc_..._context failed"); Fatal("avformat_alloc_..._context failed");
} }
@ -161,11 +110,7 @@ void VideoStream::SetupCodec( int colours, int subpixelorder, int width, int hei
codec_id = a->id; codec_id = a->id;
Debug(1, "Using codec \"%s\"", codec_name); Debug(1, "Using codec \"%s\"", codec_name);
} else { } else {
#if (LIBAVFORMAT_VERSION_CHECK(53, 8, 0, 11, 0) && (LIBAVFORMAT_VERSION_MICRO >= 100))
Debug(1, "Could not find codec \"%s\". Using default \"%s\"", codec_name, avcodec_get_name(codec_id)); Debug(1, "Could not find codec \"%s\". Using default \"%s\"", codec_name, avcodec_get_name(codec_id));
#else
Debug(1, "Could not find codec \"%s\". Using default \"%d\"", codec_name, codec_id);
#endif
} }
} }
@ -175,24 +120,12 @@ void VideoStream::SetupCodec( int colours, int subpixelorder, int width, int hei
if ( codec_id != AV_CODEC_ID_NONE ) { if ( codec_id != AV_CODEC_ID_NONE ) {
codec = avcodec_find_encoder(codec_id); codec = avcodec_find_encoder(codec_id);
if ( !codec ) { if ( !codec ) {
#if (LIBAVFORMAT_VERSION_CHECK(53, 8, 0, 11, 0) && (LIBAVFORMAT_VERSION_MICRO >= 100))
Fatal("Could not find encoder for '%s'", avcodec_get_name(codec_id)); Fatal("Could not find encoder for '%s'", avcodec_get_name(codec_id));
#else
Fatal("Could not find encoder for '%d'", codec_id);
#endif
} }
#if (LIBAVFORMAT_VERSION_CHECK(53, 8, 0, 11, 0) && (LIBAVFORMAT_VERSION_MICRO >= 100))
Debug(1, "Found encoder for '%s'", avcodec_get_name(codec_id)); Debug(1, "Found encoder for '%s'", avcodec_get_name(codec_id));
#else
Debug(1, "Found encoder for '%d'", codec_id);
#endif
#if LIBAVFORMAT_VERSION_CHECK(53, 10, 0, 17, 0)
ost = avformat_new_stream( ofc, codec ); ost = avformat_new_stream( ofc, codec );
#else
ost = av_new_stream( ofc, 0 );
#endif
if ( !ost ) { if ( !ost ) {
Fatal( "Could not alloc stream" ); Fatal( "Could not alloc stream" );
@ -201,13 +134,8 @@ void VideoStream::SetupCodec( int colours, int subpixelorder, int width, int hei
Debug( 1, "Allocated stream (%d) !=? (%d)", ost->id , ofc->nb_streams - 1 ); Debug( 1, "Allocated stream (%d) !=? (%d)", ost->id , ofc->nb_streams - 1 );
ost->id = ofc->nb_streams - 1; ost->id = ofc->nb_streams - 1;
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
codec_context = avcodec_alloc_context3(nullptr); codec_context = avcodec_alloc_context3(nullptr);
//avcodec_parameters_to_context(codec_context, ost->codecpar); //avcodec_parameters_to_context(codec_context, ost->codecpar);
#else
codec_context = ost->codec;
#endif
codec_context->codec_id = codec->id; codec_context->codec_id = codec->id;
codec_context->codec_type = codec->type; codec_context->codec_type = codec->type;
@ -216,11 +144,7 @@ void VideoStream::SetupCodec( int colours, int subpixelorder, int width, int hei
if ( bitrate <= 100 ) { if ( bitrate <= 100 ) {
// Quality based bitrate control (VBR). Scale is 1..31 where 1 is best. // Quality based bitrate control (VBR). Scale is 1..31 where 1 is best.
// This gets rid of artifacts in the beginning of the movie; and well, even quality. // This gets rid of artifacts in the beginning of the movie; and well, even quality.
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
codec_context->flags |= AV_CODEC_FLAG_QSCALE; codec_context->flags |= AV_CODEC_FLAG_QSCALE;
#else
codec_context->flags |= CODEC_FLAG_QSCALE;
#endif
codec_context->global_quality = FF_QP2LAMBDA * (31 - (31 * (bitrate / 100.0))); codec_context->global_quality = FF_QP2LAMBDA * (31 - (31 * (bitrate / 100.0)));
} else { } else {
codec_context->bit_rate = bitrate; codec_context->bit_rate = bitrate;
@ -246,15 +170,10 @@ void VideoStream::SetupCodec( int colours, int subpixelorder, int width, int hei
// some formats want stream headers to be separate // some formats want stream headers to be separate
if ( of->flags & AVFMT_GLOBALHEADER ) if ( of->flags & AVFMT_GLOBALHEADER )
#if LIBAVCODEC_VERSION_CHECK(56, 35, 0, 64, 0)
codec_context->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; codec_context->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
#else
codec_context->flags |= CODEC_FLAG_GLOBAL_HEADER;
#endif
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
avcodec_parameters_from_context(ost->codecpar, codec_context); avcodec_parameters_from_context(ost->codecpar, codec_context);
zm_dump_codecpar(ost->codecpar); zm_dump_codecpar(ost->codecpar);
#endif
} else { } else {
Fatal( "of->video_codec == AV_CODEC_ID_NONE" ); Fatal( "of->video_codec == AV_CODEC_ID_NONE" );
} }
@ -291,12 +210,8 @@ bool VideoStream::OpenStream( ) {
Debug(1,"Opening codec"); Debug(1,"Opening codec");
/* open the codec */ /* open the codec */
#if !LIBAVFORMAT_VERSION_CHECK(53, 8, 0, 8, 0)
if ( (ret = avcodec_open(codec_context, codec)) < 0 ) if ((ret = avcodec_open2(codec_context, codec, nullptr)) < 0) {
#else
if ( (ret = avcodec_open2(codec_context, codec, nullptr)) < 0 )
#endif
{
Error("Could not open codec. Error code %d \"%s\"", ret, av_err2str(ret)); Error("Could not open codec. Error code %d \"%s\"", ret, av_err2str(ret));
return false; return false;
} }
@ -313,11 +228,7 @@ bool VideoStream::OpenStream( ) {
opicture->height = codec_context->height; opicture->height = codec_context->height;
opicture->format = codec_context->pix_fmt; opicture->format = codec_context->pix_fmt;
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
int size = av_image_get_buffer_size(codec_context->pix_fmt, codec_context->width, codec_context->height, 1); int size = av_image_get_buffer_size(codec_context->pix_fmt, codec_context->width, codec_context->height, 1);
#else
int size = avpicture_get_size(codec_context->pix_fmt, codec_context->width, codec_context->height);
#endif
uint8_t *opicture_buf = (uint8_t *)av_malloc(size); uint8_t *opicture_buf = (uint8_t *)av_malloc(size);
if ( !opicture_buf ) { if ( !opicture_buf ) {
@ -325,59 +236,39 @@ bool VideoStream::OpenStream( ) {
Error( "Could not allocate opicture_buf" ); Error( "Could not allocate opicture_buf" );
return false; return false;
} }
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
av_image_fill_arrays(opicture->data, opicture->linesize, av_image_fill_arrays(opicture->data, opicture->linesize,
opicture_buf, codec_context->pix_fmt, codec_context->width, codec_context->height, 1); opicture_buf, codec_context->pix_fmt, codec_context->width, codec_context->height, 1);
#else
avpicture_fill( (AVPicture *)opicture, opicture_buf, codec_context->pix_fmt,
codec_context->width, codec_context->height );
#endif
/* if the output format is not identical to the input format, then a temporary /* if the output format is not identical to the input format, then a temporary
picture is needed too. It is then converted to the required picture is needed too. It is then converted to the required
output format */ output format */
tmp_opicture = nullptr; tmp_opicture = nullptr;
if ( codec_context->pix_fmt != pf ) { if ( codec_context->pix_fmt != pf ) {
#if LIBAVCODEC_VERSION_CHECK(55, 28, 1, 45, 101) tmp_opicture = av_frame_alloc();
tmp_opicture = av_frame_alloc( );
#else
tmp_opicture = avcodec_alloc_frame( );
#endif
if ( !tmp_opicture ) { if ( !tmp_opicture ) {
Error( "Could not allocate tmp_opicture" ); Error( "Could not allocate tmp_opicture" );
return false; return false;
} }
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
int size = av_image_get_buffer_size( pf, codec_context->width, codec_context->height,1 ); int size = av_image_get_buffer_size( pf, codec_context->width, codec_context->height,1 );
#else
int size = avpicture_get_size( pf, codec_context->width, codec_context->height );
#endif
uint8_t *tmp_opicture_buf = (uint8_t *)av_malloc( size ); uint8_t *tmp_opicture_buf = (uint8_t *)av_malloc( size );
if ( !tmp_opicture_buf ) { if ( !tmp_opicture_buf ) {
av_frame_free( &tmp_opicture ); av_frame_free( &tmp_opicture );
Error( "Could not allocate tmp_opicture_buf" ); Error( "Could not allocate tmp_opicture_buf" );
return false; return false;
} }
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
av_image_fill_arrays(tmp_opicture->data, av_image_fill_arrays(tmp_opicture->data,
tmp_opicture->linesize, tmp_opicture_buf, pf, tmp_opicture->linesize, tmp_opicture_buf, pf,
codec_context->width, codec_context->height, 1); codec_context->width, codec_context->height, 1);
#else
avpicture_fill( (AVPicture *)tmp_opicture,
tmp_opicture_buf, pf, codec_context->width, codec_context->height );
#endif
} }
} // end if ost } // end if ost
/* open the output file, if needed */ /* open the output file, if needed */
if ( !(of->flags & AVFMT_NOFILE) ) { if ( !(of->flags & AVFMT_NOFILE) ) {
#if LIBAVFORMAT_VERSION_CHECK(53, 15, 0, 21, 0)
ret = avio_open2( &ofc->pb, filename, AVIO_FLAG_WRITE, nullptr, nullptr ); ret = avio_open2( &ofc->pb, filename, AVIO_FLAG_WRITE, nullptr, nullptr );
#elif LIBAVFORMAT_VERSION_CHECK(52, 102, 0, 102, 0)
ret = avio_open( &ofc->pb, filename, AVIO_FLAG_WRITE );
#else
ret = url_fopen( &ofc->pb, filename, AVIO_FLAG_WRITE );
#endif
if ( ret < 0 ) { if ( ret < 0 ) {
Error("Could not open '%s'", filename); Error("Could not open '%s'", filename);
return false; return false;
@ -390,12 +281,8 @@ bool VideoStream::OpenStream( ) {
} }
video_outbuf = nullptr; video_outbuf = nullptr;
#if LIBAVFORMAT_VERSION_CHECK(57, 0, 0, 0, 0)
if (codec_context->codec_type == AVMEDIA_TYPE_VIDEO && if (codec_context->codec_type == AVMEDIA_TYPE_VIDEO &&
codec_context->codec_id == AV_CODEC_ID_RAWVIDEO) { codec_context->codec_id == AV_CODEC_ID_RAWVIDEO) {
#else
if ( !(of->flags & AVFMT_RAWPICTURE) ) {
#endif
/* allocate output buffer */ /* allocate output buffer */
/* XXX: API change will be done */ /* XXX: API change will be done */
// TODO: Make buffer dynamic. // TODO: Make buffer dynamic.
@ -406,17 +293,9 @@ bool VideoStream::OpenStream( ) {
} }
} }
#if LIBAVFORMAT_VERSION_CHECK(52, 101, 0, 101, 0)
av_dump_format(ofc, 0, filename, 1); av_dump_format(ofc, 0, filename, 1);
#else
dump_format(ofc, 0, filename, 1);
#endif
#if !LIBAVFORMAT_VERSION_CHECK(53, 2, 0, 4, 0)
ret = av_write_header(ofc);
#else
ret = avformat_write_header(ofc, nullptr); ret = avformat_write_header(ofc, nullptr);
#endif
if ( ret < 0 ) { if ( ret < 0 ) {
Error("?_write_header failed with error %d \"%s\"", ret, av_err2str(ret)); Error("?_write_header failed with error %d \"%s\"", ret, av_err2str(ret));
@ -531,11 +410,7 @@ VideoStream::~VideoStream( ) {
if ( !(of->flags & AVFMT_NOFILE) ) { if ( !(of->flags & AVFMT_NOFILE) ) {
/* close the output file */ /* close the output file */
#if LIBAVFORMAT_VERSION_CHECK(52, 105, 0, 105, 0)
avio_close( ofc->pb ); avio_close( ofc->pb );
#else
url_fclose( ofc->pb );
#endif
} }
/* free the stream */ /* free the stream */
@ -609,28 +484,18 @@ double VideoStream::ActuallyEncodeFrame( const uint8_t *buffer, int buffer_size,
AVPacket *pkt = packet_buffers[packet_index]; AVPacket *pkt = packet_buffers[packet_index];
av_init_packet( pkt ); av_init_packet( pkt );
int got_packet = 0; int got_packet = 0;
#if LIBAVFORMAT_VERSION_CHECK(57, 0, 0, 0, 0)
if (codec_context->codec_type == AVMEDIA_TYPE_VIDEO && if (codec_context->codec_type == AVMEDIA_TYPE_VIDEO &&
codec_context->codec_id == AV_CODEC_ID_RAWVIDEO) { codec_context->codec_id == AV_CODEC_ID_RAWVIDEO) {
#else
if ( of->flags & AVFMT_RAWPICTURE ) {
#endif
#if LIBAVCODEC_VERSION_CHECK(52, 30, 2, 30, 2)
pkt->flags |= AV_PKT_FLAG_KEY; pkt->flags |= AV_PKT_FLAG_KEY;
#else
pkt->flags |= PKT_FLAG_KEY;
#endif
pkt->stream_index = ost->index; pkt->stream_index = ost->index;
pkt->data = (uint8_t *)opicture_ptr; pkt->data = (uint8_t *)opicture_ptr;
pkt->size = sizeof (AVPicture); pkt->size = sizeof (AVPicture);
got_packet = 1; got_packet = 1;
} else { } else {
opicture_ptr->pts = codec_context->frame_number; opicture_ptr->pts = codec_context->frame_number;
opicture_ptr->quality = codec_context->global_quality; opicture_ptr->quality = codec_context->global_quality;
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
avcodec_send_frame(codec_context, opicture_ptr); avcodec_send_frame(codec_context, opicture_ptr);
int ret = avcodec_receive_packet(codec_context, pkt); int ret = avcodec_receive_packet(codec_context, pkt);
if ( ret < 0 ) { if ( ret < 0 ) {
@ -641,28 +506,11 @@ double VideoStream::ActuallyEncodeFrame( const uint8_t *buffer, int buffer_size,
} else { } else {
got_packet = 1; got_packet = 1;
} }
#else
#if LIBAVFORMAT_VERSION_CHECK(54, 1, 0, 2, 100)
int ret = avcodec_encode_video2( codec_context, pkt, opicture_ptr, &got_packet );
if ( ret != 0 ) {
Fatal( "avcodec_encode_video2 failed with errorcode %d \"%s\"", ret, av_err2str( ret ) );
}
#else
int out_size = avcodec_encode_video( codec_context, video_outbuf, video_outbuf_size, opicture_ptr );
got_packet = out_size > 0 ? 1 : 0;
pkt->data = got_packet ? video_outbuf : nullptr;
pkt->size = got_packet ? out_size : 0;
#endif
#endif
if ( got_packet ) { if ( got_packet ) {
// if ( c->coded_frame->key_frame ) // if ( c->coded_frame->key_frame )
// { // {
//#if LIBAVCODEC_VERSION_CHECK(52, 30, 2, 30, 2)
// pkt->flags |= AV_PKT_FLAG_KEY; // pkt->flags |= AV_PKT_FLAG_KEY;
//#else
// pkt->flags |= PKT_FLAG_KEY;
//#endif
// } // }
if ( pkt->pts != (int64_t)AV_NOPTS_VALUE ) { if ( pkt->pts != (int64_t)AV_NOPTS_VALUE ) {
@ -685,11 +533,7 @@ int VideoStream::SendPacket(AVPacket *packet) {
if ( ret != 0 ) { if ( ret != 0 ) {
Fatal( "Error %d while writing video frame: %s", ret, av_err2str( errno ) ); Fatal( "Error %d while writing video frame: %s", ret, av_err2str( errno ) );
} }
#if LIBAVCODEC_VERSION_CHECK(57, 8, 0, 12, 100)
av_packet_unref( packet ); av_packet_unref( packet );
#else
av_free_packet( packet );
#endif
return ret; return ret;
} }
@ -703,11 +547,8 @@ void *VideoStream::StreamingThreadCallback(void *ctx){
const uint64_t nanosecond_multiplier = 1000000000; const uint64_t nanosecond_multiplier = 1000000000;
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
uint64_t target_interval_ns = nanosecond_multiplier * ( ((double)videoStream->codec_context->time_base.num) / (videoStream->codec_context->time_base.den) ); uint64_t target_interval_ns = nanosecond_multiplier * ( ((double)videoStream->codec_context->time_base.num) / (videoStream->codec_context->time_base.den) );
#else
uint64_t target_interval_ns = nanosecond_multiplier * ( ((double)videoStream->codec_context->time_base.num) / (videoStream->codec_context->time_base.den) );
#endif
uint64_t frame_count = 0; uint64_t frame_count = 0;
timespec start_time; timespec start_time;
clock_gettime(CLOCK_MONOTONIC, &start_time); clock_gettime(CLOCK_MONOTONIC, &start_time);
@ -732,11 +573,8 @@ void *VideoStream::StreamingThreadCallback(void *ctx){
if (packet->size) { if (packet->size) {
videoStream->SendPacket(packet); videoStream->SendPacket(packet);
} }
#if LIBAVCODEC_VERSION_CHECK(57, 8, 0, 12, 100)
av_packet_unref( packet); av_packet_unref( packet);
#else
av_free_packet( packet );
#endif
videoStream->packet_index = videoStream->packet_index ? 0 : 1; videoStream->packet_index = videoStream->packet_index ? 0 : 1;
// Lock buffer and render next frame. // Lock buffer and render next frame.

View File

@ -257,7 +257,6 @@ AVFrame *ZMPacket::get_out_frame(int width, int height, AVPixelFormat format) {
return nullptr; return nullptr;
} }
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
int alignment = 32; int alignment = 32;
if (width%alignment) alignment = 1; if (width%alignment) alignment = 1;
@ -278,20 +277,7 @@ AVFrame *ZMPacket::get_out_frame(int width, int height, AVPixelFormat format) {
av_frame_free(&out_frame); av_frame_free(&out_frame);
return nullptr; return nullptr;
} }
#else
codec_imgsize = avpicture_get_size(
format,
width,
height);
buffer = (uint8_t *)av_malloc(codec_imgsize);
avpicture_fill(
(AVPicture *)out_frame,
buffer,
format,
width,
height
);
#endif
out_frame->width = width; out_frame->width = width;
out_frame->height = height; out_frame->height = height;
out_frame->format = format; out_frame->format = format;

View File

@ -173,12 +173,8 @@ int RemoteCameraRtsp::PrimeCapture() {
Debug(3, "Unable to locate audio stream"); Debug(3, "Unable to locate audio stream");
// Get a pointer to the codec context for the video stream // Get a pointer to the codec context for the video stream
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0) mVideoCodecContext = avcodec_alloc_context3(nullptr);
mVideoCodecContext = avcodec_alloc_context3(NULL);
avcodec_parameters_to_context(mVideoCodecContext, mFormatContext->streams[mVideoStreamId]->codecpar); avcodec_parameters_to_context(mVideoCodecContext, mFormatContext->streams[mVideoStreamId]->codecpar);
#else
mVideoCodecContext = mFormatContext->streams[mVideoStreamId]->codec;
#endif
// Find the decoder for the video stream // Find the decoder for the video stream
AVCodec *codec = avcodec_find_decoder(mVideoCodecContext->codec_id); AVCodec *codec = avcodec_find_decoder(mVideoCodecContext->codec_id);
@ -186,18 +182,10 @@ int RemoteCameraRtsp::PrimeCapture() {
Panic("Unable to locate codec %d decoder", mVideoCodecContext->codec_id); Panic("Unable to locate codec %d decoder", mVideoCodecContext->codec_id);
// Open codec // Open codec
#if !LIBAVFORMAT_VERSION_CHECK(53, 8, 0, 8, 0) if ( avcodec_open2(mVideoCodecContext, codec, nullptr) < 0 )
if ( avcodec_open(mVideoCodecContext, codec) < 0 )
#else
if ( avcodec_open2(mVideoCodecContext, codec, 0) < 0 )
#endif
Panic("Can't open codec"); Panic("Can't open codec");
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
int pSize = av_image_get_buffer_size(imagePixFormat, width, height, 1); int pSize = av_image_get_buffer_size(imagePixFormat, width, height, 1);
#else
int pSize = avpicture_get_size(imagePixFormat, width, height);
#endif
if ( (unsigned int)pSize != imagesize ) { if ( (unsigned int)pSize != imagesize ) {
Fatal("Image size mismatch. Required: %d Available: %llu", pSize, imagesize); Fatal("Image size mismatch. Required: %d Available: %llu", pSize, imagesize);
@ -281,25 +269,12 @@ int RemoteCameraRtsp::Capture(std::shared_ptr<ZMPacket> &zm_packet) {
buffer -= packet->size; buffer -= packet->size;
if ( bytes_consumed ) { if ( bytes_consumed ) {
zm_dump_video_frame(zm_packet->in_frame, "remote_rtsp_decode"); zm_dump_video_frame(zm_packet->in_frame, "remote_rtsp_decode");
if ( ! mVideoStream-> if (!mVideoStream->codecpar->width) {
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
codecpar
#else
codec
#endif
->width ) {
zm_dump_codec(mVideoCodecContext); zm_dump_codec(mVideoCodecContext);
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
zm_dump_codecpar(mVideoStream->codecpar); zm_dump_codecpar(mVideoStream->codecpar);
mVideoStream->codecpar->width = zm_packet->in_frame->width; mVideoStream->codecpar->width = zm_packet->in_frame->width;
mVideoStream->codecpar->height = zm_packet->in_frame->height; mVideoStream->codecpar->height = zm_packet->in_frame->height;
#else
mVideoStream->codec->width = zm_packet->in_frame->width;
mVideoStream->codec->height = zm_packet->in_frame->height;
#endif
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
zm_dump_codecpar(mVideoStream->codecpar); zm_dump_codecpar(mVideoStream->codecpar);
#endif
} }
zm_packet->codec_type = mVideoCodecContext->codec_type; zm_packet->codec_type = mVideoCodecContext->codec_type;
zm_packet->stream = mVideoStream; zm_packet->stream = mVideoStream;

View File

@ -186,11 +186,7 @@ RtspThread::~RtspThread() {
mThread.join(); mThread.join();
if ( mFormatContext ) { if ( mFormatContext ) {
#if LIBAVFORMAT_VERSION_CHECK(52, 96, 0, 96, 0)
avformat_free_context(mFormatContext); avformat_free_context(mFormatContext);
#else
av_free_format_context(mFormatContext);
#endif
mFormatContext = nullptr; mFormatContext = nullptr;
} }
if ( mSessDesc ) { if ( mSessDesc ) {
@ -396,14 +392,7 @@ void RtspThread::Run() {
if ( mFormatContext->nb_streams >= 1 ) { if ( mFormatContext->nb_streams >= 1 ) {
for ( unsigned int i = 0; i < mFormatContext->nb_streams; i++ ) { for ( unsigned int i = 0; i < mFormatContext->nb_streams; i++ ) {
SessionDescriptor::MediaDescriptor *mediaDesc = mSessDesc->getStream(i); SessionDescriptor::MediaDescriptor *mediaDesc = mSessDesc->getStream(i);
#if LIBAVFORMAT_VERSION_CHECK(57, 33, 0, 33, 0) if (mFormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
if ( mFormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO )
#elif (LIBAVCODEC_VERSION_CHECK(52, 64, 0, 64, 0) || LIBAVUTIL_VERSION_CHECK(50, 14, 0, 14, 0))
if ( mFormatContext->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO )
#else
if ( mFormatContext->streams[i]->codec->codec_type == CODEC_TYPE_VIDEO )
#endif
{
// Check if control Url is absolute or relative // Check if control Url is absolute or relative
controlUrl = mediaDesc->getControlUrl(); controlUrl = mediaDesc->getControlUrl();
if (trackUrl == controlUrl) { if (trackUrl == controlUrl) {
@ -416,11 +405,7 @@ void RtspThread::Run() {
} }
} }
rtpClock = mediaDesc->getClock(); rtpClock = mediaDesc->getClock();
#if LIBAVFORMAT_VERSION_CHECK(57, 33, 0, 33, 0)
codecId = mFormatContext->streams[i]->codecpar->codec_id; codecId = mFormatContext->streams[i]->codecpar->codec_id;
#else
codecId = mFormatContext->streams[i]->codec->codec_id;
#endif
break; break;
} // end if is video } // end if is video
} // end foreach stream } // end foreach stream

View File

@ -34,13 +34,7 @@ ADTS_ZoneMinderDeviceSource::ADTS_ZoneMinderDeviceSource(
: :
ZoneMinderDeviceSource(env, std::move(monitor), stream, queueSize), ZoneMinderDeviceSource(env, std::move(monitor), stream, queueSize),
samplingFrequencyIndex(0), samplingFrequencyIndex(0),
channels( channels(stream->codecpar->channels)
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
stream->codecpar->channels
#else
stream->codec->channels
#endif
)
{ {
std::ostringstream os; std::ostringstream os;
os << os <<

View File

@ -45,13 +45,7 @@ class ADTS_ZoneMinderDeviceSource : public ZoneMinderDeviceSource {
virtual unsigned char* findMarker(unsigned char *frame, size_t size, size_t &length); virtual unsigned char* findMarker(unsigned char *frame, size_t size, size_t &length);
*/ */
public: public:
int samplingFrequency() { return int samplingFrequency() { return m_stream->codecpar->sample_rate; };
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
m_stream->codecpar->sample_rate;
#else
m_stream->codec->sample_rate;
#endif
};
const char *configStr() { return config.c_str(); }; const char *configStr() { return config.c_str(); };
int numChannels() { int numChannels() {
return channels; return channels;

View File

@ -23,7 +23,6 @@
#include "zm_exception.h" #include "zm_exception.h"
#include "zm_logger.h" #include "zm_logger.h"
#if (LIBAVCODEC_VERSION_CHECK(52, 64, 0, 64, 0) || LIBAVUTIL_VERSION_CHECK(50, 14, 0, 14, 0))
SessionDescriptor::StaticPayloadDesc SessionDescriptor::smStaticPayloads[] = { SessionDescriptor::StaticPayloadDesc SessionDescriptor::smStaticPayloads[] = {
{ 0, "PCMU", AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_PCM_MULAW, 8000, 1 }, { 0, "PCMU", AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_PCM_MULAW, 8000, 1 },
{ 3, "GSM", AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_NONE, 8000, 1 }, { 3, "GSM", AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_NONE, 8000, 1 },
@ -61,45 +60,6 @@ SessionDescriptor::DynamicPayloadDesc SessionDescriptor::smDynamicPayloads[] = {
{ "AMR", AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_AMR_NB }, { "AMR", AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_AMR_NB },
{ "vnd.onvif.metadata", AVMEDIA_TYPE_DATA, AV_CODEC_ID_NONE } { "vnd.onvif.metadata", AVMEDIA_TYPE_DATA, AV_CODEC_ID_NONE }
}; };
#else
SessionDescriptor::StaticPayloadDesc SessionDescriptor::smStaticPayloads[] = {
{ 0, "PCMU", CODEC_TYPE_AUDIO, CODEC_ID_PCM_MULAW, 8001, 1 },
{ 3, "GSM", CODEC_TYPE_AUDIO, CODEC_ID_NONE, 8000, 1 },
{ 4, "G723", CODEC_TYPE_AUDIO, CODEC_ID_NONE, 8000, 1 },
{ 5, "DVI4", CODEC_TYPE_AUDIO, CODEC_ID_NONE, 8000, 1 },
{ 6, "DVI4", CODEC_TYPE_AUDIO, CODEC_ID_NONE, 16000, 1 },
{ 7, "LPC", CODEC_TYPE_AUDIO, CODEC_ID_NONE, 8000, 1 },
{ 8, "PCMA", CODEC_TYPE_AUDIO, CODEC_ID_PCM_ALAW, 8000, 1 },
{ 9, "G722", CODEC_TYPE_AUDIO, CODEC_ID_NONE, 8000, 1 },
{ 10, "L16", CODEC_TYPE_AUDIO, CODEC_ID_PCM_S16BE, 44100, 2 },
{ 11, "L16", CODEC_TYPE_AUDIO, CODEC_ID_PCM_S16BE, 44100, 1 },
{ 12, "QCELP", CODEC_TYPE_AUDIO, CODEC_ID_QCELP, 8000, 1 },
{ 13, "CN", CODEC_TYPE_AUDIO, CODEC_ID_NONE, 8000, 1 },
{ 14, "MPA", CODEC_TYPE_AUDIO, CODEC_ID_MP2, -1, -1 },
{ 14, "MPA", CODEC_TYPE_AUDIO, CODEC_ID_MP3, -1, -1 },
{ 15, "G728", CODEC_TYPE_AUDIO, CODEC_ID_NONE, 8000, 1 },
{ 16, "DVI4", CODEC_TYPE_AUDIO, CODEC_ID_NONE, 11025, 1 },
{ 17, "DVI4", CODEC_TYPE_AUDIO, CODEC_ID_NONE, 22050, 1 },
{ 18, "G729", CODEC_TYPE_AUDIO, CODEC_ID_NONE, 8000, 1 },
{ 25, "CelB", CODEC_TYPE_VIDEO, CODEC_ID_NONE, 90000, -1 },
{ 26, "JPEG", CODEC_TYPE_VIDEO, CODEC_ID_MJPEG, 90000, -1 },
{ 28, "nv", CODEC_TYPE_VIDEO, CODEC_ID_NONE, 90000, -1 },
{ 31, "H261", CODEC_TYPE_VIDEO, CODEC_ID_H261, 90000, -1 },
{ 32, "MPV", CODEC_TYPE_VIDEO, CODEC_ID_MPEG1VIDEO, 90000, -1 },
{ 32, "MPV", CODEC_TYPE_VIDEO, CODEC_ID_MPEG2VIDEO, 90000, -1 },
{ 33, "MP2T", CODEC_TYPE_DATA, CODEC_ID_MPEG2TS, 90000, -1 },
{ 34, "H263", CODEC_TYPE_VIDEO, CODEC_ID_H263, 90000, -1 },
{ -1, "", CODEC_TYPE_UNKNOWN, CODEC_ID_NONE, -1, -1 }
};
SessionDescriptor::DynamicPayloadDesc SessionDescriptor::smDynamicPayloads[] = {
{ "MP4V-ES", CODEC_TYPE_VIDEO, CODEC_ID_MPEG4 },
{ "mpeg4-generic", CODEC_TYPE_AUDIO, CODEC_ID_AAC },
{ "H264", CODEC_TYPE_VIDEO, CODEC_ID_H264 },
{ "AMR", CODEC_TYPE_AUDIO, CODEC_ID_AMR_NB },
{ "vnd.onvif.metadata", CODEC_TYPE_DATA, CODEC_ID_NONE }
};
#endif
SessionDescriptor::ConnInfo::ConnInfo( const std::string &connInfo ) : SessionDescriptor::ConnInfo::ConnInfo( const std::string &connInfo ) :
mTtl( 16 ), mTtl( 16 ),
@ -341,53 +301,30 @@ AVFormatContext *SessionDescriptor::generateFormatContext() const {
//formatContext->nb_streams = mMediaList.size(); //formatContext->nb_streams = mMediaList.size();
for ( unsigned int i = 0; i < mMediaList.size(); i++ ) { for ( unsigned int i = 0; i < mMediaList.size(); i++ ) {
const MediaDescriptor *mediaDesc = mMediaList[i]; const MediaDescriptor *mediaDesc = mMediaList[i];
#if !LIBAVFORMAT_VERSION_CHECK(53, 10, 0, 17, 0)
AVStream *stream = av_new_stream(formatContext, i);
#else
AVStream *stream = avformat_new_stream(formatContext, nullptr); AVStream *stream = avformat_new_stream(formatContext, nullptr);
stream->id = i; stream->id = i;
#endif
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
AVCodecContext *codec_context = avcodec_alloc_context3(nullptr); AVCodecContext *codec_context = avcodec_alloc_context3(nullptr);
#else
AVCodecContext *codec_context = stream->codec;
#endif
std::string type = mediaDesc->getType(); std::string type = mediaDesc->getType();
Debug(1, "Looking for codec for %s payload type %d / %s", Debug(1, "Looking for codec for %s payload type %d / %s",
type.c_str(), mediaDesc->getPayloadType(), mediaDesc->getPayloadDesc().c_str()); type.c_str(), mediaDesc->getPayloadType(), mediaDesc->getPayloadDesc().c_str());
#if (LIBAVCODEC_VERSION_CHECK(52, 64, 0, 64, 0) || LIBAVUTIL_VERSION_CHECK(50, 14, 0, 14, 0))
if ( type == "video" ) if ( type == "video" )
codec_context->codec_type = AVMEDIA_TYPE_VIDEO; codec_context->codec_type = AVMEDIA_TYPE_VIDEO;
else if ( type == "audio" ) else if ( type == "audio" )
codec_context->codec_type = AVMEDIA_TYPE_AUDIO; codec_context->codec_type = AVMEDIA_TYPE_AUDIO;
else if ( type == "application" ) else if ( type == "application" )
codec_context->codec_type = AVMEDIA_TYPE_DATA; codec_context->codec_type = AVMEDIA_TYPE_DATA;
#else
if ( type == "video" )
codec_context->codec_type = CODEC_TYPE_VIDEO;
else if ( type == "audio" )
codec_context->codec_type = CODEC_TYPE_AUDIO;
else if ( type == "application" )
codec_context->codec_type = CODEC_TYPE_DATA;
#endif
else else
Warning("Unknown media_type %s", type.c_str()); Warning("Unknown media_type %s", type.c_str());
#if LIBAVCODEC_VERSION_CHECK(55, 50, 3, 60, 103)
std::string codec_name; std::string codec_name;
#endif
if ( mediaDesc->getPayloadType() < PAYLOAD_TYPE_DYNAMIC ) { if ( mediaDesc->getPayloadType() < PAYLOAD_TYPE_DYNAMIC ) {
// Look in static table // Look in static table
for ( unsigned int j = 0; j < (sizeof(smStaticPayloads)/sizeof(*smStaticPayloads)); j++ ) { for ( unsigned int j = 0; j < (sizeof(smStaticPayloads)/sizeof(*smStaticPayloads)); j++ ) {
if ( smStaticPayloads[j].payloadType == mediaDesc->getPayloadType() ) { if ( smStaticPayloads[j].payloadType == mediaDesc->getPayloadType() ) {
Debug( 1, "Got static payload type %d, %s", smStaticPayloads[j].payloadType, smStaticPayloads[j].payloadName ); Debug( 1, "Got static payload type %d, %s", smStaticPayloads[j].payloadType, smStaticPayloads[j].payloadName );
#if LIBAVCODEC_VERSION_CHECK(55, 50, 3, 60, 103)
codec_name = std::string(smStaticPayloads[j].payloadName); codec_name = std::string(smStaticPayloads[j].payloadName);
#else
strncpy(codec_context->codec_name, smStaticPayloads[j].payloadName, sizeof(codec_context->codec_name));
#endif
codec_context->codec_type = smStaticPayloads[j].codecType; codec_context->codec_type = smStaticPayloads[j].codecType;
codec_context->codec_id = smStaticPayloads[j].codecId; codec_context->codec_id = smStaticPayloads[j].codecId;
codec_context->sample_rate = smStaticPayloads[j].clockRate; codec_context->sample_rate = smStaticPayloads[j].clockRate;
@ -399,11 +336,7 @@ AVFormatContext *SessionDescriptor::generateFormatContext() const {
for ( unsigned int j = 0; j < (sizeof(smDynamicPayloads)/sizeof(*smDynamicPayloads)); j++ ) { for ( unsigned int j = 0; j < (sizeof(smDynamicPayloads)/sizeof(*smDynamicPayloads)); j++ ) {
if ( smDynamicPayloads[j].payloadName == mediaDesc->getPayloadDesc() ) { if ( smDynamicPayloads[j].payloadName == mediaDesc->getPayloadDesc() ) {
Debug(1, "Got dynamic payload type %d, %s", mediaDesc->getPayloadType(), smDynamicPayloads[j].payloadName); Debug(1, "Got dynamic payload type %d, %s", mediaDesc->getPayloadType(), smDynamicPayloads[j].payloadName);
#if LIBAVCODEC_VERSION_CHECK(55, 50, 3, 60, 103)
codec_name = std::string(smStaticPayloads[j].payloadName); codec_name = std::string(smStaticPayloads[j].payloadName);
#else
strncpy(codec_context->codec_name, smDynamicPayloads[j].payloadName, sizeof(codec_context->codec_name));
#endif
codec_context->codec_type = smDynamicPayloads[j].codecType; codec_context->codec_type = smDynamicPayloads[j].codecType;
codec_context->codec_id = smDynamicPayloads[j].codecId; codec_context->codec_id = smDynamicPayloads[j].codecId;
codec_context->sample_rate = mediaDesc->getClock(); codec_context->sample_rate = mediaDesc->getClock();
@ -413,12 +346,7 @@ AVFormatContext *SessionDescriptor::generateFormatContext() const {
} /// end if static or dynamic } /// end if static or dynamic
#if LIBAVCODEC_VERSION_CHECK(55, 50, 3, 60, 103) if (codec_name.empty()) {
if ( codec_name.empty() )
#else
if ( !stream->codec->codec_name[0] )
#endif
{
Warning( "Can't find payload details for %s payload type %d, name %s", Warning( "Can't find payload details for %s payload type %d, name %s",
mediaDesc->getType().c_str(), mediaDesc->getPayloadType(), mediaDesc->getPayloadDesc().c_str() ); mediaDesc->getType().c_str(), mediaDesc->getPayloadType(), mediaDesc->getPayloadDesc().c_str() );
} }
@ -452,15 +380,9 @@ AVFormatContext *SessionDescriptor::generateFormatContext() const {
packet_size = av_base64_decode(decoded_packet, (const char *)base64packet, (int)sizeof(decoded_packet)); packet_size = av_base64_decode(decoded_packet, (const char *)base64packet, (int)sizeof(decoded_packet));
Hexdump(4, (char *)decoded_packet, packet_size); Hexdump(4, (char *)decoded_packet, packet_size);
if ( packet_size ) { if ( packet_size ) {
uint8_t *dest = uint8_t *dest =
(uint8_t *)av_malloc(packet_size + sizeof(start_sequence) + (uint8_t *) av_malloc(
codec_context->extradata_size + packet_size + sizeof(start_sequence) + codec_context->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
#if LIBAVCODEC_VERSION_CHECK(57, 0, 0, 0, 0)
AV_INPUT_BUFFER_PADDING_SIZE
#else
FF_INPUT_BUFFER_PADDING_SIZE
#endif
);
if ( dest ) { if ( dest ) {
if ( codec_context->extradata_size ) { if ( codec_context->extradata_size ) {
// av_realloc? // av_realloc?
@ -472,11 +394,7 @@ AVFormatContext *SessionDescriptor::generateFormatContext() const {
memcpy(dest+codec_context->extradata_size+sizeof(start_sequence), decoded_packet, packet_size); memcpy(dest+codec_context->extradata_size+sizeof(start_sequence), decoded_packet, packet_size);
memset(dest+codec_context->extradata_size+sizeof(start_sequence)+ memset(dest+codec_context->extradata_size+sizeof(start_sequence)+
packet_size, 0, packet_size, 0,
#if LIBAVCODEC_VERSION_CHECK(57, 0, 0, 0, 0)
AV_INPUT_BUFFER_PADDING_SIZE AV_INPUT_BUFFER_PADDING_SIZE
#else
FF_INPUT_BUFFER_PADDING_SIZE
#endif
); );
codec_context->extradata= dest; codec_context->extradata= dest;
@ -488,9 +406,7 @@ AVFormatContext *SessionDescriptor::generateFormatContext() const {
} }
} }
} }
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
avcodec_parameters_from_context(stream->codecpar, codec_context); avcodec_parameters_from_context(stream->codecpar, codec_context);
#endif
} // end foreach mediaList } // end foreach mediaList
return formatContext; return formatContext;

View File

@ -32,11 +32,7 @@ protected:
struct StaticPayloadDesc { struct StaticPayloadDesc {
int payloadType; int payloadType;
const char payloadName[6]; const char payloadName[6];
#if (LIBAVCODEC_VERSION_CHECK(52, 64, 0, 64, 0) || LIBAVUTIL_VERSION_CHECK(50, 14, 0, 14, 0))
AVMediaType codecType; AVMediaType codecType;
#else
enum CodecType codecType;
#endif
_AVCODECID codecId; _AVCODECID codecId;
int clockRate; int clockRate;
int autoChannels; int autoChannels;
@ -44,11 +40,7 @@ protected:
struct DynamicPayloadDesc { struct DynamicPayloadDesc {
const char payloadName[32]; const char payloadName[32];
#if (LIBAVCODEC_VERSION_CHECK(52, 64, 0, 64, 0) || LIBAVUTIL_VERSION_CHECK(50, 14, 0, 14, 0))
AVMediaType codecType; AVMediaType codecType;
#else
enum CodecType codecType;
#endif
_AVCODECID codecId; _AVCODECID codecId;
//int clockRate; //int clockRate;

View File

@ -27,24 +27,14 @@ SWScale::SWScale() : gotdefaults(false), swscale_ctx(nullptr), input_avframe(nul
} }
bool SWScale::init() { bool SWScale::init() {
/* Allocate AVFrame for the input */
#if LIBAVCODEC_VERSION_CHECK(55, 28, 1, 45, 101)
input_avframe = av_frame_alloc(); input_avframe = av_frame_alloc();
#else if (!input_avframe) {
input_avframe = avcodec_alloc_frame();
#endif
if ( input_avframe == nullptr ) {
Error("Failed allocating AVFrame for the input"); Error("Failed allocating AVFrame for the input");
return false; return false;
} }
/* Allocate AVFrame for the output */
#if LIBAVCODEC_VERSION_CHECK(55, 28, 1, 45, 101)
output_avframe = av_frame_alloc(); output_avframe = av_frame_alloc();
#else if (!output_avframe) {
output_avframe = avcodec_alloc_frame();
#endif
if ( output_avframe == nullptr ) {
Error("Failed allocating AVFrame for the output"); Error("Failed allocating AVFrame for the output");
return false; return false;
} }
@ -146,7 +136,6 @@ int SWScale::Convert(
in_pf = fix_deprecated_pix_fmt(in_pf); in_pf = fix_deprecated_pix_fmt(in_pf);
#if LIBSWSCALE_VERSION_CHECK(0, 8, 0, 8, 0)
/* Warn if the input or output pixelformat is not supported */ /* Warn if the input or output pixelformat is not supported */
if (!sws_isSupportedInput(in_pf)) { if (!sws_isSupportedInput(in_pf)) {
Warning("swscale does not support the input format: %c%c%c%c", Warning("swscale does not support the input format: %c%c%c%c",
@ -156,7 +145,6 @@ int SWScale::Convert(
Warning("swscale does not support the output format: %c%c%c%c", Warning("swscale does not support the output format: %c%c%c%c",
(out_pf)&0xff,((out_pf>>8)&0xff),((out_pf>>16)&0xff),((out_pf>>24)&0xff)); (out_pf)&0xff,((out_pf>>8)&0xff),((out_pf>>16)&0xff),((out_pf>>24)&0xff));
} }
#endif
int alignment = width % 32 ? 1 : 32; int alignment = width % 32 ? 1 : 32;
/* Check the buffer sizes */ /* Check the buffer sizes */
@ -197,23 +185,13 @@ int SWScale::Convert(
output_avframe->height = new_height; output_avframe->height = new_height;
*/ */
/* Fill in the buffers */ /* Fill in the buffers */
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
if (av_image_fill_arrays(input_avframe->data, input_avframe->linesize, if (av_image_fill_arrays(input_avframe->data, input_avframe->linesize,
(uint8_t*) in_buffer, in_pf, width, height, alignment) <= 0) { (uint8_t*) in_buffer, in_pf, width, height, alignment) <= 0) {
#else
if (avpicture_fill((AVPicture*) input_avframe, (uint8_t*) in_buffer,
in_pf, width, height) <= 0) {
#endif
Error("Failed filling input frame with input buffer"); Error("Failed filling input frame with input buffer");
return -7; return -7;
} }
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
if (av_image_fill_arrays(output_avframe->data, output_avframe->linesize, if (av_image_fill_arrays(output_avframe->data, output_avframe->linesize,
out_buffer, out_pf, new_width, new_height, alignment) <= 0) { out_buffer, out_pf, new_width, new_height, alignment) <= 0) {
#else
if (avpicture_fill((AVPicture*) output_avframe, out_buffer, out_pf, new_width,
new_height) <= 0) {
#endif
Error("Failed filling output frame with output buffer"); Error("Failed filling output frame with output buffer");
return -8; return -8;
} }
@ -284,9 +262,5 @@ int SWScale::ConvertDefaults(const uint8_t* in_buffer, const size_t in_buffer_si
} }
size_t SWScale::GetBufferSize(enum _AVPIXELFORMAT pf, unsigned int width, unsigned int height) { size_t SWScale::GetBufferSize(enum _AVPIXELFORMAT pf, unsigned int width, unsigned int height) {
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
return av_image_get_buffer_size(pf, width, height, 1); return av_image_get_buffer_size(pf, width, height, 1);
#else
return outsize = avpicture_get_size(pf, width,height);
#endif
} }

View File

@ -152,9 +152,7 @@ bool VideoStore::open() {
} }
if (video_in_stream) { if (video_in_stream) {
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
zm_dump_codecpar(video_in_stream->codecpar); zm_dump_codecpar(video_in_stream->codecpar);
#endif
if (monitor->GetOptVideoWriter() == Monitor::PASSTHROUGH) { if (monitor->GetOptVideoWriter() == Monitor::PASSTHROUGH) {
video_out_stream = avformat_new_stream(oc, nullptr); video_out_stream = avformat_new_stream(oc, nullptr);
@ -163,9 +161,8 @@ bool VideoStore::open() {
return false; return false;
} }
avcodec_parameters_copy(video_out_stream->codecpar, video_in_stream->codecpar); avcodec_parameters_copy(video_out_stream->codecpar, video_in_stream->codecpar);
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
zm_dump_codecpar(video_out_stream->codecpar); zm_dump_codecpar(video_out_stream->codecpar);
#endif
video_out_stream->avg_frame_rate = video_in_stream->avg_frame_rate; video_out_stream->avg_frame_rate = video_in_stream->avg_frame_rate;
// Only set orientation if doing passthrough, otherwise the frame image will be rotated // Only set orientation if doing passthrough, otherwise the frame image will be rotated
Monitor::Orientation orientation = monitor->getOrientation(); Monitor::Orientation orientation = monitor->getOrientation();
@ -192,22 +189,15 @@ bool VideoStore::open() {
video_out_codec = avcodec_find_encoder(video_in_stream->codecpar->codec_id); video_out_codec = avcodec_find_encoder(video_in_stream->codecpar->codec_id);
if (video_out_codec) { if (video_out_codec) {
video_out_ctx = avcodec_alloc_context3(video_out_codec); video_out_ctx = avcodec_alloc_context3(video_out_codec);
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
ret = avcodec_parameters_to_context(video_out_ctx, video_in_stream->codecpar); ret = avcodec_parameters_to_context(video_out_ctx, video_in_stream->codecpar);
#else
ret = avcodec_copy_context(video_out_ctx, video_in_ctx);
#endif
if (ret < 0) { if (ret < 0) {
Error("Could not initialize ctx parameters"); Error("Could not initialize ctx parameters");
return false; return false;
} }
//video_out_ctx->pix_fmt = fix_deprecated_pix_fmt(video_out_ctx->pix_fmt); //video_out_ctx->pix_fmt = fix_deprecated_pix_fmt(video_out_ctx->pix_fmt);
if (oc->oformat->flags & AVFMT_GLOBALHEADER) { if (oc->oformat->flags & AVFMT_GLOBALHEADER) {
#if LIBAVCODEC_VERSION_CHECK(56, 35, 0, 64, 0)
video_out_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; video_out_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
#else
video_out_ctx->flags |= CODEC_FLAG_GLOBAL_HEADER;
#endif
} }
video_out_ctx->time_base = video_in_ctx->time_base; video_out_ctx->time_base = video_in_ctx->time_base;
if (!(video_out_ctx->time_base.num && video_out_ctx->time_base.den)) { if (!(video_out_ctx->time_base.num && video_out_ctx->time_base.den)) {
@ -234,14 +224,11 @@ bool VideoStore::open() {
video_out_codec = nullptr; video_out_codec = nullptr;
} }
} // end if video_out_codec } // end if video_out_codec
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
ret = avcodec_parameters_from_context(video_out_stream->codecpar, video_out_ctx); ret = avcodec_parameters_from_context(video_out_stream->codecpar, video_out_ctx);
if (ret < 0) { if (ret < 0) {
Error("Could not initialize stream parameteres"); Error("Could not initialize stream parameteres");
} }
#else
avcodec_copy_context(video_out_stream->codec, video_out_ctx);
#endif
} // end if extradata_entry } // end if extradata_entry
av_dict_free(&opts); av_dict_free(&opts);
} else if (monitor->GetOptVideoWriter() == Monitor::ENCODE) { } else if (monitor->GetOptVideoWriter() == Monitor::ENCODE) {
@ -286,11 +273,7 @@ bool VideoStore::open() {
Debug(1, "Found video codec for %s", codec_data[i].codec_name); Debug(1, "Found video codec for %s", codec_data[i].codec_name);
video_out_ctx = avcodec_alloc_context3(video_out_codec); video_out_ctx = avcodec_alloc_context3(video_out_codec);
if (oc->oformat->flags & AVFMT_GLOBALHEADER) { if (oc->oformat->flags & AVFMT_GLOBALHEADER) {
#if LIBAVCODEC_VERSION_CHECK(56, 35, 0, 64, 0)
video_out_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; video_out_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
#else
video_out_ctx->flags |= CODEC_FLAG_GLOBAL_HEADER;
#endif
} }
// When encoding, we are going to use the timestamp values instead of packet pts/dts // When encoding, we are going to use the timestamp values instead of packet pts/dts
@ -377,12 +360,14 @@ bool VideoStore::open() {
Warning("Encoder Option %s not recognized by ffmpeg codec", e->key); Warning("Encoder Option %s not recognized by ffmpeg codec", e->key);
} }
av_dict_free(&opts); av_dict_free(&opts);
if (video_out_codec) break; if (video_out_codec) {
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0) break;
}
// We allocate and copy in newer ffmpeg, so need to free it // We allocate and copy in newer ffmpeg, so need to free it
avcodec_free_context(&video_out_ctx); avcodec_free_context(&video_out_ctx);
if (hw_device_ctx) av_buffer_unref(&hw_device_ctx); if (hw_device_ctx) {
#endif av_buffer_unref(&hw_device_ctx);
}
} // end foreach codec } // end foreach codec
if (!video_out_codec) { if (!video_out_codec) {
@ -392,17 +377,12 @@ bool VideoStore::open() {
Debug(2, "Success opening codec"); Debug(2, "Success opening codec");
video_out_stream = avformat_new_stream(oc, nullptr); video_out_stream = avformat_new_stream(oc, nullptr);
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
ret = avcodec_parameters_from_context(video_out_stream->codecpar, video_out_ctx); ret = avcodec_parameters_from_context(video_out_stream->codecpar, video_out_ctx);
if (ret < 0) { if (ret < 0) {
Error("Could not initialize stream parameteres"); Error("Could not initialize stream parameteres");
return false; return false;
} }
#else
avcodec_copy_context(video_out_stream->codec, video_out_ctx);
#endif
} // end if copying or transcoding } // end if copying or transcoding
// zm_dump_codec(video_out_ctx);
} // end if video_in_stream } // end if video_in_stream
max_stream_index = video_out_stream->index; max_stream_index = video_out_stream->index;
@ -416,24 +396,16 @@ bool VideoStore::open() {
if (!audio_out_codec) { if (!audio_out_codec) {
Error("Could not find codec for AAC"); Error("Could not find codec for AAC");
} else { } else {
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
audio_in_ctx = avcodec_alloc_context3(audio_out_codec); audio_in_ctx = avcodec_alloc_context3(audio_out_codec);
ret = avcodec_parameters_to_context(audio_in_ctx, ret = avcodec_parameters_to_context(audio_in_ctx, audio_in_stream->codecpar);
audio_in_stream->codecpar);
audio_in_ctx->time_base = audio_in_stream->time_base; audio_in_ctx->time_base = audio_in_stream->time_base;
#else
audio_in_ctx = audio_in_stream->codec;
#endif
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
audio_out_ctx = avcodec_alloc_context3(audio_out_codec); audio_out_ctx = avcodec_alloc_context3(audio_out_codec);
if (!audio_out_ctx) { if (!audio_out_ctx) {
Error("could not allocate codec ctx for AAC"); Error("could not allocate codec ctx for AAC");
return false; return false;
} }
#else
audio_out_ctx = audio_out_stream->codec;
#endif
audio_out_stream = avformat_new_stream(oc, audio_out_codec); audio_out_stream = avformat_new_stream(oc, audio_out_codec);
audio_out_stream->time_base = audio_in_stream->time_base; audio_out_stream->time_base = audio_in_stream->time_base;
@ -453,7 +425,6 @@ bool VideoStore::open() {
} }
audio_out_stream->time_base = audio_in_stream->time_base; audio_out_stream->time_base = audio_in_stream->time_base;
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
// Just use the ctx to copy the parameters over // Just use the ctx to copy the parameters over
audio_out_ctx = avcodec_alloc_context3(audio_out_codec); audio_out_ctx = avcodec_alloc_context3(audio_out_codec);
if (!audio_out_ctx) { if (!audio_out_ctx) {
@ -477,17 +448,6 @@ bool VideoStore::open() {
Error("Unable to copy audio params to stream %s", Error("Unable to copy audio params to stream %s",
av_make_error_string(ret).c_str()); av_make_error_string(ret).c_str());
} }
#else
audio_out_ctx = audio_out_stream->codec;
ret = avcodec_copy_context(audio_out_ctx, audio_in_stream->codec);
if (ret < 0) {
Error("Unable to copy audio ctx %s",
av_make_error_string(ret).c_str());
audio_out_stream = nullptr;
return false;
} // end if
audio_out_ctx->codec_tag = 0;
#endif
if (audio_out_ctx->channels > 1) { if (audio_out_ctx->channels > 1) {
Warning("Audio isn't mono, changing it."); Warning("Audio isn't mono, changing it.");
@ -498,11 +458,7 @@ bool VideoStore::open() {
} // end if is AAC } // end if is AAC
if (oc->oformat->flags & AVFMT_GLOBALHEADER) { if (oc->oformat->flags & AVFMT_GLOBALHEADER) {
#if LIBAVCODEC_VERSION_CHECK(56, 35, 0, 64, 0)
audio_out_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; audio_out_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
#else
audio_out_ctx->flags |= CODEC_FLAG_GLOBAL_HEADER;
#endif
} }
// We will assume that subsequent stream allocations will increase the index // We will assume that subsequent stream allocations will increase the index
@ -572,13 +528,7 @@ void VideoStore::flush_codecs() {
av_init_packet(&pkt); av_init_packet(&pkt);
// I got crashes if the codec didn't do DELAY, so let's test for it. // I got crashes if the codec didn't do DELAY, so let's test for it.
if (video_out_ctx && video_out_ctx->codec && ( video_out_ctx->codec->capabilities & if (video_out_ctx && video_out_ctx->codec && (video_out_ctx->codec->capabilities & AV_CODEC_CAP_DELAY)) {
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
AV_CODEC_CAP_DELAY
#else
CODEC_CAP_DELAY
#endif
)) {
// Put encoder into flushing mode // Put encoder into flushing mode
while ((zm_send_frame_receive_packet(video_out_ctx, nullptr, pkt)) > 0) { while ((zm_send_frame_receive_packet(video_out_ctx, nullptr, pkt)) > 0) {
av_packet_rescale_ts(&pkt, av_packet_rescale_ts(&pkt,
@ -637,12 +587,10 @@ void VideoStore::flush_codecs() {
} // end if data returned from fifo } // end if data returned from fifo
} // end while still data in the fifo } // end while still data in the fifo
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
// Put encoder into flushing mode // Put encoder into flushing mode
avcodec_send_frame(audio_out_ctx, nullptr); avcodec_send_frame(audio_out_ctx, nullptr);
#endif
while (1) { while (true) {
if (0 >= zm_receive_packet(audio_out_ctx, pkt)) { if (0 >= zm_receive_packet(audio_out_ctx, pkt)) {
Debug(1, "No more packets"); Debug(1, "No more packets");
break; break;
@ -705,19 +653,12 @@ VideoStore::~VideoStore() {
} }
if (audio_out_stream) { if (audio_out_stream) {
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
// We allocate and copy in newer ffmpeg, so need to free it
//avcodec_free_context(&audio_in_ctx);
#endif
//Debug(4, "Success freeing audio_in_ctx");
audio_in_codec = nullptr; audio_in_codec = nullptr;
if (audio_out_ctx) { if (audio_out_ctx) {
Debug(4, "Success closing audio_out_ctx"); Debug(4, "Success closing audio_out_ctx");
avcodec_close(audio_out_ctx); avcodec_close(audio_out_ctx);
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
avcodec_free_context(&audio_out_ctx); avcodec_free_context(&audio_out_ctx);
#endif
} }
if (resample_ctx) { if (resample_ctx) {
@ -751,7 +692,6 @@ VideoStore::~VideoStore() {
bool VideoStore::setup_resampler() { bool VideoStore::setup_resampler() {
int ret; int ret;
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
// Newer ffmpeg wants to keep everything separate... so have to lookup our own // Newer ffmpeg wants to keep everything separate... so have to lookup our own
// decoder, can't reuse the one from the camera. // decoder, can't reuse the one from the camera.
audio_in_codec = avcodec_find_decoder(audio_in_stream->codecpar->codec_id); audio_in_codec = avcodec_find_decoder(audio_in_stream->codecpar->codec_id);
@ -762,17 +702,6 @@ bool VideoStore::setup_resampler() {
Error("Unable to copy audio params to ctx %s", Error("Unable to copy audio params to ctx %s",
av_make_error_string(ret).c_str()); av_make_error_string(ret).c_str());
} }
#else
// codec is already open in ffmpeg_camera
audio_in_ctx = audio_in_stream->codec;
audio_in_codec = reinterpret_cast<const AVCodec *>(audio_in_ctx->codec);
if (!audio_in_codec) {
audio_in_codec = avcodec_find_decoder(audio_in_stream->codec->codec_id);
if (!audio_in_codec) {
return false;
}
}
#endif
// if the codec is already open, nothing is done. // if the codec is already open, nothing is done.
if ((ret = avcodec_open2(audio_in_ctx, audio_in_codec, nullptr)) < 0) { if ((ret = avcodec_open2(audio_in_ctx, audio_in_codec, nullptr)) < 0) {
@ -796,7 +725,6 @@ bool VideoStore::setup_resampler() {
audio_out_ctx->channels = audio_in_ctx->channels; audio_out_ctx->channels = audio_in_ctx->channels;
audio_out_ctx->channel_layout = audio_in_ctx->channel_layout; audio_out_ctx->channel_layout = audio_in_ctx->channel_layout;
audio_out_ctx->sample_fmt = audio_in_ctx->sample_fmt; audio_out_ctx->sample_fmt = audio_in_ctx->sample_fmt;
#if LIBAVCODEC_VERSION_CHECK(56, 8, 0, 60, 100)
if (!audio_out_ctx->channel_layout) { if (!audio_out_ctx->channel_layout) {
Debug(3, "Correcting channel layout from (%" PRIi64 ") to (%" PRIi64 ")", Debug(3, "Correcting channel layout from (%" PRIi64 ") to (%" PRIi64 ")",
audio_out_ctx->channel_layout, audio_out_ctx->channel_layout,
@ -804,7 +732,7 @@ bool VideoStore::setup_resampler() {
); );
audio_out_ctx->channel_layout = av_get_default_channel_layout(audio_out_ctx->channels); audio_out_ctx->channel_layout = av_get_default_channel_layout(audio_out_ctx->channels);
} }
#endif
if (audio_out_codec->supported_samplerates) { if (audio_out_codec->supported_samplerates) {
int found = 0; int found = 0;
for (unsigned int i = 0; audio_out_codec->supported_samplerates[i]; i++) { for (unsigned int i = 0; audio_out_codec->supported_samplerates[i]; i++) {
@ -851,15 +779,11 @@ bool VideoStore::setup_resampler() {
zm_dump_codec(audio_out_ctx); zm_dump_codec(audio_out_ctx);
audio_out_stream->time_base = (AVRational){1, audio_out_ctx->sample_rate}; audio_out_stream->time_base = (AVRational){1, audio_out_ctx->sample_rate};
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0) if ((ret = avcodec_parameters_from_context(audio_out_stream->codecpar, audio_out_ctx)) < 0) {
if ( (ret = avcodec_parameters_from_context(
audio_out_stream->codecpar,
audio_out_ctx)) < 0 ) {
Error("Could not initialize stream parameteres"); Error("Could not initialize stream parameteres");
return false; return false;
} }
zm_dump_codecpar(audio_out_stream->codecpar); zm_dump_codecpar(audio_out_stream->codecpar);
#endif
Debug(3, Debug(3,
"Time bases: AUDIO in stream (%d/%d) in codec: (%d/%d) out " "Time bases: AUDIO in stream (%d/%d) in codec: (%d/%d) out "
@ -880,20 +804,11 @@ bool VideoStore::setup_resampler() {
audio_out_ctx->channels, audio_out_ctx->sample_fmt, audio_out_ctx->channels, audio_out_ctx->sample_fmt,
audio_out_ctx->channel_layout, audio_out_ctx->frame_size); audio_out_ctx->channel_layout, audio_out_ctx->frame_size);
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
Debug(1, Debug(1,
"Audio out stream bit_rate (%" PRIi64 ") sample_rate(%d) channels(%d) fmt(%d) layout(%" PRIi64 ") frame_size(%d)", "Audio out stream bit_rate (%" PRIi64 ") sample_rate(%d) channels(%d) fmt(%d) layout(%" PRIi64 ") frame_size(%d)",
audio_out_stream->codecpar->bit_rate, audio_out_stream->codecpar->sample_rate, audio_out_stream->codecpar->bit_rate, audio_out_stream->codecpar->sample_rate,
audio_out_stream->codecpar->channels, audio_out_stream->codecpar->format, audio_out_stream->codecpar->channels, audio_out_stream->codecpar->format,
audio_out_stream->codecpar->channel_layout, audio_out_stream->codecpar->frame_size); audio_out_stream->codecpar->channel_layout, audio_out_stream->codecpar->frame_size);
#else
Debug(1,
"Audio out bit_rate (%d) sample_rate(%d) channels(%d) fmt(%d) "
"layout(%" PRIi64 ") frame_size(%d)",
audio_out_stream->codec->bit_rate, audio_out_stream->codec->sample_rate,
audio_out_stream->codec->channels, audio_out_stream->codec->sample_fmt,
audio_out_stream->codec->channel_layout, audio_out_stream->codec->frame_size);
#endif
/** Create a new frame to store the audio samples. */ /** Create a new frame to store the audio samples. */
if (!in_frame) { if (!in_frame) {
@ -942,9 +857,7 @@ bool VideoStore::setup_resampler() {
out_frame->nb_samples = audio_out_ctx->frame_size; out_frame->nb_samples = audio_out_ctx->frame_size;
out_frame->format = audio_out_ctx->sample_fmt; out_frame->format = audio_out_ctx->sample_fmt;
#if LIBAVCODEC_VERSION_CHECK(56, 8, 0, 60, 100)
out_frame->channels = audio_out_ctx->channels; out_frame->channels = audio_out_ctx->channels;
#endif
out_frame->channel_layout = audio_out_ctx->channel_layout; out_frame->channel_layout = audio_out_ctx->channel_layout;
out_frame->sample_rate = audio_out_ctx->sample_rate; out_frame->sample_rate = audio_out_ctx->sample_rate;
@ -1074,9 +987,7 @@ int VideoStore::writeVideoFramePacket(const std::shared_ptr<ZMPacket> &zm_packet
// Do this to allow the encoder to choose whether to use I/P/B frame // Do this to allow the encoder to choose whether to use I/P/B frame
//zm_packet->out_frame->pict_type = AV_PICTURE_TYPE_NONE; //zm_packet->out_frame->pict_type = AV_PICTURE_TYPE_NONE;
//zm_packet->out_frame->key_frame = zm_packet->keyframe; //zm_packet->out_frame->key_frame = zm_packet->keyframe;
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
frame->pkt_duration = 0; frame->pkt_duration = 0;
#endif
int64_t in_pts = zm_packet->timestamp.tv_sec * (uint64_t)1000000 + zm_packet->timestamp.tv_usec; int64_t in_pts = zm_packet->timestamp.tv_sec * (uint64_t)1000000 + zm_packet->timestamp.tv_usec;
if (!video_first_pts) { if (!video_first_pts) {

View File

@ -88,7 +88,7 @@ fi;
if [ "$DISTROS" == "" ]; then if [ "$DISTROS" == "" ]; then
if [ "$RELEASE" != "" ]; then if [ "$RELEASE" != "" ]; then
DISTROS="xenial,bionic,focal,groovy,hirsute" DISTROS="bionic,focal,groovy,hirsute"
else else
DISTROS=`lsb_release -a 2>/dev/null | grep Codename | awk '{print $2}'`; DISTROS=`lsb_release -a 2>/dev/null | grep Codename | awk '{print $2}'`;
fi; fi;
@ -242,8 +242,6 @@ IFS=',' ;for DISTRO in `echo "$DISTROS"`; do
elif [ "$DISTRO" == "beowulf" ] elif [ "$DISTRO" == "beowulf" ]
then then
cp -Rpd distros/beowulf debian cp -Rpd distros/beowulf debian
else
cp -Rpd distros/ubuntu1604 debian
fi; fi;
if [ "$DEBEMAIL" != "" ] && [ "$DEBFULLNAME" != "" ]; then if [ "$DEBEMAIL" != "" ] && [ "$DEBFULLNAME" != "" ]; then

View File

@ -160,7 +160,7 @@ movecrud () {
} }
# previsouly part of installzm.sh # previsouly part of installzm.sh
# install the xenial deb and test zoneminder # install the deb and test zoneminder
install_deb () { install_deb () {
# Check we've got gdebi installed # Check we've got gdebi installed
@ -173,7 +173,7 @@ install_deb () {
exit 1 exit 1
fi fi
# Install and test the zoneminder package (only) for Ubuntu Xenial # Install and test the zoneminder package
pkgname="build/zoneminder_${VERSION}-${RELEASE}_amd64.deb" pkgname="build/zoneminder_${VERSION}-${RELEASE}_amd64.deb"
if [ -e $pkgname ]; then if [ -e $pkgname ]; then
@ -373,8 +373,6 @@ elif [ "${OS}" == "debian" ] || [ "${OS}" == "ubuntu" ] || [ "${OS}" == "raspbia
ln -sfT distros/ubuntu2004 debian ln -sfT distros/ubuntu2004 debian
elif [ "${DIST}" == "beowulf" ]; then elif [ "${DIST}" == "beowulf" ]; then
ln -sfT distros/beowulf debian ln -sfT distros/beowulf debian
else
ln -sfT distros/ubuntu1604 debian
fi fi
setdebchangelog setdebchangelog