comparison OrthancServer/ServerContext.cpp @ 3939:c205f670098e transcoding

new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 18 May 2020 17:15:16 +0200
parents 54dbebbcc032
children 771dbd9eb3bd
comparison
equal deleted inserted replaced
3938:54dbebbcc032 3939:c205f670098e
244 isJobsEngineUnserialized_(false), 244 isJobsEngineUnserialized_(false),
245 metricsRegistry_(new MetricsRegistry), 245 metricsRegistry_(new MetricsRegistry),
246 isHttpServerSecure_(true), 246 isHttpServerSecure_(true),
247 isExecuteLuaEnabled_(false), 247 isExecuteLuaEnabled_(false),
248 overwriteInstances_(false), 248 overwriteInstances_(false),
249 dcmtkTranscoder_(new DcmtkTranscoder) 249 dcmtkTranscoder_(new DcmtkTranscoder),
250 { 250 isIngestTranscoding_(false)
251 { 251 {
252 OrthancConfiguration::ReaderLock lock; 252 try
253 253 {
254 queryRetrieveArchive_.reset( 254 unsigned int lossyQuality;
255 new SharedArchive(lock.GetConfiguration().GetUnsignedIntegerParameter("QueryRetrieveSize", 100))); 255
256 mediaArchive_.reset( 256 {
257 new SharedArchive(lock.GetConfiguration().GetUnsignedIntegerParameter("MediaArchiveSize", 1))); 257 OrthancConfiguration::ReaderLock lock;
258 defaultLocalAet_ = lock.GetConfiguration().GetStringParameter("DicomAet", "ORTHANC"); 258
259 jobsEngine_.SetWorkersCount(lock.GetConfiguration().GetUnsignedIntegerParameter("ConcurrentJobs", 2)); 259 queryRetrieveArchive_.reset(
260 saveJobs_ = lock.GetConfiguration().GetBooleanParameter("SaveJobs", true); 260 new SharedArchive(lock.GetConfiguration().GetUnsignedIntegerParameter("QueryRetrieveSize", 100)));
261 metricsRegistry_->SetEnabled(lock.GetConfiguration().GetBooleanParameter("MetricsEnabled", true)); 261 mediaArchive_.reset(
262 262 new SharedArchive(lock.GetConfiguration().GetUnsignedIntegerParameter("MediaArchiveSize", 1)));
263 // New configuration options in Orthanc 1.5.1 263 defaultLocalAet_ = lock.GetConfiguration().GetStringParameter("DicomAet", "ORTHANC");
264 findStorageAccessMode_ = StringToFindStorageAccessMode(lock.GetConfiguration().GetStringParameter("StorageAccessOnFind", "Always")); 264 jobsEngine_.SetWorkersCount(lock.GetConfiguration().GetUnsignedIntegerParameter("ConcurrentJobs", 2));
265 limitFindInstances_ = lock.GetConfiguration().GetUnsignedIntegerParameter("LimitFindInstances", 0); 265 saveJobs_ = lock.GetConfiguration().GetBooleanParameter("SaveJobs", true);
266 limitFindResults_ = lock.GetConfiguration().GetUnsignedIntegerParameter("LimitFindResults", 0); 266 metricsRegistry_->SetEnabled(lock.GetConfiguration().GetBooleanParameter("MetricsEnabled", true));
267 267
268 // New configuration option in Orthanc 1.6.0 268 // New configuration options in Orthanc 1.5.1
269 storageCommitmentReports_.reset(new StorageCommitmentReports(lock.GetConfiguration().GetUnsignedIntegerParameter("StorageCommitmentReportsSize", 100))); 269 findStorageAccessMode_ = StringToFindStorageAccessMode(lock.GetConfiguration().GetStringParameter("StorageAccessOnFind", "Always"));
270 270 limitFindInstances_ = lock.GetConfiguration().GetUnsignedIntegerParameter("LimitFindInstances", 0);
271 // New options in Orthanc 1.7.0 271 limitFindResults_ = lock.GetConfiguration().GetUnsignedIntegerParameter("LimitFindResults", 0);
272 transcodeDicomProtocol_ = lock.GetConfiguration().GetBooleanParameter("TranscodeDicomProtocol", true); 272
273 builtinDecoderTranscoderOrder_ = StringToBuiltinDecoderTranscoderOrder(lock.GetConfiguration().GetStringParameter("BuiltinDecoderTranscoderOrder", "After")); 273 // New configuration option in Orthanc 1.6.0
274 } 274 storageCommitmentReports_.reset(new StorageCommitmentReports(lock.GetConfiguration().GetUnsignedIntegerParameter("StorageCommitmentReportsSize", 100)));
275 275
276 jobsEngine_.SetThreadSleep(unitTesting ? 20 : 200); 276 // New options in Orthanc 1.7.0
277 277 transcodeDicomProtocol_ = lock.GetConfiguration().GetBooleanParameter("TranscodeDicomProtocol", true);
278 listeners_.push_back(ServerListener(luaListener_, "Lua")); 278 builtinDecoderTranscoderOrder_ = StringToBuiltinDecoderTranscoderOrder(lock.GetConfiguration().GetStringParameter("BuiltinDecoderTranscoderOrder", "After"));
279 changeThread_ = boost::thread(ChangeThread, this, (unitTesting ? 20 : 100)); 279 lossyQuality = lock.GetConfiguration().GetUnsignedIntegerParameter("DicomLossyTranscodingQuality", 90);
280
281 std::string s;
282 if (lock.GetConfiguration().LookupStringParameter(s, "IngestTranscoding"))
283 {
284 if (LookupTransferSyntax(ingestTransferSyntax_, s))
285 {
286 isIngestTranscoding_ = true;
287 LOG(WARNING) << "Incoming DICOM instances will automatically be transcoded to "
288 << "transfer syntax: " << GetTransferSyntaxUid(ingestTransferSyntax_);
289 }
290 else
291 {
292 throw OrthancException(ErrorCode_ParameterOutOfRange,
293 "Unknown transfer syntax for ingest transcoding: " + s);
294 }
295 }
296 else
297 {
298 isIngestTranscoding_ = true;
299 LOG(INFO) << "Automated transcoding of incoming DICOM instances is disabled";
300 }
301 }
302
303 jobsEngine_.SetThreadSleep(unitTesting ? 20 : 200);
304
305 listeners_.push_back(ServerListener(luaListener_, "Lua"));
306 changeThread_ = boost::thread(ChangeThread, this, (unitTesting ? 20 : 100));
307
308 dynamic_cast<DcmtkTranscoder&>(*dcmtkTranscoder_).SetLossyQuality(lossyQuality);
309 }
310 catch (OrthancException&)
311 {
312 Stop();
313 throw;
314 }
280 } 315 }
281 316
282 317
283 318
284 ServerContext::~ServerContext() 319 ServerContext::~ServerContext()
506 541
507 StoreStatus ServerContext::Store(std::string& resultPublicId, 542 StoreStatus ServerContext::Store(std::string& resultPublicId,
508 DicomInstanceToStore& dicom, 543 DicomInstanceToStore& dicom,
509 StoreInstanceMode mode) 544 StoreInstanceMode mode)
510 { 545 {
511 const DicomTransferSyntax option = DicomTransferSyntax_JPEGProcess1; 546 if (!isIngestTranscoding_)
512 //const DicomTransferSyntax option = DicomTransferSyntax_JPEGProcess14SV1; 547 {
513 //const DicomTransferSyntax option = DicomTransferSyntax_LittleEndianExplicit; 548 // No automated transcoding
514
515 if (1)
516 {
517 return StoreAfterTranscoding(resultPublicId, dicom, mode); 549 return StoreAfterTranscoding(resultPublicId, dicom, mode);
518 } 550 }
519 else 551 else
520 { 552 {
521 // TODO => Automated transcoding of incoming DICOM files 553 // Automated transcoding of incoming DICOM files
522 554
523 DicomTransferSyntax sourceSyntax; 555 DicomTransferSyntax sourceSyntax;
524 if (!FromDcmtkBridge::LookupOrthancTransferSyntax( 556 if (!FromDcmtkBridge::LookupOrthancTransferSyntax(
525 sourceSyntax, dicom.GetParsedDicomFile().GetDcmtkObject()) || 557 sourceSyntax, dicom.GetParsedDicomFile().GetDcmtkObject()) ||
526 sourceSyntax == option) 558 sourceSyntax == ingestTransferSyntax_)
527 { 559 {
528 // No transcoding 560 // No transcoding
529 return StoreAfterTranscoding(resultPublicId, dicom, mode); 561 return StoreAfterTranscoding(resultPublicId, dicom, mode);
530 } 562 }
531 else 563 else
532 { 564 {
533 std::set<DicomTransferSyntax> syntaxes; 565 std::set<DicomTransferSyntax> syntaxes;
534 syntaxes.insert(option); 566 syntaxes.insert(ingestTransferSyntax_);
535 567
536 std::unique_ptr<IDicomTranscoder::TranscodedDicom> transcoded( 568 std::unique_ptr<IDicomTranscoder::TranscodedDicom> transcoded(
537 TranscodeToParsed(dicom.GetParsedDicomFile().GetDcmtkObject(), 569 TranscodeToParsed(dicom.GetParsedDicomFile().GetDcmtkObject(),
538 dicom.GetBufferData(), dicom.GetBufferSize(), 570 dicom.GetBufferData(), dicom.GetBufferSize(),
539 syntaxes, true /* allow new SOP instance UID */)); 571 syntaxes, true /* allow new SOP instance UID */));