Skip to content
4 changes: 4 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ PKG_CHECK_UPIPE(SRT, srt, [srt/srt.h])
AC_LANG_PUSH([C++])
PKG_CHECK_UPIPE(QTWEBKIT, QtWebKit, [QtWebKit])
AC_LANG_POP([C++])
PKG_CHECK_UPIPE(OPENSSL, openssl, [openssl/ssl.h])

# if have gcrypt and tasn then
AC_SUBST(LIBUPIPE_TS_PKGCONFIG_REQUIRES)
Expand Down Expand Up @@ -285,6 +286,7 @@ AC_CONFIG_FILES([Makefile
include/upipe-dvbcsa/Makefile
include/upipe-ebur128/Makefile
include/upipe-bearssl/Makefile
include/upipe-openssl/Makefile
lib/Makefile
lib/upipe/Makefile
lib/upipe/libupipe.pc
Expand Down Expand Up @@ -352,6 +354,8 @@ AC_CONFIG_FILES([Makefile
lib/upipe-ebur128/libupipe_ebur128.pc
lib/upipe-bearssl/Makefile
lib/upipe-bearssl/libupipe_bearssl.pc
lib/upipe-openssl/Makefile
lib/upipe-openssl/libupipe_openssl.pc
x86/Makefile
x86/config.asm
tests/Makefile
Expand Down
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
53 changes: 51 additions & 2 deletions examples/hls2rtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,11 @@
#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.h"
#include "upipe-bearssl/uprobe_https_bearssl.h"
#endif

#include <pthread.h>
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_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
4 changes: 4 additions & 0 deletions include/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ if HAVE_DVBV5
SUBDIRS += upipe-dvb
endif

if HAVE_OPENSSL
SUBDIRS += upipe-openssl
endif

if HAVE_BEARSSL
SUBDIRS += upipe-bearssl
endif
Expand Down
2 changes: 1 addition & 1 deletion include/upipe-bearssl/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
NULL =
myincludedir = $(includedir)/upipe-bearssl
myinclude_HEADERS = \
uprobe_https.h \
uprobe_https_bearssl.h \
$(NULL)
49 changes: 49 additions & 0 deletions include/upipe-bearssl/uprobe_https_bearssl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright (C) 2020-2024 EasyTools
*
* Authors: Arnaud de Turckheim
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation https (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.
*/

/** @file
* @short probe catching http scheme hook for SSL connection
*/

#ifndef _UPIPE_BEARSSL_UPROBE_HTTPS_BEARSSL_H_
#define _UPIPE_BEARSSL_UPROBE_HTTPS_BEARSSL_H_

#ifdef __cplusplus
extern "C" {
#endif

#include "upipe/uprobe.h"

/** @This allocates and initializes a new uprobe_https structure.
*
* @param next next probe to test if this one doesn't catch the event
* @return pointer to uprobe, or NULL in case of error
*/
struct uprobe *uprobe_https_bearssl_alloc(struct uprobe *next);

#ifdef __cplusplus
}
#endif
#endif
10 changes: 6 additions & 4 deletions include/upipe-modules/upipe_http_source.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,17 @@ struct upipe_http_src_hook {

struct {
/** called when the transport socket is ready for read */
int (*read)(struct upipe_http_src_hook *, int);
int (*read)(struct upipe *upipe, struct upipe_http_src_hook *, int);
/** called when the transport socket is ready for write */
int (*write)(struct upipe_http_src_hook *, int);
int (*write)(struct upipe *upipe, struct upipe_http_src_hook *, int);
} transport;
struct {
/** called when there is data for read */
ssize_t (*read)(struct upipe_http_src_hook *, uint8_t *, size_t);
ssize_t (*read)(struct upipe *upipe, struct upipe_http_src_hook *,
uint8_t *, size_t);
/** called when there is space for data to write */
ssize_t (*write)(struct upipe_http_src_hook *, const uint8_t *, size_t);
ssize_t (*write)(struct upipe *upipe, struct upipe_http_src_hook *,
const uint8_t *, size_t);
} data;
};

Expand Down
5 changes: 5 additions & 0 deletions include/upipe-openssl/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
NULL =
myincludedir = $(includedir)/upipe-openssl
myinclude_HEADERS = \
uprobe_https_openssl.h \
$(NULL)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 EasyTools
* Copyright (C) 2024 EasyTools
*
* Authors: Arnaud de Turckheim
*
Expand Down Expand Up @@ -27,8 +27,8 @@
* @short probe catching http scheme hook for SSL connection
*/

#ifndef _UPIPE_BEARSSL_UPROBE_HTTPS_H_
#define _UPIPE_BEARSSL_UPROBE_HTTPS_H_
#ifndef _UPIPE_OPENSSL_UPROBE_HTTPS_OPENSSL_H_
#define _UPIPE_OPENSSL_UPROBE_HTTPS_OPENSSL_H_

#ifdef __cplusplus
extern "C" {
Expand All @@ -41,7 +41,7 @@ extern "C" {
* @param next next probe to test if this one doesn't catch the event
* @return pointer to uprobe, or NULL in case of error
*/
struct uprobe *uprobe_https_alloc(struct uprobe *next);
struct uprobe *uprobe_https_openssl_alloc(struct uprobe *next);

#ifdef __cplusplus
}
Expand Down
4 changes: 4 additions & 0 deletions lib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,7 @@ if !HAVE_OSX_DARWIN
SUBDIRS += upump-srt
endif
endif

if HAVE_OPENSSL
SUBDIRS += upipe-openssl
endif
6 changes: 3 additions & 3 deletions lib/upipe-bearssl/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ NULL =
lib_LTLIBRARIES = libupipe_bearssl.la

libupipe_bearssl_la_SOURCES = \
https_source_hook.h \
https_source_hook.c \
uprobe_https.c \
https_source_hook_bearssl.h \
https_source_hook_bearssl.c \
uprobe_https_bearssl.c \
$(NULL)

libupipe_bearssl_la_CPPFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include
Expand Down
Loading
Loading