mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-25 20:27:34 +08:00
Refine: 优化rtsp相关代码
This commit is contained in:
parent
5b6ff0af27
commit
d52fc4c31f
@ -236,7 +236,8 @@ public:
|
||||
* @param len rtp数据指针长度
|
||||
* @return 解析成功返回true
|
||||
*/
|
||||
bool handleOneRtp(int index, TrackType type, int sample_rate, uint8_t *ptr, size_t len){
|
||||
bool handleOneRtp(int index, TrackType type, int sample_rate, uint8_t *ptr, size_t len) {
|
||||
assert(index < kCount && index >= 0);
|
||||
return _track[index].inputRtp(type, sample_rate, ptr, len).operator bool();
|
||||
}
|
||||
|
||||
@ -247,7 +248,8 @@ public:
|
||||
* @param rtp_stamp rtp时间戳
|
||||
* @param ntp_stamp_ms ntp时间戳
|
||||
*/
|
||||
void setNtpStamp(int index, uint32_t rtp_stamp, uint64_t ntp_stamp_ms){
|
||||
void setNtpStamp(int index, uint32_t rtp_stamp, uint64_t ntp_stamp_ms) {
|
||||
assert(index < kCount && index >= 0);
|
||||
_track[index].setNtpStamp(rtp_stamp, ntp_stamp_ms);
|
||||
}
|
||||
|
||||
@ -258,14 +260,17 @@ public:
|
||||
}
|
||||
|
||||
size_t getJitterSize(int index) const {
|
||||
assert(index < kCount && index >= 0);
|
||||
return _track[index].getJitterSize();
|
||||
}
|
||||
|
||||
size_t getCycleCount(int index) const {
|
||||
assert(index < kCount && index >= 0);
|
||||
return _track[index].getCycleCount();
|
||||
}
|
||||
|
||||
uint32_t getSSRC(int index) const {
|
||||
assert(index < kCount && index >= 0);
|
||||
return _track[index].getSSRC();
|
||||
}
|
||||
|
||||
|
@ -693,7 +693,7 @@ void RtspPlayer::onPlayResult_l(const SockException &ex , bool handshake_done) {
|
||||
}
|
||||
|
||||
int RtspPlayer::getTrackIndexByInterleaved(int interleaved) const {
|
||||
for (unsigned int i = 0; i < _sdp_track.size(); i++) {
|
||||
for (size_t i = 0; i < _sdp_track.size(); ++i) {
|
||||
if (_sdp_track[i]->_interleaved == interleaved) {
|
||||
return i;
|
||||
}
|
||||
@ -705,7 +705,7 @@ int RtspPlayer::getTrackIndexByInterleaved(int interleaved) const {
|
||||
}
|
||||
|
||||
int RtspPlayer::getTrackIndexByTrackType(TrackType track_type) const {
|
||||
for (unsigned int i = 0; i < _sdp_track.size(); i++) {
|
||||
for (size_t i = 0; i < _sdp_track.size(); ++i) {
|
||||
if (_sdp_track[i]->_type == track_type) {
|
||||
return i;
|
||||
}
|
||||
@ -713,7 +713,7 @@ int RtspPlayer::getTrackIndexByTrackType(TrackType track_type) const {
|
||||
if (_sdp_track.size() == 1) {
|
||||
return 0;
|
||||
}
|
||||
throw SockException(Err_shutdown, StrPrinter << "no such track with type:" << (int) track_type);
|
||||
throw SockException(Err_shutdown, StrPrinter << "no such track with type:" << getTrackString(track_type));
|
||||
}
|
||||
|
||||
} /* namespace mediakit */
|
||||
|
@ -419,7 +419,7 @@ void RtspPusher::sendRtpPacket(const RtspMediaSource::RingDataType &pkt) {
|
||||
}
|
||||
|
||||
int RtspPusher::getTrackIndexByInterleaved(int interleaved) const {
|
||||
for (int i = 0; i < (int)_track_vec.size(); ++i) {
|
||||
for (size_t i = 0; i < _track_vec.size(); ++i) {
|
||||
if (_track_vec[i]->_interleaved == interleaved) {
|
||||
return i;
|
||||
}
|
||||
@ -430,8 +430,8 @@ int RtspPusher::getTrackIndexByInterleaved(int interleaved) const {
|
||||
throw SockException(Err_shutdown, StrPrinter << "no such track with interleaved:" << interleaved);
|
||||
}
|
||||
|
||||
int RtspPusher::getTrackIndexByTrackType(TrackType type) const{
|
||||
for (int i = 0; i < (int)_track_vec.size(); ++i) {
|
||||
int RtspPusher::getTrackIndexByTrackType(TrackType type) const {
|
||||
for (size_t i = 0; i < _track_vec.size(); ++i) {
|
||||
if (type == _track_vec[i]->_type) {
|
||||
return i;
|
||||
}
|
||||
@ -439,7 +439,7 @@ int RtspPusher::getTrackIndexByTrackType(TrackType type) const{
|
||||
if (_track_vec.size() == 1) {
|
||||
return 0;
|
||||
}
|
||||
throw SockException(Err_shutdown, StrPrinter << "no such track with type:" << (int) type);
|
||||
throw SockException(Err_shutdown, StrPrinter << "no such track with type:" << getTrackString(type));
|
||||
}
|
||||
|
||||
void RtspPusher::sendRecord() {
|
||||
|
@ -1098,36 +1098,36 @@ bool RtspSession::sendRtspResponse(const string &res_code, const std::initialize
|
||||
}
|
||||
|
||||
int RtspSession::getTrackIndexByTrackType(TrackType type) {
|
||||
for (unsigned int i = 0; i < _sdp_track.size(); i++) {
|
||||
for (size_t i = 0; i < _sdp_track.size(); ++i) {
|
||||
if (type == _sdp_track[i]->_type) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
if(_sdp_track.size() == 1){
|
||||
if (_sdp_track.size() == 1) {
|
||||
return 0;
|
||||
}
|
||||
throw SockException(Err_shutdown, StrPrinter << "no such track with type:" << (int) type);
|
||||
throw SockException(Err_shutdown, StrPrinter << "no such track with type:" << getTrackString(type));
|
||||
}
|
||||
|
||||
int RtspSession::getTrackIndexByControlUrl(const string &control_url) {
|
||||
for (unsigned int i = 0; i < _sdp_track.size(); i++) {
|
||||
for (size_t i = 0; i < _sdp_track.size(); ++i) {
|
||||
if (control_url == _sdp_track[i]->getControlUrl(_content_base)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
if(_sdp_track.size() == 1){
|
||||
if (_sdp_track.size() == 1) {
|
||||
return 0;
|
||||
}
|
||||
throw SockException(Err_shutdown, StrPrinter << "no such track with control url:" << control_url);
|
||||
}
|
||||
|
||||
int RtspSession::getTrackIndexByInterleaved(int interleaved){
|
||||
for (unsigned int i = 0; i < _sdp_track.size(); i++) {
|
||||
int RtspSession::getTrackIndexByInterleaved(int interleaved) {
|
||||
for (size_t i = 0; i < _sdp_track.size(); ++i) {
|
||||
if (_sdp_track[i]->_interleaved == interleaved) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
if(_sdp_track.size() == 1){
|
||||
if (_sdp_track.size() == 1) {
|
||||
return 0;
|
||||
}
|
||||
throw SockException(Err_shutdown, StrPrinter << "no such track with interleaved:" << interleaved);
|
||||
|
Loading…
Reference in New Issue
Block a user