正在显示
2 个修改的文件
包含
409 行增加
和
404 行删除
| @@ -765,6 +765,91 @@ void SrsConfig::print_help(char** argv) | @@ -765,6 +765,91 @@ void SrsConfig::print_help(char** argv) | ||
| 765 | argv[0]); | 765 | argv[0]); |
| 766 | } | 766 | } |
| 767 | 767 | ||
| 768 | +bool SrsConfig::get_deamon() | ||
| 769 | +{ | ||
| 770 | + srs_assert(root); | ||
| 771 | + | ||
| 772 | + SrsConfDirective* conf = root->get("daemon"); | ||
| 773 | + if (conf && conf->arg0() == "off") { | ||
| 774 | + return false; | ||
| 775 | + } | ||
| 776 | + | ||
| 777 | + return true; | ||
| 778 | +} | ||
| 779 | + | ||
| 780 | +int SrsConfig::get_max_connections() | ||
| 781 | +{ | ||
| 782 | + srs_assert(root); | ||
| 783 | + | ||
| 784 | + SrsConfDirective* conf = root->get("max_connections"); | ||
| 785 | + if (!conf || conf->arg0().empty()) { | ||
| 786 | + return 2000; | ||
| 787 | + } | ||
| 788 | + | ||
| 789 | + return ::atoi(conf->arg0().c_str()); | ||
| 790 | +} | ||
| 791 | + | ||
| 792 | +SrsConfDirective* SrsConfig::get_listen() | ||
| 793 | +{ | ||
| 794 | + return root->get("listen"); | ||
| 795 | +} | ||
| 796 | + | ||
| 797 | +string SrsConfig::get_pid_file() | ||
| 798 | +{ | ||
| 799 | + SrsConfDirective* conf = root->get("pid"); | ||
| 800 | + | ||
| 801 | + if (!conf) { | ||
| 802 | + return SRS_CONF_DEFAULT_PID_FILE; | ||
| 803 | + } | ||
| 804 | + | ||
| 805 | + return conf->arg0(); | ||
| 806 | +} | ||
| 807 | + | ||
| 808 | +int SrsConfig::get_pithy_print_publish() | ||
| 809 | +{ | ||
| 810 | + SrsConfDirective* pithy = root->get("pithy_print"); | ||
| 811 | + if (!pithy) { | ||
| 812 | + return SRS_STAGE_PUBLISH_USER_INTERVAL_MS; | ||
| 813 | + } | ||
| 814 | + | ||
| 815 | + pithy = pithy->get("publish"); | ||
| 816 | + if (!pithy) { | ||
| 817 | + return SRS_STAGE_PUBLISH_USER_INTERVAL_MS; | ||
| 818 | + } | ||
| 819 | + | ||
| 820 | + return ::atoi(pithy->arg0().c_str()); | ||
| 821 | +} | ||
| 822 | + | ||
| 823 | +int SrsConfig::get_pithy_print_forwarder() | ||
| 824 | +{ | ||
| 825 | + SrsConfDirective* pithy = root->get("pithy_print"); | ||
| 826 | + if (!pithy) { | ||
| 827 | + return SRS_STAGE_FORWARDER_INTERVAL_MS; | ||
| 828 | + } | ||
| 829 | + | ||
| 830 | + pithy = pithy->get("forwarder"); | ||
| 831 | + if (!pithy) { | ||
| 832 | + return SRS_STAGE_FORWARDER_INTERVAL_MS; | ||
| 833 | + } | ||
| 834 | + | ||
| 835 | + return ::atoi(pithy->arg0().c_str()); | ||
| 836 | +} | ||
| 837 | + | ||
| 838 | +int SrsConfig::get_pithy_print_hls() | ||
| 839 | +{ | ||
| 840 | + SrsConfDirective* pithy = root->get("pithy_print"); | ||
| 841 | + if (!pithy) { | ||
| 842 | + return SRS_STAGE_HLS_INTERVAL_MS; | ||
| 843 | + } | ||
| 844 | + | ||
| 845 | + pithy = pithy->get("hls"); | ||
| 846 | + if (!pithy) { | ||
| 847 | + return SRS_STAGE_HLS_INTERVAL_MS; | ||
| 848 | + } | ||
| 849 | + | ||
| 850 | + return ::atoi(pithy->arg0().c_str()); | ||
| 851 | +} | ||
| 852 | + | ||
| 768 | SrsConfDirective* SrsConfig::get_vhost(string vhost) | 853 | SrsConfDirective* SrsConfig::get_vhost(string vhost) |
| 769 | { | 854 | { |
| 770 | srs_assert(root); | 855 | srs_assert(root); |
| @@ -939,190 +1024,156 @@ bool SrsConfig::get_vhost_enabled(SrsConfDirective* vhost) | @@ -939,190 +1024,156 @@ bool SrsConfig::get_vhost_enabled(SrsConfDirective* vhost) | ||
| 939 | return true; | 1024 | return true; |
| 940 | } | 1025 | } |
| 941 | 1026 | ||
| 942 | -SrsConfDirective* SrsConfig::get_transcode(string vhost, string scope) | 1027 | +bool SrsConfig::get_gop_cache(string vhost) |
| 943 | { | 1028 | { |
| 944 | SrsConfDirective* conf = get_vhost(vhost); | 1029 | SrsConfDirective* conf = get_vhost(vhost); |
| 945 | 1030 | ||
| 946 | if (!conf) { | 1031 | if (!conf) { |
| 947 | - return NULL; | ||
| 948 | - } | ||
| 949 | - | ||
| 950 | - SrsConfDirective* transcode = conf->get("transcode"); | ||
| 951 | - if (!transcode) { | ||
| 952 | - return NULL; | ||
| 953 | - } | ||
| 954 | - | ||
| 955 | - if (transcode->arg0() == scope) { | ||
| 956 | - return transcode; | ||
| 957 | - } | ||
| 958 | - | ||
| 959 | - return NULL; | ||
| 960 | -} | ||
| 961 | - | ||
| 962 | -bool SrsConfig::get_transcode_enabled(SrsConfDirective* transcode) | ||
| 963 | -{ | ||
| 964 | - if (!transcode) { | ||
| 965 | - return false; | 1032 | + return true; |
| 966 | } | 1033 | } |
| 967 | 1034 | ||
| 968 | - SrsConfDirective* conf = transcode->get("enabled"); | ||
| 969 | - if (!conf || conf->arg0() != "on") { | 1035 | + conf = conf->get("gop_cache"); |
| 1036 | + if (conf && conf->arg0() == "off") { | ||
| 970 | return false; | 1037 | return false; |
| 971 | } | 1038 | } |
| 972 | 1039 | ||
| 973 | return true; | 1040 | return true; |
| 974 | } | 1041 | } |
| 975 | 1042 | ||
| 976 | -string SrsConfig::get_transcode_ffmpeg(SrsConfDirective* transcode) | 1043 | +bool SrsConfig::get_atc(string vhost) |
| 977 | { | 1044 | { |
| 978 | - if (!transcode) { | ||
| 979 | - return ""; | ||
| 980 | - } | 1045 | + SrsConfDirective* conf = get_vhost(vhost); |
| 981 | 1046 | ||
| 982 | - SrsConfDirective* conf = transcode->get("ffmpeg"); | ||
| 983 | if (!conf) { | 1047 | if (!conf) { |
| 984 | - return ""; | ||
| 985 | - } | ||
| 986 | - | ||
| 987 | - return conf->arg0(); | ||
| 988 | -} | ||
| 989 | - | ||
| 990 | -void SrsConfig::get_transcode_engines(SrsConfDirective* transcode, std::vector<SrsConfDirective*>& engines) | ||
| 991 | -{ | ||
| 992 | - if (!transcode) { | ||
| 993 | - return; | 1048 | + return true; |
| 994 | } | 1049 | } |
| 995 | 1050 | ||
| 996 | - for (int i = 0; i < (int)transcode->directives.size(); i++) { | ||
| 997 | - SrsConfDirective* conf = transcode->directives[i]; | ||
| 998 | - | ||
| 999 | - if (conf->name == "engine") { | ||
| 1000 | - engines.push_back(conf); | ||
| 1001 | - } | 1051 | + conf = conf->get("atc"); |
| 1052 | + if (conf && conf->arg0() == "on") { | ||
| 1053 | + return true; | ||
| 1002 | } | 1054 | } |
| 1003 | 1055 | ||
| 1004 | - return; | 1056 | + return false; |
| 1005 | } | 1057 | } |
| 1006 | 1058 | ||
| 1007 | -bool SrsConfig::get_engine_enabled(SrsConfDirective* engine) | 1059 | +double SrsConfig::get_queue_length(string vhost) |
| 1008 | { | 1060 | { |
| 1009 | - if (!engine) { | ||
| 1010 | - return false; | 1061 | + SrsConfDirective* conf = get_vhost(vhost); |
| 1062 | + | ||
| 1063 | + if (!conf) { | ||
| 1064 | + return SRS_CONF_DEFAULT_QUEUE_LENGTH; | ||
| 1011 | } | 1065 | } |
| 1012 | 1066 | ||
| 1013 | - SrsConfDirective* conf = engine->get("enabled"); | ||
| 1014 | - if (!conf || conf->arg0() != "on") { | ||
| 1015 | - return false; | 1067 | + conf = conf->get("queue_length"); |
| 1068 | + if (!conf || conf->arg0().empty()) { | ||
| 1069 | + return SRS_CONF_DEFAULT_QUEUE_LENGTH; | ||
| 1016 | } | 1070 | } |
| 1017 | 1071 | ||
| 1018 | - return true; | 1072 | + return ::atoi(conf->arg0().c_str()); |
| 1019 | } | 1073 | } |
| 1020 | 1074 | ||
| 1021 | -string SrsConfig::get_engine_vcodec(SrsConfDirective* engine) | 1075 | +SrsConfDirective* SrsConfig::get_forward(string vhost) |
| 1022 | { | 1076 | { |
| 1023 | - if (!engine) { | ||
| 1024 | - return ""; | ||
| 1025 | - } | 1077 | + SrsConfDirective* conf = get_vhost(vhost); |
| 1026 | 1078 | ||
| 1027 | - SrsConfDirective* conf = engine->get("vcodec"); | ||
| 1028 | if (!conf) { | 1079 | if (!conf) { |
| 1029 | - return ""; | 1080 | + return NULL; |
| 1030 | } | 1081 | } |
| 1031 | 1082 | ||
| 1032 | - return conf->arg0(); | 1083 | + return conf->get("forward"); |
| 1033 | } | 1084 | } |
| 1034 | 1085 | ||
| 1035 | -int SrsConfig::get_engine_vbitrate(SrsConfDirective* engine) | 1086 | +SrsConfDirective* SrsConfig::get_refer(string vhost) |
| 1036 | { | 1087 | { |
| 1037 | - if (!engine) { | ||
| 1038 | - return 0; | ||
| 1039 | - } | 1088 | + SrsConfDirective* conf = get_vhost(vhost); |
| 1040 | 1089 | ||
| 1041 | - SrsConfDirective* conf = engine->get("vbitrate"); | ||
| 1042 | if (!conf) { | 1090 | if (!conf) { |
| 1043 | - return 0; | 1091 | + return NULL; |
| 1044 | } | 1092 | } |
| 1045 | 1093 | ||
| 1046 | - return ::atoi(conf->arg0().c_str()); | 1094 | + return conf->get("refer"); |
| 1047 | } | 1095 | } |
| 1048 | 1096 | ||
| 1049 | -double SrsConfig::get_engine_vfps(SrsConfDirective* engine) | 1097 | +SrsConfDirective* SrsConfig::get_refer_play(string vhost) |
| 1050 | { | 1098 | { |
| 1051 | - if (!engine) { | ||
| 1052 | - return 0; | ||
| 1053 | - } | 1099 | + SrsConfDirective* conf = get_vhost(vhost); |
| 1054 | 1100 | ||
| 1055 | - SrsConfDirective* conf = engine->get("vfps"); | ||
| 1056 | if (!conf) { | 1101 | if (!conf) { |
| 1057 | - return 0; | 1102 | + return NULL; |
| 1058 | } | 1103 | } |
| 1059 | 1104 | ||
| 1060 | - return ::atof(conf->arg0().c_str()); | 1105 | + return conf->get("refer_play"); |
| 1061 | } | 1106 | } |
| 1062 | 1107 | ||
| 1063 | -int SrsConfig::get_engine_vwidth(SrsConfDirective* engine) | 1108 | +SrsConfDirective* SrsConfig::get_refer_publish(string vhost) |
| 1064 | { | 1109 | { |
| 1065 | - if (!engine) { | ||
| 1066 | - return 0; | ||
| 1067 | - } | 1110 | + SrsConfDirective* conf = get_vhost(vhost); |
| 1068 | 1111 | ||
| 1069 | - SrsConfDirective* conf = engine->get("vwidth"); | ||
| 1070 | if (!conf) { | 1112 | if (!conf) { |
| 1071 | - return 0; | 1113 | + return NULL; |
| 1072 | } | 1114 | } |
| 1073 | 1115 | ||
| 1074 | - return ::atoi(conf->arg0().c_str()); | 1116 | + return conf->get("refer_publish"); |
| 1075 | } | 1117 | } |
| 1076 | 1118 | ||
| 1077 | -int SrsConfig::get_engine_vheight(SrsConfDirective* engine) | 1119 | +int SrsConfig::get_chunk_size(const std::string &vhost) |
| 1078 | { | 1120 | { |
| 1079 | - if (!engine) { | ||
| 1080 | - return 0; | 1121 | + SrsConfDirective* conf = get_vhost(vhost); |
| 1122 | + | ||
| 1123 | + if (!conf) { | ||
| 1124 | + return SRS_CONF_DEFAULT_CHUNK_SIZE; | ||
| 1081 | } | 1125 | } |
| 1082 | 1126 | ||
| 1083 | - SrsConfDirective* conf = engine->get("vheight"); | 1127 | + conf = conf->get("chunk_size"); |
| 1084 | if (!conf) { | 1128 | if (!conf) { |
| 1085 | - return 0; | 1129 | + // vhost does not specify the chunk size, |
| 1130 | + // use the global instead. | ||
| 1131 | + conf = root->get("chunk_size"); | ||
| 1132 | + if (!conf) { | ||
| 1133 | + return SRS_CONF_DEFAULT_CHUNK_SIZE; | ||
| 1134 | + } | ||
| 1135 | + | ||
| 1136 | + return ::atoi(conf->arg0().c_str()); | ||
| 1086 | } | 1137 | } |
| 1087 | 1138 | ||
| 1088 | return ::atoi(conf->arg0().c_str()); | 1139 | return ::atoi(conf->arg0().c_str()); |
| 1089 | } | 1140 | } |
| 1090 | 1141 | ||
| 1091 | -int SrsConfig::get_engine_vthreads(SrsConfDirective* engine) | 1142 | +bool SrsConfig::get_bw_check_enabled(const string &vhost) |
| 1092 | { | 1143 | { |
| 1093 | - if (!engine) { | ||
| 1094 | - return 0; | 1144 | + SrsConfDirective* conf = get_vhost(vhost); |
| 1145 | + | ||
| 1146 | + if (!conf) { | ||
| 1147 | + return false; | ||
| 1095 | } | 1148 | } |
| 1096 | 1149 | ||
| 1097 | - SrsConfDirective* conf = engine->get("vthreads"); | 1150 | + conf = conf->get("bandcheck"); |
| 1098 | if (!conf) { | 1151 | if (!conf) { |
| 1099 | - return 0; | 1152 | + return false; |
| 1100 | } | 1153 | } |
| 1101 | 1154 | ||
| 1102 | - return ::atoi(conf->arg0().c_str()); | 1155 | + conf = conf->get("enabled"); |
| 1156 | + if (!conf || conf->arg0() != "on") { | ||
| 1157 | + return false; | ||
| 1158 | + } | ||
| 1159 | + | ||
| 1160 | + return true; | ||
| 1103 | } | 1161 | } |
| 1104 | 1162 | ||
| 1105 | -string SrsConfig::get_engine_vprofile(SrsConfDirective* engine) | 1163 | +string SrsConfig::get_bw_check_key(const string &vhost) |
| 1106 | { | 1164 | { |
| 1107 | - if (!engine) { | ||
| 1108 | - return ""; | ||
| 1109 | - } | 1165 | + SrsConfDirective* conf = get_vhost(vhost); |
| 1110 | 1166 | ||
| 1111 | - SrsConfDirective* conf = engine->get("vprofile"); | ||
| 1112 | if (!conf) { | 1167 | if (!conf) { |
| 1113 | return ""; | 1168 | return ""; |
| 1114 | } | 1169 | } |
| 1115 | 1170 | ||
| 1116 | - return conf->arg0(); | ||
| 1117 | -} | ||
| 1118 | - | ||
| 1119 | -string SrsConfig::get_engine_vpreset(SrsConfDirective* engine) | ||
| 1120 | -{ | ||
| 1121 | - if (!engine) { | 1171 | + conf = conf->get("bandcheck"); |
| 1172 | + if (!conf) { | ||
| 1122 | return ""; | 1173 | return ""; |
| 1123 | } | 1174 | } |
| 1124 | 1175 | ||
| 1125 | - SrsConfDirective* conf = engine->get("vpreset"); | 1176 | + conf = conf->get("key"); |
| 1126 | if (!conf) { | 1177 | if (!conf) { |
| 1127 | return ""; | 1178 | return ""; |
| 1128 | } | 1179 | } |
| @@ -1130,57 +1181,134 @@ string SrsConfig::get_engine_vpreset(SrsConfDirective* engine) | @@ -1130,57 +1181,134 @@ string SrsConfig::get_engine_vpreset(SrsConfDirective* engine) | ||
| 1130 | return conf->arg0(); | 1181 | return conf->arg0(); |
| 1131 | } | 1182 | } |
| 1132 | 1183 | ||
| 1133 | -void SrsConfig::get_engine_vparams(SrsConfDirective* engine, std::vector<string>& vparams) | 1184 | +int SrsConfig::get_bw_check_interval_ms(const string &vhost) |
| 1134 | { | 1185 | { |
| 1135 | - if (!engine) { | ||
| 1136 | - return; | 1186 | + SrsConfDirective* conf = get_vhost(vhost); |
| 1187 | + | ||
| 1188 | + if (!conf) { | ||
| 1189 | + return SRS_CONF_DEFAULT_BANDWIDTH_INTERVAL; | ||
| 1137 | } | 1190 | } |
| 1138 | 1191 | ||
| 1139 | - SrsConfDirective* conf = engine->get("vparams"); | 1192 | + conf = conf->get("bandcheck"); |
| 1140 | if (!conf) { | 1193 | if (!conf) { |
| 1141 | - return; | 1194 | + return SRS_CONF_DEFAULT_BANDWIDTH_INTERVAL; |
| 1142 | } | 1195 | } |
| 1143 | 1196 | ||
| 1144 | - for (int i = 0; i < (int)conf->directives.size(); i++) { | ||
| 1145 | - SrsConfDirective* p = conf->directives[i]; | ||
| 1146 | - if (!p) { | ||
| 1147 | - continue; | 1197 | + conf = conf->get("interval_ms"); |
| 1198 | + if (!conf) { | ||
| 1199 | + return SRS_CONF_DEFAULT_BANDWIDTH_INTERVAL; | ||
| 1148 | } | 1200 | } |
| 1149 | 1201 | ||
| 1150 | - vparams.push_back("-" + p->name); | ||
| 1151 | - vparams.push_back(p->arg0()); | 1202 | + return ::atoi(conf->arg0().c_str()) * 1000; |
| 1203 | +} | ||
| 1204 | + | ||
| 1205 | +int SrsConfig::get_bw_check_limit_kbps(const string &vhost) | ||
| 1206 | +{ | ||
| 1207 | + SrsConfDirective* conf = get_vhost(vhost); | ||
| 1208 | + | ||
| 1209 | + if (!conf) { | ||
| 1210 | + return SRS_CONF_DEFAULT_BANDWIDTH_LIMIT_KBPS; | ||
| 1211 | + } | ||
| 1212 | + | ||
| 1213 | + conf = conf->get("bandcheck"); | ||
| 1214 | + if (!conf) { | ||
| 1215 | + return SRS_CONF_DEFAULT_BANDWIDTH_LIMIT_KBPS; | ||
| 1216 | + } | ||
| 1217 | + | ||
| 1218 | + conf = conf->get("limit_kbps"); | ||
| 1219 | + if (!conf) { | ||
| 1220 | + return SRS_CONF_DEFAULT_BANDWIDTH_LIMIT_KBPS; | ||
| 1152 | } | 1221 | } |
| 1222 | + | ||
| 1223 | + return ::atoi(conf->arg0().c_str()); | ||
| 1153 | } | 1224 | } |
| 1154 | 1225 | ||
| 1155 | -void SrsConfig::get_engine_vfilter(SrsConfDirective* engine, std::vector<string>& vfilter) | 1226 | +SrsConfDirective* SrsConfig::get_transcode(string vhost, string scope) |
| 1156 | { | 1227 | { |
| 1157 | - if (!engine) { | ||
| 1158 | - return; | 1228 | + SrsConfDirective* conf = get_vhost(vhost); |
| 1229 | + | ||
| 1230 | + if (!conf) { | ||
| 1231 | + return NULL; | ||
| 1159 | } | 1232 | } |
| 1160 | 1233 | ||
| 1161 | - SrsConfDirective* conf = engine->get("vfilter"); | 1234 | + SrsConfDirective* transcode = conf->get("transcode"); |
| 1235 | + if (!transcode) { | ||
| 1236 | + return NULL; | ||
| 1237 | + } | ||
| 1238 | + | ||
| 1239 | + if (transcode->arg0() == scope) { | ||
| 1240 | + return transcode; | ||
| 1241 | + } | ||
| 1242 | + | ||
| 1243 | + return NULL; | ||
| 1244 | +} | ||
| 1245 | + | ||
| 1246 | +bool SrsConfig::get_transcode_enabled(SrsConfDirective* transcode) | ||
| 1247 | +{ | ||
| 1248 | + if (!transcode) { | ||
| 1249 | + return false; | ||
| 1250 | + } | ||
| 1251 | + | ||
| 1252 | + SrsConfDirective* conf = transcode->get("enabled"); | ||
| 1253 | + if (!conf || conf->arg0() != "on") { | ||
| 1254 | + return false; | ||
| 1255 | + } | ||
| 1256 | + | ||
| 1257 | + return true; | ||
| 1258 | +} | ||
| 1259 | + | ||
| 1260 | +string SrsConfig::get_transcode_ffmpeg(SrsConfDirective* transcode) | ||
| 1261 | +{ | ||
| 1262 | + if (!transcode) { | ||
| 1263 | + return ""; | ||
| 1264 | + } | ||
| 1265 | + | ||
| 1266 | + SrsConfDirective* conf = transcode->get("ffmpeg"); | ||
| 1162 | if (!conf) { | 1267 | if (!conf) { |
| 1268 | + return ""; | ||
| 1269 | + } | ||
| 1270 | + | ||
| 1271 | + return conf->arg0(); | ||
| 1272 | +} | ||
| 1273 | + | ||
| 1274 | +void SrsConfig::get_transcode_engines(SrsConfDirective* transcode, std::vector<SrsConfDirective*>& engines) | ||
| 1275 | +{ | ||
| 1276 | + if (!transcode) { | ||
| 1163 | return; | 1277 | return; |
| 1164 | } | 1278 | } |
| 1165 | 1279 | ||
| 1166 | - for (int i = 0; i < (int)conf->directives.size(); i++) { | ||
| 1167 | - SrsConfDirective* p = conf->directives[i]; | ||
| 1168 | - if (!p) { | ||
| 1169 | - continue; | 1280 | + for (int i = 0; i < (int)transcode->directives.size(); i++) { |
| 1281 | + SrsConfDirective* conf = transcode->directives[i]; | ||
| 1282 | + | ||
| 1283 | + if (conf->name == "engine") { | ||
| 1284 | + engines.push_back(conf); | ||
| 1285 | + } | ||
| 1170 | } | 1286 | } |
| 1171 | 1287 | ||
| 1172 | - vfilter.push_back("-" + p->name); | ||
| 1173 | - vfilter.push_back(p->arg0()); | 1288 | + return; |
| 1289 | +} | ||
| 1290 | + | ||
| 1291 | +bool SrsConfig::get_engine_enabled(SrsConfDirective* engine) | ||
| 1292 | +{ | ||
| 1293 | + if (!engine) { | ||
| 1294 | + return false; | ||
| 1174 | } | 1295 | } |
| 1296 | + | ||
| 1297 | + SrsConfDirective* conf = engine->get("enabled"); | ||
| 1298 | + if (!conf || conf->arg0() != "on") { | ||
| 1299 | + return false; | ||
| 1300 | + } | ||
| 1301 | + | ||
| 1302 | + return true; | ||
| 1175 | } | 1303 | } |
| 1176 | 1304 | ||
| 1177 | -string SrsConfig::get_engine_acodec(SrsConfDirective* engine) | 1305 | +string SrsConfig::get_engine_vcodec(SrsConfDirective* engine) |
| 1178 | { | 1306 | { |
| 1179 | if (!engine) { | 1307 | if (!engine) { |
| 1180 | return ""; | 1308 | return ""; |
| 1181 | } | 1309 | } |
| 1182 | 1310 | ||
| 1183 | - SrsConfDirective* conf = engine->get("acodec"); | 1311 | + SrsConfDirective* conf = engine->get("vcodec"); |
| 1184 | if (!conf) { | 1312 | if (!conf) { |
| 1185 | return ""; | 1313 | return ""; |
| 1186 | } | 1314 | } |
| @@ -1188,13 +1316,13 @@ string SrsConfig::get_engine_acodec(SrsConfDirective* engine) | @@ -1188,13 +1316,13 @@ string SrsConfig::get_engine_acodec(SrsConfDirective* engine) | ||
| 1188 | return conf->arg0(); | 1316 | return conf->arg0(); |
| 1189 | } | 1317 | } |
| 1190 | 1318 | ||
| 1191 | -int SrsConfig::get_engine_abitrate(SrsConfDirective* engine) | 1319 | +int SrsConfig::get_engine_vbitrate(SrsConfDirective* engine) |
| 1192 | { | 1320 | { |
| 1193 | if (!engine) { | 1321 | if (!engine) { |
| 1194 | return 0; | 1322 | return 0; |
| 1195 | } | 1323 | } |
| 1196 | 1324 | ||
| 1197 | - SrsConfDirective* conf = engine->get("abitrate"); | 1325 | + SrsConfDirective* conf = engine->get("vbitrate"); |
| 1198 | if (!conf) { | 1326 | if (!conf) { |
| 1199 | return 0; | 1327 | return 0; |
| 1200 | } | 1328 | } |
| @@ -1202,27 +1330,27 @@ int SrsConfig::get_engine_abitrate(SrsConfDirective* engine) | @@ -1202,27 +1330,27 @@ int SrsConfig::get_engine_abitrate(SrsConfDirective* engine) | ||
| 1202 | return ::atoi(conf->arg0().c_str()); | 1330 | return ::atoi(conf->arg0().c_str()); |
| 1203 | } | 1331 | } |
| 1204 | 1332 | ||
| 1205 | -int SrsConfig::get_engine_asample_rate(SrsConfDirective* engine) | 1333 | +double SrsConfig::get_engine_vfps(SrsConfDirective* engine) |
| 1206 | { | 1334 | { |
| 1207 | if (!engine) { | 1335 | if (!engine) { |
| 1208 | return 0; | 1336 | return 0; |
| 1209 | } | 1337 | } |
| 1210 | 1338 | ||
| 1211 | - SrsConfDirective* conf = engine->get("asample_rate"); | 1339 | + SrsConfDirective* conf = engine->get("vfps"); |
| 1212 | if (!conf) { | 1340 | if (!conf) { |
| 1213 | return 0; | 1341 | return 0; |
| 1214 | } | 1342 | } |
| 1215 | 1343 | ||
| 1216 | - return ::atoi(conf->arg0().c_str()); | 1344 | + return ::atof(conf->arg0().c_str()); |
| 1217 | } | 1345 | } |
| 1218 | 1346 | ||
| 1219 | -int SrsConfig::get_engine_achannels(SrsConfDirective* engine) | 1347 | +int SrsConfig::get_engine_vwidth(SrsConfDirective* engine) |
| 1220 | { | 1348 | { |
| 1221 | if (!engine) { | 1349 | if (!engine) { |
| 1222 | return 0; | 1350 | return 0; |
| 1223 | } | 1351 | } |
| 1224 | 1352 | ||
| 1225 | - SrsConfDirective* conf = engine->get("achannels"); | 1353 | + SrsConfDirective* conf = engine->get("vwidth"); |
| 1226 | if (!conf) { | 1354 | if (!conf) { |
| 1227 | return 0; | 1355 | return 0; |
| 1228 | } | 1356 | } |
| @@ -1230,35 +1358,41 @@ int SrsConfig::get_engine_achannels(SrsConfDirective* engine) | @@ -1230,35 +1358,41 @@ int SrsConfig::get_engine_achannels(SrsConfDirective* engine) | ||
| 1230 | return ::atoi(conf->arg0().c_str()); | 1358 | return ::atoi(conf->arg0().c_str()); |
| 1231 | } | 1359 | } |
| 1232 | 1360 | ||
| 1233 | -void SrsConfig::get_engine_aparams(SrsConfDirective* engine, std::vector<string>& aparams) | 1361 | +int SrsConfig::get_engine_vheight(SrsConfDirective* engine) |
| 1234 | { | 1362 | { |
| 1235 | if (!engine) { | 1363 | if (!engine) { |
| 1236 | - return; | 1364 | + return 0; |
| 1237 | } | 1365 | } |
| 1238 | 1366 | ||
| 1239 | - SrsConfDirective* conf = engine->get("aparams"); | 1367 | + SrsConfDirective* conf = engine->get("vheight"); |
| 1240 | if (!conf) { | 1368 | if (!conf) { |
| 1241 | - return; | 1369 | + return 0; |
| 1242 | } | 1370 | } |
| 1243 | 1371 | ||
| 1244 | - for (int i = 0; i < (int)conf->directives.size(); i++) { | ||
| 1245 | - SrsConfDirective* p = conf->directives[i]; | ||
| 1246 | - if (!p) { | ||
| 1247 | - continue; | 1372 | + return ::atoi(conf->arg0().c_str()); |
| 1373 | +} | ||
| 1374 | + | ||
| 1375 | +int SrsConfig::get_engine_vthreads(SrsConfDirective* engine) | ||
| 1376 | +{ | ||
| 1377 | + if (!engine) { | ||
| 1378 | + return 0; | ||
| 1248 | } | 1379 | } |
| 1249 | 1380 | ||
| 1250 | - aparams.push_back("-" + p->name); | ||
| 1251 | - aparams.push_back(p->arg0()); | 1381 | + SrsConfDirective* conf = engine->get("vthreads"); |
| 1382 | + if (!conf) { | ||
| 1383 | + return 0; | ||
| 1252 | } | 1384 | } |
| 1385 | + | ||
| 1386 | + return ::atoi(conf->arg0().c_str()); | ||
| 1253 | } | 1387 | } |
| 1254 | 1388 | ||
| 1255 | -string SrsConfig::get_engine_output(SrsConfDirective* engine) | 1389 | +string SrsConfig::get_engine_vprofile(SrsConfDirective* engine) |
| 1256 | { | 1390 | { |
| 1257 | if (!engine) { | 1391 | if (!engine) { |
| 1258 | return ""; | 1392 | return ""; |
| 1259 | } | 1393 | } |
| 1260 | 1394 | ||
| 1261 | - SrsConfDirective* conf = engine->get("output"); | 1395 | + SrsConfDirective* conf = engine->get("vprofile"); |
| 1262 | if (!conf) { | 1396 | if (!conf) { |
| 1263 | return ""; | 1397 | return ""; |
| 1264 | } | 1398 | } |
| @@ -1266,87 +1400,154 @@ string SrsConfig::get_engine_output(SrsConfDirective* engine) | @@ -1266,87 +1400,154 @@ string SrsConfig::get_engine_output(SrsConfDirective* engine) | ||
| 1266 | return conf->arg0(); | 1400 | return conf->arg0(); |
| 1267 | } | 1401 | } |
| 1268 | 1402 | ||
| 1269 | -bool SrsConfig::get_deamon() | 1403 | +string SrsConfig::get_engine_vpreset(SrsConfDirective* engine) |
| 1270 | { | 1404 | { |
| 1271 | - srs_assert(root); | 1405 | + if (!engine) { |
| 1406 | + return ""; | ||
| 1407 | + } | ||
| 1272 | 1408 | ||
| 1273 | - SrsConfDirective* conf = root->get("daemon"); | ||
| 1274 | - if (conf && conf->arg0() == "off") { | ||
| 1275 | - return false; | 1409 | + SrsConfDirective* conf = engine->get("vpreset"); |
| 1410 | + if (!conf) { | ||
| 1411 | + return ""; | ||
| 1276 | } | 1412 | } |
| 1277 | 1413 | ||
| 1278 | - return true; | 1414 | + return conf->arg0(); |
| 1279 | } | 1415 | } |
| 1280 | 1416 | ||
| 1281 | -int SrsConfig::get_max_connections() | 1417 | +void SrsConfig::get_engine_vparams(SrsConfDirective* engine, std::vector<string>& vparams) |
| 1282 | { | 1418 | { |
| 1283 | - srs_assert(root); | 1419 | + if (!engine) { |
| 1420 | + return; | ||
| 1421 | + } | ||
| 1284 | 1422 | ||
| 1285 | - SrsConfDirective* conf = root->get("max_connections"); | ||
| 1286 | - if (!conf || conf->arg0().empty()) { | ||
| 1287 | - return 2000; | 1423 | + SrsConfDirective* conf = engine->get("vparams"); |
| 1424 | + if (!conf) { | ||
| 1425 | + return; | ||
| 1288 | } | 1426 | } |
| 1289 | 1427 | ||
| 1290 | - return ::atoi(conf->arg0().c_str()); | 1428 | + for (int i = 0; i < (int)conf->directives.size(); i++) { |
| 1429 | + SrsConfDirective* p = conf->directives[i]; | ||
| 1430 | + if (!p) { | ||
| 1431 | + continue; | ||
| 1432 | + } | ||
| 1433 | + | ||
| 1434 | + vparams.push_back("-" + p->name); | ||
| 1435 | + vparams.push_back(p->arg0()); | ||
| 1436 | + } | ||
| 1291 | } | 1437 | } |
| 1292 | 1438 | ||
| 1293 | -bool SrsConfig::get_gop_cache(string vhost) | 1439 | +void SrsConfig::get_engine_vfilter(SrsConfDirective* engine, std::vector<string>& vfilter) |
| 1294 | { | 1440 | { |
| 1295 | - SrsConfDirective* conf = get_vhost(vhost); | 1441 | + if (!engine) { |
| 1442 | + return; | ||
| 1443 | + } | ||
| 1296 | 1444 | ||
| 1445 | + SrsConfDirective* conf = engine->get("vfilter"); | ||
| 1297 | if (!conf) { | 1446 | if (!conf) { |
| 1298 | - return true; | 1447 | + return; |
| 1299 | } | 1448 | } |
| 1300 | 1449 | ||
| 1301 | - conf = conf->get("gop_cache"); | ||
| 1302 | - if (conf && conf->arg0() == "off") { | ||
| 1303 | - return false; | 1450 | + for (int i = 0; i < (int)conf->directives.size(); i++) { |
| 1451 | + SrsConfDirective* p = conf->directives[i]; | ||
| 1452 | + if (!p) { | ||
| 1453 | + continue; | ||
| 1304 | } | 1454 | } |
| 1305 | 1455 | ||
| 1306 | - return true; | 1456 | + vfilter.push_back("-" + p->name); |
| 1457 | + vfilter.push_back(p->arg0()); | ||
| 1458 | + } | ||
| 1307 | } | 1459 | } |
| 1308 | 1460 | ||
| 1309 | -bool SrsConfig::get_atc(string vhost) | 1461 | +string SrsConfig::get_engine_acodec(SrsConfDirective* engine) |
| 1310 | { | 1462 | { |
| 1311 | - SrsConfDirective* conf = get_vhost(vhost); | 1463 | + if (!engine) { |
| 1464 | + return ""; | ||
| 1465 | + } | ||
| 1312 | 1466 | ||
| 1467 | + SrsConfDirective* conf = engine->get("acodec"); | ||
| 1313 | if (!conf) { | 1468 | if (!conf) { |
| 1314 | - return true; | 1469 | + return ""; |
| 1315 | } | 1470 | } |
| 1316 | 1471 | ||
| 1317 | - conf = conf->get("atc"); | ||
| 1318 | - if (conf && conf->arg0() == "on") { | ||
| 1319 | - return true; | 1472 | + return conf->arg0(); |
| 1473 | +} | ||
| 1474 | + | ||
| 1475 | +int SrsConfig::get_engine_abitrate(SrsConfDirective* engine) | ||
| 1476 | +{ | ||
| 1477 | + if (!engine) { | ||
| 1478 | + return 0; | ||
| 1320 | } | 1479 | } |
| 1321 | 1480 | ||
| 1322 | - return false; | 1481 | + SrsConfDirective* conf = engine->get("abitrate"); |
| 1482 | + if (!conf) { | ||
| 1483 | + return 0; | ||
| 1484 | + } | ||
| 1485 | + | ||
| 1486 | + return ::atoi(conf->arg0().c_str()); | ||
| 1323 | } | 1487 | } |
| 1324 | 1488 | ||
| 1325 | -double SrsConfig::get_queue_length(string vhost) | 1489 | +int SrsConfig::get_engine_asample_rate(SrsConfDirective* engine) |
| 1326 | { | 1490 | { |
| 1327 | - SrsConfDirective* conf = get_vhost(vhost); | 1491 | + if (!engine) { |
| 1492 | + return 0; | ||
| 1493 | + } | ||
| 1328 | 1494 | ||
| 1495 | + SrsConfDirective* conf = engine->get("asample_rate"); | ||
| 1329 | if (!conf) { | 1496 | if (!conf) { |
| 1330 | - return SRS_CONF_DEFAULT_QUEUE_LENGTH; | 1497 | + return 0; |
| 1331 | } | 1498 | } |
| 1332 | 1499 | ||
| 1333 | - conf = conf->get("queue_length"); | ||
| 1334 | - if (!conf || conf->arg0().empty()) { | ||
| 1335 | - return SRS_CONF_DEFAULT_QUEUE_LENGTH; | 1500 | + return ::atoi(conf->arg0().c_str()); |
| 1501 | +} | ||
| 1502 | + | ||
| 1503 | +int SrsConfig::get_engine_achannels(SrsConfDirective* engine) | ||
| 1504 | +{ | ||
| 1505 | + if (!engine) { | ||
| 1506 | + return 0; | ||
| 1507 | + } | ||
| 1508 | + | ||
| 1509 | + SrsConfDirective* conf = engine->get("achannels"); | ||
| 1510 | + if (!conf) { | ||
| 1511 | + return 0; | ||
| 1336 | } | 1512 | } |
| 1337 | 1513 | ||
| 1338 | return ::atoi(conf->arg0().c_str()); | 1514 | return ::atoi(conf->arg0().c_str()); |
| 1339 | } | 1515 | } |
| 1340 | 1516 | ||
| 1341 | -SrsConfDirective* SrsConfig::get_forward(string vhost) | 1517 | +void SrsConfig::get_engine_aparams(SrsConfDirective* engine, std::vector<string>& aparams) |
| 1342 | { | 1518 | { |
| 1343 | - SrsConfDirective* conf = get_vhost(vhost); | 1519 | + if (!engine) { |
| 1520 | + return; | ||
| 1521 | + } | ||
| 1344 | 1522 | ||
| 1523 | + SrsConfDirective* conf = engine->get("aparams"); | ||
| 1345 | if (!conf) { | 1524 | if (!conf) { |
| 1346 | - return NULL; | 1525 | + return; |
| 1347 | } | 1526 | } |
| 1348 | 1527 | ||
| 1349 | - return conf->get("forward"); | 1528 | + for (int i = 0; i < (int)conf->directives.size(); i++) { |
| 1529 | + SrsConfDirective* p = conf->directives[i]; | ||
| 1530 | + if (!p) { | ||
| 1531 | + continue; | ||
| 1532 | + } | ||
| 1533 | + | ||
| 1534 | + aparams.push_back("-" + p->name); | ||
| 1535 | + aparams.push_back(p->arg0()); | ||
| 1536 | + } | ||
| 1537 | +} | ||
| 1538 | + | ||
| 1539 | +string SrsConfig::get_engine_output(SrsConfDirective* engine) | ||
| 1540 | +{ | ||
| 1541 | + if (!engine) { | ||
| 1542 | + return ""; | ||
| 1543 | + } | ||
| 1544 | + | ||
| 1545 | + SrsConfDirective* conf = engine->get("output"); | ||
| 1546 | + if (!conf) { | ||
| 1547 | + return ""; | ||
| 1548 | + } | ||
| 1549 | + | ||
| 1550 | + return conf->arg0(); | ||
| 1350 | } | 1551 | } |
| 1351 | 1552 | ||
| 1352 | string SrsConfig::get_srs_log_file() | 1553 | string SrsConfig::get_srs_log_file() |
| @@ -1553,207 +1754,6 @@ int SrsConfig::get_http_stream_listen() | @@ -1553,207 +1754,6 @@ int SrsConfig::get_http_stream_listen() | ||
| 1553 | return 8080; | 1754 | return 8080; |
| 1554 | } | 1755 | } |
| 1555 | 1756 | ||
| 1556 | -SrsConfDirective* SrsConfig::get_refer(string vhost) | ||
| 1557 | -{ | ||
| 1558 | - SrsConfDirective* conf = get_vhost(vhost); | ||
| 1559 | - | ||
| 1560 | - if (!conf) { | ||
| 1561 | - return NULL; | ||
| 1562 | - } | ||
| 1563 | - | ||
| 1564 | - return conf->get("refer"); | ||
| 1565 | -} | ||
| 1566 | - | ||
| 1567 | -SrsConfDirective* SrsConfig::get_refer_play(string vhost) | ||
| 1568 | -{ | ||
| 1569 | - SrsConfDirective* conf = get_vhost(vhost); | ||
| 1570 | - | ||
| 1571 | - if (!conf) { | ||
| 1572 | - return NULL; | ||
| 1573 | - } | ||
| 1574 | - | ||
| 1575 | - return conf->get("refer_play"); | ||
| 1576 | -} | ||
| 1577 | - | ||
| 1578 | -SrsConfDirective* SrsConfig::get_refer_publish(string vhost) | ||
| 1579 | -{ | ||
| 1580 | - SrsConfDirective* conf = get_vhost(vhost); | ||
| 1581 | - | ||
| 1582 | - if (!conf) { | ||
| 1583 | - return NULL; | ||
| 1584 | - } | ||
| 1585 | - | ||
| 1586 | - return conf->get("refer_publish"); | ||
| 1587 | -} | ||
| 1588 | - | ||
| 1589 | -SrsConfDirective* SrsConfig::get_listen() | ||
| 1590 | -{ | ||
| 1591 | - return root->get("listen"); | ||
| 1592 | -} | ||
| 1593 | - | ||
| 1594 | -string SrsConfig::get_pid_file() | ||
| 1595 | -{ | ||
| 1596 | - SrsConfDirective* conf = root->get("pid"); | ||
| 1597 | - | ||
| 1598 | - if (!conf) { | ||
| 1599 | - return SRS_CONF_DEFAULT_PID_FILE; | ||
| 1600 | - } | ||
| 1601 | - | ||
| 1602 | - return conf->arg0(); | ||
| 1603 | -} | ||
| 1604 | - | ||
| 1605 | -int SrsConfig::get_chunk_size(const std::string &vhost) | ||
| 1606 | -{ | ||
| 1607 | - SrsConfDirective* conf = get_vhost(vhost); | ||
| 1608 | - | ||
| 1609 | - if (!conf) { | ||
| 1610 | - return SRS_CONF_DEFAULT_CHUNK_SIZE; | ||
| 1611 | - } | ||
| 1612 | - | ||
| 1613 | - conf = conf->get("chunk_size"); | ||
| 1614 | - if (!conf) { | ||
| 1615 | - // vhost does not specify the chunk size, | ||
| 1616 | - // use the global instead. | ||
| 1617 | - conf = root->get("chunk_size"); | ||
| 1618 | - if (!conf) { | ||
| 1619 | - return SRS_CONF_DEFAULT_CHUNK_SIZE; | ||
| 1620 | - } | ||
| 1621 | - | ||
| 1622 | - return ::atoi(conf->arg0().c_str()); | ||
| 1623 | - } | ||
| 1624 | - | ||
| 1625 | - return ::atoi(conf->arg0().c_str()); | ||
| 1626 | -} | ||
| 1627 | - | ||
| 1628 | -int SrsConfig::get_pithy_print_publish() | ||
| 1629 | -{ | ||
| 1630 | - SrsConfDirective* pithy = root->get("pithy_print"); | ||
| 1631 | - if (!pithy) { | ||
| 1632 | - return SRS_STAGE_PUBLISH_USER_INTERVAL_MS; | ||
| 1633 | - } | ||
| 1634 | - | ||
| 1635 | - pithy = pithy->get("publish"); | ||
| 1636 | - if (!pithy) { | ||
| 1637 | - return SRS_STAGE_PUBLISH_USER_INTERVAL_MS; | ||
| 1638 | - } | ||
| 1639 | - | ||
| 1640 | - return ::atoi(pithy->arg0().c_str()); | ||
| 1641 | -} | ||
| 1642 | - | ||
| 1643 | -int SrsConfig::get_pithy_print_forwarder() | ||
| 1644 | -{ | ||
| 1645 | - SrsConfDirective* pithy = root->get("pithy_print"); | ||
| 1646 | - if (!pithy) { | ||
| 1647 | - return SRS_STAGE_FORWARDER_INTERVAL_MS; | ||
| 1648 | - } | ||
| 1649 | - | ||
| 1650 | - pithy = pithy->get("forwarder"); | ||
| 1651 | - if (!pithy) { | ||
| 1652 | - return SRS_STAGE_FORWARDER_INTERVAL_MS; | ||
| 1653 | - } | ||
| 1654 | - | ||
| 1655 | - return ::atoi(pithy->arg0().c_str()); | ||
| 1656 | -} | ||
| 1657 | - | ||
| 1658 | -int SrsConfig::get_pithy_print_hls() | ||
| 1659 | -{ | ||
| 1660 | - SrsConfDirective* pithy = root->get("pithy_print"); | ||
| 1661 | - if (!pithy) { | ||
| 1662 | - return SRS_STAGE_HLS_INTERVAL_MS; | ||
| 1663 | - } | ||
| 1664 | - | ||
| 1665 | - pithy = pithy->get("hls"); | ||
| 1666 | - if (!pithy) { | ||
| 1667 | - return SRS_STAGE_HLS_INTERVAL_MS; | ||
| 1668 | - } | ||
| 1669 | - | ||
| 1670 | - return ::atoi(pithy->arg0().c_str()); | ||
| 1671 | -} | ||
| 1672 | - | ||
| 1673 | -bool SrsConfig::get_bw_check_enabled(const string &vhost) | ||
| 1674 | -{ | ||
| 1675 | - SrsConfDirective* conf = get_vhost(vhost); | ||
| 1676 | - | ||
| 1677 | - if (!conf) { | ||
| 1678 | - return false; | ||
| 1679 | - } | ||
| 1680 | - | ||
| 1681 | - conf = conf->get("bandcheck"); | ||
| 1682 | - if (!conf) { | ||
| 1683 | - return false; | ||
| 1684 | - } | ||
| 1685 | - | ||
| 1686 | - conf = conf->get("enabled"); | ||
| 1687 | - if (!conf || conf->arg0() != "on") { | ||
| 1688 | - return false; | ||
| 1689 | - } | ||
| 1690 | - | ||
| 1691 | - return true; | ||
| 1692 | -} | ||
| 1693 | - | ||
| 1694 | -string SrsConfig::get_bw_check_key(const string &vhost) | ||
| 1695 | -{ | ||
| 1696 | - SrsConfDirective* conf = get_vhost(vhost); | ||
| 1697 | - | ||
| 1698 | - if (!conf) { | ||
| 1699 | - return ""; | ||
| 1700 | - } | ||
| 1701 | - | ||
| 1702 | - conf = conf->get("bandcheck"); | ||
| 1703 | - if (!conf) { | ||
| 1704 | - return ""; | ||
| 1705 | - } | ||
| 1706 | - | ||
| 1707 | - conf = conf->get("key"); | ||
| 1708 | - if (!conf) { | ||
| 1709 | - return ""; | ||
| 1710 | - } | ||
| 1711 | - | ||
| 1712 | - return conf->arg0(); | ||
| 1713 | -} | ||
| 1714 | - | ||
| 1715 | -int SrsConfig::get_bw_check_interval_ms(const string &vhost) | ||
| 1716 | -{ | ||
| 1717 | - SrsConfDirective* conf = get_vhost(vhost); | ||
| 1718 | - | ||
| 1719 | - if (!conf) { | ||
| 1720 | - return SRS_CONF_DEFAULT_BANDWIDTH_INTERVAL; | ||
| 1721 | - } | ||
| 1722 | - | ||
| 1723 | - conf = conf->get("bandcheck"); | ||
| 1724 | - if (!conf) { | ||
| 1725 | - return SRS_CONF_DEFAULT_BANDWIDTH_INTERVAL; | ||
| 1726 | - } | ||
| 1727 | - | ||
| 1728 | - conf = conf->get("interval_ms"); | ||
| 1729 | - if (!conf) { | ||
| 1730 | - return SRS_CONF_DEFAULT_BANDWIDTH_INTERVAL; | ||
| 1731 | - } | ||
| 1732 | - | ||
| 1733 | - return ::atoi(conf->arg0().c_str()) * 1000; | ||
| 1734 | -} | ||
| 1735 | - | ||
| 1736 | -int SrsConfig::get_bw_check_limit_kbps(const string &vhost) | ||
| 1737 | -{ | ||
| 1738 | - SrsConfDirective* conf = get_vhost(vhost); | ||
| 1739 | - | ||
| 1740 | - if (!conf) { | ||
| 1741 | - return SRS_CONF_DEFAULT_BANDWIDTH_LIMIT_KBPS; | ||
| 1742 | - } | ||
| 1743 | - | ||
| 1744 | - conf = conf->get("bandcheck"); | ||
| 1745 | - if (!conf) { | ||
| 1746 | - return SRS_CONF_DEFAULT_BANDWIDTH_LIMIT_KBPS; | ||
| 1747 | - } | ||
| 1748 | - | ||
| 1749 | - conf = conf->get("limit_kbps"); | ||
| 1750 | - if (!conf) { | ||
| 1751 | - return SRS_CONF_DEFAULT_BANDWIDTH_LIMIT_KBPS; | ||
| 1752 | - } | ||
| 1753 | - | ||
| 1754 | - return ::atoi(conf->arg0().c_str()); | ||
| 1755 | -} | ||
| 1756 | - | ||
| 1757 | int SrsConfig::get_pithy_print_encoder() | 1757 | int SrsConfig::get_pithy_print_encoder() |
| 1758 | { | 1758 | { |
| 1759 | SrsConfDirective* pithy = root->get("encoder"); | 1759 | SrsConfDirective* pithy = root->get("encoder"); |
| @@ -116,6 +116,18 @@ private: | @@ -116,6 +116,18 @@ private: | ||
| 116 | virtual int parse_file(const char* filename); | 116 | virtual int parse_file(const char* filename); |
| 117 | virtual int parse_argv(int& i, char** argv); | 117 | virtual int parse_argv(int& i, char** argv); |
| 118 | virtual void print_help(char** argv); | 118 | virtual void print_help(char** argv); |
| 119 | +// global section | ||
| 120 | +public: | ||
| 121 | + virtual bool get_deamon(); | ||
| 122 | + virtual int get_max_connections(); | ||
| 123 | + virtual SrsConfDirective* get_listen(); | ||
| 124 | + virtual std::string get_pid_file(); | ||
| 125 | + virtual int get_pithy_print_publish(); | ||
| 126 | + virtual int get_pithy_print_forwarder(); | ||
| 127 | + virtual int get_pithy_print_encoder(); | ||
| 128 | + virtual int get_pithy_print_hls(); | ||
| 129 | + virtual int get_pithy_print_play(); | ||
| 130 | +// vhost section | ||
| 119 | public: | 131 | public: |
| 120 | virtual SrsConfDirective* get_vhost(std::string vhost); | 132 | virtual SrsConfDirective* get_vhost(std::string vhost); |
| 121 | virtual bool get_vhost_enabled(std::string vhost); | 133 | virtual bool get_vhost_enabled(std::string vhost); |
| @@ -126,6 +138,22 @@ public: | @@ -126,6 +138,22 @@ public: | ||
| 126 | virtual SrsConfDirective* get_vhost_on_unpublish(std::string vhost); | 138 | virtual SrsConfDirective* get_vhost_on_unpublish(std::string vhost); |
| 127 | virtual SrsConfDirective* get_vhost_on_play(std::string vhost); | 139 | virtual SrsConfDirective* get_vhost_on_play(std::string vhost); |
| 128 | virtual SrsConfDirective* get_vhost_on_stop(std::string vhost); | 140 | virtual SrsConfDirective* get_vhost_on_stop(std::string vhost); |
| 141 | + virtual bool get_gop_cache(std::string vhost); | ||
| 142 | + virtual bool get_atc(std::string vhost); | ||
| 143 | + virtual double get_queue_length(std::string vhost); | ||
| 144 | + virtual SrsConfDirective* get_forward(std::string vhost); | ||
| 145 | + virtual SrsConfDirective* get_refer(std::string vhost); | ||
| 146 | + virtual SrsConfDirective* get_refer_play(std::string vhost); | ||
| 147 | + virtual SrsConfDirective* get_refer_publish(std::string vhost); | ||
| 148 | + virtual int get_chunk_size(const std::string& vhost); | ||
| 149 | +// bwct(bandwidth check tool) section | ||
| 150 | +public: | ||
| 151 | + virtual bool get_bw_check_enabled(const std::string& vhost); | ||
| 152 | + virtual std::string get_bw_check_key(const std::string& vhost); | ||
| 153 | + virtual int get_bw_check_interval_ms(const std::string& vhost); | ||
| 154 | + virtual int get_bw_check_limit_kbps(const std::string& vhost); | ||
| 155 | +// vhost transcode section | ||
| 156 | +public: | ||
| 129 | virtual SrsConfDirective* get_transcode(std::string vhost, std::string scope); | 157 | virtual SrsConfDirective* get_transcode(std::string vhost, std::string scope); |
| 130 | virtual bool get_transcode_enabled(SrsConfDirective* transcode); | 158 | virtual bool get_transcode_enabled(SrsConfDirective* transcode); |
| 131 | virtual std::string get_transcode_ffmpeg(SrsConfDirective* transcode); | 159 | virtual std::string get_transcode_ffmpeg(SrsConfDirective* transcode); |
| @@ -147,12 +175,6 @@ public: | @@ -147,12 +175,6 @@ public: | ||
| 147 | virtual int get_engine_achannels(SrsConfDirective* engine); | 175 | virtual int get_engine_achannels(SrsConfDirective* engine); |
| 148 | virtual void get_engine_aparams(SrsConfDirective* engine, std::vector<std::string>& aparams); | 176 | virtual void get_engine_aparams(SrsConfDirective* engine, std::vector<std::string>& aparams); |
| 149 | virtual std::string get_engine_output(SrsConfDirective* engine); | 177 | virtual std::string get_engine_output(SrsConfDirective* engine); |
| 150 | - virtual bool get_deamon(); | ||
| 151 | - virtual int get_max_connections(); | ||
| 152 | - virtual bool get_gop_cache(std::string vhost); | ||
| 153 | - virtual bool get_atc(std::string vhost); | ||
| 154 | - virtual double get_queue_length(std::string vhost); | ||
| 155 | - virtual SrsConfDirective* get_forward(std::string vhost); | ||
| 156 | // log section | 178 | // log section |
| 157 | public: | 179 | public: |
| 158 | virtual bool get_srs_log_tank_file(); | 180 | virtual bool get_srs_log_tank_file(); |
| @@ -179,23 +201,6 @@ private: | @@ -179,23 +201,6 @@ private: | ||
| 179 | public: | 201 | public: |
| 180 | virtual bool get_http_stream_enabled(); | 202 | virtual bool get_http_stream_enabled(); |
| 181 | virtual int get_http_stream_listen(); | 203 | virtual int get_http_stream_listen(); |
| 182 | -// others | ||
| 183 | -public: | ||
| 184 | - virtual SrsConfDirective* get_refer(std::string vhost); | ||
| 185 | - virtual SrsConfDirective* get_refer_play(std::string vhost); | ||
| 186 | - virtual SrsConfDirective* get_refer_publish(std::string vhost); | ||
| 187 | - virtual SrsConfDirective* get_listen(); | ||
| 188 | - virtual std::string get_pid_file(); | ||
| 189 | - virtual int get_chunk_size(const std::string& vhost); | ||
| 190 | - virtual int get_pithy_print_publish(); | ||
| 191 | - virtual int get_pithy_print_forwarder(); | ||
| 192 | - virtual int get_pithy_print_encoder(); | ||
| 193 | - virtual int get_pithy_print_hls(); | ||
| 194 | - virtual int get_pithy_print_play(); | ||
| 195 | - virtual bool get_bw_check_enabled(const std::string& vhost); | ||
| 196 | - virtual std::string get_bw_check_key(const std::string& vhost); | ||
| 197 | - virtual int get_bw_check_interval_ms(const std::string& vhost); | ||
| 198 | - virtual int get_bw_check_limit_kbps(const std::string& vhost); | ||
| 199 | }; | 204 | }; |
| 200 | 205 | ||
| 201 | /** | 206 | /** |
-
请 注册 或 登录 后发表评论