winlin

refine the filter of camera and microphone

@@ -148,39 +148,63 @@ function srs_initialize_codec_page( @@ -148,39 +148,63 @@ function srs_initialize_codec_page(
148 for (var i = 0; i < cameras.length; i++) { 148 for (var i = 0; i < cameras.length; i++) {
149 $(sl_cameras).append("<option value='" + i + "'>" + cameras[i] + "</option"); 149 $(sl_cameras).append("<option value='" + i + "'>" + cameras[i] + "</option");
150 } 150 }
151 - // optional: select the first no "virtual" signed. 151 + // optional: select the except matches
  152 + matchs = ["virtual"];
152 for (var i = 0; i < cameras.length; i++) { 153 for (var i = 0; i < cameras.length; i++) {
153 - if (cameras[i].toLowerCase().indexOf("virtual") == -1) { 154 + for (var j = 0; j < matchs.length; j++) {
  155 + if (cameras[i].toLowerCase().indexOf(matchs[j]) == -1) {
154 $(sl_cameras + " option[value='" + i + "']").attr("selected", true); 156 $(sl_cameras + " option[value='" + i + "']").attr("selected", true);
155 break; 157 break;
156 } 158 }
157 } 159 }
158 - // optional: select the first "integrated" signed. 160 + if (j < matchs.length) {
  161 + break;
  162 + }
  163 + }
  164 + // optional: select the first matched.
  165 + matchs = ["turevision", "integrated"];
159 for (var i = 0; i < cameras.length; i++) { 166 for (var i = 0; i < cameras.length; i++) {
160 - if (cameras[i].toLowerCase().indexOf("integrated") >= 0) { 167 + for (var j = 0; j < matchs.length; j++) {
  168 + if (cameras[i].toLowerCase().indexOf(matchs[j]) >= 0) {
161 $(sl_cameras + " option[value='" + i + "']").attr("selected", true); 169 $(sl_cameras + " option[value='" + i + "']").attr("selected", true);
162 break; 170 break;
163 } 171 }
164 } 172 }
  173 + if (j < matchs.length) {
  174 + break;
  175 + }
  176 + }
165 177
166 $(sl_microphones).empty(); 178 $(sl_microphones).empty();
167 for (var i = 0; i < microphones.length; i++) { 179 for (var i = 0; i < microphones.length; i++) {
168 $(sl_microphones).append("<option value='" + i + "'>" + microphones[i] + "</option"); 180 $(sl_microphones).append("<option value='" + i + "'>" + microphones[i] + "</option");
169 } 181 }
170 - // optional: select the first no "default" signed. 182 + // optional: select the except matches
  183 + matchs = ["default"];
171 for (var i = 0; i < microphones.length; i++) { 184 for (var i = 0; i < microphones.length; i++) {
172 - if (microphones[i].toLowerCase().indexOf("default") == -1) { 185 + for (var j = 0; j < matchs.length; j++) {
  186 + if (microphones[i].toLowerCase().indexOf(matchs[j]) == -1) {
173 $(sl_microphones + " option[value='" + i + "']").attr("selected", true); 187 $(sl_microphones + " option[value='" + i + "']").attr("selected", true);
174 break; 188 break;
175 } 189 }
176 } 190 }
177 - // optional: select the first "realtek" signed. 191 + if (j < matchs.length) {
  192 + break;
  193 + }
  194 + }
  195 + // optional: select the first matched.
  196 + matchs = ["realtek", "内置式麦克风"];
178 for (var i = 0; i < microphones.length; i++) { 197 for (var i = 0; i < microphones.length; i++) {
179 - if (microphones[i].toLowerCase().indexOf("realtek") >= 0) { 198 + for (var j = 0; j < matchs.length; j++) {
  199 + if (microphones[i].toLowerCase().indexOf(matchs[j]) >= 0) {
180 $(sl_microphones + " option[value='" + i + "']").attr("selected", true); 200 $(sl_microphones + " option[value='" + i + "']").attr("selected", true);
181 break; 201 break;
182 } 202 }
183 } 203 }
  204 + if (j < matchs.length) {
  205 + break;
  206 + }
  207 + }
184 208
185 $(sl_vcodec).empty(); 209 $(sl_vcodec).empty();
186 var vcodecs = ["h264", "vp6"]; 210 var vcodecs = ["h264", "vp6"];
@@ -373,7 +373,7 @@ @@ -373,7 +373,7 @@
373 } 373 }
374 374
375 function on_user_publish() { 375 function on_user_publish() {
376 - if ($("#txt_name").val().trim() == "") { 376 + if ($("#txt_name").val() == "") {
377 $("#txt_name").focus().parent().parent().addClass("error"); 377 $("#txt_name").focus().parent().parent().addClass("error");
378 warn(100, "请输入您的名字"); 378 warn(100, "请输入您的名字");
379 return; 379 return;
@@ -460,7 +460,7 @@ @@ -460,7 +460,7 @@
460 460
461 var chat = {}; 461 var chat = {};
462 chat.id = -1; 462 chat.id = -1;
463 - chat.username = $("#txt_name").val().trim(); 463 + chat.username = $("#txt_name").val();
464 chat.agent = navigator.userAgent; 464 chat.agent = navigator.userAgent;
465 chat.url = url; 465 chat.url = url;
466 chat.vcodec = vcodec; 466 chat.vcodec = vcodec;