comparison OrthancServer/ServerJobs/OrthancPeerStoreJob.cpp @ 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
comparison
equal deleted inserted replaced
3949:ef696db8426f 3950:5797ca4f3b8d
36 36
37 #include "../../Core/Logging.h" 37 #include "../../Core/Logging.h"
38 #include "../../Core/SerializationToolbox.h" 38 #include "../../Core/SerializationToolbox.h"
39 #include "../ServerContext.h" 39 #include "../ServerContext.h"
40 40
41 #include <dcmtk/dcmdata/dcfilefo.h>
42
41 43
42 namespace Orthanc 44 namespace Orthanc
43 { 45 {
44 bool OrthancPeerStoreJob::HandleInstance(const std::string& instance) 46 bool OrthancPeerStoreJob::HandleInstance(const std::string& instance)
45 { 47 {
54 LOG(INFO) << "Sending instance " << instance << " to peer \"" 56 LOG(INFO) << "Sending instance " << instance << " to peer \""
55 << peer_.GetUrl() << "\""; 57 << peer_.GetUrl() << "\"";
56 58
57 try 59 try
58 { 60 {
59 context_.ReadDicom(client_->GetBody(), instance); 61 if (transcode_)
62 {
63 std::string dicom;
64 context_.ReadDicom(dicom, instance);
65
66 std::set<DicomTransferSyntax> syntaxes;
67 syntaxes.insert(transferSyntax_);
68
69 IDicomTranscoder::DicomImage source, transcoded;
70 source.SetExternalBuffer(dicom);
71
72 bool hasSopInstanceUidChanged;
73 if (context_.Transcode(transcoded, hasSopInstanceUidChanged, source, syntaxes, true))
74 {
75 client_->GetBody().assign(reinterpret_cast<const char*>(transcoded.GetBufferData()),
76 transcoded.GetBufferSize());
77 }
78 else
79 {
80 client_->GetBody().swap(dicom);
81 }
82 }
83 else
84 {
85 context_.ReadDicom(client_->GetBody(), instance);
86 }
60 } 87 }
61 catch (OrthancException& e) 88 catch (OrthancException& e)
62 { 89 {
63 LOG(WARNING) << "An instance was removed after the job was issued: " << instance; 90 LOG(WARNING) << "An instance was removed after the job was issued: " << instance;
64 return false; 91 return false;