Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 2 additions & 22 deletions Build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ version = 0.5

cflags = -O2 -g $(warn) $(warn_c)
cxxflags = -O2 -g $(warn) $(warn_cxx)
cppflags = -Iinclude -I$(top_srcdir)/include
cppflags = -I$(top_builddir) -Iinclude -I$(top_srcdir)/include
ldflags = $(if $(or $(have_apple),$(have_san)),,-Wl,--no-undefined)

warn = -Wall \
Expand Down Expand Up @@ -49,9 +49,6 @@ SED ?= sed
configs += atomic
atomic-assert = __ATOMIC_SEQ_CST

configs += bigendian
bigendian-assert = __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__

configs += eventfd
eventfd-includes = sys/eventfd.h
eventfd-functions = eventfd
Expand Down Expand Up @@ -94,24 +91,7 @@ includesubdir = $(notdir $(patsubst %/,%,$(dir $1)))
genfiles = config.h include/upipe/config.h

config.h:
$(call cmd,gen){ \
$(if $(have_alsa),echo "#define HAVE_ALSA_ASOUNDLIB_H 1";) \
$(if $(have_atomic),echo "#define HAVE_ATOMIC_OPS 1";) \
$(if $(have_audiotoolbox),echo "#define HAVE_AUDIOTOOLBOX_AUDIOTOOLBOX_H 1";) \
$(if $(have_bearssl),echo "#define HAVE_BEARSSL_H 1";) \
$(if $(have_bigendian),echo "#define WORDS_BIGENDIAN 1";) \
$(if $(have_bitstream),echo "#define HAVE_BITSTREAM_COMMON_H 1";) \
$(if $(have_eventfd),echo "#define HAVE_EVENTFD 1";) \
$(if $(have_features.h),echo "#define HAVE_FEATURES_H 1";) \
$(if $(have_libgcrypt),echo "#define HAVE_GCRYPT_H 1";) \
$(if $(have_libtasn1),echo "#define HAVE_LIBTASN1_H 1";) \
$(if $(have_net/if.h),echo "#define HAVE_NET_IF_H 1";) \
$(if $(have_pipe),echo "#define HAVE_PIPE 1";) \
$(if $(have_semaphore),echo "#define HAVE_SEMAPHORE_H 1";) \
$(if $(have_unistd.h),echo "#define HAVE_UNISTD_H 1";) \
$(if $(have_x86asm),echo "#define HAVE_X86ASM 1";) \
$(if $(have_zvbi-0.2),echo "#define HAVE_LIBZVBI_H 1";) \
} > $@
$(call cmd,config.h)

# --- coding-style checks ------------------------------------------------------

Expand Down
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,19 @@ config-deps:
config-env:
@$(foreach v,$(_config_env_vars),printf "%-15s: %s\n" $v '$($v)';)

[a-z] = a b c d e f g h i j k l m n o p q r s t u v w x y z
[A-Z] = A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

_tr = $(strip $(if $1,$(subst $(firstword $1),$(firstword $2),\
$(call _tr,$(wordlist 2,26,$1),$(wordlist 2,26,$2),$3)),$3))
_toupper = $(call _tr,$([a-z]),$([A-Z]),$1)
_toid = $(call _tr,- . /,_ _ _,$1)
_have = $(sort $(foreach c,$(configs) $(_pkgs),\
$(if $(have_$c),$(call _toid,$(call _toupper,$c)))))

print-config.h = CONFIG $@
cmd-config.h = for i in $(_have); do echo "\#define HAVE_$$i 1"; done > $@

_distcleanfiles = config.mk config.log $(if $(_oot),Makefile) $(_makefiles)

# --- dependencies -------------------------------------------------------------
Expand Down
30 changes: 15 additions & 15 deletions examples/hls2rtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include <ctype.h>
#include <syslog.h>

#include "upipe/config.h"
#include "config.h"
#include "upipe/upipe_dump.h"
#include "upipe/uprobe.h"
#include "upipe/uprobe_helper_uprobe.h"
Expand Down Expand Up @@ -81,10 +81,10 @@
#include "upipe-pthread/uprobe_pthread_upump_mgr.h"
#include "upipe-pthread/upipe_pthread_transfer.h"
#include "upipe-pthread/umutex_pthread.h"
#ifdef UPIPE_HAVE_OPENSSL_SSL_H
#ifdef HAVE_OPENSSL
#include "upipe-openssl/uprobe_https_openssl.h"
#endif
#ifdef UPIPE_HAVE_BEARSSL_H
#ifdef HAVE_BEARSSL
#include "upipe-bearssl/uprobe_https_bearssl.h"
#endif

Expand Down Expand Up @@ -1287,10 +1287,10 @@ enum opt {
OPT_DELAY,
OPT_QUIT_TIMEOUT,
OPT_USER_AGENT,
#ifdef UPIPE_HAVE_BEARSSL_H
#ifdef HAVE_BEARSSL
OPT_USE_BEARSSL,
#endif
#ifdef UPIPE_HAVE_OPENSSL_SSL_H
#ifdef HAVE_OPENSSL
OPT_USE_OPENSSL,
#endif
};
Expand Down Expand Up @@ -1323,10 +1323,10 @@ static struct option options[] = {
{ "delay", required_argument, NULL, OPT_DELAY },
{ "quit-timeout", required_argument, NULL, OPT_QUIT_TIMEOUT },
{ "user-agent", required_argument, NULL, OPT_USER_AGENT },
#ifdef UPIPE_HAVE_BEARSSL_H
#ifdef HAVE_BEARSSL
{ "use-bearssl", no_argument, NULL, OPT_USE_BEARSSL },
#endif
#ifdef UPIPE_HAVE_OPENSSL_SSL_H
#ifdef HAVE_OPENSSL
{ "use-openssl", no_argument, NULL, OPT_USE_OPENSSL },
#endif
{ 0, 0, 0, 0 },
Expand Down Expand Up @@ -1369,11 +1369,11 @@ int main(int argc, char **argv)
enum upipe_ts_conformance conformance = UPIPE_TS_CONFORMANCE_AUTO;
bool no_stdin = false;

#ifdef UPIPE_HAVE_BEARSSL_H
#ifdef HAVE_BEARSSL
bool use_bearssl = true;
#endif

#ifdef UPIPE_HAVE_OPENSSL_SSL_H
#ifdef HAVE_OPENSSL
bool use_openssl = true;
#endif

Expand Down Expand Up @@ -1482,19 +1482,19 @@ int main(int argc, char **argv)
case OPT_MISSING_ARG:
return usage(argv[0], "missing argument");

#ifdef UPIPE_HAVE_BEARSSL_H
#ifdef HAVE_BEARSSL
case OPT_USE_BEARSSL:
use_bearssl = true;
#ifdef UPIPE_HAVE_OPENSSL_SSL_H
#ifdef HAVE_OPENSSL
use_openssl = false;
#endif
break;
#endif

#ifdef UPIPE_HAVE_OPENSSL_SSL_H
#ifdef HAVE_OPENSSL
case OPT_USE_OPENSSL:
use_openssl = true;
#ifdef UPIPE_HAVE_BEARSSL_H
#ifdef HAVE_BEARSSL
use_bearssl = false;
#endif
break;
Expand Down Expand Up @@ -1793,12 +1793,12 @@ int main(int argc, char **argv)
uprobe_release(main_probe);
main_probe = &probe_src;

#ifdef UPIPE_HAVE_OPENSSL_SSL_H
#ifdef HAVE_OPENSSL
if (use_openssl)
main_probe = uprobe_https_openssl_alloc(main_probe);
#endif

#ifdef UPIPE_HAVE_BEARSSL_H
#ifdef HAVE_BEARSSL
if (use_bearssl)
main_probe = uprobe_https_bearssl_alloc(main_probe);
#endif
Expand Down
6 changes: 3 additions & 3 deletions examples/ts_encrypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#include "upipe/config.h"
#include "config.h"

#include "upump-ev/upump_ev.h"

Expand Down Expand Up @@ -73,7 +73,7 @@
#include <unistd.h>
#include <syslog.h>

#ifdef UPIPE_HAVE_GCRYPT_H
#ifdef HAVE_LIBGCRYPT
#include <gcrypt.h>
#endif

Expand Down Expand Up @@ -269,7 +269,7 @@ int main(int argc, char *argv[])
exit(-1);
}

#ifdef UPIPE_HAVE_GCRYPT_H
#ifdef HAVE_LIBGCRYPT
gcry_check_version(NULL);
gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0);
#endif
Expand Down
9 changes: 5 additions & 4 deletions examples/uplay.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <stdlib.h>
#include <stdio.h>

#include "config.h"
#include "upipe/uprobe.h"
#include "upipe/uprobe_stdio.h"
#include "upipe/uprobe_prefix.h"
Expand Down Expand Up @@ -81,9 +82,9 @@
#include "upipe-gl/upipe_glx_sink.h"
#include "upipe-gl/uprobe_gl_sink.h"
#include "upipe-gl/uprobe_gl_sink_cube.h"
#ifdef UPIPE_HAVE_ALSA_ASOUNDLIB_H
#ifdef HAVE_ALSA
#include "upipe-alsa/upipe_alsa_sink.h"
#elif defined(UPIPE_HAVE_AUDIOTOOLBOX_AUDIOTOOLBOX_H)
#elif defined(HAVE_AUDIOTOOLBOX)
#include "upipe-osx/upipe_osx_audioqueue_sink.h"
#endif

Expand Down Expand Up @@ -482,15 +483,15 @@ static int catch_audio(struct uprobe *uprobe, struct upipe *upipe,
uprobe_throw(uprobe_main, NULL, UPROBE_FREEZE_UPUMP_MGR);

struct upipe *sink;
#ifdef UPIPE_HAVE_ALSA_ASOUNDLIB_H
#ifdef HAVE_ALSA
struct upipe_mgr *upipe_alsink_mgr = upipe_alsink_mgr_alloc();
sink = upipe_void_alloc(upipe_alsink_mgr,
uprobe_pfx_alloc(uprobe_use(uprobe_main), UPROBE_LOG_VERBOSE,
"alsink"));
assert(sink != NULL);
upipe_mgr_release(upipe_alsink_mgr);
upipe_attach_uclock(sink);
#elif defined(UPIPE_HAVE_AUDIOTOOLBOX_AUDIOTOOLBOX_H)
#elif defined(HAVE_AUDIOTOOLBOX)
struct upipe_mgr *upipe_osx_audioqueue_sink_mgr =
upipe_osx_audioqueue_sink_mgr_alloc();
sink = upipe_void_alloc(upipe_osx_audioqueue_sink_mgr,
Expand Down
5 changes: 3 additions & 2 deletions include/upipe-av/upipe_av_samplefmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
extern "C" {
#endif

#include "upipe/ubase.h"
#include "upipe/uref_sound_flow.h"
#include "upipe/uref_sound_flow_formats.h"
#include <libavutil/samplefmt.h>
Expand All @@ -50,7 +51,7 @@ static const struct {
{ AV_SAMPLE_FMT_S32, "sound.s32." },
{ AV_SAMPLE_FMT_FLT, "sound.f32." },
{ AV_SAMPLE_FMT_DBL, "sound.f64." },
#ifdef UPIPE_WORDS_BIGENDIAN
#ifdef UBASE_BIGENDIAN
{ AV_SAMPLE_FMT_S16, "sound.s16be." },
{ AV_SAMPLE_FMT_S32, "sound.s32be." },
{ AV_SAMPLE_FMT_FLT, "sound.f32be." },
Expand Down Expand Up @@ -91,7 +92,7 @@ upipe_av_samplefmt_to_flow_format(enum AVSampleFormat fmt)
{ AV_SAMPLE_FMT_S64, &uref_sound_flow_format_s64 },
{ AV_SAMPLE_FMT_S64P, &uref_sound_flow_format_s64_planar },

#ifdef UPIPE_WORDS_BIGENDIAN
#ifdef UBASE_BIGENDIAN
{ AV_SAMPLE_FMT_S16, &uref_sound_flow_format_s16be },
{ AV_SAMPLE_FMT_S32, &uref_sound_flow_format_s32be },
{ AV_SAMPLE_FMT_FLT, &uref_sound_flow_format_f32be },
Expand Down
4 changes: 2 additions & 2 deletions include/upipe/uatomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ typedef void * _Atomic uatomic_ptr_t;
#define uatomic_fetch_add atomic_fetch_add
#define uatomic_fetch_sub atomic_fetch_sub

#elif defined(UPIPE_HAVE_ATOMIC_OPS)
#elif defined(UPIPE_HAVE_ATOMIC)

/*
* Preferred method: gcc atomic operations
Expand Down Expand Up @@ -161,7 +161,7 @@ static inline uint32_t uatomic_fetch_sub(uatomic_uint32_t *obj,
}


#elif defined(UPIPE_HAVE_SEMAPHORE_H) /* mkdoc:skip */
#elif defined(UPIPE_HAVE_SEMAPHORE) /* mkdoc:skip */

/*
* On POSIX platforms use semaphores (slower)
Expand Down
6 changes: 5 additions & 1 deletion include/upipe/ubase.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,11 @@ static inline void uchain_init(struct uchain *uchain)
uchain->next = uchain->prev = NULL;
}

#ifdef UPIPE_WORDS_BIGENDIAN
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
#define UBASE_BIGENDIAN
#endif

#ifdef UBASE_BIGENDIAN
/** @This allows to define a 32-bit unsigned integer with 4 letters. */ \
# define UBASE_FOURCC(a, b, c, d) \
(((uint32_t)d) | (((uint32_t)c) << 8) | (((uint32_t)b) << 16) | \
Expand Down
16 changes: 8 additions & 8 deletions lib/upipe-alsa/upipe_alsa_sink.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ static snd_pcm_format_t upipe_alsink_format_from_flow_def(struct uref *flow_def)
else if (!ubase_ncmp(def, "s16be."))
format = SND_PCM_FORMAT_S16_BE;
else if (!ubase_ncmp(def, "s16."))
#ifdef UPIPE_WORDS_BIGENDIAN
#ifdef UBASE_BIGENDIAN
format = SND_PCM_FORMAT_S16_BE;
#else
format = SND_PCM_FORMAT_S16_LE;
Expand All @@ -172,7 +172,7 @@ static snd_pcm_format_t upipe_alsink_format_from_flow_def(struct uref *flow_def)
else if (!ubase_ncmp(def, "u16be."))
format = SND_PCM_FORMAT_U16_BE;
else if (!ubase_ncmp(def, "u16."))
#ifdef UPIPE_WORDS_BIGENDIAN
#ifdef UBASE_BIGENDIAN
format = SND_PCM_FORMAT_U16_BE;
#else
format = SND_PCM_FORMAT_U16_LE;
Expand All @@ -190,7 +190,7 @@ static snd_pcm_format_t upipe_alsink_format_from_flow_def(struct uref *flow_def)
else if (!ubase_ncmp(def, "s32be."))
format = SND_PCM_FORMAT_S32_BE;
else if (!ubase_ncmp(def, "s32."))
#ifdef UPIPE_WORDS_BIGENDIAN
#ifdef UBASE_BIGENDIAN
format = SND_PCM_FORMAT_S32_BE;
#else
format = SND_PCM_FORMAT_S32_LE;
Expand All @@ -200,7 +200,7 @@ static snd_pcm_format_t upipe_alsink_format_from_flow_def(struct uref *flow_def)
else if (!ubase_ncmp(def, "u32be."))
format = SND_PCM_FORMAT_U32_BE;
else if (!ubase_ncmp(def, "u32."))
#ifdef UPIPE_WORDS_BIGENDIAN
#ifdef UBASE_BIGENDIAN
format = SND_PCM_FORMAT_U32_BE;
#else
format = SND_PCM_FORMAT_U32_LE;
Expand All @@ -210,7 +210,7 @@ static snd_pcm_format_t upipe_alsink_format_from_flow_def(struct uref *flow_def)
else if (!ubase_ncmp(def, "s24be."))
format = SND_PCM_FORMAT_S24_BE;
else if (!ubase_ncmp(def, "s24."))
#ifdef UPIPE_WORDS_BIGENDIAN
#ifdef UBASE_BIGENDIAN
format = SND_PCM_FORMAT_S24_BE;
#else
format = SND_PCM_FORMAT_S24_LE;
Expand All @@ -220,7 +220,7 @@ static snd_pcm_format_t upipe_alsink_format_from_flow_def(struct uref *flow_def)
else if (!ubase_ncmp(def, "u24be."))
format = SND_PCM_FORMAT_U24_BE;
else if (!ubase_ncmp(def, "u24."))
#ifdef UPIPE_WORDS_BIGENDIAN
#ifdef UBASE_BIGENDIAN
format = SND_PCM_FORMAT_U24_BE;
#else
format = SND_PCM_FORMAT_U24_LE;
Expand All @@ -230,7 +230,7 @@ static snd_pcm_format_t upipe_alsink_format_from_flow_def(struct uref *flow_def)
else if (!ubase_ncmp(def, "f32be."))
format = SND_PCM_FORMAT_FLOAT_BE;
else if (!ubase_ncmp(def, "f32."))
#ifdef UPIPE_WORDS_BIGENDIAN
#ifdef UBASE_BIGENDIAN
format = SND_PCM_FORMAT_FLOAT_BE;
#else
format = SND_PCM_FORMAT_FLOAT_LE;
Expand All @@ -240,7 +240,7 @@ static snd_pcm_format_t upipe_alsink_format_from_flow_def(struct uref *flow_def)
else if (!ubase_ncmp(def, "f64be."))
format = SND_PCM_FORMAT_FLOAT64_BE;
else if (!ubase_ncmp(def, "f64."))
#ifdef UPIPE_WORDS_BIGENDIAN
#ifdef UBASE_BIGENDIAN
format = SND_PCM_FORMAT_FLOAT64_BE;
#else
format = SND_PCM_FORMAT_FLOAT64_LE;
Expand Down
3 changes: 2 additions & 1 deletion lib/upipe-av/upipe_avcodec_decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
* @short Upipe avcodec decode module
*/

#include "upipe/ubase.h"
#include "upipe/uclock.h"
#include "upipe/ubuf.h"
#include "upipe/uref.h"
Expand Down Expand Up @@ -1120,7 +1121,7 @@ static void upipe_avcdec_output_sub(struct upipe *upipe, AVSubtitle *sub,
}

if (unlikely(
#ifdef UPIPE_WORDS_BIGENDIAN
#ifdef UBASE_BIGENDIAN
!ubase_check(uref_pic_flow_set_argb(flow_def_attr)) ||
#else
!ubase_check(uref_pic_flow_set_bgra(flow_def_attr)) ||
Expand Down
Loading
Loading