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