<commit_before>/*
 *  Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree.
 */

/* More information about these options at jshint.com/docs/options */
// Variables defined in and used from main.js.
/* globals randomString, AppController, sendAsyncUrlRequest, parseJSON */
/* exported params */
'use strict';

// Generate random room id and connect.

var roomServer = 'https://apprtc.appspot.com';
var loadingParams = {
  errorMessages: [],
  roomId: randomString(9),
  roomServer: roomServer,
  paramsFunction: function() {
    return new Promise(function(resolve, reject) {
      trace('Initializing; retrieving params from: ' + roomServer + '/params');
      sendAsyncUrlRequest('GET', roomServer + '/params').then(function(result) {
        var serverParams = parseJSON(result);
        var newParams = {};
        if (!serverParams)
        {
          resolve(newParams);
        }
        
        // Convert from server format to expected format.
        // TODO(tkchin): clean up response format. JSHint doesn't like it.
        /* jshint ignore:start */
        newParams.isLoopback = serverParams.is_loopback === 'true';
        newParams.mediaConstraints = parseJSON(serverParams.media_constraints);
        newParams.offerConstraints = parseJSON(serverParams.offer_constraints);
        newParams.peerConnectionConfig = parseJSON(serverParams.pc_config);
        newParams.peerConnectionConstraints = parseJSON(serverParams.pc_constraints);
        newParams.turnRequestUrl = serverParams.turn_url;
        newParams.turnTransports = serverParams.turn_transports;
        newParams.audioSendBitrate = serverParams.asbr;
        newParams.audioSendCodec = serverParams.audio_send_codec;
        newParams.audioRecvBitrate = serverParams.arbr;
        newParams.audioRecvCodec = serverParams.audio_receive_codec;
        newParams.opusMaxPbr = serverParams.opusmaxpbr;
        newParams.opusFec = serverParams.opusfec;
        newParams.videoSendBitrate = serverParams.vsbr;
        newParams.videoSendInitialBitrate = serverParams.vsibr;
        newParams.videoSendCodec = serverParams.video_send_codec;
        newParams.videoRecvBitrate = serverParams.vrbr;
        newParams.videoRecvCodec = serverParams.video_receive_codec;
        newParams.wssUrl = serverParams.wss_url;
        newParams.wssPostUrl = serverParams.wss_post_url;
        /* jshint ignore:end */
        newParams.messages = serverParams.messages;
        
        trace('Initializing; parameters from server: ');
        trace(JSON.stringify(newParams));
        resolve(newParams);
      }).catch(function(error) {
        trace('Initializing; error getting params from server: ' + error.message);
        reject(error);
      });
    });
    
  }<commit_msg>Fix missing return statement.<commit_after>/*
 *  Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree.
 */

/* More information about these options at jshint.com/docs/options */
// Variables defined in and used from main.js.
/* globals randomString, AppController, sendAsyncUrlRequest, parseJSON */
/* exported params */
'use strict';

// Generate random room id and connect.

var roomServer = 'https://apprtc.appspot.com';
var loadingParams = {
  errorMessages: [],
  roomId: randomString(9),
  roomServer: roomServer,
  paramsFunction: function() {
    return new Promise(function(resolve, reject) {
      trace('Initializing; retrieving params from: ' + roomServer + '/params');
      sendAsyncUrlRequest('GET', roomServer + '/params').then(function(result) {
        var serverParams = parseJSON(result);
        var newParams = {};
        if (!serverParams)
        {
          resolve(newParams);
          return;
        }
        
        // Convert from server format to expected format.
        // TODO(tkchin): clean up response format. JSHint doesn't like it.
        /* jshint ignore:start */
        newParams.isLoopback = serverParams.is_loopback === 'true';
        newParams.mediaConstraints = parseJSON(serverParams.media_constraints);
        newParams.offerConstraints = parseJSON(serverParams.offer_constraints);
        newParams.peerConnectionConfig = parseJSON(serverParams.pc_config);
        newParams.peerConnectionConstraints = parseJSON(serverParams.pc_constraints);
        newParams.turnRequestUrl = serverParams.turn_url;
        newParams.turnTransports = serverParams.turn_transports;
        newParams.audioSendBitrate = serverParams.asbr;
        newParams.audioSendCodec = serverParams.audio_send_codec;
        newParams.audioRecvBitrate = serverParams.arbr;
        newParams.audioRecvCodec = serverParams.audio_receive_codec;
        newParams.opusMaxPbr = serverParams.opusmaxpbr;
        newParams.opusFec = serverParams.opusfec;
        newParams.videoSendBitrate = serverParams.vsbr;
        newParams.videoSendInitialBitrate = serverParams.vsibr;
        newParams.videoSendCodec = serverParams.video_send_codec;
        newParams.videoRecvBitrate = serverParams.vrbr;
        newParams.videoRecvCodec = serverParams.video_receive_codec;
        newParams.wssUrl = serverParams.wss_url;
        newParams.wssPostUrl = serverParams.wss_post_url;
        /* jshint ignore:end */
        newParams.messages = serverParams.messages;
        
        trace('Initializing; parameters from server: ');
        trace(JSON.stringify(newParams));
        resolve(newParams);
      }).catch(function(error) {
        trace('Initializing; error getting params from server: ' + error.message);
        reject(error);
      });
    });
  }
{'fraction_non_alphanumeric': 0.09566260929195954, 'fraction_numerical': 0.0017143836790673753, 'mean_word_length': 3.17012151536812, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7380358', 'n_tokens_mistral': 1618, 'n_tokens_neox': 1588, 'n_words': 358}