Refine code

pull/1656/head
winlin 5 years ago
parent a342f460e7
commit 6012ac4eb0

@ -226,64 +226,134 @@ http_server {
#############################################################################################
# the streamer cast stream from other protocol to SRS over RTMP.
# @see https://github.com/ossrs/srs/tree/develop#stream-architecture
# MPEGTS over UDP
stream_caster {
# whether stream caster is enabled.
# default: off
enabled off;
enabled on;
# the caster type of stream, the casters:
# mpegts_over_udp, MPEG-TS over UDP caster.
# rtsp, Real Time Streaming Protocol (RTSP).
# flv, FLV over HTTP by POST.
caster mpegts_over_udp;
# the output rtmp url.
# for mpegts_over_udp caster, the typically output url:
# rtmp://127.0.0.1/live/livestream
output rtmp://127.0.0.1/live/livestream;
# the listen port for stream caster.
# for mpegts_over_udp caster, listen at udp port. for example, 8935.
listen 8935;
}
# RTSP
stream_caster {
# whether stream caster is enabled.
# default: off
enabled on;
# the caster type of stream, the casters:
# rtsp, Real Time Streaming Protocol (RTSP).
caster rtsp;
# the output rtmp url.
# for rtsp caster, the typically output url:
# rtmp://127.0.0.1/[app]/[stream]
# for example, the rtsp url:
# rtsp://192.168.1.173:8544/live/livestream.sdp
# where the [app] is "live" and [stream] is "livestream", output is:
# rtmp://127.0.0.1/live/livestream
# for flv caster, the typically output url:
# rtmp://127.0.0.1/[app]/[stream]
# for example, POST to url:
# http://127.0.0.1:8936/live/livestream.flv
# where the [app] is "live" and [stream] is "livestream", output is:
# rtmp://127.0.0.1/live/livestream
output rtmp://127.0.0.1/live/livestream;
output rtmp://127.0.0.1/[app]/[stream];
# the listen port for stream caster.
# for mpegts_over_udp caster, listen at udp port. for example, 8935.
# for rtsp caster, listen at tcp port. for example, 554.
# for flv caster, listen at tcp port. for example, 8936.
# TODO: support listen at <[ip:]port>
listen 8935;
listen 554;
# for the rtsp caster, the rtp server local port over udp,
# which reply the rtsp setup request message, the port will be used:
# [rtp_port_min, rtp_port_max)
rtp_port_min 57200;
rtp_port_max 57300;
}
# FLV
stream_caster {
enabled off;
caster mpegts_over_udp;
output rtmp://127.0.0.1/live/livestream;
listen 8935;
}
stream_caster {
enabled off;
caster rtsp;
output rtmp://127.0.0.1/[app]/[stream];
listen 554;
rtp_port_min 57200;
rtp_port_max 57300;
}
stream_caster {
enabled off;
# whether stream caster is enabled.
# default: off
enabled on;
# the caster type of stream, the casters:
# flv, FLV over HTTP by POST.
caster flv;
# the output rtmp url.
# for flv caster, the typically output url:
# rtmp://127.0.0.1/[app]/[stream]
# for example, POST to url:
# http://127.0.0.1:8936/live/livestream.flv
# where the [app] is "live" and [stream] is "livestream", output is:
# rtmp://127.0.0.1/live/livestream
output rtmp://127.0.0.1/[app]/[stream];
# the listen port for stream caster.
# for flv caster, listen at tcp port. for example, 8936.
listen 8936;
}
# GB28181
stream_caster {
# whether stream caster is enabled.
# default: off
enabled on;
# the caster type of stream, the casters:
# gb28181, Push GB28181 to SRS.
caster gb28181;
# the output rtmp url.
# for gb28181 caster, the typically output url:
# rtmp://127.0.0.1/live/[stream]
# where the [stream] is the VideoChannelCodecID.
output rtmp://127.0.0.1/live/[stream];
# the listen port for stream caster.
# for gb28181 caster, listen at udp port. for example, 9000.
# @remark We can bundle all gb28181 to this port, to reuse this port.
# User can choose to bundle port in API port_mode or SIP invite_port_fixed.
listen 9000;
# If not bundle ports, use specified ports for each stream.
rtp_port_min 58200;
rtp_port_max 58300;
# Whether wait for keyframe then forward to RTMP.
wait_keyframe off;
# Max timeout in seconds for RTP stream, if timeout, RTCP bye and close stream.
# default: 30
rtp_idle_timeout 30;
# Whether has audio.
# @remark Flash/RTMP only supports 11025 22050 44100 sample rate, if not the audio may corrupt.
# default: off
audio_enable off;
# The exposed IP to receive media stream.
host 192.168.1.3;
sip {
# Whether enable embeded SIP server.
# default: on
enabled on;
# The SIP listen port.
# default: 5060
listen 5060;
# The SIP server ID.
# default: 34020000002000000001
serial 34020000002000000001;
# The SIP server domain.
# default: 3402000000
realm 3402000000;
# The SIP ACK response timeout in seconds.
# default: 30
ack_timeout 30;
# The keepalive timeout in seconds.
# default: 120
keepalive_timeout 120;
# Whether print SIP logs.
print_sip_message off;
# Whether play immediately after registered.
# default: on
auto_play on;
# Whether bundle media stream port.
# default: on
invite_port_fixed on;
}
}
#############################################################################################
# SRT server section
#############################################################################################

@ -3,8 +3,6 @@
listen 1935;
max_connections 1000;
daemon off;
pid ./objs/srs28181.pid;
srs_log_file ./objs/srs28181.log;
srs_log_tank console;
http_api {
@ -16,80 +14,84 @@ stream_caster {
enabled on;
caster gb28181;
#转发流到rtmp服务器地址与端口
# 转发流到rtmp服务器地址与端口
# TODO: https://github.com/ossrs/srs/pull/1679/files#r400875104
# [stream] is VideoChannelCodecID(视频通道编码ID)
output 127.0.0.1:1935;
#接收设备端rtp流的多路复用端口
# 接收设备端rtp流的多路复用端口
listen 9000;
#rtp接收监听端口范围最小值
# rtp接收监听端口范围最小值
rtp_port_min 58200;
#rtp接收监听端口范围最大值
# rtp接收监听端口范围最大值
rtp_port_max 58300;
#是否等待关键帧之后,再转发,
#off:不需等待,直接转发
#on:等第一个关键帧后,再转发
# 是否等待关键帧之后,再转发,
# off:不需等待,直接转发
# on:等第一个关键帧后,再转发
wait_keyframe off;
#rtp包空闲等待时间如果指定时间没有收到任何包
#rtp监听连接自动停止发送BYE命令
# rtp包空闲等待时间如果指定时间没有收到任何包
# rtp监听连接自动停止发送BYE命令
rtp_idle_timeout 30;
#是否转发音频流
#目前只支持aac格式所以需要设备支持aac格式
#on:转发音频
#off:不转发音频,只有视频
#*注意*!!!:flv 只支持11025 22050 44100 三种
#如果设备端没有三种中任何一个,转发时为自动选择一种格式
#同时也会将adts的头封装在flv aac raw数据中
#这样的话播放器为自动通过adts头自动选择采样频率
#像ffplay, vlc都可以但是flash是没有声音
#因为flash,只支持11025 22050 44100
audio_enable on;
# 是否转发音频流
# 目前只支持aac格式所以需要设备支持aac格式
# on:转发音频
# off:不转发音频,只有视频
# *注意*!!!:flv 只支持11025 22050 44100 三种
# 如果设备端没有三种中任何一个,转发时为自动选择一种格式
# 同时也会将adts的头封装在flv aac raw数据中
# 这样的话播放器为自动通过adts头自动选择采样频率
# 像ffplay, vlc都可以但是flash是没有声音
# 因为flash,只支持11025 22050 44100
audio_enable off;
#服务器主机号可以域名或ip地址
#也就是设备端将媒体发送的地址,如果是服务器是内外网
#需要写外网地址,
#调用api创建stream session时返回ip地址也是host
# 服务器主机号可以域名或ip地址
# 也就是设备端将媒体发送的地址,如果是服务器是内外网
# 需要写外网地址,
# 调用api创建stream session时返回ip地址也是host
# TODO: https://github.com/ossrs/srs/pull/1679/files#r400917594
host 192.168.1.27;
sip {
#是否启用srs内部sip信令
#为on信令走srs, off 只转发ps流
# 是否启用srs内部sip信令
# 为on信令走srs, off 只转发ps流
enabled on;
#sip监听udp端口
listen 15060;
# sip监听udp端口
listen 5060;
#服务器端编号
#设备端配置编号需要与该值一致,否则无法注册
# SIP server ID(SIP服务器ID).
# 设备端配置编号需要与该值一致,否则无法注册
serial 34020000002000000001;
#服务器
# SIP server domain(SIP服务器域)
realm 3402000000;
#服务端发送ack后接收回应的超时时间单位为秒
#如果指定时间没有回应,认为失败
# 服务端发送ack后接收回应的超时时间单位为秒
# 如果指定时间没有回应,认为失败
ack_timeout 30;
#设备心跳维持时间,如果指定时间内(秒)没有接收一个心跳
#认为设备离线
keepalive_timeout 30;
# 设备心跳维持时间,如果指定时间内(秒)没有接收一个心跳
# 认为设备离线
keepalive_timeout 120;
#日志打印是否打印sip信息
#off:不打印
#on:打印接收或发送sip命令信息
# 日志打印是否打印sip信息
# off:不打印
# on:打印接收或发送sip命令信息
# TODO: https://github.com/ossrs/srs/pull/1679/files#r400929300
print_sip_message off;
#注册之后是否自动给设备端发送invite
#on: 是 off 不是需要通过api控制
# 注册之后是否自动给设备端发送invite
# on: 是 off 不是需要通过api控制
auto_play on;
#设备将流发送的端口,是否固定
#on 发送流到多路复用端口 如9000
#off 自动从rtp_mix_port - rtp_max_port 之间的值中
#选一个可以用的端口
# 设备将流发送的端口,是否固定
# on 发送流到多路复用端口 如9000
# off 自动从rtp_mix_port - rtp_max_port 之间的值中
# 选一个可以用的端口
invite_port_fixed on;
}
}

@ -4310,9 +4310,9 @@ int SrsConfig::get_stream_caster_rtp_port_max(SrsConfDirective* conf)
return ::atoi(conf->arg0().c_str());
}
int SrsConfig::get_stream_caster_gb28181_rtp_idle_timeout(SrsConfDirective* conf)
srs_utime_t SrsConfig::get_stream_caster_gb28181_rtp_idle_timeout(SrsConfDirective* conf)
{
static int DEFAULT = 30;
static srs_utime_t DEFAULT = 30 * SRS_UTIME_SECONDS;
if (!conf) {
return DEFAULT;
@ -4323,7 +4323,7 @@ int SrsConfig::get_stream_caster_gb28181_rtp_idle_timeout(SrsConfDirective* conf
return DEFAULT;
}
return ::atoi(conf->arg0().c_str());
return (srs_utime_t)(::atoi(conf->arg0().c_str()) * SRS_UTIME_SECONDS);
}
int SrsConfig::get_stream_caster_gb28181_ack_timeout(SrsConfDirective* conf)
@ -4349,7 +4349,7 @@ int SrsConfig::get_stream_caster_gb28181_ack_timeout(SrsConfDirective* conf)
int SrsConfig::get_stream_caster_gb28181_keepalive_timeout(SrsConfDirective* conf)
{
static int DEFAULT = 30;
static int DEFAULT = 120;
if (!conf) {
return DEFAULT;
@ -4386,7 +4386,7 @@ string SrsConfig::get_stream_caster_gb28181_host(SrsConfDirective* conf)
string SrsConfig::get_stream_caster_gb28181_serial(SrsConfDirective* conf)
{
static string DEFAULT = "";
static string DEFAULT = "34020000002000000001";
if (!conf) {
return DEFAULT;
@ -4407,7 +4407,7 @@ string SrsConfig::get_stream_caster_gb28181_serial(SrsConfDirective* conf)
string SrsConfig::get_stream_caster_gb28181_realm(SrsConfDirective* conf)
{
static string DEFAULT = "";
static string DEFAULT = "3402000000";
if (!conf) {
return DEFAULT;
@ -4428,7 +4428,7 @@ string SrsConfig::get_stream_caster_gb28181_realm(SrsConfDirective* conf)
bool SrsConfig::get_stream_caster_gb28181_audio_enable(SrsConfDirective* conf)
{
static bool DEFAULT = true;
static bool DEFAULT = false;
if (!conf) {
return DEFAULT;
@ -4481,7 +4481,7 @@ bool SrsConfig::get_stream_caster_gb28181_wait_keyframe(SrsConfDirective* conf)
bool SrsConfig::get_stream_caster_gb28181_sip_enable(SrsConfDirective* conf)
{
static bool DEFAULT = false;
static bool DEFAULT = true;
if (!conf) {
return DEFAULT;
@ -4503,7 +4503,7 @@ bool SrsConfig::get_stream_caster_gb28181_sip_enable(SrsConfDirective* conf)
bool SrsConfig::get_stream_caster_gb28181_sip_auto_play(SrsConfDirective* conf)
{
static bool DEFAULT = false;
static bool DEFAULT = true;
if (!conf) {
return DEFAULT;
@ -4525,7 +4525,7 @@ bool SrsConfig::get_stream_caster_gb28181_sip_auto_play(SrsConfDirective* conf)
int SrsConfig::get_stream_caster_gb28181_sip_listen(SrsConfDirective* conf)
{
static int DEFAULT = 0;
static int DEFAULT = 5060;
if (!conf) {
return DEFAULT;

@ -500,7 +500,7 @@ public:
// 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_idle_timeout(SrsConfDirective* conf);
virtual srs_utime_t get_stream_caster_gb28181_rtp_idle_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);
@ -514,7 +514,6 @@ public:
virtual int get_stream_caster_gb28181_sip_listen(SrsConfDirective* conf);
virtual bool get_stream_caster_gb28181_sip_invite_port_fixed(SrsConfDirective* conf);
// vhost specified section
public:
// Get the vhost directive by vhost name.

@ -1,7 +1,7 @@
/**
* The MIT License (MIT)
*
* Copyright (c) 2013-2020 Winlin
* Copyright (c) 2013-2020 Lixin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
@ -749,7 +749,7 @@ srs_error_t SrsGb28181RtmpMuxer::do_cycle()
}
srs_utime_t now = srs_get_system_time();
srs_utime_t duration = (now - recv_stream_time) / (1000*1000);
srs_utime_t duration = now - recv_stream_time;
SrsGb28181Config config = gb28181_manger->get_gb28181_config();
if (duration > config.rtp_idle_timeout){

@ -1,7 +1,7 @@
/**
* The MIT License (MIT)
*
* Copyright (c) 2013-2020 Winlin
* Copyright (c) 2013-2020 Lixin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
@ -296,7 +296,7 @@ class SrsGb28181Config
{
public:
std::string host;
int rtp_idle_timeout;
srs_utime_t rtp_idle_timeout;
bool audio_enable;
bool wait_keyframe;
std::string output;

@ -1,7 +1,7 @@
/**
* The MIT License (MIT)
*
* Copyright (c) 2013-2020 Winlin
* Copyright (c) 2013-2020 Lixin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in

@ -1,7 +1,7 @@
/**
* The MIT License (MIT)
*
* Copyright (c) 2013-2020 Winlin
* Copyright (c) 2013-2020 Lixin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in

@ -1,7 +1,7 @@
/**
* The MIT License (MIT)
*
* Copyright (c) 2013-2020 Winlin
* Copyright (c) 2013-2020 Lixin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in

@ -1,7 +1,7 @@
/**
* The MIT License (MIT)
*
* Copyright (c) 2013-2020 Winlin
* Copyright (c) 2013-2020 Lixin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in

Loading…
Cancel
Save