Mercurial > hg > orthanc
comparison OrthancServer/ServerContext.cpp @ 3894:8f7ad4989fec transcoding
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 07 May 2020 11:13:29 +0200 |
parents | 5bba4d249422 |
children | d1273d7cc200 |
comparison
equal
deleted
inserted
replaced
3893:7a5fa8f307e9 | 3894:8f7ad4989fec |
---|---|
33 | 33 |
34 #include "PrecompiledHeadersServer.h" | 34 #include "PrecompiledHeadersServer.h" |
35 #include "ServerContext.h" | 35 #include "ServerContext.h" |
36 | 36 |
37 #include "../Core/Cache/SharedArchive.h" | 37 #include "../Core/Cache/SharedArchive.h" |
38 #include "../Core/DicomParsing/DcmtkTranscoder.h" | |
38 #include "../Core/DicomParsing/FromDcmtkBridge.h" | 39 #include "../Core/DicomParsing/FromDcmtkBridge.h" |
39 #include "../Core/FileStorage/StorageAccessor.h" | 40 #include "../Core/FileStorage/StorageAccessor.h" |
40 #include "../Core/HttpServer/FilesystemHttpSender.h" | 41 #include "../Core/HttpServer/FilesystemHttpSender.h" |
41 #include "../Core/HttpServer/HttpStreamTranscoder.h" | 42 #include "../Core/HttpServer/HttpStreamTranscoder.h" |
42 #include "../Core/JobsEngine/SetOfInstancesJob.h" | 43 #include "../Core/JobsEngine/SetOfInstancesJob.h" |
241 haveJobsChanged_(false), | 242 haveJobsChanged_(false), |
242 isJobsEngineUnserialized_(false), | 243 isJobsEngineUnserialized_(false), |
243 metricsRegistry_(new MetricsRegistry), | 244 metricsRegistry_(new MetricsRegistry), |
244 isHttpServerSecure_(true), | 245 isHttpServerSecure_(true), |
245 isExecuteLuaEnabled_(false), | 246 isExecuteLuaEnabled_(false), |
246 overwriteInstances_(false) | 247 overwriteInstances_(false), |
248 dcmtkTranscoder_(new DcmtkTranscoder) | |
247 { | 249 { |
248 { | 250 { |
249 OrthancConfiguration::ReaderLock lock; | 251 OrthancConfiguration::ReaderLock lock; |
250 | 252 |
251 queryRetrieveArchive_.reset( | 253 queryRetrieveArchive_.reset( |
262 limitFindInstances_ = lock.GetConfiguration().GetUnsignedIntegerParameter("LimitFindInstances", 0); | 264 limitFindInstances_ = lock.GetConfiguration().GetUnsignedIntegerParameter("LimitFindInstances", 0); |
263 limitFindResults_ = lock.GetConfiguration().GetUnsignedIntegerParameter("LimitFindResults", 0); | 265 limitFindResults_ = lock.GetConfiguration().GetUnsignedIntegerParameter("LimitFindResults", 0); |
264 | 266 |
265 // New configuration option in Orthanc 1.6.0 | 267 // New configuration option in Orthanc 1.6.0 |
266 storageCommitmentReports_.reset(new StorageCommitmentReports(lock.GetConfiguration().GetUnsignedIntegerParameter("StorageCommitmentReportsSize", 100))); | 268 storageCommitmentReports_.reset(new StorageCommitmentReports(lock.GetConfiguration().GetUnsignedIntegerParameter("StorageCommitmentReportsSize", 100))); |
269 | |
270 // New option in Orthanc 1.7.0 | |
271 transcodingEnabled_ = lock.GetConfiguration().GetBooleanParameter("TranscodingEnabled", true); | |
267 } | 272 } |
268 | 273 |
269 jobsEngine_.SetThreadSleep(unitTesting ? 20 : 200); | 274 jobsEngine_.SetThreadSleep(unitTesting ? 20 : 200); |
270 | 275 |
271 listeners_.push_back(ServerListener(luaListener_, "Lua")); | 276 listeners_.push_back(ServerListener(luaListener_, "Lua")); |
1106 } | 1111 } |
1107 #endif | 1112 #endif |
1108 | 1113 |
1109 return NULL; | 1114 return NULL; |
1110 } | 1115 } |
1116 | |
1117 | |
1118 void ServerContext::StoreWithTranscoding(std::string& sopClassUid, | |
1119 std::string& sopInstanceUid, | |
1120 DicomStoreUserConnection& connection, | |
1121 const std::string& dicom, | |
1122 bool hasMoveOriginator, | |
1123 const std::string& moveOriginatorAet, | |
1124 uint16_t moveOriginatorId) | |
1125 { | |
1126 const void* data = dicom.empty() ? NULL : dicom.c_str(); | |
1127 | |
1128 if (!transcodingEnabled_ || | |
1129 !connection.GetParameters().GetRemoteModality().IsTranscodingAllowed()) | |
1130 { | |
1131 connection.Store(sopClassUid, sopInstanceUid, data, dicom.size(), | |
1132 hasMoveOriginator, moveOriginatorAet, moveOriginatorId); | |
1133 } | |
1134 else | |
1135 { | |
1136 IDicomTranscoder* transcoder = dcmtkTranscoder_.get(); | |
1137 | |
1138 #if ORTHANC_ENABLE_PLUGINS == 1 | |
1139 if (HasPlugins()) | |
1140 { | |
1141 transcoder = &GetPlugins(); | |
1142 } | |
1143 #endif | |
1144 | |
1145 if (transcoder == NULL) | |
1146 { | |
1147 throw OrthancException(ErrorCode_InternalError); | |
1148 } | |
1149 else | |
1150 { | |
1151 connection.Transcode(sopClassUid, sopInstanceUid, *transcoder, data, dicom.size(), | |
1152 hasMoveOriginator, moveOriginatorAet, moveOriginatorId); | |
1153 } | |
1154 } | |
1155 } | |
1156 | |
1157 | |
1158 bool ServerContext::TranscodeMemoryBuffer(std::string& target, | |
1159 bool& hasSopInstanceUidChanged, | |
1160 const std::string& source, | |
1161 const std::set<DicomTransferSyntax>& allowedSyntaxes, | |
1162 bool allowNewSopInstanceUid) | |
1163 { | |
1164 const char* data = source.empty() ? NULL : source.c_str(); | |
1165 | |
1166 #if ORTHANC_ENABLE_PLUGINS == 1 | |
1167 if (HasPlugins()) | |
1168 { | |
1169 return GetPlugins().TranscodeToBuffer( | |
1170 target, hasSopInstanceUidChanged, data, source.size(), allowedSyntaxes, allowNewSopInstanceUid); | |
1171 } | |
1172 #endif | |
1173 | |
1174 assert(dcmtkTranscoder_.get() != NULL); | |
1175 return dcmtkTranscoder_->TranscodeToBuffer( | |
1176 target, hasSopInstanceUidChanged, data, source.size(), allowedSyntaxes, allowNewSopInstanceUid); | |
1177 } | |
1111 } | 1178 } |