BUILD.gn
- 下载
我把修改过后的上传到github上了,可以直接下载修改后的源码。
$ git clone git@github.com:momo0853/rtmpdump.git
- 为rtmpdump添加GN编译
BUILD.gn
#----------------------------------------------------
# Author: stoneliu
# Time : Thu May 7 18:05:00 CST 2020
#----------------------------------------------------
config("public_config") {
include_dirs = [ "." ]
}
config("librtmp_config") {
if (is_win) {
cflags = [
"/wd4047",
"/wd4310",
"/wd4701",
"/wd4005",
]
} else {
cflags = [
"-Wno-unused-const-variable",
"-Wno-sign-compare",
"-Wno-delete-incomplete",
"-Wno-deprecated-register",
"-Wno-null-dereference",
"-Wno-non-virtual-dtor",
"-Wno-tautological-compare",
]
ldflags = [ "-lz" ]
}
defines = [
"RTMPDUMP_VERSION=\"2.4\"",
"USE_OPENSSL",
]
}
static_library("librtmp") {
sources = [
"librtmp/amf.c",
"librtmp/hashswf.c",
"librtmp/log.c",
"librtmp/parseurl.c",
"librtmp/rtmp.c",
]
configs += [ ":librtmp_config" ]
public_configs = [ ":public_config" ]
deps = [
"//third_party/boringssl:boringssl",
]
}
executable("rtmpdump") {
sources = [ "rtmpdump.c" ]
deps = [ ":librtmp" ]
configs += [ ":librtmp_config" ]
}
executable("rtmpgw") {
sources = [ "rtmpgw.c", "thread.c" ]
deps = [ ":librtmp" ]
configs += [ ":librtmp_config" ]
}
executable("rtmpsrv") {
sources = [ "rtmpsrv.c", "thread.c" ]
deps = [ ":librtmp" ]
configs += [ ":librtmp_config" ]
}
executable("rtmpsuck") {
sources = [ "rtmpsuck.c", "thread.c" ]
deps = [ ":librtmp" ]
configs += [ ":librtmp_config" ]
}
rtmpdump使用BoringSSL
rtmpdump依赖OpenSSL的,但是这里我想用BoringSSL(因为WebRTC内部使用的是BoringSSL),这两个库的MDH数据结构的成员函数名字有点点差异,所以需要修改一下。自从2015年OpenSSL出现重大漏洞,Google大部分自身的开源项目都是依赖BoringSSL。
diff --git a/librtmp/dh.h b/librtmp/dh.h
index 5fc3f32..ff7b915 100644
--- a/librtmp/dh.h
+++ b/librtmp/dh.h
@@ -266,7 +266,7 @@ DHInit(int nKeyBits)
MP_set_w(dh->g, 2); /* base 2 */
- dh->length = nKeyBits;
+ dh->priv_length = (unsigned)nKeyBits;
return dh;
BoringSSL修改
rtmpdump依赖BIO_f_base64
,但是BoringSSL并没有编译进去。
diff --git a/third_party/boringssl/BUILD.generated.gni b/third_party/boringssl/BUILD.generated.gni
index 0e96ff54f..c69befb38 100644
--- a/third_party/boringssl/BUILD.generated.gni
+++ b/third_party/boringssl/BUILD.generated.gni
@@ -329,6 +329,10 @@ crypto_sources = [
"src/include/openssl/x509v3.h",
]
+crypto_sources += [
+ "src/decrepit/bio/base64_bio.c",
+]
+
ssl_sources = [
"src/include/openssl/dtls1.h",
"src/include/openssl/ssl.h",