Initial release

parents
# Matches ALL Makefile and Makefile.in occurrences
Makefile
Makefile.in
# ...
_*
.deps/
.libs/
*.o
*.a
*.lo
*.la
*~
*.sw[op]
*.trs
*.log
# Various auto-tools artifacts
/aclocal.m4
/autom4te.cache/
/build-aux
/compile
/config.guess
/config.h
/config.h.in
/config.status
/config.sub
/configure
/configure.lineno
/depcomp
/install-sh
/libtool
/ltmain.sh
/m4/libtool.m4
/m4/ltoptions.m4
/m4/ltsugar.m4
/m4/ltversion.m4
/m4/lt~obsolete.m4
/missing
/stamp-h1
TAGS
tags
cscope.*out
.dirstamp
test-driver
# our binary
elbestream
# man
elbestream.1
# dist
elbestream-*.tar.gz
CONTRIBUTING
============
To contribute code or documentation, submit a `merge request
<https://gitlab.com/uplex/misc/elbestream/-/merge_requests>`_.
If you have a problem or discover a bug, you can post an `issue
<https://gitlab.com/uplex/misc/elbestream/-/issues>`_.
INSTALLATION
============
Building from source
~~~~~~~~~~~~~~~~~~~~
This tool should build like any other autotools-supported tool::
./autogen.sh
./configure
make
make check
sudo make install
The ``./autogen.sh`` step is only needed when building from the git
repository.
Copyright 2021 UPLEX Nils Goroll Systemoptimierung
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. 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.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
ACLOCAL_AMFLAGS = -I m4
bin_PROGRAMS = elbestream
elbestream_SOURCES = elbestream.c
TESTS = test.sh
EXTRA_DIST = README.rst LICENSE CONTRIBUTING.rst INSTALL.rst test.sh
doc_DATA = README.rst LICENSE CONTRIBUTING.rst INSTALL.rst
elbestream.1: README.rst
$(AM_V_GEN) $(RST2MAN) $< $@
%.1 %.2 %.3 %.4 %.5 %.6 %.7 %.8 %.9:
if HAVE_RST2MAN
${RST2MAN} $< $@
else
@echo "========================================"
@echo "You need rst2man installed to make dist"
@echo "========================================"
@false
endif
.PHONY: fint
flint: flint.lnt elbestream.c
flexelint flint.lnt elbestream.c
==========
ELBEstream
==========
---------------------------
Error Latched BuffEr stream
---------------------------
:Manual section: 1
SYNOPSIS
========
::
./elbestream
[-i <input buffer size> (default: 1048576 bytes)]
[-o <output buffer size> (default: 1048576 bytes)]
[-m <minimum output size>]
-- try command ...
---- fin command ...
*fin command* needs to contain one ``%f`` argument which is replaced
by a filename which *fin command* should read input data from.
EXAMPLE
-------
::
./elbestream -m 131 \
-- /usr/bin/ffmpeg -i - -ac 2 -f wav pipe:1 \
---- /usr/bin/ffmpeg -i %f -ac 2 -f wav pipe:1
DESCRIPTION
===========
Programs which usually work in *streaming* mode, taking their input
from `stdin(3)` and writing to `stdout(3)` might fail for some inputs.
For example,
::
/usr/bin/ffmpeg -i - -ac 2 -f wav pipe:1 <FILE.aac >t.wav
might throw errors like::
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x560855efb900] stream 0, offset 0x28: partial file
pipe:: Invalid data found when processing input
...
Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used)
while::
/usr/bin/ffmpeg -i FILE.aac -ac 2 -f wav pipe:1 >t.wav
works just fine.
This program aims to solve this case like these in a generic,
efficient manner, trying to use the *streaming* case whenever possible
and only failing back to a buffered file mode if necessary.
First, the input buffer is filled from `stdin(3)`.
Next, *try command* is executed on the input buffer with its output
buffered. Once either all of the input buffer has been written to *try
command*, or the output buffer is full, it is determined if the
program is classified as failed or considered successful (so far,
because not all input has necessarily been processed).
* Obviously, if the *try command* process has exited with failure, it
is considered to have failed.
* Also, if it has not output at least as many bytes as specified by
the ``-m`` argument, it is considered to have failed and gets
terminated by elbestream.
If *try command* has not failed by these checks, it is left running
on the remainder of `stdin(3)`, with its output being sent to
`stdout(3)` as if only *try command* was run to begin with.
If, however, *try command* is considered to have failed, the input
buffer and the rest of `stdin(3)` are written to a temporary
file. Then, the ``%f`` argument of *fin command* is replaced with the
name of that file and *fin command* is run.
IMPLEMENTATION DETAILS
======================
This tool uses the `splice(2)` and `vmsplice(2)` systemcalls on Linux
if they are available and usable on the respective file descriptors in
an attempt to reduce overhead of the I/O operations involved. It falls
back to ordinary `read(2)`\ /\ `write(2)` loops.
INSTALLATION
============
See `INSTALL.rst <INSTALL.rst>`_ in the source repository.
SUPPORT
=======
For community support, please use `Gitlab Issues`_.
For commercial support, please contact info@uplex.de
.. _Gitlab Issues: https://gitlab.com/uplex/misc/elbestream/-/issues
COPYRIGHT
=========
::
Copyright 2021 UPLEX Nils Goroll Systemoptimierung
All rights reserved
Author: Nils Goroll <nils.goroll@uplex.de>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. 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.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
#!/bin/sh
#
# Use autogen.des when doing code development
autoreconf -i
AC_PREREQ(2.68)
AC_COPYRIGHT([Copyright 2021 UPLEX - Nils Goroll Systemoptimierung])
AC_INIT([elbestream], [trunk], [varnish-support@uplex.de], [elbestream])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_SRCDIR(elbestream.c)
AM_CONFIG_HEADER(config.h)
AC_CANONICAL_SYSTEM
AC_LANG(C)
AM_INIT_AUTOMAKE([1.12 -Wall -Werror foreign parallel-tests])
AM_SILENT_RULES([yes])
AC_PROG_CC
AC_PROG_CC_STDC
if test "x$ac_cv_prog_cc_c99" = xno; then
AC_MSG_ERROR([Could not find a C99 compatible compiler])
fi
AC_PROG_CPP
AX_PTHREAD(,[AC_MSG_ERROR([Could not configure pthreads support])])
LIBS="$PTHREAD_LIBS $LIBS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
CC="$PTHREAD_CC"
AC_ARG_WITH([rst2man],
AS_HELP_STRING(
[--with-rst2man=PATH],
[Location of rst2man (auto)]),
[RST2MAN="$withval"],
AC_CHECK_PROGS(RST2MAN, [rst2man rst2man.py], []))
AM_CONDITIONAL(HAVE_RST2MAN, [test "x$RST2MAN" != "xno"])
AC_CHECK_FUNCS([splice vmsplice])
AC_CONFIG_FILES([
Makefile
])
AC_OUTPUT
This diff is collapsed.
-e717 // do ... while(1) ...
-e716 // while(1) ...
#!/bin/bash
set -eux
t=$(date)
for i in 1 4 10 29 30 31 40 ; do
for o in 1 4 10 29 30 31 40 ; do
r=$(echo "${t}" | ./elbestream -i $i -o $o -- /usr/bin/cat \
---- /usr/bin/cat %f)
if [[ "${r}" != "${t}" ]] ; then
echo >&2 FAIL
exit 9
fi
r=$(echo "${t}" | ./elbestream -i $i -o $o -m 1 -- /bin/false \
---- /usr/bin/cat %f)
if [[ "${r}" != "${t}" ]] ; then
echo >&2 FAIL
exit 9
fi
done
done
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment