mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-26 04:31:37 +08:00
整理代码
This commit is contained in:
parent
67f4ca4b83
commit
11420b868b
@ -57,7 +57,7 @@ bool loadIniConfig(const char *ini_path = nullptr);
|
|||||||
#define CLEAR_ARR(arr) for(auto &item : arr){ item = 0;}
|
#define CLEAR_ARR(arr) for(auto &item : arr){ item = 0;}
|
||||||
#endif //CLEAR_ARR
|
#endif //CLEAR_ARR
|
||||||
|
|
||||||
#define SERVER_NAME "ZLMediaKit-4.0"
|
#define SERVER_NAME "ZLMediaKit-4.0(build in " __DATE__ " " __TIME__ ")"
|
||||||
#define VHOST_KEY "vhost"
|
#define VHOST_KEY "vhost"
|
||||||
#define HTTP_SCHEMA "http"
|
#define HTTP_SCHEMA "http"
|
||||||
#define RTSP_SCHEMA "rtsp"
|
#define RTSP_SCHEMA "rtsp"
|
||||||
|
@ -71,7 +71,7 @@ void HttpClient::sendRequest(const string &strUrl, float fTimeOutSec) {
|
|||||||
host = FindField(host.data(), NULL, ":");
|
host = FindField(host.data(), NULL, ":");
|
||||||
}
|
}
|
||||||
_header.emplace("Host", host);
|
_header.emplace("Host", host);
|
||||||
_header.emplace("Tools", "ZLMediaKit");
|
_header.emplace("Tools", SERVER_NAME);
|
||||||
_header.emplace("Connection", "keep-alive");
|
_header.emplace("Connection", "keep-alive");
|
||||||
_header.emplace("Accept", "*/*");
|
_header.emplace("Accept", "*/*");
|
||||||
_header.emplace("Accept-Language", "zh-CN,zh;q=0.8");
|
_header.emplace("Accept-Language", "zh-CN,zh;q=0.8");
|
||||||
|
@ -398,7 +398,6 @@ static const string kContentType = "Content-Type";
|
|||||||
static const string kContentLength = "Content-Length";
|
static const string kContentLength = "Content-Length";
|
||||||
static const string kAccessControlAllowOrigin = "Access-Control-Allow-Origin";
|
static const string kAccessControlAllowOrigin = "Access-Control-Allow-Origin";
|
||||||
static const string kAccessControlAllowCredentials = "Access-Control-Allow-Credentials";
|
static const string kAccessControlAllowCredentials = "Access-Control-Allow-Credentials";
|
||||||
static const string kServerName = SERVER_NAME;
|
|
||||||
|
|
||||||
void HttpSession::sendResponse(const char *pcStatus,
|
void HttpSession::sendResponse(const char *pcStatus,
|
||||||
bool bClose,
|
bool bClose,
|
||||||
@ -426,7 +425,7 @@ void HttpSession::sendResponse(const char *pcStatus,
|
|||||||
|
|
||||||
HttpSession::KeyValue &headerOut = const_cast<HttpSession::KeyValue &>(header);
|
HttpSession::KeyValue &headerOut = const_cast<HttpSession::KeyValue &>(header);
|
||||||
headerOut.emplace(kDate, dateStr());
|
headerOut.emplace(kDate, dateStr());
|
||||||
headerOut.emplace(kServer, kServerName);
|
headerOut.emplace(kServer, SERVER_NAME);
|
||||||
headerOut.emplace(kConnection, bClose ? "close" : "keep-alive");
|
headerOut.emplace(kConnection, bClose ? "close" : "keep-alive");
|
||||||
if(!bClose){
|
if(!bClose){
|
||||||
string keepAliveString = "timeout=";
|
string keepAliveString = "timeout=";
|
||||||
|
@ -325,7 +325,7 @@ public:
|
|||||||
const map<string,string> &header = map<string,string>()){
|
const map<string,string> &header = map<string,string>()){
|
||||||
_metadata.set("duration", dur_sec);
|
_metadata.set("duration", dur_sec);
|
||||||
_metadata.set("fileSize", 0);
|
_metadata.set("fileSize", 0);
|
||||||
_metadata.set("server","ZLMediaKit");
|
_metadata.set("server",SERVER_NAME);
|
||||||
for (auto &pr : header){
|
for (auto &pr : header){
|
||||||
_metadata.set(pr.first, pr.second);
|
_metadata.set(pr.first, pr.second);
|
||||||
}
|
}
|
||||||
|
@ -108,8 +108,7 @@ string SdpTrack::toString() const {
|
|||||||
_printer << "t=" << _t << "\r\n";
|
_printer << "t=" << _t << "\r\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
_printer << "s=RTSP Session, streamed by the ZLMediaKit\r\n";
|
_printer << "s=Streamed by " << SERVER_NAME << "\r\n";
|
||||||
_printer << "i=ZLMediaKit Live Stream\r\n";
|
|
||||||
getAttrSdp(_attr,_printer);
|
getAttrSdp(_attr,_printer);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -258,17 +258,17 @@ public:
|
|||||||
_printer << pr.first << "=" << pr.second << "\r\n";
|
_printer << pr.first << "=" << pr.second << "\r\n";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_printer << "o=- 1383190487994921 1 IN IP4 0.0.0.0\r\n";
|
_printer << "o=- 0 0 IN IP4 0.0.0.0\r\n";
|
||||||
_printer << "s=RTSP Session, streamed by the ZLMediaKit\r\n";
|
_printer << "s=Streamed by " << SERVER_NAME << "\r\n";
|
||||||
_printer << "i=ZLMediaKit Live Stream\r\n";
|
|
||||||
_printer << "c=IN IP4 0.0.0.0\r\n";
|
_printer << "c=IN IP4 0.0.0.0\r\n";
|
||||||
_printer << "t=0 0\r\n";
|
_printer << "t=0 0\r\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(dur_sec <= 0){
|
if(dur_sec <= 0){
|
||||||
|
//直播
|
||||||
_printer << "a=range:npt=now-\r\n";
|
_printer << "a=range:npt=now-\r\n";
|
||||||
}else{
|
}else{
|
||||||
//点播情况下,vlc不支持支持npt=now-xxx, 但是貌似echo show只支持npt=now-xxx ?
|
//点播
|
||||||
_printer << "a=range:npt=0-" << dur_sec << "\r\n";
|
_printer << "a=range:npt=0-" << dur_sec << "\r\n";
|
||||||
}
|
}
|
||||||
_printer << "a=control:*\r\n";
|
_printer << "a=control:*\r\n";
|
||||||
|
@ -133,7 +133,7 @@ public:
|
|||||||
case 1:
|
case 1:
|
||||||
return tracks[0]->_time_stamp;
|
return tracks[0]->_time_stamp;
|
||||||
default:
|
default:
|
||||||
return MAX(tracks[0]->_time_stamp, tracks[1]->_time_stamp);
|
return MIN(tracks[0]->_time_stamp, tracks[1]->_time_stamp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -668,7 +668,7 @@ void RtspPlayer::sendRtspRequest(const string &cmd, const string &url, const std
|
|||||||
void RtspPlayer::sendRtspRequest(const string &cmd, const string &url,const StrCaseMap &header_const) {
|
void RtspPlayer::sendRtspRequest(const string &cmd, const string &url,const StrCaseMap &header_const) {
|
||||||
auto header = header_const;
|
auto header = header_const;
|
||||||
header.emplace("CSeq",StrPrinter << _uiCseq++);
|
header.emplace("CSeq",StrPrinter << _uiCseq++);
|
||||||
header.emplace("User-Agent",SERVER_NAME "(build in " __DATE__ " " __TIME__ ")");
|
header.emplace("User-Agent",SERVER_NAME);
|
||||||
|
|
||||||
if(!_strSession.empty()){
|
if(!_strSession.empty()){
|
||||||
header.emplace("Session",_strSession);
|
header.emplace("Session",_strSession);
|
||||||
|
@ -398,7 +398,7 @@ void RtspPusher::sendRtspRequest(const string &cmd, const string &url, const std
|
|||||||
void RtspPusher::sendRtspRequest(const string &cmd, const string &url,const StrCaseMap &header_const,const string &sdp ) {
|
void RtspPusher::sendRtspRequest(const string &cmd, const string &url,const StrCaseMap &header_const,const string &sdp ) {
|
||||||
auto header = header_const;
|
auto header = header_const;
|
||||||
header.emplace("CSeq",StrPrinter << _uiCseq++);
|
header.emplace("CSeq",StrPrinter << _uiCseq++);
|
||||||
header.emplace("User-Agent",SERVER_NAME "(build in " __DATE__ " " __TIME__ ")");
|
header.emplace("User-Agent",SERVER_NAME);
|
||||||
|
|
||||||
if(!_strSession.empty()){
|
if(!_strSession.empty()){
|
||||||
header.emplace("Session",_strSession);
|
header.emplace("Session",_strSession);
|
||||||
|
@ -795,7 +795,7 @@ void RtspSession::handleReq_Play(const Parser &parser) {
|
|||||||
rtp_info.pop_back();
|
rtp_info.pop_back();
|
||||||
|
|
||||||
sendRtspResponse("200 OK",
|
sendRtspResponse("200 OK",
|
||||||
{"Range", StrPrinter << "npt=" << setiosflags(ios::fixed) << setprecision(2) << pMediaSrc->getTimeStamp(TrackInvalid) / 1000.0,
|
{"Range", StrPrinter << "npt=" << setiosflags(ios::fixed) << setprecision(2) << pMediaSrc->getTimeStamp(TrackInvalid) / 1000.0 << "-",
|
||||||
"RTP-Info",rtp_info
|
"RTP-Info",rtp_info
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1033,7 +1033,7 @@ bool RtspSession::sendRtspResponse(const string &res_code,
|
|||||||
header.emplace("Session",_strSession);
|
header.emplace("Session",_strSession);
|
||||||
}
|
}
|
||||||
|
|
||||||
header.emplace("Server",SERVER_NAME "(build in " __DATE__ " " __TIME__ ")");
|
header.emplace("Server",SERVER_NAME);
|
||||||
header.emplace("Date",dateStr());
|
header.emplace("Date",dateStr());
|
||||||
|
|
||||||
if(!sdp.empty()){
|
if(!sdp.empty()){
|
||||||
|
@ -236,8 +236,6 @@ private:
|
|||||||
RtcpCounter _aRtcpCnt[2];
|
RtcpCounter _aRtcpCnt[2];
|
||||||
//rtcp发送时间,trackid idx 为数组下标
|
//rtcp发送时间,trackid idx 为数组下标
|
||||||
Ticker _aRtcpTicker[2];
|
Ticker _aRtcpTicker[2];
|
||||||
//时间戳修整器
|
|
||||||
Stamp _stamp[2];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user