annotate OrthancFramework/Sources/DicomNetworking/DicomStoreUserConnection.cpp @ 4284:756126cd2219

moving all logs from DicomNetworking folder into the "dicom" category
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 04 Nov 2020 15:01:47 +0100
parents d2f79a475b51
children 3b70a2e6a06c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3825
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
4119
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
8 * modify it under the terms of the GNU Lesser General Public License
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
10 * the License, or (at your option) any later version.
3825
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4119
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
15 * Lesser General Public License for more details.
3825
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 *
4119
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
18 * License along with this program. If not, see
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
19 * <http://www.gnu.org/licenses/>.
3825
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 **/
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 #include "../PrecompiledHeaders.h"
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #include "DicomStoreUserConnection.h"
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
3831
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
26 #include "../DicomParsing/FromDcmtkBridge.h"
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
27 #include "../DicomParsing/ParsedDicomFile.h"
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
28 #include "../Logging.h"
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
29 #include "../OrthancException.h"
3826
e82bd07c384e putting DicomAssociation behind pimpl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3825
diff changeset
30 #include "DicomAssociation.h"
e82bd07c384e putting DicomAssociation behind pimpl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3825
diff changeset
31
3831
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
32 #include <dcmtk/dcmdata/dcdeftag.h>
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
33
3825
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 namespace Orthanc
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 {
4281
d2f79a475b51 debug log for DCMTK SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
37 static void ProgressCallback(void * /*callbackData*/,
d2f79a475b51 debug log for DCMTK SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
38 T_DIMSE_StoreProgress *progress,
d2f79a475b51 debug log for DCMTK SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
39 T_DIMSE_C_StoreRQ * req)
d2f79a475b51 debug log for DCMTK SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
40 {
d2f79a475b51 debug log for DCMTK SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
41 if (req != NULL &&
d2f79a475b51 debug log for DCMTK SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
42 progress->state == DIMSE_StoreBegin)
d2f79a475b51 debug log for DCMTK SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
43 {
d2f79a475b51 debug log for DCMTK SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
44 OFString str;
d2f79a475b51 debug log for DCMTK SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
45 CLOG(TRACE, DICOM) << "Sending Store Request:" << std::endl
d2f79a475b51 debug log for DCMTK SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
46 << DIMSE_dumpMessage(str, *req, DIMSE_OUTGOING);
d2f79a475b51 debug log for DCMTK SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
47 }
d2f79a475b51 debug log for DCMTK SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
48 }
d2f79a475b51 debug log for DCMTK SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
49
d2f79a475b51 debug log for DCMTK SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
50
3825
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 bool DicomStoreUserConnection::ProposeStorageClass(const std::string& sopClassUid,
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 const std::set<DicomTransferSyntax>& syntaxes)
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 {
3868
d5be23fc0106 better negotiation of transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3862
diff changeset
54 // Default transfer syntax for DICOM
d5be23fc0106 better negotiation of transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3862
diff changeset
55 const bool addLittleEndianImplicit = (
d5be23fc0106 better negotiation of transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3862
diff changeset
56 proposeUncompressedSyntaxes_ &&
d5be23fc0106 better negotiation of transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3862
diff changeset
57 syntaxes.find(DicomTransferSyntax_LittleEndianImplicit) == syntaxes.end());
d5be23fc0106 better negotiation of transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3862
diff changeset
58
d5be23fc0106 better negotiation of transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3862
diff changeset
59 const bool addLittleEndianExplicit = (
d5be23fc0106 better negotiation of transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3862
diff changeset
60 proposeUncompressedSyntaxes_ &&
d5be23fc0106 better negotiation of transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3862
diff changeset
61 syntaxes.find(DicomTransferSyntax_LittleEndianExplicit) == syntaxes.end());
d5be23fc0106 better negotiation of transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3862
diff changeset
62
d5be23fc0106 better negotiation of transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3862
diff changeset
63 const bool addBigEndianExplicit = (
d5be23fc0106 better negotiation of transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3862
diff changeset
64 proposeUncompressedSyntaxes_ &&
d5be23fc0106 better negotiation of transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3862
diff changeset
65 proposeRetiredBigEndian_ &&
d5be23fc0106 better negotiation of transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3862
diff changeset
66 syntaxes.find(DicomTransferSyntax_BigEndianExplicit) == syntaxes.end());
d5be23fc0106 better negotiation of transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3862
diff changeset
67
3825
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 size_t requiredCount = syntaxes.size();
3868
d5be23fc0106 better negotiation of transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3862
diff changeset
69 if (addLittleEndianImplicit)
d5be23fc0106 better negotiation of transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3862
diff changeset
70 {
d5be23fc0106 better negotiation of transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3862
diff changeset
71 requiredCount += 1;
d5be23fc0106 better negotiation of transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3862
diff changeset
72 }
d5be23fc0106 better negotiation of transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3862
diff changeset
73
d5be23fc0106 better negotiation of transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3862
diff changeset
74 if (addLittleEndianExplicit ||
d5be23fc0106 better negotiation of transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3862
diff changeset
75 addBigEndianExplicit)
3825
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 {
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 requiredCount += 1;
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 }
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79
3826
e82bd07c384e putting DicomAssociation behind pimpl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3825
diff changeset
80 if (association_->GetRemainingPropositions() <= requiredCount)
3825
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 {
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 return false; // Not enough room
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 }
3868
d5be23fc0106 better negotiation of transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3862
diff changeset
84 else
3825
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 {
3868
d5be23fc0106 better negotiation of transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3862
diff changeset
86 for (std::set<DicomTransferSyntax>::const_iterator
d5be23fc0106 better negotiation of transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3862
diff changeset
87 it = syntaxes.begin(); it != syntaxes.end(); ++it)
3825
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 {
3868
d5be23fc0106 better negotiation of transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3862
diff changeset
89 association_->ProposePresentationContext(sopClassUid, *it);
3880
cdd0cb5ec4e4 DicomStoreUserConnection::LookupTranscoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3879
diff changeset
90 proposedOriginalClasses_.insert(std::make_pair(sopClassUid, *it));
3825
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 }
3868
d5be23fc0106 better negotiation of transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3862
diff changeset
92
d5be23fc0106 better negotiation of transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3862
diff changeset
93 if (addLittleEndianImplicit)
3825
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 {
3880
cdd0cb5ec4e4 DicomStoreUserConnection::LookupTranscoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3879
diff changeset
95 association_->ProposePresentationContext(sopClassUid, DicomTransferSyntax_LittleEndianImplicit);
cdd0cb5ec4e4 DicomStoreUserConnection::LookupTranscoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3879
diff changeset
96 proposedOriginalClasses_.insert(std::make_pair(sopClassUid, DicomTransferSyntax_LittleEndianImplicit));
3825
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 }
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98
3868
d5be23fc0106 better negotiation of transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3862
diff changeset
99 if (addLittleEndianExplicit ||
d5be23fc0106 better negotiation of transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3862
diff changeset
100 addBigEndianExplicit)
3825
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 {
3868
d5be23fc0106 better negotiation of transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3862
diff changeset
102 std::set<DicomTransferSyntax> uncompressed;
d5be23fc0106 better negotiation of transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3862
diff changeset
103
d5be23fc0106 better negotiation of transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3862
diff changeset
104 if (addLittleEndianExplicit)
d5be23fc0106 better negotiation of transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3862
diff changeset
105 {
d5be23fc0106 better negotiation of transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3862
diff changeset
106 uncompressed.insert(DicomTransferSyntax_LittleEndianExplicit);
d5be23fc0106 better negotiation of transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3862
diff changeset
107 }
d5be23fc0106 better negotiation of transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3862
diff changeset
108
d5be23fc0106 better negotiation of transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3862
diff changeset
109 if (addBigEndianExplicit)
d5be23fc0106 better negotiation of transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3862
diff changeset
110 {
d5be23fc0106 better negotiation of transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3862
diff changeset
111 uncompressed.insert(DicomTransferSyntax_BigEndianExplicit);
d5be23fc0106 better negotiation of transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3862
diff changeset
112 }
d5be23fc0106 better negotiation of transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3862
diff changeset
113
3826
e82bd07c384e putting DicomAssociation behind pimpl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3825
diff changeset
114 association_->ProposePresentationContext(sopClassUid, uncompressed);
3880
cdd0cb5ec4e4 DicomStoreUserConnection::LookupTranscoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3879
diff changeset
115
cdd0cb5ec4e4 DicomStoreUserConnection::LookupTranscoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3879
diff changeset
116 assert(!uncompressed.empty());
cdd0cb5ec4e4 DicomStoreUserConnection::LookupTranscoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3879
diff changeset
117 if (addLittleEndianExplicit ^ addBigEndianExplicit)
cdd0cb5ec4e4 DicomStoreUserConnection::LookupTranscoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3879
diff changeset
118 {
cdd0cb5ec4e4 DicomStoreUserConnection::LookupTranscoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3879
diff changeset
119 // Only one transfer syntax was proposed for this presentation context
cdd0cb5ec4e4 DicomStoreUserConnection::LookupTranscoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3879
diff changeset
120 assert(uncompressed.size() == 1);
cdd0cb5ec4e4 DicomStoreUserConnection::LookupTranscoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3879
diff changeset
121 proposedOriginalClasses_.insert(std::make_pair(sopClassUid, *uncompressed.begin()));
cdd0cb5ec4e4 DicomStoreUserConnection::LookupTranscoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3879
diff changeset
122 }
3825
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 }
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124
3868
d5be23fc0106 better negotiation of transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3862
diff changeset
125 return true;
d5be23fc0106 better negotiation of transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3862
diff changeset
126 }
3825
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 }
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 bool DicomStoreUserConnection::LookupPresentationContext(
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 uint8_t& presentationContextId,
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 const std::string& sopClassUid,
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 DicomTransferSyntax transferSyntax)
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 {
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 typedef std::map<DicomTransferSyntax, uint8_t> PresentationContexts;
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 PresentationContexts pc;
3826
e82bd07c384e putting DicomAssociation behind pimpl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3825
diff changeset
138 if (association_->IsOpen() &&
e82bd07c384e putting DicomAssociation behind pimpl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3825
diff changeset
139 association_->LookupAcceptedPresentationContext(pc, sopClassUid))
3825
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 {
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 PresentationContexts::const_iterator found = pc.find(transferSyntax);
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 if (found != pc.end())
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 {
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 presentationContextId = found->second;
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 return true;
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 }
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147 }
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 return false;
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 }
3862
594263db316a DicomModalityStoreJob now uses DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3831
diff changeset
151
594263db316a DicomModalityStoreJob now uses DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3831
diff changeset
152
594263db316a DicomModalityStoreJob now uses DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3831
diff changeset
153 DicomStoreUserConnection::DicomStoreUserConnection(
3825
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 const DicomAssociationParameters& params) :
3874
2effa961f67f forcing use of DicomAssociationParameters if creating an SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3868
diff changeset
155 parameters_(params),
2effa961f67f forcing use of DicomAssociationParameters if creating an SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3868
diff changeset
156 association_(new DicomAssociation),
2effa961f67f forcing use of DicomAssociationParameters if creating an SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3868
diff changeset
157 proposeCommonClasses_(true),
2effa961f67f forcing use of DicomAssociationParameters if creating an SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3868
diff changeset
158 proposeUncompressedSyntaxes_(true),
2effa961f67f forcing use of DicomAssociationParameters if creating an SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3868
diff changeset
159 proposeRetiredBigEndian_(false)
3825
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 {
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 }
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163
3868
d5be23fc0106 better negotiation of transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3862
diff changeset
164 void DicomStoreUserConnection::RegisterStorageClass(const std::string& sopClassUid,
d5be23fc0106 better negotiation of transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3862
diff changeset
165 DicomTransferSyntax syntax)
3825
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 {
3879
a18b34dec94a reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
167 RegisteredClasses::iterator found = registeredClasses_.find(sopClassUid);
3825
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168
3879
a18b34dec94a reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
169 if (found == registeredClasses_.end())
3825
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170 {
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171 std::set<DicomTransferSyntax> ts;
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172 ts.insert(syntax);
3879
a18b34dec94a reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
173 registeredClasses_[sopClassUid] = ts;
3825
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174 }
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175 else
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176 {
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177 found->second.insert(syntax);
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178 }
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179 }
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
180
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
181
3862
594263db316a DicomModalityStoreJob now uses DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3831
diff changeset
182 void DicomStoreUserConnection::LookupParameters(std::string& sopClassUid,
594263db316a DicomModalityStoreJob now uses DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3831
diff changeset
183 std::string& sopInstanceUid,
3882
904575738462 implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3881
diff changeset
184 DicomTransferSyntax& transferSyntax,
904575738462 implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3881
diff changeset
185 DcmFileFormat& dicom)
3862
594263db316a DicomModalityStoreJob now uses DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3831
diff changeset
186 {
3882
904575738462 implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3881
diff changeset
187 if (dicom.getDataset() == NULL)
904575738462 implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3881
diff changeset
188 {
904575738462 implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3881
diff changeset
189 throw OrthancException(ErrorCode_InternalError);
904575738462 implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3881
diff changeset
190 }
904575738462 implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3881
diff changeset
191
3862
594263db316a DicomModalityStoreJob now uses DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3831
diff changeset
192 OFString a, b;
3882
904575738462 implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3881
diff changeset
193 if (!dicom.getDataset()->findAndGetOFString(DCM_SOPClassUID, a).good() ||
904575738462 implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3881
diff changeset
194 !dicom.getDataset()->findAndGetOFString(DCM_SOPInstanceUID, b).good())
3862
594263db316a DicomModalityStoreJob now uses DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3831
diff changeset
195 {
594263db316a DicomModalityStoreJob now uses DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3831
diff changeset
196 throw OrthancException(ErrorCode_NoSopClassOrInstance,
594263db316a DicomModalityStoreJob now uses DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3831
diff changeset
197 "Unable to determine the SOP class/instance for C-STORE with AET " +
3875
ea1d32861cfc moving timeout from DicomAssocation to DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3874
diff changeset
198 parameters_.GetRemoteModality().GetApplicationEntityTitle());
3862
594263db316a DicomModalityStoreJob now uses DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3831
diff changeset
199 }
594263db316a DicomModalityStoreJob now uses DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3831
diff changeset
200
594263db316a DicomModalityStoreJob now uses DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3831
diff changeset
201 sopClassUid.assign(a.c_str());
594263db316a DicomModalityStoreJob now uses DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3831
diff changeset
202 sopInstanceUid.assign(b.c_str());
3882
904575738462 implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3881
diff changeset
203
904575738462 implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3881
diff changeset
204 if (!FromDcmtkBridge::LookupOrthancTransferSyntax(transferSyntax, dicom))
904575738462 implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3881
diff changeset
205 {
904575738462 implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3881
diff changeset
206 throw OrthancException(ErrorCode_InternalError,
904575738462 implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3881
diff changeset
207 "Unknown transfer syntax from DCMTK");
904575738462 implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3881
diff changeset
208 }
3862
594263db316a DicomModalityStoreJob now uses DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3831
diff changeset
209 }
594263db316a DicomModalityStoreJob now uses DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3831
diff changeset
210
594263db316a DicomModalityStoreJob now uses DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3831
diff changeset
211
3825
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
212 bool DicomStoreUserConnection::NegotiatePresentationContext(
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
213 uint8_t& presentationContextId,
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
214 const std::string& sopClassUid,
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
215 DicomTransferSyntax transferSyntax)
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
216 {
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
217 /**
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218 * Step 1: Check whether this presentation context is already
3880
cdd0cb5ec4e4 DicomStoreUserConnection::LookupTranscoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3879
diff changeset
219 * available in the previously negotiated assocation.
3825
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
220 **/
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
221
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
222 if (LookupPresentationContext(presentationContextId, sopClassUid, transferSyntax))
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
223 {
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
224 return true;
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
225 }
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
226
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
227 // The association must be re-negotiated
3862
594263db316a DicomModalityStoreJob now uses DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3831
diff changeset
228 if (association_->IsOpen())
594263db316a DicomModalityStoreJob now uses DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3831
diff changeset
229 {
4284
756126cd2219 moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4281
diff changeset
230 CLOG(INFO, DICOM) << "Re-negotiating DICOM association with "
756126cd2219 moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4281
diff changeset
231 << parameters_.GetRemoteModality().GetApplicationEntityTitle();
3880
cdd0cb5ec4e4 DicomStoreUserConnection::LookupTranscoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3879
diff changeset
232
cdd0cb5ec4e4 DicomStoreUserConnection::LookupTranscoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3879
diff changeset
233 if (proposedOriginalClasses_.find(std::make_pair(sopClassUid, transferSyntax)) !=
cdd0cb5ec4e4 DicomStoreUserConnection::LookupTranscoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3879
diff changeset
234 proposedOriginalClasses_.end())
cdd0cb5ec4e4 DicomStoreUserConnection::LookupTranscoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3879
diff changeset
235 {
4284
756126cd2219 moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4281
diff changeset
236 CLOG(INFO, DICOM) << "The remote modality has already rejected SOP class UID \""
756126cd2219 moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4281
diff changeset
237 << sopClassUid << "\" with transfer syntax \""
756126cd2219 moving all logs from DicomNetworking folder into the "dicom" category
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4281
diff changeset
238 << GetTransferSyntaxUid(transferSyntax) << "\", don't renegotiate";
3880
cdd0cb5ec4e4 DicomStoreUserConnection::LookupTranscoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3879
diff changeset
239 return false;
cdd0cb5ec4e4 DicomStoreUserConnection::LookupTranscoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3879
diff changeset
240 }
3862
594263db316a DicomModalityStoreJob now uses DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3831
diff changeset
241 }
3880
cdd0cb5ec4e4 DicomStoreUserConnection::LookupTranscoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3879
diff changeset
242
3826
e82bd07c384e putting DicomAssociation behind pimpl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3825
diff changeset
243 association_->ClearPresentationContexts();
3880
cdd0cb5ec4e4 DicomStoreUserConnection::LookupTranscoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3879
diff changeset
244 proposedOriginalClasses_.clear();
3879
a18b34dec94a reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
245 RegisterStorageClass(sopClassUid, transferSyntax); // (*)
3825
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
246
3879
a18b34dec94a reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
247
3825
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
248 /**
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
249 * Step 2: Propose at least the mandatory SOP class.
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
250 **/
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
251
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
252 {
3879
a18b34dec94a reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
253 RegisteredClasses::const_iterator mandatory = registeredClasses_.find(sopClassUid);
3825
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
254
3879
a18b34dec94a reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
255 if (mandatory == registeredClasses_.end() ||
3825
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
256 mandatory->second.find(transferSyntax) == mandatory->second.end())
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
257 {
3879
a18b34dec94a reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
258 // Should never fail because of (*)
3825
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
259 throw OrthancException(ErrorCode_InternalError);
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
260 }
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
261
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
262 if (!ProposeStorageClass(sopClassUid, mandatory->second))
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
263 {
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
264 // Should never happen in real life: There are no more than
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
265 // 128 transfer syntaxes in DICOM!
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
266 throw OrthancException(ErrorCode_InternalError,
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
267 "Too many transfer syntaxes for SOP class UID: " + sopClassUid);
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
268 }
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
269 }
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
270
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
271
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
272 /**
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
273 * Step 3: Propose all the previously spotted SOP classes, as
3868
d5be23fc0106 better negotiation of transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3862
diff changeset
274 * registered through the "RegisterStorageClass()" method.
3825
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
275 **/
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
276
3879
a18b34dec94a reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
277 for (RegisteredClasses::const_iterator it = registeredClasses_.begin();
a18b34dec94a reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
278 it != registeredClasses_.end(); ++it)
3825
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
279 {
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
280 if (it->first != sopClassUid)
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
281 {
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
282 ProposeStorageClass(it->first, it->second);
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
283 }
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
284 }
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
285
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
286
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
287 /**
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
288 * Step 4: As long as there is room left in the proposed
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
289 * presentation contexts, propose the uncompressed transfer syntaxes
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
290 * for the most common SOP classes, as can be found in the
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
291 * "dcmShortSCUStorageSOPClassUIDs" array from DCMTK. The
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
292 * preferred transfer syntax is "LittleEndianImplicit".
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
293 **/
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
294
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
295 if (proposeCommonClasses_)
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
296 {
3868
d5be23fc0106 better negotiation of transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3862
diff changeset
297 // The method "ProposeStorageClass()" will automatically add
d5be23fc0106 better negotiation of transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3862
diff changeset
298 // "LittleEndianImplicit"
3825
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
299 std::set<DicomTransferSyntax> ts;
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
300
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
301 for (int i = 0; i < numberOfDcmShortSCUStorageSOPClassUIDs; i++)
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
302 {
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
303 std::string c(dcmShortSCUStorageSOPClassUIDs[i]);
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
304
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
305 if (c != sopClassUid &&
3879
a18b34dec94a reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
306 registeredClasses_.find(c) == registeredClasses_.end())
3825
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
307 {
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
308 ProposeStorageClass(c, ts);
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
309 }
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
310 }
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
311 }
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
312
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
313
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
314 /**
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
315 * Step 5: Open the association, and check whether the pair (SOP
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
316 * class UID, transfer syntax) was accepted by the remote host.
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
317 **/
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
318
3826
e82bd07c384e putting DicomAssociation behind pimpl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3825
diff changeset
319 association_->Open(parameters_);
3825
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
320 return LookupPresentationContext(presentationContextId, sopClassUid, transferSyntax);
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
321 }
3831
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
322
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
323
3881
f23ab7829a8d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3880
diff changeset
324 void DicomStoreUserConnection::Store(std::string& sopClassUid,
f23ab7829a8d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3880
diff changeset
325 std::string& sopInstanceUid,
3882
904575738462 implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3881
diff changeset
326 DcmFileFormat& dicom,
3894
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3893
diff changeset
327 bool hasMoveOriginator,
3881
f23ab7829a8d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3880
diff changeset
328 const std::string& moveOriginatorAET,
f23ab7829a8d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3880
diff changeset
329 uint16_t moveOriginatorID)
3831
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
330 {
3862
594263db316a DicomModalityStoreJob now uses DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3831
diff changeset
331 DicomTransferSyntax transferSyntax;
3882
904575738462 implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3881
diff changeset
332 LookupParameters(sopClassUid, sopInstanceUid, transferSyntax, dicom);
3880
cdd0cb5ec4e4 DicomStoreUserConnection::LookupTranscoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3879
diff changeset
333
3862
594263db316a DicomModalityStoreJob now uses DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3831
diff changeset
334 uint8_t presID;
594263db316a DicomModalityStoreJob now uses DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3831
diff changeset
335 if (!NegotiatePresentationContext(presID, sopClassUid, transferSyntax))
3831
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
336 {
3862
594263db316a DicomModalityStoreJob now uses DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3831
diff changeset
337 throw OrthancException(ErrorCode_NetworkProtocol,
594263db316a DicomModalityStoreJob now uses DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3831
diff changeset
338 "No valid presentation context was negotiated for "
594263db316a DicomModalityStoreJob now uses DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3831
diff changeset
339 "SOP class UID [" + sopClassUid + "] and transfer "
594263db316a DicomModalityStoreJob now uses DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3831
diff changeset
340 "syntax [" + GetTransferSyntaxUid(transferSyntax) + "] "
594263db316a DicomModalityStoreJob now uses DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3831
diff changeset
341 "while sending to modality [" +
3875
ea1d32861cfc moving timeout from DicomAssocation to DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3874
diff changeset
342 parameters_.GetRemoteModality().GetApplicationEntityTitle() + "]");
3831
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
343 }
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
344
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
345 // Prepare the transmission of data
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
346 T_DIMSE_C_StoreRQ request;
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
347 memset(&request, 0, sizeof(request));
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
348 request.MessageID = association_->GetDcmtkAssociation().nextMsgID++;
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
349 strncpy(request.AffectedSOPClassUID, sopClassUid.c_str(), DIC_UI_LEN);
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
350 request.Priority = DIMSE_PRIORITY_MEDIUM;
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
351 request.DataSetType = DIMSE_DATASET_PRESENT;
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
352 strncpy(request.AffectedSOPInstanceUID, sopInstanceUid.c_str(), DIC_UI_LEN);
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
353
3894
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3893
diff changeset
354 if (hasMoveOriginator)
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3893
diff changeset
355 {
3831
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
356 strncpy(request.MoveOriginatorApplicationEntityTitle,
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
357 moveOriginatorAET.c_str(), DIC_AE_LEN);
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
358 request.opts = O_STORE_MOVEORIGINATORAETITLE;
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
359
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
360 request.MoveOriginatorID = moveOriginatorID; // The type DIC_US is an alias for uint16_t
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
361 request.opts |= O_STORE_MOVEORIGINATORID;
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
362 }
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
363
3882
904575738462 implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3881
diff changeset
364 if (dicom.getDataset() == NULL)
904575738462 implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3881
diff changeset
365 {
904575738462 implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3881
diff changeset
366 throw OrthancException(ErrorCode_InternalError);
904575738462 implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3881
diff changeset
367 }
904575738462 implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3881
diff changeset
368
3831
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
369 // Finally conduct transmission of data
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
370 T_DIMSE_C_StoreRSP response;
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
371 DcmDataset* statusDetail = NULL;
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
372 DicomAssociation::CheckCondition(
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
373 DIMSE_storeUser(&association_->GetDcmtkAssociation(), presID, &request,
4281
d2f79a475b51 debug log for DCMTK SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
374 NULL, dicom.getDataset(), ProgressCallback, NULL,
3831
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
375 /*opt_blockMode*/ (GetParameters().HasTimeout() ? DIMSE_NONBLOCKING : DIMSE_BLOCKING),
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
376 /*opt_dimse_timeout*/ GetParameters().GetTimeout(),
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
377 &response, &statusDetail, NULL),
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
378 GetParameters(), "C-STORE");
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
379
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
380 if (statusDetail != NULL)
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
381 {
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
382 delete statusDetail;
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
383 }
4281
d2f79a475b51 debug log for DCMTK SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
384
d2f79a475b51 debug log for DCMTK SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
385 {
d2f79a475b51 debug log for DCMTK SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
386 OFString str;
d2f79a475b51 debug log for DCMTK SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
387 CLOG(TRACE, DICOM) << "Received Store Response:" << std::endl
d2f79a475b51 debug log for DCMTK SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
388 << DIMSE_dumpMessage(str, response, DIMSE_INCOMING, NULL, presID);
d2f79a475b51 debug log for DCMTK SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
389 }
3831
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
390
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
391 /**
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
392 * New in Orthanc 1.6.0: Deal with failures during C-STORE.
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
393 * http://dicom.nema.org/medical/dicom/current/output/chtml/part04/sect_B.2.3.html#table_B.2-1
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
394 **/
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
395
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
396 if (response.DimseStatus != 0x0000 && // Success
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
397 response.DimseStatus != 0xB000 && // Warning - Coercion of Data Elements
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
398 response.DimseStatus != 0xB007 && // Warning - Data Set does not match SOP Class
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
399 response.DimseStatus != 0xB006) // Warning - Elements Discarded
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
400 {
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
401 char buf[16];
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
402 sprintf(buf, "%04X", response.DimseStatus);
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
403 throw OrthancException(ErrorCode_NetworkProtocol,
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
404 "C-STORE SCU to AET \"" +
3875
ea1d32861cfc moving timeout from DicomAssocation to DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3874
diff changeset
405 GetParameters().GetRemoteModality().GetApplicationEntityTitle() +
3831
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
406 "\" has failed with DIMSE status 0x" + buf);
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
407 }
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
408 }
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
409
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
410
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
411 void DicomStoreUserConnection::Store(std::string& sopClassUid,
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
412 std::string& sopInstanceUid,
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
413 const void* buffer,
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
414 size_t size,
3894
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3893
diff changeset
415 bool hasMoveOriginator,
3831
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
416 const std::string& moveOriginatorAET,
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
417 uint16_t moveOriginatorID)
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
418 {
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
419 std::unique_ptr<DcmFileFormat> dicom(
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
420 FromDcmtkBridge::LoadFromMemoryBuffer(buffer, size));
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
421
3882
904575738462 implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3881
diff changeset
422 if (dicom.get() == NULL)
3862
594263db316a DicomModalityStoreJob now uses DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3831
diff changeset
423 {
594263db316a DicomModalityStoreJob now uses DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3831
diff changeset
424 throw OrthancException(ErrorCode_InternalError);
594263db316a DicomModalityStoreJob now uses DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3831
diff changeset
425 }
594263db316a DicomModalityStoreJob now uses DicomStoreUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3831
diff changeset
426
3894
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3893
diff changeset
427 Store(sopClassUid, sopInstanceUid, *dicom, hasMoveOriginator, moveOriginatorAET, moveOriginatorID);
3831
83ea6939293d starting DicomStoreUserConnection::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3826
diff changeset
428 }
3880
cdd0cb5ec4e4 DicomStoreUserConnection::LookupTranscoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3879
diff changeset
429
cdd0cb5ec4e4 DicomStoreUserConnection::LookupTranscoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3879
diff changeset
430
3882
904575738462 implemented IDicomTranscoder::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3881
diff changeset
431 void DicomStoreUserConnection::LookupTranscoding(std::set<DicomTransferSyntax>& acceptedSyntaxes,
3880
cdd0cb5ec4e4 DicomStoreUserConnection::LookupTranscoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3879
diff changeset
432 const std::string& sopClassUid,
cdd0cb5ec4e4 DicomStoreUserConnection::LookupTranscoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3879
diff changeset
433 DicomTransferSyntax sourceSyntax)
cdd0cb5ec4e4 DicomStoreUserConnection::LookupTranscoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3879
diff changeset
434 {
cdd0cb5ec4e4 DicomStoreUserConnection::LookupTranscoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3879
diff changeset
435 acceptedSyntaxes.clear();
cdd0cb5ec4e4 DicomStoreUserConnection::LookupTranscoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3879
diff changeset
436
cdd0cb5ec4e4 DicomStoreUserConnection::LookupTranscoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3879
diff changeset
437 // Make sure a negotiation has already occurred for this transfer
cdd0cb5ec4e4 DicomStoreUserConnection::LookupTranscoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3879
diff changeset
438 // syntax. We don't use the return code: Transcoding is possible
cdd0cb5ec4e4 DicomStoreUserConnection::LookupTranscoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3879
diff changeset
439 // even if the "sourceSyntax" is not supported.
cdd0cb5ec4e4 DicomStoreUserConnection::LookupTranscoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3879
diff changeset
440 uint8_t presID;
cdd0cb5ec4e4 DicomStoreUserConnection::LookupTranscoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3879
diff changeset
441 NegotiatePresentationContext(presID, sopClassUid, sourceSyntax);
cdd0cb5ec4e4 DicomStoreUserConnection::LookupTranscoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3879
diff changeset
442
cdd0cb5ec4e4 DicomStoreUserConnection::LookupTranscoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3879
diff changeset
443 std::map<DicomTransferSyntax, uint8_t> contexts;
cdd0cb5ec4e4 DicomStoreUserConnection::LookupTranscoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3879
diff changeset
444 if (association_->LookupAcceptedPresentationContext(contexts, sopClassUid))
cdd0cb5ec4e4 DicomStoreUserConnection::LookupTranscoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3879
diff changeset
445 {
cdd0cb5ec4e4 DicomStoreUserConnection::LookupTranscoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3879
diff changeset
446 for (std::map<DicomTransferSyntax, uint8_t>::const_iterator
cdd0cb5ec4e4 DicomStoreUserConnection::LookupTranscoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3879
diff changeset
447 it = contexts.begin(); it != contexts.end(); ++it)
cdd0cb5ec4e4 DicomStoreUserConnection::LookupTranscoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3879
diff changeset
448 {
cdd0cb5ec4e4 DicomStoreUserConnection::LookupTranscoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3879
diff changeset
449 acceptedSyntaxes.insert(it->first);
cdd0cb5ec4e4 DicomStoreUserConnection::LookupTranscoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3879
diff changeset
450 }
cdd0cb5ec4e4 DicomStoreUserConnection::LookupTranscoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3879
diff changeset
451 }
cdd0cb5ec4e4 DicomStoreUserConnection::LookupTranscoding()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3879
diff changeset
452 }
3893
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
453
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
454
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
455 void DicomStoreUserConnection::Transcode(std::string& sopClassUid /* out */,
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
456 std::string& sopInstanceUid /* out */,
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
457 IDicomTranscoder& transcoder,
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
458 const void* buffer,
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
459 size_t size,
3894
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3893
diff changeset
460 bool hasMoveOriginator,
3893
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
461 const std::string& moveOriginatorAET,
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
462 uint16_t moveOriginatorID)
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
463 {
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
464 std::unique_ptr<DcmFileFormat> dicom(FromDcmtkBridge::LoadFromMemoryBuffer(buffer, size));
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
465 if (dicom.get() == NULL ||
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
466 dicom->getDataset() == NULL)
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
467 {
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
468 throw OrthancException(ErrorCode_NullPointer);
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
469 }
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
470
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
471 DicomTransferSyntax inputSyntax;
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
472 LookupParameters(sopClassUid, sopInstanceUid, inputSyntax, *dicom);
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
473
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
474 std::set<DicomTransferSyntax> accepted;
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
475 LookupTranscoding(accepted, sopClassUid, inputSyntax);
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
476
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
477 if (accepted.find(inputSyntax) != accepted.end())
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
478 {
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
479 // No need for transcoding
3894
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3893
diff changeset
480 Store(sopClassUid, sopInstanceUid, *dicom,
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3893
diff changeset
481 hasMoveOriginator, moveOriginatorAET, moveOriginatorID);
3893
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
482 }
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
483 else
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
484 {
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
485 // Transcoding is needed
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
486 std::set<DicomTransferSyntax> uncompressedSyntaxes;
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
487
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
488 if (accepted.find(DicomTransferSyntax_LittleEndianImplicit) != accepted.end())
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
489 {
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
490 uncompressedSyntaxes.insert(DicomTransferSyntax_LittleEndianImplicit);
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
491 }
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
492
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
493 if (accepted.find(DicomTransferSyntax_LittleEndianExplicit) != accepted.end())
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
494 {
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
495 uncompressedSyntaxes.insert(DicomTransferSyntax_LittleEndianExplicit);
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
496 }
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
497
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
498 if (accepted.find(DicomTransferSyntax_BigEndianExplicit) != accepted.end())
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
499 {
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
500 uncompressedSyntaxes.insert(DicomTransferSyntax_BigEndianExplicit);
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
501 }
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
502
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3907
diff changeset
503 IDicomTranscoder::DicomImage source;
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3907
diff changeset
504 source.AcquireParsed(dicom.release());
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3907
diff changeset
505 source.SetExternalBuffer(buffer, size);
3951
5fe8c6d3212e removed useless information "hasSopInstanceUidChanged"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
506
5fe8c6d3212e removed useless information "hasSopInstanceUidChanged"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
507 const std::string sourceUid = IDicomTranscoder::GetSopInstanceUid(source.GetParsed());
3894
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3893
diff changeset
508
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3907
diff changeset
509 IDicomTranscoder::DicomImage transcoded;
3951
5fe8c6d3212e removed useless information "hasSopInstanceUidChanged"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
510 if (transcoder.Transcode(transcoded, source, uncompressedSyntaxes, false))
3893
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
511 {
3951
5fe8c6d3212e removed useless information "hasSopInstanceUidChanged"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
512 if (sourceUid != IDicomTranscoder::GetSopInstanceUid(transcoded.GetParsed()))
3893
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
513 {
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3907
diff changeset
514 throw OrthancException(ErrorCode_Plugin, "The transcoder has changed the SOP "
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3907
diff changeset
515 "instance UID while transcoding to an uncompressed transfer syntax");
3893
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
516 }
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
517 else
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
518 {
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3907
diff changeset
519 DicomTransferSyntax transcodedSyntax;
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3907
diff changeset
520
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3907
diff changeset
521 // Sanity check
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3907
diff changeset
522 if (!FromDcmtkBridge::LookupOrthancTransferSyntax(transcodedSyntax, transcoded.GetParsed()) ||
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3907
diff changeset
523 accepted.find(transcodedSyntax) == accepted.end())
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3907
diff changeset
524 {
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3907
diff changeset
525 throw OrthancException(ErrorCode_InternalError);
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3907
diff changeset
526 }
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3907
diff changeset
527 else
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3907
diff changeset
528 {
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3907
diff changeset
529 Store(sopClassUid, sopInstanceUid, transcoded.GetParsed(),
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3907
diff changeset
530 hasMoveOriginator, moveOriginatorAET, moveOriginatorID);
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3907
diff changeset
531 }
3893
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
532 }
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
533 }
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
534 }
7a5fa8f307e9 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3882
diff changeset
535 }
3825
4570c57668a8 refactoring DicomUserConnection as Dicom[Control|Store]UserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
536 }