diff --git a/src/account.cpp b/src/account.cpp index e315e3c7f4ad21382988648aff9c92fa050af0a5..75eaee64397cf1cc527dfb763d03dd43a93d0cce 100644 --- a/src/account.cpp +++ b/src/account.cpp @@ -179,29 +179,22 @@ void Account::loadDefaultCodecs() { // default codec are system codecs - auto systemCodecList = systemCodecContainer_->getSystemCodecInfoList(); - - accountCodecInfoList_.empty(); - + const auto& systemCodecList = systemCodecContainer_->getSystemCodecInfoList(); + accountCodecInfoList_.clear(); + accountCodecInfoList_.reserve(systemCodecList.size()); for (const auto& systemCodec: systemCodecList) { - // As defined in SDP RFC, only select a codec if he can encode and decode + // As defined in SDP RFC, only select a codec if it can encode and decode if ((systemCodec->codecType & CODEC_ENCODER_DECODER) != CODEC_ENCODER_DECODER) continue; if (systemCodec->mediaType & MEDIA_AUDIO) { - // we are sure of our downcast type : use static_pointer_cast - auto audioCodec = std::static_pointer_cast<SystemAudioCodecInfo>(systemCodec); - // instantiate AccountAudioCodecInfo initialized with our system codec - auto codec = std::make_shared <AccountAudioCodecInfo>(*audioCodec); - accountCodecInfoList_.push_back(codec); + accountCodecInfoList_.emplace_back(std::make_shared <AccountAudioCodecInfo>( + *std::static_pointer_cast<SystemAudioCodecInfo>(systemCodec))); } if (systemCodec->mediaType & MEDIA_VIDEO) { - // we are sure of our downcast type : use static_pointer_cast - auto videoCodec = std::static_pointer_cast<SystemVideoCodecInfo>(systemCodec); - // instantiate AccountVideoCodecInfo initialized with our system codec - auto codec = std::make_shared<AccountVideoCodecInfo>(*videoCodec); - accountCodecInfoList_.push_back(codec); + accountCodecInfoList_.emplace_back(std::make_shared<AccountVideoCodecInfo>( + *std::static_pointer_cast<SystemVideoCodecInfo>(systemCodec))); } } } diff --git a/src/client/videomanager.cpp b/src/client/videomanager.cpp index 938d8854eba5fbaeb34c27a23042e1af556c0a35..6f76a75453b423d7ca70eff05af63ca396141f1c 100644 --- a/src/client/videomanager.cpp +++ b/src/client/videomanager.cpp @@ -577,17 +577,13 @@ setEncodingAccelerated(bool state) #endif // refresh codec container + setH265 jami::getSystemCodecContainer()->initCodecConfig(); - auto accIdList = jami::Manager::instance().getAccountList(); - for (const auto accId : accIdList) { - auto acc = jami::Manager::instance().accountFactory.getAccount(accId); - if (!acc) - continue; + for (const auto& acc : jami::Manager::instance().getAllAccounts()) { // Save activated codec auto activeCodecs = acc->getActiveCodecs(); // Refresh codec list for the account acc->loadDefaultCodecs(); // Activate H265 if it is available, if not ignore - acc->setCodecActive(AV_CODEC_ID_H265); + acc->setCodecActive(AV_CODEC_ID_HEVC); // Reactivate saved codec acc->setActiveCodecs(activeCodecs); jami::Manager::instance().saveConfig(acc); diff --git a/src/jamidht/jamiaccount.cpp b/src/jamidht/jamiaccount.cpp index a64325512e98a092ad6d26738e9cf45b1531b1cc..9a3d00b24f951039cc20ef7d581a554d33c84b1e 100644 --- a/src/jamidht/jamiaccount.cpp +++ b/src/jamidht/jamiaccount.cpp @@ -2746,7 +2746,7 @@ JamiAccount::setActiveCodecs(const std::vector<unsigned>& list) if (!hasActiveCodec(MEDIA_AUDIO)) setCodecActive(AV_CODEC_ID_OPUS); if (!hasActiveCodec(MEDIA_VIDEO)) { - setCodecActive(AV_CODEC_ID_H265); + setCodecActive(AV_CODEC_ID_HEVC); setCodecActive(AV_CODEC_ID_H264); setCodecActive(AV_CODEC_ID_VP8); } diff --git a/src/media/media_encoder.cpp b/src/media/media_encoder.cpp index 3c9f047d5c43227db0a2fa11dfb9b98d5944ca4b..f2a98af1866cc0dbdc1b616f6d39401b76a627b1 100644 --- a/src/media/media_encoder.cpp +++ b/src/media/media_encoder.cpp @@ -778,7 +778,7 @@ MediaEncoder::setBitrate(uint64_t br) // Change parameters on the fly if(codecId == AV_CODEC_ID_H264) initH264(encoderCtx, br); - if(codecId == AV_CODEC_ID_H265) + if(codecId == AV_CODEC_ID_HEVC) initH265(encoderCtx, br); else if(codecId == AV_CODEC_ID_H263P) initH263(encoderCtx, br); diff --git a/src/media/system_codec_container.cpp b/src/media/system_codec_container.cpp index 3689c5944b96e46cbb59bc2e76b3b48f91760e3a..87d320e76342f2aa676500332a25e3d51d88a4b1 100644 --- a/src/media/system_codec_container.cpp +++ b/src/media/system_codec_container.cpp @@ -243,7 +243,7 @@ void SystemCodecContainer::removeCodecByName(const std::string& name, MediaType mediaType) { for (auto codecIt = availableCodecList_.begin(); codecIt != availableCodecList_.end(); ++codecIt) { - if ((*codecIt)->name == name && (*codecIt)->mediaType & mediaType) { + if ((*codecIt)->mediaType & mediaType and (*codecIt)->name == name) { availableCodecList_.erase(codecIt); break; } diff --git a/src/media/video/accel.cpp b/src/media/video/accel.cpp index f4224a94d239d68e7cbcd7deb3abd8415a5cfd3c..99e8792ee362f3414142c4aa1181eb7db7209256 100644 --- a/src/media/video/accel.cpp +++ b/src/media/video/accel.cpp @@ -20,7 +20,6 @@ */ #include <algorithm> -#include <thread> // hardware_concurrency #include "media_buffer.h" #include "string_utils.h" @@ -31,6 +30,16 @@ namespace jami { namespace video { +struct HardwareAPI +{ + std::string name; + AVHWDeviceType hwType; + AVPixelFormat format; + AVPixelFormat swFormat; + std::vector<AVCodecID> supportedCodecs; + std::set<std::string> possible_devices; +}; + static const std::list<HardwareAPI> apiListDec = { { "nvdec", AV_HWDEVICE_TYPE_CUDA, AV_PIX_FMT_CUDA, AV_PIX_FMT_NV12, { AV_CODEC_ID_H264, AV_CODEC_ID_H265, AV_CODEC_ID_VP8, AV_CODEC_ID_MJPEG }, { "0", "1", "2" } }, { "vaapi", AV_HWDEVICE_TYPE_VAAPI, AV_PIX_FMT_VAAPI, AV_PIX_FMT_NV12, { AV_CODEC_ID_H264, AV_CODEC_ID_MPEG4, AV_CODEC_ID_VP8, AV_CODEC_ID_MJPEG }, { "/dev/dri/renderD128", "/dev/dri/renderD129", ":0" } }, diff --git a/src/media/video/accel.h b/src/media/video/accel.h index 8776b77598f51959c145bcbdac72ad2266495bed..4e344199a1afcc2285448ae0491f06171b6f0af8 100644 --- a/src/media/video/accel.h +++ b/src/media/video/accel.h @@ -35,16 +35,6 @@ extern "C" { namespace jami { namespace video { -struct HardwareAPI -{ - std::string name; - AVHWDeviceType hwType; - AVPixelFormat format; - AVPixelFormat swFormat; - std::vector<AVCodecID> supportedCodecs; - std::set<std::string> possible_devices; -}; - /** * @brief Provides an abstraction layer to the hardware acceleration APIs in FFmpeg. */