Mercurial > hg > orthanc
comparison OrthancServer/ServerContext.cpp @ 3928:4cdc875510d1 transcoding
ServerContext::DecodeDicomFrame()
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 14 May 2020 13:31:05 +0200 |
parents | 6ddad3e0b569 |
children | b99acc213937 |
comparison
equal
deleted
inserted
replaced
3926:2910b0d30fe0 | 3928:4cdc875510d1 |
---|---|
32 | 32 |
33 | 33 |
34 #include "PrecompiledHeadersServer.h" | 34 #include "PrecompiledHeadersServer.h" |
35 #include "ServerContext.h" | 35 #include "ServerContext.h" |
36 | 36 |
37 #include "../Core/DicomParsing/Internals/DicomImageDecoder.h" | |
37 #include "../Core/Cache/SharedArchive.h" | 38 #include "../Core/Cache/SharedArchive.h" |
38 #include "../Core/DicomParsing/DcmtkTranscoder.h" | 39 #include "../Core/DicomParsing/DcmtkTranscoder.h" |
39 #include "../Core/DicomParsing/FromDcmtkBridge.h" | 40 #include "../Core/DicomParsing/FromDcmtkBridge.h" |
40 #include "../Core/FileStorage/StorageAccessor.h" | 41 #include "../Core/FileStorage/StorageAccessor.h" |
41 #include "../Core/HttpServer/FilesystemHttpSender.h" | 42 #include "../Core/HttpServer/FilesystemHttpSender.h" |
1191 return *transcoder; | 1192 return *transcoder; |
1192 } | 1193 } |
1193 } | 1194 } |
1194 | 1195 |
1195 | 1196 |
1197 ImageAccessor* ServerContext::DecodeDicomFrame(const std::string& publicId, | |
1198 unsigned int frameIndex) | |
1199 { | |
1200 // TODO => Reorder given the global parameter | |
1201 | |
1202 #if ORTHANC_ENABLE_PLUGINS == 1 | |
1203 if (HasPlugins() && | |
1204 GetPlugins().HasCustomImageDecoder()) | |
1205 { | |
1206 // TODO: Store the raw buffer in the DicomCacheLocker | |
1207 std::string dicomContent; | |
1208 ReadDicom(dicomContent, publicId); | |
1209 | |
1210 std::unique_ptr<ImageAccessor> decoded( | |
1211 GetPlugins().Decode(dicomContent.c_str(), dicomContent.size(), frameIndex)); | |
1212 if (decoded.get() != NULL) | |
1213 { | |
1214 return decoded.release(); | |
1215 } | |
1216 else | |
1217 { | |
1218 LOG(INFO) << "The installed image decoding plugins cannot handle an image, " | |
1219 << "fallback to the built-in decoder"; | |
1220 } | |
1221 } | |
1222 #endif | |
1223 | |
1224 { | |
1225 // Use Orthanc's built-in decoder, using the cache to speed-up | |
1226 // things on multi-frame images | |
1227 ServerContext::DicomCacheLocker locker(*this, publicId); | |
1228 return DicomImageDecoder::Decode(locker.GetDicom(), frameIndex); | |
1229 } | |
1230 } | |
1231 | |
1232 | |
1233 ImageAccessor* ServerContext::DecodeDicomFrame(const DicomInstanceToStore& dicom, | |
1234 unsigned int frameIndex) | |
1235 { | |
1236 // TODO => Reorder given the global parameter | |
1237 | |
1238 #if ORTHANC_ENABLE_PLUGINS == 1 | |
1239 if (HasPlugins() && | |
1240 GetPlugins().HasCustomImageDecoder()) | |
1241 { | |
1242 std::unique_ptr<ImageAccessor> decoded( | |
1243 GetPlugins().Decode(dicom.GetBufferData(), dicom.GetBufferSize(), frameIndex)); | |
1244 if (decoded.get() != NULL) | |
1245 { | |
1246 return decoded.release(); | |
1247 } | |
1248 else | |
1249 { | |
1250 LOG(INFO) << "The installed image decoding plugins cannot handle an image, " | |
1251 << "fallback to the built-in decoder"; | |
1252 } | |
1253 } | |
1254 #endif | |
1255 | |
1256 return DicomImageDecoder::Decode(dicom.GetParsedDicomFile(), frameIndex); | |
1257 } | |
1258 | |
1259 | |
1196 void ServerContext::StoreWithTranscoding(std::string& sopClassUid, | 1260 void ServerContext::StoreWithTranscoding(std::string& sopClassUid, |
1197 std::string& sopInstanceUid, | 1261 std::string& sopInstanceUid, |
1198 DicomStoreUserConnection& connection, | 1262 DicomStoreUserConnection& connection, |
1199 const std::string& dicom, | 1263 const std::string& dicom, |
1200 bool hasMoveOriginator, | 1264 bool hasMoveOriginator, |