继续操作前请注册或者登录。
winlin

move some consts to kernel consts

@@ -1405,8 +1405,8 @@ SrsConfDirective* SrsConfig::get_vhost(string vhost) @@ -1405,8 +1405,8 @@ SrsConfDirective* SrsConfig::get_vhost(string vhost)
1405 } 1405 }
1406 } 1406 }
1407 1407
1408 - if (vhost != RTMP_VHOST_DEFAULT) {  
1409 - return get_vhost(RTMP_VHOST_DEFAULT); 1408 + if (vhost != SRS_CONSTS_RTMP_DEFAULT_VHOST) {
  1409 + return get_vhost(SRS_CONSTS_RTMP_DEFAULT_VHOST);
1410 } 1410 }
1411 1411
1412 return NULL; 1412 return NULL;
@@ -1575,7 +1575,7 @@ int SrsConfig::get_chunk_size(string vhost) @@ -1575,7 +1575,7 @@ int SrsConfig::get_chunk_size(string vhost)
1575 SrsConfDirective* conf = get_vhost(vhost); 1575 SrsConfDirective* conf = get_vhost(vhost);
1576 1576
1577 if (!conf) { 1577 if (!conf) {
1578 - return SRS_CONF_DEFAULT_CHUNK_SIZE; 1578 + return SRS_CONSTS_RTMP_SRS_CHUNK_SIZE;
1579 } 1579 }
1580 1580
1581 conf = conf->get("chunk_size"); 1581 conf = conf->get("chunk_size");
@@ -1584,7 +1584,7 @@ int SrsConfig::get_chunk_size(string vhost) @@ -1584,7 +1584,7 @@ int SrsConfig::get_chunk_size(string vhost)
1584 // use the global instead. 1584 // use the global instead.
1585 conf = root->get("chunk_size"); 1585 conf = root->get("chunk_size");
1586 if (!conf) { 1586 if (!conf) {
1587 - return SRS_CONF_DEFAULT_CHUNK_SIZE; 1587 + return SRS_CONSTS_RTMP_SRS_CHUNK_SIZE;
1588 } 1588 }
1589 1589
1590 return ::atoi(conf->arg0().c_str()); 1590 return ::atoi(conf->arg0().c_str());
@@ -35,12 +35,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -35,12 +35,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35 #include <srs_app_reload.hpp> 35 #include <srs_app_reload.hpp>
36 36
37 /////////////////////////////////////////////////////////// 37 ///////////////////////////////////////////////////////////
38 -// the value consts  
39 -///////////////////////////////////////////////////////////  
40 -#define SRS_CONSTS_NULL_FILE "/dev/null"  
41 -#define SRS_CONSTS_LOCALHOST "127.0.0.1"  
42 -  
43 -///////////////////////////////////////////////////////////  
44 // default consts values 38 // default consts values
45 /////////////////////////////////////////////////////////// 39 ///////////////////////////////////////////////////////////
46 #define SRS_CONF_DEFAULT_PID_FILE "./objs/srs.pid" 40 #define SRS_CONF_DEFAULT_PID_FILE "./objs/srs.pid"
@@ -285,8 +285,8 @@ int SrsEdgeIngester::connect_server() @@ -285,8 +285,8 @@ int SrsEdgeIngester::connect_server()
285 std::string server = conf->args.at(origin_index % conf->args.size()); 285 std::string server = conf->args.at(origin_index % conf->args.size());
286 origin_index = (origin_index + 1) % conf->args.size(); 286 origin_index = (origin_index + 1) % conf->args.size();
287 287
288 - std::string s_port = RTMP_DEFAULT_PORT;  
289 - int port = ::atoi(RTMP_DEFAULT_PORT); 288 + std::string s_port = SRS_CONSTS_RTMP_DEFAULT_PORT;
  289 + int port = ::atoi(SRS_CONSTS_RTMP_DEFAULT_PORT);
290 size_t pos = server.find(":"); 290 size_t pos = server.find(":");
291 if (pos != std::string::npos) { 291 if (pos != std::string::npos) {
292 s_port = server.substr(pos + 1); 292 s_port = server.substr(pos + 1);
@@ -538,8 +538,8 @@ int SrsEdgeForwarder::connect_server() @@ -538,8 +538,8 @@ int SrsEdgeForwarder::connect_server()
538 std::string server = conf->args.at(origin_index % conf->args.size()); 538 std::string server = conf->args.at(origin_index % conf->args.size());
539 origin_index = (origin_index + 1) % conf->args.size(); 539 origin_index = (origin_index + 1) % conf->args.size();
540 540
541 - std::string s_port = RTMP_DEFAULT_PORT;  
542 - int port = ::atoi(RTMP_DEFAULT_PORT); 541 + std::string s_port = SRS_CONSTS_RTMP_DEFAULT_PORT;
  542 + int port = ::atoi(SRS_CONSTS_RTMP_DEFAULT_PORT);
543 size_t pos = server.find(":"); 543 size_t pos = server.find(":");
544 if (pos != std::string::npos) { 544 if (pos != std::string::npos) {
545 s_port = server.substr(pos + 1); 545 s_port = server.substr(pos + 1);
@@ -34,6 +34,7 @@ using namespace std; @@ -34,6 +34,7 @@ using namespace std;
34 #include <srs_protocol_stack.hpp> 34 #include <srs_protocol_stack.hpp>
35 #include <srs_app_ffmpeg.hpp> 35 #include <srs_app_ffmpeg.hpp>
36 #include <srs_kernel_utility.hpp> 36 #include <srs_kernel_utility.hpp>
  37 +#include <srs_kernel_consts.hpp>
37 38
38 #ifdef SRS_AUTO_TRANSCODE 39 #ifdef SRS_AUTO_TRANSCODE
39 40
@@ -86,8 +86,8 @@ int SrsForwarder::on_publish(SrsRequest* req, std::string forward_server) @@ -86,8 +86,8 @@ int SrsForwarder::on_publish(SrsRequest* req, std::string forward_server)
86 86
87 stream_name = req->stream; 87 stream_name = req->stream;
88 server = forward_server; 88 server = forward_server;
89 - std::string s_port = RTMP_DEFAULT_PORT;  
90 - port = ::atoi(RTMP_DEFAULT_PORT); 89 + std::string s_port = SRS_CONSTS_RTMP_DEFAULT_PORT;
  90 + port = ::atoi(SRS_CONSTS_RTMP_DEFAULT_PORT);
91 91
92 // TODO: FIXME: parse complex params 92 // TODO: FIXME: parse complex params
93 size_t pos = forward_server.find(":"); 93 size_t pos = forward_server.find(":");
@@ -33,6 +33,7 @@ using namespace std; @@ -33,6 +33,7 @@ using namespace std;
33 #include <srs_app_ffmpeg.hpp> 33 #include <srs_app_ffmpeg.hpp>
34 #include <srs_app_pithy_print.hpp> 34 #include <srs_app_pithy_print.hpp>
35 #include <srs_kernel_utility.hpp> 35 #include <srs_kernel_utility.hpp>
  36 +#include <srs_kernel_consts.hpp>
36 37
37 // when error, ingester sleep for a while and retry. 38 // when error, ingester sleep for a while and retry.
38 // ingest never sleep a long time, for we must start the stream ASAP. 39 // ingest never sleep a long time, for we must start the stream ASAP.
@@ -933,8 +933,8 @@ int SrsRtmpConn::connect_server(int origin_index, st_netfd_t* pstsock) @@ -933,8 +933,8 @@ int SrsRtmpConn::connect_server(int origin_index, st_netfd_t* pstsock)
933 std::string server = conf->args.at(origin_index % conf->args.size()); 933 std::string server = conf->args.at(origin_index % conf->args.size());
934 origin_index = (origin_index + 1) % conf->args.size(); 934 origin_index = (origin_index + 1) % conf->args.size();
935 935
936 - std::string s_port = RTMP_DEFAULT_PORT;  
937 - int port = ::atoi(RTMP_DEFAULT_PORT); 936 + std::string s_port = SRS_CONSTS_RTMP_DEFAULT_PORT;
  937 + int port = ::atoi(SRS_CONSTS_RTMP_DEFAULT_PORT);
938 size_t pos = server.find(":"); 938 size_t pos = server.find(":");
939 if (pos != std::string::npos) { 939 if (pos != std::string::npos) {
940 s_port = server.substr(pos + 1); 940 s_port = server.substr(pos + 1);
@@ -36,6 +36,7 @@ using namespace std; @@ -36,6 +36,7 @@ using namespace std;
36 #include <srs_kernel_error.hpp> 36 #include <srs_kernel_error.hpp>
37 #include <srs_app_kbps.hpp> 37 #include <srs_app_kbps.hpp>
38 #include <srs_app_json.hpp> 38 #include <srs_app_json.hpp>
  39 +#include <srs_kernel_consts.hpp>
39 40
40 int srs_socket_connect(std::string server, int port, int64_t timeout, st_netfd_t* pstfd) 41 int srs_socket_connect(std::string server, int port, int64_t timeout, st_netfd_t* pstfd)
41 { 42 {
@@ -30,4 +30,24 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -30,4 +30,24 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 30
31 #include <srs_core.hpp> 31 #include <srs_core.hpp>
32 32
  33 +///////////////////////////////////////////////////////////
  34 +// RTMP consts values
  35 +///////////////////////////////////////////////////////////
  36 +// default vhost of rtmp
  37 +#define SRS_CONSTS_RTMP_DEFAULT_VHOST "__defaultVhost__"
  38 +// default port of rtmp
  39 +#define SRS_CONSTS_RTMP_DEFAULT_PORT "1935"
  40 +
  41 +// the default chunk size for system.
  42 +#define SRS_CONSTS_RTMP_SRS_CHUNK_SIZE 60000
  43 +// 6. Chunking, RTMP protocol default chunk size.
  44 +#define SRS_CONSTS_RTMP_PROTOCOL_CHUNK_SIZE 128
  45 +
  46 +///////////////////////////////////////////////////////////
  47 +// SRS consts values
  48 +///////////////////////////////////////////////////////////
  49 +#define SRS_CONSTS_NULL_FILE "/dev/null"
  50 +#define SRS_CONSTS_LOCALHOST "127.0.0.1"
  51 +
  52 +
33 #endif 53 #endif
@@ -605,11 +605,11 @@ int SrsRtmpClient::play(string stream, int stream_id) @@ -605,11 +605,11 @@ int SrsRtmpClient::play(string stream, int stream_id)
605 // SetChunkSize 605 // SetChunkSize
606 if (true) { 606 if (true) {
607 SrsSetChunkSizePacket* pkt = new SrsSetChunkSizePacket(); 607 SrsSetChunkSizePacket* pkt = new SrsSetChunkSizePacket();
608 - pkt->chunk_size = SRS_CONF_DEFAULT_CHUNK_SIZE; 608 + pkt->chunk_size = SRS_CONSTS_RTMP_SRS_CHUNK_SIZE;
609 if ((ret = protocol->send_and_free_packet(pkt, 0)) != ERROR_SUCCESS) { 609 if ((ret = protocol->send_and_free_packet(pkt, 0)) != ERROR_SUCCESS) {
610 srs_error("send set chunk size failed. " 610 srs_error("send set chunk size failed. "
611 "stream=%s, chunk_size=%d, ret=%d", 611 "stream=%s, chunk_size=%d, ret=%d",
612 - stream.c_str(), SRS_CONF_DEFAULT_CHUNK_SIZE, ret); 612 + stream.c_str(), SRS_CONSTS_RTMP_SRS_CHUNK_SIZE, ret);
613 return ret; 613 return ret;
614 } 614 }
615 } 615 }
@@ -624,11 +624,11 @@ int SrsRtmpClient::publish(string stream, int stream_id) @@ -624,11 +624,11 @@ int SrsRtmpClient::publish(string stream, int stream_id)
624 // SetChunkSize 624 // SetChunkSize
625 if (true) { 625 if (true) {
626 SrsSetChunkSizePacket* pkt = new SrsSetChunkSizePacket(); 626 SrsSetChunkSizePacket* pkt = new SrsSetChunkSizePacket();
627 - pkt->chunk_size = SRS_CONF_DEFAULT_CHUNK_SIZE; 627 + pkt->chunk_size = SRS_CONSTS_RTMP_SRS_CHUNK_SIZE;
628 if ((ret = protocol->send_and_free_packet(pkt, 0)) != ERROR_SUCCESS) { 628 if ((ret = protocol->send_and_free_packet(pkt, 0)) != ERROR_SUCCESS) {
629 srs_error("send set chunk size failed. " 629 srs_error("send set chunk size failed. "
630 "stream=%s, chunk_size=%d, ret=%d", 630 "stream=%s, chunk_size=%d, ret=%d",
631 - stream.c_str(), SRS_CONF_DEFAULT_CHUNK_SIZE, ret); 631 + stream.c_str(), SRS_CONSTS_RTMP_SRS_CHUNK_SIZE, ret);
632 return ret; 632 return ret;
633 } 633 }
634 } 634 }
@@ -31,6 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -31,6 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 #include <srs_kernel_stream.hpp> 31 #include <srs_kernel_stream.hpp>
32 #include <srs_core_autofree.hpp> 32 #include <srs_core_autofree.hpp>
33 #include <srs_kernel_utility.hpp> 33 #include <srs_kernel_utility.hpp>
  34 +#include <srs_kernel_consts.hpp>
34 35
35 using namespace std; 36 using namespace std;
36 37
@@ -177,7 +178,6 @@ messages. @@ -177,7 +178,6 @@ messages.
177 * good for high-bit rate streaming. Chunk size is maintained 178 * good for high-bit rate streaming. Chunk size is maintained
178 * independently for each direction. 179 * independently for each direction.
179 */ 180 */
180 -#define RTMP_DEFAULT_CHUNK_SIZE 128  
181 #define RTMP_MIN_CHUNK_SIZE 128 181 #define RTMP_MIN_CHUNK_SIZE 128
182 #define RTMP_MAX_CHUNK_SIZE 65536 182 #define RTMP_MAX_CHUNK_SIZE 65536
183 183
@@ -299,7 +299,7 @@ SrsProtocol::SrsProtocol(ISrsProtocolReaderWriter* io) @@ -299,7 +299,7 @@ SrsProtocol::SrsProtocol(ISrsProtocolReaderWriter* io)
299 in_buffer = new SrsBuffer(); 299 in_buffer = new SrsBuffer();
300 skt = io; 300 skt = io;
301 301
302 - in_chunk_size = out_chunk_size = RTMP_DEFAULT_CHUNK_SIZE; 302 + in_chunk_size = out_chunk_size = SRS_CONSTS_RTMP_PROTOCOL_CHUNK_SIZE;
303 } 303 }
304 304
305 SrsProtocol::~SrsProtocol() 305 SrsProtocol::~SrsProtocol()
@@ -3704,7 +3704,7 @@ int SrsAcknowledgementPacket::encode_packet(SrsStream* stream) @@ -3704,7 +3704,7 @@ int SrsAcknowledgementPacket::encode_packet(SrsStream* stream)
3704 3704
3705 SrsSetChunkSizePacket::SrsSetChunkSizePacket() 3705 SrsSetChunkSizePacket::SrsSetChunkSizePacket()
3706 { 3706 {
3707 - chunk_size = RTMP_DEFAULT_CHUNK_SIZE; 3707 + chunk_size = SRS_CONSTS_RTMP_PROTOCOL_CHUNK_SIZE;
3708 } 3708 }
3709 3709
3710 SrsSetChunkSizePacket::~SrsSetChunkSizePacket() 3710 SrsSetChunkSizePacket::~SrsSetChunkSizePacket()
@@ -49,7 +49,7 @@ void srs_discovery_tc_url( @@ -49,7 +49,7 @@ void srs_discovery_tc_url(
49 srs_info("discovery host=%s", host.c_str()); 49 srs_info("discovery host=%s", host.c_str());
50 } 50 }
51 51
52 - port = RTMP_DEFAULT_PORT; 52 + port = SRS_CONSTS_RTMP_DEFAULT_PORT;
53 if ((pos = host.find(":")) != std::string::npos) { 53 if ((pos = host.find(":")) != std::string::npos) {
54 port = host.substr(pos + 1); 54 port = host.substr(pos + 1);
55 host = host.substr(0, pos); 55 host = host.substr(0, pos);
@@ -117,13 +117,13 @@ string srs_generate_tc_url(string ip, string vhost, string app, string port, str @@ -117,13 +117,13 @@ string srs_generate_tc_url(string ip, string vhost, string app, string port, str
117 { 117 {
118 string tcUrl = "rtmp://"; 118 string tcUrl = "rtmp://";
119 119
120 - if (vhost == RTMP_VHOST_DEFAULT) { 120 + if (vhost == SRS_CONSTS_RTMP_DEFAULT_VHOST) {
121 tcUrl += ip; 121 tcUrl += ip;
122 } else { 122 } else {
123 tcUrl += vhost; 123 tcUrl += vhost;
124 } 124 }
125 125
126 - if (port != RTMP_DEFAULT_PORT) { 126 + if (port != SRS_CONSTS_RTMP_DEFAULT_PORT) {
127 tcUrl += ":"; 127 tcUrl += ":";
128 tcUrl += port; 128 tcUrl += port;
129 } 129 }
@@ -31,13 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -31,13 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 31
32 #include <string> 32 #include <string>
33 33
34 -// default vhost of rtmp  
35 -#define RTMP_VHOST_DEFAULT "__defaultVhost__"  
36 -// default port of rtmp  
37 -#define RTMP_DEFAULT_PORT "1935"  
38 -  
39 -// the default chunk size for system.  
40 -#define SRS_CONF_DEFAULT_CHUNK_SIZE 60000 34 +#include <srs_kernel_consts.hpp>
41 35
42 /** 36 /**
43 * parse the tcUrl, output the schema, host, vhost, app and port. 37 * parse the tcUrl, output the schema, host, vhost, app and port.