Mercurial > hg > orthanc
diff OrthancServer/Sources/ServerContext.cpp @ 5426:c65e036d649b
StorageCache is now storing transcoded instances + added ?transcode=... option to the /file route.
author | Alain Mazy <am@osimis.io> |
---|---|
date | Thu, 16 Nov 2023 16:09:04 +0100 |
parents | d37dff2c0028 |
children | 111e21b4f8bc |
line wrap: on
line diff
--- a/OrthancServer/Sources/ServerContext.cpp Wed Nov 15 08:58:45 2023 +0100 +++ b/OrthancServer/Sources/ServerContext.cpp Thu Nov 16 16:09:04 2023 +0100 @@ -1948,6 +1948,36 @@ } + bool ServerContext::TranscodeWithCache(std::string& target, + const std::string& source, + const std::string& sourceInstanceId, + DicomTransferSyntax targetSyntax) + { + StorageCache::Accessor cacheAccessor(storageCache_); + + if (!cacheAccessor.FetchTranscodedInstance(target, sourceInstanceId, targetSyntax)) + { + IDicomTranscoder::DicomImage sourceDicom; + sourceDicom.SetExternalBuffer(source); + + IDicomTranscoder::DicomImage targetDicom; + std::set<DicomTransferSyntax> syntaxes; + syntaxes.insert(targetSyntax); + + if (Transcode(targetDicom, sourceDicom, syntaxes, true)) + { + cacheAccessor.AddTranscodedInstance(sourceInstanceId, targetSyntax, reinterpret_cast<const char*>(targetDicom.GetBufferData()), targetDicom.GetBufferSize()); + target = std::string(reinterpret_cast<const char*>(targetDicom.GetBufferData()), targetDicom.GetBufferSize()); + return true; + } + + return false; + } + + return true; + } + + bool ServerContext::Transcode(DicomImage& target, DicomImage& source /* in, "GetParsed()" possibly modified */, const std::set<DicomTransferSyntax>& allowedSyntaxes,