Mercurial > hg > orthanc-dicomweb
changeset 452:36d04c9586c1
Support transcoding in WADO-RS RetrieveStudy, RetrieveSeries and RetrieveInstance
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 22 Jun 2020 16:17:31 +0200 |
parents | f9abaad46bba |
children | 1351ca908f9d |
files | NEWS Plugin/WadoRs.cpp Status.txt |
diffstat | 3 files changed, 40 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/NEWS Mon Jun 22 15:02:56 2020 +0200 +++ b/NEWS Mon Jun 22 16:17:31 2020 +0200 @@ -1,6 +1,7 @@ Pending changes in the mainline =============================== +* Support transcoding in WADO-RS RetrieveStudy, RetrieveSeries and RetrieveInstance * Support of dynamic linking against the Orthanc framework library
--- a/Plugin/WadoRs.cpp Mon Jun 22 15:02:56 2020 +0200 +++ b/Plugin/WadoRs.cpp Mon Jun 22 16:17:31 2020 +0200 @@ -57,7 +57,7 @@ static bool AcceptMultipartDicom(bool& transcode, - Orthanc::DicomTransferSyntax& transferSyntax /* only if transcoding */, + Orthanc::DicomTransferSyntax& targetSyntax /* only if transcoding */, const OrthancPluginHttpRequest* request) { transcode = false; @@ -106,9 +106,13 @@ } else { - throw Orthanc::OrthancException(Orthanc::ErrorCode_BadRequest, - "This WADO-RS plugin cannot change the transfer syntax to " + - found->second); + transcode = true; + + if (!Orthanc::LookupTransferSyntax(targetSyntax, found->second)) + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_BadRequest, + "Unsupported transfer syntax in WADO-RS: " + found->second); + } } } @@ -234,7 +238,7 @@ Orthanc::ResourceType level, const std::string& publicId, bool transcode, - Orthanc::DicomTransferSyntax transferSyntax /* only if transcoding */) + Orthanc::DicomTransferSyntax targetSyntax /* only if transcoding */) { if (level != Orthanc::ResourceType_Study && level != Orthanc::ResourceType_Series && @@ -277,14 +281,27 @@ OrthancPlugins::MemoryBuffer dicom; if (dicom.RestApiGet(uri, false)) { - if (! - OrthancPluginSendMultipartItem(context, output, dicom.GetData(), dicom.GetSize()) != 0) - { - throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); + if (transcode) + { + std::unique_ptr<OrthancPlugins::DicomInstance> transcoded( + OrthancPlugins::DicomInstance::Transcode( + dicom.GetData(), dicom.GetSize(), Orthanc::GetTransferSyntaxUid(targetSyntax))); + + if (OrthancPluginSendMultipartItem( + context, output, reinterpret_cast<const char*>(transcoded->GetBuffer()), + transcoded->GetSize()) != 0) + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); + } + } + else + { + if (OrthancPluginSendMultipartItem(context, output, dicom.GetData(), dicom.GetSize()) != 0) + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); + } + } } - - /*instance.reset(OrthancPlugins::DicomInstance::Transcode( - content.GetData(), content.GetSize(), GetTransferSyntaxUid(targetSyntax)));*/ } } @@ -885,9 +902,9 @@ const OrthancPluginHttpRequest* request) { bool transcode; - Orthanc::DicomTransferSyntax transferSyntax; + Orthanc::DicomTransferSyntax targetSyntax; - if (!AcceptMultipartDicom(transcode, transferSyntax, request)) + if (!AcceptMultipartDicom(transcode, targetSyntax, request)) { OrthancPluginSendHttpStatusCode(OrthancPlugins::GetGlobalContext(), output, 400 /* Bad request */); } @@ -896,7 +913,7 @@ std::string orthancId, studyInstanceUid; if (LocateStudy(output, orthancId, studyInstanceUid, request)) { - AnswerListOfDicomInstances(output, Orthanc::ResourceType_Study, orthancId, transcode, transferSyntax); + AnswerListOfDicomInstances(output, Orthanc::ResourceType_Study, orthancId, transcode, targetSyntax); } } } @@ -907,9 +924,9 @@ const OrthancPluginHttpRequest* request) { bool transcode; - Orthanc::DicomTransferSyntax transferSyntax; + Orthanc::DicomTransferSyntax targetSyntax; - if (!AcceptMultipartDicom(transcode, transferSyntax, request)) + if (!AcceptMultipartDicom(transcode, targetSyntax, request)) { OrthancPluginSendHttpStatusCode(OrthancPlugins::GetGlobalContext(), output, 400 /* Bad request */); } @@ -918,7 +935,7 @@ std::string orthancId, studyInstanceUid, seriesInstanceUid; if (LocateSeries(output, orthancId, studyInstanceUid, seriesInstanceUid, request)) { - AnswerListOfDicomInstances(output, Orthanc::ResourceType_Series, orthancId, transcode, transferSyntax); + AnswerListOfDicomInstances(output, Orthanc::ResourceType_Series, orthancId, transcode, targetSyntax); } } } @@ -930,9 +947,9 @@ const OrthancPluginHttpRequest* request) { bool transcode; - Orthanc::DicomTransferSyntax transferSyntax; + Orthanc::DicomTransferSyntax targetSyntax; - if (!AcceptMultipartDicom(transcode, transferSyntax, request)) + if (!AcceptMultipartDicom(transcode, targetSyntax, request)) { OrthancPluginSendHttpStatusCode(OrthancPlugins::GetGlobalContext(), output, 400 /* Bad request */); } @@ -941,7 +958,7 @@ std::string orthancId, studyInstanceUid, seriesInstanceUid, sopInstanceUid; if (LocateInstance(output, orthancId, studyInstanceUid, seriesInstanceUid, sopInstanceUid, request)) { - AnswerListOfDicomInstances(output, Orthanc::ResourceType_Instance, orthancId, transcode, transferSyntax); + AnswerListOfDicomInstances(output, Orthanc::ResourceType_Instance, orthancId, transcode, targetSyntax); } } }
--- a/Status.txt Mon Jun 22 15:02:56 2020 +0200 +++ b/Status.txt Mon Jun 22 16:17:31 2020 +0200 @@ -39,12 +39,12 @@ --------- * DICOM Response, if no change in the transfer syntax +* DICOM Response with a change in the transfer syntax (since version 1.3) Not supported ------------- -* DICOM Response with a change in the transfer syntax * Bulk data response * MediaType data response