feat: 增加拉流代理rtsp时提供倍速功能支持 (#3669)

Co-authored-by: lidaofu <lidf@ahtelit.com>
This commit is contained in:
Lidaofu 2024-06-28 12:43:41 +08:00 committed by xia-chu
parent 2f2e8c2e43
commit 5a717186dd
5 changed files with 16 additions and 2 deletions

View File

@ -79,7 +79,7 @@ API_EXPORT void API_CALL mk_proxy_player_release(mk_proxy_player ctx);
/**
*
* @param ctx
* @param key , net_adapter/rtp_type/rtsp_user/rtsp_pwd/protocol_timeout_ms/media_timeout_ms/beat_interval_ms
* @param key , net_adapter/rtp_type/rtsp_user/rtsp_pwd/protocol_timeout_ms/media_timeout_ms/beat_interval_ms/rtsp_speed
* @param val ,string
*/
API_EXPORT void API_CALL mk_proxy_player_set_option(mk_proxy_player ctx, const char *key, const char *val);

View File

@ -375,6 +375,7 @@ const string kBenchmarkMode = "benchmark_mode";
const string kWaitTrackReady = "wait_track_ready";
const string kPlayTrack = "play_track";
const string kProxyUrl = "proxy_url";
const string kRtspSpeed = "rtsp_speed";
} // namespace Client
} // namespace mediakit

View File

@ -447,6 +447,8 @@ extern const std::string kWaitTrackReady;
extern const std::string kPlayTrack;
//设置代理url目前只支持http协议
extern const std::string kProxyUrl;
//设置开始rtsp倍速播放
extern const std::string kRtspSpeed;
} // namespace Client
} // namespace mediakit

View File

@ -88,6 +88,7 @@ void RtspPlayer::play(const string &strUrl) {
_rtp_type = (Rtsp::eRtpType)(int)(*this)[Client::kRtpType];
_beat_type = (*this)[Client::kRtspBeatType].as<int>();
_beat_interval_ms = (*this)[Client::kBeatIntervalMS].as<int>();
_speed = (*this)[Client::kRtspSpeed].as<float>();
DebugL << url._url << " " << (url._user.size() ? url._user : "null") << " " << (url._passwd.size() ? url._passwd : "null") << " " << _rtp_type;
weak_ptr<RtspPlayer> weakSelf = static_pointer_cast<RtspPlayer>(shared_from_this());
@ -387,7 +388,12 @@ void RtspPlayer::handleResSETUP(const Parser &parser, unsigned int track_idx) {
}
// 所有setup命令发送完毕
// 发送play命令
sendPause(type_play, 0);
if (_speed==0.0f) {
sendPause(type_play, 0);
} else {
sendPause(type_speed, 0);
}
}
void RtspPlayer::sendDescribe() {
@ -436,6 +442,9 @@ void RtspPlayer::sendPause(int type, uint32_t seekMS) {
case type_seek:
sendRtspRequest("PLAY", _control_url, { "Range", StrPrinter << "npt=" << setiosflags(ios::fixed) << setprecision(2) << seekMS / 1000.0 << "-" });
break;
case type_speed:
speed(_speed);
break;
default:
WarnL << "unknown type : " << type;
_on_response = nullptr;

View File

@ -120,6 +120,8 @@ private:
uint32_t _beat_interval_ms = 0;
std::string _play_url;
// rtsp开始倍速
float _speed= 0.0f;
std::vector<SdpTrack::Ptr> _sdp_track;
std::function<void(const Parser&)> _on_response;
//RTP端口,trackid idx 为数组下标