comparison OrthancServer/Sources/OrthancConfiguration.cpp @ 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 c06659885362
comparison
equal deleted inserted replaced
4473:68f52897c119 4474:f8c1d94363b6
955 { 955 {
956 target.insert(*syntax); 956 target.insert(*syntax);
957 } 957 }
958 else 958 else
959 { 959 {
960 target.insert(*syntax); 960 target.erase(*syntax);
961 } 961 }
962 } 962 }
963 } 963 }
964 } 964 }
965 965
966 966
967 void OrthancConfiguration::GetAcceptedTransferSyntaxes(std::set<DicomTransferSyntax>& target) const 967 void OrthancConfiguration::GetAcceptedTransferSyntaxes(std::set<DicomTransferSyntax>& target) const
968 { 968 {
969 target.clear(); 969 target.clear();
970 970
971 // This is the list of the transfer syntaxes that were supported up to Orthanc 0.7.1 971 #if 1
972 /**
973 * This is the behavior in Orthanc >= 1.9.0. All the transfer
974 * syntaxes are accepted by default, and the
975 * "TransferSyntaxAccepted" options can be used to disable groups
976 * of transfer syntaxes.
977 **/
978
979 static const char* const ACCEPTED_TRANSFER_SYNTAXES = "AcceptedTransferSyntaxes";
980
981 if (json_.type() != Json::objectValue)
982 {
983 throw OrthancException(ErrorCode_InternalError);
984 }
985 else if (json_.isMember(ACCEPTED_TRANSFER_SYNTAXES))
986 {
987 ParseAcceptedTransferSyntaxes(target, json_[ACCEPTED_TRANSFER_SYNTAXES]);
988 }
989 else
990 {
991 GetAllDicomTransferSyntaxes(target);
992 }
993 #else
994 /**
995 * This was the behavior of Orthanc <= 1.8.2. The uncompressed
996 * transfer syntaxes were always accepted, and additional transfer
997 * syntaxes were added using the configuration options
998 * "XXXTransferSyntaxAccepted".
999 **/
1000
1001 // The 3 transfer syntaxes below were the only ones to be supported in Orthanc <= 0.7.1
972 target.insert(DicomTransferSyntax_LittleEndianExplicit); 1002 target.insert(DicomTransferSyntax_LittleEndianExplicit);
973 target.insert(DicomTransferSyntax_BigEndianExplicit); 1003 target.insert(DicomTransferSyntax_BigEndianExplicit);
974 target.insert(DicomTransferSyntax_LittleEndianImplicit); 1004 target.insert(DicomTransferSyntax_LittleEndianImplicit);
1005 #endif
975 1006
976 // Groups of transfer syntaxes, supported since Orthanc 0.7.2 1007 // Groups of transfer syntaxes, supported since Orthanc 0.7.2
977 GetAcceptOption(target, *this, "DeflatedTransferSyntaxAccepted", TransferSyntaxGroup_Deflated); 1008 GetAcceptOption(target, *this, "DeflatedTransferSyntaxAccepted", TransferSyntaxGroup_Deflated);
978 GetAcceptOption(target, *this, "JpegTransferSyntaxAccepted", TransferSyntaxGroup_Jpeg); 1009 GetAcceptOption(target, *this, "JpegTransferSyntaxAccepted", TransferSyntaxGroup_Jpeg);
979 GetAcceptOption(target, *this, "Jpeg2000TransferSyntaxAccepted", TransferSyntaxGroup_Jpeg2000); 1010 GetAcceptOption(target, *this, "Jpeg2000TransferSyntaxAccepted", TransferSyntaxGroup_Jpeg2000);
980 GetAcceptOption(target, *this, "JpegLosslessTransferSyntaxAccepted", TransferSyntaxGroup_JpegLossless); 1011 GetAcceptOption(target, *this, "JpegLosslessTransferSyntaxAccepted", TransferSyntaxGroup_JpegLossless);
981 GetAcceptOption(target, *this, "JpipTransferSyntaxAccepted", TransferSyntaxGroup_Jpip); 1012 GetAcceptOption(target, *this, "JpipTransferSyntaxAccepted", TransferSyntaxGroup_Jpip);
982 GetAcceptOption(target, *this, "Mpeg2TransferSyntaxAccepted", TransferSyntaxGroup_Mpeg2); 1013 GetAcceptOption(target, *this, "Mpeg2TransferSyntaxAccepted", TransferSyntaxGroup_Mpeg2);
983 GetAcceptOption(target, *this, "Mpeg4TransferSyntaxAccepted", TransferSyntaxGroup_Mpeg4); 1014 GetAcceptOption(target, *this, "Mpeg4TransferSyntaxAccepted", TransferSyntaxGroup_Mpeg4);
984 GetAcceptOption(target, *this, "RleTransferSyntaxAccepted", TransferSyntaxGroup_Rle); 1015 GetAcceptOption(target, *this, "RleTransferSyntaxAccepted", TransferSyntaxGroup_Rle);
1016 GetAcceptOption(target, *this, "H265TransferSyntaxAccepted", TransferSyntaxGroup_H265);
985 } 1017 }
986 1018
987 1019
988 void OrthancConfiguration::DefaultExtractDicomSummary(DicomMap& target, 1020 void OrthancConfiguration::DefaultExtractDicomSummary(DicomMap& target,
989 const ParsedDicomFile& dicom) 1021 const ParsedDicomFile& dicom)
1035 } 1067 }
1036 } 1068 }
1037 1069
1038 1070
1039 void OrthancConfiguration::ParseAcceptedTransferSyntaxes(std::set<DicomTransferSyntax>& target, 1071 void OrthancConfiguration::ParseAcceptedTransferSyntaxes(std::set<DicomTransferSyntax>& target,
1040 const std::string& source) 1072 const Json::Value& source)
1041 { 1073 {
1042 Json::Value json; 1074 if (source.type() == Json::stringValue)
1043 1075 {
1044 if (Toolbox::ReadJson(json, source)) 1076 AddTransferSyntaxes(target, source.asString());
1045 { 1077 }
1046 if (json.type() == Json::stringValue) 1078 else if (source.type() == Json::arrayValue)
1047 { 1079 {
1048 AddTransferSyntaxes(target, json.asString()); 1080 for (Json::Value::ArrayIndex i = 0; i < source.size(); i++)
1049 } 1081 {
1050 else if (json.type() == Json::arrayValue) 1082 if (source[i].type() == Json::stringValue)
1051 {
1052 for (Json::Value::ArrayIndex i = 0; i < json.size(); i++)
1053 { 1083 {
1054 if (json[i].type() == Json::stringValue) 1084 AddTransferSyntaxes(target, source[i].asString());
1055 {
1056 AddTransferSyntaxes(target, json[i].asString());
1057 }
1058 else
1059 {
1060 throw OrthancException(ErrorCode_BadFileFormat);
1061 }
1062 } 1085 }
1063 } 1086 else
1064 else 1087 {
1065 { 1088 throw OrthancException(ErrorCode_BadFileFormat);
1066 throw OrthancException(ErrorCode_BadFileFormat); 1089 }
1067 } 1090 }
1068 } 1091 }
1069 else 1092 else
1070 { 1093 {
1071 AddTransferSyntaxes(target, source); 1094 throw OrthancException(ErrorCode_BadFileFormat);
1072 } 1095 }
1073 } 1096 }
1074 } 1097 }