This commit is contained in:
ace
2025-12-08 00:42:50 +03:00
parent 7aaf6cb565
commit 3a29f1e8a7
43 changed files with 13471 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a4c01b3ab..c0b0a7973 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -849,7 +849,9 @@ else()
${DBUS_FILES}
${DBUS_ADAPTOR_FILES}
)
- target_link_libraries(jamid ${PROJECT_NAME} PkgConfig::DBusCpp)
+ find_package(OpenSSL REQUIRED)
+ find_package(ZLIB REQUIRED)
+ target_link_libraries(jamid ${PROJECT_NAME} PkgConfig::DBusCpp OpenSSL::SSL OpenSSL::Crypto ZLIB::ZLIB)
install (TARGETS jamid DESTINATION ${CMAKE_INSTALL_LIBEXECDIR})
endif()

View File

@@ -0,0 +1,63 @@
diff --git a/src/media/audio/sound/dtmfgenerator.cpp b/src/media/audio/sound/dtmfgenerator.cpp
index c05435f66..5b9eca18a 100644
--- a/src/media/audio/sound/dtmfgenerator.cpp
+++ b/src/media/audio/sound/dtmfgenerator.cpp
@@ -115,7 +115,7 @@ DTMFGenerator::fillToneBuffer(int index)
ptr->nb_samples = sampleRate_;
ptr->format = tone_.getFormat().sampleFormat;
ptr->sample_rate = sampleRate_;
- ptr->channel_layout = AV_CH_LAYOUT_MONO;
+ ptr->ch_layout.u.mask = AV_CH_LAYOUT_MONO;
av_channel_layout_from_mask(&ptr->ch_layout, AV_CH_LAYOUT_MONO);
av_frame_get_buffer(ptr.get(), 0);
tone_.genSin(ptr.get(), 0, ptr->nb_samples, tones_[index].higher, tones_[index].lower);
diff --git a/src/media/media_decoder.cpp b/src/media/media_decoder.cpp
index ceaa036c6..0cbeae5be 100644
--- a/src/media/media_decoder.cpp
+++ b/src/media/media_decoder.cpp
@@ -375,11 +375,11 @@ MediaDemuxer::Status
MediaDemuxer::decode()
{
if (inputParams_.format == "x11grab" || inputParams_.format == "dxgigrab") {
- auto ret = inputCtx_->iformat->read_header(inputCtx_);
- if (ret == AVERROR_EXTERNAL) {
- JAMI_ERR("Unable to read frame: %s\n", libav_utils::getError(ret).c_str());
- return Status::ReadError;
- }
+ // auto ret = inputCtx_->iformat->read_header(inputCtx_);
+ // if (ret == AVERROR_EXTERNAL) {
+ // JAMI_ERR("Unable to read frame: %s\n", libav_utils::getError(ret).c_str());
+ // return Status::ReadError;
+ // }
auto codecpar = inputCtx_->streams[0]->codecpar;
if (baseHeight_ != codecpar->height || baseWidth_ != codecpar->width) {
baseHeight_ = codecpar->height;
diff --git a/src/media/media_io_handle.h b/src/media/media_io_handle.h
index 7a64b85a7..a668e73c0 100644
--- a/src/media/media_io_handle.h
+++ b/src/media/media_io_handle.h
@@ -32,7 +32,7 @@ struct AVIOContext;
#endif
typedef int (*io_readcallback)(void* opaque, uint8_t* buf, int buf_size);
-typedef int (*io_writecallback)(void* opaque, uint8_t* buf, int buf_size);
+typedef int (*io_writecallback)(void* opaque, const uint8_t* buf, int buf_size);
typedef int64_t (*io_seekcallback)(void* opaque, int64_t offset, int whence);
namespace jami {
diff --git a/src/media/socket_pair.cpp b/src/media/socket_pair.cpp
index 0589affd5..f0005f6b0 100644
--- a/src/media/socket_pair.cpp
+++ b/src/media/socket_pair.cpp
@@ -382,8 +382,8 @@ SocketPair::createIOContext(const uint16_t mtu)
[](void* sp, uint8_t* buf, int len) {
return static_cast<SocketPair*>(sp)->readCallback(buf, len);
},
- [](void* sp, uint8_t* buf, int len) {
- return static_cast<SocketPair*>(sp)->writeCallback(buf, len);
+ [](void* sp, const uint8_t* buf, int len) {
+ return static_cast<SocketPair*>(sp)->writeCallback((uint8_t*)buf, len);
},
0,
reinterpret_cast<void*>(this));

View File

@@ -0,0 +1,110 @@
diff --git a/src/media/media_encoder.cpp b/src/media/media_encoder.cpp
index f999ffe42..eae622d48 100644
--- a/src/media/media_encoder.cpp
+++ b/src/media/media_encoder.cpp
@@ -72,11 +72,7 @@ MediaEncoder::~MediaEncoder()
}
for (auto encoderCtx : encoders_) {
if (encoderCtx) {
-#ifndef _MSC_VER
avcodec_free_context(&encoderCtx);
-#else
- avcodec_close(encoderCtx);
-#endif
}
}
avformat_free_context(outputCtx_);
@@ -354,7 +350,7 @@ MediaEncoder::initStream(const SystemCodecInfo& systemCodecInfo, AVBufferRef* fr
throw MediaEncoderException(
("Unable to compute buffer size: " + libav_utils::getError(scaledFrameBufferSize_))
.c_str());
- else if (scaledFrameBufferSize_ <= AV_INPUT_BUFFER_MIN_SIZE)
+ else if (scaledFrameBufferSize_ <= 16384)
throw MediaEncoderException("buffer too small");
scaledFrameBuffer_.resize(scaledFrameBufferSize_);
@@ -448,10 +444,10 @@ MediaEncoder::encode(const std::shared_ptr<VideoFrame>& input,
if (is_keyframe) {
avframe->pict_type = AV_PICTURE_TYPE_I;
- avframe->key_frame = 1;
+ avframe->flags |= AV_FRAME_FLAG_KEY;
} else {
avframe->pict_type = AV_PICTURE_TYPE_NONE;
- avframe->key_frame = 0;
+ avframe->flags &= ~AV_FRAME_FLAG_KEY;
}
return encode(avframe, currentStreamIdx_);
@@ -690,7 +686,7 @@ MediaEncoder::extractProfileLevelID(const std::string& parameters, AVCodecContex
// From RFC3984:
// If no profile-level-id is present, the Baseline Profile without
// additional constraints at Level 1 MUST be implied.
- ctx->profile = FF_PROFILE_H264_CONSTRAINED_BASELINE;
+ ctx->profile = AV_PROFILE_H264_CONSTRAINED_BASELINE;
ctx->level = 0x0d;
// ctx->level = 0x0d; // => 13 aka 1.3
if (parameters.empty())
@@ -716,17 +712,17 @@ MediaEncoder::extractProfileLevelID(const std::string& parameters, AVCodecContex
const unsigned char profile_iop = ((result >> 8) & 0xff); // xx80xx -> 80
ctx->level = result & 0xff; // xxxx0d -> 0d
switch (profile_idc) {
- case FF_PROFILE_H264_BASELINE:
+ case AV_PROFILE_H264_BASELINE:
// check constraint_set_1_flag
if ((profile_iop & 0x40) >> 6)
- ctx->profile |= FF_PROFILE_H264_CONSTRAINED;
+ ctx->profile |= AV_PROFILE_H264_CONSTRAINED;
break;
- case FF_PROFILE_H264_HIGH_10:
- case FF_PROFILE_H264_HIGH_422:
- case FF_PROFILE_H264_HIGH_444_PREDICTIVE:
+ case AV_PROFILE_H264_HIGH_10:
+ case AV_PROFILE_H264_HIGH_422:
+ case AV_PROFILE_H264_HIGH_444_PREDICTIVE:
// check constraint_set_3_flag
if ((profile_iop & 0x10) >> 4)
- ctx->profile |= FF_PROFILE_H264_INTRA;
+ ctx->profile |= AV_PROFILE_H264_INTRA;
break;
}
JAMI_DBG("Using profile %s (%x) and level %d",
@@ -837,7 +833,7 @@ MediaEncoder::initCodec(AVMediaType mediaType, AVCodecID avcodecId, uint64_t br)
encoderCtx->flags2 |= AV_CODEC_FLAG2_LOCAL_HEADER;
initH264(encoderCtx, br);
} else if (avcodecId == AV_CODEC_ID_HEVC) {
- encoderCtx->profile = FF_PROFILE_HEVC_MAIN;
+ encoderCtx->profile = AV_PROFILE_HEVC_MAIN;
forcePresetX2645(encoderCtx);
initH265(encoderCtx, br);
av_opt_set_int(encoderCtx, "b_ref_mode", 0, AV_OPT_SEARCH_CHILDREN);
@@ -1108,7 +1104,6 @@ MediaEncoder::stopEncoder()
}
}
AVCodecContext* encoderCtx = getCurrentVideoAVCtx();
- avcodec_close(encoderCtx);
avcodec_free_context(&encoderCtx);
av_free(encoderCtx);
}
@@ -1212,7 +1207,7 @@ MediaEncoder::testH265Accel()
framerate.den = 1;
encoderCtx->time_base = av_inv_q(framerate);
encoderCtx->pix_fmt = accel->getFormat();
- encoderCtx->profile = FF_PROFILE_HEVC_MAIN;
+ encoderCtx->profile = AV_PROFILE_HEVC_MAIN;
encoderCtx->opaque = accel.get();
auto br = SystemCodecInfo::DEFAULT_VIDEO_BITRATE;
@@ -1349,11 +1344,7 @@ MediaEncoder::resetStreams(int width, int height)
if (outputCtx_) {
for (auto encoderCtx : encoders_) {
if (encoderCtx) {
-#ifndef _MSC_VER
avcodec_free_context(&encoderCtx);
-#else
- avcodec_close(encoderCtx);
-#endif
}
}
encoders_.clear();

View File

@@ -0,0 +1,32 @@
diff -ru dhtnet.orig/src/upnp/upnp_context.cpp dhtnet/src/upnp/upnp_context.cpp
--- dhtnet.orig/src/upnp/upnp_context.cpp 2025-10-04 15:51:40.889482196 +0200
+++ dhtnet/src/upnp/upnp_context.cpp 2025-10-04 16:09:31.538008243 +0200
@@ -734,9 +734,12 @@
}
if (toRenewLaterCount > 0) {
nextRenewalTime += MAPPING_RENEWAL_THROTTLING_DELAY;
- if (logger_) logger_->debug("{} mapping(s) didn't need to be renewed (next renewal scheduled for {:%Y-%m-%d %H:%M:%S})",
+ if (logger_) {
+ std::time_t t = sys_clock::to_time_t(nextRenewalTime);
+ logger_->debug("{} mapping(s) didn't need to be renewed (next renewal scheduled for {:%Y-%m-%d %H:%M:%S})",
toRenewLaterCount,
- fmt::localtime(sys_clock::to_time_t(nextRenewalTime)));
+ *std::localtime(&t));
+ }
mappingRenewalTimer_.expires_at(nextRenewalTime);
mappingRenewalTimer_.async_wait([this](asio::error_code const& ec) {
if (ec != asio::error::operation_aborted)
@@ -783,8 +786,11 @@
if (nextRenewalTime == mappingRenewalTimer_.expiry())
return;
- if (logger_) logger_->debug("Scheduling next port mapping renewal for {:%Y-%m-%d %H:%M:%S}",
- fmt::localtime(sys_clock::to_time_t(nextRenewalTime)));
+ if (logger_) {
+ std::time_t t = sys_clock::to_time_t(nextRenewalTime);
+ logger_->debug("Scheduling next port mapping renewal for {:%Y-%m-%d %H:%M:%S}",
+ *std::localtime(&t));
+ }
mappingRenewalTimer_.expires_at(nextRenewalTime);
mappingRenewalTimer_.async_wait([this](asio::error_code const& ec) {
if (ec != asio::error::operation_aborted)