Mercurial > hg > orthanc
changeset 3950:5797ca4f3b8d transcoding
"/peers/{id}/store": New option "Transcode"
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 19 May 2020 20:37:00 +0200 |
parents | ef696db8426f |
children | 5fe8c6d3212e |
files | NEWS OrthancServer/OrthancRestApi/OrthancRestModalities.cpp OrthancServer/ServerJobs/OrthancPeerStoreJob.cpp |
diffstat | 3 files changed, 51 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/NEWS Tue May 19 18:44:36 2020 +0200 +++ b/NEWS Tue May 19 20:37:00 2020 +0200 @@ -24,6 +24,7 @@ * Changes: - "/{patients|studies|series}/.../modify": New option "KeepSource" - "/{patients|studies|series|instances}/.../modify": New option "Transcode" + - "/peers/{id}/store": New option "Transcode" - ".../archive", ".../media", "/tools/create-media" and "/tools/create-archive": New option "Transcode" - "/ordered-slices": reverted the change introduced in 1.5.8 and go-back
--- a/OrthancServer/OrthancRestApi/OrthancRestModalities.cpp Tue May 19 18:44:36 2020 +0200 +++ b/OrthancServer/OrthancRestApi/OrthancRestModalities.cpp Tue May 19 20:37:00 2020 +0200 @@ -1136,21 +1136,31 @@ std::unique_ptr<OrthancPeerStoreJob> job(new OrthancPeerStoreJob(context)); GetInstancesToExport(request, *job, remote, call); + + static const char* TRANSCODE = "Transcode"; + if (request.type() == Json::objectValue && + request.isMember(TRANSCODE)) + { + job->SetTranscode(SerializationToolbox::ReadString(request, TRANSCODE)); + } - OrthancConfiguration::ReaderLock lock; - - WebServiceParameters peer; - if (lock.GetConfiguration().LookupOrthancPeer(peer, remote)) { - job->SetPeer(peer); - OrthancRestApi::GetApi(call).SubmitCommandsJob - (call, job.release(), true /* synchronous by default */, request); + OrthancConfiguration::ReaderLock lock; + + WebServiceParameters peer; + if (lock.GetConfiguration().LookupOrthancPeer(peer, remote)) + { + job->SetPeer(peer); + } + else + { + throw OrthancException(ErrorCode_UnknownResource, + "No peer with symbolic name: " + remote); + } } - else - { - throw OrthancException(ErrorCode_UnknownResource, - "No peer with symbolic name: " + remote); - } + + OrthancRestApi::GetApi(call).SubmitCommandsJob + (call, job.release(), true /* synchronous by default */, request); } static void PeerSystem(RestApiGetCall& call)
--- a/OrthancServer/ServerJobs/OrthancPeerStoreJob.cpp Tue May 19 18:44:36 2020 +0200 +++ b/OrthancServer/ServerJobs/OrthancPeerStoreJob.cpp Tue May 19 20:37:00 2020 +0200 @@ -38,6 +38,8 @@ #include "../../Core/SerializationToolbox.h" #include "../ServerContext.h" +#include <dcmtk/dcmdata/dcfilefo.h> + namespace Orthanc { @@ -56,7 +58,32 @@ try { - context_.ReadDicom(client_->GetBody(), instance); + if (transcode_) + { + std::string dicom; + context_.ReadDicom(dicom, instance); + + std::set<DicomTransferSyntax> syntaxes; + syntaxes.insert(transferSyntax_); + + IDicomTranscoder::DicomImage source, transcoded; + source.SetExternalBuffer(dicom); + + bool hasSopInstanceUidChanged; + if (context_.Transcode(transcoded, hasSopInstanceUidChanged, source, syntaxes, true)) + { + client_->GetBody().assign(reinterpret_cast<const char*>(transcoded.GetBufferData()), + transcoded.GetBufferSize()); + } + else + { + client_->GetBody().swap(dicom); + } + } + else + { + context_.ReadDicom(client_->GetBody(), instance); + } } catch (OrthancException& e) {