Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For #1653, #1500, Support GB28181, another solution. #1656

Merged
merged 37 commits into from
Mar 31, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
f911477
Merge pull request #2 from ossrs/3.0release
lam2003 Mar 19, 2020
bbfb03f
修复srs_write_large_iovs中nwrite未累加的错误
lam2003 Mar 19, 2020
cbe9c1d
Support gb28181 sip over udp, ps steam over rtp
xialixin Mar 19, 2020
8b4f84e
fix push.gb28181.conf, gb28181conn repeat call serve()
xialixin Mar 20, 2020
de9a004
Merge branch 'dev-28181' of https://github.com/xialixin/srs into feat…
winlinvip Mar 20, 2020
b6b5236
Update authors
winlinvip Mar 21, 2020
355f351
Merge pull request #1651 from lam2003/3.0release
winlinvip Mar 21, 2020
f89b4b3
For #1651, fix return pnwrite of srs_write_large_iovs. 3.0.135
winlinvip Mar 21, 2020
850a4bb
Fix #1619, configure without utest by default. 3.0.136
winlinvip Mar 21, 2020
0dd6c31
Fix #1629, fix kickoff FLV client bug. 3.0.137
winlinvip Mar 21, 2020
be746da
Merge branch '3.0release' into 4.0release
winlinvip Mar 21, 2020
b12f0e8
Update readme
winlinvip Mar 24, 2020
b3b76b0
Update readme
winlinvip Mar 24, 2020
c339542
Support macOS OSX
winlinvip Mar 28, 2020
3556da4
Fix #1250, Support macOS, OSX, MacbookPro, Apple Darwin. 3.0.138
winlinvip Mar 28, 2020
2d287e3
Merge branch 'feature/macos' into 3.0release
winlinvip Mar 28, 2020
0a030a4
Update
winlinvip Mar 28, 2020
217b8b9
Merge 3.0release
winlinvip Mar 28, 2020
218fe33
For #1250, support osx build
winlinvip Mar 28, 2020
9e8b888
Merge branch '3.0release' into 4.0release
winlinvip Mar 28, 2020
98a7195
Support multiple OS/Platform build cache. 3.0.139
winlinvip Mar 28, 2020
3e0a7ee
Merge branch '3.0release' into 4.0release
winlinvip Mar 28, 2020
f674cab
Release 3.0-b4, 3.0.139
winlinvip Mar 29, 2020
d5339ac
Update package script
winlinvip Mar 29, 2020
c0a8193
Update build script
winlinvip Mar 29, 2020
0081525
Update package script
winlinvip Mar 29, 2020
f8b0bc1
Update build script
winlinvip Mar 29, 2020
b9a3df5
Update utest script
winlinvip Mar 29, 2020
2ba8104
Update coverage script
winlinvip Mar 29, 2020
1c65987
Refine links use relative path
winlinvip Mar 29, 2020
22ec783
Merge branch '3.0release' into 4.0release
winlinvip Mar 29, 2020
80f315f
Support utest on mac osx
winlinvip Mar 29, 2020
6b8f0d8
Merge branch '3.0release' into 4.0release
winlinvip Mar 29, 2020
c99fb99
refactor gb28181, supporting SIP server enable, multiplex, API interface
xialixin Mar 30, 2020
3345586
Merge branch 'dev-28181' of https://github.com/xialixin/srs into xial…
winlinvip Mar 31, 2020
a342f46
Merge branch '4.0release' into xialixin-dev-28181
winlinvip Mar 31, 2020
6012ac4
Refine code
winlinvip Mar 31, 2020
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
72 changes: 72 additions & 0 deletions trunk/conf/push.gb28181.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# push gb28281 stream to SRS.

listen 1935;
max_connections 1000;
daemon off;
pid ./objs/srs28181.pid;
srs_log_file ./objs/srs28181.log;
srs_log_tank console;
stream_caster {
enabled on;
caster gb28181;

#rtmp输出地址,可以参数化
#[stream] 代表客户端sip设备编号
#[timestamp] 时间戳
output rtmp://127.0.0.1/live/[stream];
#sip监听udp端口
listen 15060;

#服务器主机号,可以域名或ip地址
#也就是设备端将媒体发送的地址,如果是服务器是内外网
#需要写外网地址
host 192.168.1.27;

#服务器端编号
#设备端配置编号需要与该值一致,否则无法注册
serial 34020000002000000001;

#服务器端域
realm 3402000000;

#是否转发音频流
#目前只支持aac格式,所以需要设备支持aac格式
#on:转发音频
#off:不转发音频,只有视频
#*注意*!!!:flv 只支持11025 22050 44100 三种
#如果设备端没有三种中任何一个,转发时为自动选择一种格式
#同时也会将adts的头封装在flv aac raw数据中
#这样的话播放器为自动通过adts头自动选择采样频率
#像ffplay, vlc都可以,但是flash是没有声音,
#因为flash,只支持11025 22050 44100
audio_enable on;

#服务端发送ack后,接收回应的超时时间,单位为秒
#如果指定时间没有回应,认为失败
ack_timeout 30;

#设备心跳维持时间,如果指定时间内(秒)没有接收一个心跳
#认为设备离线
keepalive_timeout 30;

#是否等待关键帧之后,再转发,
#off:不需等待,直接转发
#on:等第一个关键帧后,再转发
wait_keyframe off;

#日志打印是否打印sip信息
#off:不打印
#on:打印接收或发送sip命令信息
print_sip_message off;

#rtp包空闲等待时间,如果指定时间没有收到任何包
#rtp监听连接自动停止,发送BYE命令
rtp_idle_timeout 30;

#rtp接收监听端口范围,最小值
rtp_port_min 58200;
#rtp接收监听端口范围,最大值
rtp_port_max 58300;
}
vhost __defaultVhost__ {
}
4 changes: 2 additions & 2 deletions trunk/configure
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ MODULE_DEPENDS=("CORE" "KERNEL")
ModuleLibIncs=(${SRS_OBJS_DIR} ${LibSSLRoot})
MODULE_FILES=("srs_protocol_amf0" "srs_protocol_io" "srs_rtmp_stack"
"srs_rtmp_handshake" "srs_protocol_utility" "srs_rtmp_msg_array" "srs_protocol_stream"
"srs_raw_avc" "srs_rtsp_stack" "srs_http_stack" "srs_protocol_kbps" "srs_protocol_json"
"srs_raw_avc" "srs_rtsp_stack" "srs_sip_stack" "srs_http_stack" "srs_protocol_kbps" "srs_protocol_json"
"srs_protocol_format")
PROTOCOL_INCS="src/protocol"; MODULE_DIR=${PROTOCOL_INCS} . auto/modules.sh
PROTOCOL_OBJS="${MODULE_OBJS[@]}"
Expand Down Expand Up @@ -257,7 +257,7 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
"srs_app_mpegts_udp" "srs_app_rtsp" "srs_app_listener" "srs_app_async_call"
"srs_app_caster_flv" "srs_app_process" "srs_app_ng_exec"
"srs_app_hourglass" "srs_app_dash" "srs_app_fragment" "srs_app_dvr"
"srs_app_coworkers" "srs_app_hybrid")
"srs_app_coworkers" "srs_app_hybrid" "srs_app_gb28181")
DEFINES=""
# add each modules for app
for SRS_MODULE in ${SRS_MODULES[*]}; do
Expand Down
174 changes: 173 additions & 1 deletion trunk/src/app/srs_app_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,11 @@ bool srs_stream_caster_is_flv(string caster)
return caster == "flv";
}

bool srs_stream_caster_is_gb28181(string caster)
{
return caster == "gb28181";
}

bool srs_config_apply_filter(SrsConfDirective* dvr_apply, SrsRequest* req)
{
static bool DEFAULT = true;
Expand Down Expand Up @@ -2137,7 +2142,26 @@ srs_error_t SrsConfig::global_to_json(SrsJsonObject* obj)
sobj->set(sdir->name, sdir->dumps_arg0_to_integer());
} else if (sdir->name == "rtp_port_max") {
sobj->set(sdir->name, sdir->dumps_arg0_to_integer());
} else if (sdir->name == "rtp_idle_timeout") {
sobj->set(sdir->name, sdir->dumps_arg0_to_integer());
} else if (sdir->name == "ack_timeout") {
sobj->set(sdir->name, sdir->dumps_arg0_to_integer());
} else if (sdir->name == "keepalive_timeout") {
sobj->set(sdir->name, sdir->dumps_arg0_to_integer());
} else if (sdir->name == "audio_enable") {
sobj->set(sdir->name, sdir->dumps_arg0_to_boolean());
} else if (sdir->name == "host") {
sobj->set(sdir->name, sdir->dumps_arg0_to_str());
} else if (sdir->name == "serial") {
sobj->set(sdir->name, sdir->dumps_arg0_to_str());
} else if (sdir->name == "realm") {
sobj->set(sdir->name, sdir->dumps_arg0_to_str());
} else if (sdir->name == "wait_keyframe") {
sobj->set(sdir->name, sdir->dumps_arg0_to_str());
} else if (sdir->name == "print_sip_message") {
sobj->set(sdir->name, sdir->dumps_arg0_to_str());
}

}
obj->set(dir->name, sobj);
} else {
Expand Down Expand Up @@ -3650,7 +3674,11 @@ srs_error_t SrsConfig::check_normal_config()
SrsConfDirective* conf = stream_caster->at(i);
string n = conf->name;
if (n != "enabled" && n != "caster" && n != "output"
&& n != "listen" && n != "rtp_port_min" && n != "rtp_port_max") {
&& n != "listen" && n != "rtp_port_min" && n != "rtp_port_max"
&& n != "rtp_idle_timeout" && n != "ack_timeout" && n != "keepalive_timeout"
&& n != "host" && n != "serial" && n != "realm"
&& n != "audio_enable" && n != "wait_keyframe"
&& n != "print_sip_message") {
return srs_error_new(ERROR_SYSTEM_CONFIG_INVALID, "illegal stream_caster.%s", n.c_str());
}
}
Expand Down Expand Up @@ -4266,6 +4294,150 @@ int SrsConfig::get_stream_caster_rtp_port_max(SrsConfDirective* conf)
return ::atoi(conf->arg0().c_str());
}

int SrsConfig::get_stream_caster_gb28181_rtp_ide_timeout(SrsConfDirective* conf)
{
static int DEFAULT = 30;

if (!conf) {
return DEFAULT;
}

conf = conf->get("rtp_ide_timeout");
if (!conf || conf->arg0().empty()) {
return DEFAULT;
}

return ::atoi(conf->arg0().c_str());
}

int SrsConfig::get_stream_caster_gb28181_ack_timeout(SrsConfDirective* conf)
{
static int DEFAULT = 30;

if (!conf) {
return DEFAULT;
}

conf = conf->get("ack_timeout");
if (!conf || conf->arg0().empty()) {
return DEFAULT;
}

return ::atoi(conf->arg0().c_str());
}

int SrsConfig::get_stream_caster_gb28181_keepalive_timeout(SrsConfDirective* conf)
{
static int DEFAULT = 30;

if (!conf) {
return DEFAULT;
}

conf = conf->get("keepalive_timeout");
if (!conf || conf->arg0().empty()) {
return DEFAULT;
}

return ::atoi(conf->arg0().c_str());
}

string SrsConfig::get_stream_caster_gb28181_host(SrsConfDirective* conf)
{
static string DEFAULT = "127.0.0.1";

if (!conf) {
return DEFAULT;
}

conf = conf->get("host");
if (!conf || conf->arg0().empty()) {
return DEFAULT;
}

return conf->arg0();
}

string SrsConfig::get_stream_caster_gb28181_serial(SrsConfDirective* conf)
{
static string DEFAULT = "";

if (!conf) {
return DEFAULT;
}

conf = conf->get("serial");
if (!conf || conf->arg0().empty()) {
return DEFAULT;
}

return conf->arg0();
}

string SrsConfig::get_stream_caster_gb28181_realm(SrsConfDirective* conf)
{
static string DEFAULT = "";

if (!conf) {
return DEFAULT;
}

conf = conf->get("realm");
if (!conf || conf->arg0().empty()) {
return DEFAULT;
}

return conf->arg0();
}

bool SrsConfig::get_stream_caster_gb28181_audio_enable(SrsConfDirective* conf)
{
static bool DEFAULT = true;

if (!conf) {
return DEFAULT;
}

conf = conf->get("audio_enable");
if (!conf || conf->arg0().empty()) {
return DEFAULT;
}

return SRS_CONF_PERFER_FALSE(conf->arg0());
}

bool SrsConfig::get_stream_caster_gb28181_print_sip_message(SrsConfDirective* conf)
{
static bool DEFAULT = false;

if (!conf) {
return DEFAULT;
}

conf = conf->get("print_sip_message");
if (!conf || conf->arg0().empty()) {
return DEFAULT;
}

return SRS_CONF_PERFER_FALSE(conf->arg0());
}

bool SrsConfig::get_stream_caster_gb28181_wait_keyframe(SrsConfDirective* conf)
{
static bool DEFAULT = false;

if (!conf) {
return DEFAULT;
}

conf = conf->get("wait_keyframe");
if (!conf || conf->arg0().empty()) {
return DEFAULT;
}

return SRS_CONF_PERFER_FALSE(conf->arg0());
}

SrsConfDirective* SrsConfig::get_vhost(string vhost, bool try_default_vhost)
{
srs_assert(root);
Expand Down
12 changes: 12 additions & 0 deletions trunk/src/app/srs_app_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ extern bool srs_config_dvr_is_plan_session(std::string plan);
extern bool srs_stream_caster_is_udp(std::string caster);
extern bool srs_stream_caster_is_rtsp(std::string caster);
extern bool srs_stream_caster_is_flv(std::string caster);
extern bool srs_stream_caster_is_gb28181(std::string caster);
// Whether the dvr_apply active the stream specified by req.
extern bool srs_config_apply_filter(SrsConfDirective* dvr_apply, SrsRequest* req);

Expand Down Expand Up @@ -498,6 +499,17 @@ class SrsConfig
virtual int get_stream_caster_rtp_port_min(SrsConfDirective* conf);
// Get the max udp port for rtp of stream caster rtsp.
virtual int get_stream_caster_rtp_port_max(SrsConfDirective* conf);

virtual int get_stream_caster_gb28181_rtp_ide_timeout(SrsConfDirective* conf);
virtual int get_stream_caster_gb28181_ack_timeout(SrsConfDirective* conf);
virtual int get_stream_caster_gb28181_keepalive_timeout(SrsConfDirective* conf);
virtual bool get_stream_caster_gb28181_audio_enable(SrsConfDirective* conf);
virtual std::string get_stream_caster_gb28181_host(SrsConfDirective* conf);
virtual std::string get_stream_caster_gb28181_serial(SrsConfDirective* conf);
virtual std::string get_stream_caster_gb28181_realm(SrsConfDirective* conf);
virtual bool get_stream_caster_gb28181_print_sip_message(SrsConfDirective* conf);
virtual bool get_stream_caster_gb28181_wait_keyframe(SrsConfDirective* conf);

// vhost specified section
public:
// Get the vhost directive by vhost name.
Expand Down
Loading