Mercurial > hg > orthanc
comparison Core/DicomNetworking/DicomStoreUserConnection.cpp @ 3868:d5be23fc0106 transcoding
better negotiation of transfer syntaxes
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 28 Apr 2020 08:43:48 +0200 |
parents | 594263db316a |
children | 2effa961f67f |
comparison
equal
deleted
inserted
replaced
3866:e1c2bc9a5cc1 | 3868:d5be23fc0106 |
---|---|
46 namespace Orthanc | 46 namespace Orthanc |
47 { | 47 { |
48 bool DicomStoreUserConnection::ProposeStorageClass(const std::string& sopClassUid, | 48 bool DicomStoreUserConnection::ProposeStorageClass(const std::string& sopClassUid, |
49 const std::set<DicomTransferSyntax>& syntaxes) | 49 const std::set<DicomTransferSyntax>& syntaxes) |
50 { | 50 { |
51 // Default transfer syntax for DICOM | |
52 const bool addLittleEndianImplicit = ( | |
53 proposeUncompressedSyntaxes_ && | |
54 syntaxes.find(DicomTransferSyntax_LittleEndianImplicit) == syntaxes.end()); | |
55 | |
56 const bool addLittleEndianExplicit = ( | |
57 proposeUncompressedSyntaxes_ && | |
58 syntaxes.find(DicomTransferSyntax_LittleEndianExplicit) == syntaxes.end()); | |
59 | |
60 const bool addBigEndianExplicit = ( | |
61 proposeUncompressedSyntaxes_ && | |
62 proposeRetiredBigEndian_ && | |
63 syntaxes.find(DicomTransferSyntax_BigEndianExplicit) == syntaxes.end()); | |
64 | |
51 size_t requiredCount = syntaxes.size(); | 65 size_t requiredCount = syntaxes.size(); |
52 if (proposeUncompressedSyntaxes_) | 66 if (addLittleEndianImplicit) |
53 { | 67 { |
54 requiredCount += 1; | 68 requiredCount += 1; |
55 } | 69 } |
56 | 70 |
71 if (addLittleEndianExplicit || | |
72 addBigEndianExplicit) | |
73 { | |
74 requiredCount += 1; | |
75 } | |
76 | |
57 if (association_->GetRemainingPropositions() <= requiredCount) | 77 if (association_->GetRemainingPropositions() <= requiredCount) |
58 { | 78 { |
59 return false; // Not enough room | 79 return false; // Not enough room |
60 } | 80 } |
61 | 81 else |
62 for (std::set<DicomTransferSyntax>::const_iterator | 82 { |
63 it = syntaxes.begin(); it != syntaxes.end(); ++it) | 83 for (std::set<DicomTransferSyntax>::const_iterator |
64 { | 84 it = syntaxes.begin(); it != syntaxes.end(); ++it) |
65 association_->ProposePresentationContext(sopClassUid, *it); | 85 { |
66 } | 86 association_->ProposePresentationContext(sopClassUid, *it); |
67 | 87 } |
68 if (proposeUncompressedSyntaxes_) | 88 |
69 { | 89 if (addLittleEndianImplicit) |
70 std::set<DicomTransferSyntax> uncompressed; | 90 { |
71 | 91 std::set<DicomTransferSyntax> uncompressed; |
72 if (syntaxes.find(DicomTransferSyntax_LittleEndianImplicit) == syntaxes.end()) | |
73 { | |
74 uncompressed.insert(DicomTransferSyntax_LittleEndianImplicit); | 92 uncompressed.insert(DicomTransferSyntax_LittleEndianImplicit); |
75 } | |
76 | |
77 if (syntaxes.find(DicomTransferSyntax_LittleEndianExplicit) == syntaxes.end()) | |
78 { | |
79 uncompressed.insert(DicomTransferSyntax_LittleEndianExplicit); | |
80 } | |
81 | |
82 if (proposeRetiredBigEndian_ && | |
83 syntaxes.find(DicomTransferSyntax_BigEndianExplicit) == syntaxes.end()) | |
84 { | |
85 uncompressed.insert(DicomTransferSyntax_BigEndianExplicit); | |
86 } | |
87 | |
88 if (!uncompressed.empty()) | |
89 { | |
90 association_->ProposePresentationContext(sopClassUid, uncompressed); | 93 association_->ProposePresentationContext(sopClassUid, uncompressed); |
91 } | 94 } |
92 } | 95 |
93 | 96 if (addLittleEndianExplicit || |
94 return true; | 97 addBigEndianExplicit) |
98 { | |
99 std::set<DicomTransferSyntax> uncompressed; | |
100 | |
101 if (addLittleEndianExplicit) | |
102 { | |
103 uncompressed.insert(DicomTransferSyntax_LittleEndianExplicit); | |
104 } | |
105 | |
106 if (addBigEndianExplicit) | |
107 { | |
108 uncompressed.insert(DicomTransferSyntax_BigEndianExplicit); | |
109 } | |
110 | |
111 association_->ProposePresentationContext(sopClassUid, uncompressed); | |
112 } | |
113 | |
114 return true; | |
115 } | |
95 } | 116 } |
96 | 117 |
97 | 118 |
98 bool DicomStoreUserConnection::LookupPresentationContext( | 119 bool DicomStoreUserConnection::LookupPresentationContext( |
99 uint8_t& presentationContextId, | 120 uint8_t& presentationContextId, |
142 { | 163 { |
143 Setup(); | 164 Setup(); |
144 } | 165 } |
145 | 166 |
146 | 167 |
147 void DicomStoreUserConnection::PrepareStorageClass(const std::string& sopClassUid, | 168 void DicomStoreUserConnection::RegisterStorageClass(const std::string& sopClassUid, |
148 DicomTransferSyntax syntax) | 169 DicomTransferSyntax syntax) |
149 { | 170 { |
150 StorageClasses::iterator found = storageClasses_.find(sopClassUid); | 171 StorageClasses::iterator found = storageClasses_.find(sopClassUid); |
151 | 172 |
152 if (found == storageClasses_.end()) | 173 if (found == storageClasses_.end()) |
153 { | 174 { |
209 LOG(INFO) << "Re-negociating DICOM association with " | 230 LOG(INFO) << "Re-negociating DICOM association with " |
210 << parameters_.GetRemoteApplicationEntityTitle(); | 231 << parameters_.GetRemoteApplicationEntityTitle(); |
211 } | 232 } |
212 | 233 |
213 association_->ClearPresentationContexts(); | 234 association_->ClearPresentationContexts(); |
214 PrepareStorageClass(sopClassUid, transferSyntax); | 235 RegisterStorageClass(sopClassUid, transferSyntax); |
215 | 236 |
216 | 237 |
217 /** | 238 /** |
218 * Step 2: Propose at least the mandatory SOP class. | 239 * Step 2: Propose at least the mandatory SOP class. |
219 **/ | 240 **/ |
237 } | 258 } |
238 | 259 |
239 | 260 |
240 /** | 261 /** |
241 * Step 3: Propose all the previously spotted SOP classes, as | 262 * Step 3: Propose all the previously spotted SOP classes, as |
242 * registered through the "PrepareStorageClass()" method. | 263 * registered through the "RegisterStorageClass()" method. |
243 **/ | 264 **/ |
244 | 265 |
245 for (StorageClasses::const_iterator it = storageClasses_.begin(); | 266 for (StorageClasses::const_iterator it = storageClasses_.begin(); |
246 it != storageClasses_.end(); ++it) | 267 it != storageClasses_.end(); ++it) |
247 { | 268 { |
260 * preferred transfer syntax is "LittleEndianImplicit". | 281 * preferred transfer syntax is "LittleEndianImplicit". |
261 **/ | 282 **/ |
262 | 283 |
263 if (proposeCommonClasses_) | 284 if (proposeCommonClasses_) |
264 { | 285 { |
286 // The method "ProposeStorageClass()" will automatically add | |
287 // "LittleEndianImplicit" | |
265 std::set<DicomTransferSyntax> ts; | 288 std::set<DicomTransferSyntax> ts; |
266 ts.insert(DicomTransferSyntax_LittleEndianImplicit); | |
267 | 289 |
268 for (int i = 0; i < numberOfDcmShortSCUStorageSOPClassUIDs; i++) | 290 for (int i = 0; i < numberOfDcmShortSCUStorageSOPClassUIDs; i++) |
269 { | 291 { |
270 std::string c(dcmShortSCUStorageSOPClassUIDs[i]); | 292 std::string c(dcmShortSCUStorageSOPClassUIDs[i]); |
271 | 293 |