Skip to content

Commit

Permalink
examples/hls2rtp: add OpenSSL support
Browse files Browse the repository at this point in the history
  • Loading branch information
quarium committed Dec 3, 2024
1 parent 1d385a1 commit 2452ceb
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
4 changes: 4 additions & 0 deletions examples/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ UPIPEOSX_LIBS = $(top_builddir)/lib/upipe-osx/libupipe_osx.la
UPIPEDVBCSA_LIBS = $(top_builddir)/lib/upipe-dvbcsa/libupipe_dvbcsa.la
UPIPEDVB_LIBS = $(top_builddir)/lib/upipe-dvb/libupipe_dvb.la
UPIPEBEARSSL_LIBS = $(top_builddir)/lib/upipe-bearssl/libupipe_bearssl.la
UPIPEOPENSSL_LIBS = $(top_builddir)/lib/upipe-openssl/libupipe_openssl.la

noinst_PROGRAMS =

Expand All @@ -29,6 +30,9 @@ rist_tx_LDADD = $(LDADD) $(UPUMPEV_LIBS) $(UPIPEMODULES_LIBS) $(UPIPEFILTERS_LIB
udpmulticat_LDADD = $(LDADD) $(UPUMPEV_LIBS) $(UPIPEMODULES_LIBS)
multicatudp_LDADD = $(LDADD) $(UPUMPEV_LIBS) $(UPIPEMODULES_LIBS) $(UPIPEPTHREAD_LIBS) -lpthread
hls2rtp_LDADD= $(LDADD) $(UPUMPEV_LIBS) $(UPIPEMODULES_LIBS) $(UPIPEFRAMERS_LIBS) $(UPIPETS_LIBS) $(UPIPEHLS_LIBS) $(UPIPEPTHREAD_LIBS) -lpthread
if HAVE_OPENSSL
hls2rtp_LDADD += $(UPIPEOPENSSL_LIBS)
endif
if HAVE_BEARSSL
hls2rtp_LDADD += $(UPIPEBEARSSL_LIBS)
endif
Expand Down
51 changes: 50 additions & 1 deletion examples/hls2rtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@
#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
#include "upipe-openssl/uprobe_https_openssl.h"
#endif
#ifdef UPIPE_HAVE_BEARSSL_H
#include "upipe-bearssl/uprobe_https_bearssl.h"
#endif
Expand Down Expand Up @@ -1284,6 +1287,12 @@ enum opt {
OPT_DELAY,
OPT_QUIT_TIMEOUT,
OPT_USER_AGENT,
#ifdef UPIPE_HAVE_BEARSSL_H
OPT_USE_BEARSSL,
#endif
#ifdef UPIPE_HAVE_OPENSSL_SSL_H
OPT_USE_OPENSSL,
#endif
};

static struct option options[] = {
Expand Down Expand Up @@ -1314,6 +1323,12 @@ 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
{ "use-bearssl", no_argument, NULL, OPT_USE_BEARSSL },
#endif
#ifdef UPIPE_HAVE_OPENSSL_SSL_H
{ "use-openssl", no_argument, NULL, OPT_USE_OPENSSL },
#endif
{ 0, 0, 0, 0 },
};

Expand Down Expand Up @@ -1354,6 +1369,14 @@ int main(int argc, char **argv)
enum upipe_ts_conformance conformance = UPIPE_TS_CONFORMANCE_AUTO;
bool no_stdin = false;

#ifdef UPIPE_HAVE_BEARSSL_H
bool use_bearssl = true;
#endif

#ifdef UPIPE_HAVE_OPENSSL_SSL_H
bool use_openssl = true;
#endif

/*
* parse options
*/
Expand Down Expand Up @@ -1458,6 +1481,24 @@ int main(int argc, char **argv)

case OPT_MISSING_ARG:
return usage(argv[0], "missing argument");

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

#ifdef UPIPE_HAVE_OPENSSL_SSL_H
case OPT_USE_OPENSSL:
use_openssl = true;
#ifdef UPIPE_HAVE_BEARSSL_H
use_bearssl = false;
#endif
break;
#endif
}
}

Expand Down Expand Up @@ -1751,9 +1792,17 @@ int main(int argc, char **argv)
uprobe_init(&probe_src, catch_src, uprobe_use(main_probe));
uprobe_release(main_probe);
main_probe = &probe_src;

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

#ifdef UPIPE_HAVE_BEARSSL_H
main_probe = uprobe_https_bearssl_alloc(main_probe);
if (use_bearssl)
main_probe = uprobe_https_bearssl_alloc(main_probe);
#endif

{
struct upipe_mgr *upipe_auto_src_mgr = upipe_auto_src_mgr_alloc();
assert(upipe_auto_src_mgr);
Expand Down

0 comments on commit 2452ceb

Please sign in to comment.