Mercurial > hg > orthanc
comparison OrthancFramework/Sources/DicomNetworking/DicomStoreUserConnection.cpp @ 5438:7a20ee948676 debug-telemis
Added a new 'Telemis' manufacturer for DicomModalities
author | Alain Mazy <am@osimis.io> |
---|---|
date | Wed, 22 Nov 2023 12:57:07 +0100 |
parents | 742448a9b600 |
children | 99fa307438e1 |
comparison
equal
deleted
inserted
replaced
5437:85da6dcd0e08 | 5438:7a20ee948676 |
---|---|
251 bool DicomStoreUserConnection::NegotiatePresentationContext( | 251 bool DicomStoreUserConnection::NegotiatePresentationContext( |
252 uint8_t& presentationContextId, | 252 uint8_t& presentationContextId, |
253 const std::string& sopClassUid, | 253 const std::string& sopClassUid, |
254 DicomTransferSyntax transferSyntax, | 254 DicomTransferSyntax transferSyntax, |
255 bool hasPreferred, | 255 bool hasPreferred, |
256 DicomTransferSyntax preferred) | 256 DicomTransferSyntax preferred, |
257 bool alwaysRenegotiate) | |
257 { | 258 { |
258 /** | 259 /** |
259 * Step 1: Check whether this presentation context is already | 260 * Step 1: Check whether this presentation context is already |
260 * available in the previously negotiated assocation. | 261 * available in the previously negotiated assocation. |
261 **/ | 262 **/ |
271 CLOG(INFO, DICOM) << "Re-negotiating DICOM association with " | 272 CLOG(INFO, DICOM) << "Re-negotiating DICOM association with " |
272 << parameters_.GetRemoteModality().GetApplicationEntityTitle(); | 273 << parameters_.GetRemoteModality().GetApplicationEntityTitle(); |
273 | 274 |
274 // Don't renegociate if we know that the remote modality was | 275 // Don't renegociate if we know that the remote modality was |
275 // already proposed this individual transfer syntax (**) | 276 // already proposed this individual transfer syntax (**) |
276 if (proposedOriginalClasses_.find(std::make_pair(sopClassUid, transferSyntax)) != | 277 if (!alwaysRenegotiate && |
277 proposedOriginalClasses_.end()) | 278 proposedOriginalClasses_.find(std::make_pair(sopClassUid, transferSyntax)) != proposedOriginalClasses_.end()) |
278 { | 279 { |
279 CLOG(INFO, DICOM) << "The remote modality has already rejected SOP class UID \"" | 280 CLOG(INFO, DICOM) << "The remote modality has already rejected SOP class UID \"" |
280 << sopClassUid << "\" with transfer syntax \"" | 281 << sopClassUid << "\" with transfer syntax \"" |
281 << GetTransferSyntaxUid(transferSyntax) << "\", don't renegotiate"; | 282 << GetTransferSyntaxUid(transferSyntax) << "\", don't renegotiate"; |
282 return false; | 283 return false; |
367 void DicomStoreUserConnection::Store(std::string& sopClassUid, | 368 void DicomStoreUserConnection::Store(std::string& sopClassUid, |
368 std::string& sopInstanceUid, | 369 std::string& sopInstanceUid, |
369 DcmFileFormat& dicom, | 370 DcmFileFormat& dicom, |
370 bool hasMoveOriginator, | 371 bool hasMoveOriginator, |
371 const std::string& moveOriginatorAET, | 372 const std::string& moveOriginatorAET, |
372 uint16_t moveOriginatorID) | 373 uint16_t moveOriginatorID, |
374 bool alwaysRenegotiate) | |
373 { | 375 { |
374 DicomTransferSyntax transferSyntax; | 376 DicomTransferSyntax transferSyntax; |
375 LookupParameters(sopClassUid, sopInstanceUid, transferSyntax, dicom); | 377 LookupParameters(sopClassUid, sopInstanceUid, transferSyntax, dicom); |
376 | 378 |
377 uint8_t presID; | 379 uint8_t presID; |
378 if (!NegotiatePresentationContext(presID, sopClassUid, transferSyntax, proposeUncompressedSyntaxes_, | 380 if (!NegotiatePresentationContext(presID, sopClassUid, transferSyntax, proposeUncompressedSyntaxes_, |
379 DicomTransferSyntax_LittleEndianExplicit)) | 381 DicomTransferSyntax_LittleEndianExplicit, alwaysRenegotiate)) |
380 { | 382 { |
381 throw OrthancException(ErrorCode_NetworkProtocol, | 383 throw OrthancException(ErrorCode_NetworkProtocol, |
382 "No valid presentation context was negotiated for " | 384 "No valid presentation context was negotiated for " |
383 "SOP class UID [" + sopClassUid + "] and transfer " | 385 "SOP class UID [" + sopClassUid + "] and transfer " |
384 "syntax [" + GetTransferSyntaxUid(transferSyntax) + "] " | 386 "syntax [" + GetTransferSyntaxUid(transferSyntax) + "] " |
456 std::string& sopInstanceUid, | 458 std::string& sopInstanceUid, |
457 const void* buffer, | 459 const void* buffer, |
458 size_t size, | 460 size_t size, |
459 bool hasMoveOriginator, | 461 bool hasMoveOriginator, |
460 const std::string& moveOriginatorAET, | 462 const std::string& moveOriginatorAET, |
461 uint16_t moveOriginatorID) | 463 uint16_t moveOriginatorID, |
464 bool alwaysRenegotiate) | |
462 { | 465 { |
463 std::unique_ptr<DcmFileFormat> dicom( | 466 std::unique_ptr<DcmFileFormat> dicom( |
464 FromDcmtkBridge::LoadFromMemoryBuffer(buffer, size)); | 467 FromDcmtkBridge::LoadFromMemoryBuffer(buffer, size)); |
465 | 468 |
466 if (dicom.get() == NULL) | 469 if (dicom.get() == NULL) |
467 { | 470 { |
468 throw OrthancException(ErrorCode_InternalError); | 471 throw OrthancException(ErrorCode_InternalError); |
469 } | 472 } |
470 | 473 |
471 Store(sopClassUid, sopInstanceUid, *dicom, hasMoveOriginator, moveOriginatorAET, moveOriginatorID); | 474 Store(sopClassUid, sopInstanceUid, *dicom, hasMoveOriginator, moveOriginatorAET, moveOriginatorID, alwaysRenegotiate); |
472 } | 475 } |
473 | 476 |
474 | 477 |
475 #if ORTHANC_ENABLE_DCMTK_TRANSCODING == 1 | 478 #if ORTHANC_ENABLE_DCMTK_TRANSCODING == 1 |
476 void DicomStoreUserConnection::LookupTranscoding(std::set<DicomTransferSyntax>& acceptedSyntaxes, | 479 void DicomStoreUserConnection::LookupTranscoding(std::set<DicomTransferSyntax>& acceptedSyntaxes, |
477 const std::string& sopClassUid, | 480 const std::string& sopClassUid, |
478 DicomTransferSyntax sourceSyntax, | 481 DicomTransferSyntax sourceSyntax, |
479 bool hasPreferred, | 482 bool hasPreferred, |
480 DicomTransferSyntax preferred) | 483 DicomTransferSyntax preferred, |
484 bool alwaysRenegotiate) | |
481 { | 485 { |
482 acceptedSyntaxes.clear(); | 486 acceptedSyntaxes.clear(); |
483 | 487 |
484 // Make sure a negotiation has already occurred for this transfer | 488 // Make sure a negotiation has already occurred for this transfer |
485 // syntax. We don't use the return code: Transcoding is possible | 489 // syntax. We don't use the return code: Transcoding is possible |
486 // even if the "sourceSyntax" is not supported. | 490 // even if the "sourceSyntax" is not supported. |
487 uint8_t presID; | 491 uint8_t presID; |
488 NegotiatePresentationContext(presID, sopClassUid, sourceSyntax, hasPreferred, preferred); | 492 NegotiatePresentationContext(presID, sopClassUid, sourceSyntax, hasPreferred, preferred, alwaysRenegotiate); |
489 | 493 |
490 std::map<DicomTransferSyntax, uint8_t> contexts; | 494 std::map<DicomTransferSyntax, uint8_t> contexts; |
491 if (association_->LookupAcceptedPresentationContext(contexts, sopClassUid)) | 495 if (association_->LookupAcceptedPresentationContext(contexts, sopClassUid)) |
492 { | 496 { |
493 for (std::map<DicomTransferSyntax, uint8_t>::const_iterator | 497 for (std::map<DicomTransferSyntax, uint8_t>::const_iterator |
507 const void* buffer, | 511 const void* buffer, |
508 size_t size, | 512 size_t size, |
509 DicomTransferSyntax preferredTransferSyntax, | 513 DicomTransferSyntax preferredTransferSyntax, |
510 bool hasMoveOriginator, | 514 bool hasMoveOriginator, |
511 const std::string& moveOriginatorAET, | 515 const std::string& moveOriginatorAET, |
512 uint16_t moveOriginatorID) | 516 uint16_t moveOriginatorID, |
517 bool alwaysRenegotiate) | |
513 { | 518 { |
514 std::unique_ptr<DcmFileFormat> dicom(FromDcmtkBridge::LoadFromMemoryBuffer(buffer, size)); | 519 std::unique_ptr<DcmFileFormat> dicom(FromDcmtkBridge::LoadFromMemoryBuffer(buffer, size)); |
515 if (dicom.get() == NULL || | 520 if (dicom.get() == NULL || |
516 dicom->getDataset() == NULL) | 521 dicom->getDataset() == NULL) |
517 { | 522 { |
520 | 525 |
521 DicomTransferSyntax sourceSyntax; | 526 DicomTransferSyntax sourceSyntax; |
522 LookupParameters(sopClassUid, sopInstanceUid, sourceSyntax, *dicom); | 527 LookupParameters(sopClassUid, sopInstanceUid, sourceSyntax, *dicom); |
523 | 528 |
524 std::set<DicomTransferSyntax> accepted; | 529 std::set<DicomTransferSyntax> accepted; |
525 LookupTranscoding(accepted, sopClassUid, sourceSyntax, true, preferredTransferSyntax); | 530 LookupTranscoding(accepted, sopClassUid, sourceSyntax, true, preferredTransferSyntax, alwaysRenegotiate); |
526 | 531 |
527 if (accepted.find(sourceSyntax) != accepted.end()) | 532 if (accepted.find(sourceSyntax) != accepted.end()) |
528 { | 533 { |
529 // No need for transcoding | 534 // No need for transcoding |
530 Store(sopClassUid, sopInstanceUid, *dicom, | 535 Store(sopClassUid, sopInstanceUid, *dicom, |
531 hasMoveOriginator, moveOriginatorAET, moveOriginatorID); | 536 hasMoveOriginator, moveOriginatorAET, moveOriginatorID, alwaysRenegotiate); |
532 } | 537 } |
533 else | 538 else |
534 { | 539 { |
535 // Transcoding is needed | 540 // Transcoding is needed |
536 IDicomTranscoder::DicomImage source; | 541 IDicomTranscoder::DicomImage source; |
615 throw OrthancException(ErrorCode_InternalError); | 620 throw OrthancException(ErrorCode_InternalError); |
616 } | 621 } |
617 else | 622 else |
618 { | 623 { |
619 Store(sopClassUid, sopInstanceUid, transcoded.GetParsed(), | 624 Store(sopClassUid, sopInstanceUid, transcoded.GetParsed(), |
620 hasMoveOriginator, moveOriginatorAET, moveOriginatorID); | 625 hasMoveOriginator, moveOriginatorAET, moveOriginatorID, alwaysRenegotiate); |
621 } | 626 } |
622 } | 627 } |
623 else | 628 else |
624 { | 629 { |
625 std::string s; | 630 std::string s; |
644 IDicomTranscoder& transcoder, | 649 IDicomTranscoder& transcoder, |
645 const void* buffer, | 650 const void* buffer, |
646 size_t size, | 651 size_t size, |
647 bool hasMoveOriginator, | 652 bool hasMoveOriginator, |
648 const std::string& moveOriginatorAET, | 653 const std::string& moveOriginatorAET, |
649 uint16_t moveOriginatorID) | 654 uint16_t moveOriginatorID, |
655 bool alwaysRenegotiate) | |
650 { | 656 { |
651 Transcode(sopClassUid, sopInstanceUid, transcoder, buffer, size, DicomTransferSyntax_LittleEndianExplicit, | 657 Transcode(sopClassUid, sopInstanceUid, transcoder, buffer, size, DicomTransferSyntax_LittleEndianExplicit, |
652 hasMoveOriginator, moveOriginatorAET, moveOriginatorID); | 658 hasMoveOriginator, moveOriginatorAET, moveOriginatorID, alwaysRenegotiate); |
653 } | 659 } |
654 #endif | 660 #endif |
655 } | 661 } |