winlin

refine macros of HTTP

@@ -170,7 +170,7 @@ int SrsEdgeIngester::ingest() @@ -170,7 +170,7 @@ int SrsEdgeIngester::ingest()
170 170
171 client->set_recv_timeout(SRS_EDGE_INGESTER_TIMEOUT_US); 171 client->set_recv_timeout(SRS_EDGE_INGESTER_TIMEOUT_US);
172 172
173 - SrsPithyPrint pithy_print(SRS_STAGE_EDGE); 173 + SrsPithyPrint pithy_print(SRS_CONSTS_STAGE_EDGE);
174 174
175 while (pthread->can_loop()) { 175 while (pthread->can_loop()) {
176 // switch to other st-threads. 176 // switch to other st-threads.
@@ -413,7 +413,7 @@ int SrsEdgeForwarder::cycle() @@ -413,7 +413,7 @@ int SrsEdgeForwarder::cycle()
413 413
414 client->set_recv_timeout(SRS_CONSTS_RTMP_PULSE_TIMEOUT_US); 414 client->set_recv_timeout(SRS_CONSTS_RTMP_PULSE_TIMEOUT_US);
415 415
416 - SrsPithyPrint pithy_print(SRS_STAGE_EDGE); 416 + SrsPithyPrint pithy_print(SRS_CONSTS_STAGE_EDGE);
417 417
418 SrsSharedPtrMessageArray msgs(SYS_MAX_EDGE_SEND_MSGS); 418 SrsSharedPtrMessageArray msgs(SYS_MAX_EDGE_SEND_MSGS);
419 419
@@ -47,7 +47,7 @@ static std::vector<std::string> _transcoded_url; @@ -47,7 +47,7 @@ static std::vector<std::string> _transcoded_url;
47 SrsEncoder::SrsEncoder() 47 SrsEncoder::SrsEncoder()
48 { 48 {
49 pthread = new SrsThread(this, SRS_RTMP_ENCODER_SLEEP_US, true); 49 pthread = new SrsThread(this, SRS_RTMP_ENCODER_SLEEP_US, true);
50 - pithy_print = new SrsPithyPrint(SRS_STAGE_ENCODER); 50 + pithy_print = new SrsPithyPrint(SRS_CONSTS_STAGE_ENCODER);
51 } 51 }
52 52
53 SrsEncoder::~SrsEncoder() 53 SrsEncoder::~SrsEncoder()
@@ -284,7 +284,7 @@ int SrsForwarder::forward() @@ -284,7 +284,7 @@ int SrsForwarder::forward()
284 284
285 client->set_recv_timeout(SRS_CONSTS_RTMP_PULSE_TIMEOUT_US); 285 client->set_recv_timeout(SRS_CONSTS_RTMP_PULSE_TIMEOUT_US);
286 286
287 - SrsPithyPrint pithy_print(SRS_STAGE_FORWARDER); 287 + SrsPithyPrint pithy_print(SRS_CONSTS_STAGE_FORWARDER);
288 288
289 SrsSharedPtrMessageArray msgs(SYS_MAX_FORWARD_SEND_MSGS); 289 SrsSharedPtrMessageArray msgs(SYS_MAX_FORWARD_SEND_MSGS);
290 290
@@ -1342,7 +1342,7 @@ SrsHls::SrsHls(SrsSource* _source) @@ -1342,7 +1342,7 @@ SrsHls::SrsHls(SrsSource* _source)
1342 muxer = new SrsHlsMuxer(); 1342 muxer = new SrsHlsMuxer();
1343 hls_cache = new SrsHlsCache(); 1343 hls_cache = new SrsHlsCache();
1344 1344
1345 - pithy_print = new SrsPithyPrint(SRS_STAGE_HLS); 1345 + pithy_print = new SrsPithyPrint(SRS_CONSTS_STAGE_HLS);
1346 stream_dts = 0; 1346 stream_dts = 0;
1347 } 1347 }
1348 1348
@@ -217,107 +217,107 @@ int SrsHttpHandler::best_match(const char* path, int length, SrsHttpHandlerMatch @@ -217,107 +217,107 @@ int SrsHttpHandler::best_match(const char* path, int length, SrsHttpHandlerMatch
217 217
218 SrsHttpHandler* SrsHttpHandler::res_status_line(stringstream& ss) 218 SrsHttpHandler* SrsHttpHandler::res_status_line(stringstream& ss)
219 { 219 {
220 - ss << "HTTP/1.1 200 OK " << __CRLF  
221 - << "Server: "RTMP_SIG_SRS_KEY"/"RTMP_SIG_SRS_VERSION"" << __CRLF; 220 + ss << "HTTP/1.1 200 OK " << __SRS_CRLF
  221 + << "Server: "RTMP_SIG_SRS_KEY"/"RTMP_SIG_SRS_VERSION"" << __SRS_CRLF;
222 return this; 222 return this;
223 } 223 }
224 224
225 SrsHttpHandler* SrsHttpHandler::res_status_line_error(stringstream& ss, int code, string reason_phrase) 225 SrsHttpHandler* SrsHttpHandler::res_status_line_error(stringstream& ss, int code, string reason_phrase)
226 { 226 {
227 - ss << "HTTP/1.1 " << code << " " << reason_phrase << __CRLF  
228 - << "Server: SRS/"RTMP_SIG_SRS_VERSION"" << __CRLF; 227 + ss << "HTTP/1.1 " << code << " " << reason_phrase << __SRS_CRLF
  228 + << "Server: SRS/"RTMP_SIG_SRS_VERSION"" << __SRS_CRLF;
229 return this; 229 return this;
230 } 230 }
231 231
232 SrsHttpHandler* SrsHttpHandler::res_content_type(stringstream& ss) 232 SrsHttpHandler* SrsHttpHandler::res_content_type(stringstream& ss)
233 { 233 {
234 - ss << "Content-Type: text/html;charset=utf-8" << __CRLF  
235 - << "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __CRLF; 234 + ss << "Content-Type: text/html;charset=utf-8" << __SRS_CRLF
  235 + << "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __SRS_CRLF;
236 return this; 236 return this;
237 } 237 }
238 238
239 SrsHttpHandler* SrsHttpHandler::res_content_type_xml(stringstream& ss) 239 SrsHttpHandler* SrsHttpHandler::res_content_type_xml(stringstream& ss)
240 { 240 {
241 - ss << "Content-Type: text/xml;charset=utf-8" << __CRLF  
242 - << "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __CRLF; 241 + ss << "Content-Type: text/xml;charset=utf-8" << __SRS_CRLF
  242 + << "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __SRS_CRLF;
243 return this; 243 return this;
244 } 244 }
245 245
246 SrsHttpHandler* SrsHttpHandler::res_content_type_javascript(stringstream& ss) 246 SrsHttpHandler* SrsHttpHandler::res_content_type_javascript(stringstream& ss)
247 { 247 {
248 - ss << "Content-Type: text/javascript" << __CRLF  
249 - << "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __CRLF; 248 + ss << "Content-Type: text/javascript" << __SRS_CRLF
  249 + << "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __SRS_CRLF;
250 return this; 250 return this;
251 } 251 }
252 252
253 SrsHttpHandler* SrsHttpHandler::res_content_type_swf(stringstream& ss) 253 SrsHttpHandler* SrsHttpHandler::res_content_type_swf(stringstream& ss)
254 { 254 {
255 - ss << "Content-Type: application/x-shockwave-flash" << __CRLF  
256 - << "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __CRLF; 255 + ss << "Content-Type: application/x-shockwave-flash" << __SRS_CRLF
  256 + << "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __SRS_CRLF;
257 return this; 257 return this;
258 } 258 }
259 259
260 SrsHttpHandler* SrsHttpHandler::res_content_type_css(stringstream& ss) 260 SrsHttpHandler* SrsHttpHandler::res_content_type_css(stringstream& ss)
261 { 261 {
262 - ss << "Content-Type: text/css;charset=utf-8" << __CRLF  
263 - << "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __CRLF; 262 + ss << "Content-Type: text/css;charset=utf-8" << __SRS_CRLF
  263 + << "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __SRS_CRLF;
264 return this; 264 return this;
265 } 265 }
266 266
267 SrsHttpHandler* SrsHttpHandler::res_content_type_ico(stringstream& ss) 267 SrsHttpHandler* SrsHttpHandler::res_content_type_ico(stringstream& ss)
268 { 268 {
269 - ss << "Content-Type: image/x-icon" << __CRLF  
270 - << "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __CRLF; 269 + ss << "Content-Type: image/x-icon" << __SRS_CRLF
  270 + << "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __SRS_CRLF;
271 return this; 271 return this;
272 } 272 }
273 273
274 SrsHttpHandler* SrsHttpHandler::res_content_type_json(stringstream& ss) 274 SrsHttpHandler* SrsHttpHandler::res_content_type_json(stringstream& ss)
275 { 275 {
276 - ss << "Content-Type: application/json;charset=utf-8" << __CRLF  
277 - << "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __CRLF; 276 + ss << "Content-Type: application/json;charset=utf-8" << __SRS_CRLF
  277 + << "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __SRS_CRLF;
278 return this; 278 return this;
279 } 279 }
280 280
281 SrsHttpHandler* SrsHttpHandler::res_content_type_m3u8(stringstream& ss) 281 SrsHttpHandler* SrsHttpHandler::res_content_type_m3u8(stringstream& ss)
282 { 282 {
283 - ss << "Content-Type: application/x-mpegURL;charset=utf-8" << __CRLF  
284 - << "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __CRLF; 283 + ss << "Content-Type: application/x-mpegURL;charset=utf-8" << __SRS_CRLF
  284 + << "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __SRS_CRLF;
285 return this; 285 return this;
286 } 286 }
287 287
288 SrsHttpHandler* SrsHttpHandler::res_content_type_mpegts(stringstream& ss) 288 SrsHttpHandler* SrsHttpHandler::res_content_type_mpegts(stringstream& ss)
289 { 289 {
290 - ss << "Content-Type: video/MP2T" << __CRLF  
291 - << "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __CRLF; 290 + ss << "Content-Type: video/MP2T" << __SRS_CRLF
  291 + << "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __SRS_CRLF;
292 return this; 292 return this;
293 } 293 }
294 294
295 SrsHttpHandler* SrsHttpHandler::res_content_type_flv(stringstream& ss) 295 SrsHttpHandler* SrsHttpHandler::res_content_type_flv(stringstream& ss)
296 { 296 {
297 - ss << "Content-Type: video/x-flv" << __CRLF  
298 - << "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __CRLF; 297 + ss << "Content-Type: video/x-flv" << __SRS_CRLF
  298 + << "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __SRS_CRLF;
299 return this; 299 return this;
300 } 300 }
301 301
302 SrsHttpHandler* SrsHttpHandler::res_content_length(stringstream& ss, int64_t length) 302 SrsHttpHandler* SrsHttpHandler::res_content_length(stringstream& ss, int64_t length)
303 { 303 {
304 - ss << "Content-Length: "<< length << __CRLF; 304 + ss << "Content-Length: "<< length << __SRS_CRLF;
305 return this; 305 return this;
306 } 306 }
307 307
308 SrsHttpHandler* SrsHttpHandler::res_enable_crossdomain(stringstream& ss) 308 SrsHttpHandler* SrsHttpHandler::res_enable_crossdomain(stringstream& ss)
309 { 309 {
310 - ss << "Access-Control-Allow-Origin: *" << __CRLF 310 + ss << "Access-Control-Allow-Origin: *" << __SRS_CRLF
311 << "Access-Control-Allow-Methods: " 311 << "Access-Control-Allow-Methods: "
312 - << "GET, POST, HEAD, PUT, DELETE" << __CRLF 312 + << "GET, POST, HEAD, PUT, DELETE" << __SRS_CRLF
313 << "Access-Control-Allow-Headers: " 313 << "Access-Control-Allow-Headers: "
314 - << "Cache-Control,X-Proxy-Authorization,X-Requested-With,Content-Type" << __CRLF; 314 + << "Cache-Control,X-Proxy-Authorization,X-Requested-With,Content-Type" << __SRS_CRLF;
315 return this; 315 return this;
316 } 316 }
317 317
318 SrsHttpHandler* SrsHttpHandler::res_header_eof(stringstream& ss) 318 SrsHttpHandler* SrsHttpHandler::res_header_eof(stringstream& ss)
319 { 319 {
320 - ss << __CRLF; 320 + ss << __SRS_CRLF;
321 return this; 321 return this;
322 } 322 }
323 323
@@ -48,19 +48,19 @@ class SrsHttpHandler; @@ -48,19 +48,19 @@ class SrsHttpHandler;
48 48
49 // http specification 49 // http specification
50 // CR = <US-ASCII CR, carriage return (13)> 50 // CR = <US-ASCII CR, carriage return (13)>
51 -#define __CR "\r" // 0x0D 51 +#define __SRS_CR "\r" // 0x0D
52 // LF = <US-ASCII LF, linefeed (10)> 52 // LF = <US-ASCII LF, linefeed (10)>
53 -#define __LF "\n" // 0x0A 53 +#define __SRS_LF "\n" // 0x0A
54 // SP = <US-ASCII SP, space (32)> 54 // SP = <US-ASCII SP, space (32)>
55 -#define __SP " " // 0x20 55 +#define __SRS_SP " " // 0x20
56 // HT = <US-ASCII HT, horizontal-tab (9)> 56 // HT = <US-ASCII HT, horizontal-tab (9)>
57 -#define __HT "\x09" // 0x09 57 +#define __SRS_HT "\x09" // 0x09
58 58
59 // HTTP/1.1 defines the sequence CR LF as the end-of-line marker for all 59 // HTTP/1.1 defines the sequence CR LF as the end-of-line marker for all
60 // protocol elements except the entity-body (see appendix 19.3 for 60 // protocol elements except the entity-body (see appendix 19.3 for
61 // tolerant applications). 61 // tolerant applications).
62 -#define __CRLF "\r\n" // 0x0D0A  
63 -#define __CRLFCRLF "\r\n\r\n" // 0x0D0A0D0A 62 +#define __SRS_CRLF "\r\n" // 0x0D0A
  63 +#define __SRS_CRLFCRLF "\r\n\r\n" // 0x0D0A0D0A
64 64
65 // 6.1.1 Status Code and Reason Phrase 65 // 6.1.1 Status Code and Reason Phrase
66 #define HTTP_Continue 100 66 #define HTTP_Continue 100
@@ -76,13 +76,13 @@ int SrsHttpClient::post(SrsHttpUri* uri, string req, string& res) @@ -76,13 +76,13 @@ int SrsHttpClient::post(SrsHttpUri* uri, string req, string& res)
76 // POST %s HTTP/1.1\r\nHost: %s\r\nContent-Length: %d\r\n\r\n%s 76 // POST %s HTTP/1.1\r\nHost: %s\r\nContent-Length: %d\r\n\r\n%s
77 std::stringstream ss; 77 std::stringstream ss;
78 ss << "POST " << uri->get_path() << " " 78 ss << "POST " << uri->get_path() << " "
79 - << "HTTP/1.1" << __CRLF  
80 - << "Host: " << uri->get_host() << __CRLF  
81 - << "Connection: Keep-Alive" << __CRLF  
82 - << "Content-Length: " << std::dec << req.length() << __CRLF  
83 - << "User-Agent: " << RTMP_SIG_SRS_NAME << RTMP_SIG_SRS_VERSION << __CRLF  
84 - << "Content-Type: text/html" << __CRLF  
85 - << __CRLF 79 + << "HTTP/1.1" << __SRS_CRLF
  80 + << "Host: " << uri->get_host() << __SRS_CRLF
  81 + << "Connection: Keep-Alive" << __SRS_CRLF
  82 + << "Content-Length: " << std::dec << req.length() << __SRS_CRLF
  83 + << "User-Agent: " << RTMP_SIG_SRS_NAME << RTMP_SIG_SRS_VERSION << __SRS_CRLF
  84 + << "Content-Type: text/html" << __SRS_CRLF
  85 + << __SRS_CRLF
86 << req; 86 << req;
87 87
88 SrsSocket skt(stfd); 88 SrsSocket skt(stfd);
@@ -56,7 +56,7 @@ SrsIngester::SrsIngester() @@ -56,7 +56,7 @@ SrsIngester::SrsIngester()
56 _srs_config->subscribe(this); 56 _srs_config->subscribe(this);
57 57
58 pthread = new SrsThread(this, SRS_AUTO_INGESTER_SLEEP_US, true); 58 pthread = new SrsThread(this, SRS_AUTO_INGESTER_SLEEP_US, true);
59 - pithy_print = new SrsPithyPrint(SRS_STAGE_INGESTER); 59 + pithy_print = new SrsPithyPrint(SRS_CONSTS_STAGE_INGESTER);
60 } 60 }
61 61
62 SrsIngester::~SrsIngester() 62 SrsIngester::~SrsIngester()
@@ -32,7 +32,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -32,7 +32,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 #include <srs_kernel_error.hpp> 32 #include <srs_kernel_error.hpp>
33 #include <srs_kernel_utility.hpp> 33 #include <srs_kernel_utility.hpp>
34 34
35 -#define SRS_STAGE_DEFAULT_INTERVAL_MS 1200 35 +#define SRS_CONSTS_STAGE_DEFAULT_INTERVAL_MS 1200
36 36
37 SrsStageInfo::SrsStageInfo(int _stage_id) 37 SrsStageInfo::SrsStageInfo(int _stage_id)
38 { 38 {
@@ -53,36 +53,36 @@ SrsStageInfo::~SrsStageInfo() @@ -53,36 +53,36 @@ SrsStageInfo::~SrsStageInfo()
53 void SrsStageInfo::update_print_time() 53 void SrsStageInfo::update_print_time()
54 { 54 {
55 switch (stage_id) { 55 switch (stage_id) {
56 - case SRS_STAGE_PLAY_USER: { 56 + case SRS_CONSTS_STAGE_PLAY_USER: {
57 pithy_print_time_ms = _srs_config->get_pithy_print_play(); 57 pithy_print_time_ms = _srs_config->get_pithy_print_play();
58 break; 58 break;
59 } 59 }
60 - case SRS_STAGE_PUBLISH_USER: { 60 + case SRS_CONSTS_STAGE_PUBLISH_USER: {
61 pithy_print_time_ms = _srs_config->get_pithy_print_publish(); 61 pithy_print_time_ms = _srs_config->get_pithy_print_publish();
62 break; 62 break;
63 } 63 }
64 - case SRS_STAGE_FORWARDER: { 64 + case SRS_CONSTS_STAGE_FORWARDER: {
65 pithy_print_time_ms = _srs_config->get_pithy_print_forwarder(); 65 pithy_print_time_ms = _srs_config->get_pithy_print_forwarder();
66 break; 66 break;
67 } 67 }
68 - case SRS_STAGE_ENCODER: { 68 + case SRS_CONSTS_STAGE_ENCODER: {
69 pithy_print_time_ms = _srs_config->get_pithy_print_encoder(); 69 pithy_print_time_ms = _srs_config->get_pithy_print_encoder();
70 break; 70 break;
71 } 71 }
72 - case SRS_STAGE_INGESTER: { 72 + case SRS_CONSTS_STAGE_INGESTER: {
73 pithy_print_time_ms = _srs_config->get_pithy_print_ingester(); 73 pithy_print_time_ms = _srs_config->get_pithy_print_ingester();
74 break; 74 break;
75 } 75 }
76 - case SRS_STAGE_EDGE: { 76 + case SRS_CONSTS_STAGE_EDGE: {
77 pithy_print_time_ms = _srs_config->get_pithy_print_edge(); 77 pithy_print_time_ms = _srs_config->get_pithy_print_edge();
78 break; 78 break;
79 } 79 }
80 - case SRS_STAGE_HLS: { 80 + case SRS_CONSTS_STAGE_HLS: {
81 pithy_print_time_ms = _srs_config->get_pithy_print_hls(); 81 pithy_print_time_ms = _srs_config->get_pithy_print_hls();
82 break; 82 break;
83 } 83 }
84 default: { 84 default: {
85 - pithy_print_time_ms = SRS_STAGE_DEFAULT_INTERVAL_MS; 85 + pithy_print_time_ms = SRS_CONSTS_STAGE_DEFAULT_INTERVAL_MS;
86 break; 86 break;
87 } 87 }
88 } 88 }
@@ -32,21 +32,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -32,21 +32,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 32
33 #include <srs_app_reload.hpp> 33 #include <srs_app_reload.hpp>
34 34
35 -// the pithy stage for all play clients.  
36 -#define SRS_STAGE_PLAY_USER 1  
37 -// the pithy stage for all publish clients.  
38 -#define SRS_STAGE_PUBLISH_USER 2  
39 -// the pithy stage for all forward clients.  
40 -#define SRS_STAGE_FORWARDER 3  
41 -// the pithy stage for all encoders.  
42 -#define SRS_STAGE_ENCODER 4  
43 -// the pithy stage for all hls.  
44 -#define SRS_STAGE_HLS 5  
45 -// the pithy stage for all ingesters.  
46 -#define SRS_STAGE_INGESTER 6  
47 -// the pithy stage for all edge.  
48 -#define SRS_STAGE_EDGE 7  
49 -  
50 class SrsStageInfo : public ISrsReloadHandler 35 class SrsStageInfo : public ISrsReloadHandler
51 { 36 {
52 public: 37 public:
@@ -83,7 +68,7 @@ private: @@ -83,7 +68,7 @@ private:
83 int64_t previous_tick; 68 int64_t previous_tick;
84 public: 69 public:
85 /** 70 /**
86 - * @param _stage_id defined in SRS_STAGE_xxx, eg. SRS_STAGE_PLAY_USER. 71 + * @param _stage_id defined in SRS_CONSTS_STAGE_xxx, eg. SRS_CONSTS_STAGE_PLAY_USER.
87 */ 72 */
88 SrsPithyPrint(int _stage_id); 73 SrsPithyPrint(int _stage_id);
89 virtual ~SrsPithyPrint(); 74 virtual ~SrsPithyPrint();
@@ -503,7 +503,7 @@ int SrsRtmpConn::playing(SrsSource* source) @@ -503,7 +503,7 @@ int SrsRtmpConn::playing(SrsSource* source)
503 503
504 rtmp->set_recv_timeout(SRS_CONSTS_RTMP_PULSE_TIMEOUT_US); 504 rtmp->set_recv_timeout(SRS_CONSTS_RTMP_PULSE_TIMEOUT_US);
505 505
506 - SrsPithyPrint pithy_print(SRS_STAGE_PLAY_USER); 506 + SrsPithyPrint pithy_print(SRS_CONSTS_STAGE_PLAY_USER);
507 507
508 SrsSharedPtrMessageArray msgs(SYS_MAX_PLAY_SEND_MSGS); 508 SrsSharedPtrMessageArray msgs(SYS_MAX_PLAY_SEND_MSGS);
509 509
@@ -611,7 +611,7 @@ int SrsRtmpConn::fmle_publishing(SrsSource* source) @@ -611,7 +611,7 @@ int SrsRtmpConn::fmle_publishing(SrsSource* source)
611 } 611 }
612 srs_verbose("fmle check publish_refer success."); 612 srs_verbose("fmle check publish_refer success.");
613 613
614 - SrsPithyPrint pithy_print(SRS_STAGE_PUBLISH_USER); 614 + SrsPithyPrint pithy_print(SRS_CONSTS_STAGE_PUBLISH_USER);
615 615
616 bool vhost_is_edge = _srs_config->get_vhost_is_edge(req->vhost); 616 bool vhost_is_edge = _srs_config->get_vhost_is_edge(req->vhost);
617 617
@@ -690,7 +690,7 @@ int SrsRtmpConn::flash_publishing(SrsSource* source) @@ -690,7 +690,7 @@ int SrsRtmpConn::flash_publishing(SrsSource* source)
690 } 690 }
691 srs_verbose("flash check publish_refer success."); 691 srs_verbose("flash check publish_refer success.");
692 692
693 - SrsPithyPrint pithy_print(SRS_STAGE_PUBLISH_USER); 693 + SrsPithyPrint pithy_print(SRS_CONSTS_STAGE_PUBLISH_USER);
694 694
695 bool vhost_is_edge = _srs_config->get_vhost_is_edge(req->vhost); 695 bool vhost_is_edge = _srs_config->get_vhost_is_edge(req->vhost);
696 696
@@ -125,5 +125,29 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -125,5 +125,29 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
125 // encoder log id. 125 // encoder log id.
126 #define SRS_CONSTS_LOG_ENCODER "ENC" 126 #define SRS_CONSTS_LOG_ENCODER "ENC"
127 127
  128 +///////////////////////////////////////////////////////////
  129 +///////////////////////////////////////////////////////////
  130 +///////////////////////////////////////////////////////////
  131 +///////////////////////////////////////////////////////////
  132 +///////////////////////////////////////////////////////////
  133 +///////////////////////////////////////////////////////////
  134 +
  135 +///////////////////////////////////////////////////////////
  136 +// pithy-print consts values
  137 +///////////////////////////////////////////////////////////
  138 +// the pithy stage for all play clients.
  139 +#define SRS_CONSTS_STAGE_PLAY_USER 1
  140 +// the pithy stage for all publish clients.
  141 +#define SRS_CONSTS_STAGE_PUBLISH_USER 2
  142 +// the pithy stage for all forward clients.
  143 +#define SRS_CONSTS_STAGE_FORWARDER 3
  144 +// the pithy stage for all encoders.
  145 +#define SRS_CONSTS_STAGE_ENCODER 4
  146 +// the pithy stage for all hls.
  147 +#define SRS_CONSTS_STAGE_HLS 5
  148 +// the pithy stage for all ingesters.
  149 +#define SRS_CONSTS_STAGE_INGESTER 6
  150 +// the pithy stage for all edge.
  151 +#define SRS_CONSTS_STAGE_EDGE 7
128 152
129 #endif 153 #endif
@@ -583,14 +583,14 @@ namespace _srs_internal @@ -583,14 +583,14 @@ namespace _srs_internal
583 { 583 {
584 int ret = ERROR_SUCCESS; 584 int ret = ERROR_SUCCESS;
585 585
586 - char temp_key[OpensslHashSize]; 586 + char temp_key[SRS_CONSTS_OpensslHashSize];
587 if ((ret = openssl_HMACsha256(s1->get_digest(), 32, SrsGenuineFPKey, 62, temp_key)) != ERROR_SUCCESS) { 587 if ((ret = openssl_HMACsha256(s1->get_digest(), 32, SrsGenuineFPKey, 62, temp_key)) != ERROR_SUCCESS) {
588 srs_error("create c2 temp key failed. ret=%d", ret); 588 srs_error("create c2 temp key failed. ret=%d", ret);
589 return ret; 589 return ret;
590 } 590 }
591 srs_verbose("generate c2 temp key success."); 591 srs_verbose("generate c2 temp key success.");
592 592
593 - char _digest[OpensslHashSize]; 593 + char _digest[SRS_CONSTS_OpensslHashSize];
594 if ((ret = openssl_HMACsha256(random, 1504, temp_key, 32, _digest)) != ERROR_SUCCESS) { 594 if ((ret = openssl_HMACsha256(random, 1504, temp_key, 32, _digest)) != ERROR_SUCCESS) {
595 srs_error("create c2 digest failed. ret=%d", ret); 595 srs_error("create c2 digest failed. ret=%d", ret);
596 return ret; 596 return ret;
@@ -607,14 +607,14 @@ namespace _srs_internal @@ -607,14 +607,14 @@ namespace _srs_internal
607 is_valid = false; 607 is_valid = false;
608 int ret = ERROR_SUCCESS; 608 int ret = ERROR_SUCCESS;
609 609
610 - char temp_key[OpensslHashSize]; 610 + char temp_key[SRS_CONSTS_OpensslHashSize];
611 if ((ret = openssl_HMACsha256(s1->get_digest(), 32, SrsGenuineFPKey, 62, temp_key)) != ERROR_SUCCESS) { 611 if ((ret = openssl_HMACsha256(s1->get_digest(), 32, SrsGenuineFPKey, 62, temp_key)) != ERROR_SUCCESS) {
612 srs_error("create c2 temp key failed. ret=%d", ret); 612 srs_error("create c2 temp key failed. ret=%d", ret);
613 return ret; 613 return ret;
614 } 614 }
615 srs_verbose("generate c2 temp key success."); 615 srs_verbose("generate c2 temp key success.");
616 616
617 - char _digest[OpensslHashSize]; 617 + char _digest[SRS_CONSTS_OpensslHashSize];
618 if ((ret = openssl_HMACsha256(random, 1504, temp_key, 32, _digest)) != ERROR_SUCCESS) { 618 if ((ret = openssl_HMACsha256(random, 1504, temp_key, 32, _digest)) != ERROR_SUCCESS) {
619 srs_error("create c2 digest failed. ret=%d", ret); 619 srs_error("create c2 digest failed. ret=%d", ret);
620 return ret; 620 return ret;
@@ -630,14 +630,14 @@ namespace _srs_internal @@ -630,14 +630,14 @@ namespace _srs_internal
630 { 630 {
631 int ret = ERROR_SUCCESS; 631 int ret = ERROR_SUCCESS;
632 632
633 - char temp_key[OpensslHashSize]; 633 + char temp_key[SRS_CONSTS_OpensslHashSize];
634 if ((ret = openssl_HMACsha256(c1->get_digest(), 32, SrsGenuineFMSKey, 68, temp_key)) != ERROR_SUCCESS) { 634 if ((ret = openssl_HMACsha256(c1->get_digest(), 32, SrsGenuineFMSKey, 68, temp_key)) != ERROR_SUCCESS) {
635 srs_error("create s2 temp key failed. ret=%d", ret); 635 srs_error("create s2 temp key failed. ret=%d", ret);
636 return ret; 636 return ret;
637 } 637 }
638 srs_verbose("generate s2 temp key success."); 638 srs_verbose("generate s2 temp key success.");
639 639
640 - char _digest[OpensslHashSize]; 640 + char _digest[SRS_CONSTS_OpensslHashSize];
641 if ((ret = openssl_HMACsha256(random, 1504, temp_key, 32, _digest)) != ERROR_SUCCESS) { 641 if ((ret = openssl_HMACsha256(random, 1504, temp_key, 32, _digest)) != ERROR_SUCCESS) {
642 srs_error("create s2 digest failed. ret=%d", ret); 642 srs_error("create s2 digest failed. ret=%d", ret);
643 return ret; 643 return ret;
@@ -654,14 +654,14 @@ namespace _srs_internal @@ -654,14 +654,14 @@ namespace _srs_internal
654 is_valid = false; 654 is_valid = false;
655 int ret = ERROR_SUCCESS; 655 int ret = ERROR_SUCCESS;
656 656
657 - char temp_key[OpensslHashSize]; 657 + char temp_key[SRS_CONSTS_OpensslHashSize];
658 if ((ret = openssl_HMACsha256(c1->get_digest(), 32, SrsGenuineFMSKey, 68, temp_key)) != ERROR_SUCCESS) { 658 if ((ret = openssl_HMACsha256(c1->get_digest(), 32, SrsGenuineFMSKey, 68, temp_key)) != ERROR_SUCCESS) {
659 srs_error("create s2 temp key failed. ret=%d", ret); 659 srs_error("create s2 temp key failed. ret=%d", ret);
660 return ret; 660 return ret;
661 } 661 }
662 srs_verbose("generate s2 temp key success."); 662 srs_verbose("generate s2 temp key success.");
663 663
664 - char _digest[OpensslHashSize]; 664 + char _digest[SRS_CONSTS_OpensslHashSize];
665 if ((ret = openssl_HMACsha256(random, 1504, temp_key, 32, _digest)) != ERROR_SUCCESS) { 665 if ((ret = openssl_HMACsha256(random, 1504, temp_key, 32, _digest)) != ERROR_SUCCESS) {
666 srs_error("create s2 digest failed. ret=%d", ret); 666 srs_error("create s2 digest failed. ret=%d", ret);
667 return ret; 667 return ret;
@@ -921,7 +921,7 @@ namespace _srs_internal @@ -921,7 +921,7 @@ namespace _srs_internal
921 srs_assert(c1s1_joined_bytes != NULL); 921 srs_assert(c1s1_joined_bytes != NULL);
922 SrsAutoFree(char, c1s1_joined_bytes); 922 SrsAutoFree(char, c1s1_joined_bytes);
923 923
924 - digest = new char[OpensslHashSize]; 924 + digest = new char[SRS_CONSTS_OpensslHashSize];
925 if ((ret = openssl_HMACsha256(c1s1_joined_bytes, 1536 - 32, SrsGenuineFMSKey, 36, digest)) != ERROR_SUCCESS) { 925 if ((ret = openssl_HMACsha256(c1s1_joined_bytes, 1536 - 32, SrsGenuineFMSKey, 36, digest)) != ERROR_SUCCESS) {
926 srs_error("calc digest for s1 failed. ret=%d", ret); 926 srs_error("calc digest for s1 failed. ret=%d", ret);
927 return ret; 927 return ret;
@@ -948,7 +948,7 @@ namespace _srs_internal @@ -948,7 +948,7 @@ namespace _srs_internal
948 srs_assert(c1s1_joined_bytes != NULL); 948 srs_assert(c1s1_joined_bytes != NULL);
949 SrsAutoFree(char, c1s1_joined_bytes); 949 SrsAutoFree(char, c1s1_joined_bytes);
950 950
951 - digest = new char[OpensslHashSize]; 951 + digest = new char[SRS_CONSTS_OpensslHashSize];
952 if ((ret = openssl_HMACsha256(c1s1_joined_bytes, 1536 - 32, SrsGenuineFPKey, 30, digest)) != ERROR_SUCCESS) { 952 if ((ret = openssl_HMACsha256(c1s1_joined_bytes, 1536 - 32, SrsGenuineFPKey, 30, digest)) != ERROR_SUCCESS) {
953 srs_error("calc digest for c1 failed. ret=%d", ret); 953 srs_error("calc digest for c1 failed. ret=%d", ret);
954 return ret; 954 return ret;
@@ -111,7 +111,7 @@ namespace _srs_internal @@ -111,7 +111,7 @@ namespace _srs_internal
111 }; 111 };
112 112
113 // the digest key generate size. 113 // the digest key generate size.
114 - #define OpensslHashSize 512 114 + #define SRS_CONSTS_OpensslHashSize 512
115 extern u_int8_t SrsGenuineFMSKey[]; 115 extern u_int8_t SrsGenuineFMSKey[];
116 extern u_int8_t SrsGenuineFPKey[]; 116 extern u_int8_t SrsGenuineFPKey[];
117 int openssl_HMACsha256(const void* data, int data_size, const void* key, int key_size, void* digest); 117 int openssl_HMACsha256(const void* data, int data_size, const void* key, int key_size, void* digest);
@@ -217,7 +217,7 @@ VOID TEST(ProtocolHandshakeTest, OpensslSha256) @@ -217,7 +217,7 @@ VOID TEST(ProtocolHandshakeTest, OpensslSha256)
217 (char)0xfd, (char)0x48, (char)0xaa, (char)0xc1, (char)0xfa, (char)0xbf, (char)0x33, (char)0x87, (char)0x5c, (char)0x0d, (char)0xe5, (char)0x34, (char)0x24, (char)0x70, (char)0x14, (char)0x1e, (char)0x4a, (char)0x48, (char)0x07, (char)0x6e, (char)0xaf, (char)0xbf, (char)0xfe, (char)0x34, (char)0x1e, (char)0x1e, (char)0x19, (char)0xfc, (char)0xb5, (char)0x8a, (char)0x4f, (char)0x3c, (char)0xb4, (char)0xcf, (char)0xde, (char)0x24, (char)0x79, (char)0x65, (char)0x17, (char)0x22, (char)0x3f, (char)0xc0, (char)0x06, (char)0x76, (char)0x4e, (char)0x3c, (char)0xfb, (char)0xc3, (char)0xd0, (char)0x7f, (char)0x7b, (char)0x87, (char)0x5c, (char)0xeb, (char)0x97, (char)0x87, 217 (char)0xfd, (char)0x48, (char)0xaa, (char)0xc1, (char)0xfa, (char)0xbf, (char)0x33, (char)0x87, (char)0x5c, (char)0x0d, (char)0xe5, (char)0x34, (char)0x24, (char)0x70, (char)0x14, (char)0x1e, (char)0x4a, (char)0x48, (char)0x07, (char)0x6e, (char)0xaf, (char)0xbf, (char)0xfe, (char)0x34, (char)0x1e, (char)0x1e, (char)0x19, (char)0xfc, (char)0xb5, (char)0x8a, (char)0x4f, (char)0x3c, (char)0xb4, (char)0xcf, (char)0xde, (char)0x24, (char)0x79, (char)0x65, (char)0x17, (char)0x22, (char)0x3f, (char)0xc0, (char)0x06, (char)0x76, (char)0x4e, (char)0x3c, (char)0xfb, (char)0xc3, (char)0xd0, (char)0x7f, (char)0x7b, (char)0x87, (char)0x5c, (char)0xeb, (char)0x97, (char)0x87,
218 }; 218 };
219 219
220 - char digest[OpensslHashSize]; 220 + char digest[SRS_CONSTS_OpensslHashSize];
221 ASSERT_EQ(ERROR_SUCCESS, 221 ASSERT_EQ(ERROR_SUCCESS,
222 openssl_HMACsha256( 222 openssl_HMACsha256(
223 random_bytes, sizeof(random_bytes), 223 random_bytes, sizeof(random_bytes),