Mercurial > hg > orthanc
changeset 6813:aa91aa473d3d streaming
removed DicomCacheLocker from OrthancRestResources.cpp
| author | Sebastien Jodogne <s.jodogne@gmail.com> |
|---|---|
| date | Tue, 19 May 2026 17:28:05 +0200 |
| parents | d689c2f52405 |
| children | e496596c3e4c |
| files | OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp |
| diffstat | 1 files changed, 57 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp Tue May 19 16:55:23 2026 +0200 +++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp Tue May 19 17:28:05 2026 +0200 @@ -24,6 +24,8 @@ #include "../PrecompiledHeadersServer.h" #include "../ResourceFinder.h" +#include <signal.h> + #include "OrthancRestApi.h" #include "../../../OrthancFramework/Sources/CompatibilityMath.h" @@ -382,8 +384,9 @@ DicomWebJsonVisitor visitor; { - ServerContext::DicomCacheLocker locker(OrthancRestApi::GetContext(call), publicId); - locker.GetDicom().Apply(visitor); + std::unique_ptr<DicomDataSource::Dicom> dicom(context.ReadParsedDicom(publicId, false)); + DicomDataSource::Dicom::Lock lock(*dicom); + lock.GetContent().Apply(visitor); } if (mime == MimeType_DicomWebJson) @@ -520,8 +523,9 @@ Json::Value answer; { - ServerContext::DicomCacheLocker locker(OrthancRestApi::GetContext(call), publicId); - locker.GetDicom().DatasetToJson(answer, format, flags, + std::unique_ptr<DicomDataSource::Dicom> dicom(context.ReadParsedDicom(publicId, false)); + DicomDataSource::Dicom::Lock lock(*dicom); + lock.GetContent().DatasetToJson(answer, format, flags, ORTHANC_MAXIMUM_TAG_LENGTH, ignoreTagLength); } @@ -634,13 +638,16 @@ return; } + ServerContext& context = OrthancRestApi::GetContext(call); + std::string publicId = call.GetUriComponent("id", ""); unsigned int numberOfFrames; { - ServerContext::DicomCacheLocker locker(OrthancRestApi::GetContext(call), publicId); - numberOfFrames = locker.GetDicom().GetFramesCount(); + std::unique_ptr<DicomDataSource::Dicom> dicom(context.ReadParsedDicom(publicId, false)); + DicomDataSource::Dicom::Lock lock(*dicom); + numberOfFrames = lock.GetContent().GetFramesCount(); } Json::Value result = Json::arrayValue; @@ -923,9 +930,11 @@ * Retrieve a summary of the DICOM tags, which is * necessary to deal with MONOCHROME1 photometric * interpretation, and with windowing parameters. - **/ - ServerContext::DicomCacheLocker locker(context, publicId); - handler.Handle(call, decoded, &locker.GetDicom(), frame); + **/ + + std::unique_ptr<DicomDataSource::Dicom> dicom(context.ReadParsedDicom(publicId, false)); + DicomDataSource::Dicom::Lock lock(*dicom); + handler.Handle(call, decoded, &lock.GetContent(), frame); } else { @@ -1393,6 +1402,8 @@ } else { + ServerContext& context = OrthancRestApi::GetContext(call); + const std::string instanceId = call.GetUriComponent("id", ""); const bool compress = call.GetBooleanArgument("compress", false); const bool rescale = call.GetBooleanArgument("rescale", true); @@ -1406,10 +1417,9 @@ NumpyVisitor visitor(0 /* no depth, 2D frame */, rescale); { - Semaphore::Locker throttling(throttlingSemaphore_); - ServerContext::DicomCacheLocker locker(OrthancRestApi::GetContext(call), instanceId); - - visitor.WriteFrame(locker.GetDicom(), frame); + std::unique_ptr<DicomDataSource::Dicom> dicom(context.ReadParsedDicom(instanceId, false)); + DicomDataSource::Dicom::Lock lock(*dicom); + visitor.WriteFrame(lock.GetContent(), frame); } visitor.Answer(call.GetOutput(), compress); @@ -1430,15 +1440,17 @@ } else { + ServerContext& context = OrthancRestApi::GetContext(call); + const std::string instanceId = call.GetUriComponent("id", ""); const bool compress = call.GetBooleanArgument("compress", false); const bool rescale = call.GetBooleanArgument("rescale", true); { - Semaphore::Locker throttling(throttlingSemaphore_); - ServerContext::DicomCacheLocker locker(OrthancRestApi::GetContext(call), instanceId); - - const unsigned int depth = locker.GetDicom().GetFramesCount(); + std::unique_ptr<DicomDataSource::Dicom> dicom(context.ReadParsedDicom(instanceId, false)); + DicomDataSource::Dicom::Lock lock(*dicom); + + const unsigned int depth = lock.GetContent().GetFramesCount(); if (depth == 0) { throw OrthancException(ErrorCode_BadFileFormat, "Empty DICOM instance"); @@ -1448,7 +1460,7 @@ for (unsigned int frame = 0; frame < depth; frame++) { - visitor.WriteFrame(locker.GetDicom(), frame); + visitor.WriteFrame(lock.GetContent(), frame); } visitor.Answer(call.GetOutput(), compress); @@ -1474,8 +1486,6 @@ const bool compress = call.GetBooleanArgument("compress", false); const bool rescale = call.GetBooleanArgument("rescale", true); - Semaphore::Locker throttling(throttlingSemaphore_); - ServerIndex& index = OrthancRestApi::GetIndex(call); SliceOrdering ordering(index, seriesId); @@ -1495,11 +1505,12 @@ unsigned int framesCount = ordering.GetFramesCount(i); { - ServerContext::DicomCacheLocker locker(context, instanceId); + std::unique_ptr<DicomDataSource::Dicom> dicom(context.ReadParsedDicom(instanceId, false)); + DicomDataSource::Dicom::Lock lock(*dicom); for (unsigned int frame = 0; frame < framesCount; frame++) { - visitor.WriteFrame(locker.GetDicom(), frame); + visitor.WriteFrame(lock.GetContent(), frame); } } } @@ -1594,7 +1605,9 @@ } return; } - + + ServerContext& context = OrthancRestApi::GetContext(call); + std::string frameId = call.GetUriComponent("frame", "0"); unsigned int frame; @@ -1612,8 +1625,9 @@ MimeType mime; { - ServerContext::DicomCacheLocker locker(OrthancRestApi::GetContext(call), publicId); - locker.GetDicom().GetRawFrame(raw, mime, frame); + std::unique_ptr<DicomDataSource::Dicom> dicom(context.ReadParsedDicom(publicId, false)); + DicomDataSource::Dicom::Lock lock(*dicom); + lock.GetContent().GetRawFrame(raw, mime, frame); } if (GzipCompression) @@ -2842,11 +2856,15 @@ return; } + ServerContext& context = OrthancRestApi::GetContext(call); + std::string id = call.GetUriComponent("id", ""); - ServerContext::DicomCacheLocker locker(OrthancRestApi::GetContext(call), id); - - locker.GetDicom().SendPathValue(call.GetOutput(), call.GetTrailingUri()); + { + std::unique_ptr<DicomDataSource::Dicom> dicom(context.ReadParsedDicom(id, false)); + DicomDataSource::Dicom::Lock lock(*dicom); + lock.GetContent().SendPathValue(call.GetOutput(), call.GetTrailingUri()); + } } @@ -3809,14 +3827,20 @@ return; } + ServerContext& context = OrthancRestApi::GetContext(call); + const std::string id = call.GetUriComponent("id", ""); std::string pdf; - ServerContext::DicomCacheLocker locker(OrthancRestApi::GetContext(call), id); - - if (locker.GetDicom().ExtractPdf(pdf)) + { - call.GetOutput().AnswerBuffer(pdf, MimeType_Pdf); - return; + std::unique_ptr<DicomDataSource::Dicom> dicom(context.ReadParsedDicom(id, false)); + DicomDataSource::Dicom::Lock lock(*dicom); + + if (lock.GetContent().ExtractPdf(pdf)) + { + call.GetOutput().AnswerBuffer(pdf, MimeType_Pdf); + return; + } } }
