Commit 00c21cd9 by xiongziliang

优化代码

parent eda7a59f
...@@ -520,7 +520,6 @@ bool HttpSession::emitHttpEvent(bool doInvoke){ ...@@ -520,7 +520,6 @@ bool HttpSession::emitHttpEvent(bool doInvoke){
}; };
///////////////////广播HTTP事件/////////////////////////// ///////////////////广播HTTP事件///////////////////////////
bool consumed = false;//该事件是否被消费 bool consumed = false;//该事件是否被消费
TcpSession &session = static_cast<TcpSession &>(*this);
NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastHttpRequest,_parser,invoker,consumed,static_cast<SockInfo &>(*this)); NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastHttpRequest,_parser,invoker,consumed,static_cast<SockInfo &>(*this));
if(!consumed && doInvoke){ if(!consumed && doInvoke){
//该事件无人消费,所以返回404 //该事件无人消费,所以返回404
......
...@@ -119,10 +119,12 @@ void RtspPlayer::onRecv(const Buffer::Ptr& pBuf) { ...@@ -119,10 +119,12 @@ void RtspPlayer::onRecv(const Buffer::Ptr& pBuf) {
} }
input(pBuf->data(),pBuf->size()); input(pBuf->data(),pBuf->size());
} }
void RtspPlayer::onErr(const SockException &ex) { void RtspPlayer::onErr(const SockException &ex) {
//定时器_pPlayTimer为空后表明握手结束了 //定时器_pPlayTimer为空后表明握手结束了
onPlayResult_l(ex,!_pPlayTimer); onPlayResult_l(ex,!_pPlayTimer);
} }
// from live555 // from live555
bool RtspPlayer::handleAuthenticationFailure(const string &paramsStr) { bool RtspPlayer::handleAuthenticationFailure(const string &paramsStr) {
if(!_rtspRealm.empty()){ if(!_rtspRealm.empty()){
...@@ -155,6 +157,7 @@ bool RtspPlayer::handleAuthenticationFailure(const string &paramsStr) { ...@@ -155,6 +157,7 @@ bool RtspPlayer::handleAuthenticationFailure(const string &paramsStr) {
} }
return false; return false;
} }
void RtspPlayer::handleResDESCRIBE(const Parser& parser) { void RtspPlayer::handleResDESCRIBE(const Parser& parser) {
string authInfo = parser["WWW-Authenticate"]; string authInfo = parser["WWW-Authenticate"];
//发送DESCRIBE命令后的回复 //发送DESCRIBE命令后的回复
...@@ -237,7 +240,6 @@ void RtspPlayer::createUdpSockIfNecessary(int track_idx){ ...@@ -237,7 +240,6 @@ void RtspPlayer::createUdpSockIfNecessary(int track_idx){
} }
} }
//发送SETUP命令 //发送SETUP命令
void RtspPlayer::sendSetup(unsigned int trackIndex) { void RtspPlayer::sendSetup(unsigned int trackIndex) {
_onHandshake = std::bind(&RtspPlayer::handleResSETUP,this, placeholders::_1,trackIndex); _onHandshake = std::bind(&RtspPlayer::handleResSETUP,this, placeholders::_1,trackIndex);
...@@ -394,6 +396,7 @@ void RtspPlayer::sendPause(int type , uint32_t seekMS){ ...@@ -394,6 +396,7 @@ void RtspPlayer::sendPause(int type , uint32_t seekMS){
break; break;
} }
} }
void RtspPlayer::pause(bool bPause) { void RtspPlayer::pause(bool bPause) {
sendPause(bPause ? type_pause : type_seek, getProgressMilliSecond()); sendPause(bPause ? type_pause : type_seek, getProgressMilliSecond());
} }
...@@ -468,10 +471,8 @@ void RtspPlayer::onRtpPacket(const char *data, uint64_t len) { ...@@ -468,10 +471,8 @@ void RtspPlayer::onRtpPacket(const char *data, uint64_t len) {
} }
} }
void RtspPlayer::onRtcpPacket(int iTrackidx, SdpTrack::Ptr &track, unsigned char *pucData, unsigned int uiLen){ //此处预留rtcp处理函数
void RtspPlayer::onRtcpPacket(int iTrackidx, SdpTrack::Ptr &track, unsigned char *pucData, unsigned int uiLen){}
}
#if 0 #if 0
//改代码提取自FFmpeg,参考之 //改代码提取自FFmpeg,参考之
...@@ -597,7 +598,6 @@ void RtspPlayer::sendReceiverReport(bool overTcp,int iTrackIndex){ ...@@ -597,7 +598,6 @@ void RtspPlayer::sendReceiverReport(bool overTcp,int iTrackIndex){
} }
} }
void RtspPlayer::onRtpSorted(const RtpPacket::Ptr &rtppt, int trackidx){ void RtspPlayer::onRtpSorted(const RtpPacket::Ptr &rtppt, int trackidx){
//统计丢包率 //统计丢包率
if (_aui16FirstSeq[trackidx] == 0 || rtppt->sequence < _aui16FirstSeq[trackidx]) { if (_aui16FirstSeq[trackidx] == 0 || rtppt->sequence < _aui16FirstSeq[trackidx]) {
...@@ -613,6 +613,7 @@ void RtspPlayer::onRtpSorted(const RtpPacket::Ptr &rtppt, int trackidx){ ...@@ -613,6 +613,7 @@ void RtspPlayer::onRtpSorted(const RtpPacket::Ptr &rtppt, int trackidx){
rtppt->timeStamp = dts_out; rtppt->timeStamp = dts_out;
onRecvRTP_l(rtppt,_aTrackInfo[trackidx]); onRecvRTP_l(rtppt,_aTrackInfo[trackidx]);
} }
float RtspPlayer::getPacketLossRate(TrackType type) const{ float RtspPlayer::getPacketLossRate(TrackType type) const{
int iTrackIdx = getTrackIndexByTrackType(type); int iTrackIdx = getTrackIndexByTrackType(type);
if(iTrackIdx == -1){ if(iTrackIdx == -1){
...@@ -637,6 +638,7 @@ float RtspPlayer::getPacketLossRate(TrackType type) const{ ...@@ -637,6 +638,7 @@ float RtspPlayer::getPacketLossRate(TrackType type) const{
uint32_t RtspPlayer::getProgressMilliSecond() const{ uint32_t RtspPlayer::getProgressMilliSecond() const{
return MAX(_stamp[0].getRelativeStamp(),_stamp[1].getRelativeStamp()); return MAX(_stamp[0].getRelativeStamp(),_stamp[1].getRelativeStamp());
} }
void RtspPlayer::seekToMilliSecond(uint32_t ms) { void RtspPlayer::seekToMilliSecond(uint32_t ms) {
sendPause(type_seek,ms); sendPause(type_seek,ms);
} }
...@@ -654,6 +656,7 @@ void RtspPlayer::sendRtspRequest(const string &cmd, const string &url, const std ...@@ -654,6 +656,7 @@ void RtspPlayer::sendRtspRequest(const string &cmd, const string &url, const std
} }
sendRtspRequest(cmd,url,header_map); sendRtspRequest(cmd,url,header_map);
} }
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++);
...@@ -725,9 +728,8 @@ void RtspPlayer::onRecvRTP_l(const RtpPacket::Ptr &pkt, const SdpTrack::Ptr &tra ...@@ -725,9 +728,8 @@ void RtspPlayer::onRecvRTP_l(const RtpPacket::Ptr &pkt, const SdpTrack::Ptr &tra
ticker.resetTime(); ticker.resetTime();
} }
} }
} }
void RtspPlayer::onPlayResult_l(const SockException &ex , bool handshakeCompleted) { void RtspPlayer::onPlayResult_l(const SockException &ex , bool handshakeCompleted) {
WarnL << ex.getErrCode() << " " << ex.what(); WarnL << ex.getErrCode() << " " << ex.what();
...@@ -795,5 +797,3 @@ int RtspPlayer::getTrackIndexByTrackType(TrackType trackType) const { ...@@ -795,5 +797,3 @@ int RtspPlayer::getTrackIndexByTrackType(TrackType trackType) const {
} }
} /* namespace mediakit */ } /* namespace mediakit */
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论