Mercurial > hg > orthanc
comparison OrthancFramework/Sources/DicomParsing/ParsedDicomFile.cpp @ 5406:aaf7c49a9ddc am-http-compression
tentative to implement smart HTTP compression with detection of transfer syntax
author | Alain Mazy <am@osimis.io> |
---|---|
date | Sat, 04 Nov 2023 13:42:30 +0100 |
parents | c5f1865aaa3b |
children |
comparison
equal
deleted
inserted
replaced
5405:62bb63346185 | 5406:aaf7c49a9ddc |
---|---|
358 DcmPixelItem* pixelItem = NULL; | 358 DcmPixelItem* pixelItem = NULL; |
359 if (pixelSequence->getItem(pixelItem, block).good() && pixelItem) | 359 if (pixelSequence->getItem(pixelItem, block).good() && pixelItem) |
360 { | 360 { |
361 if (pixelItem->getLength() == 0) | 361 if (pixelItem->getLength() == 0) |
362 { | 362 { |
363 output.AnswerBuffer(NULL, 0, MimeType_Binary); | 363 output.AnswerBuffer(NULL, 0, MimeType_Binary, ContentCompression_AlreadyCompressed); |
364 return true; | 364 return true; |
365 } | 365 } |
366 | 366 |
367 Uint8* buffer = NULL; | 367 Uint8* buffer = NULL; |
368 if (pixelItem->getUint8Array(buffer).good() && buffer) | 368 if (pixelItem->getUint8Array(buffer).good() && buffer) |
369 { | 369 { |
370 output.AnswerBuffer(buffer, pixelItem->getLength(), MimeType_Binary); | 370 output.AnswerBuffer(buffer, pixelItem->getLength(), MimeType_Binary, ContentCompression_AlreadyCompressed); |
371 return true; | 371 return true; |
372 } | 372 } |
373 } | 373 } |
374 } | 374 } |
375 } | 375 } |
376 else | 376 else |
377 { | 377 { |
378 // This is the case for raw, uncompressed image buffers | 378 // This is the case for raw, uncompressed image buffers |
379 assert(*blockUri == "0"); | 379 assert(*blockUri == "0"); |
380 DicomFieldStream stream(*element, transferSyntax); | 380 DicomFieldStream stream(*element, transferSyntax); |
381 output.AnswerStream(stream); | 381 output.AnswerStream(stream, ContentCompression_NotCompressed); |
382 } | 382 } |
383 } | 383 } |
384 } | 384 } |
385 catch (boost::bad_lexical_cast&) | 385 catch (boost::bad_lexical_cast&) |
386 { | 386 { |
836 void ParsedDicomFile::Answer(RestApiOutput& output) const | 836 void ParsedDicomFile::Answer(RestApiOutput& output) const |
837 { | 837 { |
838 std::string serialized; | 838 std::string serialized; |
839 if (FromDcmtkBridge::SaveToMemoryBuffer(serialized, *GetDcmtkObjectConst().getDataset())) | 839 if (FromDcmtkBridge::SaveToMemoryBuffer(serialized, *GetDcmtkObjectConst().getDataset())) |
840 { | 840 { |
841 output.AnswerBuffer(serialized, MimeType_Dicom); | 841 ContentCompression contentCompression = ContentCompression_Unknown; |
842 DicomTransferSyntax transferSyntax; | |
843 | |
844 if (LookupTransferSyntax(transferSyntax)) | |
845 { | |
846 contentCompression = (IsCompressedTransferSyntax(transferSyntax) ? ContentCompression_AlreadyCompressed : ContentCompression_NotCompressed); | |
847 } | |
848 | |
849 output.AnswerBuffer(serialized, | |
850 MimeType_Dicom, | |
851 contentCompression); | |
842 } | 852 } |
843 } | 853 } |
844 #endif | 854 #endif |
845 | 855 |
846 | 856 |