Mercurial > hg > orthanc
changeset 6861:f475ce43d92f streaming
introducing TranscoderDataSource into DicomSequentialReader
| author | Sebastien Jodogne <s.jodogne@gmail.com> |
|---|---|
| date | Tue, 26 May 2026 14:22:45 +0200 |
| parents | e66251d14156 |
| children | 634a8082ce04 |
| files | OrthancFramework/Sources/DataSource/DicomSequentialReader.cpp OrthancFramework/Sources/DataSource/DicomSequentialReader.h OrthancFramework/Sources/DataSource/TranscoderDataSource.cpp OrthancFramework/Sources/DataSource/TranscoderDataSource.h OrthancServer/Sources/OrthancGetRequestHandler.cpp OrthancServer/Sources/ServerContext.cpp OrthancServer/Sources/ServerContext.h OrthancServer/Sources/ServerTranscoder.cpp |
| diffstat | 8 files changed, 68 insertions(+), 38 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancFramework/Sources/DataSource/DicomSequentialReader.cpp Tue May 26 13:38:11 2026 +0200 +++ b/OrthancFramework/Sources/DataSource/DicomSequentialReader.cpp Tue May 26 14:22:45 2026 +0200 @@ -71,12 +71,18 @@ DicomSequentialReader::DicomSequentialReader(Type type, const boost::shared_ptr<IExecutorService>& executor, - DicomTransferSyntax transferSyntax, + DicomTransferSyntax targetSyntax, + TranscodingSopInstanceUidMode mode, + bool hasLossyQuality, + unsigned int lossyQuality, const boost::shared_ptr<DataSourceReader>& reader, unsigned int windowSize, uint64_t windowCapacity) : type_(type), - transferSyntax_(transferSyntax), + targetSyntax_(targetSyntax), + mode_(mode), + hasLossyQuality_(hasLossyQuality), + lossyQuality_(lossyQuality), reader_(executor, reader, new Disconnector(type), windowSize, windowCapacity) { } @@ -95,6 +101,10 @@ id.reset(DicomDataSource::CreateWholeRequest(attachment)); break; + case Type_Transcoded: + id.reset(TranscoderDataSource::CreateRequest(attachment, targetSyntax_, mode_, hasLossyQuality_, lossyQuality_)); + break; + default: throw OrthancException(ErrorCode_InternalError); } @@ -114,19 +124,26 @@ uint64_t windowCapacity) { return new DicomSequentialReader( - Type_Original, executor, DicomTransferSyntax_LittleEndianImplicit /* dummy value */, + Type_Original, executor, + DicomTransferSyntax_LittleEndianImplicit, TranscodingSopInstanceUidMode_AllowNew, + false /* no lossy */, 0 /* unused lossy quality */, dicomReader, windowSize, windowCapacity); } DicomSequentialReader* DicomSequentialReader::CreateForTranscoded(const boost::shared_ptr<IExecutorService>& executor, - DicomTransferSyntax transferSyntax, + DicomTransferSyntax targetSyntax, + TranscodingSopInstanceUidMode mode, + bool hasLossyQuality, + unsigned int lossyQuality, const boost::shared_ptr<DataSourceReader>& transcoderReader, unsigned int windowSize, uint64_t windowCapacity) { return new DicomSequentialReader( - Type_Transcoded, executor, transferSyntax, transcoderReader, windowSize, windowCapacity); + Type_Transcoded, executor, + targetSyntax, mode, hasLossyQuality, lossyQuality, + transcoderReader, windowSize, windowCapacity); }
--- a/OrthancFramework/Sources/DataSource/DicomSequentialReader.h Tue May 26 13:38:11 2026 +0200 +++ b/OrthancFramework/Sources/DataSource/DicomSequentialReader.h Tue May 26 14:22:45 2026 +0200 @@ -45,13 +45,19 @@ Type_Transcoded }; - Type type_; - DicomTransferSyntax transferSyntax_; - DataSourceSequentialReader reader_; + Type type_; + DicomTransferSyntax targetSyntax_; + TranscodingSopInstanceUidMode mode_; + bool hasLossyQuality_; + unsigned int lossyQuality_; + DataSourceSequentialReader reader_; DicomSequentialReader(Type type, const boost::shared_ptr<IExecutorService>& executor, - DicomTransferSyntax transferSyntax, + DicomTransferSyntax targetSyntax, + TranscodingSopInstanceUidMode mode, + bool hasLossyQuality, + unsigned int lossyQuality, const boost::shared_ptr<DataSourceReader>& reader, unsigned int windowSize, uint64_t windowCapacity); @@ -66,7 +72,10 @@ uint64_t windowCapacity); static DicomSequentialReader* CreateForTranscoded(const boost::shared_ptr<IExecutorService>& executor, - DicomTransferSyntax transferSyntax, + DicomTransferSyntax targetSyntax, + TranscodingSopInstanceUidMode mode, + bool hasLossyQuality, + unsigned int lossyQuality, const boost::shared_ptr<DataSourceReader>& transcoderReader, unsigned int windowSize, uint64_t windowCapacity);
--- a/OrthancFramework/Sources/DataSource/TranscoderDataSource.cpp Tue May 26 13:38:11 2026 +0200 +++ b/OrthancFramework/Sources/DataSource/TranscoderDataSource.cpp Tue May 26 14:22:45 2026 +0200 @@ -146,20 +146,16 @@ public: Identifier(const FileInfo& attachment, - DicomTransferSyntax targetSyntax) : + DicomTransferSyntax targetSyntax, + TranscodingSopInstanceUidMode mode) : attachment_(attachment), targetSyntax_(targetSyntax), - mode_(TranscodingSopInstanceUidMode_AllowNew), + mode_(mode), hasLossyQuality_(false), lossyQuality_(0) { } - void SetMode(TranscodingSopInstanceUidMode mode) - { - mode_ = mode; - } - void SetLossyQuality(unsigned int quality) { hasLossyQuality_ = true; @@ -172,8 +168,7 @@ GetTransferSyntaxUid(targetSyntax_) + "|" + boost::lexical_cast<std::string>(mode_)); - if (hasLossyQuality_ && - !IsLosslessTransferSyntax(targetSyntax_)) + if (hasLossyQuality_) { key += "|" + boost::lexical_cast<std::string>(lossyQuality_); } @@ -302,20 +297,19 @@ IDataIdentifier* TranscoderDataSource::CreateRequest(const FileInfo& attachment, - DicomTransferSyntax targetSyntax) - { - return new Identifier(attachment, targetSyntax); - } - - - IDataIdentifier* TranscoderDataSource::CreateRequest(const FileInfo& attachment, DicomTransferSyntax targetSyntax, TranscodingSopInstanceUidMode mode, + bool hasLossyQuality, unsigned int lossyQuality) { - std::unique_ptr<Identifier> id(new Identifier(attachment, targetSyntax)); - id->SetMode(mode); - id->SetLossyQuality(lossyQuality); + std::unique_ptr<Identifier> id(new Identifier(attachment, targetSyntax, mode)); + + if (hasLossyQuality && + !IsLosslessTransferSyntax(targetSyntax)) + { + id->SetLossyQuality(lossyQuality); + } + return id.release(); }
--- a/OrthancFramework/Sources/DataSource/TranscoderDataSource.h Tue May 26 13:38:11 2026 +0200 +++ b/OrthancFramework/Sources/DataSource/TranscoderDataSource.h Tue May 26 14:22:45 2026 +0200 @@ -105,11 +105,9 @@ }; static IDataIdentifier* CreateRequest(const FileInfo& attachment, - DicomTransferSyntax targetSyntax); - - static IDataIdentifier* CreateRequest(const FileInfo& attachment, DicomTransferSyntax targetSyntax, TranscodingSopInstanceUidMode mode, + bool hasLossyQuality, unsigned int lossyQuality); static Transcoded* Execute(DataSourceReader& reader,
--- a/OrthancServer/Sources/OrthancGetRequestHandler.cpp Tue May 26 13:38:11 2026 +0200 +++ b/OrthancServer/Sources/OrthancGetRequestHandler.cpp Tue May 26 14:22:45 2026 +0200 @@ -320,7 +320,12 @@ IDicomTranscoder::DicomImage source, transcoded; source.AcquireParsed(dicom); // This invalidates the "dicom" object, cf. (*) - // TODO-Streaming : Trancode upfront + /** + * TODO-Streaming : It doesn't seem possible to uniformly trancode upfront + * using "DicomSequentialReader::CreateForTranscoded()", as the + * selected transfer syntax is not constant, but varies upon + * each individual instance given the presentation context. + **/ std::set<DicomTransferSyntax> ts; ts.insert(selectedSyntax);
--- a/OrthancServer/Sources/ServerContext.cpp Tue May 26 13:38:11 2026 +0200 +++ b/OrthancServer/Sources/ServerContext.cpp Tue May 26 14:22:45 2026 +0200 @@ -2162,10 +2162,13 @@ } - DicomSequentialReader* ServerContext::CreateDicomSequentialReader(DicomTransferSyntax transcodingSyntax) + DicomSequentialReader* ServerContext::CreateTranscodedSequentialReader(DicomTransferSyntax targetSyntax, + TranscodingSopInstanceUidMode mode, + bool hasLossyQuality, + unsigned int lossyQuality) { return DicomSequentialReader::CreateForTranscoded( - sequentialReaderThreadPool_, transcodingSyntax, transcoderReader_, + sequentialReaderThreadPool_, targetSyntax, mode, hasLossyQuality, lossyQuality, transcoderReader_, 4 /* TODO-Streaming: Parameter */, 0 /* TODO-Streaming: Parameter */); }
--- a/OrthancServer/Sources/ServerContext.h Tue May 26 13:38:11 2026 +0200 +++ b/OrthancServer/Sources/ServerContext.h Tue May 26 14:22:45 2026 +0200 @@ -595,6 +595,9 @@ DicomSequentialReader* CreateDicomSequentialReader(); - DicomSequentialReader* CreateDicomSequentialReader(DicomTransferSyntax transcodingSyntax); + DicomSequentialReader* CreateTranscodedSequentialReader(DicomTransferSyntax targetSyntax, + TranscodingSopInstanceUidMode mode, + bool hasLossyQuality, + unsigned int lossyQuality); }; }
--- a/OrthancServer/Sources/ServerTranscoder.cpp Tue May 26 13:38:11 2026 +0200 +++ b/OrthancServer/Sources/ServerTranscoder.cpp Tue May 26 14:22:45 2026 +0200 @@ -278,8 +278,9 @@ else { std::unique_ptr<TranscoderDataSource::Transcoded> transcoded( - TranscoderDataSource::Execute( - *transcoderReader, TranscoderDataSource::CreateRequest(attachment, DicomTransferSyntax_LittleEndianExplicit))); + TranscoderDataSource::Execute(*transcoderReader, TranscoderDataSource::CreateRequest( + attachment, DicomTransferSyntax_LittleEndianExplicit, + TranscodingSopInstanceUidMode_AllowNew, false /* no lossy quality specified */, 0))); TranscoderDataSource::Transcoded::LockAsParsed lock(*transcoded);
