<commit_before>'use strict';

angular.module('ahoyApp.services', [])
    .service('ahoyService', ["$modal", function($modal) {
      var self = this;
      var activeConference = false;
      var activeMedia = false;
      var subscribingMedia = false;
      var transmitOnly = false;
      var preferences = {};
      preferences.room = '';
      preferences.name = '';
      preferences.password = '';
      preferences.shareVideo = false;
      preferences.shareAudio = false;
      preferences.maxVideoBitrate = 1000;
      preferences.captureHdVideo = false;
      preferences.speaker = false;
      preferences.moderator = false;
      preferences.muteVideo = false;
      preferences.muteAudio = false;
      
      var scopeListener = null;
      var chatMessageListener = null;
      var controlMessageListener = null;
      var statusMessageListener = null;
      var mediaEventListener = null;
      var conferenceEventListener = null;
      var members = {};
      var localMember = {};
      var speakerID = null;

      var ws = null;
      var wsUrl;
      if (document.location.href.indexOf("ttp://") > 0) {
        wsUrl = "ws://"+document.location.href.substring(7, document.location.href.indexOf("/", 7));
      } else if (document.location.href.indexOf("ttps://") > 0) {
        wsUrl = "wss://"+document.location.href.substring(8, document.location.href.indexOf("/", 8));
      }

      preferences.wsUrl = wsUrl;
      console.log('ahoyService: '+wsUrl);

	function sendMediaRequest(members) {
	    var request_members = Array();
	    if ((members == null) || (members.length == 0)) return;
	    for (var key in members) {
		if (members[key] != localMember) {
		    request_members.push({memberID: members[key].memberID, audio: members[key].audio.available, video: members[key].video.available});
		}
	    }
	    ws.send(JSON.stringify({messageType:"MEDIA_request", members: request_members, transactionID: generateTransactionID()}));
	}


      function generateTransactionID() {
	    var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
            var string_length = 32;
            var randomstring = '';
            for (var i=0; i<string_length; i++) {
                var rnum = Math.floor(Math.random() * chars.length);
                randomstring += chars.substring(rnum,rnum+1);
            }
            return randomstring;
      }
	function processSdp(sdp_str) {
            var sdp = new Array();
            var sdp_idx = 0;
            var fingerprint = "";
            var has_mid = false;
            var lines = sdp_str.split("\r\n");

            for (var i = 0; i < lines.length; i++) {
                if (lines[i].indexOf("=crypto") > 0) {
            	    /* no SDES, DTLS all the way */
                } else {
                    /* keep the rest */
                    sdp[sdp_idx++] = lines[i];
                }
            }
            return sdp.join("\r\n");
        }

	function createPeerConnection(memberID) {
	    var peer_connection = null;
	    console.log("createPeerConnection: browser is " + webrtcDetectedBrowser);
	    try {
		if (webrtcDetectedBrowser == "firefox") {
		    peer_connection = new RTCPeerConnection();
		} else {
		    var pc_config = null;
		    var pc_constraints = {"optional": [{"DtlsSrtpKeyAgreement": true}]};
		    peer_connection = new RTCPeerConnection(pc_config, pc_constraints);
		}
		if (peer_connection == null) {
		    console.log("createPeerConnection: FAILED.");
		}
		if (memberID != null) {
		  peer_connection.onaddstream = function(event) {<commit_msg>Use "googCpuOverUseDetection" PeerConnection constraint.<commit_after>'use strict';

angular.module('ahoyApp.services', [])
    .service('ahoyService', ["$modal", function($modal) {
      var self = this;
      var activeConference = false;
      var activeMedia = false;
      var subscribingMedia = false;
      var transmitOnly = false;
      var preferences = {};
      preferences.room = '';
      preferences.name = '';
      preferences.password = '';
      preferences.shareVideo = false;
      preferences.shareAudio = false;
      preferences.maxVideoBitrate = 1000;
      preferences.captureHdVideo = false;
      preferences.speaker = false;
      preferences.moderator = false;
      preferences.muteVideo = false;
      preferences.muteAudio = false;
      
      var scopeListener = null;
      var chatMessageListener = null;
      var controlMessageListener = null;
      var statusMessageListener = null;
      var mediaEventListener = null;
      var conferenceEventListener = null;
      var members = {};
      var localMember = {};
      var speakerID = null;

      var ws = null;
      var wsUrl;
      if (document.location.href.indexOf("ttp://") > 0) {
        wsUrl = "ws://"+document.location.href.substring(7, document.location.href.indexOf("/", 7));
      } else if (document.location.href.indexOf("ttps://") > 0) {
        wsUrl = "wss://"+document.location.href.substring(8, document.location.href.indexOf("/", 8));
      }

      preferences.wsUrl = wsUrl;
      console.log('ahoyService: '+wsUrl);

	function sendMediaRequest(members) {
	    var request_members = Array();
	    if ((members == null) || (members.length == 0)) return;
	    for (var key in members) {
		if (members[key] != localMember) {
		    request_members.push({memberID: members[key].memberID, audio: members[key].audio.available, video: members[key].video.available});
		}
	    }
	    ws.send(JSON.stringify({messageType:"MEDIA_request", members: request_members, transactionID: generateTransactionID()}));
	}


      function generateTransactionID() {
	    var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
            var string_length = 32;
            var randomstring = '';
            for (var i=0; i<string_length; i++) {
                var rnum = Math.floor(Math.random() * chars.length);
                randomstring += chars.substring(rnum,rnum+1);
            }
            return randomstring;
      }
	function processSdp(sdp_str) {
            var sdp = new Array();
            var sdp_idx = 0;
            var fingerprint = "";
            var has_mid = false;
            var lines = sdp_str.split("\r\n");

            for (var i = 0; i < lines.length; i++) {
                if (lines[i].indexOf("=crypto") > 0) {
            	    /* no SDES, DTLS all the way */
                } else {
                    /* keep the rest */
                    sdp[sdp_idx++] = lines[i];
                }
            }
            return sdp.join("\r\n");
        }

	function createPeerConnection(memberID) {
	    var peer_connection = null;
	    console.log("createPeerConnection: browser is " + webrtcDetectedBrowser);
	    try {
		if (webrtcDetectedBrowser == "firefox") {
		    peer_connection = new RTCPeerConnection();
		} else {
		    var pc_config = null;
		    var pc_constraints = {"optional": [{"DtlsSrtpKeyAgreement": true}, {"googCpuOveruseDetection": true}]};
		    peer_connection = new RTCPeerConnection(pc_config, pc_constraints);
		}
		if (peer_connection == null) {
		    console.log("createPeerConnection: FAILED.");
		}
		if (memberID != null) {
		  peer_connection.onaddstream = function(event) {
{'fraction_non_alphanumeric': 0.12831491712707183, 'fraction_numerical': 0.0077348066298342545, 'mean_word_length': 2.4171779141104293, 'pattern_counts': {'":': 5, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, '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': '4356854', 'n_tokens_mistral': 2241, 'n_tokens_neox': 2089, 'n_words': 453}