Compare commits

...

4 Commits

Author SHA1 Message Date
xia-chu
5c58f39046 优化getMediaList接口,新增返回currentStamp字段,获取单个流时确保返回loss字段 (#4260)
Some checks are pending
Android / build (push) Waiting to run
CodeQL / Analyze (cpp) (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
Docker / build (push) Waiting to run
Linux / build (push) Waiting to run
macOS / build (push) Waiting to run
Windows / build (push) Waiting to run
2025-10-18 13:00:54 +08:00
xia-chu
f7c2803691 修复getSequence拼写错误 2025-10-18 12:45:11 +08:00
xia-chu
6d01aa6389 loadMP4File接口新增支持seek_ms与speed参数 (#4261) 2025-10-18 12:36:46 +08:00
xtxxtx
676000e355
修复ENABLE_WEBRTC、ENABLE_OPENSSL关闭时编译报错问题 (#4501)
修复:当ENABLE_WEBRTC=OFF且ENABLE_OPENSSL=OFF时,编译报错:找不到ssl.h
2025-10-18 12:11:37 +08:00
5 changed files with 52 additions and 11 deletions

View File

@ -25,16 +25,19 @@
#include "Http/HttpSession.h"
#include "Shell/ShellSession.h"
#include "Player/PlayerProxy.h"
#include "webrtc/WebRtcProxyPlayer.h"
#include "webrtc/WebRtcProxyPlayerImp.h"
#include "../webrtc/WebRtcSignalingPeer.h"
#include "../webrtc/WebRtcSignalingSession.h"
using namespace std;
using namespace toolkit;
using namespace mediakit;
#ifdef ENABLE_WEBRTC
#include "../webrtc/WebRtcSession.h"
#include "webrtc/WebRtcProxyPlayer.h"
#include "webrtc/WebRtcProxyPlayerImp.h"
#include "webrtc/WebRtcSignalingPeer.h"
#include "webrtc/WebRtcSignalingSession.h"
#include "webrtc/WebRtcSession.h"
static UdpServer::Ptr rtcServer_udp;
static TcpServer::Ptr rtcServer_tcp;
class WebRtcArgsUrl : public mediakit::WebRtcArgs {
@ -184,4 +187,4 @@ API_EXPORT void API_CALL mk_webrtc_list_rooms(on_mk_webrtc_room_keeper_data_cb c
#else
WarnL << "未启用webrtc功能, 编译时请开启ENABLE_WEBRTC";
#endif
}
}

View File

@ -2612,6 +2612,18 @@
"description": "是否循环点播mp4文件如果配置文件已经开启循环点播此参数无效",
"disabled": true
},
{
"key": "seek_ms",
"value": "0",
"description": "点播seek到特定位置单位毫秒",
"disabled": true
},
{
"key": "speed",
"value": "1.0",
"description": "播放速度, float类型",
"disabled": true
},
{
"key": "enable_hls",
"value": "",

View File

@ -391,6 +391,7 @@ Value makeMediaSourceJson(MediaSource &media){
item["schema"] = media.getSchema();
dumpMediaTuple(media.getMediaTuple(), item);
item["createStamp"] = (Json::UInt64) media.getCreateStamp();
item["currentStamp"] = (Json::UInt64) media.getTimeStamp(TrackInvalid);
item["aliveSecond"] = (Json::UInt64) media.getAliveSecond();
item["bytesSpeed"] = (Json::UInt64) media.getBytesSpeed();
item["totalBytes"] = (Json::UInt64) media.getTotalBytes();
@ -908,12 +909,24 @@ void installWebApi() {
// Test url1 (get streams with virtual host "__defaultVost__") http://127.0.0.1/index/api/getMediaList?vhost=__defaultVost__
// 测试url2(获取rtsp类型的流) http://127.0.0.1/index/api/getMediaList?schema=rtsp [AUTO-TRANSLATED:21c2c15d]
// Test url2 (get rtsp type streams) http://127.0.0.1/index/api/getMediaList?schema=rtsp
api_regist("/index/api/getMediaList",[](API_ARGS_MAP){
api_regist("/index/api/getMediaList",[](API_ARGS_MAP_ASYNC){
CHECK_SECRET();
// 获取所有MediaSource列表 [AUTO-TRANSLATED:7bf16dc2]
// Get all MediaSource lists
bool first = true;
std::shared_ptr<Json::Value> done(new Json::Value(val), [invoker, headerOut](Json::Value *val) {
invoker(200, headerOut, val->toStyledString());
delete val;
});
MediaSource::for_each_media([&](const MediaSource::Ptr &media) {
val["data"].append(makeMediaSourceJson(*media));
if (first) {
first = false;
media->getOwnerPoller()->async([media, done]() mutable {
(*done)["data"].append(makeMediaSourceJson(*media));
});
} else {
(*done)["data"].append(makeMediaSourceJson(*media));
}
}, allArgs["schema"], allArgs["vhost"], allArgs["app"], allArgs["stream"]);
});
@ -2251,6 +2264,19 @@ void installWebApi() {
// sample_ms设置为0从配置文件加载file_repeat可以指定如果配置文件也指定循环解复用那么强制开启 [AUTO-TRANSLATED:23e826b4]
// sample_ms is set to 0, loaded from the configuration file; file_repeat can be specified, if the configuration file also specifies loop demultiplexing, then force it to be enabled
reader->startReadMP4(0, true, allArgs["file_repeat"]);
auto seek_ms = allArgs["seek_ms"].as<uint32_t>();
auto speed = allArgs["speed"].as<float>();
if (seek_ms || speed) {
auto p = static_pointer_cast<MediaSourceEvent>(reader);
p->getOwnerPoller(MediaSource::NullMediaSource())->async([seek_ms, speed, p]() {
if (seek_ms) {
p->seekTo(MediaSource::NullMediaSource(), seek_ms);
}
if (speed && speed != 1.0) {
p->speed(MediaSource::NullMediaSource(), speed);
}
});
}
val["data"]["duration_ms"] = (Json::UInt64)reader->getDemuxer()->getDurationMS();
});
#endif

View File

@ -132,7 +132,7 @@ public:
* [AUTO-TRANSLATED:24b0ee74]
*/
virtual uint16_t getSeqence(TrackType trackType) {
virtual uint16_t getSequence(TrackType trackType) {
assert(trackType >= 0 && trackType < TrackMax);
auto &track = _tracks[trackType];
if (!track) {

View File

@ -437,7 +437,7 @@ void RtspSession::onAuthSuccess() {
strong_self->_play_src = rtsp_src;
for(auto &track : strong_self->_sdp_track){
track->_ssrc = rtsp_src->getSsrc(track->_type);
track->_seq = rtsp_src->getSeqence(track->_type);
track->_seq = rtsp_src->getSequence(track->_type);
track->_time_stamp = rtsp_src->getTimeStamp(track->_type);
}
@ -832,7 +832,7 @@ void RtspSession::handleReq_Play(const Parser &parser) {
}
inited_tracks.emplace_back(track->_type);
track->_ssrc = play_src->getSsrc(track->_type);
track->_seq = play_src->getSeqence(track->_type);
track->_seq = play_src->getSequence(track->_type);
track->_time_stamp = play_src->getTimeStamp(track->_type);
rtp_info << "url=" << track->getControlUrl(_content_base) << ";"