-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
refactor gb28181, supporting SIP server enable, multiplex, API interface #1679
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,28 +6,35 @@ daemon off; | |
pid ./objs/srs28181.pid; | ||
srs_log_file ./objs/srs28181.log; | ||
srs_log_tank console; | ||
|
||
http_api { | ||
enabled on; | ||
listen 1985; | ||
} | ||
|
||
stream_caster { | ||
enabled on; | ||
caster gb28181; | ||
|
||
#rtmp输出地址,可以参数化 | ||
#[stream] 代表客户端sip设备编号 | ||
#[timestamp] 时间戳 | ||
output rtmp://127.0.0.1/live/[stream]; | ||
#sip监听udp端口 | ||
listen 15060; | ||
#转发流到rtmp服务器地址与端口 | ||
output 127.0.0.1:1935; | ||
|
||
#服务器主机号,可以域名或ip地址 | ||
#也就是设备端将媒体发送的地址,如果是服务器是内外网 | ||
#需要写外网地址 | ||
host 192.168.1.27; | ||
#接收设备端rtp流的多路复用端口 | ||
listen 9000; | ||
|
||
#服务器端编号 | ||
#设备端配置编号需要与该值一致,否则无法注册 | ||
serial 34020000002000000001; | ||
#rtp接收监听端口范围,最小值 | ||
rtp_port_min 58200; | ||
#rtp接收监听端口范围,最大值 | ||
rtp_port_max 58300; | ||
|
||
#服务器端域 | ||
realm 3402000000; | ||
#是否等待关键帧之后,再转发, | ||
#off:不需等待,直接转发 | ||
#on:等第一个关键帧后,再转发 | ||
wait_keyframe off; | ||
|
||
#rtp包空闲等待时间,如果指定时间没有收到任何包 | ||
#rtp监听连接自动停止,发送BYE命令 | ||
rtp_idle_timeout 30; | ||
|
||
#是否转发音频流 | ||
#目前只支持aac格式,所以需要设备支持aac格式 | ||
|
@@ -41,32 +48,50 @@ stream_caster { | |
#因为flash,只支持11025 22050 44100 | ||
audio_enable on; | ||
|
||
#服务端发送ack后,接收回应的超时时间,单位为秒 | ||
#如果指定时间没有回应,认为失败 | ||
ack_timeout 30; | ||
#服务器主机号,可以域名或ip地址 | ||
#也就是设备端将媒体发送的地址,如果是服务器是内外网 | ||
#需要写外网地址, | ||
#调用api创建stream session时返回ip地址也是host | ||
host 192.168.1.27; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This place needs support for a more comprehensive way of obtaining IP, refer to #307 (comment).
|
||
|
||
#设备心跳维持时间,如果指定时间内(秒)没有接收一个心跳 | ||
#认为设备离线 | ||
keepalive_timeout 30; | ||
sip { | ||
#是否启用srs内部sip信令 | ||
#为on信令走srs, off 只转发ps流 | ||
enabled on; | ||
|
||
#sip监听udp端口 | ||
listen 15060; | ||
|
||
#服务器端编号 | ||
#设备端配置编号需要与该值一致,否则无法注册 | ||
serial 34020000002000000001; | ||
|
||
#是否等待关键帧之后,再转发, | ||
#off:不需等待,直接转发 | ||
#on:等第一个关键帧后,再转发 | ||
wait_keyframe off; | ||
#服务器端域 | ||
realm 3402000000; | ||
|
||
#日志打印是否打印sip信息 | ||
#off:不打印 | ||
#on:打印接收或发送sip命令信息 | ||
print_sip_message off; | ||
|
||
#rtp包空闲等待时间,如果指定时间没有收到任何包 | ||
#rtp监听连接自动停止,发送BYE命令 | ||
rtp_idle_timeout 30; | ||
#服务端发送ack后,接收回应的超时时间,单位为秒 | ||
#如果指定时间没有回应,认为失败 | ||
ack_timeout 30; | ||
|
||
#rtp接收监听端口范围,最小值 | ||
rtp_port_min 58200; | ||
#rtp接收监听端口范围,最大值 | ||
rtp_port_max 58300; | ||
#设备心跳维持时间,如果指定时间内(秒)没有接收一个心跳 | ||
#认为设备离线 | ||
keepalive_timeout 30; | ||
|
||
#日志打印是否打印sip信息 | ||
#off:不打印 | ||
#on:打印接收或发送sip命令信息 | ||
print_sip_message off; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Change to log-level, srs_info level log, enable info log.
|
||
|
||
#注册之后是否自动给设备端发送invite | ||
#on: 是 off 不是,需要通过api控制 | ||
auto_play on; | ||
|
||
#设备将流发送的端口,是否固定 | ||
#on 发送流到多路复用端口 如9000 | ||
#off 自动从rtp_mix_port - rtp_max_port 之间的值中 | ||
#选一个可以用的端口 | ||
invite_port_fixed on; | ||
} | ||
} | ||
vhost __defaultVhost__ { | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2160,6 +2160,10 @@ srs_error_t SrsConfig::global_to_json(SrsJsonObject* obj) | |
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()); | ||
} else if (sdir->name == "invite_port_fixed") { | ||
sobj->set(sdir->name, sdir->dumps_arg0_to_str()); | ||
} else if (sdir->name == "auto_play") { | ||
sobj->set(sdir->name, sdir->dumps_arg0_to_str()); | ||
} | ||
|
||
} | ||
|
@@ -3672,12 +3676,24 @@ srs_error_t SrsConfig::check_normal_config() | |
string n = conf->name; | ||
if (n != "enabled" && n != "caster" && n != "output" | ||
&& 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 != "rtp_idle_timeout" && n != "sip" | ||
&& n != "audio_enable" && n != "wait_keyframe" | ||
&& n != "print_sip_message") { | ||
&& n != "host") { | ||
return srs_error_new(ERROR_SYSTEM_CONFIG_INVALID, "illegal stream_caster.%s", n.c_str()); | ||
} | ||
|
||
if (n == "sip") { | ||
for (int j = 0; j < (int)conf->directives.size(); j++) { | ||
string m = conf->at(j)->name; | ||
if (m != "enabled" && m != "listen" | ||
&& m != "ack_timeout" && m != "keepalive_timeout" | ||
&& m != "host" && m != "serial" && m != "realm" | ||
&& m != "print_sip_message" && m != "auto_play" | ||
&& m != "invite_port_fixed") { | ||
return srs_error_new(ERROR_SYSTEM_CONFIG_INVALID, "illegal stream_caster.%s", m.c_str()); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
@@ -4207,15 +4223,15 @@ 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) | ||
int SrsConfig::get_stream_caster_gb28181_rtp_idle_timeout(SrsConfDirective* conf) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use srs_utime_t uniformly, which is defined in time, and there are also related macro definitions for converting time. Please make sure to change it together in other places.
|
||
{ | ||
static int DEFAULT = 30; | ||
|
||
if (!conf) { | ||
return DEFAULT; | ||
} | ||
|
||
conf = conf->get("rtp_ide_timeout"); | ||
conf = conf->get("rtp_idle_timeout"); | ||
if (!conf || conf->arg0().empty()) { | ||
return DEFAULT; | ||
} | ||
|
@@ -4230,6 +4246,11 @@ int SrsConfig::get_stream_caster_gb28181_ack_timeout(SrsConfDirective* conf) | |
if (!conf) { | ||
return DEFAULT; | ||
} | ||
|
||
conf = conf->get("sip"); | ||
if (!conf) { | ||
return DEFAULT; | ||
} | ||
|
||
conf = conf->get("ack_timeout"); | ||
if (!conf || conf->arg0().empty()) { | ||
|
@@ -4246,6 +4267,11 @@ int SrsConfig::get_stream_caster_gb28181_keepalive_timeout(SrsConfDirective* con | |
if (!conf) { | ||
return DEFAULT; | ||
} | ||
|
||
conf = conf->get("sip"); | ||
if (!conf) { | ||
return DEFAULT; | ||
} | ||
|
||
conf = conf->get("keepalive_timeout"); | ||
if (!conf || conf->arg0().empty()) { | ||
|
@@ -4257,12 +4283,12 @@ int SrsConfig::get_stream_caster_gb28181_keepalive_timeout(SrsConfDirective* con | |
|
||
string SrsConfig::get_stream_caster_gb28181_host(SrsConfDirective* conf) | ||
{ | ||
static string DEFAULT = "127.0.0.1"; | ||
static string DEFAULT = ""; | ||
|
||
if (!conf) { | ||
return DEFAULT; | ||
} | ||
|
||
conf = conf->get("host"); | ||
if (!conf || conf->arg0().empty()) { | ||
return DEFAULT; | ||
|
@@ -4278,6 +4304,11 @@ string SrsConfig::get_stream_caster_gb28181_serial(SrsConfDirective* conf) | |
if (!conf) { | ||
return DEFAULT; | ||
} | ||
|
||
conf = conf->get("sip"); | ||
if (!conf) { | ||
return DEFAULT; | ||
} | ||
|
||
conf = conf->get("serial"); | ||
if (!conf || conf->arg0().empty()) { | ||
|
@@ -4294,6 +4325,11 @@ string SrsConfig::get_stream_caster_gb28181_realm(SrsConfDirective* conf) | |
if (!conf) { | ||
return DEFAULT; | ||
} | ||
|
||
conf = conf->get("sip"); | ||
if (!conf) { | ||
return DEFAULT; | ||
} | ||
|
||
conf = conf->get("realm"); | ||
if (!conf || conf->arg0().empty()) { | ||
|
@@ -4326,6 +4362,11 @@ bool SrsConfig::get_stream_caster_gb28181_print_sip_message(SrsConfDirective* co | |
if (!conf) { | ||
return DEFAULT; | ||
} | ||
|
||
conf = conf->get("sip"); | ||
if (!conf) { | ||
return DEFAULT; | ||
} | ||
|
||
conf = conf->get("print_sip_message"); | ||
if (!conf || conf->arg0().empty()) { | ||
|
@@ -4351,6 +4392,95 @@ bool SrsConfig::get_stream_caster_gb28181_wait_keyframe(SrsConfDirective* conf) | |
return SRS_CONF_PERFER_FALSE(conf->arg0()); | ||
} | ||
|
||
bool SrsConfig::get_stream_caster_gb28181_sip_enable(SrsConfDirective* conf) | ||
{ | ||
static bool DEFAULT = false; | ||
|
||
if (!conf) { | ||
return DEFAULT; | ||
} | ||
|
||
conf = conf->get("sip"); | ||
if (!conf) { | ||
return DEFAULT; | ||
} | ||
|
||
conf = conf->get("enabled"); | ||
if (!conf || conf->arg0().empty()) { | ||
return DEFAULT; | ||
} | ||
|
||
return SRS_CONF_PERFER_FALSE(conf->arg0()); | ||
|
||
} | ||
|
||
bool SrsConfig::get_stream_caster_gb28181_sip_auto_play(SrsConfDirective* conf) | ||
{ | ||
static bool DEFAULT = false; | ||
|
||
if (!conf) { | ||
return DEFAULT; | ||
} | ||
|
||
conf = conf->get("sip"); | ||
if (!conf) { | ||
return DEFAULT; | ||
} | ||
|
||
conf = conf->get("auto_play"); | ||
if (!conf || conf->arg0().empty()) { | ||
return DEFAULT; | ||
} | ||
|
||
return SRS_CONF_PERFER_FALSE(conf->arg0()); | ||
|
||
} | ||
|
||
int SrsConfig::get_stream_caster_gb28181_sip_listen(SrsConfDirective* conf) | ||
{ | ||
static int DEFAULT = 0; | ||
|
||
if (!conf) { | ||
return DEFAULT; | ||
} | ||
|
||
conf = conf->get("sip"); | ||
if (!conf) { | ||
return DEFAULT; | ||
} | ||
|
||
conf = conf->get("listen"); | ||
if (!conf || conf->arg0().empty()) { | ||
return DEFAULT; | ||
} | ||
|
||
return ::atoi(conf->arg0().c_str()); | ||
|
||
} | ||
|
||
bool SrsConfig::get_stream_caster_gb28181_sip_invite_port_fixed(SrsConfDirective* conf) | ||
{ | ||
static bool DEFAULT = true; | ||
|
||
if (!conf) { | ||
return DEFAULT; | ||
} | ||
|
||
conf = conf->get("sip"); | ||
if (!conf) { | ||
return DEFAULT; | ||
} | ||
|
||
conf = conf->get("invite_port_fixed"); | ||
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); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
需要改成rtmp地址,这样用户可以指定app。' translates to:
'Need to change to rtmp address so that users can specify the app.
TRANS_BY_GPT3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[stream]
is thevideo channel encoding ID
.TRANS_BY_GPT3