mirror of
https://github.com/ossrs/srs.git
synced 2025-02-15 04:42:04 +00:00
refine macros of HTTP
This commit is contained in:
parent
198a7f1e9d
commit
573952e2fc
15 changed files with 97 additions and 88 deletions
|
@ -170,7 +170,7 @@ int SrsEdgeIngester::ingest()
|
||||||
|
|
||||||
client->set_recv_timeout(SRS_EDGE_INGESTER_TIMEOUT_US);
|
client->set_recv_timeout(SRS_EDGE_INGESTER_TIMEOUT_US);
|
||||||
|
|
||||||
SrsPithyPrint pithy_print(SRS_STAGE_EDGE);
|
SrsPithyPrint pithy_print(SRS_CONSTS_STAGE_EDGE);
|
||||||
|
|
||||||
while (pthread->can_loop()) {
|
while (pthread->can_loop()) {
|
||||||
// switch to other st-threads.
|
// switch to other st-threads.
|
||||||
|
@ -413,7 +413,7 @@ int SrsEdgeForwarder::cycle()
|
||||||
|
|
||||||
client->set_recv_timeout(SRS_CONSTS_RTMP_PULSE_TIMEOUT_US);
|
client->set_recv_timeout(SRS_CONSTS_RTMP_PULSE_TIMEOUT_US);
|
||||||
|
|
||||||
SrsPithyPrint pithy_print(SRS_STAGE_EDGE);
|
SrsPithyPrint pithy_print(SRS_CONSTS_STAGE_EDGE);
|
||||||
|
|
||||||
SrsSharedPtrMessageArray msgs(SYS_MAX_EDGE_SEND_MSGS);
|
SrsSharedPtrMessageArray msgs(SYS_MAX_EDGE_SEND_MSGS);
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ static std::vector<std::string> _transcoded_url;
|
||||||
SrsEncoder::SrsEncoder()
|
SrsEncoder::SrsEncoder()
|
||||||
{
|
{
|
||||||
pthread = new SrsThread(this, SRS_RTMP_ENCODER_SLEEP_US, true);
|
pthread = new SrsThread(this, SRS_RTMP_ENCODER_SLEEP_US, true);
|
||||||
pithy_print = new SrsPithyPrint(SRS_STAGE_ENCODER);
|
pithy_print = new SrsPithyPrint(SRS_CONSTS_STAGE_ENCODER);
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsEncoder::~SrsEncoder()
|
SrsEncoder::~SrsEncoder()
|
||||||
|
|
|
@ -284,7 +284,7 @@ int SrsForwarder::forward()
|
||||||
|
|
||||||
client->set_recv_timeout(SRS_CONSTS_RTMP_PULSE_TIMEOUT_US);
|
client->set_recv_timeout(SRS_CONSTS_RTMP_PULSE_TIMEOUT_US);
|
||||||
|
|
||||||
SrsPithyPrint pithy_print(SRS_STAGE_FORWARDER);
|
SrsPithyPrint pithy_print(SRS_CONSTS_STAGE_FORWARDER);
|
||||||
|
|
||||||
SrsSharedPtrMessageArray msgs(SYS_MAX_FORWARD_SEND_MSGS);
|
SrsSharedPtrMessageArray msgs(SYS_MAX_FORWARD_SEND_MSGS);
|
||||||
|
|
||||||
|
|
|
@ -1342,7 +1342,7 @@ SrsHls::SrsHls(SrsSource* _source)
|
||||||
muxer = new SrsHlsMuxer();
|
muxer = new SrsHlsMuxer();
|
||||||
hls_cache = new SrsHlsCache();
|
hls_cache = new SrsHlsCache();
|
||||||
|
|
||||||
pithy_print = new SrsPithyPrint(SRS_STAGE_HLS);
|
pithy_print = new SrsPithyPrint(SRS_CONSTS_STAGE_HLS);
|
||||||
stream_dts = 0;
|
stream_dts = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -217,107 +217,107 @@ int SrsHttpHandler::best_match(const char* path, int length, SrsHttpHandlerMatch
|
||||||
|
|
||||||
SrsHttpHandler* SrsHttpHandler::res_status_line(stringstream& ss)
|
SrsHttpHandler* SrsHttpHandler::res_status_line(stringstream& ss)
|
||||||
{
|
{
|
||||||
ss << "HTTP/1.1 200 OK " << __CRLF
|
ss << "HTTP/1.1 200 OK " << __SRS_CRLF
|
||||||
<< "Server: "RTMP_SIG_SRS_KEY"/"RTMP_SIG_SRS_VERSION"" << __CRLF;
|
<< "Server: "RTMP_SIG_SRS_KEY"/"RTMP_SIG_SRS_VERSION"" << __SRS_CRLF;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsHttpHandler* SrsHttpHandler::res_status_line_error(stringstream& ss, int code, string reason_phrase)
|
SrsHttpHandler* SrsHttpHandler::res_status_line_error(stringstream& ss, int code, string reason_phrase)
|
||||||
{
|
{
|
||||||
ss << "HTTP/1.1 " << code << " " << reason_phrase << __CRLF
|
ss << "HTTP/1.1 " << code << " " << reason_phrase << __SRS_CRLF
|
||||||
<< "Server: SRS/"RTMP_SIG_SRS_VERSION"" << __CRLF;
|
<< "Server: SRS/"RTMP_SIG_SRS_VERSION"" << __SRS_CRLF;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsHttpHandler* SrsHttpHandler::res_content_type(stringstream& ss)
|
SrsHttpHandler* SrsHttpHandler::res_content_type(stringstream& ss)
|
||||||
{
|
{
|
||||||
ss << "Content-Type: text/html;charset=utf-8" << __CRLF
|
ss << "Content-Type: text/html;charset=utf-8" << __SRS_CRLF
|
||||||
<< "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __CRLF;
|
<< "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __SRS_CRLF;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsHttpHandler* SrsHttpHandler::res_content_type_xml(stringstream& ss)
|
SrsHttpHandler* SrsHttpHandler::res_content_type_xml(stringstream& ss)
|
||||||
{
|
{
|
||||||
ss << "Content-Type: text/xml;charset=utf-8" << __CRLF
|
ss << "Content-Type: text/xml;charset=utf-8" << __SRS_CRLF
|
||||||
<< "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __CRLF;
|
<< "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __SRS_CRLF;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsHttpHandler* SrsHttpHandler::res_content_type_javascript(stringstream& ss)
|
SrsHttpHandler* SrsHttpHandler::res_content_type_javascript(stringstream& ss)
|
||||||
{
|
{
|
||||||
ss << "Content-Type: text/javascript" << __CRLF
|
ss << "Content-Type: text/javascript" << __SRS_CRLF
|
||||||
<< "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __CRLF;
|
<< "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __SRS_CRLF;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsHttpHandler* SrsHttpHandler::res_content_type_swf(stringstream& ss)
|
SrsHttpHandler* SrsHttpHandler::res_content_type_swf(stringstream& ss)
|
||||||
{
|
{
|
||||||
ss << "Content-Type: application/x-shockwave-flash" << __CRLF
|
ss << "Content-Type: application/x-shockwave-flash" << __SRS_CRLF
|
||||||
<< "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __CRLF;
|
<< "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __SRS_CRLF;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsHttpHandler* SrsHttpHandler::res_content_type_css(stringstream& ss)
|
SrsHttpHandler* SrsHttpHandler::res_content_type_css(stringstream& ss)
|
||||||
{
|
{
|
||||||
ss << "Content-Type: text/css;charset=utf-8" << __CRLF
|
ss << "Content-Type: text/css;charset=utf-8" << __SRS_CRLF
|
||||||
<< "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __CRLF;
|
<< "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __SRS_CRLF;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsHttpHandler* SrsHttpHandler::res_content_type_ico(stringstream& ss)
|
SrsHttpHandler* SrsHttpHandler::res_content_type_ico(stringstream& ss)
|
||||||
{
|
{
|
||||||
ss << "Content-Type: image/x-icon" << __CRLF
|
ss << "Content-Type: image/x-icon" << __SRS_CRLF
|
||||||
<< "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __CRLF;
|
<< "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __SRS_CRLF;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsHttpHandler* SrsHttpHandler::res_content_type_json(stringstream& ss)
|
SrsHttpHandler* SrsHttpHandler::res_content_type_json(stringstream& ss)
|
||||||
{
|
{
|
||||||
ss << "Content-Type: application/json;charset=utf-8" << __CRLF
|
ss << "Content-Type: application/json;charset=utf-8" << __SRS_CRLF
|
||||||
<< "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __CRLF;
|
<< "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __SRS_CRLF;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsHttpHandler* SrsHttpHandler::res_content_type_m3u8(stringstream& ss)
|
SrsHttpHandler* SrsHttpHandler::res_content_type_m3u8(stringstream& ss)
|
||||||
{
|
{
|
||||||
ss << "Content-Type: application/x-mpegURL;charset=utf-8" << __CRLF
|
ss << "Content-Type: application/x-mpegURL;charset=utf-8" << __SRS_CRLF
|
||||||
<< "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __CRLF;
|
<< "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __SRS_CRLF;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsHttpHandler* SrsHttpHandler::res_content_type_mpegts(stringstream& ss)
|
SrsHttpHandler* SrsHttpHandler::res_content_type_mpegts(stringstream& ss)
|
||||||
{
|
{
|
||||||
ss << "Content-Type: video/MP2T" << __CRLF
|
ss << "Content-Type: video/MP2T" << __SRS_CRLF
|
||||||
<< "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __CRLF;
|
<< "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __SRS_CRLF;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsHttpHandler* SrsHttpHandler::res_content_type_flv(stringstream& ss)
|
SrsHttpHandler* SrsHttpHandler::res_content_type_flv(stringstream& ss)
|
||||||
{
|
{
|
||||||
ss << "Content-Type: video/x-flv" << __CRLF
|
ss << "Content-Type: video/x-flv" << __SRS_CRLF
|
||||||
<< "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __CRLF;
|
<< "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __SRS_CRLF;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsHttpHandler* SrsHttpHandler::res_content_length(stringstream& ss, int64_t length)
|
SrsHttpHandler* SrsHttpHandler::res_content_length(stringstream& ss, int64_t length)
|
||||||
{
|
{
|
||||||
ss << "Content-Length: "<< length << __CRLF;
|
ss << "Content-Length: "<< length << __SRS_CRLF;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsHttpHandler* SrsHttpHandler::res_enable_crossdomain(stringstream& ss)
|
SrsHttpHandler* SrsHttpHandler::res_enable_crossdomain(stringstream& ss)
|
||||||
{
|
{
|
||||||
ss << "Access-Control-Allow-Origin: *" << __CRLF
|
ss << "Access-Control-Allow-Origin: *" << __SRS_CRLF
|
||||||
<< "Access-Control-Allow-Methods: "
|
<< "Access-Control-Allow-Methods: "
|
||||||
<< "GET, POST, HEAD, PUT, DELETE" << __CRLF
|
<< "GET, POST, HEAD, PUT, DELETE" << __SRS_CRLF
|
||||||
<< "Access-Control-Allow-Headers: "
|
<< "Access-Control-Allow-Headers: "
|
||||||
<< "Cache-Control,X-Proxy-Authorization,X-Requested-With,Content-Type" << __CRLF;
|
<< "Cache-Control,X-Proxy-Authorization,X-Requested-With,Content-Type" << __SRS_CRLF;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsHttpHandler* SrsHttpHandler::res_header_eof(stringstream& ss)
|
SrsHttpHandler* SrsHttpHandler::res_header_eof(stringstream& ss)
|
||||||
{
|
{
|
||||||
ss << __CRLF;
|
ss << __SRS_CRLF;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,19 +48,19 @@ class SrsHttpHandler;
|
||||||
|
|
||||||
// http specification
|
// http specification
|
||||||
// CR = <US-ASCII CR, carriage return (13)>
|
// CR = <US-ASCII CR, carriage return (13)>
|
||||||
#define __CR "\r" // 0x0D
|
#define __SRS_CR "\r" // 0x0D
|
||||||
// LF = <US-ASCII LF, linefeed (10)>
|
// LF = <US-ASCII LF, linefeed (10)>
|
||||||
#define __LF "\n" // 0x0A
|
#define __SRS_LF "\n" // 0x0A
|
||||||
// SP = <US-ASCII SP, space (32)>
|
// SP = <US-ASCII SP, space (32)>
|
||||||
#define __SP " " // 0x20
|
#define __SRS_SP " " // 0x20
|
||||||
// HT = <US-ASCII HT, horizontal-tab (9)>
|
// HT = <US-ASCII HT, horizontal-tab (9)>
|
||||||
#define __HT "\x09" // 0x09
|
#define __SRS_HT "\x09" // 0x09
|
||||||
|
|
||||||
// HTTP/1.1 defines the sequence CR LF as the end-of-line marker for all
|
// HTTP/1.1 defines the sequence CR LF as the end-of-line marker for all
|
||||||
// protocol elements except the entity-body (see appendix 19.3 for
|
// protocol elements except the entity-body (see appendix 19.3 for
|
||||||
// tolerant applications).
|
// tolerant applications).
|
||||||
#define __CRLF "\r\n" // 0x0D0A
|
#define __SRS_CRLF "\r\n" // 0x0D0A
|
||||||
#define __CRLFCRLF "\r\n\r\n" // 0x0D0A0D0A
|
#define __SRS_CRLFCRLF "\r\n\r\n" // 0x0D0A0D0A
|
||||||
|
|
||||||
// 6.1.1 Status Code and Reason Phrase
|
// 6.1.1 Status Code and Reason Phrase
|
||||||
#define HTTP_Continue 100
|
#define HTTP_Continue 100
|
||||||
|
|
|
@ -76,13 +76,13 @@ int SrsHttpClient::post(SrsHttpUri* uri, string req, string& res)
|
||||||
// POST %s HTTP/1.1\r\nHost: %s\r\nContent-Length: %d\r\n\r\n%s
|
// POST %s HTTP/1.1\r\nHost: %s\r\nContent-Length: %d\r\n\r\n%s
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << "POST " << uri->get_path() << " "
|
ss << "POST " << uri->get_path() << " "
|
||||||
<< "HTTP/1.1" << __CRLF
|
<< "HTTP/1.1" << __SRS_CRLF
|
||||||
<< "Host: " << uri->get_host() << __CRLF
|
<< "Host: " << uri->get_host() << __SRS_CRLF
|
||||||
<< "Connection: Keep-Alive" << __CRLF
|
<< "Connection: Keep-Alive" << __SRS_CRLF
|
||||||
<< "Content-Length: " << std::dec << req.length() << __CRLF
|
<< "Content-Length: " << std::dec << req.length() << __SRS_CRLF
|
||||||
<< "User-Agent: " << RTMP_SIG_SRS_NAME << RTMP_SIG_SRS_VERSION << __CRLF
|
<< "User-Agent: " << RTMP_SIG_SRS_NAME << RTMP_SIG_SRS_VERSION << __SRS_CRLF
|
||||||
<< "Content-Type: text/html" << __CRLF
|
<< "Content-Type: text/html" << __SRS_CRLF
|
||||||
<< __CRLF
|
<< __SRS_CRLF
|
||||||
<< req;
|
<< req;
|
||||||
|
|
||||||
SrsSocket skt(stfd);
|
SrsSocket skt(stfd);
|
||||||
|
|
|
@ -56,7 +56,7 @@ SrsIngester::SrsIngester()
|
||||||
_srs_config->subscribe(this);
|
_srs_config->subscribe(this);
|
||||||
|
|
||||||
pthread = new SrsThread(this, SRS_AUTO_INGESTER_SLEEP_US, true);
|
pthread = new SrsThread(this, SRS_AUTO_INGESTER_SLEEP_US, true);
|
||||||
pithy_print = new SrsPithyPrint(SRS_STAGE_INGESTER);
|
pithy_print = new SrsPithyPrint(SRS_CONSTS_STAGE_INGESTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsIngester::~SrsIngester()
|
SrsIngester::~SrsIngester()
|
||||||
|
|
|
@ -32,7 +32,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
#include <srs_kernel_error.hpp>
|
#include <srs_kernel_error.hpp>
|
||||||
#include <srs_kernel_utility.hpp>
|
#include <srs_kernel_utility.hpp>
|
||||||
|
|
||||||
#define SRS_STAGE_DEFAULT_INTERVAL_MS 1200
|
#define SRS_CONSTS_STAGE_DEFAULT_INTERVAL_MS 1200
|
||||||
|
|
||||||
SrsStageInfo::SrsStageInfo(int _stage_id)
|
SrsStageInfo::SrsStageInfo(int _stage_id)
|
||||||
{
|
{
|
||||||
|
@ -53,36 +53,36 @@ SrsStageInfo::~SrsStageInfo()
|
||||||
void SrsStageInfo::update_print_time()
|
void SrsStageInfo::update_print_time()
|
||||||
{
|
{
|
||||||
switch (stage_id) {
|
switch (stage_id) {
|
||||||
case SRS_STAGE_PLAY_USER: {
|
case SRS_CONSTS_STAGE_PLAY_USER: {
|
||||||
pithy_print_time_ms = _srs_config->get_pithy_print_play();
|
pithy_print_time_ms = _srs_config->get_pithy_print_play();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SRS_STAGE_PUBLISH_USER: {
|
case SRS_CONSTS_STAGE_PUBLISH_USER: {
|
||||||
pithy_print_time_ms = _srs_config->get_pithy_print_publish();
|
pithy_print_time_ms = _srs_config->get_pithy_print_publish();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SRS_STAGE_FORWARDER: {
|
case SRS_CONSTS_STAGE_FORWARDER: {
|
||||||
pithy_print_time_ms = _srs_config->get_pithy_print_forwarder();
|
pithy_print_time_ms = _srs_config->get_pithy_print_forwarder();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SRS_STAGE_ENCODER: {
|
case SRS_CONSTS_STAGE_ENCODER: {
|
||||||
pithy_print_time_ms = _srs_config->get_pithy_print_encoder();
|
pithy_print_time_ms = _srs_config->get_pithy_print_encoder();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SRS_STAGE_INGESTER: {
|
case SRS_CONSTS_STAGE_INGESTER: {
|
||||||
pithy_print_time_ms = _srs_config->get_pithy_print_ingester();
|
pithy_print_time_ms = _srs_config->get_pithy_print_ingester();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SRS_STAGE_EDGE: {
|
case SRS_CONSTS_STAGE_EDGE: {
|
||||||
pithy_print_time_ms = _srs_config->get_pithy_print_edge();
|
pithy_print_time_ms = _srs_config->get_pithy_print_edge();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SRS_STAGE_HLS: {
|
case SRS_CONSTS_STAGE_HLS: {
|
||||||
pithy_print_time_ms = _srs_config->get_pithy_print_hls();
|
pithy_print_time_ms = _srs_config->get_pithy_print_hls();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
pithy_print_time_ms = SRS_STAGE_DEFAULT_INTERVAL_MS;
|
pithy_print_time_ms = SRS_CONSTS_STAGE_DEFAULT_INTERVAL_MS;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,21 +32,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
#include <srs_app_reload.hpp>
|
#include <srs_app_reload.hpp>
|
||||||
|
|
||||||
// the pithy stage for all play clients.
|
|
||||||
#define SRS_STAGE_PLAY_USER 1
|
|
||||||
// the pithy stage for all publish clients.
|
|
||||||
#define SRS_STAGE_PUBLISH_USER 2
|
|
||||||
// the pithy stage for all forward clients.
|
|
||||||
#define SRS_STAGE_FORWARDER 3
|
|
||||||
// the pithy stage for all encoders.
|
|
||||||
#define SRS_STAGE_ENCODER 4
|
|
||||||
// the pithy stage for all hls.
|
|
||||||
#define SRS_STAGE_HLS 5
|
|
||||||
// the pithy stage for all ingesters.
|
|
||||||
#define SRS_STAGE_INGESTER 6
|
|
||||||
// the pithy stage for all edge.
|
|
||||||
#define SRS_STAGE_EDGE 7
|
|
||||||
|
|
||||||
class SrsStageInfo : public ISrsReloadHandler
|
class SrsStageInfo : public ISrsReloadHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -83,7 +68,7 @@ private:
|
||||||
int64_t previous_tick;
|
int64_t previous_tick;
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @param _stage_id defined in SRS_STAGE_xxx, eg. SRS_STAGE_PLAY_USER.
|
* @param _stage_id defined in SRS_CONSTS_STAGE_xxx, eg. SRS_CONSTS_STAGE_PLAY_USER.
|
||||||
*/
|
*/
|
||||||
SrsPithyPrint(int _stage_id);
|
SrsPithyPrint(int _stage_id);
|
||||||
virtual ~SrsPithyPrint();
|
virtual ~SrsPithyPrint();
|
||||||
|
|
|
@ -503,7 +503,7 @@ int SrsRtmpConn::playing(SrsSource* source)
|
||||||
|
|
||||||
rtmp->set_recv_timeout(SRS_CONSTS_RTMP_PULSE_TIMEOUT_US);
|
rtmp->set_recv_timeout(SRS_CONSTS_RTMP_PULSE_TIMEOUT_US);
|
||||||
|
|
||||||
SrsPithyPrint pithy_print(SRS_STAGE_PLAY_USER);
|
SrsPithyPrint pithy_print(SRS_CONSTS_STAGE_PLAY_USER);
|
||||||
|
|
||||||
SrsSharedPtrMessageArray msgs(SYS_MAX_PLAY_SEND_MSGS);
|
SrsSharedPtrMessageArray msgs(SYS_MAX_PLAY_SEND_MSGS);
|
||||||
|
|
||||||
|
@ -611,7 +611,7 @@ int SrsRtmpConn::fmle_publishing(SrsSource* source)
|
||||||
}
|
}
|
||||||
srs_verbose("fmle check publish_refer success.");
|
srs_verbose("fmle check publish_refer success.");
|
||||||
|
|
||||||
SrsPithyPrint pithy_print(SRS_STAGE_PUBLISH_USER);
|
SrsPithyPrint pithy_print(SRS_CONSTS_STAGE_PUBLISH_USER);
|
||||||
|
|
||||||
bool vhost_is_edge = _srs_config->get_vhost_is_edge(req->vhost);
|
bool vhost_is_edge = _srs_config->get_vhost_is_edge(req->vhost);
|
||||||
|
|
||||||
|
@ -690,7 +690,7 @@ int SrsRtmpConn::flash_publishing(SrsSource* source)
|
||||||
}
|
}
|
||||||
srs_verbose("flash check publish_refer success.");
|
srs_verbose("flash check publish_refer success.");
|
||||||
|
|
||||||
SrsPithyPrint pithy_print(SRS_STAGE_PUBLISH_USER);
|
SrsPithyPrint pithy_print(SRS_CONSTS_STAGE_PUBLISH_USER);
|
||||||
|
|
||||||
bool vhost_is_edge = _srs_config->get_vhost_is_edge(req->vhost);
|
bool vhost_is_edge = _srs_config->get_vhost_is_edge(req->vhost);
|
||||||
|
|
||||||
|
|
|
@ -125,5 +125,29 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
// encoder log id.
|
// encoder log id.
|
||||||
#define SRS_CONSTS_LOG_ENCODER "ENC"
|
#define SRS_CONSTS_LOG_ENCODER "ENC"
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
// pithy-print consts values
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
// the pithy stage for all play clients.
|
||||||
|
#define SRS_CONSTS_STAGE_PLAY_USER 1
|
||||||
|
// the pithy stage for all publish clients.
|
||||||
|
#define SRS_CONSTS_STAGE_PUBLISH_USER 2
|
||||||
|
// the pithy stage for all forward clients.
|
||||||
|
#define SRS_CONSTS_STAGE_FORWARDER 3
|
||||||
|
// the pithy stage for all encoders.
|
||||||
|
#define SRS_CONSTS_STAGE_ENCODER 4
|
||||||
|
// the pithy stage for all hls.
|
||||||
|
#define SRS_CONSTS_STAGE_HLS 5
|
||||||
|
// the pithy stage for all ingesters.
|
||||||
|
#define SRS_CONSTS_STAGE_INGESTER 6
|
||||||
|
// the pithy stage for all edge.
|
||||||
|
#define SRS_CONSTS_STAGE_EDGE 7
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -583,14 +583,14 @@ namespace _srs_internal
|
||||||
{
|
{
|
||||||
int ret = ERROR_SUCCESS;
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
char temp_key[OpensslHashSize];
|
char temp_key[SRS_CONSTS_OpensslHashSize];
|
||||||
if ((ret = openssl_HMACsha256(s1->get_digest(), 32, SrsGenuineFPKey, 62, temp_key)) != ERROR_SUCCESS) {
|
if ((ret = openssl_HMACsha256(s1->get_digest(), 32, SrsGenuineFPKey, 62, temp_key)) != ERROR_SUCCESS) {
|
||||||
srs_error("create c2 temp key failed. ret=%d", ret);
|
srs_error("create c2 temp key failed. ret=%d", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
srs_verbose("generate c2 temp key success.");
|
srs_verbose("generate c2 temp key success.");
|
||||||
|
|
||||||
char _digest[OpensslHashSize];
|
char _digest[SRS_CONSTS_OpensslHashSize];
|
||||||
if ((ret = openssl_HMACsha256(random, 1504, temp_key, 32, _digest)) != ERROR_SUCCESS) {
|
if ((ret = openssl_HMACsha256(random, 1504, temp_key, 32, _digest)) != ERROR_SUCCESS) {
|
||||||
srs_error("create c2 digest failed. ret=%d", ret);
|
srs_error("create c2 digest failed. ret=%d", ret);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -607,14 +607,14 @@ namespace _srs_internal
|
||||||
is_valid = false;
|
is_valid = false;
|
||||||
int ret = ERROR_SUCCESS;
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
char temp_key[OpensslHashSize];
|
char temp_key[SRS_CONSTS_OpensslHashSize];
|
||||||
if ((ret = openssl_HMACsha256(s1->get_digest(), 32, SrsGenuineFPKey, 62, temp_key)) != ERROR_SUCCESS) {
|
if ((ret = openssl_HMACsha256(s1->get_digest(), 32, SrsGenuineFPKey, 62, temp_key)) != ERROR_SUCCESS) {
|
||||||
srs_error("create c2 temp key failed. ret=%d", ret);
|
srs_error("create c2 temp key failed. ret=%d", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
srs_verbose("generate c2 temp key success.");
|
srs_verbose("generate c2 temp key success.");
|
||||||
|
|
||||||
char _digest[OpensslHashSize];
|
char _digest[SRS_CONSTS_OpensslHashSize];
|
||||||
if ((ret = openssl_HMACsha256(random, 1504, temp_key, 32, _digest)) != ERROR_SUCCESS) {
|
if ((ret = openssl_HMACsha256(random, 1504, temp_key, 32, _digest)) != ERROR_SUCCESS) {
|
||||||
srs_error("create c2 digest failed. ret=%d", ret);
|
srs_error("create c2 digest failed. ret=%d", ret);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -630,14 +630,14 @@ namespace _srs_internal
|
||||||
{
|
{
|
||||||
int ret = ERROR_SUCCESS;
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
char temp_key[OpensslHashSize];
|
char temp_key[SRS_CONSTS_OpensslHashSize];
|
||||||
if ((ret = openssl_HMACsha256(c1->get_digest(), 32, SrsGenuineFMSKey, 68, temp_key)) != ERROR_SUCCESS) {
|
if ((ret = openssl_HMACsha256(c1->get_digest(), 32, SrsGenuineFMSKey, 68, temp_key)) != ERROR_SUCCESS) {
|
||||||
srs_error("create s2 temp key failed. ret=%d", ret);
|
srs_error("create s2 temp key failed. ret=%d", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
srs_verbose("generate s2 temp key success.");
|
srs_verbose("generate s2 temp key success.");
|
||||||
|
|
||||||
char _digest[OpensslHashSize];
|
char _digest[SRS_CONSTS_OpensslHashSize];
|
||||||
if ((ret = openssl_HMACsha256(random, 1504, temp_key, 32, _digest)) != ERROR_SUCCESS) {
|
if ((ret = openssl_HMACsha256(random, 1504, temp_key, 32, _digest)) != ERROR_SUCCESS) {
|
||||||
srs_error("create s2 digest failed. ret=%d", ret);
|
srs_error("create s2 digest failed. ret=%d", ret);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -654,14 +654,14 @@ namespace _srs_internal
|
||||||
is_valid = false;
|
is_valid = false;
|
||||||
int ret = ERROR_SUCCESS;
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
char temp_key[OpensslHashSize];
|
char temp_key[SRS_CONSTS_OpensslHashSize];
|
||||||
if ((ret = openssl_HMACsha256(c1->get_digest(), 32, SrsGenuineFMSKey, 68, temp_key)) != ERROR_SUCCESS) {
|
if ((ret = openssl_HMACsha256(c1->get_digest(), 32, SrsGenuineFMSKey, 68, temp_key)) != ERROR_SUCCESS) {
|
||||||
srs_error("create s2 temp key failed. ret=%d", ret);
|
srs_error("create s2 temp key failed. ret=%d", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
srs_verbose("generate s2 temp key success.");
|
srs_verbose("generate s2 temp key success.");
|
||||||
|
|
||||||
char _digest[OpensslHashSize];
|
char _digest[SRS_CONSTS_OpensslHashSize];
|
||||||
if ((ret = openssl_HMACsha256(random, 1504, temp_key, 32, _digest)) != ERROR_SUCCESS) {
|
if ((ret = openssl_HMACsha256(random, 1504, temp_key, 32, _digest)) != ERROR_SUCCESS) {
|
||||||
srs_error("create s2 digest failed. ret=%d", ret);
|
srs_error("create s2 digest failed. ret=%d", ret);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -921,7 +921,7 @@ namespace _srs_internal
|
||||||
srs_assert(c1s1_joined_bytes != NULL);
|
srs_assert(c1s1_joined_bytes != NULL);
|
||||||
SrsAutoFree(char, c1s1_joined_bytes);
|
SrsAutoFree(char, c1s1_joined_bytes);
|
||||||
|
|
||||||
digest = new char[OpensslHashSize];
|
digest = new char[SRS_CONSTS_OpensslHashSize];
|
||||||
if ((ret = openssl_HMACsha256(c1s1_joined_bytes, 1536 - 32, SrsGenuineFMSKey, 36, digest)) != ERROR_SUCCESS) {
|
if ((ret = openssl_HMACsha256(c1s1_joined_bytes, 1536 - 32, SrsGenuineFMSKey, 36, digest)) != ERROR_SUCCESS) {
|
||||||
srs_error("calc digest for s1 failed. ret=%d", ret);
|
srs_error("calc digest for s1 failed. ret=%d", ret);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -948,7 +948,7 @@ namespace _srs_internal
|
||||||
srs_assert(c1s1_joined_bytes != NULL);
|
srs_assert(c1s1_joined_bytes != NULL);
|
||||||
SrsAutoFree(char, c1s1_joined_bytes);
|
SrsAutoFree(char, c1s1_joined_bytes);
|
||||||
|
|
||||||
digest = new char[OpensslHashSize];
|
digest = new char[SRS_CONSTS_OpensslHashSize];
|
||||||
if ((ret = openssl_HMACsha256(c1s1_joined_bytes, 1536 - 32, SrsGenuineFPKey, 30, digest)) != ERROR_SUCCESS) {
|
if ((ret = openssl_HMACsha256(c1s1_joined_bytes, 1536 - 32, SrsGenuineFPKey, 30, digest)) != ERROR_SUCCESS) {
|
||||||
srs_error("calc digest for c1 failed. ret=%d", ret);
|
srs_error("calc digest for c1 failed. ret=%d", ret);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -111,7 +111,7 @@ namespace _srs_internal
|
||||||
};
|
};
|
||||||
|
|
||||||
// the digest key generate size.
|
// the digest key generate size.
|
||||||
#define OpensslHashSize 512
|
#define SRS_CONSTS_OpensslHashSize 512
|
||||||
extern u_int8_t SrsGenuineFMSKey[];
|
extern u_int8_t SrsGenuineFMSKey[];
|
||||||
extern u_int8_t SrsGenuineFPKey[];
|
extern u_int8_t SrsGenuineFPKey[];
|
||||||
int openssl_HMACsha256(const void* data, int data_size, const void* key, int key_size, void* digest);
|
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)
|
||||||
(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,
|
(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,
|
||||||
};
|
};
|
||||||
|
|
||||||
char digest[OpensslHashSize];
|
char digest[SRS_CONSTS_OpensslHashSize];
|
||||||
ASSERT_EQ(ERROR_SUCCESS,
|
ASSERT_EQ(ERROR_SUCCESS,
|
||||||
openssl_HMACsha256(
|
openssl_HMACsha256(
|
||||||
random_bytes, sizeof(random_bytes),
|
random_bytes, sizeof(random_bytes),
|
||||||
|
|
Loading…
Reference in a new issue