From f56e0b0125bcffa579aaad72762ea1f321afa6e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20H=C3=A4rer?= Date: Thu, 2 Jan 2025 20:49:38 +0100 Subject: [PATCH] Migrate logging to `std::format` --- lib/cdm/cdm/media/cdm/cdm_adapter.cc | 13 +++-- src/CompKodiProps.cpp | 36 ++++++------- src/Session.cpp | 38 +++++++------- src/aes_decrypter.cpp | 2 +- src/codechandler/ttml/TTML.cpp | 3 +- src/common/AdaptiveStream.cpp | 52 ++++++++++--------- src/common/AdaptiveTree.cpp | 6 +-- src/common/AdaptiveTreeFactory.cpp | 3 +- src/common/AdaptiveUtils.cpp | 2 +- src/common/Chooser.cpp | 10 ++-- src/common/ChooserDefault.cpp | 18 +++---- src/common/ChooserFixedRes.cpp | 6 +-- src/common/ChooserManualOSD.cpp | 10 ++-- src/common/ChooserTest.cpp | 2 +- src/common/Period.cpp | 4 +- src/common/SegTemplate.cpp | 2 +- src/common/Segment.cpp | 2 +- src/decrypters/HelperPr.cpp | 24 +++++---- src/decrypters/HelperWv.cpp | 8 +-- src/decrypters/Helpers.cpp | 6 +-- .../ClearKeyCencSingleSampleDecrypter.cpp | 8 +-- src/decrypters/widevine/CdmTypeConversion.cpp | 8 +-- src/decrypters/widevine/WVCdmAdapter.cpp | 6 +-- .../widevine/WVCencSingleSampleDecrypter.cpp | 24 ++++----- src/decrypters/widevine/WVDecrypter.cpp | 2 +- .../widevineandroid/WVCdmAdapter.cpp | 4 +- .../WVCencSingleSampleDecrypter.cpp | 28 +++++----- .../widevineandroid/WVDecrypter.cpp | 4 +- src/demuxers/TSReader.cpp | 8 +-- src/main.cpp | 18 +++---- src/parser/DASHTree.cpp | 39 +++++++------- src/parser/HLSTree.cpp | 30 +++++------ src/parser/SmoothTree.cpp | 17 +++--- src/samplereader/FragmentedSampleReader.cpp | 17 +++--- src/samplereader/SubtitleSampleReader.cpp | 10 ++-- src/test/TestDASHTree.cpp | 4 +- src/test/TestHLSTree.cpp | 4 +- src/test/TestHelper.cpp | 2 +- src/test/TestSmoothTree.cpp | 4 +- src/utils/CharArrayParser.cpp | 38 +++++++------- src/utils/CurlUtils.cpp | 10 ++-- src/utils/FileUtils.cpp | 4 +- src/utils/XMLUtils.cpp | 2 +- src/utils/log.h | 26 ++++++---- 44 files changed, 293 insertions(+), 271 deletions(-) diff --git a/lib/cdm/cdm/media/cdm/cdm_adapter.cc b/lib/cdm/cdm/media/cdm/cdm_adapter.cc index 22f872257..734072d9f 100644 --- a/lib/cdm/cdm/media/cdm/cdm_adapter.cc +++ b/lib/cdm/cdm/media/cdm/cdm_adapter.cc @@ -240,8 +240,7 @@ void CdmAdapter::Initialize() if (!library_) { - LOG::LogF(LOGERROR, "%s: Failed to load library: %s", __FUNCTION__, - error.ToString().c_str()); + LOG::LogF(LOGERROR, "{}: Failed to load library: {}", __FUNCTION__, error.ToString().c_str()); return; } @@ -258,7 +257,7 @@ void CdmAdapter::Initialize() } std::string version{get_cdm_verion_func()}; - LOG::LogF(LOGDEBUG, "CDM version: %s", version.c_str()); + LOG::LogF(LOGDEBUG, "CDM version: {}", version.c_str()); #if defined(OS_WIN) // Load DXVA before sandbox lockdown to give CDM access to Output Protection @@ -624,8 +623,8 @@ void CdmAdapter::OnSessionKeysChange(const char* session_id, char* bufferPtr{buffer}; for (uint32_t j{0}; j < keys_info[i].key_id_size; ++j) bufferPtr += std::snprintf(bufferPtr, 3, "%02X", (int)keys_info[i].key_id[j]); - LOG::Log(LOGDEBUG, "%s: Sessionkey %s status: %d syscode: %u", __func__, buffer, - keys_info[i].status, keys_info[i].system_code); + LOG::Log(LOGDEBUG, "{}: Sessionkey {} status: {} syscode: {}", __func__, buffer, + static_cast(keys_info[i].status), keys_info[i].system_code); SendClientMessage(session_id, session_id_size, CdmAdapterClient::kSessionKeysChange, keys_info[i].key_id, keys_info[i].key_id_size, keys_info[i].status); @@ -700,7 +699,7 @@ void CdmAdapter::RequestStorageId(uint32_t version) void CdmAdapter::OnInitialized(bool success) { - LOG::LogF(LOGDEBUG, "CDM is initialized: %s", success ? "true" : "false"); + LOG::LogF(LOGDEBUG, "CDM is initialized: {}", success ? "true" : "false"); } @@ -758,7 +757,7 @@ void CdmFileIoImpl::Write(const uint8_t* data, uint32_t data_size) { if (!ExistsDir(base_path_.c_str()) && !CreateDirs(base_path_.c_str())) { - LOG::LogF(LOGERROR, "Cannot create directory: %s", base_path_.c_str()); + LOG::LogF(LOGERROR, "Cannot create directory: {}", base_path_.c_str()); client_->OnWriteComplete(cdm::FileIOClient::Status::kError); return; } diff --git a/src/CompKodiProps.cpp b/src/CompKodiProps.cpp index e4a7868f8..6bc572bcb 100644 --- a/src/CompKodiProps.cpp +++ b/src/CompKodiProps.cpp @@ -69,7 +69,7 @@ constexpr std::string_view PROP_CHOOSER_RES_SECURE_MAX = "inputstream.adaptive.c void LogProp(std::string_view name, std::string_view value, bool isValueRedacted = false) { - LOG::Log(LOGDEBUG, "Property found \"%s\" value: %s", name.data(), + LOG::Log(LOGDEBUG, "Property found \"{}\" value: {}", name.data(), isValueRedacted ? "[redacted]" : value.data()); } @@ -87,7 +87,7 @@ void LogDrmJsonDictKeys(std::string_view keyName, keys += it->name.GetString(); } LOG::Log(LOGDEBUG, - "Found DRM config for key system: \"%s\" -> Dictionary: \"%s\", Values: \"%s\"", + "Found DRM config for key system: \"{}\" -> Dictionary: \"{}\", Values: \"{}\"", keySystem.data(), keyName.data(), keys.c_str()); } } @@ -218,7 +218,7 @@ void ADP::KODI_PROPS::CCompKodiProps::Init(const std::mapOpen(manifestResp.effectiveUrl, manifestResp.headers, manifestResp.data)) { - LOG::Log(LOGERROR, "Cannot parse the manifest (%s)", manifestUrl.c_str()); + LOG::Log(LOGERROR, "Cannot parse the manifest ({})", manifestUrl.c_str()); return false; } @@ -223,7 +223,7 @@ void SESSION::CSession::CheckHDCP() if (repr->GetHdcpVersion() > ssd_caps.hdcpVersion || (ssd_caps.hdcpLimit > 0 && repr->GetWidth() * repr->GetHeight() > ssd_caps.hdcpLimit)) { - LOG::Log(LOGDEBUG, "Representation ID \"%s\" removed as not HDCP compliant", + LOG::Log(LOGDEBUG, "Representation ID \"{}\" removed as not HDCP compliant", repr->GetId().data()); itRepr = adp->GetRepresentations().erase(itRepr); } @@ -251,7 +251,8 @@ bool SESSION::CSession::PreInitializeDRM(std::string& challengeB64, if (psshData.empty() || kidData.empty()) { - LOG::LogF(LOGERROR, "Invalid DRM pre-init data, must be as: {PSSH as base64}|{KID as base64}"); + LOG::LogF(LOGERROR, + "Invalid DRM pre-init data, must be as: {{PSSH as base64}}|{{KID as base64}}"); return false; } @@ -287,7 +288,7 @@ bool SESSION::CSession::PreInitializeDRM(std::string& challengeB64, CCdmSession& session(m_cdmSessions[1]); std::string hexKid{STRING::ToHexadecimal(decKid)}; - LOG::LogF(LOGDEBUG, "Initializing session with KID: %s", hexKid.c_str()); + LOG::LogF(LOGDEBUG, "Initializing session with KID: {}", hexKid.c_str()); if (m_decrypter && (session.m_cencSingleSampleDecrypter = m_decrypter->CreateSingleSampleDecrypter(initData, decKid, "", true, @@ -379,7 +380,7 @@ bool SESSION::CSession::InitializeDRM(bool addDefaultKID /* = false */) } else { - LOG::Log(LOGDEBUG, "License data: Create Widevine PSSH for SmoothStreaming %s", + LOG::Log(LOGDEBUG, "License data: Create Widevine PSSH for SmoothStreaming {}", customInitData.empty() ? "" : "(with custom data)"); initData = @@ -428,7 +429,7 @@ bool SESSION::CSession::InitializeDRM(bool addDefaultKID /* = false */) if (!defaultKid.empty()) { - LOG::Log(LOGDEBUG, "Initializing stream with KID: %s", defaultKidStr.c_str()); + LOG::Log(LOGDEBUG, "Initializing stream with KID: {}", defaultKidStr.c_str()); // If a decrypter has the default KID, re-use the same decrypter for also this session for (size_t i{1}; i < ses; ++i) @@ -577,7 +578,8 @@ bool SESSION::CSession::InitializePeriod(bool isSessionOpened /* = false */) if (adp->GetStreamType() == StreamType::NOTYPE) { - LOG::LogF(LOGDEBUG, "Skipped streams on adaptation set id \"%s\" due to unsupported/unknown type", + LOG::LogF(LOGDEBUG, + "Skipped streams on adaptation set id \"{}\" due to unsupported/unknown type", adp->GetId().data()); continue; } @@ -697,7 +699,7 @@ void SESSION::CSession::UpdateStream(CStream& stream) if (rep->GetContainerType() == ContainerType::INVALID) { - LOG::LogF(LOGERROR, "Container type not valid on stream representation ID: %s", + LOG::LogF(LOGERROR, "Container type not valid on stream representation ID: {}", rep->GetId().data()); stream.m_isValid = false; return; @@ -792,7 +794,7 @@ void SESSION::CSession::UpdateStream(CStream& stream) stream.m_info.SetCodecProfile(STREAMCODEC_PROFILE::VP9CodecProfile3); break; default: - LOG::LogF(LOGWARNING, "Unhandled video codec profile \"%i\" for codec string: %s", + LOG::LogF(LOGWARNING, "Unhandled video codec profile \"{}\" for codec string: {}", codecProfileNum, codecStr.c_str()); break; } @@ -907,7 +909,7 @@ bool SESSION::CSession::IsCDMSessionSecurePath(size_t index) { if (index >= m_cdmSessions.size()) { - LOG::LogF(LOGERROR, "No CDM session at index %u", index); + LOG::LogF(LOGERROR, "No CDM session at index {}", index); return false; } @@ -919,7 +921,7 @@ std::string SESSION::CSession::GetCDMSession(unsigned int index) { if (index >= m_cdmSessions.size()) { - LOG::LogF(LOGERROR, "No CDM session at index %u", index); + LOG::LogF(LOGERROR, "No CDM session at index {}", index); return {}; } return m_cdmSessions[index].m_sessionId; @@ -930,7 +932,7 @@ std::shared_ptr SESSION::CSession::GetSingle { if (index >= m_cdmSessions.size()) { - LOG::LogF(LOGERROR, "Index %u out of range, cannot get single sample decrypter", index); + LOG::LogF(LOGERROR, "Index {} out of range, cannot get single sample decrypter", index); return nullptr; } @@ -1104,7 +1106,7 @@ bool SESSION::CSession::SeekTime(double seekTime, unsigned int streamId, bool pr if ((*pi).get() != m_adaptiveTree->m_currentPeriod) { - LOG::Log(LOGDEBUG, "SeekTime: seeking into new chapter: %d", + LOG::Log(LOGDEBUG, "SeekTime: seeking into new chapter: {}", static_cast((pi - m_adaptiveTree->m_periods.begin()) + 1)); SeekChapter(static_cast(pi - m_adaptiveTree->m_periods.begin()) + 1); m_chapterSeekTime = seekTime; @@ -1194,8 +1196,8 @@ bool SESSION::CSession::SeekTime(double seekTime, unsigned int streamId, bool pr double destTime{static_cast(PTSToElapsed(streamReader->PTS())) / STREAM_TIME_BASE}; LOG::Log(LOGINFO, - "Seek time %0.1lf for stream: %u (physical index %u) continues at %0.1lf " - "(PTS: %llu)", + "Seek time {:0.1f} for stream: {} (physical index {}) continues at {:0.1f} " + "(PTS: {})", seekTime, streamReader->GetStreamId(), stream->m_info.GetPhysicalIndex(), destTime, streamReader->PTS()); if (stream->m_info.GetStreamType() == INPUTSTREAM_TYPE_VIDEO) @@ -1282,7 +1284,7 @@ bool SESSION::CSession::OnGetStream(int streamid, kodi::addon::InputstreamInfo& // we are forced to delete all CStream's here, so that when demux reader will starts // will have no data to process, and so stop the playback // (other streams may have been requested/opened before this one) - LOG::Log(LOGERROR, "GetStream(%d): Decrypter for the stream not found", streamid); + LOG::Log(LOGERROR, "GetStream({}): Decrypter for the stream not found", streamid); DeleteStreams(); return false; } @@ -1428,7 +1430,7 @@ bool SESSION::CSession::SeekChapter(int ch) { CPeriod* nextPeriod = m_adaptiveTree->m_periods[ch].get(); m_adaptiveTree->m_nextPeriod = nextPeriod; - LOG::LogF(LOGDEBUG, "Switching to new Period (id=%s, start=%llu, seq=%u)", + LOG::LogF(LOGDEBUG, "Switching to new Period (id={}, start={}, seq={})", nextPeriod->GetId().data(), nextPeriod->GetStart(), nextPeriod->GetSequence()); for (auto& stream : m_streams) diff --git a/src/aes_decrypter.cpp b/src/aes_decrypter.cpp index 99ad2710a..94d6d8689 100644 --- a/src/aes_decrypter.cpp +++ b/src/aes_decrypter.cpp @@ -37,7 +37,7 @@ void AESDecrypter::decrypt(const AP4_UI08* aes_key, reinterpret_cast(&dataSize), lastChunk); if (!AP4_SUCCEEDED(result)) { - LOG::LogF(LOGERROR, "AES decryption failed: %d", result); + LOG::LogF(LOGERROR, "AES decryption failed: {}", result); } dst.resize(dstOffset + dataSize); } diff --git a/src/codechandler/ttml/TTML.cpp b/src/codechandler/ttml/TTML.cpp index 0d6c33010..554c426c9 100644 --- a/src/codechandler/ttml/TTML.cpp +++ b/src/codechandler/ttml/TTML.cpp @@ -93,7 +93,8 @@ bool TTML2SRT::ParseData(const void* buffer, size_t bufferSize) if (parseRes.status != status_ok) { - LOG::LogF(LOGERROR, "Failed to parse XML data, error code: %i", parseRes.status); + LOG::LogF(LOGERROR, "Failed to parse XML data, error code: {}", + static_cast(parseRes.status)); return false; } diff --git a/src/common/AdaptiveStream.cpp b/src/common/AdaptiveStream.cpp index de1e773b3..89e626187 100644 --- a/src/common/AdaptiveStream.cpp +++ b/src/common/AdaptiveStream.cpp @@ -63,7 +63,7 @@ AdaptiveStream::AdaptiveStream(AdaptiveTree* tree, // Set the class id for debug purpose clsId = globalClsId++; LOG::Log(LOGDEBUG, - "Created AdaptiveStream [AS-%u] with adaptation set ID: \"%s\", stream type: %s", clsId, + "Created AdaptiveStream [AS-{}] with adaptation set ID: \"{}\", stream type: {}", clsId, adp->GetId().data(), StreamTypeToString(adp->GetStreamType()).data()); } @@ -111,7 +111,7 @@ bool adaptive::AdaptiveStream::DownloadSegment(const DownloadInfo& downloadInfo) { if (!downloadInfo.m_segmentBuffer) { - LOG::LogF(LOGERROR, "[AS-%u] Download failed, no segment buffer", clsId); + LOG::LogF(LOGERROR, "[AS-{}] Download failed, no segment buffer", clsId); return false; } return DownloadImpl(downloadInfo, nullptr); @@ -138,9 +138,9 @@ bool adaptive::AdaptiveStream::DownloadImpl(const DownloadInfo& downloadInfo, int statusCode = curl.Open(); if (statusCode == -1) - LOG::Log(LOGERROR, "[AS-%u] Download failed, internal error: %s", clsId, url.c_str()); + LOG::Log(LOGERROR, "[AS-{}] Download failed, internal error: {}", clsId, url.c_str()); else if (statusCode >= 400) - LOG::Log(LOGERROR, "[AS-%u] Download failed, HTTP error %d: %s", clsId, statusCode, + LOG::Log(LOGERROR, "[AS-{}] Download failed, HTTP error {}: {}", clsId, statusCode, url.c_str()); else // Start the download { @@ -187,18 +187,18 @@ bool adaptive::AdaptiveStream::DownloadImpl(const DownloadInfo& downloadInfo, if (downloadStatus == CURL::ReadStatus::ERROR) { - LOG::Log(LOGERROR, "[AS-%u] Download failed, cannot read chunk: %s", clsId, url.c_str()); + LOG::Log(LOGERROR, "[AS-{}] Download failed, cannot read chunk: {}", clsId, url.c_str()); } else if (downloadStatus == CURL::ReadStatus::CHUNK_READ) { // Chunk reading operations have been stopped - LOG::Log(LOGDEBUG, "[AS-%u] Download cancelled: %s", clsId, url.c_str()); + LOG::Log(LOGDEBUG, "[AS-{}] Download cancelled: {}", clsId, url.c_str()); } else if (downloadStatus == CURL::ReadStatus::IS_EOF) { if (curl.GetTotalByteRead() == 0) { - LOG::Log(LOGERROR, "[AS-%u] Download failed, no data: %s", clsId, url.c_str()); + LOG::Log(LOGERROR, "[AS-{}] Download failed, no data: {}", clsId, url.c_str()); return false; } @@ -212,7 +212,7 @@ bool adaptive::AdaptiveStream::DownloadImpl(const DownloadInfo& downloadInfo, if (totalBytesRead > minSize) m_tree->GetRepChooser()->SetDownloadSpeed(downloadSpeed); - LOG::Log(LOGDEBUG, "[AS-%u] Download finished: %s (downloaded %zu byte, speed %0.2lf byte/s)", + LOG::Log(LOGDEBUG, "[AS-{}] Download finished: {} (downloaded {} byte, speed %0.2lf byte/s)", clsId, url.c_str(), totalBytesRead, downloadSpeed); return true; } @@ -402,7 +402,8 @@ void AdaptiveStream::worker() //! we have to interrupt the sleep when it happens std::this_thread::sleep_for(msSleep); downloadAttempts++; - LOG::Log(LOGWARNING, "[AS-%u] Segment download failed, attempt %zu...", clsId, downloadAttempts); + LOG::Log(LOGWARNING, "[AS-{}] Segment download failed, attempt {}...", clsId, + downloadAttempts); } lckdl.lock(); @@ -447,7 +448,7 @@ bool AdaptiveStream::parseIndexRange(PLAYLIST::CRepresentation* rep, const std::vector& buffer) { #ifndef INPUTSTREAM_TEST_BUILD - LOG::Log(LOGDEBUG, "[AS-%u] Build segments from SIDX atom...", clsId); + LOG::Log(LOGDEBUG, "[AS-{}] Build segments from SIDX atom...", clsId); AP4_MemoryByteStream byteStream{reinterpret_cast(buffer.data()), static_cast(buffer.size())}; @@ -558,13 +559,13 @@ bool AdaptiveStream::parseIndexRange(PLAYLIST::CRepresentation* rep, { if (!isMoovFound) { - LOG::LogF(LOGERROR, "[AS-%u] Cannot create init segment, missing MOOV atom in stream", + LOG::LogF(LOGERROR, "[AS-{}] Cannot create init segment, missing MOOV atom in stream", clsId); return false; } if (initRangeEnd == NO_VALUE) { - LOG::LogF(LOGERROR, "[AS-%u] Cannot create init segment, cannot determinate range end", + LOG::LogF(LOGERROR, "[AS-{}] Cannot create init segment, cannot determinate range end", clsId); return false; } @@ -753,8 +754,8 @@ bool AdaptiveStream::start_stream(const uint64_t startPts) if (!current_rep_->Timeline().Get(0)) { - LOG::LogF(LOGERROR, "[AS-%u] Segment at position 0 not found from representation id: %s", - clsId, current_rep_->GetId().data()); + LOG::LogF(LOGERROR, "[AS-{}] Segment at position 0 not found from representation id: {}", clsId, + current_rep_->GetId().data()); return false; } @@ -832,7 +833,7 @@ bool AdaptiveStream::ensureSegment() if (valid_segment_buffers_ == 0 && available_segment_buffers_ > 0) { - LOG::LogF(LOGDEBUG, "[AS-%u] Download not started yet (rep. id \"%s\" period id \"%s\")", + LOG::LogF(LOGDEBUG, "[AS-{}] Download not started yet (rep. id \"{}\" period id \"{}\")", clsId, current_rep_->GetId().data(), current_period_->GetId().data()); return false; } @@ -865,7 +866,7 @@ bool AdaptiveStream::ensureSegment() if (!nextSegment && !current_rep_->IsWaitForSegment()) { current_rep_->SetIsWaitForSegment(true); - LOG::LogF(LOGDEBUG, "[AS-%u] Begin WaitForSegment stream rep. id \"%s\" period id \"%s\"", + LOG::LogF(LOGDEBUG, "[AS-{}] Begin WaitForSegment stream rep. id \"{}\" period id \"{}\"", clsId, current_rep_->GetId().data(), current_period_->GetId().data()); return false; } @@ -984,7 +985,7 @@ bool AdaptiveStream::ensureSegment() } else if (available_segment_buffers_ == 0) { - LOG::LogF(LOGDEBUG, "[AS-%u] End of segments", clsId); + LOG::LogF(LOGDEBUG, "[AS-{}] End of segments", clsId); state_ = STOPPED; return false; } @@ -1140,7 +1141,7 @@ int adaptive::AdaptiveStream::GetTrackType() const { if (!current_adp_) { - LOG::LogF(LOGERROR, "[AS-%u] Failed get track type, current adaptation set is nullptr.", clsId); + LOG::LogF(LOGERROR, "[AS-{}] Failed get track type, current adaptation set is nullptr.", clsId); return AP4_Track::TYPE_UNKNOWN; } @@ -1153,8 +1154,8 @@ int adaptive::AdaptiveStream::GetTrackType() const case StreamType::SUBTITLE: return AP4_Track::TYPE_SUBTITLES; default: - LOG::LogF(LOGERROR, "[AS-%u] Stream type \"%i\" not mapped to AP4_Track::Type", - clsId, static_cast(current_adp_->GetStreamType())); + LOG::LogF(LOGERROR, "[AS-{}] Stream type \"{}\" not mapped to AP4_Track::Type", clsId, + static_cast(current_adp_->GetStreamType())); break; } return AP4_Track::TYPE_UNKNOWN; @@ -1164,7 +1165,8 @@ PLAYLIST::StreamType adaptive::AdaptiveStream::GetStreamType() const { if (!current_adp_) { - LOG::LogF(LOGERROR, "[AS-%u] Failed get stream type, current adaptation set is nullptr.", clsId); + LOG::LogF(LOGERROR, "[AS-{}] Failed get stream type, current adaptation set is nullptr.", + clsId); return StreamType::NOTYPE; } return current_adp_->GetStreamType(); @@ -1195,7 +1197,7 @@ bool AdaptiveStream::seek_time(double seek_seconds, bool preceeding, bool& needR { if (!current_rep_->Timeline().Get(0)) { - LOG::LogF(LOGERROR, "[AS-%u] Segment at position 0 not found from representation id: %s", + LOG::LogF(LOGERROR, "[AS-{}] Segment at position 0 not found from representation id: {}", clsId, current_rep_->GetId().data()); return false; } @@ -1281,7 +1283,7 @@ bool AdaptiveStream::GenerateSidxSegments(PLAYLIST::CRepresentation* rep) else if (containerType != ContainerType::MP4 && containerType != ContainerType::WEBM) { LOG::LogF(LOGERROR, - "[AS-%u] Cannot generate segments from SIDX on repr id \"%s\" with container \"%i\"", + "[AS-{}] Cannot generate segments from SIDX on repr id \"{}\" with container \"{}\"", clsId, rep->GetId().data(), static_cast(containerType)); return false; } @@ -1353,12 +1355,12 @@ void adaptive::AdaptiveStream::DisposeWorker() { if (worker_processing_) { - LOG::LogF(LOGERROR, "[AS-%u] Cannot delete worker thread, download is in progress.", clsId); + LOG::LogF(LOGERROR, "[AS-{}] Cannot delete worker thread, download is in progress.", clsId); return; } if (!thread_data_->thread_stop_) { - LOG::LogF(LOGERROR, "[AS-%u] Cannot delete worker thread, loop is still running.", clsId); + LOG::LogF(LOGERROR, "[AS-{}] Cannot delete worker thread, loop is still running.", clsId); return; } delete thread_data_; diff --git a/src/common/AdaptiveTree.cpp b/src/common/AdaptiveTree.cpp index 2699cc285..49fe85b55 100644 --- a/src/common/AdaptiveTree.cpp +++ b/src/common/AdaptiveTree.cpp @@ -107,7 +107,7 @@ namespace adaptive StartUpdateThread(); LOG::Log(LOGINFO, - "Manifest successfully parsed (Periods: %zu, Streams in first period: %zu, Type: %s)", + "Manifest successfully parsed (Periods: {}, Streams in first period: {}, Type: {})", m_periods.size(), m_currentPeriod->GetAdaptationSets().size(), m_isLive ? "live" : "VOD"); } @@ -208,7 +208,7 @@ namespace adaptive const uint64_t segEndPtsMs = segment->m_endPts * 1000 / segRep->GetTimescale(); - LOG::LogF(LOGDEBUG, "Check for last segment (period end PTS: %llu, segment end PTS: %llu)", + LOG::LogF(LOGDEBUG, "Check for last segment (period end PTS: {}, segment end PTS: {})", pEndPtsMs, segEndPtsMs); return segEndPtsMs >= pEndPtsMs; @@ -248,7 +248,7 @@ namespace adaptive } if (FILESYS::SaveFile(filePath, dataToSave, false)) - LOG::Log(LOGDEBUG, "Manifest saved to: %s", filePath.c_str()); + LOG::Log(LOGDEBUG, "Manifest saved to: {}", filePath.c_str()); } } } diff --git a/src/common/AdaptiveTreeFactory.cpp b/src/common/AdaptiveTreeFactory.cpp index dd9376ccf..d1c6b9940 100644 --- a/src/common/AdaptiveTreeFactory.cpp +++ b/src/common/AdaptiveTreeFactory.cpp @@ -10,6 +10,7 @@ #include "CompKodiProps.h" #include "SrvBroker.h" +#include "kodi/tools/StringUtils.h" #include "parser/DASHTree.h" #include "parser/HLSTree.h" #include "parser/SmoothTree.h" @@ -48,7 +49,7 @@ adaptive::AdaptiveTree* PLAYLIST_FACTORY::CreateAdaptiveTree( "Check if the content-type header is correctly provided in the manifest response."); break; default: - LOG::LogF(LOGFATAL, "Manifest type %i not handled", type); + LOG::LogF(LOGFATAL, "Manifest type {} not handled", static_cast(type)); }; return nullptr; diff --git a/src/common/AdaptiveUtils.cpp b/src/common/AdaptiveUtils.cpp index 60f948f44..509d6285f 100644 --- a/src/common/AdaptiveUtils.cpp +++ b/src/common/AdaptiveUtils.cpp @@ -131,7 +131,7 @@ AP4_Movie* PLAYLIST::CreateMovieAtom(adaptive::AdaptiveStream& adStream, // audio SampleDescription atom require different code rework. This means also that CFragmentedSampleReader // will use a generic CodecHandler instead of AudioCodecHandler, because will be not able do determine the codec LOG::LogF(LOGDEBUG, - "Created sample description atom of unknown type for codec \"%s\" because unhandled", + "Created sample description atom of unknown type for codec \"{}\" because unhandled", codecName.data()); sampleDesc = new AP4_SampleDescription(AP4_SampleDescription::TYPE_UNKNOWN, 0, 0); } diff --git a/src/common/Chooser.cpp b/src/common/Chooser.cpp index 5edfd8578..48b6c383a 100644 --- a/src/common/Chooser.cpp +++ b/src/common/Chooser.cpp @@ -61,7 +61,7 @@ IRepresentationChooser* CHOOSER::CreateRepresentationChooser() { reprChooser = GetReprChooser(props.m_chooserType); if (!reprChooser) - LOG::Log(LOGERROR, "Stream selection type \"%s\" not exist. Fallback to XML settings"); + LOG::Log(LOGERROR, "Stream selection type \"{}\" not exist. Fallback to XML settings", props.m_chooserType); } if (!reprChooser) @@ -91,7 +91,7 @@ void CHOOSER::IRepresentationChooser::OnUpdateScreenRes() const auto sInfo = CSrvBroker::GetResources().GetScreenInfo(); LOG::Log(LOGINFO, - "[Repr. chooser] Resolution set: %dx%d, max allowed: %dx%d, Adjust refresh rate: %i", + "[Repr. chooser] Resolution set: {}x{}, max allowed: {}x{}, Adjust refresh rate: {}", sInfo.width, sInfo.height, sInfo.maxWidth, sInfo.maxHeight, m_isAdjustRefreshRate); // Use case: User chooses to upscale Kodi GUI from TV instead of Kodi engine. @@ -124,7 +124,7 @@ void CHOOSER::IRepresentationChooser::LogDetails(PLAYLIST::CRepresentation* curr { LOG::Log(LOGDEBUG, "[Repr. chooser] Selected representation\n" - "ID %s (Bandwidth: %u bit/s, Resolution: %ix%i)", + "ID {} (Bandwidth: {} bit/s, Resolution: {}x{})", nextRep->GetId().data(), nextRep->GetBandwidth(), nextRep->GetWidth(), nextRep->GetHeight()); } @@ -132,8 +132,8 @@ void CHOOSER::IRepresentationChooser::LogDetails(PLAYLIST::CRepresentation* curr { LOG::Log(LOGDEBUG, "[Repr. chooser] Changed representation\n" - "Current ID %s (Bandwidth: %u bit/s, Resolution: %ix%i)\n" - "Next ID %s (Bandwidth: %u bit/s, Resolution: %ix%i)", + "Current ID {} (Bandwidth: {} bit/s, Resolution: {}x{})\n" + "Next ID {} (Bandwidth: {} bit/s, Resolution: {}x{})", currentRep->GetId().data(), currentRep->GetBandwidth(), currentRep->GetWidth(), currentRep->GetHeight(), nextRep->GetId().data(), nextRep->GetBandwidth(), nextRep->GetWidth(), nextRep->GetHeight()); diff --git a/src/common/ChooserDefault.cpp b/src/common/ChooserDefault.cpp index 953ff113f..17c15bc5e 100644 --- a/src/common/ChooserDefault.cpp +++ b/src/common/ChooserDefault.cpp @@ -73,11 +73,11 @@ void CRepresentationChooserDefault::Initialize(const ADP::KODI_PROPS::ChooserPro LOG::Log(LOGDEBUG, "[Repr. chooser] Configuration\n" - "Resolution max: %ix%i\n" - "Resolution max for secure decoder: %ix%i\n" - "Bandwidth limits (bit/s): min %u, max %u\n" - "Ignore screen resolution: %i\n" - "Ignore screen resolution change: %i", + "Resolution max: {}x{}\n" + "Resolution max for secure decoder: {}x{}\n" + "Bandwidth limits (bit/s): min {}, max {}\n" + "Ignore screen resolution: {}\n" + "Ignore screen resolution change: {}", m_screenResMax.first, m_screenResMax.second, m_screenResSecureMax.first, m_screenResSecureMax.second, m_bandwidthMin, m_bandwidthMax, m_ignoreScreenRes, m_ignoreScreenResChange); @@ -109,8 +109,8 @@ void CRepresentationChooserDefault::PostInit() LOG::Log(LOGDEBUG, "[Repr. chooser] Stream selection conditions\n" - "Screen resolution: %ix%i (may be limited by settings)\n" - "Initial bandwidth: %u bit/s", + "Screen resolution: {}x{} (may be limited by settings)\n" + "Initial bandwidth: {} bit/s", m_screenWidth, m_screenHeight, m_bandwidthCurrent); } @@ -129,7 +129,7 @@ void CRepresentationChooserDefault::CheckResolution() } RefreshResolution(); m_screenResLastUpdate = std::chrono::steady_clock::now(); - LOG::Log(LOGDEBUG, "[Repr. chooser] Screen resolution has changed: %ix%i", m_screenCurrentWidth, + LOG::Log(LOGDEBUG, "[Repr. chooser] Screen resolution has changed: {}x{}", m_screenCurrentWidth, m_screenCurrentHeight); } } @@ -224,7 +224,7 @@ PLAYLIST::CRepresentation* CRepresentationChooserDefault::GetNextRepresentation( if (isVideoStreamType) // Only video, to avoid fill too much the log { - LOG::Log(LOGDEBUG, "[Repr. chooser] Current average bandwidth: %u bit/s (filtered to %u bit/s)", + LOG::Log(LOGDEBUG, "[Repr. chooser] Current average bandwidth: {} bit/s (filtered to {} bit/s)", m_bandwidthCurrent, bandwidth); LogDetails(currentRep, nextRep); } diff --git a/src/common/ChooserFixedRes.cpp b/src/common/ChooserFixedRes.cpp index 197ecb5ab..37d32a8ff 100644 --- a/src/common/ChooserFixedRes.cpp +++ b/src/common/ChooserFixedRes.cpp @@ -47,8 +47,8 @@ void CRepresentationChooserFixedRes::Initialize(const ADP::KODI_PROPS::ChooserPr LOG::Log(LOGDEBUG, "[Repr. chooser] Configuration\n" - "Resolution max: %ix%i\n" - "Resolution max for secure decoder: %ix%i", + "Resolution max: {}x{}\n" + "Resolution max for secure decoder: {}x{}", m_screenResMax.first, m_screenResMax.second, m_screenResSecureMax.first, m_screenResSecureMax.second); } @@ -57,7 +57,7 @@ void CRepresentationChooserFixedRes::PostInit() { LOG::Log(LOGDEBUG, "[Repr. chooser] Stream selection conditions\n" - "Screen resolution: %ix%i", + "Screen resolution: {}x{}", m_screenCurrentWidth, m_screenCurrentHeight); } diff --git a/src/common/ChooserManualOSD.cpp b/src/common/ChooserManualOSD.cpp index 6763edc28..8841881bf 100644 --- a/src/common/ChooserManualOSD.cpp +++ b/src/common/ChooserManualOSD.cpp @@ -41,10 +41,10 @@ void CRepresentationChooserManualOSD::Initialize(const ADP::KODI_PROPS::ChooserP LOG::Log(LOGDEBUG, "[Repr. chooser] Configuration\n" - "Stream manual selection mode: %i\n" - "Resolution max: %ix%i\n" - "Resolution max for secure decoder: %ix%i", - manualSelMode, m_screenResMax.first, m_screenResMax.second, + "Stream manual selection mode: {}\n" + "Resolution max: {}x{}\n" + "Resolution max for secure decoder: {}x{}", + static_cast(manualSelMode), m_screenResMax.first, m_screenResMax.second, m_screenResSecureMax.first, m_screenResSecureMax.second); } @@ -78,7 +78,7 @@ void CRepresentationChooserManualOSD::PostInit() LOG::Log(LOGDEBUG, "[Repr. chooser] Stream selection conditions\n" - "Resolution: %ix%i", + "Resolution: {}x{}", m_screenWidth, m_screenHeight); } diff --git a/src/common/ChooserTest.cpp b/src/common/ChooserTest.cpp index 280f67fb6..1aa45c7dd 100644 --- a/src/common/ChooserTest.cpp +++ b/src/common/ChooserTest.cpp @@ -53,7 +53,7 @@ void CRepresentationChooserTest::Initialize(const ADP::KODI_PROPS::ChooserProps& LOG::Log(LOGDEBUG, "[Repr. chooser] Configuration\n" - "Test mode: %s\n%s", + "Test mode: {}\n{}", testMode.c_str(), logDetails.c_str()); } diff --git a/src/common/Period.cpp b/src/common/Period.cpp index c8cfac6b8..f18731864 100644 --- a/src/common/Period.cpp +++ b/src/common/Period.cpp @@ -86,7 +86,9 @@ void PLAYLIST::CPeriod::DecreasePSSHSetUsageCount(uint16_t pssh_set) { if (pssh_set >= m_psshSets.size()) { - LOG::LogF(LOGERROR, "Cannot decrease PSSH usage, PSSHSet position %u exceeds the container size", pssh_set); + LOG::LogF(LOGERROR, + "Cannot decrease PSSH usage, PSSHSet position {} exceeds the container size", + pssh_set); return; } diff --git a/src/common/SegTemplate.cpp b/src/common/SegTemplate.cpp index dea1b6ec0..f263e6633 100644 --- a/src/common/SegTemplate.cpp +++ b/src/common/SegTemplate.cpp @@ -201,7 +201,7 @@ std::string PLAYLIST::CSegmentTemplate::FormatIdentifier(std::string_view identi if (std::snprintf(substitution, 128, formatTag.c_str(), value) > 0) return substitution; else - LOG::LogF(LOGERROR, "Cannot convert value \"%llu\" with \"%s\" format tag", value, + LOG::LogF(LOGERROR, "Cannot convert value \"{}\" with \"{}\" format tag", value, formatTag.c_str()); return std::string{identifier}; diff --git a/src/common/Segment.cpp b/src/common/Segment.cpp index f3b3b8572..dd7b75b8e 100644 --- a/src/common/Segment.cpp +++ b/src/common/Segment.cpp @@ -18,7 +18,7 @@ const CSegment* PLAYLIST::CSegContainer::Get(size_t pos) const if (pos >= m_segments.size()) { - LOG::LogF(LOGWARNING, "Position out-of-range (%zu of %zu)", pos, m_segments.size()); + LOG::LogF(LOGWARNING, "Position out-of-range ({} of {})", pos, m_segments.size()); return nullptr; } diff --git a/src/decrypters/HelperPr.cpp b/src/decrypters/HelperPr.cpp index ea347d59c..2fff8ef04 100644 --- a/src/decrypters/HelperPr.cpp +++ b/src/decrypters/HelperPr.cpp @@ -48,7 +48,8 @@ void FixWRMHeader(std::string& xmlData) xml_parse_result parseRes = doc.load_buffer(xmlData.c_str(), xmlData.size()); if (parseRes.status != status_ok) { - LOG::LogF(LOGERROR, "Failed to parse the Playready header, error code: %i", parseRes.status); + LOG::LogF(LOGERROR, "Failed to parse the Playready header, error code: {}", + static_cast(parseRes.status)); return; } @@ -151,21 +152,21 @@ bool DRM::PRHeaderParser::Parse(const std::vector& prHeader) { if (charParser.CharsLeft() < 2) { - LOG::LogF(LOGERROR, "Failed parse PlayReady object record %u, cannot read record type", i); + LOG::LogF(LOGERROR, "Failed parse PlayReady object record {}, cannot read record type", i); return false; } uint16_t recordType = charParser.ReadLENextUnsignedShort(); if (charParser.CharsLeft() < 2) { - LOG::LogF(LOGERROR, "Failed parse PlayReady object record %u, cannot read record size", i); + LOG::LogF(LOGERROR, "Failed parse PlayReady object record {}, cannot read record size", i); return false; } uint16_t recordSize = charParser.ReadLENextUnsignedShort(); if (charParser.CharsLeft() < recordSize) { - LOG::LogF(LOGERROR, "Failed parse PlayReady object record %u, cannot read WRM header", i); + LOG::LogF(LOGERROR, "Failed parse PlayReady object record {}, cannot read WRM header", i); return false; } if ((recordType & PLAYREADY_WRM_TAG) == PLAYREADY_WRM_TAG) @@ -182,7 +183,8 @@ bool DRM::PRHeaderParser::Parse(const std::vector& prHeader) xml_parse_result parseRes = doc.load_buffer(xmlData.c_str(), xmlData.size()); if (parseRes.status != status_ok) { - LOG::LogF(LOGERROR, "Failed to parse the Playready header, error code: %i", parseRes.status); + LOG::LogF(LOGERROR, "Failed to parse the Playready header, error code: {}", + static_cast(parseRes.status)); return false; } @@ -194,7 +196,7 @@ bool DRM::PRHeaderParser::Parse(const std::vector& prHeader) } std::string_view ver = XML::GetAttrib(nodeWRM, "version"); - LOG::Log(LOGDEBUG, "Parsing Playready header version %s", ver.data()); + LOG::Log(LOGDEBUG, "Parsing Playready header version {}", ver.data()); xml_node nodeDATA = nodeWRM.child("DATA"); if (!nodeDATA) @@ -248,7 +250,7 @@ bool DRM::PRHeaderParser::Parse(const std::vector& prHeader) xml_node nodeKIDS = nodePROTECTINFO.child("KIDS"); if (nodeKIDS) { - LOG::Log(LOGDEBUG, "Playready header contains %zu KID's.", + LOG::Log(LOGDEBUG, "Playready header contains {} KID's.", XML::CountChilds(nodeKIDS, "KID")); // We get the first KID xml_node nodeKID = nodeKIDS.child("KID"); @@ -275,7 +277,7 @@ bool DRM::PRHeaderParser::Parse(const std::vector& prHeader) m_KID = ConvertKidtoWv(prKid); } else - LOG::LogF(LOGWARNING, "KID size %zu instead of 16, KID ignored.", prKid.size()); + LOG::LogF(LOGWARNING, "KID size {} instead of 16, KID ignored.", prKid.size()); } xml_node nodeLAURL = nodeDATA.child("LA_URL"); @@ -326,7 +328,7 @@ std::vector DRM::FixPrHeader(const std::vector& prHeader) { if (charParser.CharsLeft() < 2) { - LOG::LogF(LOGERROR, "Failed parse PlayReady object record %u, cannot read record type", i); + LOG::LogF(LOGERROR, "Failed parse PlayReady object record {}, cannot read record type", i); return {}; } uint16_t recordType = charParser.ReadLENextUnsignedShort(); @@ -335,14 +337,14 @@ std::vector DRM::FixPrHeader(const std::vector& prHeader) if (charParser.CharsLeft() < 2) { - LOG::LogF(LOGERROR, "Failed parse PlayReady object record %u, cannot read record size", i); + LOG::LogF(LOGERROR, "Failed parse PlayReady object record {}, cannot read record size", i); return {}; } uint16_t recordSize = charParser.ReadLENextUnsignedShort(); if (charParser.CharsLeft() < recordSize) { - LOG::LogF(LOGERROR, "Failed parse PlayReady object record %u, cannot read WRM header", i); + LOG::LogF(LOGERROR, "Failed parse PlayReady object record {}, cannot read WRM header", i); return {}; } if ((recordType & PLAYREADY_WRM_TAG) == PLAYREADY_WRM_TAG) diff --git a/src/decrypters/HelperWv.cpp b/src/decrypters/HelperWv.cpp index 95b1534d1..49df1cade 100644 --- a/src/decrypters/HelperWv.cpp +++ b/src/decrypters/HelperWv.cpp @@ -165,7 +165,7 @@ std::vector TranslateWrapper(std::string_view wrapper) result.emplace_back(Wrapper::URL_ENC); else { - LOG::LogF(LOGERROR, "Cannot translate license wrapper, unknown type \"%s\"", wrapper.c_str()); + LOG::LogF(LOGERROR, "Cannot translate license wrapper, unknown type \"{}\"", wrapper.c_str()); return {Wrapper::AUTO}; } } @@ -542,13 +542,13 @@ bool DRM::WvUnwrapLicense(std::string_view wrapper, if (!jHdcpObjValue) { - LOG::LogF(LOGERROR, "Unable to parse JSON HDCP value, path \"%s\" not found", + LOG::LogF(LOGERROR, "Unable to parse JSON HDCP value, path \"{}\" not found", params.at("path_hdcp").c_str()); } else if (!jHdcpObjValue->IsInt()) { LOG::LogF(LOGERROR, - "Unable to parse JSON HDCP value, value with wrong data type on path \"%s\"", + "Unable to parse JSON HDCP value, value with wrong data type on path \"{}\"", params.at("path_hdcp").c_str()); } else @@ -597,7 +597,7 @@ bool DRM::WvUnwrapLicense(std::string_view wrapper, if (!node) { - LOG::LogF(LOGERROR, "Unable to get license data from XML path \"%s\"", + LOG::LogF(LOGERROR, "Unable to get license data from XML path \"{}\"", params.at("path_data").c_str()); return false; } diff --git a/src/decrypters/Helpers.cpp b/src/decrypters/Helpers.cpp index 48123ac71..b389ceff6 100644 --- a/src/decrypters/Helpers.cpp +++ b/src/decrypters/Helpers.cpp @@ -74,7 +74,7 @@ std::string DRM::UrnToSystemId(std::string_view urn) if (sysId.size() != 32) { - LOG::Log(LOGERROR, "Cannot convert URN (%s) to System ID", urn.data()); + LOG::Log(LOGERROR, "Cannot convert URN ({}) to System ID", urn.data()); return ""; } return sysId; @@ -147,7 +147,7 @@ std::vector DRM::ConvertKidStrToBytes(std::string_view kidStr) { if (kidStr.size() != 32) { - LOG::LogF(LOGERROR, "Cannot convert KID \"%s\" as bytes due to wrong size", kidStr.data()); + LOG::LogF(LOGERROR, "Cannot convert KID \"{}\" as bytes due to wrong size", kidStr.data()); return {}; } @@ -200,7 +200,7 @@ std::vector DRM::PSSH::Make(const uint8_t* systemId, } if (version > 1) { - LOG::LogF(LOGERROR, "Cannot make PSSH, version %u not supported", version); + LOG::LogF(LOGERROR, "Cannot make PSSH, version {} not supported", version); return {}; } if (initData.empty() && keyIds.empty()) diff --git a/src/decrypters/clearkey/ClearKeyCencSingleSampleDecrypter.cpp b/src/decrypters/clearkey/ClearKeyCencSingleSampleDecrypter.cpp index bb31e8dde..529de64c2 100644 --- a/src/decrypters/clearkey/ClearKeyCencSingleSampleDecrypter.cpp +++ b/src/decrypters/clearkey/ClearKeyCencSingleSampleDecrypter.cpp @@ -71,7 +71,7 @@ CClearKeyCencSingleSampleDecrypter::CClearKeyCencSingleSampleDecrypter( int statusCode = curl.Open(); if (statusCode == -1 || statusCode >= 400) { - LOG::Log(LOGERROR, "License server returned failure (HTTP error %i)", statusCode); + LOG::Log(LOGERROR, "License server returned failure (HTTP error {})", statusCode); return; } @@ -132,7 +132,9 @@ CClearKeyCencSingleSampleDecrypter::CClearKeyCencSingleSampleDecrypter( if (STRING::KeyExists(keys, hexDefKid)) STRING::ToHexBytes(keys.at(hexDefKid), hexKey); else - LOG::LogF(LOGERROR, "Missing KeyId \"%s\" on DRM configuration", defaultKeyId.data()); + LOG::LogF(LOGERROR, "Missing KeyId \"{}\" on DRM configuration", + std::string_view(reinterpret_cast(defaultKeyId.data()), + defaultKeyId.size())); } AP4_CencSingleSampleDecrypter::Create(AP4_CENC_CIPHER_AES_128_CTR, hexKey.data(), @@ -243,7 +245,7 @@ bool CClearKeyCencSingleSampleDecrypter::ParseLicenseResponse(std::string data) if (keyName == "Message" && jDictVal.IsString()) { - LOG::LogF(LOGERROR, "Error in license response: %s", jDictVal.GetString()); + LOG::LogF(LOGERROR, "Error in license response: {}", jDictVal.GetString()); return false; } diff --git a/src/decrypters/widevine/CdmTypeConversion.cpp b/src/decrypters/widevine/CdmTypeConversion.cpp index 0d6695b83..28e2bcf45 100644 --- a/src/decrypters/widevine/CdmTypeConversion.cpp +++ b/src/decrypters/widevine/CdmTypeConversion.cpp @@ -64,7 +64,7 @@ cdm::VideoCodec media::ToCdmVideoCodec(const VIDEOCODEC_TYPE codec) case VIDEOCODEC_AV1: return cdm::VideoCodec::kCodecAv1; default: - LOG::LogF(LOGWARNING, "Unknown video codec %i", codec); + LOG::LogF(LOGWARNING, "Unknown video codec {}", static_cast(codec)); return cdm::VideoCodec::kUnknownVideoCodec; } } @@ -104,7 +104,7 @@ cdm::VideoCodecProfile media::ToCdmVideoCodecProfile(const STREAMCODEC_PROFILE p case STREAMCODEC_PROFILE::CodecProfileNotNeeded: return cdm::VideoCodecProfile::kProfileNotNeeded; default: - LOG::LogF(LOGWARNING, "Unknown codec profile %i", profile); + LOG::LogF(LOGWARNING, "Unknown codec profile {}", static_cast(profile)); return cdm::VideoCodecProfile::kUnknownVideoCodecProfile; } } @@ -136,7 +136,7 @@ cdm::VideoFormat media::ToCdmVideoFormat(const VIDEOCODEC_FORMAT format) case VIDEOCODEC_FORMAT::VIDEOCODEC_FORMAT_YUV444P12: return cdm::VideoFormat::kYUV444P12; default: - LOG::LogF(LOGWARNING, "Unknown video format %i", format); + LOG::LogF(LOGWARNING, "Unknown video format {}", static_cast(format)); return cdm::VideoFormat::kUnknownVideoFormat; } } @@ -168,7 +168,7 @@ VIDEOCODEC_FORMAT media::ToSSDVideoFormat(const cdm::VideoFormat format) case cdm::VideoFormat::kYUV444P12: return VIDEOCODEC_FORMAT_YUV444P12; default: - LOG::LogF(LOGWARNING, "Unknown video format %i", format); + LOG::LogF(LOGWARNING, "Unknown video format {}", static_cast(format)); return VIDEOCODEC_FORMAT_UNKNOWN; } } diff --git a/src/decrypters/widevine/WVCdmAdapter.cpp b/src/decrypters/widevine/WVCdmAdapter.cpp index 8a295077f..426e5c6c9 100644 --- a/src/decrypters/widevine/WVCdmAdapter.cpp +++ b/src/decrypters/widevine/WVCdmAdapter.cpp @@ -60,7 +60,7 @@ CWVCdmAdapter::CWVCdmAdapter(const DRM::Config& config, CWVDecrypter* host) if (!m_cdmAdapter->valid()) { - LOG::Log(LOGERROR, "Unable to load widevine shared library (%s)", cdmPath.c_str()); + LOG::Log(LOGERROR, "Unable to load widevine shared library ({})", cdmPath.c_str()); m_cdmAdapter = nullptr; return; } @@ -80,7 +80,7 @@ CWVCdmAdapter::~CWVCdmAdapter() if (m_cdmAdapter) { m_cdmAdapter->RemoveClient(); - // LOG::LogF(LOGDEBUG, "CDM Adapter instances: %u", m_cdmAdapter.use_count()); + // LOG::LogF(LOGDEBUG, "CDM Adapter instances: {}", m_cdmAdapter.use_count()); m_cdmAdapter = nullptr; } } @@ -92,7 +92,7 @@ void CWVCdmAdapter::OnCDMMessage(const char* session, size_t data_size, uint32_t status) { - LOG::Log(LOGDEBUG, "CDM message: type %i arrived", msg); + LOG::Log(LOGDEBUG, "CDM message: type {} arrived", static_cast(msg)); CdmMessageType type; if (msg == CDMADPMSG::kSessionMessage) diff --git a/src/decrypters/widevine/WVCencSingleSampleDecrypter.cpp b/src/decrypters/widevine/WVCencSingleSampleDecrypter.cpp index ac11cb1ca..0877edac4 100644 --- a/src/decrypters/widevine/WVCencSingleSampleDecrypter.cpp +++ b/src/decrypters/widevine/WVCencSingleSampleDecrypter.cpp @@ -37,7 +37,7 @@ void CWVCencSingleSampleDecrypter::SetSession(const std::string sessionId, m_strSession = sessionId; m_challenge.SetData(data, dataSize); - LOG::LogF(LOGDEBUG, "Opened widevine session ID: %s", m_strSession.c_str()); + LOG::LogF(LOGDEBUG, "Opened widevine session ID: {}", m_strSession.c_str()); } CWVCencSingleSampleDecrypter::CWVCencSingleSampleDecrypter( @@ -60,7 +60,7 @@ CWVCencSingleSampleDecrypter::CWVCencSingleSampleDecrypter( if (pssh.size() < 4 || pssh.size() > 4096) { - LOG::LogF(LOGERROR, "PSSH init data with length %zu seems not to be cenc init data", + LOG::LogF(LOGERROR, "PSSH init data with length {} seems not to be cenc init data", pssh.size()); return; } @@ -188,7 +188,7 @@ void CWVCencSingleSampleDecrypter::GetCapabilities(const std::vector& k } catch (const std::exception& e) { - LOG::LogF(LOGDEBUG, "Decrypt error, assuming secure path: %s", e.what()); + LOG::LogF(LOGDEBUG, "Decrypt error, assuming secure path: {}", e.what()); caps.flags |= (DecrypterCapabilites::SSD_SECURE_PATH | DecrypterCapabilites::SSD_ANNEXB_REQUIRED); } @@ -209,11 +209,11 @@ void CWVCencSingleSampleDecrypter::CloseSessionId() { if (!m_strSession.empty()) { - LOG::LogF(LOGDEBUG, "Closing widevine session ID: %s", m_strSession.c_str()); + LOG::LogF(LOGDEBUG, "Closing widevine session ID: {}", m_strSession.c_str()); m_cdmAdapter->GetCDM()->CloseSession(++m_promiseId, m_strSession.data(), m_strSession.size()); - LOG::LogF(LOGDEBUG, "Widevine session ID %s closed", m_strSession.c_str()); + LOG::LogF(LOGDEBUG, "Widevine session ID {} closed", m_strSession.c_str()); m_strSession.clear(); } } @@ -294,7 +294,7 @@ bool CWVCencSingleSampleDecrypter::SendSessionMessage() if (statusCode == -1 || statusCode >= 400) { - LOG::Log(LOGERROR, "License server returned failure (HTTP error %i)", statusCode); + LOG::Log(LOGERROR, "License server returned failure (HTTP error {})", statusCode); return false; } @@ -450,7 +450,7 @@ void CWVCencSingleSampleDecrypter::RemovePool(AP4_UI32 poolId) void CWVCencSingleSampleDecrypter::LogDecryptError(const cdm::Status status, const std::vector& keyId) { - LOG::LogF(LOGDEBUG, "Decrypt failed with error code: %d and KID: %s", status, + LOG::LogF(LOGDEBUG, "Decrypt failed with error code: {} and KID: {}", static_cast(status), STRING::ToHexadecimal(keyId).c_str()); } @@ -639,7 +639,7 @@ AP4_Result CWVCencSingleSampleDecrypter::DecryptSampleData(AP4_UI32 poolId, if (nalSize + fragInfo.m_nalLengthSize + nalUnitSum > summedBytes) { - LOG::LogF(LOGERROR, "NAL Unit exceeds subsample definition (nls: %u) %u -> %u ", + LOG::LogF(LOGERROR, "NAL Unit exceeds subsample definition (nls: {}) {} -> {} ", static_cast(fragInfo.m_nalLengthSize), static_cast(nalSize + fragInfo.m_nalLengthSize + nalUnitSum), summedBytes); @@ -652,7 +652,7 @@ AP4_Result CWVCencSingleSampleDecrypter::DecryptSampleData(AP4_UI32 poolId, } if (packetIn != packetInEnd || subsampleCount) { - LOG::Log(LOGERROR, "NAL Unit definition incomplete (nls: %u) %u -> %u ", + LOG::Log(LOGERROR, "NAL Unit definition incomplete (nls: {}) {} -> {} ", static_cast(fragInfo.m_nalLengthSize), static_cast(packetInEnd - packetIn), subsampleCount); return AP4_ERROR_NOT_SUPPORTED; @@ -805,7 +805,7 @@ bool CWVCencSingleSampleDecrypter::OpenVideoDecoder(const VIDEOCODEC_INITDATA* i m_videoFrames.clear(); m_isDrained = true; - LOG::LogF(LOGDEBUG, "Initialization returned status: %s", media::CdmStatusToString(ret).c_str()); + LOG::LogF(LOGDEBUG, "Initialization returned status: {}", media::CdmStatusToString(ret).c_str()); return ret == cdm::Status::kSuccess; } @@ -858,12 +858,12 @@ VIDEOCODEC_RETVAL CWVCencSingleSampleDecrypter::DecryptAndDecodeVideo( } else if (status == cdm::Status::kNoKey) { - LOG::LogF(LOGERROR, "Returned CDM status \"kNoKey\" for KID: %s", + LOG::LogF(LOGERROR, "Returned CDM status \"kNoKey\" for KID: {}", STRING::ToHexadecimal(inputBuffer.key_id, inputBuffer.key_id_size).c_str()); return VC_EOF; } - LOG::LogF(LOGDEBUG, "Returned CDM status: %i", status); + LOG::LogF(LOGDEBUG, "Returned CDM status: {}", static_cast(status)); return VC_ERROR; } diff --git a/src/decrypters/widevine/WVDecrypter.cpp b/src/decrypters/widevine/WVDecrypter.cpp index 963714daf..44ee4ed59 100644 --- a/src/decrypters/widevine/WVDecrypter.cpp +++ b/src/decrypters/widevine/WVDecrypter.cpp @@ -66,7 +66,7 @@ bool CWVDecrypter::Initialize() m_hdlLibLoader = dlopen(binaryPath.c_str(), RTLD_GLOBAL | RTLD_LAZY); if (!m_hdlLibLoader) { - LOG::LogF(LOGERROR, "Failed to load CDM aarch64 loader from path \"%s\", error: %s", + LOG::LogF(LOGERROR, "Failed to load CDM aarch64 loader from path \"{}\", error: {}", binaryPath.c_str(), dlerror()); return false; } diff --git a/src/decrypters/widevineandroid/WVCdmAdapter.cpp b/src/decrypters/widevineandroid/WVCdmAdapter.cpp index acc1d6b4d..3c6439014 100644 --- a/src/decrypters/widevineandroid/WVCdmAdapter.cpp +++ b/src/decrypters/widevineandroid/WVCdmAdapter.cpp @@ -117,7 +117,7 @@ CWVCdmAdapterA::CWVCdmAdapterA(std::string_view keySystem, } LOG::Log(LOGDEBUG, - "MediaDrm initialized (Device unique ID size: %zu, System ID: %s, Security level: %s)", + "MediaDrm initialized (Device unique ID size: {}, System ID: {}, Security level: {})", strDeviceId.size(), strSystemId.c_str(), strSecurityLevel.c_str()); } @@ -181,7 +181,7 @@ void CWVCdmAdapterA::OnMediaDrmEvent(const jni::CJNIMediaDrm& mediaDrm, int extra, const std::vector& data) { - LOG::Log(LOGDEBUG, "MediaDrm event: type %i arrived", event); + LOG::Log(LOGDEBUG, "MediaDrm event: type {} arrived", event); CdmMessageType type; if (event == jni::CJNIMediaDrm::EVENT_KEY_REQUIRED) diff --git a/src/decrypters/widevineandroid/WVCencSingleSampleDecrypter.cpp b/src/decrypters/widevineandroid/WVCencSingleSampleDecrypter.cpp index c91bc7171..36e3471c1 100644 --- a/src/decrypters/widevineandroid/WVCencSingleSampleDecrypter.cpp +++ b/src/decrypters/widevineandroid/WVCencSingleSampleDecrypter.cpp @@ -42,7 +42,7 @@ CWVCencSingleSampleDecrypterA::CWVCencSingleSampleDecrypterA( if (pssh.size() < 4 || pssh.size() > 65535) { - LOG::LogF(LOGERROR, "PSSH init data with length %zu seems not to be cenc init data", + LOG::LogF(LOGERROR, "PSSH init data with length {} seems not to be cenc init data", pssh.size()); return; } @@ -123,7 +123,8 @@ CWVCencSingleSampleDecrypterA::CWVCencSingleSampleDecrypterA( int maxSecuritylevel = m_cdmAdapter->GetCDM()->getMaxSecurityLevel(); xbmc_jnienv()->ExceptionClear(); - LOG::Log(LOGDEBUG, "Session ID: %s, Max security level: %d", m_sessionId.c_str(), maxSecuritylevel); + LOG::Log(LOGDEBUG, "Session ID: {}, Max security level: {}", m_sessionId.c_str(), + maxSecuritylevel); } } @@ -149,7 +150,7 @@ CWVCencSingleSampleDecrypterA::~CWVCencSingleSampleDecrypterA() xbmc_jnienv()->ExceptionClear(); } else - LOG::LogF(LOGDEBUG, "MediaDrm Session ID %s closed", m_sessionId.c_str()); + LOG::LogF(LOGDEBUG, "MediaDrm Session ID {} closed", m_sessionId.c_str()); m_sessionIdVec.clear(); m_sessionId.clear(); @@ -194,7 +195,7 @@ void CWVCencSingleSampleDecrypterA::GetCapabilities(const std::vector& caps.hdcpLimit = m_resolutionLimit; //No restriction caps.flags |= DRM::DecrypterCapabilites::SSD_SECURE_DECODER; } - LOG::LogF(LOGDEBUG, "hdcpLimit: %i", caps.hdcpLimit); + LOG::LogF(LOGDEBUG, "hdcpLimit: {}", caps.hdcpLimit); caps.hdcpVersion = 99; } @@ -212,7 +213,8 @@ void CWVCencSingleSampleDecrypterA::OnNotify(const CdmMessage& message) bool CWVCencSingleSampleDecrypterA::ProvisionRequest() { - LOG::Log(LOGWARNING, "Provision data request (MediaDrm instance: %p)", m_cdmAdapter->GetCDM().get()); + LOG::Log(LOGWARNING, "Provision data request (MediaDrm instance: {:x})", + reinterpret_cast(m_cdmAdapter->GetCDM().get())); jni::CJNIMediaDrmProvisionRequest request = m_cdmAdapter->GetCDM()->getProvisionRequest(); if (xbmc_jnienv()->ExceptionCheck()) @@ -225,7 +227,7 @@ bool CWVCencSingleSampleDecrypterA::ProvisionRequest() std::vector provData = request.getData(); std::string url = request.getDefaultUrl(); - LOG::Log(LOGDEBUG, "Provision data size: %lu, url: %s", provData.size(), url.c_str()); + LOG::Log(LOGDEBUG, "Provision data size: {}, url: {}", provData.size(), url.c_str()); std::string reqData("{\"signedRequest\":\""); reqData += std::string(provData.cbegin(), provData.cend()); @@ -283,7 +285,7 @@ bool CWVCencSingleSampleDecrypterA::GetKeyRequest(std::vector& keyReque } keyRequestData = keyRequest.getData(); - LOG::Log(LOGDEBUG, "Key request successful size: %lu", keyRequestData.size()); + LOG::Log(LOGDEBUG, "Key request successful size: {}", keyRequestData.size()); return true; } @@ -321,14 +323,14 @@ bool CWVCencSingleSampleDecrypterA::KeyUpdateRequest(bool waitKeys, bool skipSes { int securityLevel = m_cdmAdapter->GetCDM()->getSecurityLevel(m_sessionIdVec); xbmc_jnienv()->ExceptionClear(); - LOG::Log(LOGDEBUG, "Security level: %d", securityLevel); + LOG::Log(LOGDEBUG, "Security level: {}", securityLevel); std::map keyStatus = m_cdmAdapter->GetCDM()->queryKeyStatus(m_sessionIdVec); - LOG::Log(LOGDEBUG, "Key status (%ld):", keyStatus.size()); + LOG::Log(LOGDEBUG, "Key status ({}):", keyStatus.size()); for (auto const& ks : keyStatus) { - LOG::Log(LOGDEBUG, "-> %s -> %s", ks.first.c_str(), ks.second.c_str()); + LOG::Log(LOGDEBUG, "-> {} -> {}", ks.first.c_str(), ks.second.c_str()); } } return true; @@ -391,7 +393,7 @@ bool CWVCencSingleSampleDecrypterA::SendSessionMessage(const std::vector= 400) { - LOG::Log(LOGERROR, "License server returned failure (HTTP error %i)", statusCode); + LOG::Log(LOGERROR, "License server returned failure (HTTP error {})", statusCode); return false; } @@ -638,7 +640,7 @@ AP4_Result CWVCencSingleSampleDecrypterA::DecryptSampleData(AP4_UI32 poolId, if (nalsize + fragInfo.m_nalLengthSize + nalUnitSum > summedBytes) { - LOG::LogF(LOGERROR, "NAL Unit exceeds subsample definition (nls: %u) %u -> %u ", + LOG::LogF(LOGERROR, "NAL Unit exceeds subsample definition (nls: {}) {} -> {} ", static_cast(fragInfo.m_nalLengthSize), static_cast(nalsize + fragInfo.m_nalLengthSize + nalUnitSum), summedBytes); @@ -651,7 +653,7 @@ AP4_Result CWVCencSingleSampleDecrypterA::DecryptSampleData(AP4_UI32 poolId, } if (packetIn != packetInEnd || subsampleCount) { - LOG::LogF(LOGERROR, "NAL Unit definition incomplete (nls: %d) %d -> %u ", + LOG::LogF(LOGERROR, "NAL Unit definition incomplete (nls: {}) {} -> {} ", fragInfo.m_nalLengthSize, (int)(packetInEnd - packetIn), subsampleCount); return AP4_ERROR_NOT_SUPPORTED; } diff --git a/src/decrypters/widevineandroid/WVDecrypter.cpp b/src/decrypters/widevineandroid/WVDecrypter.cpp index 0bda81c1b..e956440e5 100644 --- a/src/decrypters/widevineandroid/WVDecrypter.cpp +++ b/src/decrypters/widevineandroid/WVDecrypter.cpp @@ -54,7 +54,7 @@ void JNIThread(JavaVM* vm) std::vector CWVDecrypterA::SelectKeySystems(std::string_view keySystem) { - LOG::Log(LOGDEBUG, "Key system request: %s", keySystem); + LOG::Log(LOGDEBUG, "Key system request: {}", keySystem); if (keySystem == KS_WIDEVINE) { @@ -173,7 +173,7 @@ bool CWVDecrypterA::Initialize() //JNIEnv* env = static_cast(m_androidSystem.GetJNIEnv()); CJNIBase::SetSDKVersion(m_androidSystem.GetSDKVersion()); CJNIBase::SetBaseClassName(m_androidSystem.GetClassName()); - LOG::Log(LOGDEBUG, "WVDecrypter JNI, SDK version: %d", m_androidSystem.GetSDKVersion()); + LOG::Log(LOGDEBUG, "WVDecrypter JNI, SDK version: {}", m_androidSystem.GetSDKVersion()); const char* apkEnv = getenv("XBMC_ANDROID_APK"); if (!apkEnv) diff --git a/src/demuxers/TSReader.cpp b/src/demuxers/TSReader.cpp index 5584c7a28..4aa3c95b4 100644 --- a/src/demuxers/TSReader.cpp +++ b/src/demuxers/TSReader.cpp @@ -29,18 +29,18 @@ void DebugLog(int level, char* msg) switch (level) { case DEMUX_DBG_ERROR: - LOG::Log(LOGERROR, msg); + LOG::Log(LOGERROR, "{}", msg); break; case DEMUX_DBG_WARN: - LOG::Log(LOGWARNING, msg); + LOG::Log(LOGWARNING, "{}", msg); break; case DEMUX_DBG_INFO: - LOG::Log(LOGINFO, msg); + LOG::Log(LOGINFO, "{}", msg); break; case DEMUX_DBG_DEBUG: [[fallthrough]]; case DEMUX_DBG_PARSE: - LOG::Log(LOGDEBUG, msg); + LOG::Log(LOGDEBUG, "{}", msg); break; default: break; diff --git a/src/main.cpp b/src/main.cpp index 0552d0593..cf16ddff9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -74,7 +74,7 @@ bool CInputStreamAdaptive::GetStreamIds(std::vector& ids) CStream* stream = m_session->GetStream(i); if (!stream) { - LOG::LogF(LOGERROR, "Cannot get the stream from sid %u", i); + LOG::LogF(LOGERROR, "Cannot get the stream from sid {}", i); continue; } @@ -128,7 +128,7 @@ void CInputStreamAdaptive::GetCapabilities(kodi::addon::InputstreamCapabilities& bool CInputStreamAdaptive::GetStream(int streamid, kodi::addon::InputstreamInfo& info) { // GetStream is called by Kodi twice times, before and after OpenStream. - LOG::Log(LOGDEBUG, "GetStream(%d)", streamid); + LOG::Log(LOGDEBUG, "GetStream({})", streamid); // Return false prevents this stream from loading, but does not stop playback, // Kodi core will continue to request another stream of same type (a/v) @@ -153,7 +153,7 @@ void CInputStreamAdaptive::UnlinkIncludedStreams(CStream* stream) void CInputStreamAdaptive::EnableStream(int streamid, bool enable) { - LOG::Log(LOGDEBUG, "EnableStream(%d: %s)", streamid, enable ? "true" : "false"); + LOG::Log(LOGDEBUG, "EnableStream({}: {})", streamid, enable ? "true" : "false"); if (!m_session) return; @@ -171,7 +171,7 @@ void CInputStreamAdaptive::EnableStream(int streamid, bool enable) // to allow Kodi demuxer to reset with our changes the stream properties. bool CInputStreamAdaptive::OpenStream(int streamid) { - LOG::Log(LOGDEBUG, "OpenStream(%d)", streamid); + LOG::Log(LOGDEBUG, "OpenStream({})", streamid); // This method can be called when: // - Stream first start // - Chapter/period change @@ -284,7 +284,7 @@ bool CInputStreamAdaptive::OpenStream(int streamid) CStream* incStream = m_session->GetStream(sid); if (!incStream) { - LOG::LogF(LOGERROR, "Cannot get the stream from sid %u", sid); + LOG::LogF(LOGERROR, "Cannot get the stream from sid {}", sid); } else { @@ -300,7 +300,7 @@ bool CInputStreamAdaptive::OpenStream(int streamid) if (stream->m_isEncrypted && m_session->IsCDMSessionSecurePath(cdmSessionIndex)) { - LOG::Log(LOGDEBUG, "OpenStream(%d): Create secure crypto session", streamid); + LOG::Log(LOGDEBUG, "OpenStream({}): Create secure crypto session", streamid); // StreamCryptoSession enable the use of ISA VideoCodecAdaptive decoder kodi::addon::StreamCryptoSession cryptoSession; @@ -339,7 +339,7 @@ DEMUX_PACKET* CInputStreamAdaptive::DemuxRead(void) if (~m_failedSeekTime) { - LOG::Log(LOGDEBUG, "Seeking to last failed seek position (%d)", m_failedSeekTime); + LOG::Log(LOGDEBUG, "Seeking to last failed seek position ({})", m_failedSeekTime); m_session->SeekTime(static_cast(m_failedSeekTime) * 0.001f, 0, false); m_failedSeekTime = ~0; } @@ -402,7 +402,7 @@ DEMUX_PACKET* CInputStreamAdaptive::DemuxRead(void) std::memcpy(p->pData, pData, iSize); } - //LOG::Log(LOGDEBUG, "DTS: %0.4f, PTS:%0.4f, ID: %u SZ: %d", p->dts, p->pts, p->iStreamId, p->iSize); + //LOG::Log(LOGDEBUG, "DTS: {:0.4f}, PTS:{:0.4f}, ID: {} SZ: {}", p->dts, p->pts, p->iStreamId, p->iSize); // Start reading the next sample sr->ReadSampleAsync(); @@ -460,7 +460,7 @@ bool CInputStreamAdaptive::PosTime(int ms) if (!m_session) return false; - LOG::Log(LOGINFO, "PosTime (%d)", ms); + LOG::Log(LOGINFO, "PosTime ({})", ms); bool ret = m_session->SeekTime(static_cast(ms) * 0.001f, 0, false); m_failedSeekTime = ret ? ~0 : ms; diff --git a/src/parser/DASHTree.cpp b/src/parser/DASHTree.cpp index 17cce2bdd..09b4f7de5 100644 --- a/src/parser/DASHTree.cpp +++ b/src/parser/DASHTree.cpp @@ -165,7 +165,8 @@ bool adaptive::CDashTree::ParseManifest(const std::string& data) xml_parse_result parseRes = doc.load_buffer(data.c_str(), data.size()); if (parseRes.status != status_ok) { - LOG::LogF(LOGERROR, "Failed to parse the manifest file, error code: %i", parseRes.status); + LOG::LogF(LOGERROR, "Failed to parse the manifest file, error code: {}", + static_cast(parseRes.status)); return false; } @@ -501,7 +502,7 @@ void adaptive::CDashTree::ParseTagAdaptationSet(pugi::xml_node nodeAdp, PLAYLIST if (adpSet->GetContainerType() == ContainerType::NOTYPE) { - LOG::LogF(LOGWARNING, "Skipped AdaptationSet with id: \"%s\", container type not specified.", + LOG::LogF(LOGWARNING, "Skipped AdaptationSet with id: \"{}\", container type not specified.", adpSet->GetId().data()); return; } @@ -657,7 +658,7 @@ void adaptive::CDashTree::ParseTagAdaptationSet(pugi::xml_node nodeAdp, PLAYLIST if (adpSet->GetRepresentations().empty()) { - LOG::LogF(LOGWARNING, "Skipped AdaptationSet with id: \"%s\", has no representations.", + LOG::LogF(LOGWARNING, "Skipped AdaptationSet with id: \"{}\", has no representations.", adpSet->GetId().data()); return; } @@ -717,7 +718,7 @@ void adaptive::CDashTree::ParseTagRepresentation(pugi::xml_node nodeRepr, if (repr->GetCodecs().empty()) { LOG::LogF(LOGWARNING, - "Cannot get codecs for representation with id: \"%s\". Representation skipped.", + "Cannot get codecs for representation with id: \"{}\". Representation skipped.", repr->GetId().data()); return; } @@ -959,7 +960,7 @@ void adaptive::CDashTree::ParseTagRepresentation(pugi::xml_node nodeRepr, if (psshSetPos == PSSHSET_POS_INVALID) { - LOG::LogF(LOGWARNING, "Skipped representation with id: \"%s\", due to not valid PSSH", + LOG::LogF(LOGWARNING, "Skipped representation with id: \"{}\", due to not valid PSSH", repr->GetId().data()); return; } @@ -1513,7 +1514,7 @@ uint32_t adaptive::CDashTree::ParseAudioChannelConfig(pugi::xml_node node) } if (channels == 0) { - LOG::LogF(LOGWARNING, "Cannot parse channel configuration \"%s\", fallback to 2 channels.", + LOG::LogF(LOGWARNING, "Cannot parse channel configuration \"{}\", fallback to 2 channels.", schemeIdUri.data()); channels = 2; } @@ -1670,7 +1671,7 @@ void adaptive::CDashTree::OnUpdateSegments() // new period, insert it if (!period) { - LOG::LogF(LOGDEBUG, "Inserting new Period (id=%s, start=%llu)", updPeriod->GetId().data(), + LOG::LogF(LOGDEBUG, "Inserting new Period (id={}, start={})", updPeriod->GetId().data(), updPeriod->GetStart()); updPeriod->SetSequence(m_periodCurrentSeq++); @@ -1715,7 +1716,7 @@ void adaptive::CDashTree::OnUpdateSegments() { LOG::LogF(LOGWARNING, "MPD update - Updated timeline has no segments " - "(repr. id \"%s\", period id \"%s\")", + "(repr. id \"{}\", period id \"{}\")", repr->GetId().data(), period->GetId().data()); continue; } @@ -1732,7 +1733,7 @@ void adaptive::CDashTree::OnUpdateSegments() repr->Timeline().Get(0)->startPTS_ == updRepr->Timeline().Get(0)->startPTS_) { LOG::LogF(LOGDEBUG, - "MPD update - No new segments (repr. id \"%s\", period id \"%s\")", + "MPD update - No new segments (repr. id \"{}\", period id \"{}\")", repr->GetId().data(), period->GetId().data()); continue; } @@ -1755,9 +1756,9 @@ void adaptive::CDashTree::OnUpdateSegments() const uint64_t segNumber = repr->current_segment_->m_number; foundSeg = &segment; LOG::LogF(LOGDEBUG, - "MPD update - Misaligned: current seg [PTS %llu, Number: %llu] " - "found [PTS %llu, Number %llu] " - "(repr. id \"%s\", period id \"%s\")", + "MPD update - Misaligned: current seg [PTS {}, Number: {}] " + "found [PTS {}, Number {}] " + "(repr. id \"{}\", period id \"{}\")", segStartPTS, segNumber, segment.startPTS_, segment.m_number, repr->GetId().data(), period->GetId().data()); break; @@ -1767,7 +1768,7 @@ void adaptive::CDashTree::OnUpdateSegments() if (!foundSeg) { LOG::LogF(LOGDEBUG, - "MPD update - No segment found (repr. id \"%s\", period id \"%s\")", + "MPD update - No segment found (repr. id \"{}\", period id \"{}\")", repr->GetId().data(), period->GetId().data()); } else @@ -1775,7 +1776,7 @@ void adaptive::CDashTree::OnUpdateSegments() repr->Timeline().Swap(updRepr->Timeline()); repr->current_segment_ = foundSeg; - LOG::LogF(LOGDEBUG, "MPD update - Done (repr. id \"%s\", period id \"%s\")", + LOG::LogF(LOGDEBUG, "MPD update - Done (repr. id \"{}\", period id \"{}\")", updRepr->GetId().data(), period->GetId().data()); } } @@ -1783,7 +1784,7 @@ void adaptive::CDashTree::OnUpdateSegments() if (repr->IsWaitForSegment() && repr->GetNextSegment()) { repr->SetIsWaitForSegment(false); - LOG::LogF(LOGDEBUG, "End WaitForSegment repr. id %s", repr->GetId().data()); + LOG::LogF(LOGDEBUG, "End WaitForSegment repr. id {}", repr->GetId().data()); } m_totalTime = updateTree->m_totalTime; @@ -1841,7 +1842,7 @@ bool adaptive::CDashTree::InsertLiveSegment(PLAYLIST::CPeriod* period, if (!segment) { - LOG::LogF(LOGERROR, "Segment at position %zu not found from representation id: %s", pos, + LOG::LogF(LOGERROR, "Segment at position {} not found from representation id: {}", pos, repr->GetId().data()); return false; } @@ -1853,7 +1854,7 @@ bool adaptive::CDashTree::InsertLiveSegment(PLAYLIST::CPeriod* period, segCopy.m_time = segCopy.m_endPts; segCopy.m_number++; - LOG::LogF(LOGDEBUG, "Insert live segment to adptation set \"%s\" (Start PTS: %llu, number: %llu)", + LOG::LogF(LOGDEBUG, "Insert live segment to adptation set \"{}\" (Start PTS: {}, number: {})", adpSet->GetId().data(), segCopy.startPTS_, segCopy.m_number); for (auto& repr : adpSet->GetRepresentations()) @@ -1878,7 +1879,7 @@ bool adaptive::CDashTree::InsertLiveFragment(PLAYLIST::CAdaptationSet* adpSet, if (!lastSeg) return false; - LOG::Log(LOGDEBUG, "Fragment info - timestamp: %llu, duration: %llu, timescale: %u", fTimestamp, + LOG::Log(LOGDEBUG, "Fragment info - timestamp: {}, duration: {}, timescale: {}", fTimestamp, fDuration, fTimescale); const uint64_t fStartPts = @@ -1898,7 +1899,7 @@ bool adaptive::CDashTree::InsertLiveFragment(PLAYLIST::CAdaptationSet* adpSet, segCopy.m_time = segCopy.startPTS_; segCopy.m_number++; - LOG::Log(LOGDEBUG, "Insert fragment to adaptation set \"%s\" (PTS: %llu, number: %llu)", + LOG::Log(LOGDEBUG, "Insert fragment to adaptation set \"{}\" (PTS: {}, number: {})", adpSet->GetId().data(), segCopy.startPTS_, segCopy.m_number); for (auto& repr : adpSet->GetRepresentations()) diff --git a/src/parser/HLSTree.cpp b/src/parser/HLSTree.cpp index 12fe178fd..67222903e 100644 --- a/src/parser/HLSTree.cpp +++ b/src/parser/HLSTree.cpp @@ -216,7 +216,7 @@ bool adaptive::CHLSTree::DownloadChildManifest(PLAYLIST::CAdaptationSet* adp, { if (rep->GetSourceUrl().empty()) { - LOG::LogF(LOGERROR, "Cannot download child manifest, no source url on representation id \"%s\"", + LOG::LogF(LOGERROR, "Cannot download child manifest, no source url on representation id \"{}\"", rep->GetId().data()); return false; } @@ -284,14 +284,14 @@ void adaptive::CHLSTree::FixMediaSequence(std::stringstream& streamData, if (mediaSeqNumber != mediaSeqNumberFix) { - LOG::Log(LOGWARNING, "Inconsistent EXT-X-MEDIA-SEQUENCE of %llu, corrected to %llu", + LOG::Log(LOGWARNING, "Inconsistent EXT-X-MEDIA-SEQUENCE of {}, corrected to {}", mediaSeqNumber, mediaSeqNumberFix); mediaSeqNumber = mediaSeqNumberFix; } } else { - LOG::Log(LOGERROR, "Inconsistent EXT-X-MEDIA-SEQUENCE of %llu, cannot be corrected"); + LOG::Log(LOGERROR, "Inconsistent EXT-X-MEDIA-SEQUENCE of {}, cannot be corrected", mediaSeqNumber); } } @@ -410,7 +410,7 @@ void adaptive::CHLSTree::FixDiscSequence(std::stringstream& streamData, uint32_t if (discSeqNumber != discSeqNumberFix) { - LOG::Log(LOGWARNING, "Inconsistent EXT-X-DISCONTINUITY-SEQUENCE of %u, corrected to %u", + LOG::Log(LOGWARNING, "Inconsistent EXT-X-DISCONTINUITY-SEQUENCE of {}, corrected to {}", discSeqNumber, discSeqNumberFix); discSeqNumber = discSeqNumberFix; } @@ -769,12 +769,12 @@ bool adaptive::CHLSTree::ProcessChildManifest(PLAYLIST::CPeriod* period, auto& pCurrRep = pCurrAdp->GetRepresentations()[reprPos]; pCurrRep->Timeline().Clear(); pCurrRep->current_segment_ = nullptr; - LOG::Log(LOGDEBUG, "Clear outdated period of discontinuity %u", + LOG::Log(LOGDEBUG, "Clear outdated period of discontinuity {}", itPeriod->get()->GetSequence()); } else { - LOG::Log(LOGDEBUG, "Deleted period of discontinuity %u", + LOG::Log(LOGDEBUG, "Deleted period of discontinuity {}", itPeriod->get()->GetSequence()); itPeriod = m_periods.erase(itPeriod); continue; @@ -792,7 +792,7 @@ bool adaptive::CHLSTree::ProcessChildManifest(PLAYLIST::CPeriod* period, } else { - LOG::LogF(LOGERROR, "Period of discontinuity %u not found, attempt to advance to the next", + LOG::LogF(LOGERROR, "Period of discontinuity {} not found, attempt to advance to the next", discontSeq); isSkipUntilDiscont = true; } @@ -975,7 +975,7 @@ void adaptive::CHLSTree::PrepareSegments(PLAYLIST::CPeriod* period, if (rep->IsWaitForSegment() && (rep->GetNextSegment() || m_currentPeriod != m_periods.back().get())) { - LOG::LogF(LOGDEBUG, "End WaitForSegment stream id \"%s\"", rep->GetId().data()); + LOG::LogF(LOGDEBUG, "End WaitForSegment stream id \"{}\"", rep->GetId().data()); rep->SetIsWaitForSegment(false); } } @@ -997,7 +997,7 @@ void adaptive::CHLSTree::OnDataArrived(uint64_t segNum, if (psshSet >= psshSets.size()) { - LOG::LogF(LOGERROR, "Cannot get PSSHSet at position %u", psshSet); + LOG::LogF(LOGERROR, "Cannot get PSSHSet at position {}", psshSet); return; } @@ -1369,7 +1369,7 @@ PLAYLIST::EncryptionType adaptive::CHLSTree::ProcessEncryption( } // Unsupported encryption - LOG::Log(LOGDEBUG, "Unsupported EXT-X-KEY keyformat \"%s\"", keyFormat.c_str()); + LOG::Log(LOGDEBUG, "Unsupported EXT-X-KEY keyformat \"{}\"", keyFormat.c_str()); return EncryptionType::NOT_SUPPORTED; } @@ -1394,7 +1394,7 @@ bool adaptive::CHLSTree::GetUriByteData(std::string_view uri, std::vectorm_codecs); else - LOG::LogF(LOGERROR, "Cannot find variant for AUDIO GROUP-ID: %s", r.m_groupId.c_str()); + LOG::LogF(LOGERROR, "Cannot find variant for AUDIO GROUP-ID: {}", r.m_groupId.c_str()); if (codecStr.empty()) codecStr = CODEC::FOURCC_MP4A; // Fallback @@ -1729,7 +1729,7 @@ bool adaptive::CHLSTree::ParseMultivariantPlaylist(const std::string& data) if (rFound) r = *rFound; else - LOG::LogF(LOGWARNING, "Undefined GROUP-ID \"%s\" in EXT-X-STREAM-INF variant", + LOG::LogF(LOGWARNING, "Undefined GROUP-ID \"{}\" in EXT-X-STREAM-INF variant", var.m_groupIdAudio.c_str()); } diff --git a/src/parser/SmoothTree.cpp b/src/parser/SmoothTree.cpp index 2ff2a8226..36338e62b 100644 --- a/src/parser/SmoothTree.cpp +++ b/src/parser/SmoothTree.cpp @@ -65,7 +65,8 @@ bool adaptive::CSmoothTree::ParseManifest(const std::string& data) xml_parse_result parseRes = doc.load_buffer(data.c_str(), data.size()); if (parseRes.status != status_ok) { - LOG::LogF(LOGERROR, "Failed to parse the manifest file, error code: %i", parseRes.status); + LOG::LogF(LOGERROR, "Failed to parse the manifest file, error code: {}", + static_cast(parseRes.status)); return false; } @@ -156,7 +157,8 @@ void adaptive::CSmoothTree::ParseTagStreamIndex(pugi::xml_node nodeSI, if (subtype == "ZOET" || // Trick mode subtype == "CHAP") // Chapter headings { - LOG::LogF(LOGDEBUG, "Skipped tag, Subtype \"%s\" not supported.", subtype.data()); + LOG::LogF(LOGDEBUG, "Skipped tag, Subtype \"{}\" not supported.", + subtype.data()); return; } adpSet->SetStreamType(StreamType::VIDEO); @@ -174,7 +176,7 @@ void adaptive::CSmoothTree::ParseTagStreamIndex(pugi::xml_node nodeSI, subtype == "DATA" || // Application data subtype == "ADI3") // ADS sparse tracks { - LOG::LogF(LOGDEBUG, "Skipped tag, Subtype \"%s\" not supported.", + LOG::LogF(LOGDEBUG, "Skipped tag, Subtype \"{}\" not supported.", subtype.data()); return; } @@ -210,13 +212,13 @@ void adaptive::CSmoothTree::ParseTagStreamIndex(pugi::xml_node nodeSI, if (!STRING::Contains(url, "{start time}", false)) { LOG::LogF(LOGERROR, - "Skipped tag, {start time} placeholder is missing in the url."); + "Skipped tag, {{start time}} placeholder is missing in the url."); return; } if (!STRING::Contains(url, "{bitrate}", false)) { LOG::LogF(LOGERROR, - "Skipped tag, {bitrate} placeholder is missing in the url."); + "Skipped tag, {{bitrate}} placeholder is missing in the url."); return; } adpSet->SetBaseUrl(URL::Join(base_url_, url.data())); @@ -428,8 +430,7 @@ bool adaptive::CSmoothTree::InsertLiveFragment(PLAYLIST::CAdaptationSet* adpSet, if (!lastSeg) return false; - LOG::Log(LOGDEBUG, - "Fragment info - timestamp: %llu, duration: %llu, timescale: %u (PTS base: %llu)", + LOG::Log(LOGDEBUG, "Fragment info - timestamp: {}, duration: {}, timescale: {} (PTS base: {})", fTimestamp, fDuration, fTimescale, m_ptsBase); const uint64_t fStartPts = @@ -450,7 +451,7 @@ bool adaptive::CSmoothTree::InsertLiveFragment(PLAYLIST::CAdaptationSet* adpSet, segCopy.m_time = fTimestamp; segCopy.m_number++; - LOG::Log(LOGDEBUG, "Insert fragment to adaptation set \"%s\" (PTS: %llu, number: %llu)", + LOG::Log(LOGDEBUG, "Insert fragment to adaptation set \"{}\" (PTS: {}, number: {})", adpSet->GetId().data(), segCopy.startPTS_, segCopy.m_number); for (auto& repr : adpSet->GetRepresentations()) diff --git a/src/samplereader/FragmentedSampleReader.cpp b/src/samplereader/FragmentedSampleReader.cpp index a8fafcb97..b497d716c 100644 --- a/src/samplereader/FragmentedSampleReader.cpp +++ b/src/samplereader/FragmentedSampleReader.cpp @@ -301,7 +301,7 @@ bool CFragmentedSampleReader::GetFragmentInfo(uint64_t& duration) duration = fragSampleTable->GetDuration(); else { - LOG::LogF(LOGERROR, "Can't get FragmentSampleTable from track %u", m_track->GetId()); + LOG::LogF(LOGERROR, "Can't get FragmentSampleTable from track {}", m_track->GetId()); return false; } return true; @@ -323,11 +323,12 @@ AP4_Result CFragmentedSampleReader::ProcessMoof(AP4_ContainerAtom* moof, if (m_track->GetId() == AP4_TRACK_ID_UNKNOWN) { m_track->SetId(ids[0]); - LOG::LogF(LOGDEBUG, "Track ID changed from UNKNOWN to %u", ids[0]); + LOG::LogF(LOGDEBUG, "Track ID changed from UNKNOWN to {}", ids[0]); } else if (ids[0] != m_track->GetId()) { - LOG::LogF(LOGDEBUG, "Track ID does not match! Expected: %u Got: %u", m_track->GetId(), ids[0]); + LOG::LogF(LOGDEBUG, "Track ID does not match! Expected: {} Got: {}", m_track->GetId(), + ids[0]); return AP4_ERROR_NO_SUCH_ITEM; } } @@ -459,7 +460,7 @@ AP4_Result CFragmentedSampleReader::ProcessMoof(AP4_ContainerAtom* moof, else if (schemeType == AP4_PROTECTION_SCHEME_TYPE_CBC1 || schemeType == AP4_PROTECTION_SCHEME_TYPE_CENS) { - LOG::LogF(LOGERROR, "Protection scheme %u not implemented.", schemeType); + LOG::LogF(LOGERROR, "Protection scheme {} not implemented.", schemeType); } } } @@ -485,7 +486,7 @@ void CFragmentedSampleReader::UpdateSampleDescription() AP4_SampleDescription* desc = m_track->GetSampleDescription(m_sampleDescIndex - 1); if (!desc) { - LOG::LogF(LOGERROR, "Cannot get sample description from index %u", m_sampleDescIndex - 1); + LOG::LogF(LOGERROR, "Cannot get sample description from index {}", m_sampleDescIndex - 1); return; } @@ -500,9 +501,9 @@ void CFragmentedSampleReader::UpdateSampleDescription() } } - LOG::LogF(LOGDEBUG, "Codec fourcc: %s (%u)", CODEC::FourCCToString(desc->GetFormat()).c_str(), + LOG::LogF(LOGDEBUG, "Codec fourcc: {} ({})", CODEC::FourCCToString(desc->GetFormat()).c_str(), desc->GetFormat()); - + if (AP4_DYNAMIC_CAST(AP4_AudioSampleDescription, desc)) { // Audio sample of any format @@ -575,7 +576,7 @@ void CFragmentedSampleReader::ParseTrafTfrf(AP4_UuidAtom* uuidAtom) } else { - LOG::LogF(LOGWARNING, "Version %u of TFRF atom fragment is not supported.", version); + LOG::LogF(LOGWARNING, "Version {} of TFRF atom fragment is not supported.", version); return; } m_observer->OnTFRFatom(time, duration, m_track->GetMediaTimeScale()); diff --git a/src/samplereader/SubtitleSampleReader.cpp b/src/samplereader/SubtitleSampleReader.cpp index dc9af7785..2099d78e2 100644 --- a/src/samplereader/SubtitleSampleReader.cpp +++ b/src/samplereader/SubtitleSampleReader.cpp @@ -43,7 +43,7 @@ bool CSubtitleSampleReader::Initialize(SESSION::CStream* stream) m_codecHandler = std::make_unique(nullptr, true); else { - LOG::LogF(LOGERROR, "Codec \"%s\" not implemented", codecInternalName.data()); + LOG::LogF(LOGERROR, "Codec \"{}\" not implemented", codecInternalName.data()); return false; } @@ -63,7 +63,7 @@ bool CSubtitleSampleReader::Initialize(SESSION::CStream* stream) m_codecHandler = std::make_unique(nullptr, false); else { - LOG::LogF(LOGERROR, "Codec \"%s\" not implemented", codecInternalName.data()); + LOG::LogF(LOGERROR, "Codec \"{}\" not implemented", codecInternalName.data()); return false; } return true; @@ -83,12 +83,12 @@ bool CSubtitleSampleReader::InitializeFile(std::string url) int statusCode = curl.Open(); if (statusCode == -1) { - LOG::Log(LOGERROR, "Download failed, internal error: %s", url.c_str()); + LOG::Log(LOGERROR, "Download failed, internal error: {}", url.c_str()); return false; } else if (statusCode >= 400) { - LOG::Log(LOGERROR, "Download failed, HTTP error %d: %s", statusCode, url.c_str()); + LOG::Log(LOGERROR, "Download failed, HTTP error {}: {}", statusCode, url.c_str()); return false; } @@ -96,7 +96,7 @@ bool CSubtitleSampleReader::InitializeFile(std::string url) if (curl.Read(data) != CURL::ReadStatus::IS_EOF) { - LOG::Log(LOGERROR, "Download failed: %s", statusCode, url.c_str()); + LOG::Log(LOGERROR, "Download failed: {}", statusCode, url.c_str()); return false; } diff --git a/src/test/TestDASHTree.cpp b/src/test/TestDASHTree.cpp index 1ca45f2f2..c6dd109a8 100644 --- a/src/test/TestDASHTree.cpp +++ b/src/test/TestDASHTree.cpp @@ -59,7 +59,7 @@ class DASHTreeTest : public ::testing::Test UTILS::CURL::HTTPResponse resp; if (!testHelper::DownloadFile(url, {}, {}, resp)) { - LOG::Log(LOGERROR, "Cannot download \"%s\" DASH manifest file.", url.c_str()); + LOG::Log(LOGERROR, "Cannot download \"{}\" DASH manifest file.", url.c_str()); exit(1); } @@ -74,7 +74,7 @@ class DASHTreeTest : public ::testing::Test // Parse the manifest if (!tree->Open(resp.effectiveUrl, resp.headers, resp.data)) { - LOG::Log(LOGERROR, "Cannot open \"%s\" DASH manifest.", url.c_str()); + LOG::Log(LOGERROR, "Cannot open \"{}\" DASH manifest.", url.c_str()); exit(1); } tree->PostOpen(); diff --git a/src/test/TestHLSTree.cpp b/src/test/TestHLSTree.cpp index e53d53030..210b11e6a 100644 --- a/src/test/TestHLSTree.cpp +++ b/src/test/TestHLSTree.cpp @@ -55,7 +55,7 @@ class HLSTreeTest : public ::testing::Test UTILS::CURL::HTTPResponse resp; if (!testHelper::DownloadFile(url, {}, {}, resp)) { - LOG::Log(LOGERROR, "Cannot download \"%s\" DASH manifest file.", url.c_str()); + LOG::Log(LOGERROR, "Cannot download \"{}\" DASH manifest file.", url.c_str()); return false; } @@ -69,7 +69,7 @@ class HLSTreeTest : public ::testing::Test // Parse the manifest if (!tree->Open(resp.effectiveUrl, resp.headers, resp.data)) { - LOG::Log(LOGERROR, "Cannot open \"%s\" HLS manifest.", url.c_str()); + LOG::Log(LOGERROR, "Cannot open \"{}\" HLS manifest.", url.c_str()); return false; } diff --git a/src/test/TestHelper.cpp b/src/test/TestHelper.cpp index 021815700..7abc4f954 100644 --- a/src/test/TestHelper.cpp +++ b/src/test/TestHelper.cpp @@ -22,7 +22,7 @@ bool testHelper::LoadFile(std::string path, std::string& data) FILE* f = fopen(path.c_str(), "rb"); if (!f) { - LOG::LogF(LOGERROR, "Failed open file %s", path.c_str()); + LOG::LogF(LOGERROR, "Failed open file {}", path.c_str()); return false; } diff --git a/src/test/TestSmoothTree.cpp b/src/test/TestSmoothTree.cpp index 8126378a2..dd3b50aad 100644 --- a/src/test/TestSmoothTree.cpp +++ b/src/test/TestSmoothTree.cpp @@ -50,7 +50,7 @@ class SmoothTreeTest : public ::testing::Test UTILS::CURL::HTTPResponse resp; if (!testHelper::DownloadFile(url, {}, {}, resp)) { - LOG::Log(LOGERROR, "Cannot download \"%s\" DASH manifest file.", url.c_str()); + LOG::Log(LOGERROR, "Cannot download \"{}\" DASH manifest file.", url.c_str()); exit(1); } @@ -64,7 +64,7 @@ class SmoothTreeTest : public ::testing::Test // Parse the manifest if (!tree->Open(resp.effectiveUrl, resp.headers, resp.data)) { - LOG::Log(LOGERROR, "Cannot open \"%s\" Smooth Streaming manifest.", url.c_str()); + LOG::Log(LOGERROR, "Cannot open \"{}\" Smooth Streaming manifest.", url.c_str()); exit(1); } tree->PostOpen(); diff --git a/src/utils/CharArrayParser.cpp b/src/utils/CharArrayParser.cpp index b92e05fea..e1d6881e3 100644 --- a/src/utils/CharArrayParser.cpp +++ b/src/utils/CharArrayParser.cpp @@ -42,7 +42,7 @@ bool UTILS::CCharArrayParser::SetPosition(size_t position) m_position = position; else { - LOG::LogF(LOGERROR, "{} - Position out of range"); + LOG::LogF(LOGERROR, "Position out of range"); return false; } return true; @@ -58,11 +58,11 @@ uint8_t UTILS::CCharArrayParser::ReadNextUnsignedChar() m_position++; if (!m_data) { - LOG::LogF(LOGERROR, "{} - No data to read"); + LOG::LogF(LOGERROR, "No data to read"); return 0; } if (m_position > m_limit) - LOG::LogF(LOGERROR, "{} - Position out of range"); + LOG::LogF(LOGERROR, "Position out of range"); return static_cast(m_data[m_position - 1]) & 0xFF; } @@ -70,12 +70,12 @@ uint16_t UTILS::CCharArrayParser::ReadNextUnsignedShort() { if (!m_data) { - LOG::LogF(LOGERROR, "{} - No data to read"); + LOG::LogF(LOGERROR, "No data to read"); return 0; } m_position += 2; if (m_position > m_limit) - LOG::LogF(LOGERROR, "{} - Position out of range"); + LOG::LogF(LOGERROR, "Position out of range"); return (static_cast(m_data[m_position - 2]) & 0xFF) << 8 | (static_cast(m_data[m_position - 1]) & 0xFF); } @@ -84,12 +84,12 @@ uint16_t UTILS::CCharArrayParser::ReadLENextUnsignedShort() { if (!m_data) { - LOG::LogF(LOGERROR, "{} - No data to read"); + LOG::LogF(LOGERROR, "No data to read"); return 0; } m_position += 2; if (m_position > m_limit) - LOG::LogF(LOGERROR, "{} - Position out of range"); + LOG::LogF(LOGERROR, "Position out of range"); return (static_cast(m_data[m_position - 2]) & 0xFF) | (static_cast(m_data[m_position - 1]) & 0xFF) << 8; } @@ -98,12 +98,12 @@ uint32_t UTILS::CCharArrayParser::ReadNextUnsignedInt24() { if (!m_data) { - LOG::LogF(LOGERROR, "{} - No data to read"); + LOG::LogF(LOGERROR, "No data to read"); return 0; } m_position += 3; if (m_position > m_limit) - LOG::LogF(LOGERROR, "{} - Position out of range"); + LOG::LogF(LOGERROR, "Position out of range"); return (static_cast(m_data[m_position - 3]) & 0xFF) << 16 | (static_cast(m_data[m_position - 2]) & 0xFF) << 8 | (static_cast(m_data[m_position - 1]) & 0xFF); @@ -113,12 +113,12 @@ uint32_t UTILS::CCharArrayParser::ReadNextUnsignedInt() { if (!m_data) { - LOG::LogF(LOGERROR, "{} - No data to read"); + LOG::LogF(LOGERROR, "No data to read"); return 0; } m_position += 4; if (m_position > m_limit) - LOG::LogF(LOGERROR, "{} - Position out of range"); + LOG::LogF(LOGERROR, "Position out of range"); return (static_cast(m_data[m_position - 4]) & 0xFF) << 24 | (static_cast(m_data[m_position - 3]) & 0xFF) << 16 | (static_cast(m_data[m_position - 2]) & 0xFF) << 8 | @@ -129,12 +129,12 @@ uint32_t UTILS::CCharArrayParser::ReadNextLEUnsignedInt() { if (!m_data) { - LOG::LogF(LOGERROR, "{} - No data to read"); + LOG::LogF(LOGERROR, "No data to read"); return 0; } m_position += 4; if (m_position > m_limit) - LOG::LogF(LOGERROR, "{} - Position out of range"); + LOG::LogF(LOGERROR, "Position out of range"); return (static_cast(m_data[m_position - 4]) & 0xFF) | (static_cast(m_data[m_position - 3]) & 0xFF) << 8 | (static_cast(m_data[m_position - 2]) & 0xFF) << 16 | @@ -145,12 +145,12 @@ uint64_t UTILS::CCharArrayParser::ReadNextUnsignedInt64() { if (!m_data) { - LOG::LogF(LOGERROR, "{} - No data to read"); + LOG::LogF(LOGERROR, "No data to read"); return 0; } m_position += 8; if (m_position > m_limit) - LOG::LogF(LOGERROR, "{} - Position out of range"); + LOG::LogF(LOGERROR, "Position out of range"); return (static_cast(m_data[m_position - 8]) & 0xFF) << 56 | (static_cast(m_data[m_position - 7]) & 0xFF) << 48 | (static_cast(m_data[m_position - 6]) & 0xFF) << 40 | @@ -165,13 +165,13 @@ std::string UTILS::CCharArrayParser::ReadNextString(size_t length) { if (!m_data) { - LOG::LogF(LOGERROR, "{} - No data to read"); + LOG::LogF(LOGERROR, "No data to read"); return ""; } std::string str(reinterpret_cast(m_data + m_position), length); m_position += length; if (m_position > m_limit) - LOG::LogF(LOGERROR, "{} - Position out of range"); + LOG::LogF(LOGERROR, "Position out of range"); return str; } @@ -179,12 +179,12 @@ bool UTILS::CCharArrayParser::ReadNextArray(size_t length, std::vector& { if (!m_data) { - LOG::LogF(LOGERROR, "{} - No data to read"); + LOG::LogF(LOGERROR, "No data to read"); return false; } if (m_position + length > m_limit) { - LOG::LogF(LOGERROR, "{} - Position out of range"); + LOG::LogF(LOGERROR, "Position out of range"); return false; } data.insert(data.end(), m_data + m_position, m_data + m_position + length); diff --git a/src/utils/CurlUtils.cpp b/src/utils/CurlUtils.cpp index 5b563ed26..0a5abd9ea 100644 --- a/src/utils/CurlUtils.cpp +++ b/src/utils/CurlUtils.cpp @@ -334,7 +334,7 @@ bool UTILS::CURL::DownloadFile(std::string_view url, if (statusCode == -1) { - LOG::Log(LOGERROR, "Download failed, internal error: %s", url.data()); + LOG::Log(LOGERROR, "Download failed, internal error: {}", url.data()); break; } else if (statusCode >= 500) @@ -343,7 +343,7 @@ bool UTILS::CURL::DownloadFile(std::string_view url, } else if (statusCode >= 400) { - LOG::Log(LOGERROR, "Download failed, HTTP error %d: %s", statusCode, url.data()); + LOG::Log(LOGERROR, "Download failed, HTTP error {}: {}", statusCode, url.data()); break; } else // Start the download @@ -352,13 +352,13 @@ bool UTILS::CURL::DownloadFile(std::string_view url, if (curl.Read(resp.data) != CURL::ReadStatus::IS_EOF) { - LOG::Log(LOGERROR, "Download failed: %s", statusCode, url.data()); + LOG::Log(LOGERROR, "Download failed: {}", statusCode, url.data()); break; } if (resp.data.empty()) { - LOG::Log(LOGERROR, "Download failed, no data: %s", url.data()); + LOG::Log(LOGERROR, "Download failed, no data: {}", url.data()); break; } @@ -371,7 +371,7 @@ bool UTILS::CURL::DownloadFile(std::string_view url, resp.downloadSpeed = curl.GetDownloadSpeed(); resp.dataSize = curl.GetTotalByteRead(); - LOG::Log(LOGDEBUG, "Download finished: %s (downloaded %zu byte, speed %0.2lf byte/s)", + LOG::Log(LOGDEBUG, "Download finished: {} (downloaded {} byte, speed {:0.2f} byte/s)", url.data(), curl.GetTotalByteRead(), resp.downloadSpeed); return true; } diff --git a/src/utils/FileUtils.cpp b/src/utils/FileUtils.cpp index 338610771..50455e1d9 100644 --- a/src/utils/FileUtils.cpp +++ b/src/utils/FileUtils.cpp @@ -27,7 +27,7 @@ bool UTILS::FILESYS::SaveFile(const std::string filePath, const std::string& dat kodi::vfs::CFile saveFile; if (!saveFile.OpenFileForWrite(filePath, overwrite)) { - LOG::LogF(LOGERROR, "Cannot create file \"%s\".", filePath.c_str()); + LOG::LogF(LOGERROR, "Cannot create file \"{}\".", filePath.c_str()); return false; } @@ -90,7 +90,7 @@ bool UTILS::FILESYS::CheckDuplicateFilePath(std::string& filePath, uint32_t file { if (filesLimit != 0 && index > filesLimit) { - LOG::LogF(LOGERROR, "The file path \"%s\" exceeds the maximum amount of duplicate files.", + LOG::LogF(LOGERROR, "The file path \"{}\" exceeds the maximum amount of duplicate files.", filePath.c_str()); return false; } diff --git a/src/utils/XMLUtils.cpp b/src/utils/XMLUtils.cpp index 27cdd13b2..7dc0d36a0 100644 --- a/src/utils/XMLUtils.cpp +++ b/src/utils/XMLUtils.cpp @@ -80,7 +80,7 @@ double UTILS::XML::ParseDuration(std::string_view durationStr) if (matches.size() == 0) { - LOG::LogF(LOGWARNING, "Duration string \"%s\" is not valid.", durationStr); + LOG::LogF(LOGWARNING, "Duration string \"{}\" is not valid.", durationStr); return 0; } diff --git a/src/utils/log.h b/src/utils/log.h index 28fd7d104..9f3cacd02 100644 --- a/src/utils/log.h +++ b/src/utils/log.h @@ -15,6 +15,7 @@ #include #endif +#include #include // To keep in sync with SSDLogLevel on SSD_dll.h @@ -31,8 +32,14 @@ namespace LOG { template -inline void Log(const LogLevel level, const char* format, Args&&... args) +inline void Log(const LogLevel level, std::format_string format, Args&&... args) { + char buffer[16 * 1024]; // 16k is the maximum kodi logs + + const std::format_to_n_result result = + std::format_to_n(std::begin(buffer), sizeof(buffer) - 1, format, std::forward(args)...); + *result.out = '\0'; + #ifndef INPUTSTREAM_TEST_BUILD ADDON_LOG addonLevel; @@ -54,26 +61,25 @@ inline void Log(const LogLevel level, const char* format, Args&&... args) addonLevel = ADDON_LOG::ADDON_LOG_DEBUG; } - kodi::Log(addonLevel, format, std::forward(args)...); + kodi::Log(addonLevel, "%s", buffer); #else - std::string logStr = kodi::tools::StringUtils::Format(format, std::forward(args)...); switch (level) { case LogLevel::LOGFATAL: - std::cout << "[ LOG-FATAL ] " << logStr << std::endl; + std::cout << "[ LOG-FATAL ] " << buffer << std::endl; break; case LogLevel::LOGERROR: - std::cout << "[ LOG-ERROR ] " << logStr << std::endl; + std::cout << "[ LOG-ERROR ] " << buffer << std::endl; break; -/* + /* case LogLevel::LOGWARNING: - std::cout << "[ LOG-WARN ] " << logStr << std::endl; + std::cout << "[ LOG-WARN ] " << buffer << std::endl; break; case LogLevel::LOGINFO: - std::cout << "[ LOG-INFO ] " << logStr << std::endl; + std::cout << "[ LOG-INFO ] " << buffer << std::endl; break; case LogLevel::LOGDEBUG: - std::cout << "[ LOG-DEBUG ] " << logStr << std::endl; + std::cout << "[ LOG-DEBUG ] " << buffer << std::endl; */ default: break; @@ -81,6 +87,6 @@ inline void Log(const LogLevel level, const char* format, Args&&... args) #endif } -#define LogF(level, format, ...) Log((level), ("%s: " format), __FUNCTION__, ##__VA_ARGS__) +#define LogF(level, format, ...) Log((level), ("{}: " format), __FUNCTION__, ##__VA_ARGS__) } // namespace LOG