mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-25 12:11:36 +08:00
合并主线分支 (#2794)
This commit is contained in:
commit
62e9b56403
@ -1 +1 @@
|
|||||||
Subproject commit d2016522a0e4b1d8df51a78b7415fe148f7245ca
|
Subproject commit a4b8b5e00aac6251254a513c7759605c0ba35f90
|
@ -537,7 +537,7 @@ void addStreamProxy(const string &vhost, const string &app, const string &stream
|
|||||||
lock_guard<recursive_mutex> lck(s_proxyMapMtx);
|
lock_guard<recursive_mutex> lck(s_proxyMapMtx);
|
||||||
if (s_proxyMap.find(key) != s_proxyMap.end()) {
|
if (s_proxyMap.find(key) != s_proxyMap.end()) {
|
||||||
//已经在拉流了
|
//已经在拉流了
|
||||||
cb(SockException(Err_success), key);
|
cb(SockException(Err_other, "This stream already exists"), key);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//添加拉流代理
|
//添加拉流代理
|
||||||
|
@ -524,7 +524,7 @@ static void accessFile(Session &sender, const Parser &parser, const MediaInfo &m
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static string getFilePath(const Parser &parser,const MediaInfo &media_info, Session &sender){
|
static string getFilePath(const Parser &parser,const MediaInfo &media_info, Session &sender) {
|
||||||
GET_CONFIG(bool, enableVhost, General::kEnableVhost);
|
GET_CONFIG(bool, enableVhost, General::kEnableVhost);
|
||||||
GET_CONFIG(string, rootPath, Http::kRootPath);
|
GET_CONFIG(string, rootPath, Http::kRootPath);
|
||||||
GET_CONFIG_FUNC(StrCaseMap, virtualPathMap, Http::kVirtualPath, [](const string &str) {
|
GET_CONFIG_FUNC(StrCaseMap, virtualPathMap, Http::kVirtualPath, [](const string &str) {
|
||||||
@ -549,6 +549,13 @@ static string getFilePath(const Parser &parser,const MediaInfo &media_info, Sess
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto ret = File::absolutePath(enableVhost ? media_info.vhost + url : url, path);
|
auto ret = File::absolutePath(enableVhost ? media_info.vhost + url : url, path);
|
||||||
|
auto http_root = File::absolutePath(enableVhost ? media_info.vhost + "/" : "/", path);
|
||||||
|
if (!start_with(ret, http_root)) {
|
||||||
|
// 访问的http文件不得在http根目录之外
|
||||||
|
throw std::runtime_error("Attempting to access files outside of the http root directory");
|
||||||
|
}
|
||||||
|
// 替换url,防止返回的目录索引网页被注入非法内容
|
||||||
|
const_cast<Parser&>(parser).setUrl("/" + ret.substr(http_root.size()));
|
||||||
NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastHttpBeforeAccess, parser, ret, static_cast<SockInfo &>(sender));
|
NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastHttpBeforeAccess, parser, ret, static_cast<SockInfo &>(sender));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -184,8 +184,10 @@ bool MP4Reader::speed(MediaSource &sender, float speed) {
|
|||||||
WarnL << "播放速度取值范围非法:" << speed;
|
WarnL << "播放速度取值范围非法:" << speed;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//设置播放速度后应该恢复播放
|
//_seek_ticker重置,赋值_seek_to
|
||||||
pause(sender, false);
|
setCurrentStamp(getCurrentStamp());
|
||||||
|
// 设置播放速度后应该恢复播放
|
||||||
|
_paused = false;
|
||||||
if (_speed == speed) {
|
if (_speed == speed) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -8,12 +8,13 @@
|
|||||||
* may be found in the AUTHORS file in the root of the source tree.
|
* may be found in the AUTHORS file in the root of the source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <cinttypes>
|
||||||
|
#include <random>
|
||||||
#include "Rtsp.h"
|
#include "Rtsp.h"
|
||||||
#include "Common/Parser.h"
|
#include "Common/Parser.h"
|
||||||
#include "Common/config.h"
|
#include "Common/config.h"
|
||||||
#include "Network/Socket.h"
|
#include "Network/Socket.h"
|
||||||
#include <cinttypes>
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace toolkit;
|
using namespace toolkit;
|
||||||
@ -392,9 +393,13 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void setRange(uint16_t start_pos, uint16_t end_pos) {
|
void setRange(uint16_t start_pos, uint16_t end_pos) {
|
||||||
|
std::mt19937 rng(std::random_device {}());
|
||||||
lock_guard<recursive_mutex> lck(_pool_mtx);
|
lock_guard<recursive_mutex> lck(_pool_mtx);
|
||||||
|
auto it = _port_pair_pool.begin();
|
||||||
while (start_pos < end_pos) {
|
while (start_pos < end_pos) {
|
||||||
_port_pair_pool.emplace_back(start_pos++);
|
// 随机端口排序,防止重启后导致分配的端口重复
|
||||||
|
_port_pair_pool.insert(it, start_pos++);
|
||||||
|
it = _port_pair_pool.begin() + (rng() % (1 + _port_pair_pool.size()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -483,6 +483,11 @@ void RtspPlayer::handleResPAUSE(const Parser &parser, int type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RtspPlayer::onWholeRtspPacket(Parser &parser) {
|
void RtspPlayer::onWholeRtspPacket(Parser &parser) {
|
||||||
|
if (!start_with(parser.method(), "RTSP")) {
|
||||||
|
// 不是rtsp回复,忽略
|
||||||
|
WarnL << "Not rtsp response: " << parser.method();
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
decltype(_on_response) func;
|
decltype(_on_response) func;
|
||||||
_on_response.swap(func);
|
_on_response.swap(func);
|
||||||
|
@ -82,10 +82,12 @@ void UDPServer::onRecv(int interleaved, const Buffer::Ptr &buf, struct sockaddr*
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto &ref = it0->second;
|
auto &ref = it0->second;
|
||||||
for (auto it1 = ref.begin(); it1 != ref.end(); ++it1) {
|
for (auto it1 = ref.begin(); it1 != ref.end();) {
|
||||||
auto &func = it1->second;
|
auto &func = it1->second;
|
||||||
if (!func(interleaved, buf, peer_addr)) {
|
if (!func(interleaved, buf, peer_addr)) {
|
||||||
it1 = ref.erase(it1);
|
it1 = ref.erase(it1);
|
||||||
|
} else {
|
||||||
|
++it1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ref.size() == 0) {
|
if (ref.size() == 0) {
|
||||||
|
@ -322,7 +322,7 @@
|
|||||||
json.then((json)=> fillStreamList(json));
|
json.then((json)=> fillStreamList(json));
|
||||||
}
|
}
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
get_media_list();
|
// get_media_list();
|
||||||
}, 5000);
|
}, 5000);
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user