winlin

refine http for srs, rename SrsGoHttp to SrsHttp.

@@ -53,7 +53,7 @@ using namespace std; @@ -53,7 +53,7 @@ using namespace std;
53 53
54 #define SRS_HTTP_DEFAULT_PAGE "index.html" 54 #define SRS_HTTP_DEFAULT_PAGE "index.html"
55 55
56 -int srs_go_http_response_json(ISrsGoHttpResponseWriter* w, string data) 56 +int srs_go_http_response_json(ISrsHttpResponseWriter* w, string data)
57 { 57 {
58 w->header()->set_content_length(data.length()); 58 w->header()->set_content_length(data.length());
59 w->header()->set_content_type("application/json"); 59 w->header()->set_content_type("application/json");
@@ -147,7 +147,7 @@ string srs_go_http_detect(char* data, int size) @@ -147,7 +147,7 @@ string srs_go_http_detect(char* data, int size)
147 147
148 // Error replies to the request with the specified error message and HTTP code. 148 // Error replies to the request with the specified error message and HTTP code.
149 // The error message should be plain text. 149 // The error message should be plain text.
150 -int srs_go_http_error(ISrsGoHttpResponseWriter* w, int code, string error) 150 +int srs_go_http_error(ISrsHttpResponseWriter* w, int code, string error)
151 { 151 {
152 int ret = ERROR_SUCCESS; 152 int ret = ERROR_SUCCESS;
153 153
@@ -159,20 +159,20 @@ int srs_go_http_error(ISrsGoHttpResponseWriter* w, int code, string error) @@ -159,20 +159,20 @@ int srs_go_http_error(ISrsGoHttpResponseWriter* w, int code, string error)
159 return ret; 159 return ret;
160 } 160 }
161 161
162 -SrsGoHttpHeader::SrsGoHttpHeader() 162 +SrsHttpHeader::SrsHttpHeader()
163 { 163 {
164 } 164 }
165 165
166 -SrsGoHttpHeader::~SrsGoHttpHeader() 166 +SrsHttpHeader::~SrsHttpHeader()
167 { 167 {
168 } 168 }
169 169
170 -void SrsGoHttpHeader::set(string key, string value) 170 +void SrsHttpHeader::set(string key, string value)
171 { 171 {
172 headers[key] = value; 172 headers[key] = value;
173 } 173 }
174 174
175 -string SrsGoHttpHeader::get(string key) 175 +string SrsHttpHeader::get(string key)
176 { 176 {
177 std::string v; 177 std::string v;
178 178
@@ -183,7 +183,7 @@ string SrsGoHttpHeader::get(string key) @@ -183,7 +183,7 @@ string SrsGoHttpHeader::get(string key)
183 return v; 183 return v;
184 } 184 }
185 185
186 -int64_t SrsGoHttpHeader::content_length() 186 +int64_t SrsHttpHeader::content_length()
187 { 187 {
188 std::string cl = get("Content-Length"); 188 std::string cl = get("Content-Length");
189 189
@@ -194,24 +194,24 @@ int64_t SrsGoHttpHeader::content_length() @@ -194,24 +194,24 @@ int64_t SrsGoHttpHeader::content_length()
194 return (int64_t)::atof(cl.c_str()); 194 return (int64_t)::atof(cl.c_str());
195 } 195 }
196 196
197 -void SrsGoHttpHeader::set_content_length(int64_t size) 197 +void SrsHttpHeader::set_content_length(int64_t size)
198 { 198 {
199 char buf[64]; 199 char buf[64];
200 snprintf(buf, sizeof(buf), "%"PRId64, size); 200 snprintf(buf, sizeof(buf), "%"PRId64, size);
201 set("Content-Length", buf); 201 set("Content-Length", buf);
202 } 202 }
203 203
204 -string SrsGoHttpHeader::content_type() 204 +string SrsHttpHeader::content_type()
205 { 205 {
206 return get("Content-Type"); 206 return get("Content-Type");
207 } 207 }
208 208
209 -void SrsGoHttpHeader::set_content_type(string ct) 209 +void SrsHttpHeader::set_content_type(string ct)
210 { 210 {
211 set("Content-Type", ct); 211 set("Content-Type", ct);
212 } 212 }
213 213
214 -void SrsGoHttpHeader::write(stringstream& ss) 214 +void SrsHttpHeader::write(stringstream& ss)
215 { 215 {
216 std::map<std::string, std::string>::iterator it; 216 std::map<std::string, std::string>::iterator it;
217 for (it = headers.begin(); it != headers.end(); ++it) { 217 for (it = headers.begin(); it != headers.end(); ++it) {
@@ -219,64 +219,64 @@ void SrsGoHttpHeader::write(stringstream& ss) @@ -219,64 +219,64 @@ void SrsGoHttpHeader::write(stringstream& ss)
219 } 219 }
220 } 220 }
221 221
222 -ISrsGoHttpResponseWriter::ISrsGoHttpResponseWriter() 222 +ISrsHttpResponseWriter::ISrsHttpResponseWriter()
223 { 223 {
224 } 224 }
225 225
226 -ISrsGoHttpResponseWriter::~ISrsGoHttpResponseWriter() 226 +ISrsHttpResponseWriter::~ISrsHttpResponseWriter()
227 { 227 {
228 } 228 }
229 229
230 -ISrsGoHttpHandler::ISrsGoHttpHandler() 230 +ISrsHttpHandler::ISrsHttpHandler()
231 { 231 {
232 entry = NULL; 232 entry = NULL;
233 } 233 }
234 234
235 -ISrsGoHttpHandler::~ISrsGoHttpHandler() 235 +ISrsHttpHandler::~ISrsHttpHandler()
236 { 236 {
237 } 237 }
238 238
239 -SrsGoHttpRedirectHandler::SrsGoHttpRedirectHandler(string u, int c) 239 +SrsHttpRedirectHandler::SrsHttpRedirectHandler(string u, int c)
240 { 240 {
241 url = u; 241 url = u;
242 code = c; 242 code = c;
243 } 243 }
244 244
245 -SrsGoHttpRedirectHandler::~SrsGoHttpRedirectHandler() 245 +SrsHttpRedirectHandler::~SrsHttpRedirectHandler()
246 { 246 {
247 } 247 }
248 248
249 -int SrsGoHttpRedirectHandler::serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r) 249 +int SrsHttpRedirectHandler::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r)
250 { 250 {
251 int ret = ERROR_SUCCESS; 251 int ret = ERROR_SUCCESS;
252 // TODO: FIXME: implements it. 252 // TODO: FIXME: implements it.
253 return ret; 253 return ret;
254 } 254 }
255 255
256 -SrsGoHttpNotFoundHandler::SrsGoHttpNotFoundHandler() 256 +SrsHttpNotFoundHandler::SrsHttpNotFoundHandler()
257 { 257 {
258 } 258 }
259 259
260 -SrsGoHttpNotFoundHandler::~SrsGoHttpNotFoundHandler() 260 +SrsHttpNotFoundHandler::~SrsHttpNotFoundHandler()
261 { 261 {
262 } 262 }
263 263
264 -int SrsGoHttpNotFoundHandler::serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r) 264 +int SrsHttpNotFoundHandler::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r)
265 { 265 {
266 return srs_go_http_error(w, 266 return srs_go_http_error(w,
267 SRS_CONSTS_HTTP_NotFound, SRS_CONSTS_HTTP_NotFound_str); 267 SRS_CONSTS_HTTP_NotFound, SRS_CONSTS_HTTP_NotFound_str);
268 } 268 }
269 269
270 -SrsGoHttpFileServer::SrsGoHttpFileServer(string root_dir) 270 +SrsHttpFileServer::SrsHttpFileServer(string root_dir)
271 { 271 {
272 dir = root_dir; 272 dir = root_dir;
273 } 273 }
274 274
275 -SrsGoHttpFileServer::~SrsGoHttpFileServer() 275 +SrsHttpFileServer::~SrsHttpFileServer()
276 { 276 {
277 } 277 }
278 278
279 -int SrsGoHttpFileServer::serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r) 279 +int SrsHttpFileServer::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r)
280 { 280 {
281 string upath = r->path(); 281 string upath = r->path();
282 282
@@ -300,7 +300,7 @@ int SrsGoHttpFileServer::serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* @@ -300,7 +300,7 @@ int SrsGoHttpFileServer::serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage*
300 if (!srs_path_exists(fullpath)) { 300 if (!srs_path_exists(fullpath)) {
301 srs_warn("http miss file=%s, pattern=%s, upath=%s", 301 srs_warn("http miss file=%s, pattern=%s, upath=%s",
302 fullpath.c_str(), entry->pattern.c_str(), upath.c_str()); 302 fullpath.c_str(), entry->pattern.c_str(), upath.c_str());
303 - return SrsGoHttpNotFoundHandler().serve_http(w, r); 303 + return SrsHttpNotFoundHandler().serve_http(w, r);
304 } 304 }
305 srs_trace("http match file=%s, pattern=%s, upath=%s", 305 srs_trace("http match file=%s, pattern=%s, upath=%s",
306 fullpath.c_str(), entry->pattern.c_str(), upath.c_str()); 306 fullpath.c_str(), entry->pattern.c_str(), upath.c_str());
@@ -317,7 +317,7 @@ int SrsGoHttpFileServer::serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* @@ -317,7 +317,7 @@ int SrsGoHttpFileServer::serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage*
317 return serve_file(w, r, fullpath); 317 return serve_file(w, r, fullpath);
318 } 318 }
319 319
320 -int SrsGoHttpFileServer::serve_file(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r, string fullpath) 320 +int SrsHttpFileServer::serve_file(ISrsHttpResponseWriter* w, SrsHttpMessage* r, string fullpath)
321 { 321 {
322 int ret = ERROR_SUCCESS; 322 int ret = ERROR_SUCCESS;
323 323
@@ -391,7 +391,7 @@ int SrsGoHttpFileServer::serve_file(ISrsGoHttpResponseWriter* w, SrsHttpMessage* @@ -391,7 +391,7 @@ int SrsGoHttpFileServer::serve_file(ISrsGoHttpResponseWriter* w, SrsHttpMessage*
391 return w->final_request(); 391 return w->final_request();
392 } 392 }
393 393
394 -int SrsGoHttpFileServer::serve_flv_file(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r, string fullpath) 394 +int SrsHttpFileServer::serve_flv_file(ISrsHttpResponseWriter* w, SrsHttpMessage* r, string fullpath)
395 { 395 {
396 std::string start = r->query_get("start"); 396 std::string start = r->query_get("start");
397 if (start.empty()) { 397 if (start.empty()) {
@@ -406,7 +406,7 @@ int SrsGoHttpFileServer::serve_flv_file(ISrsGoHttpResponseWriter* w, SrsHttpMess @@ -406,7 +406,7 @@ int SrsGoHttpFileServer::serve_flv_file(ISrsGoHttpResponseWriter* w, SrsHttpMess
406 return serve_flv_stream(w, r, fullpath, offset); 406 return serve_flv_stream(w, r, fullpath, offset);
407 } 407 }
408 408
409 -int SrsGoHttpFileServer::serve_mp4_file(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r, string fullpath) 409 +int SrsHttpFileServer::serve_mp4_file(ISrsHttpResponseWriter* w, SrsHttpMessage* r, string fullpath)
410 { 410 {
411 // for flash to request mp4 range in query string. 411 // for flash to request mp4 range in query string.
412 // for example, http://digitalprimates.net/dash/DashTest.html?url=http://dashdemo.edgesuite.net/digitalprimates/nexus/oops-20120802-manifest.mpd 412 // for example, http://digitalprimates.net/dash/DashTest.html?url=http://dashdemo.edgesuite.net/digitalprimates/nexus/oops-20120802-manifest.mpd
@@ -443,17 +443,17 @@ int SrsGoHttpFileServer::serve_mp4_file(ISrsGoHttpResponseWriter* w, SrsHttpMess @@ -443,17 +443,17 @@ int SrsGoHttpFileServer::serve_mp4_file(ISrsGoHttpResponseWriter* w, SrsHttpMess
443 return serve_mp4_stream(w, r, fullpath, start, end); 443 return serve_mp4_stream(w, r, fullpath, start, end);
444 } 444 }
445 445
446 -int SrsGoHttpFileServer::serve_flv_stream(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r, string fullpath, int offset) 446 +int SrsHttpFileServer::serve_flv_stream(ISrsHttpResponseWriter* w, SrsHttpMessage* r, string fullpath, int offset)
447 { 447 {
448 return serve_file(w, r, fullpath); 448 return serve_file(w, r, fullpath);
449 } 449 }
450 450
451 -int SrsGoHttpFileServer::serve_mp4_stream(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r, string fullpath, int start, int end) 451 +int SrsHttpFileServer::serve_mp4_stream(ISrsHttpResponseWriter* w, SrsHttpMessage* r, string fullpath, int start, int end)
452 { 452 {
453 return serve_file(w, r, fullpath); 453 return serve_file(w, r, fullpath);
454 } 454 }
455 455
456 -int SrsGoHttpFileServer::copy(ISrsGoHttpResponseWriter* w, SrsFileReader* fs, SrsHttpMessage* r, int size) 456 +int SrsHttpFileServer::copy(ISrsHttpResponseWriter* w, SrsFileReader* fs, SrsHttpMessage* r, int size)
457 { 457 {
458 int ret = ERROR_SUCCESS; 458 int ret = ERROR_SUCCESS;
459 459
@@ -476,27 +476,27 @@ int SrsGoHttpFileServer::copy(ISrsGoHttpResponseWriter* w, SrsFileReader* fs, Sr @@ -476,27 +476,27 @@ int SrsGoHttpFileServer::copy(ISrsGoHttpResponseWriter* w, SrsFileReader* fs, Sr
476 return ret; 476 return ret;
477 } 477 }
478 478
479 -SrsGoHttpMuxEntry::SrsGoHttpMuxEntry() 479 +SrsHttpMuxEntry::SrsHttpMuxEntry()
480 { 480 {
481 enabled = true; 481 enabled = true;
482 explicit_match = false; 482 explicit_match = false;
483 handler = NULL; 483 handler = NULL;
484 } 484 }
485 485
486 -SrsGoHttpMuxEntry::~SrsGoHttpMuxEntry() 486 +SrsHttpMuxEntry::~SrsHttpMuxEntry()
487 { 487 {
488 srs_freep(handler); 488 srs_freep(handler);
489 } 489 }
490 490
491 -SrsGoHttpServeMux::SrsGoHttpServeMux() 491 +SrsHttpServeMux::SrsHttpServeMux()
492 { 492 {
493 } 493 }
494 494
495 -SrsGoHttpServeMux::~SrsGoHttpServeMux() 495 +SrsHttpServeMux::~SrsHttpServeMux()
496 { 496 {
497 - std::map<std::string, SrsGoHttpMuxEntry*>::iterator it; 497 + std::map<std::string, SrsHttpMuxEntry*>::iterator it;
498 for (it = entries.begin(); it != entries.end(); ++it) { 498 for (it = entries.begin(); it != entries.end(); ++it) {
499 - SrsGoHttpMuxEntry* entry = it->second; 499 + SrsHttpMuxEntry* entry = it->second;
500 srs_freep(entry); 500 srs_freep(entry);
501 } 501 }
502 entries.clear(); 502 entries.clear();
@@ -504,14 +504,14 @@ SrsGoHttpServeMux::~SrsGoHttpServeMux() @@ -504,14 +504,14 @@ SrsGoHttpServeMux::~SrsGoHttpServeMux()
504 vhosts.clear(); 504 vhosts.clear();
505 } 505 }
506 506
507 -int SrsGoHttpServeMux::initialize() 507 +int SrsHttpServeMux::initialize()
508 { 508 {
509 int ret = ERROR_SUCCESS; 509 int ret = ERROR_SUCCESS;
510 // TODO: FIXME: implements it. 510 // TODO: FIXME: implements it.
511 return ret; 511 return ret;
512 } 512 }
513 513
514 -int SrsGoHttpServeMux::handle(std::string pattern, ISrsGoHttpHandler* handler) 514 +int SrsHttpServeMux::handle(std::string pattern, ISrsHttpHandler* handler)
515 { 515 {
516 int ret = ERROR_SUCCESS; 516 int ret = ERROR_SUCCESS;
517 517
@@ -524,7 +524,7 @@ int SrsGoHttpServeMux::handle(std::string pattern, ISrsGoHttpHandler* handler) @@ -524,7 +524,7 @@ int SrsGoHttpServeMux::handle(std::string pattern, ISrsGoHttpHandler* handler)
524 } 524 }
525 525
526 if (entries.find(pattern) != entries.end()) { 526 if (entries.find(pattern) != entries.end()) {
527 - SrsGoHttpMuxEntry* exists = entries[pattern]; 527 + SrsHttpMuxEntry* exists = entries[pattern];
528 if (exists->explicit_match) { 528 if (exists->explicit_match) {
529 ret = ERROR_HTTP_PATTERN_DUPLICATED; 529 ret = ERROR_HTTP_PATTERN_DUPLICATED;
530 srs_error("http: multiple registrations for %s. ret=%d", pattern.c_str(), ret); 530 srs_error("http: multiple registrations for %s. ret=%d", pattern.c_str(), ret);
@@ -541,14 +541,14 @@ int SrsGoHttpServeMux::handle(std::string pattern, ISrsGoHttpHandler* handler) @@ -541,14 +541,14 @@ int SrsGoHttpServeMux::handle(std::string pattern, ISrsGoHttpHandler* handler)
541 } 541 }
542 542
543 if (true) { 543 if (true) {
544 - SrsGoHttpMuxEntry* entry = new SrsGoHttpMuxEntry(); 544 + SrsHttpMuxEntry* entry = new SrsHttpMuxEntry();
545 entry->explicit_match = true; 545 entry->explicit_match = true;
546 entry->handler = handler; 546 entry->handler = handler;
547 entry->pattern = pattern; 547 entry->pattern = pattern;
548 entry->handler->entry = entry; 548 entry->handler->entry = entry;
549 549
550 if (entries.find(pattern) != entries.end()) { 550 if (entries.find(pattern) != entries.end()) {
551 - SrsGoHttpMuxEntry* exists = entries[pattern]; 551 + SrsHttpMuxEntry* exists = entries[pattern];
552 srs_freep(exists); 552 srs_freep(exists);
553 } 553 }
554 entries[pattern] = entry; 554 entries[pattern] = entry;
@@ -559,11 +559,11 @@ int SrsGoHttpServeMux::handle(std::string pattern, ISrsGoHttpHandler* handler) @@ -559,11 +559,11 @@ int SrsGoHttpServeMux::handle(std::string pattern, ISrsGoHttpHandler* handler)
559 // It can be overridden by an explicit registration. 559 // It can be overridden by an explicit registration.
560 if (pattern != "/" && !pattern.empty() && pattern.at(pattern.length() - 1) == '/') { 560 if (pattern != "/" && !pattern.empty() && pattern.at(pattern.length() - 1) == '/') {
561 std::string rpattern = pattern.substr(0, pattern.length() - 1); 561 std::string rpattern = pattern.substr(0, pattern.length() - 1);
562 - SrsGoHttpMuxEntry* entry = NULL; 562 + SrsHttpMuxEntry* entry = NULL;
563 563
564 // free the exists not explicit entry 564 // free the exists not explicit entry
565 if (entries.find(rpattern) != entries.end()) { 565 if (entries.find(rpattern) != entries.end()) {
566 - SrsGoHttpMuxEntry* exists = entries[rpattern]; 566 + SrsHttpMuxEntry* exists = entries[rpattern];
567 if (!exists->explicit_match) { 567 if (!exists->explicit_match) {
568 entry = exists; 568 entry = exists;
569 } 569 }
@@ -573,9 +573,9 @@ int SrsGoHttpServeMux::handle(std::string pattern, ISrsGoHttpHandler* handler) @@ -573,9 +573,9 @@ int SrsGoHttpServeMux::handle(std::string pattern, ISrsGoHttpHandler* handler)
573 if (!entry || entry->explicit_match) { 573 if (!entry || entry->explicit_match) {
574 srs_freep(entry); 574 srs_freep(entry);
575 575
576 - entry = new SrsGoHttpMuxEntry(); 576 + entry = new SrsHttpMuxEntry();
577 entry->explicit_match = false; 577 entry->explicit_match = false;
578 - entry->handler = new SrsGoHttpRedirectHandler(pattern, SRS_CONSTS_HTTP_MovedPermanently); 578 + entry->handler = new SrsHttpRedirectHandler(pattern, SRS_CONSTS_HTTP_MovedPermanently);
579 entry->pattern = pattern; 579 entry->pattern = pattern;
580 entry->handler->entry = entry; 580 entry->handler->entry = entry;
581 581
@@ -586,11 +586,11 @@ int SrsGoHttpServeMux::handle(std::string pattern, ISrsGoHttpHandler* handler) @@ -586,11 +586,11 @@ int SrsGoHttpServeMux::handle(std::string pattern, ISrsGoHttpHandler* handler)
586 return ret; 586 return ret;
587 } 587 }
588 588
589 -int SrsGoHttpServeMux::serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r) 589 +int SrsHttpServeMux::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r)
590 { 590 {
591 int ret = ERROR_SUCCESS; 591 int ret = ERROR_SUCCESS;
592 592
593 - ISrsGoHttpHandler* h = NULL; 593 + ISrsHttpHandler* h = NULL;
594 if ((ret = find_handler(r, &h)) != ERROR_SUCCESS) { 594 if ((ret = find_handler(r, &h)) != ERROR_SUCCESS) {
595 srs_error("find handler failed. ret=%d", ret); 595 srs_error("find handler failed. ret=%d", ret);
596 return ret; 596 return ret;
@@ -607,7 +607,7 @@ int SrsGoHttpServeMux::serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r @@ -607,7 +607,7 @@ int SrsGoHttpServeMux::serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r
607 return ret; 607 return ret;
608 } 608 }
609 609
610 -int SrsGoHttpServeMux::find_handler(SrsHttpMessage* r, ISrsGoHttpHandler** ph) 610 +int SrsHttpServeMux::find_handler(SrsHttpMessage* r, ISrsHttpHandler** ph)
611 { 611 {
612 int ret = ERROR_SUCCESS; 612 int ret = ERROR_SUCCESS;
613 613
@@ -624,13 +624,13 @@ int SrsGoHttpServeMux::find_handler(SrsHttpMessage* r, ISrsGoHttpHandler** ph) @@ -624,13 +624,13 @@ int SrsGoHttpServeMux::find_handler(SrsHttpMessage* r, ISrsGoHttpHandler** ph)
624 } 624 }
625 625
626 if (*ph == NULL) { 626 if (*ph == NULL) {
627 - *ph = new SrsGoHttpNotFoundHandler(); 627 + *ph = new SrsHttpNotFoundHandler();
628 } 628 }
629 629
630 return ret; 630 return ret;
631 } 631 }
632 632
633 -int SrsGoHttpServeMux::match(SrsHttpMessage* r, ISrsGoHttpHandler** ph) 633 +int SrsHttpServeMux::match(SrsHttpMessage* r, ISrsHttpHandler** ph)
634 { 634 {
635 int ret = ERROR_SUCCESS; 635 int ret = ERROR_SUCCESS;
636 636
@@ -642,12 +642,12 @@ int SrsGoHttpServeMux::match(SrsHttpMessage* r, ISrsGoHttpHandler** ph) @@ -642,12 +642,12 @@ int SrsGoHttpServeMux::match(SrsHttpMessage* r, ISrsGoHttpHandler** ph)
642 } 642 }
643 643
644 int nb_matched = 0; 644 int nb_matched = 0;
645 - ISrsGoHttpHandler* h = NULL; 645 + ISrsHttpHandler* h = NULL;
646 646
647 - std::map<std::string, SrsGoHttpMuxEntry*>::iterator it; 647 + std::map<std::string, SrsHttpMuxEntry*>::iterator it;
648 for (it = entries.begin(); it != entries.end(); ++it) { 648 for (it = entries.begin(); it != entries.end(); ++it) {
649 std::string pattern = it->first; 649 std::string pattern = it->first;
650 - SrsGoHttpMuxEntry* entry = it->second; 650 + SrsHttpMuxEntry* entry = it->second;
651 651
652 if (!entry->enabled) { 652 if (!entry->enabled) {
653 continue; 653 continue;
@@ -668,7 +668,7 @@ int SrsGoHttpServeMux::match(SrsHttpMessage* r, ISrsGoHttpHandler** ph) @@ -668,7 +668,7 @@ int SrsGoHttpServeMux::match(SrsHttpMessage* r, ISrsGoHttpHandler** ph)
668 return ret; 668 return ret;
669 } 669 }
670 670
671 -bool SrsGoHttpServeMux::path_match(string pattern, string path) 671 +bool SrsHttpServeMux::path_match(string pattern, string path)
672 { 672 {
673 if (pattern.empty()) { 673 if (pattern.empty()) {
674 return false; 674 return false;
@@ -692,10 +692,10 @@ bool SrsGoHttpServeMux::path_match(string pattern, string path) @@ -692,10 +692,10 @@ bool SrsGoHttpServeMux::path_match(string pattern, string path)
692 return false; 692 return false;
693 } 693 }
694 694
695 -SrsGoHttpResponseWriter::SrsGoHttpResponseWriter(SrsStSocket* io) 695 +SrsHttpResponseWriter::SrsHttpResponseWriter(SrsStSocket* io)
696 { 696 {
697 skt = io; 697 skt = io;
698 - hdr = new SrsGoHttpHeader(); 698 + hdr = new SrsHttpHeader();
699 header_wrote = false; 699 header_wrote = false;
700 status = SRS_CONSTS_HTTP_OK; 700 status = SRS_CONSTS_HTTP_OK;
701 content_length = -1; 701 content_length = -1;
@@ -703,12 +703,12 @@ SrsGoHttpResponseWriter::SrsGoHttpResponseWriter(SrsStSocket* io) @@ -703,12 +703,12 @@ SrsGoHttpResponseWriter::SrsGoHttpResponseWriter(SrsStSocket* io)
703 header_sent = false; 703 header_sent = false;
704 } 704 }
705 705
706 -SrsGoHttpResponseWriter::~SrsGoHttpResponseWriter() 706 +SrsHttpResponseWriter::~SrsHttpResponseWriter()
707 { 707 {
708 srs_freep(hdr); 708 srs_freep(hdr);
709 } 709 }
710 710
711 -int SrsGoHttpResponseWriter::final_request() 711 +int SrsHttpResponseWriter::final_request()
712 { 712 {
713 // complete the chunked encoding. 713 // complete the chunked encoding.
714 if (content_length == -1) { 714 if (content_length == -1) {
@@ -722,12 +722,12 @@ int SrsGoHttpResponseWriter::final_request() @@ -722,12 +722,12 @@ int SrsGoHttpResponseWriter::final_request()
722 return write(NULL, 0); 722 return write(NULL, 0);
723 } 723 }
724 724
725 -SrsGoHttpHeader* SrsGoHttpResponseWriter::header() 725 +SrsHttpHeader* SrsHttpResponseWriter::header()
726 { 726 {
727 return hdr; 727 return hdr;
728 } 728 }
729 729
730 -int SrsGoHttpResponseWriter::write(char* data, int size) 730 +int SrsHttpResponseWriter::write(char* data, int size)
731 { 731 {
732 int ret = ERROR_SUCCESS; 732 int ret = ERROR_SUCCESS;
733 733
@@ -774,7 +774,7 @@ int SrsGoHttpResponseWriter::write(char* data, int size) @@ -774,7 +774,7 @@ int SrsGoHttpResponseWriter::write(char* data, int size)
774 return ret; 774 return ret;
775 } 775 }
776 776
777 -void SrsGoHttpResponseWriter::write_header(int code) 777 +void SrsHttpResponseWriter::write_header(int code)
778 { 778 {
779 if (header_wrote) { 779 if (header_wrote) {
780 srs_warn("http: multiple write_header calls, code=%d", code); 780 srs_warn("http: multiple write_header calls, code=%d", code);
@@ -788,7 +788,7 @@ void SrsGoHttpResponseWriter::write_header(int code) @@ -788,7 +788,7 @@ void SrsGoHttpResponseWriter::write_header(int code)
788 content_length = hdr->content_length(); 788 content_length = hdr->content_length();
789 } 789 }
790 790
791 -int SrsGoHttpResponseWriter::send_header(char* data, int size) 791 +int SrsHttpResponseWriter::send_header(char* data, int size)
792 { 792 {
793 int ret = ERROR_SUCCESS; 793 int ret = ERROR_SUCCESS;
794 794
@@ -47,8 +47,8 @@ class SrsHttpUri; @@ -47,8 +47,8 @@ class SrsHttpUri;
47 class SrsHttpMessage; 47 class SrsHttpMessage;
48 class SrsFileReader; 48 class SrsFileReader;
49 class SrsSimpleBuffer; 49 class SrsSimpleBuffer;
50 -class SrsGoHttpMuxEntry;  
51 -class ISrsGoHttpResponseWriter; 50 +class SrsHttpMuxEntry;
  51 +class ISrsHttpResponseWriter;
52 52
53 // http specification 53 // http specification
54 // CR = <US-ASCII CR, carriage return (13)> 54 // CR = <US-ASCII CR, carriage return (13)>
@@ -70,7 +70,7 @@ class ISrsGoHttpResponseWriter; @@ -70,7 +70,7 @@ class ISrsGoHttpResponseWriter;
70 #define __SRS_HTTP_TS_SEND_BUFFER_SIZE 4096 70 #define __SRS_HTTP_TS_SEND_BUFFER_SIZE 4096
71 71
72 // helper function: response in json format. 72 // helper function: response in json format.
73 -extern int srs_go_http_response_json(ISrsGoHttpResponseWriter* w, std::string data); 73 +extern int srs_go_http_response_json(ISrsHttpResponseWriter* w, std::string data);
74 74
75 // state of message 75 // state of message
76 enum SrsHttpParseState { 76 enum SrsHttpParseState {
@@ -80,13 +80,13 @@ enum SrsHttpParseState { @@ -80,13 +80,13 @@ enum SrsHttpParseState {
80 }; 80 };
81 81
82 // A Header represents the key-value pairs in an HTTP header. 82 // A Header represents the key-value pairs in an HTTP header.
83 -class SrsGoHttpHeader 83 +class SrsHttpHeader
84 { 84 {
85 private: 85 private:
86 std::map<std::string, std::string> headers; 86 std::map<std::string, std::string> headers;
87 public: 87 public:
88 - SrsGoHttpHeader();  
89 - virtual ~SrsGoHttpHeader(); 88 + SrsHttpHeader();
  89 + virtual ~SrsHttpHeader();
90 public: 90 public:
91 // Add adds the key, value pair to the header. 91 // Add adds the key, value pair to the header.
92 // It appends to any existing values associated with key. 92 // It appends to any existing values associated with key.
@@ -124,7 +124,7 @@ public: @@ -124,7 +124,7 @@ public:
124 // A ResponseWriter interface is used by an HTTP handler to 124 // A ResponseWriter interface is used by an HTTP handler to
125 // construct an HTTP response. 125 // construct an HTTP response.
126 // Usage 1, response with specified length content: 126 // Usage 1, response with specified length content:
127 -// ISrsGoHttpResponseWriter* w; // create or get response. 127 +// ISrsHttpResponseWriter* w; // create or get response.
128 // std::string msg = "Hello, HTTP!"; 128 // std::string msg = "Hello, HTTP!";
129 // w->header()->set_content_type("text/plain; charset=utf-8"); 129 // w->header()->set_content_type("text/plain; charset=utf-8");
130 // w->header()->set_content_length(msg.length()); 130 // w->header()->set_content_length(msg.length());
@@ -132,12 +132,12 @@ public: @@ -132,12 +132,12 @@ public:
132 // w->write((char*)msg.data(), (int)msg.length()); 132 // w->write((char*)msg.data(), (int)msg.length());
133 // w->final_request(); // optional flush. 133 // w->final_request(); // optional flush.
134 // Usage 2, response with HTTP code only, zero content length. 134 // Usage 2, response with HTTP code only, zero content length.
135 -// ISrsGoHttpResponseWriter* w; // create or get response. 135 +// ISrsHttpResponseWriter* w; // create or get response.
136 // w->header()->set_content_length(0); 136 // w->header()->set_content_length(0);
137 // w->write_header(SRS_CONSTS_HTTP_OK); 137 // w->write_header(SRS_CONSTS_HTTP_OK);
138 // w->final_request(); 138 // w->final_request();
139 // Usage 3, response in chunked encoding. 139 // Usage 3, response in chunked encoding.
140 -// ISrsGoHttpResponseWriter* w; // create or get response. 140 +// ISrsHttpResponseWriter* w; // create or get response.
141 // std::string msg = "Hello, HTTP!"; 141 // std::string msg = "Hello, HTTP!";
142 // w->header()->set_content_type("application/octet-stream"); 142 // w->header()->set_content_type("application/octet-stream");
143 // w->write_header(SRS_CONSTS_HTTP_OK); 143 // w->write_header(SRS_CONSTS_HTTP_OK);
@@ -146,11 +146,11 @@ public: @@ -146,11 +146,11 @@ public:
146 // w->write((char*)msg.data(), (int)msg.length()); 146 // w->write((char*)msg.data(), (int)msg.length());
147 // w->write((char*)msg.data(), (int)msg.length()); 147 // w->write((char*)msg.data(), (int)msg.length());
148 // w->final_request(); // required to end the chunked and flush. 148 // w->final_request(); // required to end the chunked and flush.
149 -class ISrsGoHttpResponseWriter 149 +class ISrsHttpResponseWriter
150 { 150 {
151 public: 151 public:
152 - ISrsGoHttpResponseWriter();  
153 - virtual ~ISrsGoHttpResponseWriter(); 152 + ISrsHttpResponseWriter();
  153 + virtual ~ISrsHttpResponseWriter();
154 public: 154 public:
155 // when chunked mode, 155 // when chunked mode,
156 // final the request to complete the chunked encoding. 156 // final the request to complete the chunked encoding.
@@ -159,7 +159,7 @@ public: @@ -159,7 +159,7 @@ public:
159 // Header returns the header map that will be sent by WriteHeader. 159 // Header returns the header map that will be sent by WriteHeader.
160 // Changing the header after a call to WriteHeader (or Write) has 160 // Changing the header after a call to WriteHeader (or Write) has
161 // no effect. 161 // no effect.
162 - virtual SrsGoHttpHeader* header() = 0; 162 + virtual SrsHttpHeader* header() = 0;
163 163
164 // Write writes the data to the connection as part of an HTTP reply. 164 // Write writes the data to the connection as part of an HTTP reply.
165 // If WriteHeader has not yet been called, Write calls WriteHeader(http.StatusOK) 165 // If WriteHeader has not yet been called, Write calls WriteHeader(http.StatusOK)
@@ -186,38 +186,38 @@ public: @@ -186,38 +186,38 @@ public:
186 // and then return. Returning signals that the request is finished 186 // and then return. Returning signals that the request is finished
187 // and that the HTTP server can move on to the next request on 187 // and that the HTTP server can move on to the next request on
188 // the connection. 188 // the connection.
189 -class ISrsGoHttpHandler 189 +class ISrsHttpHandler
190 { 190 {
191 public: 191 public:
192 - SrsGoHttpMuxEntry* entry; 192 + SrsHttpMuxEntry* entry;
193 public: 193 public:
194 - ISrsGoHttpHandler();  
195 - virtual ~ISrsGoHttpHandler(); 194 + ISrsHttpHandler();
  195 + virtual ~ISrsHttpHandler();
196 public: 196 public:
197 - virtual int serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r) = 0; 197 + virtual int serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r) = 0;
198 }; 198 };
199 199
200 // Redirect to a fixed URL 200 // Redirect to a fixed URL
201 -class SrsGoHttpRedirectHandler : public ISrsGoHttpHandler 201 +class SrsHttpRedirectHandler : public ISrsHttpHandler
202 { 202 {
203 private: 203 private:
204 std::string url; 204 std::string url;
205 int code; 205 int code;
206 public: 206 public:
207 - SrsGoHttpRedirectHandler(std::string u, int c);  
208 - virtual ~SrsGoHttpRedirectHandler(); 207 + SrsHttpRedirectHandler(std::string u, int c);
  208 + virtual ~SrsHttpRedirectHandler();
209 public: 209 public:
210 - virtual int serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r); 210 + virtual int serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r);
211 }; 211 };
212 212
213 // NotFound replies to the request with an HTTP 404 not found error. 213 // NotFound replies to the request with an HTTP 404 not found error.
214 -class SrsGoHttpNotFoundHandler : public ISrsGoHttpHandler 214 +class SrsHttpNotFoundHandler : public ISrsHttpHandler
215 { 215 {
216 public: 216 public:
217 - SrsGoHttpNotFoundHandler();  
218 - virtual ~SrsGoHttpNotFoundHandler(); 217 + SrsHttpNotFoundHandler();
  218 + virtual ~SrsHttpNotFoundHandler();
219 public: 219 public:
220 - virtual int serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r); 220 + virtual int serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r);
221 }; 221 };
222 222
223 // FileServer returns a handler that serves HTTP requests 223 // FileServer returns a handler that serves HTTP requests
@@ -226,54 +226,54 @@ public: @@ -226,54 +226,54 @@ public:
226 // To use the operating system's file system implementation, 226 // To use the operating system's file system implementation,
227 // use http.Dir: 227 // use http.Dir:
228 // 228 //
229 -// http.Handle("/", SrsGoHttpFileServer("/tmp"))  
230 -// http.Handle("/", SrsGoHttpFileServer("static-dir"))  
231 -class SrsGoHttpFileServer : public ISrsGoHttpHandler 229 +// http.Handle("/", SrsHttpFileServer("/tmp"))
  230 +// http.Handle("/", SrsHttpFileServer("static-dir"))
  231 +class SrsHttpFileServer : public ISrsHttpHandler
232 { 232 {
233 protected: 233 protected:
234 std::string dir; 234 std::string dir;
235 public: 235 public:
236 - SrsGoHttpFileServer(std::string root_dir);  
237 - virtual ~SrsGoHttpFileServer(); 236 + SrsHttpFileServer(std::string root_dir);
  237 + virtual ~SrsHttpFileServer();
238 public: 238 public:
239 - virtual int serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r); 239 + virtual int serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r);
240 private: 240 private:
241 /** 241 /**
242 * serve the file by specified path 242 * serve the file by specified path
243 */ 243 */
244 - virtual int serve_file(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r, std::string fullpath);  
245 - virtual int serve_flv_file(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r, std::string fullpath);  
246 - virtual int serve_mp4_file(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r, std::string fullpath); 244 + virtual int serve_file(ISrsHttpResponseWriter* w, SrsHttpMessage* r, std::string fullpath);
  245 + virtual int serve_flv_file(ISrsHttpResponseWriter* w, SrsHttpMessage* r, std::string fullpath);
  246 + virtual int serve_mp4_file(ISrsHttpResponseWriter* w, SrsHttpMessage* r, std::string fullpath);
247 protected: 247 protected:
248 /** 248 /**
249 * when access flv file with x.flv?start=xxx 249 * when access flv file with x.flv?start=xxx
250 */ 250 */
251 - virtual int serve_flv_stream(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r, std::string fullpath, int offset); 251 + virtual int serve_flv_stream(ISrsHttpResponseWriter* w, SrsHttpMessage* r, std::string fullpath, int offset);
252 /** 252 /**
253 * when access mp4 file with x.mp4?range=start-end 253 * when access mp4 file with x.mp4?range=start-end
254 * @param start the start offset in bytes. 254 * @param start the start offset in bytes.
255 * @param end the end offset in bytes. -1 to end of file. 255 * @param end the end offset in bytes. -1 to end of file.
256 * @remark response data in [start, end]. 256 * @remark response data in [start, end].
257 */ 257 */
258 - virtual int serve_mp4_stream(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r, std::string fullpath, int start, int end); 258 + virtual int serve_mp4_stream(ISrsHttpResponseWriter* w, SrsHttpMessage* r, std::string fullpath, int start, int end);
259 protected: 259 protected:
260 /** 260 /**
261 * copy the fs to response writer in size bytes. 261 * copy the fs to response writer in size bytes.
262 */ 262 */
263 - virtual int copy(ISrsGoHttpResponseWriter* w, SrsFileReader* fs, SrsHttpMessage* r, int size); 263 + virtual int copy(ISrsHttpResponseWriter* w, SrsFileReader* fs, SrsHttpMessage* r, int size);
264 }; 264 };
265 265
266 // the mux entry for server mux. 266 // the mux entry for server mux.
267 -class SrsGoHttpMuxEntry 267 +class SrsHttpMuxEntry
268 { 268 {
269 public: 269 public:
270 bool explicit_match; 270 bool explicit_match;
271 - ISrsGoHttpHandler* handler; 271 + ISrsHttpHandler* handler;
272 std::string pattern; 272 std::string pattern;
273 bool enabled; 273 bool enabled;
274 public: 274 public:
275 - SrsGoHttpMuxEntry();  
276 - virtual ~SrsGoHttpMuxEntry(); 275 + SrsHttpMuxEntry();
  276 + virtual ~SrsHttpMuxEntry();
277 }; 277 };
278 278
279 // ServeMux is an HTTP request multiplexer. 279 // ServeMux is an HTTP request multiplexer.
@@ -303,16 +303,16 @@ public: @@ -303,16 +303,16 @@ public:
303 // ServeMux also takes care of sanitizing the URL request path, 303 // ServeMux also takes care of sanitizing the URL request path,
304 // redirecting any request containing . or .. elements to an 304 // redirecting any request containing . or .. elements to an
305 // equivalent .- and ..-free URL. 305 // equivalent .- and ..-free URL.
306 -class SrsGoHttpServeMux 306 +class SrsHttpServeMux
307 { 307 {
308 private: 308 private:
309 // the pattern handler. 309 // the pattern handler.
310 - std::map<std::string, SrsGoHttpMuxEntry*> entries; 310 + std::map<std::string, SrsHttpMuxEntry*> entries;
311 // the vhost handler. 311 // the vhost handler.
312 - std::map<std::string, ISrsGoHttpHandler*> vhosts; 312 + std::map<std::string, ISrsHttpHandler*> vhosts;
313 public: 313 public:
314 - SrsGoHttpServeMux();  
315 - virtual ~SrsGoHttpServeMux(); 314 + SrsHttpServeMux();
  315 + virtual ~SrsHttpServeMux();
316 public: 316 public:
317 /** 317 /**
318 * initialize the http serve mux. 318 * initialize the http serve mux.
@@ -321,24 +321,24 @@ public: @@ -321,24 +321,24 @@ public:
321 public: 321 public:
322 // Handle registers the handler for the given pattern. 322 // Handle registers the handler for the given pattern.
323 // If a handler already exists for pattern, Handle panics. 323 // If a handler already exists for pattern, Handle panics.
324 - virtual int handle(std::string pattern, ISrsGoHttpHandler* handler);  
325 -// interface ISrsGoHttpHandler 324 + virtual int handle(std::string pattern, ISrsHttpHandler* handler);
  325 +// interface ISrsHttpHandler
326 public: 326 public:
327 - virtual int serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r); 327 + virtual int serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r);
328 private: 328 private:
329 - virtual int find_handler(SrsHttpMessage* r, ISrsGoHttpHandler** ph);  
330 - virtual int match(SrsHttpMessage* r, ISrsGoHttpHandler** ph); 329 + virtual int find_handler(SrsHttpMessage* r, ISrsHttpHandler** ph);
  330 + virtual int match(SrsHttpMessage* r, ISrsHttpHandler** ph);
331 virtual bool path_match(std::string pattern, std::string path); 331 virtual bool path_match(std::string pattern, std::string path);
332 }; 332 };
333 333
334 /** 334 /**
335 * response writer use st socket 335 * response writer use st socket
336 */ 336 */
337 -class SrsGoHttpResponseWriter : public ISrsGoHttpResponseWriter 337 +class SrsHttpResponseWriter : public ISrsHttpResponseWriter
338 { 338 {
339 private: 339 private:
340 SrsStSocket* skt; 340 SrsStSocket* skt;
341 - SrsGoHttpHeader* hdr; 341 + SrsHttpHeader* hdr;
342 private: 342 private:
343 // reply header has been (logically) written 343 // reply header has been (logically) written
344 bool header_wrote; 344 bool header_wrote;
@@ -356,11 +356,11 @@ private: @@ -356,11 +356,11 @@ private:
356 // logically written. 356 // logically written.
357 bool header_sent; 357 bool header_sent;
358 public: 358 public:
359 - SrsGoHttpResponseWriter(SrsStSocket* io);  
360 - virtual ~SrsGoHttpResponseWriter(); 359 + SrsHttpResponseWriter(SrsStSocket* io);
  360 + virtual ~SrsHttpResponseWriter();
361 public: 361 public:
362 virtual int final_request(); 362 virtual int final_request();
363 - virtual SrsGoHttpHeader* header(); 363 + virtual SrsHttpHeader* header();
364 virtual int write(char* data, int size); 364 virtual int write(char* data, int size);
365 virtual void write_header(int code); 365 virtual void write_header(int code);
366 virtual int send_header(char* data, int size); 366 virtual int send_header(char* data, int size);
@@ -48,7 +48,7 @@ SrsGoApiRoot::~SrsGoApiRoot() @@ -48,7 +48,7 @@ SrsGoApiRoot::~SrsGoApiRoot()
48 { 48 {
49 } 49 }
50 50
51 -int SrsGoApiRoot::serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r) 51 +int SrsGoApiRoot::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r)
52 { 52 {
53 std::stringstream ss; 53 std::stringstream ss;
54 54
@@ -70,7 +70,7 @@ SrsGoApiApi::~SrsGoApiApi() @@ -70,7 +70,7 @@ SrsGoApiApi::~SrsGoApiApi()
70 { 70 {
71 } 71 }
72 72
73 -int SrsGoApiApi::serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r) 73 +int SrsGoApiApi::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r)
74 { 74 {
75 std::stringstream ss; 75 std::stringstream ss;
76 76
@@ -92,7 +92,7 @@ SrsGoApiV1::~SrsGoApiV1() @@ -92,7 +92,7 @@ SrsGoApiV1::~SrsGoApiV1()
92 { 92 {
93 } 93 }
94 94
95 -int SrsGoApiV1::serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r) 95 +int SrsGoApiV1::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r)
96 { 96 {
97 std::stringstream ss; 97 std::stringstream ss;
98 98
@@ -123,7 +123,7 @@ SrsGoApiVersion::~SrsGoApiVersion() @@ -123,7 +123,7 @@ SrsGoApiVersion::~SrsGoApiVersion()
123 { 123 {
124 } 124 }
125 125
126 -int SrsGoApiVersion::serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r) 126 +int SrsGoApiVersion::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r)
127 { 127 {
128 std::stringstream ss; 128 std::stringstream ss;
129 129
@@ -148,7 +148,7 @@ SrsGoApiSummaries::~SrsGoApiSummaries() @@ -148,7 +148,7 @@ SrsGoApiSummaries::~SrsGoApiSummaries()
148 { 148 {
149 } 149 }
150 150
151 -int SrsGoApiSummaries::serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r) 151 +int SrsGoApiSummaries::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r)
152 { 152 {
153 std::stringstream ss; 153 std::stringstream ss;
154 srs_api_dump_summaries(ss); 154 srs_api_dump_summaries(ss);
@@ -163,7 +163,7 @@ SrsGoApiRusages::~SrsGoApiRusages() @@ -163,7 +163,7 @@ SrsGoApiRusages::~SrsGoApiRusages()
163 { 163 {
164 } 164 }
165 165
166 -int SrsGoApiRusages::serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* req) 166 +int SrsGoApiRusages::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* req)
167 { 167 {
168 std::stringstream ss; 168 std::stringstream ss;
169 169
@@ -204,7 +204,7 @@ SrsGoApiSelfProcStats::~SrsGoApiSelfProcStats() @@ -204,7 +204,7 @@ SrsGoApiSelfProcStats::~SrsGoApiSelfProcStats()
204 { 204 {
205 } 205 }
206 206
207 -int SrsGoApiSelfProcStats::serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r) 207 +int SrsGoApiSelfProcStats::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r)
208 { 208 {
209 std::stringstream ss; 209 std::stringstream ss;
210 210
@@ -274,7 +274,7 @@ SrsGoApiSystemProcStats::~SrsGoApiSystemProcStats() @@ -274,7 +274,7 @@ SrsGoApiSystemProcStats::~SrsGoApiSystemProcStats()
274 { 274 {
275 } 275 }
276 276
277 -int SrsGoApiSystemProcStats::serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r) 277 +int SrsGoApiSystemProcStats::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r)
278 { 278 {
279 std::stringstream ss; 279 std::stringstream ss;
280 280
@@ -309,7 +309,7 @@ SrsGoApiMemInfos::~SrsGoApiMemInfos() @@ -309,7 +309,7 @@ SrsGoApiMemInfos::~SrsGoApiMemInfos()
309 { 309 {
310 } 310 }
311 311
312 -int SrsGoApiMemInfos::serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r) 312 +int SrsGoApiMemInfos::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r)
313 { 313 {
314 std::stringstream ss; 314 std::stringstream ss;
315 315
@@ -345,7 +345,7 @@ SrsGoApiAuthors::~SrsGoApiAuthors() @@ -345,7 +345,7 @@ SrsGoApiAuthors::~SrsGoApiAuthors()
345 { 345 {
346 } 346 }
347 347
348 -int SrsGoApiAuthors::serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r) 348 +int SrsGoApiAuthors::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r)
349 { 349 {
350 std::stringstream ss; 350 std::stringstream ss;
351 351
@@ -370,7 +370,7 @@ SrsGoApiRequests::~SrsGoApiRequests() @@ -370,7 +370,7 @@ SrsGoApiRequests::~SrsGoApiRequests()
370 { 370 {
371 } 371 }
372 372
373 -int SrsGoApiRequests::serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r) 373 +int SrsGoApiRequests::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r)
374 { 374 {
375 SrsHttpMessage* req = r; 375 SrsHttpMessage* req = r;
376 376
@@ -431,7 +431,7 @@ SrsGoApiVhosts::~SrsGoApiVhosts() @@ -431,7 +431,7 @@ SrsGoApiVhosts::~SrsGoApiVhosts()
431 { 431 {
432 } 432 }
433 433
434 -int SrsGoApiVhosts::serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r) 434 +int SrsGoApiVhosts::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r)
435 { 435 {
436 std::stringstream data; 436 std::stringstream data;
437 SrsStatistic* stat = SrsStatistic::instance(); 437 SrsStatistic* stat = SrsStatistic::instance();
@@ -456,7 +456,7 @@ SrsGoApiStreams::~SrsGoApiStreams() @@ -456,7 +456,7 @@ SrsGoApiStreams::~SrsGoApiStreams()
456 { 456 {
457 } 457 }
458 458
459 -int SrsGoApiStreams::serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r) 459 +int SrsGoApiStreams::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r)
460 { 460 {
461 std::stringstream data; 461 std::stringstream data;
462 SrsStatistic* stat = SrsStatistic::instance(); 462 SrsStatistic* stat = SrsStatistic::instance();
@@ -473,7 +473,7 @@ int SrsGoApiStreams::serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r) @@ -473,7 +473,7 @@ int SrsGoApiStreams::serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r)
473 return srs_go_http_response_json(w, ss.str()); 473 return srs_go_http_response_json(w, ss.str());
474 } 474 }
475 475
476 -SrsHttpApi::SrsHttpApi(SrsServer* svr, st_netfd_t fd, SrsGoHttpServeMux* m) 476 +SrsHttpApi::SrsHttpApi(SrsServer* svr, st_netfd_t fd, SrsHttpServeMux* m)
477 : SrsConnection(svr, fd) 477 : SrsConnection(svr, fd)
478 { 478 {
479 mux = m; 479 mux = m;
@@ -535,7 +535,7 @@ int SrsHttpApi::do_cycle() @@ -535,7 +535,7 @@ int SrsHttpApi::do_cycle()
535 SrsAutoFree(SrsHttpMessage, req); 535 SrsAutoFree(SrsHttpMessage, req);
536 536
537 // ok, handle http request. 537 // ok, handle http request.
538 - SrsGoHttpResponseWriter writer(&skt); 538 + SrsHttpResponseWriter writer(&skt);
539 if ((ret = process_request(&writer, req)) != ERROR_SUCCESS) { 539 if ((ret = process_request(&writer, req)) != ERROR_SUCCESS) {
540 return ret; 540 return ret;
541 } 541 }
@@ -544,7 +544,7 @@ int SrsHttpApi::do_cycle() @@ -544,7 +544,7 @@ int SrsHttpApi::do_cycle()
544 return ret; 544 return ret;
545 } 545 }
546 546
547 -int SrsHttpApi::process_request(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r) 547 +int SrsHttpApi::process_request(ISrsHttpResponseWriter* w, SrsHttpMessage* r)
548 { 548 {
549 int ret = ERROR_SUCCESS; 549 int ret = ERROR_SUCCESS;
550 550
@@ -42,131 +42,131 @@ class SrsHttpHandler; @@ -42,131 +42,131 @@ class SrsHttpHandler;
42 #include <srs_app_http.hpp> 42 #include <srs_app_http.hpp>
43 43
44 // for http root. 44 // for http root.
45 -class SrsGoApiRoot : public ISrsGoHttpHandler 45 +class SrsGoApiRoot : public ISrsHttpHandler
46 { 46 {
47 public: 47 public:
48 SrsGoApiRoot(); 48 SrsGoApiRoot();
49 virtual ~SrsGoApiRoot(); 49 virtual ~SrsGoApiRoot();
50 public: 50 public:
51 - virtual int serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r); 51 + virtual int serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r);
52 }; 52 };
53 53
54 -class SrsGoApiApi : public ISrsGoHttpHandler 54 +class SrsGoApiApi : public ISrsHttpHandler
55 { 55 {
56 public: 56 public:
57 SrsGoApiApi(); 57 SrsGoApiApi();
58 virtual ~SrsGoApiApi(); 58 virtual ~SrsGoApiApi();
59 public: 59 public:
60 - virtual int serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r); 60 + virtual int serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r);
61 }; 61 };
62 62
63 -class SrsGoApiV1 : public ISrsGoHttpHandler 63 +class SrsGoApiV1 : public ISrsHttpHandler
64 { 64 {
65 public: 65 public:
66 SrsGoApiV1(); 66 SrsGoApiV1();
67 virtual ~SrsGoApiV1(); 67 virtual ~SrsGoApiV1();
68 public: 68 public:
69 - virtual int serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r); 69 + virtual int serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r);
70 }; 70 };
71 71
72 -class SrsGoApiVersion : public ISrsGoHttpHandler 72 +class SrsGoApiVersion : public ISrsHttpHandler
73 { 73 {
74 public: 74 public:
75 SrsGoApiVersion(); 75 SrsGoApiVersion();
76 virtual ~SrsGoApiVersion(); 76 virtual ~SrsGoApiVersion();
77 public: 77 public:
78 - virtual int serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r); 78 + virtual int serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r);
79 }; 79 };
80 80
81 -class SrsGoApiSummaries : public ISrsGoHttpHandler 81 +class SrsGoApiSummaries : public ISrsHttpHandler
82 { 82 {
83 public: 83 public:
84 SrsGoApiSummaries(); 84 SrsGoApiSummaries();
85 virtual ~SrsGoApiSummaries(); 85 virtual ~SrsGoApiSummaries();
86 public: 86 public:
87 - virtual int serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r); 87 + virtual int serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r);
88 }; 88 };
89 89
90 -class SrsGoApiRusages : public ISrsGoHttpHandler 90 +class SrsGoApiRusages : public ISrsHttpHandler
91 { 91 {
92 public: 92 public:
93 SrsGoApiRusages(); 93 SrsGoApiRusages();
94 virtual ~SrsGoApiRusages(); 94 virtual ~SrsGoApiRusages();
95 public: 95 public:
96 - virtual int serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r); 96 + virtual int serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r);
97 }; 97 };
98 98
99 -class SrsGoApiSelfProcStats : public ISrsGoHttpHandler 99 +class SrsGoApiSelfProcStats : public ISrsHttpHandler
100 { 100 {
101 public: 101 public:
102 SrsGoApiSelfProcStats(); 102 SrsGoApiSelfProcStats();
103 virtual ~SrsGoApiSelfProcStats(); 103 virtual ~SrsGoApiSelfProcStats();
104 public: 104 public:
105 - virtual int serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r); 105 + virtual int serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r);
106 }; 106 };
107 107
108 -class SrsGoApiSystemProcStats : public ISrsGoHttpHandler 108 +class SrsGoApiSystemProcStats : public ISrsHttpHandler
109 { 109 {
110 public: 110 public:
111 SrsGoApiSystemProcStats(); 111 SrsGoApiSystemProcStats();
112 virtual ~SrsGoApiSystemProcStats(); 112 virtual ~SrsGoApiSystemProcStats();
113 public: 113 public:
114 - virtual int serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r); 114 + virtual int serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r);
115 }; 115 };
116 116
117 -class SrsGoApiMemInfos : public ISrsGoHttpHandler 117 +class SrsGoApiMemInfos : public ISrsHttpHandler
118 { 118 {
119 public: 119 public:
120 SrsGoApiMemInfos(); 120 SrsGoApiMemInfos();
121 virtual ~SrsGoApiMemInfos(); 121 virtual ~SrsGoApiMemInfos();
122 public: 122 public:
123 - virtual int serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r); 123 + virtual int serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r);
124 }; 124 };
125 125
126 -class SrsGoApiAuthors : public ISrsGoHttpHandler 126 +class SrsGoApiAuthors : public ISrsHttpHandler
127 { 127 {
128 public: 128 public:
129 SrsGoApiAuthors(); 129 SrsGoApiAuthors();
130 virtual ~SrsGoApiAuthors(); 130 virtual ~SrsGoApiAuthors();
131 public: 131 public:
132 - virtual int serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r); 132 + virtual int serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r);
133 }; 133 };
134 134
135 -class SrsGoApiRequests : public ISrsGoHttpHandler 135 +class SrsGoApiRequests : public ISrsHttpHandler
136 { 136 {
137 public: 137 public:
138 SrsGoApiRequests(); 138 SrsGoApiRequests();
139 virtual ~SrsGoApiRequests(); 139 virtual ~SrsGoApiRequests();
140 public: 140 public:
141 - virtual int serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r); 141 + virtual int serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r);
142 }; 142 };
143 143
144 -class SrsGoApiVhosts : public ISrsGoHttpHandler 144 +class SrsGoApiVhosts : public ISrsHttpHandler
145 { 145 {
146 public: 146 public:
147 SrsGoApiVhosts(); 147 SrsGoApiVhosts();
148 virtual ~SrsGoApiVhosts(); 148 virtual ~SrsGoApiVhosts();
149 public: 149 public:
150 - virtual int serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r); 150 + virtual int serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r);
151 }; 151 };
152 152
153 -class SrsGoApiStreams : public ISrsGoHttpHandler 153 +class SrsGoApiStreams : public ISrsHttpHandler
154 { 154 {
155 public: 155 public:
156 SrsGoApiStreams(); 156 SrsGoApiStreams();
157 virtual ~SrsGoApiStreams(); 157 virtual ~SrsGoApiStreams();
158 public: 158 public:
159 - virtual int serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r); 159 + virtual int serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r);
160 }; 160 };
161 161
162 class SrsHttpApi : public SrsConnection 162 class SrsHttpApi : public SrsConnection
163 { 163 {
164 private: 164 private:
165 SrsHttpParser* parser; 165 SrsHttpParser* parser;
166 - SrsGoHttpServeMux* mux; 166 + SrsHttpServeMux* mux;
167 bool crossdomain_required; 167 bool crossdomain_required;
168 public: 168 public:
169 - SrsHttpApi(SrsServer* svr, st_netfd_t fd, SrsGoHttpServeMux* m); 169 + SrsHttpApi(SrsServer* svr, st_netfd_t fd, SrsHttpServeMux* m);
170 virtual ~SrsHttpApi(); 170 virtual ~SrsHttpApi();
171 public: 171 public:
172 virtual void kbps_resample(); 172 virtual void kbps_resample();
@@ -177,7 +177,7 @@ public: @@ -177,7 +177,7 @@ public:
177 protected: 177 protected:
178 virtual int do_cycle(); 178 virtual int do_cycle();
179 private: 179 private:
180 - virtual int process_request(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r); 180 + virtual int process_request(ISrsHttpResponseWriter* w, SrsHttpMessage* r);
181 }; 181 };
182 182
183 #endif 183 #endif
@@ -50,7 +50,7 @@ using namespace std; @@ -50,7 +50,7 @@ using namespace std;
50 #include <srs_app_pithy_print.hpp> 50 #include <srs_app_pithy_print.hpp>
51 51
52 SrsVodStream::SrsVodStream(string root_dir) 52 SrsVodStream::SrsVodStream(string root_dir)
53 - : SrsGoHttpFileServer(root_dir) 53 + : SrsHttpFileServer(root_dir)
54 { 54 {
55 } 55 }
56 56
@@ -58,7 +58,7 @@ SrsVodStream::~SrsVodStream() @@ -58,7 +58,7 @@ SrsVodStream::~SrsVodStream()
58 { 58 {
59 } 59 }
60 60
61 -int SrsVodStream::serve_flv_stream(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r, string fullpath, int offset) 61 +int SrsVodStream::serve_flv_stream(ISrsHttpResponseWriter* w, SrsHttpMessage* r, string fullpath, int offset)
62 { 62 {
63 int ret = ERROR_SUCCESS; 63 int ret = ERROR_SUCCESS;
64 64
@@ -142,7 +142,7 @@ int SrsVodStream::serve_flv_stream(ISrsGoHttpResponseWriter* w, SrsHttpMessage* @@ -142,7 +142,7 @@ int SrsVodStream::serve_flv_stream(ISrsGoHttpResponseWriter* w, SrsHttpMessage*
142 return ret; 142 return ret;
143 } 143 }
144 144
145 -int SrsVodStream::serve_mp4_stream(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r, string fullpath, int start, int end) 145 +int SrsVodStream::serve_mp4_stream(ISrsHttpResponseWriter* w, SrsHttpMessage* r, string fullpath, int start, int end)
146 { 146 {
147 int ret = ERROR_SUCCESS; 147 int ret = ERROR_SUCCESS;
148 148
@@ -517,7 +517,7 @@ int SrsMp3StreamEncoder::dump_cache(SrsConsumer* consumer) @@ -517,7 +517,7 @@ int SrsMp3StreamEncoder::dump_cache(SrsConsumer* consumer)
517 return cache->dump_cache(consumer); 517 return cache->dump_cache(consumer);
518 } 518 }
519 519
520 -SrsStreamWriter::SrsStreamWriter(ISrsGoHttpResponseWriter* w) 520 +SrsStreamWriter::SrsStreamWriter(ISrsHttpResponseWriter* w)
521 { 521 {
522 writer = w; 522 writer = w;
523 } 523 }
@@ -565,7 +565,7 @@ SrsLiveStream::~SrsLiveStream() @@ -565,7 +565,7 @@ SrsLiveStream::~SrsLiveStream()
565 srs_freep(req); 565 srs_freep(req);
566 } 566 }
567 567
568 -int SrsLiveStream::serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r) 568 +int SrsLiveStream::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r)
569 { 569 {
570 int ret = ERROR_SUCCESS; 570 int ret = ERROR_SUCCESS;
571 571
@@ -708,7 +708,7 @@ void SrsHlsM3u8Stream::set_m3u8(std::string v) @@ -708,7 +708,7 @@ void SrsHlsM3u8Stream::set_m3u8(std::string v)
708 m3u8 = v; 708 m3u8 = v;
709 } 709 }
710 710
711 -int SrsHlsM3u8Stream::serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r) 711 +int SrsHlsM3u8Stream::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r)
712 { 712 {
713 int ret = ERROR_SUCCESS; 713 int ret = ERROR_SUCCESS;
714 714
@@ -740,7 +740,7 @@ void SrsHlsTsStream::set_ts(std::string v) @@ -740,7 +740,7 @@ void SrsHlsTsStream::set_ts(std::string v)
740 ts = v; 740 ts = v;
741 } 741 }
742 742
743 -int SrsHlsTsStream::serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r) 743 +int SrsHlsTsStream::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r)
744 { 744 {
745 int ret = ERROR_SUCCESS; 745 int ret = ERROR_SUCCESS;
746 746
@@ -879,9 +879,9 @@ int SrsHttpServer::mount_hls(SrsRequest* r) @@ -879,9 +879,9 @@ int SrsHttpServer::mount_hls(SrsRequest* r)
879 SrsHlsEntry* entry = hls[r->vhost]; 879 SrsHlsEntry* entry = hls[r->vhost];
880 880
881 // TODO: FIXME: supports reload. 881 // TODO: FIXME: supports reload.
882 - std::map<std::string, ISrsGoHttpHandler*>::iterator it; 882 + std::map<std::string, ISrsHttpHandler*>::iterator it;
883 for (it = entry->streams.begin(); it != entry->streams.end(); ++it) { 883 for (it = entry->streams.begin(); it != entry->streams.end(); ++it) {
884 - ISrsGoHttpHandler* stream = it->second; 884 + ISrsHttpHandler* stream = it->second;
885 stream->entry->enabled = true; 885 stream->entry->enabled = true;
886 } 886 }
887 887
@@ -911,7 +911,7 @@ int SrsHttpServer::hls_update_m3u8(SrsRequest* r, string m3u8) @@ -911,7 +911,7 @@ int SrsHttpServer::hls_update_m3u8(SrsRequest* r, string m3u8)
911 mount = srs_string_replace(mount, SRS_CONSTS_RTMP_DEFAULT_VHOST"/", "/"); 911 mount = srs_string_replace(mount, SRS_CONSTS_RTMP_DEFAULT_VHOST"/", "/");
912 912
913 if (entry->streams.find(mount) == entry->streams.end()) { 913 if (entry->streams.find(mount) == entry->streams.end()) {
914 - ISrsGoHttpHandler* he = new SrsHlsM3u8Stream(); 914 + ISrsHttpHandler* he = new SrsHlsM3u8Stream();
915 entry->streams[mount] = he; 915 entry->streams[mount] = he;
916 916
917 if ((ret = mux.handle(mount, he)) != ERROR_SUCCESS) { 917 if ((ret = mux.handle(mount, he)) != ERROR_SUCCESS) {
@@ -962,7 +962,7 @@ int SrsHttpServer::hls_update_ts(SrsRequest* r, string uri, string ts) @@ -962,7 +962,7 @@ int SrsHttpServer::hls_update_ts(SrsRequest* r, string uri, string ts)
962 mount += uri; 962 mount += uri;
963 963
964 if (entry->streams.find(mount) == entry->streams.end()) { 964 if (entry->streams.find(mount) == entry->streams.end()) {
965 - ISrsGoHttpHandler* he = new SrsHlsTsStream(); 965 + ISrsHttpHandler* he = new SrsHlsTsStream();
966 entry->streams[mount] = he; 966 entry->streams[mount] = he;
967 967
968 if ((ret = mux.handle(mount, he)) != ERROR_SUCCESS) { 968 if ((ret = mux.handle(mount, he)) != ERROR_SUCCESS) {
@@ -990,9 +990,9 @@ void SrsHttpServer::unmount_hls(SrsRequest* r) @@ -990,9 +990,9 @@ void SrsHttpServer::unmount_hls(SrsRequest* r)
990 990
991 SrsHlsEntry* entry = hls[r->vhost]; 991 SrsHlsEntry* entry = hls[r->vhost];
992 992
993 - std::map<std::string, ISrsGoHttpHandler*>::iterator it; 993 + std::map<std::string, ISrsHttpHandler*>::iterator it;
994 for (it = entry->streams.begin(); it != entry->streams.end(); ++it) { 994 for (it = entry->streams.begin(); it != entry->streams.end(); ++it) {
995 - ISrsGoHttpHandler* stream = it->second; 995 + ISrsHttpHandler* stream = it->second;
996 stream->entry->enabled = false; 996 stream->entry->enabled = false;
997 } 997 }
998 } 998 }
@@ -1202,7 +1202,7 @@ int SrsHttpConn::do_cycle() @@ -1202,7 +1202,7 @@ int SrsHttpConn::do_cycle()
1202 SrsAutoFree(SrsHttpMessage, req); 1202 SrsAutoFree(SrsHttpMessage, req);
1203 1203
1204 // ok, handle http request. 1204 // ok, handle http request.
1205 - SrsGoHttpResponseWriter writer(&skt); 1205 + SrsHttpResponseWriter writer(&skt);
1206 if ((ret = process_request(&writer, req)) != ERROR_SUCCESS) { 1206 if ((ret = process_request(&writer, req)) != ERROR_SUCCESS) {
1207 return ret; 1207 return ret;
1208 } 1208 }
@@ -1211,7 +1211,7 @@ int SrsHttpConn::do_cycle() @@ -1211,7 +1211,7 @@ int SrsHttpConn::do_cycle()
1211 return ret; 1211 return ret;
1212 } 1212 }
1213 1213
1214 -int SrsHttpConn::process_request(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r) 1214 +int SrsHttpConn::process_request(ISrsHttpResponseWriter* w, SrsHttpMessage* r)
1215 { 1215 {
1216 int ret = ERROR_SUCCESS; 1216 int ret = ERROR_SUCCESS;
1217 1217
@@ -59,14 +59,14 @@ class SrsSharedPtrMessage; @@ -59,14 +59,14 @@ class SrsSharedPtrMessage;
59 * server will write flv header and sequence header, 59 * server will write flv header and sequence header,
60 * then seek(10240) and response flv tag data. 60 * then seek(10240) and response flv tag data.
61 */ 61 */
62 -class SrsVodStream : public SrsGoHttpFileServer 62 +class SrsVodStream : public SrsHttpFileServer
63 { 63 {
64 public: 64 public:
65 SrsVodStream(std::string root_dir); 65 SrsVodStream(std::string root_dir);
66 virtual ~SrsVodStream(); 66 virtual ~SrsVodStream();
67 protected: 67 protected:
68 - virtual int serve_flv_stream(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r, std::string fullpath, int offset);  
69 - virtual int serve_mp4_stream(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r, std::string fullpath, int start, int end); 68 + virtual int serve_flv_stream(ISrsHttpResponseWriter* w, SrsHttpMessage* r, std::string fullpath, int offset);
  69 + virtual int serve_mp4_stream(ISrsHttpResponseWriter* w, SrsHttpMessage* r, std::string fullpath, int start, int end);
70 }; 70 };
71 71
72 /** 72 /**
@@ -214,9 +214,9 @@ public: @@ -214,9 +214,9 @@ public:
214 class SrsStreamWriter : public SrsFileWriter 214 class SrsStreamWriter : public SrsFileWriter
215 { 215 {
216 private: 216 private:
217 - ISrsGoHttpResponseWriter* writer; 217 + ISrsHttpResponseWriter* writer;
218 public: 218 public:
219 - SrsStreamWriter(ISrsGoHttpResponseWriter* w); 219 + SrsStreamWriter(ISrsHttpResponseWriter* w);
220 virtual ~SrsStreamWriter(); 220 virtual ~SrsStreamWriter();
221 public: 221 public:
222 virtual int open(std::string file); 222 virtual int open(std::string file);
@@ -232,7 +232,7 @@ public: @@ -232,7 +232,7 @@ public:
232 * the flv live stream supports access rtmp in flv over http. 232 * the flv live stream supports access rtmp in flv over http.
233 * srs will remux rtmp to flv streaming. 233 * srs will remux rtmp to flv streaming.
234 */ 234 */
235 -class SrsLiveStream : public ISrsGoHttpHandler 235 +class SrsLiveStream : public ISrsHttpHandler
236 { 236 {
237 private: 237 private:
238 SrsRequest* req; 238 SrsRequest* req;
@@ -242,7 +242,7 @@ public: @@ -242,7 +242,7 @@ public:
242 SrsLiveStream(SrsSource* s, SrsRequest* r, SrsStreamCache* c); 242 SrsLiveStream(SrsSource* s, SrsRequest* r, SrsStreamCache* c);
243 virtual ~SrsLiveStream(); 243 virtual ~SrsLiveStream();
244 public: 244 public:
245 - virtual int serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r); 245 + virtual int serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r);
246 private: 246 private:
247 virtual int streaming_send_messages(ISrsStreamEncoder* enc, SrsSharedPtrMessage** msgs, int nb_msgs); 247 virtual int streaming_send_messages(ISrsStreamEncoder* enc, SrsSharedPtrMessage** msgs, int nb_msgs);
248 }; 248 };
@@ -263,7 +263,7 @@ struct SrsLiveEntry @@ -263,7 +263,7 @@ struct SrsLiveEntry
263 /** 263 /**
264 * the m3u8 stream handler. 264 * the m3u8 stream handler.
265 */ 265 */
266 -class SrsHlsM3u8Stream : public ISrsGoHttpHandler 266 +class SrsHlsM3u8Stream : public ISrsHttpHandler
267 { 267 {
268 private: 268 private:
269 std::string m3u8; 269 std::string m3u8;
@@ -273,13 +273,13 @@ public: @@ -273,13 +273,13 @@ public:
273 public: 273 public:
274 virtual void set_m3u8(std::string v); 274 virtual void set_m3u8(std::string v);
275 public: 275 public:
276 - virtual int serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r); 276 + virtual int serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r);
277 }; 277 };
278 278
279 /** 279 /**
280 * the ts stream handler. 280 * the ts stream handler.
281 */ 281 */
282 -class SrsHlsTsStream : public ISrsGoHttpHandler 282 +class SrsHlsTsStream : public ISrsHttpHandler
283 { 283 {
284 private: 284 private:
285 std::string ts; 285 std::string ts;
@@ -289,7 +289,7 @@ public: @@ -289,7 +289,7 @@ public:
289 public: 289 public:
290 virtual void set_ts(std::string v); 290 virtual void set_ts(std::string v);
291 public: 291 public:
292 - virtual int serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r); 292 + virtual int serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r);
293 }; 293 };
294 294
295 /** 295 /**
@@ -302,7 +302,7 @@ struct SrsHlsEntry @@ -302,7 +302,7 @@ struct SrsHlsEntry
302 302
303 // key: the m3u8/ts file path. 303 // key: the m3u8/ts file path.
304 // value: the http handler. 304 // value: the http handler.
305 - std::map<std::string, ISrsGoHttpHandler*> streams; 305 + std::map<std::string, ISrsHttpHandler*> streams;
306 306
307 SrsHlsEntry(); 307 SrsHlsEntry();
308 }; 308 };
@@ -314,7 +314,7 @@ struct SrsHlsEntry @@ -314,7 +314,7 @@ struct SrsHlsEntry
314 class SrsHttpServer : public ISrsReloadHandler 314 class SrsHttpServer : public ISrsReloadHandler
315 { 315 {
316 public: 316 public:
317 - SrsGoHttpServeMux mux; 317 + SrsHttpServeMux mux;
318 // the flv live streaming template. 318 // the flv live streaming template.
319 std::map<std::string, SrsLiveEntry*> flvs; 319 std::map<std::string, SrsLiveEntry*> flvs;
320 // the hls live streaming template. 320 // the hls live streaming template.
@@ -362,7 +362,7 @@ public: @@ -362,7 +362,7 @@ public:
362 protected: 362 protected:
363 virtual int do_cycle(); 363 virtual int do_cycle();
364 private: 364 private:
365 - virtual int process_request(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r); 365 + virtual int process_request(ISrsHttpResponseWriter* w, SrsHttpMessage* r);
366 }; 366 };
367 367
368 #endif 368 #endif
@@ -398,7 +398,7 @@ SrsServer::SrsServer() @@ -398,7 +398,7 @@ SrsServer::SrsServer()
398 // for some global instance is not ready now, 398 // for some global instance is not ready now,
399 // new these objects in initialize instead. 399 // new these objects in initialize instead.
400 #ifdef SRS_AUTO_HTTP_API 400 #ifdef SRS_AUTO_HTTP_API
401 - http_api_mux = new SrsGoHttpServeMux(); 401 + http_api_mux = new SrsHttpServeMux();
402 #endif 402 #endif
403 #ifdef SRS_AUTO_HTTP_SERVER 403 #ifdef SRS_AUTO_HTTP_SERVER
404 http_stream_mux = new SrsHttpServer(); 404 http_stream_mux = new SrsHttpServer();
@@ -41,7 +41,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -41,7 +41,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
41 41
42 class SrsServer; 42 class SrsServer;
43 class SrsConnection; 43 class SrsConnection;
44 -class SrsGoHttpServeMux; 44 +class SrsHttpServeMux;
45 class SrsHttpServer; 45 class SrsHttpServer;
46 class SrsIngester; 46 class SrsIngester;
47 class SrsHttpHeartbeat; 47 class SrsHttpHeartbeat;
@@ -178,7 +178,7 @@ class SrsServer : virtual public ISrsReloadHandler @@ -178,7 +178,7 @@ class SrsServer : virtual public ISrsReloadHandler
178 { 178 {
179 private: 179 private:
180 #ifdef SRS_AUTO_HTTP_API 180 #ifdef SRS_AUTO_HTTP_API
181 - SrsGoHttpServeMux* http_api_mux; 181 + SrsHttpServeMux* http_api_mux;
182 #endif 182 #endif
183 #ifdef SRS_AUTO_HTTP_SERVER 183 #ifdef SRS_AUTO_HTTP_SERVER
184 SrsHttpServer* http_stream_mux; 184 SrsHttpServer* http_stream_mux;