Mercurial > hg > orthanc
changeset 6860:e66251d14156 streaming
optimization in OrthancGetRequestHandler
| author | Sebastien Jodogne <s.jodogne@gmail.com> |
|---|---|
| date | Tue, 26 May 2026 13:38:11 +0200 |
| parents | a4f90fb6b3e2 |
| children | f475ce43d92f |
| files | OrthancServer/Sources/OrthancGetRequestHandler.cpp OrthancServer/Sources/OrthancGetRequestHandler.h OrthancServer/Sources/main.cpp |
| diffstat | 3 files changed, 17 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancServer/Sources/OrthancGetRequestHandler.cpp Sat May 23 22:09:26 2026 +0200 +++ b/OrthancServer/Sources/OrthancGetRequestHandler.cpp Tue May 26 13:38:11 2026 +0200 @@ -72,14 +72,15 @@ } { + /** + * It is OK to modify the content of "dicom", as + * "DicomSequentialReader" returns copies of the cached objects + * (cf. "DataSourceSequentialReader::IValueDisconnector"). (*) + **/ std::unique_ptr<ParsedDicomFile> dicom(instancesLoader_->Next()); - if (dicom.get() == NULL) - { - throw OrthancException(ErrorCode_InternalError); - } - - if (dicom->GetDcmtkObject().getDataset() == NULL) + if (dicom.get() == NULL || + dicom->GetDcmtkObject().getDataset() == NULL) { throw OrthancException(ErrorCode_InternalError); } @@ -96,7 +97,7 @@ std::string sopClassUid(a.c_str()); std::string sopInstanceUid(b.c_str()); - return PerformGetSubOp(assoc, sopClassUid, sopInstanceUid, dicom->GetDcmtkObject()); + return PerformGetSubOp(assoc, sopClassUid, sopInstanceUid, *dicom); } } @@ -227,10 +228,10 @@ bool OrthancGetRequestHandler::PerformGetSubOp(T_ASC_Association* assoc, const std::string& sopClassUid, const std::string& sopInstanceUid, - DcmFileFormat& dicom) + ParsedDicomFile& dicom) { DicomTransferSyntax sourceSyntax; - if (!FromDcmtkBridge::LookupOrthancTransferSyntax(sourceSyntax, dicom)) + if (!FromDcmtkBridge::LookupOrthancTransferSyntax(sourceSyntax, dicom.GetDcmtkObject())) { failedCount_++; AddFailedUIDInstance(sopInstanceUid); @@ -307,7 +308,7 @@ // No transcoding is required DcmDataset *stDetailTmp = NULL; cond = DIMSE_storeUser( - assoc, presId, &req, NULL /* imageFileName */, dicom.getDataset(), + assoc, presId, &req, NULL /* imageFileName */, dicom.GetDcmtkObject().getDataset(), ProgressCallback, NULL /* callbackData */, (timeout_ > 0 ? DIMSE_NONBLOCKING : DIMSE_BLOCKING), static_cast<int>(timeout_), &rsp, &stDetailTmp, &cancelParameters); @@ -317,7 +318,9 @@ { // Transcoding to the selected uncompressed transfer syntax IDicomTranscoder::DicomImage source, transcoded; - source.AcquireParsed(new DcmFileFormat(dicom)); // TODO-Streaming : Trancode upfront + source.AcquireParsed(dicom); // This invalidates the "dicom" object, cf. (*) + + // TODO-Streaming : Trancode upfront std::set<DicomTransferSyntax> ts; ts.insert(selectedSyntax);
--- a/OrthancServer/Sources/OrthancGetRequestHandler.h Sat May 23 22:09:26 2026 +0200 +++ b/OrthancServer/Sources/OrthancGetRequestHandler.h Tue May 26 13:38:11 2026 +0200 @@ -27,14 +27,11 @@ #include "../../OrthancFramework/Sources/DicomNetworking/IGetRequestHandler.h" #include "../../OrthancFramework/Sources/DicomNetworking/RemoteModalityParameters.h" -#include <dcmtk/dcmnet/dimse.h> - #include <list> -class DcmFileFormat; - namespace Orthanc { + class ParsedDicomFile; class ServerContext; class OrthancGetRequestHandler : public IGetRequestHandler @@ -63,7 +60,7 @@ bool PerformGetSubOp(T_ASC_Association *assoc, const std::string& sopClassUid, const std::string& sopInstanceUid, - DcmFileFormat& dicom); + ParsedDicomFile& dicom); void AddFailedUIDInstance(const std::string& sopInstance);
--- a/OrthancServer/Sources/main.cpp Sat May 23 22:09:26 2026 +0200 +++ b/OrthancServer/Sources/main.cpp Tue May 26 13:38:11 2026 +0200 @@ -57,6 +57,7 @@ #include "StorageCommitmentReports.h" #include <boost/algorithm/string/predicate.hpp> +#include <dcmtk/dcmnet/dimse.h> // For STATUS_STORE_Error_CannotUnderstand #if defined(_WIN32) || defined(__CYGWIN__) #include <windows.h>
