|
|
@@ -1,5 +1,5 @@
|
|
|
#include "muxer_stream_muxer.h"
|
|
|
-#include "../base/base_logger.h"
|
|
|
+#include "../base/logger.h"
|
|
|
#include <algorithm>
|
|
|
#include <sstream>
|
|
|
#include <regex>
|
|
|
@@ -13,45 +13,43 @@ extern "C" {
|
|
|
namespace av {
|
|
|
namespace muxer {
|
|
|
|
|
|
-using namespace av::base;
|
|
|
-
|
|
|
StreamMuxer::StreamMuxer() {
|
|
|
- Logger::info("StreamMuxer created");
|
|
|
+ Logger::instance().info("StreamMuxer created");
|
|
|
}
|
|
|
|
|
|
StreamMuxer::~StreamMuxer() {
|
|
|
close();
|
|
|
- Logger::info("StreamMuxer destroyed");
|
|
|
+ Logger::instance().info("StreamMuxer destroyed");
|
|
|
}
|
|
|
|
|
|
ErrorCode StreamMuxer::initialize(const MuxerParams& params) {
|
|
|
if (!validateParams(params)) {
|
|
|
- Logger::error("Invalid stream muxer parameters");
|
|
|
+ Logger::instance().error("Invalid stream muxer parameters");
|
|
|
return ErrorCode::INVALID_PARAMETER;
|
|
|
}
|
|
|
|
|
|
streamParams_ = static_cast<const StreamMuxerParams&>(params);
|
|
|
|
|
|
// 重置统计信息
|
|
|
- connectionStats_ = ConnectionStats{};
|
|
|
+ connectionStats_ = ConnectionStats();
|
|
|
|
|
|
// 设置初始状态
|
|
|
setConnectionState(ConnectionState::DISCONNECTED);
|
|
|
|
|
|
- Logger::info("StreamMuxer initialized with URL: {}", streamParams_.url);
|
|
|
+ Logger::instance().infof("StreamMuxer initialized with URL: {}", streamParams_.url);
|
|
|
return AbstractMuxer::initialize(params);
|
|
|
}
|
|
|
|
|
|
ErrorCode StreamMuxer::start() {
|
|
|
if (state_ != MuxerState::INITIALIZED) {
|
|
|
- Logger::error("StreamMuxer not initialized");
|
|
|
+ Logger::instance().error("StreamMuxer not initialized");
|
|
|
return ErrorCode::INVALID_STATE;
|
|
|
}
|
|
|
|
|
|
// 建立连接
|
|
|
ErrorCode result = connect();
|
|
|
if (result != ErrorCode::SUCCESS) {
|
|
|
- Logger::error("Failed to connect to stream");
|
|
|
+ Logger::instance().error("Failed to connect to stream");
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
@@ -71,7 +69,7 @@ ErrorCode StreamMuxer::start() {
|
|
|
}
|
|
|
|
|
|
ErrorCode StreamMuxer::stop() {
|
|
|
- if (state_ != MuxerState::RUNNING) {
|
|
|
+ if (state_ != MuxerState::STARTED) {
|
|
|
return ErrorCode::SUCCESS;
|
|
|
}
|
|
|
|
|
|
@@ -98,7 +96,7 @@ ErrorCode StreamMuxer::close() {
|
|
|
stop();
|
|
|
|
|
|
// 清理资源
|
|
|
- connectionStats_ = ConnectionStats{};
|
|
|
+ connectionStats_ = ConnectionStats();
|
|
|
setConnectionState(ConnectionState::DISCONNECTED);
|
|
|
|
|
|
return AbstractMuxer::close();
|
|
|
@@ -110,7 +108,7 @@ ErrorCode StreamMuxer::writePacket(AVPacket* packet) {
|
|
|
}
|
|
|
|
|
|
if (!isConnected()) {
|
|
|
- Logger::warning("Not connected, dropping packet");
|
|
|
+ Logger::instance().warning("Not connected, dropping packet");
|
|
|
return ErrorCode::INVALID_STATE;
|
|
|
}
|
|
|
|
|
|
@@ -123,7 +121,7 @@ ErrorCode StreamMuxer::writeFrame(AVFrame* frame, int streamIndex) {
|
|
|
}
|
|
|
|
|
|
if (!isConnected()) {
|
|
|
- Logger::warning("Not connected, dropping frame");
|
|
|
+ Logger::instance().warning("Not connected, dropping frame");
|
|
|
return ErrorCode::INVALID_STATE;
|
|
|
}
|
|
|
|
|
|
@@ -139,14 +137,14 @@ ErrorCode StreamMuxer::writeFrame(AVFrame* frame, int streamIndex) {
|
|
|
}
|
|
|
|
|
|
ErrorCode StreamMuxer::flush() {
|
|
|
- if (!formatContext_) {
|
|
|
+ if (!formatCtx_) {
|
|
|
return ErrorCode::INVALID_STATE;
|
|
|
}
|
|
|
|
|
|
- int ret = av_write_trailer(formatContext_);
|
|
|
+ int ret = av_write_trailer(formatCtx_);
|
|
|
if (ret < 0) {
|
|
|
- Logger::error("Failed to write trailer: {}", av_err2str(ret));
|
|
|
- return ErrorCode::WRITE_ERROR;
|
|
|
+ Logger::instance().errorf("Failed to write trailer: {}", ffmpeg_utils::errorToString(ret));
|
|
|
+ return ErrorCode::OPERATION_FAILED;
|
|
|
}
|
|
|
|
|
|
return ErrorCode::SUCCESS;
|
|
|
@@ -158,7 +156,7 @@ ErrorCode StreamMuxer::addStream(const StreamInfo& streamInfo) {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- Logger::info("Added stream: type={}, codec={}",
|
|
|
+ Logger::instance().infof("Added stream: type={}, codec={}",
|
|
|
static_cast<int>(streamInfo.type), streamInfo.codecName);
|
|
|
return ErrorCode::SUCCESS;
|
|
|
}
|
|
|
@@ -175,10 +173,10 @@ ErrorCode StreamMuxer::connect() {
|
|
|
setConnectionState(ConnectionState::CONNECTED);
|
|
|
connectionStats_.connectTime = std::chrono::steady_clock::now();
|
|
|
connectionStats_.lastDataTime = connectionStats_.connectTime;
|
|
|
- Logger::info("Connected to stream: {}", streamParams_.url);
|
|
|
+ Logger::instance().infof("Connected to stream: {}", streamParams_.url);
|
|
|
} else {
|
|
|
setConnectionState(ConnectionState::FAILED);
|
|
|
- Logger::error("Failed to connect to stream: {}", streamParams_.url);
|
|
|
+ Logger::instance().errorf("Failed to connect to stream: {}", streamParams_.url);
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
@@ -192,12 +190,12 @@ ErrorCode StreamMuxer::disconnect() {
|
|
|
ErrorCode result = closeConnection();
|
|
|
setConnectionState(ConnectionState::DISCONNECTED);
|
|
|
|
|
|
- Logger::info("Disconnected from stream");
|
|
|
+ Logger::instance().info("Disconnected from stream");
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
ErrorCode StreamMuxer::reconnect() {
|
|
|
- Logger::info("Attempting to reconnect...");
|
|
|
+ Logger::instance().info("Attempting to reconnect...");
|
|
|
|
|
|
setConnectionState(ConnectionState::RECONNECTING);
|
|
|
|
|
|
@@ -213,10 +211,10 @@ ErrorCode StreamMuxer::reconnect() {
|
|
|
setConnectionState(ConnectionState::CONNECTED);
|
|
|
connectionStats_.reconnectCount++;
|
|
|
connectionStats_.lastReconnectTime = std::chrono::steady_clock::now();
|
|
|
- Logger::info("Reconnected successfully");
|
|
|
+ Logger::instance().info("Reconnected successfully");
|
|
|
} else {
|
|
|
setConnectionState(ConnectionState::FAILED);
|
|
|
- Logger::error("Reconnection failed");
|
|
|
+ Logger::instance().error("Reconnection failed");
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
@@ -237,17 +235,17 @@ bool StreamMuxer::isConnected() const {
|
|
|
|
|
|
ErrorCode StreamMuxer::setUrl(const std::string& url) {
|
|
|
if (state_ != MuxerState::IDLE) {
|
|
|
- Logger::error("Cannot change URL while muxer is active");
|
|
|
+ Logger::instance().error("Cannot change URL while muxer is active");
|
|
|
return ErrorCode::INVALID_STATE;
|
|
|
}
|
|
|
|
|
|
if (!validateUrl(url)) {
|
|
|
- Logger::error("Invalid URL: {}", url);
|
|
|
+ Logger::instance().errorf("Invalid URL: {}", url);
|
|
|
return ErrorCode::INVALID_PARAMETER;
|
|
|
}
|
|
|
|
|
|
streamParams_.url = url;
|
|
|
- Logger::info("URL set to: {}", url);
|
|
|
+ Logger::instance().infof("URL set to: {}", url);
|
|
|
return ErrorCode::SUCCESS;
|
|
|
}
|
|
|
|
|
|
@@ -258,12 +256,12 @@ std::string StreamMuxer::getUrl() const {
|
|
|
ErrorCode StreamMuxer::enableAdaptiveBitrate(bool enable) {
|
|
|
adaptiveBitrateEnabled_ = enable;
|
|
|
|
|
|
- if (enable && state_ == MuxerState::RUNNING && !bitrateMonitorThread_.joinable()) {
|
|
|
+ if (enable && state_ == MuxerState::STARTED && !bitrateMonitorThread_.joinable()) {
|
|
|
shouldStopBitrateMonitor_ = false;
|
|
|
bitrateMonitorThread_ = std::thread(&StreamMuxer::monitorNetworkCondition, this);
|
|
|
}
|
|
|
|
|
|
- Logger::info("Adaptive bitrate {}", enable ? "enabled" : "disabled");
|
|
|
+ Logger::instance().infof("Adaptive bitrate {}", enable ? "enabled" : "disabled");
|
|
|
return ErrorCode::SUCCESS;
|
|
|
}
|
|
|
|
|
|
@@ -275,7 +273,7 @@ ErrorCode StreamMuxer::setBitrateRange(int minBitrate, int maxBitrate) {
|
|
|
streamParams_.minBitrate = minBitrate;
|
|
|
streamParams_.maxBitrate = maxBitrate;
|
|
|
|
|
|
- Logger::info("Bitrate range set: {} - {} bps", minBitrate, maxBitrate);
|
|
|
+ Logger::instance().infof("Bitrate range set: {} - {} bps", minBitrate, maxBitrate);
|
|
|
return ErrorCode::SUCCESS;
|
|
|
}
|
|
|
|
|
|
@@ -292,7 +290,7 @@ ErrorCode StreamMuxer::adjustBitrate(double factor) {
|
|
|
if (bitrateCallback_) {
|
|
|
bitrateCallback_(newBitrate);
|
|
|
}
|
|
|
- Logger::info("Bitrate adjusted to: {} bps", newBitrate);
|
|
|
+ Logger::instance().infof("Bitrate adjusted to: {} bps", newBitrate);
|
|
|
}
|
|
|
|
|
|
return ErrorCode::SUCCESS;
|
|
|
@@ -300,7 +298,7 @@ ErrorCode StreamMuxer::adjustBitrate(double factor) {
|
|
|
|
|
|
ErrorCode StreamMuxer::setProtocolOption(const std::string& key, const std::string& value) {
|
|
|
streamParams_.protocolOptions[key] = value;
|
|
|
- Logger::debug("Protocol option set: {}={}", key, value);
|
|
|
+ Logger::instance().debugf("Protocol option set: {}={}", key, value);
|
|
|
return ErrorCode::SUCCESS;
|
|
|
}
|
|
|
|
|
|
@@ -336,9 +334,9 @@ ErrorCode StreamMuxer::setupOutput() {
|
|
|
}
|
|
|
|
|
|
// 分配格式上下文
|
|
|
- int ret = avformat_alloc_output_context2(&formatContext_, nullptr, formatName, streamParams_.url.c_str());
|
|
|
+ int ret = avformat_alloc_output_context2(&formatCtx_, NULL, formatName, streamParams_.url.c_str());
|
|
|
if (ret < 0) {
|
|
|
- Logger::error("Failed to allocate output context: {}", av_err2str(ret));
|
|
|
+ Logger::instance().errorf("Failed to allocate output context: {}", ffmpeg_utils::errorToString(ret));
|
|
|
return ErrorCode::INITIALIZATION_FAILED;
|
|
|
}
|
|
|
|
|
|
@@ -361,36 +359,36 @@ ErrorCode StreamMuxer::setupOutput() {
|
|
|
}
|
|
|
|
|
|
ErrorCode StreamMuxer::writeHeader() {
|
|
|
- if (!formatContext_) {
|
|
|
+ if (!formatCtx_) {
|
|
|
return ErrorCode::INVALID_STATE;
|
|
|
}
|
|
|
|
|
|
// 打开输出
|
|
|
- int ret = avio_open(&formatContext_->pb, streamParams_.url.c_str(), AVIO_FLAG_WRITE);
|
|
|
+ int ret = avio_open(&formatCtx_->pb, streamParams_.url.c_str(), AVIO_FLAG_WRITE);
|
|
|
if (ret < 0) {
|
|
|
- Logger::error("Failed to open output: {}", av_err2str(ret));
|
|
|
- return ErrorCode::WRITE_ERROR;
|
|
|
+ Logger::instance().errorf("Failed to open output: {}", ffmpeg_utils::errorToString(ret));
|
|
|
+ return ErrorCode::OPERATION_FAILED;
|
|
|
}
|
|
|
|
|
|
// 写入头部
|
|
|
- ret = avformat_write_header(formatContext_, nullptr);
|
|
|
+ ret = avformat_write_header(formatCtx_, NULL);
|
|
|
if (ret < 0) {
|
|
|
- Logger::error("Failed to write header: {}", av_err2str(ret));
|
|
|
- return ErrorCode::WRITE_ERROR;
|
|
|
+ Logger::instance().errorf("Failed to write header: {}", ffmpeg_utils::errorToString(ret));
|
|
|
+ return ErrorCode::OPERATION_FAILED;
|
|
|
}
|
|
|
|
|
|
return ErrorCode::SUCCESS;
|
|
|
}
|
|
|
|
|
|
ErrorCode StreamMuxer::writeTrailer() {
|
|
|
- if (!formatContext_) {
|
|
|
+ if (!formatCtx_) {
|
|
|
return ErrorCode::INVALID_STATE;
|
|
|
}
|
|
|
|
|
|
- int ret = av_write_trailer(formatContext_);
|
|
|
+ int ret = av_write_trailer(formatCtx_);
|
|
|
if (ret < 0) {
|
|
|
- Logger::error("Failed to write trailer: {}", av_err2str(ret));
|
|
|
- return ErrorCode::WRITE_ERROR;
|
|
|
+ Logger::instance().errorf("Failed to write trailer: {}", ffmpeg_utils::errorToString(ret));
|
|
|
+ return ErrorCode::OPERATION_FAILED;
|
|
|
}
|
|
|
|
|
|
return ErrorCode::SUCCESS;
|
|
|
@@ -413,24 +411,24 @@ ErrorCode StreamMuxer::establishConnection() {
|
|
|
}
|
|
|
|
|
|
ErrorCode StreamMuxer::closeConnection() {
|
|
|
- if (formatContext_ && formatContext_->pb) {
|
|
|
+ if (formatCtx_ && formatCtx_->pb) {
|
|
|
// 写入尾部
|
|
|
writeTrailer();
|
|
|
|
|
|
// 关闭输出
|
|
|
- avio_closep(&formatContext_->pb);
|
|
|
+ avio_closep(&formatCtx_->pb);
|
|
|
}
|
|
|
|
|
|
return ErrorCode::SUCCESS;
|
|
|
}
|
|
|
|
|
|
ErrorCode StreamMuxer::setupRTMP() {
|
|
|
- if (!formatContext_) {
|
|
|
+ if (!formatCtx_) {
|
|
|
return ErrorCode::INVALID_STATE;
|
|
|
}
|
|
|
|
|
|
// 设置RTMP选项
|
|
|
- AVDictionary* options = nullptr;
|
|
|
+ AVDictionary* options = NULL;
|
|
|
|
|
|
// 连接超时
|
|
|
av_dict_set_int(&options, "timeout", streamParams_.connectTimeout * 1000, 0);
|
|
|
@@ -448,19 +446,19 @@ ErrorCode StreamMuxer::setupRTMP() {
|
|
|
av_dict_set(&options, option.first.c_str(), option.second.c_str(), 0);
|
|
|
}
|
|
|
|
|
|
- formatContext_->metadata = options;
|
|
|
+ formatCtx_->metadata = options;
|
|
|
|
|
|
- Logger::debug("RTMP setup completed");
|
|
|
+ Logger::instance().debug("RTMP setup completed");
|
|
|
return ErrorCode::SUCCESS;
|
|
|
}
|
|
|
|
|
|
ErrorCode StreamMuxer::setupUDP() {
|
|
|
- if (!formatContext_) {
|
|
|
+ if (!formatCtx_) {
|
|
|
return ErrorCode::INVALID_STATE;
|
|
|
}
|
|
|
|
|
|
// 设置UDP选项
|
|
|
- AVDictionary* options = nullptr;
|
|
|
+ AVDictionary* options = NULL;
|
|
|
|
|
|
// 缓冲区大小
|
|
|
av_dict_set_int(&options, "buffer_size", streamParams_.sendBufferSize, 0);
|
|
|
@@ -483,19 +481,19 @@ ErrorCode StreamMuxer::setupUDP() {
|
|
|
av_dict_set(&options, option.first.c_str(), option.second.c_str(), 0);
|
|
|
}
|
|
|
|
|
|
- formatContext_->metadata = options;
|
|
|
+ formatCtx_->metadata = options;
|
|
|
|
|
|
- Logger::debug("UDP setup completed");
|
|
|
+ Logger::instance().debug("UDP setup completed");
|
|
|
return ErrorCode::SUCCESS;
|
|
|
}
|
|
|
|
|
|
ErrorCode StreamMuxer::setupTCP() {
|
|
|
- if (!formatContext_) {
|
|
|
+ if (!formatCtx_) {
|
|
|
return ErrorCode::INVALID_STATE;
|
|
|
}
|
|
|
|
|
|
// 设置TCP选项
|
|
|
- AVDictionary* options = nullptr;
|
|
|
+ AVDictionary* options = NULL;
|
|
|
|
|
|
// 连接超时
|
|
|
av_dict_set_int(&options, "timeout", streamParams_.connectTimeout * 1000, 0);
|
|
|
@@ -508,19 +506,19 @@ ErrorCode StreamMuxer::setupTCP() {
|
|
|
av_dict_set(&options, option.first.c_str(), option.second.c_str(), 0);
|
|
|
}
|
|
|
|
|
|
- formatContext_->metadata = options;
|
|
|
+ formatCtx_->metadata = options;
|
|
|
|
|
|
- Logger::debug("TCP setup completed");
|
|
|
+ Logger::instance().debug("TCP setup completed");
|
|
|
return ErrorCode::SUCCESS;
|
|
|
}
|
|
|
|
|
|
ErrorCode StreamMuxer::setupSRT() {
|
|
|
- if (!formatContext_) {
|
|
|
+ if (!formatCtx_) {
|
|
|
return ErrorCode::INVALID_STATE;
|
|
|
}
|
|
|
|
|
|
// 设置SRT选项
|
|
|
- AVDictionary* options = nullptr;
|
|
|
+ AVDictionary* options = NULL;
|
|
|
|
|
|
// 延迟
|
|
|
av_dict_set_int(&options, "latency", streamParams_.srtLatency * 1000, 0);
|
|
|
@@ -535,14 +533,14 @@ ErrorCode StreamMuxer::setupSRT() {
|
|
|
av_dict_set(&options, option.first.c_str(), option.second.c_str(), 0);
|
|
|
}
|
|
|
|
|
|
- formatContext_->metadata = options;
|
|
|
+ formatCtx_->metadata = options;
|
|
|
|
|
|
- Logger::debug("SRT setup completed");
|
|
|
+ Logger::instance().debug("SRT setup completed");
|
|
|
return ErrorCode::SUCCESS;
|
|
|
}
|
|
|
|
|
|
ErrorCode StreamMuxer::processPacket(AVPacket* packet) {
|
|
|
- if (!packet || !formatContext_) {
|
|
|
+ if (!packet || !formatCtx_) {
|
|
|
return ErrorCode::INVALID_PARAMETER;
|
|
|
}
|
|
|
|
|
|
@@ -561,28 +559,28 @@ ErrorCode StreamMuxer::processPacket(AVPacket* packet) {
|
|
|
connectionStats_.lastDataTime = std::chrono::steady_clock::now();
|
|
|
} else {
|
|
|
stats_.errorCount++;
|
|
|
- Logger::warning("Failed to send packet");
|
|
|
+ Logger::instance().warning("Failed to send packet");
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
ErrorCode StreamMuxer::sendPacket(AVPacket* packet) {
|
|
|
- if (!packet || !formatContext_) {
|
|
|
+ if (!packet || !formatCtx_) {
|
|
|
return ErrorCode::INVALID_PARAMETER;
|
|
|
}
|
|
|
|
|
|
- int ret = av_interleaved_write_frame(formatContext_, packet);
|
|
|
+ int ret = av_interleaved_write_frame(formatCtx_, packet);
|
|
|
if (ret < 0) {
|
|
|
- Logger::error("Failed to write packet: {}", av_err2str(ret));
|
|
|
- return ErrorCode::WRITE_ERROR;
|
|
|
+ Logger::instance().errorf("Failed to write packet: {}", ffmpeg_utils::errorToString(ret));
|
|
|
+ return ErrorCode::OPERATION_FAILED;
|
|
|
}
|
|
|
|
|
|
return ErrorCode::SUCCESS;
|
|
|
}
|
|
|
|
|
|
void StreamMuxer::monitorNetworkCondition() {
|
|
|
- Logger::debug("Network condition monitoring started");
|
|
|
+ Logger::instance().debug("Network condition monitoring started");
|
|
|
|
|
|
while (!shouldStopBitrateMonitor_) {
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
|
|
|
@@ -592,7 +590,7 @@ void StreamMuxer::monitorNetworkCondition() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- Logger::debug("Network condition monitoring stopped");
|
|
|
+ Logger::instance().debug("Network condition monitoring stopped");
|
|
|
}
|
|
|
|
|
|
void StreamMuxer::adjustBitrateBasedOnCondition() {
|
|
|
@@ -614,7 +612,7 @@ void StreamMuxer::adjustBitrateBasedOnCondition() {
|
|
|
}
|
|
|
|
|
|
void StreamMuxer::reconnectThreadFunc() {
|
|
|
- Logger::debug("Reconnect thread started");
|
|
|
+ Logger::instance().debug("Reconnect thread started");
|
|
|
|
|
|
int attemptCount = 0;
|
|
|
|
|
|
@@ -632,7 +630,7 @@ void StreamMuxer::reconnectThreadFunc() {
|
|
|
|
|
|
if (shouldReconnect() && attemptCount < streamParams_.maxReconnectAttempts) {
|
|
|
attemptCount++;
|
|
|
- Logger::info("Reconnect attempt {}/{}", attemptCount, streamParams_.maxReconnectAttempts);
|
|
|
+ Logger::instance().infof("Reconnect attempt {}/{}", attemptCount, streamParams_.maxReconnectAttempts);
|
|
|
|
|
|
lock.unlock();
|
|
|
|
|
|
@@ -651,7 +649,7 @@ void StreamMuxer::reconnectThreadFunc() {
|
|
|
reconnectRequested_ = false;
|
|
|
}
|
|
|
|
|
|
- Logger::debug("Reconnect thread stopped");
|
|
|
+ Logger::instance().debug("Reconnect thread stopped");
|
|
|
}
|
|
|
|
|
|
bool StreamMuxer::shouldReconnect() const {
|
|
|
@@ -730,7 +728,7 @@ void StreamMuxer::setConnectionState(ConnectionState state) {
|
|
|
}
|
|
|
|
|
|
void StreamMuxer::onConnectionStateChanged(ConnectionState state) {
|
|
|
- Logger::info("Connection state changed to: {}", static_cast<int>(state));
|
|
|
+ Logger::instance().infof("Connection state changed to: {}", static_cast<int>(state));
|
|
|
|
|
|
if (connectionCallback_) {
|
|
|
connectionCallback_(state);
|
|
|
@@ -752,25 +750,25 @@ bool StreamMuxer::validateParams(const MuxerParams& params) {
|
|
|
|
|
|
// 验证URL
|
|
|
if (!validateUrl(streamParams.url)) {
|
|
|
- Logger::error("Invalid URL: {}", streamParams.url);
|
|
|
+ Logger::instance().errorf("Invalid URL: {}", streamParams.url);
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
// 验证超时参数
|
|
|
if (streamParams.connectTimeout <= 0 || streamParams.sendTimeout <= 0) {
|
|
|
- Logger::error("Invalid timeout parameters");
|
|
|
+ Logger::instance().error("Invalid timeout parameters");
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
// 验证重连参数
|
|
|
if (streamParams.maxReconnectAttempts < 0 || streamParams.reconnectDelay < 0) {
|
|
|
- Logger::error("Invalid reconnect parameters");
|
|
|
+ Logger::instance().error("Invalid reconnect parameters");
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
// 验证码率参数
|
|
|
if (streamParams.minBitrate <= 0 || streamParams.maxBitrate <= streamParams.minBitrate) {
|
|
|
- Logger::error("Invalid bitrate parameters");
|
|
|
+ Logger::instance().error("Invalid bitrate parameters");
|
|
|
return false;
|
|
|
}
|
|
|
|