<commit_before>/* global RTCPeerConnection */

//
// Camera and Microphone Authorization   
//

/*
cordova.plugins.diagnostic.requestMicrophoneAuthorization(function (status) {
    if(status === cordova.plugins.diagnostic.permissionStatus.GRANTED) {
        console.log('GRANTED');
    } else {
        console.log(new Error('AuthorizationDenied'));   
    }
}, function (err) {
    console.log(new Error('AuthorizationFailed: ' + err));   
});

cordova.plugins.diagnostic.requestCameraAuthorization(function (status) {
    if(status === cordova.plugins.diagnostic.permissionStatus.GRANTED) {
        console.log('GRANTED');
    } else {
        console.log(new Error('AuthorizationDenied'));   
    }
}, function (err) {
    console.log(new Error('AuthorizationFailed: ' + err));   
});
*/

var cordova = window.cordova;

// Expose WebRTC Globals
if (cordova && cordova.plugins && cordova.plugins.iosrtc) {
  cordova.plugins.iosrtc.registerGlobals();
}

//
// Container
//

var appContainer = document.querySelector('.appx');
if (!appContainer) {
  document.body.innerHTML = "";
  appContainer = document.body;
}


//
// getUserMedia
//

var localVideoEl = document.createElement('video');
localVideoEl.setAttribute('autoplay', 'autoplay');
localVideoEl.setAttribute('playsinline', 'playsinline');
// Cause zIndex - 1 failure
//localVideoEl.style.backgroundColor = 'purple';
localVideoEl.style.position = 'absolute';
localVideoEl.style.top = 0;
localVideoEl.style.left = 0;
localVideoEl.style.width = "100px";
localVideoEl.style.height = "100px";
localVideoEl.style.transform = "scaleX(-1)";
appContainer.appendChild(localVideoEl);

navigator.mediaDevices.enumerateDevices().then(function (devices) {
    console.log('getMediaDevices.ok', devices);
    devices.forEach(function (device, idx) {
      console.log('getMediaDevices.devices', idx, device.label, device.kind, device.deviceId);
    });
}, function (err) {
    console.log('getMediaDevices.err', err);
});

var localStream;

navigator.mediaDevices.getUserMedia({
  video: true,
  audio: true
  /*
  video: {
    // Test Back Camera
    //deviceId: 'com.apple.avfoundation.avcapturedevice.built-in_video:0'
    //sourceId: 'com.apple.avfoundation.avcapturedevice.built-in_video:0'
    deviceId: {
      exact: 'com.apple.avfoundation.avcapturedevice.built-in_video:0'
    }
  }, 
  audio: {
    exact: 'Built-In Microphone'
  }*/
}).then(function (stream) {
  
  localStream = stream;
  localVideoEl.srcObject = localStream;

  console.log('getUserMedia.stream', stream);
  console.log('getUserMedia.stream.getTracks', stream.getTracks());

  if (cordova && cordova.plugins && cordova.plugins.iosrtc) {
    cordova.plugins.iosrtc.observeVideo(localVideoEl);
  }

  //localVideoEl.src = window.URL.createObjectURL(stream);

  TestPluginMediaStreamRenderer(localVideoEl);
  TestRTCPeerConnection(localStream);
 
}).catch(function (err) {
  console.log('getUserMediaError', err, err.stack);
});

function TestPluginMediaStreamRenderer(localVideoEl) {

  // Animate video position
  var currentPosition = {
    x: 0,
    y: 0
  };
<commit_msg>update extra/renderer-and-libwebrtc-tests.js scripts<commit_after>/* global RTCPeerConnection */

//
// Camera and Microphone Authorization   
//

/*
cordova.plugins.diagnostic.requestMicrophoneAuthorization(function (status) {
    if(status === cordova.plugins.diagnostic.permissionStatus.GRANTED) {
        console.log('GRANTED');
    } else {
        console.log(new Error('AuthorizationDenied'));   
    }
}, function (err) {
    console.log(new Error('AuthorizationFailed: ' + err));   
});

cordova.plugins.diagnostic.requestCameraAuthorization(function (status) {
    if(status === cordova.plugins.diagnostic.permissionStatus.GRANTED) {
        console.log('GRANTED');
    } else {
        console.log(new Error('AuthorizationDenied'));   
    }
}, function (err) {
    console.log(new Error('AuthorizationFailed: ' + err));   
});
*/

var cordova = window.cordova;

// Expose WebRTC Globals
if (cordova && cordova.plugins && cordova.plugins.iosrtc) {
  cordova.plugins.iosrtc.registerGlobals();
}

//
// Container
//

var appContainer = document.querySelector('.appx');
if (!appContainer) {
  document.body.innerHTML = "";
  appContainer = document.body;
}


//
// getUserMedia
//

var localVideoEl = document.createElement('video');
localVideoEl.setAttribute('autoplay', 'autoplay');
localVideoEl.setAttribute('playsinline', 'playsinline');
// Cause zIndex - 1 failure
//localVideoEl.style.backgroundColor = 'purple';
localVideoEl.style.position = 'absolute';
localVideoEl.style.top = 0;
localVideoEl.style.left = 0;
localVideoEl.style.width = "100px";
localVideoEl.style.height = "100px";
localVideoEl.style.transform = "scaleX(-1)";
appContainer.appendChild(localVideoEl);

navigator.mediaDevices.enumerateDevices().then(function (devices) {
    console.log('getMediaDevices.ok', devices);
    devices.forEach(function (device, idx) {
      console.log('getMediaDevices.devices', idx, device.label, device.kind, device.deviceId);
    });
}, function (err) {
    console.log('getMediaDevices.err', err);
});

var localStream;

navigator.mediaDevices.getUserMedia({
  video: true,
  audio: true
  /*
  video: {
    // Test Back Camera
    //deviceId: 'com.apple.avfoundation.avcapturedevice.built-in_video:0'
    //sourceId: 'com.apple.avfoundation.avcapturedevice.built-in_video:0'
    deviceId: {
      exact: 'com.apple.avfoundation.avcapturedevice.built-in_video:0'
    }
  }, 
  audio: {
    exact: 'Built-In Microphone'
  }*/
}).then(function (stream) {

  console.log('getUserMedia.stream', stream);
  console.log('getUserMedia.stream.getTracks', stream.getTracks());

  var srcObjectStream;
  try {

    localStream = stream;
    srcObjectStream = localVideoEl.srcObject = localStream;
    //localVideoEl.src = window.URL.createObjectURL(stream);
  
  } catch (err) {
    console.log('srcObject.err', err);
  }

  if (cordova && cordova.plugins && cordova.plugins.iosrtc) {
    cordova.plugins.iosrtc.observeVideo(localVideoEl);
  }

  if (srcObjectStream) {

    TestPluginMediaStreamRenderer(localVideoEl);
    TestRTCPeerConnection(localStream); 
  }
 
}).catch(function (err) {
  console.log('getUserMediaError', err, err.stack);
});

function TestPluginMediaStreamRenderer(localVideoEl) {

  // Animate video position
  var currentPosition = {
    x: 0,
    y: 0
  };

{'fraction_non_alphanumeric': 0.14853654719048365, 'fraction_numerical': 0.0046955705118171855, 'mean_word_length': 4.128410914927769, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4876002', 'n_tokens_mistral': 2086, 'n_tokens_neox': 2059, 'n_words': 318}