复用printSSRC函数

This commit is contained in:
xiongziliang 2020-07-07 09:58:08 +08:00
parent 80d9f8ccaa
commit 30260e5414
4 changed files with 11 additions and 11 deletions

View File

@ -404,4 +404,14 @@ std::pair<Socket::Ptr, Socket::Ptr> makeSockPair(const EventPoller::Ptr &poller,
} }
} }
string printSSRC(uint32_t ui32Ssrc) {
char tmp[9] = { 0 };
ui32Ssrc = htonl(ui32Ssrc);
uint8_t *pSsrc = (uint8_t *) &ui32Ssrc;
for (int i = 0; i < 4; i++) {
sprintf(tmp + 2 * i, "%02X", pSsrc[i]);
}
return tmp;
}
}//namespace mediakit }//namespace mediakit

View File

@ -272,6 +272,7 @@ private:
}; };
std::pair<Socket::Ptr, Socket::Ptr> makeSockPair(const EventPoller::Ptr &poller, const string &local_ip); std::pair<Socket::Ptr, Socket::Ptr> makeSockPair(const EventPoller::Ptr &poller, const string &local_ip);
string printSSRC(uint32_t ui32Ssrc);
} //namespace mediakit } //namespace mediakit
#endif //RTSP_RTSP_H_ #endif //RTSP_RTSP_H_

View File

@ -1068,15 +1068,6 @@ bool RtspSession::sendRtspResponse(const string &res_code,
return sendRtspResponse(res_code,header_map,sdp,protocol); return sendRtspResponse(res_code,header_map,sdp,protocol);
} }
inline string RtspSession::printSSRC(uint32_t ui32Ssrc) {
char tmp[9] = { 0 };
ui32Ssrc = htonl(ui32Ssrc);
uint8_t *pSsrc = (uint8_t *) &ui32Ssrc;
for (int i = 0; i < 4; i++) {
sprintf(tmp + 2 * i, "%02X", pSsrc[i]);
}
return tmp;
}
inline int RtspSession::getTrackIndexByTrackType(TrackType type) { inline int RtspSession::getTrackIndexByTrackType(TrackType type) {
for (unsigned int i = 0; i < _aTrackInfo.size(); i++) { for (unsigned int i = 0; i < _aTrackInfo.size(); i++) {
if (type == _aTrackInfo[i]->_type) { if (type == _aTrackInfo[i]->_type) {

View File

@ -136,8 +136,6 @@ private:
void inline send_SessionNotFound(); void inline send_SessionNotFound();
//一般rtsp服务器打开端口失败时触发 //一般rtsp服务器打开端口失败时触发
void inline send_NotAcceptable(); void inline send_NotAcceptable();
//ssrc转字符串
inline string printSSRC(uint32_t ui32Ssrc);
//获取track下标 //获取track下标
inline int getTrackIndexByTrackType(TrackType type); inline int getTrackIndexByTrackType(TrackType type);