changeset 6843:749a14809ad1 streaming

managing the checkMD5 option by StorageAreaDataSource
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 22 May 2026 07:53:32 +0200
parents 6b9b5351d247
children dbebcd49317c
files OrthancFramework/Sources/DataSource/DicomDataSource.cpp OrthancFramework/Sources/DataSource/DicomDataSource.h OrthancFramework/Sources/DataSource/StorageAreaDataSource.cpp OrthancFramework/Sources/DataSource/StorageAreaDataSource.h OrthancFramework/Sources/DataSource/TranscoderDataSource.cpp OrthancFramework/Sources/DataSource/TranscoderDataSource.h OrthancServer/Sources/ServerContext.cpp OrthancServer/Sources/ServerContext.h OrthancServer/Sources/ServerTranscoder.cpp OrthancServer/Sources/ServerTranscoder.h
diffstat 10 files changed, 52 insertions(+), 79 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancFramework/Sources/DataSource/DicomDataSource.cpp	Thu May 21 16:48:05 2026 +0200
+++ b/OrthancFramework/Sources/DataSource/DicomDataSource.cpp	Fri May 22 07:53:32 2026 +0200
@@ -46,13 +46,10 @@
   {
   private:
     FileInfo  attachment_;
-    bool      checkMD5_;
 
   public:
-    explicit WholeIdentifier(const FileInfo& attachment,
-                             bool checkMD5) :
-      attachment_(attachment),
-      checkMD5_(checkMD5)
+    explicit WholeIdentifier(const FileInfo& attachment) :
+      attachment_(attachment)
     {
     }
 
@@ -71,7 +68,7 @@
 
     virtual StorageAreaDataSource::Range* ReadRange(DataSourceReader& reader) const ORTHANC_OVERRIDE
     {
-      return StorageAreaDataSource::ReadAttachment(reader, attachment_, true /* uncompress */, checkMD5_);
+      return StorageAreaDataSource::ReadAttachment(reader, attachment_, true /* uncompress */);
     }
   };
 
@@ -209,10 +206,9 @@
 
 
   DicomDataSource::Dicom* DicomDataSource::ReadWhole(DataSourceReader& reader,
-                                                     const FileInfo& attachment,
-                                                     bool checkMD5)
+                                                     const FileInfo& attachment)
   {
-    std::unique_ptr<IDataIdentifier> id(new WholeIdentifier(attachment, checkMD5));
+    std::unique_ptr<IDataIdentifier> id(new WholeIdentifier(attachment));
     boost::shared_ptr<IDynamicObject> value = reader.ReadSingle(id.release());
     return new Dicom(value);
   }
--- a/OrthancFramework/Sources/DataSource/DicomDataSource.h	Thu May 21 16:48:05 2026 +0200
+++ b/OrthancFramework/Sources/DataSource/DicomDataSource.h	Fri May 22 07:53:32 2026 +0200
@@ -97,8 +97,7 @@
     };
 
     static Dicom* ReadWhole(DataSourceReader& reader,
-                            const FileInfo& attachment,
-                            bool checkMD5);
+                            const FileInfo& attachment);
 
     static Dicom* ReadUntilPixelData(DataSourceReader& reader,
                                      const FileInfo& attachment,
--- a/OrthancFramework/Sources/DataSource/StorageAreaDataSource.cpp	Thu May 21 16:48:05 2026 +0200
+++ b/OrthancFramework/Sources/DataSource/StorageAreaDataSource.cpp	Fri May 22 07:53:32 2026 +0200
@@ -345,8 +345,7 @@
 
   StorageAreaDataSource::Range* StorageAreaDataSource::ReadAttachment(DataSourceReader& reader,
                                                                       const FileInfo& attachment,
-                                                                      bool uncompress,
-                                                                      bool checkMD5)
+                                                                      bool uncompress)
   {
     std::unique_ptr<Identifier> id(new Identifier(attachment.GetUuid(),
                                                   attachment.GetContentType(),
@@ -390,8 +389,7 @@
   StorageAreaDataSource::Range* StorageAreaDataSource::ReadRange(DataSourceReader& reader,
                                                                  const FileInfo& attachment,
                                                                  const StorageRange& range,
-                                                                 bool uncompress,
-                                                                 bool checkMD5)
+                                                                 bool uncompress)
   {
     // This mimics "StorageAccessor::ReadRange()"
 
@@ -400,7 +398,7 @@
     {
       // An uncompression is needed in this case
       std::unique_ptr<StorageAreaDataSource::Range> uncompressed(
-        ReadAttachment(reader, attachment, true /* uncompress */, checkMD5));
+        ReadAttachment(reader, attachment, true /* uncompress */));
 
       std::string content;
       range.Extract(content, uncompressed->GetData(), uncompressed->GetSize());
--- a/OrthancFramework/Sources/DataSource/StorageAreaDataSource.h	Thu May 21 16:48:05 2026 +0200
+++ b/OrthancFramework/Sources/DataSource/StorageAreaDataSource.h	Fri May 22 07:53:32 2026 +0200
@@ -55,7 +55,7 @@
 
   public:
     explicit StorageAreaDataSource(IPluginStorageArea& area,
-                                   bool checkMD5 = true /* TODO-Streaming */) :
+                                   bool checkMD5) :
       area_(area),
       checkMD5_(checkMD5)
     {
@@ -95,8 +95,7 @@
 
     static Range* ReadAttachment(DataSourceReader& reader,
                                  const FileInfo& attachment,
-                                 bool uncompress,
-                                 bool checkMD5);
+                                 bool uncompress);
 
     static Range* ReadBeginning(DataSourceReader& reader,
                                 const FileInfo& attachment,
@@ -105,7 +104,6 @@
     static Range* ReadRange(DataSourceReader& reader,
                             const FileInfo& attachment,
                             const StorageRange& range,
-                            bool uncompress,
-                            bool checkMD5);
+                            bool uncompress);
   };
 }
--- a/OrthancFramework/Sources/DataSource/TranscoderDataSource.cpp	Thu May 21 16:48:05 2026 +0200
+++ b/OrthancFramework/Sources/DataSource/TranscoderDataSource.cpp	Fri May 22 07:53:32 2026 +0200
@@ -85,18 +85,15 @@
   private:
     FileInfo                       attachment_;
     DicomTransferSyntax            targetSyntax_;
-    bool                           checkMD5_;
     TranscodingSopInstanceUidMode  mode_;
     bool                           hasLossyQuality_;
     unsigned int                   lossyQuality_;
 
   public:
     Identifier(const FileInfo& attachment,
-               DicomTransferSyntax targetSyntax,
-               bool checkMD5) :
+               DicomTransferSyntax targetSyntax) :
       attachment_(attachment),
       targetSyntax_(targetSyntax),
-      checkMD5_(checkMD5),
       mode_(TranscodingSopInstanceUidMode_AllowNew),
       hasLossyQuality_(false),
       lossyQuality_(0)
@@ -139,8 +136,7 @@
                 DataSourceReader& storageAreaReader) const
     {
       std::unique_ptr<StorageAreaDataSource::Range> range(
-        StorageAreaDataSource::ReadAttachment(
-          storageAreaReader, attachment_, true /* uncompress */, checkMD5_));
+        StorageAreaDataSource::ReadAttachment(storageAreaReader, attachment_, true /* uncompress */));
 
       IDicomTranscoder::DicomImage source;
       source.SetExternalBuffer(range->GetData(), range->GetSize());
@@ -216,10 +212,9 @@
 
   TranscoderDataSource::Transcoded* TranscoderDataSource::Transcode(DataSourceReader& reader,
                                                                     const FileInfo& attachment,
-                                                                    DicomTransferSyntax targetSyntax,
-                                                                    bool checkMD5)
+                                                                    DicomTransferSyntax targetSyntax)
   {
-    std::unique_ptr<IDataIdentifier> id(new Identifier(attachment, targetSyntax, checkMD5));
+    std::unique_ptr<IDataIdentifier> id(new Identifier(attachment, targetSyntax));
     boost::shared_ptr<IDynamicObject> value = reader.ReadSingle(id.release());
     return new Transcoded(value);
   }
@@ -229,10 +224,9 @@
                                                                     const FileInfo& attachment,
                                                                     DicomTransferSyntax targetSyntax,
                                                                     TranscodingSopInstanceUidMode mode,
-                                                                    unsigned int lossyQuality,
-                                                                    bool checkMD5)
+                                                                    unsigned int lossyQuality)
   {
-    std::unique_ptr<Identifier> id(new Identifier(attachment, targetSyntax, checkMD5));
+    std::unique_ptr<Identifier> id(new Identifier(attachment, targetSyntax));
     id->SetMode(mode);
     id->SetLossyQuality(lossyQuality);
 
--- a/OrthancFramework/Sources/DataSource/TranscoderDataSource.h	Thu May 21 16:48:05 2026 +0200
+++ b/OrthancFramework/Sources/DataSource/TranscoderDataSource.h	Fri May 22 07:53:32 2026 +0200
@@ -85,14 +85,12 @@
 
     static Transcoded* Transcode(DataSourceReader& reader,
                                  const FileInfo& attachment,
-                                 DicomTransferSyntax targetSyntax,
-                                 bool checkMD5);
+                                 DicomTransferSyntax targetSyntax);
 
     static Transcoded* Transcode(DataSourceReader& reader,
                                  const FileInfo& attachment,
                                  DicomTransferSyntax targetSyntax,
                                  TranscodingSopInstanceUidMode mode,
-                                 unsigned int lossyQuality,
-                                 bool checkMD5);
+                                 unsigned int lossyQuality);
   };
 }
--- a/OrthancServer/Sources/ServerContext.cpp	Thu May 21 16:48:05 2026 +0200
+++ b/OrthancServer/Sources/ServerContext.cpp	Fri May 22 07:53:32 2026 +0200
@@ -424,11 +424,12 @@
     readOnly_(readOnly),
     patientLevelEnabled_(true),
     deidentifyLogs_(false),
-    serverStartTimeUtc_(boost::posix_time::second_clock::universal_time()),
-    checkMD5_(true)
+    serverStartTimeUtc_(boost::posix_time::second_clock::universal_time())
   {
     try
     {
+      bool checkMD5 = true;
+
       {
         OrthancConfiguration::ReaderLock lock;
 
@@ -555,7 +556,7 @@
 
         defaultDicomRetrieveMethod_ = StringToRetrieveMethod(lock.GetConfiguration().GetDicomDefaultRetrieveMethod());
 
-        checkMD5_ = lock.GetConfiguration().GetBooleanParameter("CheckMD5", true);  // TODO-Streaming - Parameter
+        checkMD5 = lock.GetConfiguration().GetBooleanParameter("CheckMD5", true);  // TODO-Streaming - Parameter
       }
 
       jobsEngine_.SetThreadSleep(unitTesting ? 20 : 200);
@@ -579,7 +580,7 @@
         pool->SetDequeueTimeout(100);
         pool->Start();
 
-        storageAreaReader_.reset(new DataSourceReader(pool, new StorageAreaDataSource(area_)));
+        storageAreaReader_.reset(new DataSourceReader(pool, new StorageAreaDataSource(area_, checkMD5)));
         storageAreaReader_->SetCapacity(1 * GIGABYTE);  // 1 GB - TODO-Streaming - Parameter
         storageAreaReader_->CreateCache(256 * MEGABYTE); // 256 MB - TODO-Streaming - Parameter
       }
@@ -1319,8 +1320,7 @@
 
     if (LookupAttachment(attachment, FileContentType_DicomUntilPixelData, instanceAttachments))
     {
-      std::unique_ptr<DicomDataSource::Dicom> dicom(
-        DicomDataSource::ReadWhole(*dicomReader_, attachment, checkMD5_));
+      std::unique_ptr<DicomDataSource::Dicom> dicom(DicomDataSource::ReadWhole(*dicomReader_, attachment));
 
       {
         DicomDataSource::Dicom::Lock lock(*dicom);
@@ -1479,7 +1479,7 @@
   StorageAreaDataSource::Range* ServerContext::ReadAttachment(const FileInfo& attachment,
                                                               bool uncompress)
   {
-    return StorageAreaDataSource::ReadAttachment(*storageAreaReader_, attachment, uncompress, checkMD5_);
+    return StorageAreaDataSource::ReadAttachment(*storageAreaReader_, attachment, uncompress);
   }
 
 
@@ -1487,20 +1487,20 @@
                                                               const StorageRange& range,
                                                               bool uncompress)
   {
-    return StorageAreaDataSource::ReadRange(*storageAreaReader_, attachment, range, uncompress, checkMD5_);
+    return StorageAreaDataSource::ReadRange(*storageAreaReader_, attachment, range, uncompress);
   }
 
 
   StorageAreaDataSource::Range* ServerContext::ReadRawDicom(const std::string& instancePublicId)
   {
-    return StorageAreaDataSource::ReadAttachment(*storageAreaReader_, LookupDicomForInstance(instancePublicId),
-                                                 true /* uncompress */, checkMD5_);
+    return StorageAreaDataSource::ReadAttachment(
+      *storageAreaReader_, LookupDicomForInstance(instancePublicId), true /* uncompress */);
   }
 
 
   DicomDataSource::Dicom* ServerContext::ReadParsedDicom(const std::string& instancePublicId)
   {
-    return DicomDataSource::ReadWhole(*dicomReader_, LookupDicomForInstance(instancePublicId), checkMD5_);
+    return DicomDataSource::ReadWhole(*dicomReader_, LookupDicomForInstance(instancePublicId));
   }
 
 
@@ -1512,7 +1512,7 @@
     if (index_.LookupAttachment(attachment, revision, ResourceType_Instance,
                                 instancePublicId, FileContentType_DicomUntilPixelData))
     {
-      return DicomDataSource::ReadWhole(*dicomReader_, attachment, checkMD5_);
+      return DicomDataSource::ReadWhole(*dicomReader_, attachment);
     }
     else
     {
@@ -1538,7 +1538,7 @@
       }
 
       // Fallback: The pixel data offset is not present or cannot be used, the whole DICOM file must be read
-      return DicomDataSource::ReadWhole(*dicomReader_, attachment, checkMD5_);
+      return DicomDataSource::ReadWhole(*dicomReader_, attachment);
     }
   }
 
@@ -1850,7 +1850,7 @@
 
     std::unique_ptr<ImageAccessor> decoded;
 
-    decoded.reset(GetTranscoder()->DecodeFrame(dicomReader_, storageAreaReader_, transcoderReader_, attachment, frameIndex, checkMD5_));
+    decoded.reset(GetTranscoder()->DecodeFrame(dicomReader_, storageAreaReader_, transcoderReader_, attachment, frameIndex));
 
     if (decoded.get() == NULL)
     {
--- a/OrthancServer/Sources/ServerContext.h	Thu May 21 16:48:05 2026 +0200
+++ b/OrthancServer/Sources/ServerContext.h	Fri May 22 07:53:32 2026 +0200
@@ -287,7 +287,6 @@
     boost::posix_time::ptime serverStartTimeUtc_;
 
     // For streaming
-    bool                                 checkMD5_;
     boost::shared_ptr<DataSourceReader>  storageAreaReader_;
     boost::shared_ptr<DataSourceReader>  dicomReader_;
     boost::shared_ptr<ThreadPool>        transcoderThreadPool_;
--- a/OrthancServer/Sources/ServerTranscoder.cpp	Thu May 21 16:48:05 2026 +0200
+++ b/OrthancServer/Sources/ServerTranscoder.cpp	Fri May 22 07:53:32 2026 +0200
@@ -231,11 +231,9 @@
 
   ImageAccessor* ServerTranscoder::DecodeFrameBuiltin(const boost::shared_ptr<DataSourceReader>& dicomReader,
                                                       const FileInfo& attachment,
-                                                      unsigned int frameIndex,
-                                                      bool checkMD5)
+                                                      unsigned int frameIndex)
   {
-    std::unique_ptr<DicomDataSource::Dicom> dicom(
-      DicomDataSource::ReadWhole(*dicomReader, attachment, checkMD5));
+    std::unique_ptr<DicomDataSource::Dicom> dicom(DicomDataSource::ReadWhole(*dicomReader, attachment));
 
     DicomDataSource::Dicom::Lock lock(*dicom);
 
@@ -245,8 +243,7 @@
 
   ImageAccessor* ServerTranscoder::DecodeFrameUsingPluginsDecoder(const boost::shared_ptr<DataSourceReader>& storageAreaReader,
                                                                   const FileInfo& attachment,
-                                                                  unsigned int frameIndex,
-                                                                  bool checkMD5)
+                                                                  unsigned int frameIndex)
   {
     if (!HasPluginsDecoder())
     {
@@ -255,7 +252,7 @@
     else
     {
       std::unique_ptr<StorageAreaDataSource::Range> range(
-        StorageAreaDataSource::ReadAttachment(*storageAreaReader, attachment, true /* uncompress */, checkMD5));
+        StorageAreaDataSource::ReadAttachment(*storageAreaReader, attachment, true /* uncompress */));
 
       return DecodeFrameUsingPluginsDecoder(range->GetData(), range->GetSize(), frameIndex);
     }
@@ -264,8 +261,7 @@
 
   ImageAccessor* ServerTranscoder::DecodeFrameUsingPluginsTranscoder(const boost::shared_ptr<DataSourceReader>& transcoderReader,
                                                                      const FileInfo& attachment,
-                                                                     unsigned int frameIndex,
-                                                                     bool checkMD5)
+                                                                     unsigned int frameIndex)
   {
     if (!HasPluginsDecoder())
     {
@@ -274,7 +270,7 @@
     else
     {
       std::unique_ptr<TranscoderDataSource::Transcoded> transcoded(
-        TranscoderDataSource::Transcode(*transcoderReader, attachment, DicomTransferSyntax_LittleEndianExplicit, checkMD5));
+        TranscoderDataSource::Transcode(*transcoderReader, attachment, DicomTransferSyntax_LittleEndianExplicit));
 
       TranscoderDataSource::Transcoded::Lock lock(*transcoded);
 
@@ -326,8 +322,7 @@
                                                const boost::shared_ptr<DataSourceReader>& storageAreaReader,  // For plugin-based decoding
                                                const boost::shared_ptr<DataSourceReader>& transcoderReader,   // For transcoding-based decoding
                                                const FileInfo& attachment,
-                                               unsigned int frameIndex,
-                                               bool checkMD5)
+                                               unsigned int frameIndex)
   {
     // Step 1: Try with the last decoder that successfully handled this DICOM attachment
 
@@ -341,15 +336,15 @@
         break;
 
       case WorkingSource_Builtin:
-        decoded.reset(DecodeFrameBuiltin(dicomReader, attachment, frameIndex, checkMD5));
+        decoded.reset(DecodeFrameBuiltin(dicomReader, attachment, frameIndex));
         break;
 
       case WorkingSource_PluginsDecoder:
-        decoded.reset(DecodeFrameUsingPluginsDecoder(storageAreaReader, attachment, frameIndex, checkMD5));
+        decoded.reset(DecodeFrameUsingPluginsDecoder(storageAreaReader, attachment, frameIndex));
         break;
 
       case WorkingSource_PluginsTranscoder:
-        decoded.reset(DecodeFrameUsingPluginsTranscoder(transcoderReader, attachment, frameIndex, checkMD5));
+        decoded.reset(DecodeFrameUsingPluginsTranscoder(transcoderReader, attachment, frameIndex));
         break;
 
       default:
@@ -365,7 +360,7 @@
 
     if (builtinDecoderTranscoderOrder_ == BuiltinDecoderTranscoderOrder_Before)
     {
-      decoded.reset(DecodeFrameBuiltin(dicomReader, attachment, frameIndex, checkMD5));
+      decoded.reset(DecodeFrameBuiltin(dicomReader, attachment, frameIndex));
 
       if (decoded.get() != NULL)
       {
@@ -376,7 +371,7 @@
 
     if (HasPluginsDecoder())
     {
-      decoded.reset(DecodeFrameUsingPluginsDecoder(storageAreaReader, attachment, frameIndex, checkMD5));
+      decoded.reset(DecodeFrameUsingPluginsDecoder(storageAreaReader, attachment, frameIndex));
 
       if (decoded.get() != NULL)
       {
@@ -387,7 +382,7 @@
 
     if (builtinDecoderTranscoderOrder_ == BuiltinDecoderTranscoderOrder_After)
     {
-      decoded.reset(DecodeFrameBuiltin(dicomReader, attachment, frameIndex, checkMD5));
+      decoded.reset(DecodeFrameBuiltin(dicomReader, attachment, frameIndex));
 
       if (decoded.get() != NULL)
       {
@@ -398,7 +393,7 @@
 
     if (HasPluginsTranscoder())
     {
-      decoded.reset(DecodeFrameUsingPluginsTranscoder(transcoderReader, attachment, frameIndex, checkMD5));
+      decoded.reset(DecodeFrameUsingPluginsTranscoder(transcoderReader, attachment, frameIndex));
 
       if (decoded.get() != NULL)
       {
--- a/OrthancServer/Sources/ServerTranscoder.h	Thu May 21 16:48:05 2026 +0200
+++ b/OrthancServer/Sources/ServerTranscoder.h	Fri May 22 07:53:32 2026 +0200
@@ -66,18 +66,15 @@
 
     ImageAccessor* DecodeFrameBuiltin(const boost::shared_ptr<DataSourceReader>& dicomReader,
                                       const FileInfo& attachment,
-                                      unsigned int frameIndex,
-                                      bool checkMD5);
+                                      unsigned int frameIndex);
 
     ImageAccessor* DecodeFrameUsingPluginsDecoder(const boost::shared_ptr<DataSourceReader>& storageAreaReader,
                                                   const FileInfo& attachment,
-                                                  unsigned int frameIndex,
-                                                  bool checkMD5);
+                                                  unsigned int frameIndex);
 
     ImageAccessor* DecodeFrameUsingPluginsTranscoder(const boost::shared_ptr<DataSourceReader>& transcoderReader,
                                                      const FileInfo& attachment,
-                                                     unsigned int frameIndex,
-                                                     bool checkMD5);
+                                                     unsigned int frameIndex);
 
   public:
     ServerTranscoder(unsigned int maxConcurrentDcmtkTranscoder);
@@ -98,8 +95,7 @@
                                const boost::shared_ptr<DataSourceReader>& storageAreaReader,  // For plugin-based decoding
                                const boost::shared_ptr<DataSourceReader>& transcoderReader,   // For transcoding-based decoding
                                const FileInfo& attachment,
-                               unsigned int frameIndex,
-                               bool checkMD5);
+                               unsigned int frameIndex);
 
     // This method can be used even if the global option
     // "TranscodeDicomProtocol" is set to "false"