changeset 4474:f8c1d94363b6

new configuration options: "AcceptedTransferSyntaxes" and "H265TransferSyntaxAccepted"
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 26 Jan 2021 15:50:52 +0100
parents 68f52897c119
children a24d2126efd2
files NEWS OrthancServer/Resources/Configuration.json OrthancServer/Sources/OrthancConfiguration.cpp OrthancServer/Sources/OrthancConfiguration.h OrthancServer/Sources/OrthancRestApi/OrthancRestSystem.cpp OrthancServer/Sources/ServerEnumerations.cpp OrthancServer/Sources/ServerEnumerations.h
diffstat 7 files changed, 113 insertions(+), 60 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Tue Jan 26 14:48:10 2021 +0100
+++ b/NEWS	Tue Jan 26 15:50:52 2021 +0100
@@ -13,6 +13,8 @@
   - "UseDicomTls" in "DicomModalities" to enable DICOM TLS in outgoing SCU on a per-modality basis
   - "MaximumPduLength" to tune the maximum PDU length (Protocol Data Unit)
   - "LocalAet" in "DicomModalities" to overwrite global "DicomAet" for SCU on a per-modality basis
+  - "AcceptedTransferSyntaxes" to set the transfer syntax UIDs accepted by Orthanc C-STORE SCP
+  - "H265TransferSyntaxAccepted" to enable/disable all the transfer syntaxes related to H.265
 * New configuration option: "DicomScuPreferredTransferSyntax" to control transcoding in C-STORE SCU
 * New command-line option: "--openapi" to write the OpenAPI documentation of the REST API to a file
 * New metadata automatically computed at the series level: "RemoteAET"
--- a/OrthancServer/Resources/Configuration.json	Tue Jan 26 14:48:10 2021 +0100
+++ b/OrthancServer/Resources/Configuration.json	Tue Jan 26 15:50:52 2021 +0100
@@ -126,26 +126,37 @@
 
   // The default encoding that is assumed for DICOM files without
   // "SpecificCharacterSet" DICOM tag, and that is used when answering
-  // C-Find requests (including worklists). The allowed values are
+  // C-FIND requests (including worklists). The allowed values are
   // "Ascii", "Utf8", "Latin1", "Latin2", "Latin3", "Latin4",
   // "Latin5", "Cyrillic", "Windows1251", "Arabic", "Greek", "Hebrew",
   // "Thai", "Japanese", "Chinese", "JapaneseKanji", "Korean", and
   // "SimplifiedChinese".
   "DefaultEncoding" : "Latin1",
 
-  // The transfer syntaxes that are accepted by Orthanc C-Store SCP
-  "DeflatedTransferSyntaxAccepted"     : true,
-  "JpegTransferSyntaxAccepted"         : true,
-  "Jpeg2000TransferSyntaxAccepted"     : true,
-  "JpegLosslessTransferSyntaxAccepted" : true,
-  "JpipTransferSyntaxAccepted"         : true,
-  "Mpeg2TransferSyntaxAccepted"        : true,
-  "RleTransferSyntaxAccepted"          : true,
-  "Mpeg4TransferSyntaxAccepted"        : true,  // New in Orthanc 1.6.0
+  // The transfer syntaxes that are accepted by Orthanc C-STORE SCP.
+  // This is an array listing the accepted transfer syntax UIDs. Each
+  // entry can contain wildcards ("?" or "*"). By default, all the
+  // known transfer syntaxes are accepted. (new in Orthanc 1.9.0)
+  "AcceptedTransferSyntaxes" : [ "1.2.840.10008.1.*" ],
 
-  // Whether Orthanc accepts to act as C-Store SCP for unknown storage
+  // User-friendly groups of transfer syntaxes that can be enabled or
+  // disabled at once. These options are applied after the main
+  // "AcceptedTransferSyntaxes" option has been applied (if present).
+  /**
+     "DeflatedTransferSyntaxAccepted"     : true,
+     "JpegTransferSyntaxAccepted"         : true,
+     "Jpeg2000TransferSyntaxAccepted"     : true,
+     "JpegLosslessTransferSyntaxAccepted" : true,
+     "JpipTransferSyntaxAccepted"         : true,
+     "Mpeg2TransferSyntaxAccepted"        : true,
+     "RleTransferSyntaxAccepted"          : true,
+     "Mpeg4TransferSyntaxAccepted"        : true,  // New in Orthanc 1.6.0
+     "H265TransferSyntaxAccepted"         : true,  // New in Orthanc 1.9.0
+  **/
+  
+  // Whether Orthanc accepts to act as C-STORE SCP for unknown storage
   // SOP classes (aka. "promiscuous mode")
-  "UnknownSopClassAccepted"            : false,
+  "UnknownSopClassAccepted" : false,
 
   // Set the timeout (in seconds) after which the DICOM associations
   // are closed by the Orthanc SCP (server) if no further DIMSE
@@ -250,13 +261,13 @@
      "DicomTlsTrustedCertificates" : "trusted.crt",
   **/
   
-  // Whether the Orthanc SCP allows incoming C-Echo requests, even
+  // Whether the Orthanc SCP allows incoming C-ECHO requests, even
   // from SCU modalities it does not know about (i.e. that are not
   // listed in the "DicomModalities" option above). Orthanc 1.3.0
   // is the only version to behave as if this argument was set to "false".
   "DicomAlwaysAllowEcho" : true,
 
-  // Whether the Orthanc SCP allows incoming C-Store requests, even
+  // Whether the Orthanc SCP allows incoming C-STORE requests, even
   // from SCU modalities it does not know about (i.e. that are not
   // listed in the "DicomModalities" option above)
   "DicomAlwaysAllowStore" : true,
@@ -294,9 +305,9 @@
      * specific PACS manufacturers. The allowed values are currently:
      * - "Generic" (default value),
      * - "GenericNoWildcardInDates" (to replace "*" by "" in date fields 
-     *   in outgoing C-Find requests originating from Orthanc),
+     *   in outgoing C-FIND requests originating from Orthanc),
      * - "GenericNoUniversalWildcard" (to replace "*" by "" in all fields
-     *   in outgoing C-Find SCU requests originating from Orthanc),
+     *   in outgoing C-FIND SCU requests originating from Orthanc),
      * - "Vitrea",
      * - "GE" (Enterprise Archive, MRI consoles and Advantage Workstation
      *   from GE Healthcare).
@@ -540,7 +551,7 @@
   // deleted as new requests are issued.
   "QueryRetrieveSize" : 100,
 
-  // When handling a C-Find SCP request, setting this flag to "true"
+  // When handling a C-FIND SCP request, setting this flag to "true"
   // will enable case-sensitive match for PN value representation
   // (such as PatientName). By default, the search is
   // case-insensitive, which does not follow the DICOM standard.
@@ -584,13 +595,13 @@
     // "2001,5f" : [ "SQ", "StackSequence", 1, 1, "Philips Imaging DD 001" ]
   },
 
-  // Whether to run DICOM C-Move operations synchronously. If set to
-  // "false" (asynchronous mode), each incoming C-Move request results
+  // Whether to run DICOM C-MOVE operations synchronously. If set to
+  // "false" (asynchronous mode), each incoming C-MOVE request results
   // in the creation of a new background job. Up to Orthanc 1.3.2, the
-  // implicit behavior was to use synchronous C-Move ("true"). Between
+  // implicit behavior was to use synchronous C-MOVE ("true"). Between
   // Orthanc 1.4.0 and 1.4.2, the default behavior was set to
-  // asynchronous C-Move ("false"). Since Orthanc 1.5.0, the default
-  // behavior is back to synchronous C-Move ("true", which ensures
+  // asynchronous C-MOVE ("false"). Since Orthanc 1.5.0, the default
+  // behavior is back to synchronous C-MOVE ("true", which ensures
   // backward compatibility with Orthanc <= 1.3.2).
   "SynchronousCMove" : true,
 
@@ -722,8 +733,8 @@
   // Orthanc <= 1.8.1.
   "MallocArenaMax" : 5,
 
-  // Deidentify/anonymize the contents of the logs (notably C-Find,
-  // C-Get, and C-Move queries submitted to Orthanc) according to
+  // Deidentify/anonymize the contents of the logs (notably C-FIND,
+  // C-GET, and C-MOVE queries submitted to Orthanc) according to
   // Table E.1-1 of the DICOM standard (new in Orthanc 1.8.2)
   "DeidentifyLogs" : true,
 
--- a/OrthancServer/Sources/OrthancConfiguration.cpp	Tue Jan 26 14:48:10 2021 +0100
+++ b/OrthancServer/Sources/OrthancConfiguration.cpp	Tue Jan 26 15:50:52 2021 +0100
@@ -957,7 +957,7 @@
         }
         else
         {
-          target.insert(*syntax);
+          target.erase(*syntax);
         }
       }
     }
@@ -967,11 +967,42 @@
   void OrthancConfiguration::GetAcceptedTransferSyntaxes(std::set<DicomTransferSyntax>& target) const
   {
     target.clear();
-    
-    // This is the list of the transfer syntaxes that were supported up to Orthanc 0.7.1
+
+#if 1
+    /**
+     * This is the behavior in Orthanc >= 1.9.0. All the transfer
+     * syntaxes are accepted by default, and the
+     * "TransferSyntaxAccepted" options can be used to disable groups
+     * of transfer syntaxes.
+     **/
+
+    static const char* const ACCEPTED_TRANSFER_SYNTAXES = "AcceptedTransferSyntaxes";
+
+    if (json_.type() != Json::objectValue)
+    {
+      throw OrthancException(ErrorCode_InternalError);
+    }    
+    else if (json_.isMember(ACCEPTED_TRANSFER_SYNTAXES))
+    {
+      ParseAcceptedTransferSyntaxes(target, json_[ACCEPTED_TRANSFER_SYNTAXES]);
+    }
+    else
+    {
+      GetAllDicomTransferSyntaxes(target);
+    }
+#else
+    /**
+     * This was the behavior of Orthanc <= 1.8.2. The uncompressed
+     * transfer syntaxes were always accepted, and additional transfer
+     * syntaxes were added using the configuration options
+     * "XXXTransferSyntaxAccepted".
+     **/
+
+    // The 3 transfer syntaxes below were the only ones to be supported in Orthanc <= 0.7.1
     target.insert(DicomTransferSyntax_LittleEndianExplicit);
     target.insert(DicomTransferSyntax_BigEndianExplicit);
     target.insert(DicomTransferSyntax_LittleEndianImplicit);
+#endif
 
     // Groups of transfer syntaxes, supported since Orthanc 0.7.2
     GetAcceptOption(target, *this, "DeflatedTransferSyntaxAccepted", TransferSyntaxGroup_Deflated);
@@ -982,6 +1013,7 @@
     GetAcceptOption(target, *this, "Mpeg2TransferSyntaxAccepted", TransferSyntaxGroup_Mpeg2);
     GetAcceptOption(target, *this, "Mpeg4TransferSyntaxAccepted", TransferSyntaxGroup_Mpeg4);
     GetAcceptOption(target, *this, "RleTransferSyntaxAccepted", TransferSyntaxGroup_Rle);
+    GetAcceptOption(target, *this, "H265TransferSyntaxAccepted", TransferSyntaxGroup_H265);
   }
 
 
@@ -1037,38 +1069,29 @@
 
 
   void OrthancConfiguration::ParseAcceptedTransferSyntaxes(std::set<DicomTransferSyntax>& target,
-                                                           const std::string& source)
+                                                           const Json::Value& source)
   {
-    Json::Value json;
-    
-    if (Toolbox::ReadJson(json, source))
+    if (source.type() == Json::stringValue)
     {
-      if (json.type() == Json::stringValue)
+      AddTransferSyntaxes(target, source.asString());
+    }
+    else if (source.type() == Json::arrayValue)
+    {
+      for (Json::Value::ArrayIndex i = 0; i < source.size(); i++)
       {
-        AddTransferSyntaxes(target, json.asString());
-      }
-      else if (json.type() == Json::arrayValue)
-      {
-        for (Json::Value::ArrayIndex i = 0; i < json.size(); i++)
+        if (source[i].type() == Json::stringValue)
         {
-          if (json[i].type() == Json::stringValue)
-          {
-            AddTransferSyntaxes(target, json[i].asString());
-          }
-          else
-          {
-            throw OrthancException(ErrorCode_BadFileFormat);
-          }
+          AddTransferSyntaxes(target, source[i].asString());
         }
-      }
-      else
-      {
-        throw OrthancException(ErrorCode_BadFileFormat);
+        else
+        {
+          throw OrthancException(ErrorCode_BadFileFormat);
+        }
       }
     }
     else
     {
-      AddTransferSyntaxes(target, source);
+      throw OrthancException(ErrorCode_BadFileFormat);
     }
   }
 }
--- a/OrthancServer/Sources/OrthancConfiguration.h	Tue Jan 26 14:48:10 2021 +0100
+++ b/OrthancServer/Sources/OrthancConfiguration.h	Tue Jan 26 15:50:52 2021 +0100
@@ -263,6 +263,6 @@
                                          const ParsedDicomFile& dicom);
 
     static void ParseAcceptedTransferSyntaxes(std::set<DicomTransferSyntax>& target,
-                                              const std::string& source);
+                                              const Json::Value& source);
   };
 }
--- a/OrthancServer/Sources/OrthancRestApi/OrthancRestSystem.cpp	Tue Jan 26 14:48:10 2021 +0100
+++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestSystem.cpp	Tue Jan 26 15:50:52 2021 +0100
@@ -372,11 +372,21 @@
       return;
     }
 
-    std::string body;
-    call.BodyToString(body);
+    std::set<DicomTransferSyntax> syntaxes;
 
-    std::set<DicomTransferSyntax> syntaxes;
-    OrthancConfiguration::ParseAcceptedTransferSyntaxes(syntaxes, body);
+    Json::Value json;
+    if (call.ParseJsonRequest(json))
+    {
+      std::cout << json.toStyledString();
+      OrthancConfiguration::ParseAcceptedTransferSyntaxes(syntaxes, json);
+    }
+    else
+    {
+      std::string body;
+      call.BodyToString(body);
+      OrthancConfiguration::ParseAcceptedTransferSyntaxes(syntaxes, body);
+    }
+
     OrthancRestApi::GetContext(call).SetAcceptedTransferSyntaxes(syntaxes);
     
     AnswerAcceptedTransferSyntaxes(call);
--- a/OrthancServer/Sources/ServerEnumerations.cpp	Tue Jan 26 14:48:10 2021 +0100
+++ b/OrthancServer/Sources/ServerEnumerations.cpp	Tue Jan 26 15:50:52 2021 +0100
@@ -471,6 +471,10 @@
         target.insert(DicomTransferSyntax_MPEG2MainProfileAtHighLevel);
         break;
 
+      case TransferSyntaxGroup_Rle:
+        target.insert(DicomTransferSyntax_RLELossless);
+        break;
+
       case TransferSyntaxGroup_Mpeg4:
         // New in Orthanc 1.6.0
         target.insert(DicomTransferSyntax_MPEG4BDcompatibleHighProfileLevel4_1);
@@ -479,11 +483,13 @@
         target.insert(DicomTransferSyntax_MPEG4HighProfileLevel4_2_For3DVideo);
         target.insert(DicomTransferSyntax_MPEG4StereoHighProfileLevel4_2);
         break;
+
+      case TransferSyntaxGroup_H265:
+        // New in Orthanc 1.9.0
+        target.insert(DicomTransferSyntax_HEVCMainProfileLevel5_1);
+        target.insert(DicomTransferSyntax_HEVCMain10ProfileLevel5_1);
+        break;
         
-      case TransferSyntaxGroup_Rle:
-        target.insert(DicomTransferSyntax_RLELossless);
-        break;
-
       default:
         throw OrthancException(ErrorCode_ParameterOutOfRange);
     }
--- a/OrthancServer/Sources/ServerEnumerations.h	Tue Jan 26 14:48:10 2021 +0100
+++ b/OrthancServer/Sources/ServerEnumerations.h	Tue Jan 26 15:50:52 2021 +0100
@@ -104,8 +104,9 @@
     TransferSyntaxGroup_JpegLossless,
     TransferSyntaxGroup_Jpip,
     TransferSyntaxGroup_Mpeg2,
+    TransferSyntaxGroup_Rle,
     TransferSyntaxGroup_Mpeg4,  // New in Orthanc 1.6.0
-    TransferSyntaxGroup_Rle
+    TransferSyntaxGroup_H265    // New in Orthanc 1.9.0
   };