mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-07-06 19:58:10 +08:00
合并主线分支 (#2793)
This commit is contained in:
@@ -8,12 +8,13 @@
|
||||
* may be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cinttypes>
|
||||
#include <random>
|
||||
#include "Rtsp.h"
|
||||
#include "Common/Parser.h"
|
||||
#include "Common/config.h"
|
||||
#include "Network/Socket.h"
|
||||
#include <cinttypes>
|
||||
#include <cstdlib>
|
||||
|
||||
using namespace std;
|
||||
using namespace toolkit;
|
||||
@@ -392,9 +393,13 @@ public:
|
||||
|
||||
private:
|
||||
void setRange(uint16_t start_pos, uint16_t end_pos) {
|
||||
std::mt19937 rng(std::random_device {}());
|
||||
lock_guard<recursive_mutex> lck(_pool_mtx);
|
||||
auto it = _port_pair_pool.begin();
|
||||
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) {
|
||||
if (!start_with(parser.method(), "RTSP")) {
|
||||
// 不是rtsp回复,忽略
|
||||
WarnL << "Not rtsp response: " << parser.method();
|
||||
return;
|
||||
}
|
||||
try {
|
||||
decltype(_on_response) func;
|
||||
_on_response.swap(func);
|
||||
|
||||
@@ -82,10 +82,12 @@ void UDPServer::onRecv(int interleaved, const Buffer::Ptr &buf, struct sockaddr*
|
||||
return;
|
||||
}
|
||||
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;
|
||||
if (!func(interleaved, buf, peer_addr)) {
|
||||
it1 = ref.erase(it1);
|
||||
} else {
|
||||
++it1;
|
||||
}
|
||||
}
|
||||
if (ref.size() == 0) {
|
||||
|
||||
Reference in New Issue
Block a user