正在显示
3 个修改的文件
包含
43 行增加
和
19 行删除
@@ -1181,6 +1181,8 @@ int SrsConfig::check_config() | @@ -1181,6 +1181,8 @@ int SrsConfig::check_config() | ||
1181 | { | 1181 | { |
1182 | int ret = ERROR_SUCCESS; | 1182 | int ret = ERROR_SUCCESS; |
1183 | 1183 | ||
1184 | + vector<SrsConfDirective*> vhosts = get_vhosts(); | ||
1185 | + | ||
1184 | //////////////////////////////////////////////////////////////////////// | 1186 | //////////////////////////////////////////////////////////////////////// |
1185 | // check empty | 1187 | // check empty |
1186 | //////////////////////////////////////////////////////////////////////// | 1188 | //////////////////////////////////////////////////////////////////////// |
@@ -1256,7 +1258,6 @@ int SrsConfig::check_config() | @@ -1256,7 +1258,6 @@ int SrsConfig::check_config() | ||
1256 | } | 1258 | } |
1257 | } | 1259 | } |
1258 | if (true) { | 1260 | if (true) { |
1259 | - vector<SrsConfDirective*> vhosts = get_vhosts(); | ||
1260 | for (int i = 0; i < (int)vhosts.size(); i++) { | 1261 | for (int i = 0; i < (int)vhosts.size(); i++) { |
1261 | SrsConfDirective* conf = vhosts[i]; | 1262 | SrsConfDirective* conf = vhosts[i]; |
1262 | for (int i = 0; conf && i < (int)conf->directives.size(); i++) { | 1263 | for (int i = 0; conf && i < (int)conf->directives.size(); i++) { |
@@ -1441,7 +1442,30 @@ int SrsConfig::check_config() | @@ -1441,7 +1442,30 @@ int SrsConfig::check_config() | ||
1441 | return ret; | 1442 | return ret; |
1442 | } | 1443 | } |
1443 | 1444 | ||
1444 | - // TODO: FIXME: check others. | 1445 | + //////////////////////////////////////////////////////////////////////// |
1446 | + // check chunk size | ||
1447 | + //////////////////////////////////////////////////////////////////////// | ||
1448 | + if (get_global_chunk_size() < SRS_CONSTS_RTMP_MIN_CHUNK_SIZE | ||
1449 | + || get_global_chunk_size() > SRS_CONSTS_RTMP_MAX_CHUNK_SIZE | ||
1450 | + ) { | ||
1451 | + ret = ERROR_SYSTEM_CONFIG_INVALID; | ||
1452 | + srs_error("directive chunk_size invalid, chunk_size=%d, must in [%d, %d], ret=%d", | ||
1453 | + get_global_chunk_size(), SRS_CONSTS_RTMP_MIN_CHUNK_SIZE, | ||
1454 | + SRS_CONSTS_RTMP_MAX_CHUNK_SIZE, ret); | ||
1455 | + return ret; | ||
1456 | + } | ||
1457 | + for (int i = 0; i < (int)vhosts.size(); i++) { | ||
1458 | + SrsConfDirective* vhost = vhosts[i]; | ||
1459 | + if (get_chunk_size(vhost->arg0()) < SRS_CONSTS_RTMP_MIN_CHUNK_SIZE | ||
1460 | + || get_chunk_size(vhost->arg0()) > SRS_CONSTS_RTMP_MAX_CHUNK_SIZE | ||
1461 | + ) { | ||
1462 | + ret = ERROR_SYSTEM_CONFIG_INVALID; | ||
1463 | + srs_error("directive vhost %s chunk_size invalid, chunk_size=%d, must in [%d, %d], ret=%d", | ||
1464 | + vhost->arg0().c_str(), get_chunk_size(vhost->arg0()), SRS_CONSTS_RTMP_MIN_CHUNK_SIZE, | ||
1465 | + SRS_CONSTS_RTMP_MAX_CHUNK_SIZE, ret); | ||
1466 | + return ret; | ||
1467 | + } | ||
1468 | + } | ||
1445 | 1469 | ||
1446 | //////////////////////////////////////////////////////////////////////// | 1470 | //////////////////////////////////////////////////////////////////////// |
1447 | // check log name and level | 1471 | // check log name and level |
@@ -1475,7 +1499,6 @@ int SrsConfig::check_config() | @@ -1475,7 +1499,6 @@ int SrsConfig::check_config() | ||
1475 | srs_warn("http_api is disabled by configure"); | 1499 | srs_warn("http_api is disabled by configure"); |
1476 | } | 1500 | } |
1477 | #endif | 1501 | #endif |
1478 | - vector<SrsConfDirective*> vhosts = get_vhosts(); | ||
1479 | for (int i = 0; i < (int)vhosts.size(); i++) { | 1502 | for (int i = 0; i < (int)vhosts.size(); i++) { |
1480 | SrsConfDirective* vhost = vhosts[i]; | 1503 | SrsConfDirective* vhost = vhosts[i]; |
1481 | srs_assert(vhost != NULL); | 1504 | srs_assert(vhost != NULL); |
@@ -50,6 +50,20 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -50,6 +50,20 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
50 | // 6. Chunking, RTMP protocol default chunk size. | 50 | // 6. Chunking, RTMP protocol default chunk size. |
51 | #define SRS_CONSTS_RTMP_PROTOCOL_CHUNK_SIZE 128 | 51 | #define SRS_CONSTS_RTMP_PROTOCOL_CHUNK_SIZE 128 |
52 | 52 | ||
53 | +/** | ||
54 | +* 6. Chunking | ||
55 | +* The chunk size is configurable. It can be set using a control | ||
56 | +* message(Set Chunk Size) as described in section 7.1. The maximum | ||
57 | +* chunk size can be 65536 bytes and minimum 128 bytes. Larger values | ||
58 | +* reduce CPU usage, but also commit to larger writes that can delay | ||
59 | +* other content on lower bandwidth connections. Smaller chunks are not | ||
60 | +* good for high-bit rate streaming. Chunk size is maintained | ||
61 | +* independently for each direction. | ||
62 | +*/ | ||
63 | +#define SRS_CONSTS_RTMP_MIN_CHUNK_SIZE 128 | ||
64 | +#define SRS_CONSTS_RTMP_MAX_CHUNK_SIZE 65536 | ||
65 | + | ||
66 | + | ||
53 | // the following is the timeout for rtmp protocol, | 67 | // the following is the timeout for rtmp protocol, |
54 | // to avoid death connection. | 68 | // to avoid death connection. |
55 | 69 |
@@ -169,19 +169,6 @@ messages. | @@ -169,19 +169,6 @@ messages. | ||
169 | ***************************************************************************** | 169 | ***************************************************************************** |
170 | ****************************************************************************/ | 170 | ****************************************************************************/ |
171 | /** | 171 | /** |
172 | -* 6. Chunking | ||
173 | -* The chunk size is configurable. It can be set using a control | ||
174 | -* message(Set Chunk Size) as described in section 7.1. The maximum | ||
175 | -* chunk size can be 65536 bytes and minimum 128 bytes. Larger values | ||
176 | -* reduce CPU usage, but also commit to larger writes that can delay | ||
177 | -* other content on lower bandwidth connections. Smaller chunks are not | ||
178 | -* good for high-bit rate streaming. Chunk size is maintained | ||
179 | -* independently for each direction. | ||
180 | -*/ | ||
181 | -#define RTMP_MIN_CHUNK_SIZE 128 | ||
182 | -#define RTMP_MAX_CHUNK_SIZE 65536 | ||
183 | - | ||
184 | -/** | ||
185 | * 6.1. Chunk Format | 172 | * 6.1. Chunk Format |
186 | * Extended timestamp: 0 or 4 bytes | 173 | * Extended timestamp: 0 or 4 bytes |
187 | * This field MUST be sent when the normal timsestamp is set to | 174 | * This field MUST be sent when the normal timsestamp is set to |
@@ -3724,16 +3711,16 @@ int SrsSetChunkSizePacket::decode(SrsStream* stream) | @@ -3724,16 +3711,16 @@ int SrsSetChunkSizePacket::decode(SrsStream* stream) | ||
3724 | chunk_size = stream->read_4bytes(); | 3711 | chunk_size = stream->read_4bytes(); |
3725 | srs_info("decode chunk size success. chunk_size=%d", chunk_size); | 3712 | srs_info("decode chunk size success. chunk_size=%d", chunk_size); |
3726 | 3713 | ||
3727 | - if (chunk_size < RTMP_MIN_CHUNK_SIZE) { | 3714 | + if (chunk_size < SRS_CONSTS_RTMP_MIN_CHUNK_SIZE) { |
3728 | ret = ERROR_RTMP_CHUNK_SIZE; | 3715 | ret = ERROR_RTMP_CHUNK_SIZE; |
3729 | srs_error("invalid chunk size. min=%d, actual=%d, ret=%d", | 3716 | srs_error("invalid chunk size. min=%d, actual=%d, ret=%d", |
3730 | ERROR_RTMP_CHUNK_SIZE, chunk_size, ret); | 3717 | ERROR_RTMP_CHUNK_SIZE, chunk_size, ret); |
3731 | return ret; | 3718 | return ret; |
3732 | } | 3719 | } |
3733 | - if (chunk_size > RTMP_MAX_CHUNK_SIZE) { | 3720 | + if (chunk_size > SRS_CONSTS_RTMP_MAX_CHUNK_SIZE) { |
3734 | ret = ERROR_RTMP_CHUNK_SIZE; | 3721 | ret = ERROR_RTMP_CHUNK_SIZE; |
3735 | srs_error("invalid chunk size. max=%d, actual=%d, ret=%d", | 3722 | srs_error("invalid chunk size. max=%d, actual=%d, ret=%d", |
3736 | - RTMP_MAX_CHUNK_SIZE, chunk_size, ret); | 3723 | + SRS_CONSTS_RTMP_MAX_CHUNK_SIZE, chunk_size, ret); |
3737 | return ret; | 3724 | return ret; |
3738 | } | 3725 | } |
3739 | 3726 |
-
请 注册 或 登录 后发表评论