comparison Core/DicomNetworking/DicomStoreUserConnection.h @ 3896:210af28c4087 transcoding

merge
author Alain Mazy <alain@mazy.be>
date Thu, 07 May 2020 11:32:15 +0200
parents 8f7ad4989fec
children
comparison
equal deleted inserted replaced
3895:37cf1889667a 3896:210af28c4087
31 **/ 31 **/
32 32
33 33
34 #pragma once 34 #pragma once
35 35
36 #if !defined(ORTHANC_ENABLE_DCMTK_TRANSCODING)
37 # error Macro ORTHANC_ENABLE_DCMTK_TRANSCODING must be defined to use this file
38 #endif
39
36 #include "DicomAssociationParameters.h" 40 #include "DicomAssociationParameters.h"
41
42 #if ORTHANC_ENABLE_DCMTK_TRANSCODING == 1
43 # include "../DicomParsing/IDicomTranscoder.h"
44 #endif
37 45
38 #include <boost/shared_ptr.hpp> 46 #include <boost/shared_ptr.hpp>
39 #include <boost/noncopyable.hpp> 47 #include <boost/noncopyable.hpp>
40 #include <set> 48 #include <set>
41 #include <stdint.h> // For uint8_t 49 #include <stdint.h> // For uint8_t
42 50
43 51
44 class DcmDataset; 52 class DcmFileFormat;
45 53
46 namespace Orthanc 54 namespace Orthanc
47 { 55 {
48 /** 56 /**
49 57
62 Uncompressed | Same transfer syntax, or other uncompressed 70 Uncompressed | Same transfer syntax, or other uncompressed
63 71
64 **/ 72 **/
65 73
66 class DicomAssociation; // Forward declaration for PImpl design pattern 74 class DicomAssociation; // Forward declaration for PImpl design pattern
67 class ParsedDicomFile;
68 75
69 class DicomStoreUserConnection : public boost::noncopyable 76 class DicomStoreUserConnection : public boost::noncopyable
70 { 77 {
71 private: 78 private:
72 typedef std::map<std::string, std::set<DicomTransferSyntax> > StorageClasses; 79 typedef std::map<std::string, std::set<DicomTransferSyntax> > RegisteredClasses;
80
81 // "ProposedOriginalClasses" keeps track of the storage classes
82 // that were proposed with a single transfer syntax
83 typedef std::set< std::pair<std::string, DicomTransferSyntax> > ProposedOriginalClasses;
73 84
74 DicomAssociationParameters parameters_; 85 DicomAssociationParameters parameters_;
75 boost::shared_ptr<DicomAssociation> association_; // "shared_ptr" is for PImpl 86 boost::shared_ptr<DicomAssociation> association_; // "shared_ptr" is for PImpl
76 StorageClasses storageClasses_; 87 RegisteredClasses registeredClasses_;
88 ProposedOriginalClasses proposedOriginalClasses_;
77 bool proposeCommonClasses_; 89 bool proposeCommonClasses_;
78 bool proposeUncompressedSyntaxes_; 90 bool proposeUncompressedSyntaxes_;
79 bool proposeRetiredBigEndian_; 91 bool proposeRetiredBigEndian_;
80
81 void Setup();
82 92
83 // Return "false" if there is not enough room remaining in the association 93 // Return "false" if there is not enough room remaining in the association
84 bool ProposeStorageClass(const std::string& sopClassUid, 94 bool ProposeStorageClass(const std::string& sopClassUid,
85 const std::set<DicomTransferSyntax>& syntaxes); 95 const std::set<DicomTransferSyntax>& syntaxes);
86 96
97 bool LookupPresentationContext(uint8_t& presentationContextId,
98 const std::string& sopClassUid,
99 DicomTransferSyntax transferSyntax);
100
101 bool NegotiatePresentationContext(uint8_t& presentationContextId,
102 const std::string& sopClassUid,
103 DicomTransferSyntax transferSyntax);
104
105 void LookupTranscoding(std::set<DicomTransferSyntax>& acceptedSyntaxes,
106 const std::string& sopClassUid,
107 DicomTransferSyntax sourceSyntax);
108
87 public: 109 public:
88 DicomStoreUserConnection(const std::string& localAet,
89 const RemoteModalityParameters& remote);
90
91 DicomStoreUserConnection(const DicomAssociationParameters& params); 110 DicomStoreUserConnection(const DicomAssociationParameters& params);
92 111
93 const DicomAssociationParameters& GetParameters() const 112 const DicomAssociationParameters& GetParameters() const
94 { 113 {
95 return parameters_; 114 return parameters_;
96 }
97
98 void SetTimeout(int timeout)
99 {
100 parameters_.SetTimeout(timeout);
101 } 115 }
102 116
103 void SetCommonClassesProposed(bool proposed) 117 void SetCommonClassesProposed(bool proposed)
104 { 118 {
105 proposeCommonClasses_ = proposed; 119 proposeCommonClasses_ = proposed;
131 } 145 }
132 146
133 void RegisterStorageClass(const std::string& sopClassUid, 147 void RegisterStorageClass(const std::string& sopClassUid,
134 DicomTransferSyntax syntax); 148 DicomTransferSyntax syntax);
135 149
136 // Should only be used if transcoding
137 // TODO => to private
138 bool LookupPresentationContext(uint8_t& presentationContextId,
139 const std::string& sopClassUid,
140 DicomTransferSyntax transferSyntax);
141
142 // TODO => to private
143 bool NegotiatePresentationContext(uint8_t& presentationContextId,
144 const std::string& sopClassUid,
145 DicomTransferSyntax transferSyntax);
146
147 // TODO => to private
148 void LookupParameters(std::string& sopClassUid,
149 std::string& sopInstanceUid,
150 DicomTransferSyntax& transferSyntax,
151 DcmDataset& dataset);
152
153 private:
154 void Store(std::string& sopClassUid, 150 void Store(std::string& sopClassUid,
155 std::string& sopInstanceUid, 151 std::string& sopInstanceUid,
156 DcmDataset& dataset, 152 DcmFileFormat& dicom,
157 const std::string& moveOriginatorAET, 153 bool hasMoveOriginator,
158 uint16_t moveOriginatorID);
159
160 void Store(std::string& sopClassUid,
161 std::string& sopInstanceUid,
162 ParsedDicomFile& parsed,
163 const std::string& moveOriginatorAET,
164 uint16_t moveOriginatorID);
165
166 public:
167 void Store(std::string& sopClassUid,
168 std::string& sopInstanceUid,
169 const void* buffer,
170 size_t size,
171 const std::string& moveOriginatorAET, 154 const std::string& moveOriginatorAET,
172 uint16_t moveOriginatorID); 155 uint16_t moveOriginatorID);
173 156
174 void Store(std::string& sopClassUid, 157 void Store(std::string& sopClassUid,
175 std::string& sopInstanceUid, 158 std::string& sopInstanceUid,
176 const void* buffer, 159 const void* buffer,
177 size_t size) 160 size_t size,
178 { 161 bool hasMoveOriginator,
179 Store(sopClassUid, sopInstanceUid, buffer, size, "", 0); // Not a C-Move 162 const std::string& moveOriginatorAET,
180 } 163 uint16_t moveOriginatorID);
164
165 void LookupParameters(std::string& sopClassUid,
166 std::string& sopInstanceUid,
167 DicomTransferSyntax& transferSyntax,
168 DcmFileFormat& dicom);
169
170 void Transcode(std::string& sopClassUid /* out */,
171 std::string& sopInstanceUid /* out */,
172 IDicomTranscoder& transcoder,
173 const void* buffer,
174 size_t size,
175 bool hasMoveOriginator,
176 const std::string& moveOriginatorAET,
177 uint16_t moveOriginatorID);
181 }; 178 };
182 } 179 }