diff --git a/src/wip/lwpCallParkHandler.js b/src/wip/lwpCallParkHandler.js deleted file mode 100644 index 77ca093..0000000 --- a/src/wip/lwpCallParkHandler.js +++ /dev/null @@ -1,23 +0,0 @@ -'use strict'; - -import EventEmitter from 'events'; - -class lwpCallParkHandler extends EventEmitter { - constructor(libwebphone, config = {}, i18n = null) { - // TODO: render a dialpad and produce events - // when clicked, trigger playback of DTMF - // via lwpMediaDevices, and collect the dialed number - // when not in-call - super(); - this._libwebphone = libwebphone; - return Promise.resolve(); - } -} - -export default lwpCallParkHandler; - -export function CallParkUtils() -{ - -} - diff --git a/src/wip/lwpCallParkWebServiceHandler.js b/src/wip/lwpCallParkWebServiceHandler.js deleted file mode 100644 index 56f4131..0000000 --- a/src/wip/lwpCallParkWebServiceHandler.js +++ /dev/null @@ -1,31 +0,0 @@ -'use strict'; - -import EventEmitter from 'events'; - -export class lwpCallParkWebServiceHandler extends EventEmitter { - constructor(libwebphone, config = {}, i18n = null) { - // TODO: render a dialpad and produce events - // when clicked, trigger playback of DTMF - // via lwpMediaDevices, and collect the dialed number - // when not in-call - // super(); - // this._libwebphone = libwebphone; - // return Promise.resolve(); - } -} - -export default lwpCallParkWebServiceHandler; - -export function getCallParkedCallList(wsurl) -{ - - //wsurl = 'https://jsonplaceholder.typicode.com/users' - fetch(wsurl) - .then(response => response.json()) - .then(data => console.log(data)) - - - -} - - diff --git a/src/wip/lwpKazoo.js b/src/wip/lwpKazoo.js deleted file mode 100644 index 56db0f8..0000000 --- a/src/wip/lwpKazoo.js +++ /dev/null @@ -1,60 +0,0 @@ -"use strict"; - -import EventEmitter from "events"; -import i18next from "i18next"; -import _ from "lodash"; - -export default class extends EventEmitter { - constructor(libwebphone, config = {}, i18n = null) { - super(); - this._libwebphone = libwebphone; - return this._initInternationalization(config.i18n, i18n) - .then(() => { - return this._initProperties(config.phoneUtils); - }) - .then(() => { - return this; - }); - } - - kazooSubscribe(Type) {} - - kazooUnsubscribe(Type) {} - - kazooRequest(type, url, options) {} - - _initInternationalization(config = { fallbackLng: "en" }, i18n = null) { - if (i18n) { - this._translator = i18n; - return Promise.resolve(); - } - - var i18nPromise = i18next.init(config); - i18next.addResourceBundle("en", "libwebphone", { - transport: {} - }); - - return i18nPromise.then(translator => (this._translator = translator)); - } - - _initProperties(config) { - var defaults = { - sockets: [], - api: "https://sandbox.2600hz.com:8443/v2", - authentication: { - username: "", - password: "", - account_name: "" - } - }; - - this._config = this._merge(defaults, config); - - return Promise.resolve(); - } - - /** Util Functions */ - _merge(...args) { - return _.merge(...args); - } -} diff --git a/src/wip/lwpMediaPreviews.js b/src/wip/lwpMediaPreviews.js deleted file mode 100644 index 9a75125..0000000 --- a/src/wip/lwpMediaPreviews.js +++ /dev/null @@ -1,195 +0,0 @@ - - -import AudioStreamMeter from "audio-stream-meter"; - -startPreviews() { - if (this._inputActive) { - return; - } - - if (this._config.audiooutput.preview.loopback.startOnPreview) { - this.startPreviewOutputLoopback(); - } - - this._startInputStreams().then(() => { - this._previewActive = true; - this._emit("preview.started", this); - }); - } - - startPreviewOutputTone() { - this._previewAudio.oscillatorGainNode.gain.value = 1; - this._emit("preview.tone.started", this); - } - - stopPreviewOutputTone() { - this._previewAudio.oscillatorGainNode.gain.value = 0; - this._emit("preview.tone.stop", this); - } - - isPreviewOutputToneActive() { - return this._previewAudio.oscillatorGainNode.gain.value > 0; - } - - startPreviewOutputLoopback() { - this._previewAudio.loopbackGainNode.gain.value = 1; - this._emit("preview.loopback.started", this); - } - - stopPreviewOutputLoopback() { - this._previewAudio.loopbackGainNode.gain.value = 0; - this._emit("preview.loopback.stop", this); - } - - togglePreviewOutputLoopback() { - if (this.isPreviewOutputLoopbackActive()) { - this.stopPreviewOutputLoopback(); - } else { - this.startPreviewOutputLoopback(); - } - } - - isPreviewOutputLoopbackActive() { - return this._previewAudio.loopbackGainNode.gain.value > 0; - } - - stopPreviews() { - this.stopPreviewOutputLoopback(); - this.stopPreviewOutputTone(); - - if (!this._inputActive) { - this._stopAllInputs(); - } - - this._previewActive = false; - this._emit("preview.stop", this); - } - - - updateRenders() { - this.render((render) => { - render.data = this._renderData(render.data); - return render; - }).then((rendered) => { - this._mediaStreamPromise.then((mediaStream) => { - let audioInputPreviews = []; - rendered.forEach((render) => { - Object.keys(render.by_id).forEach((key) => { - if (render.by_id[key].preview == "audioinput") { - let element = render.by_id[key].element; - if (element) { - element.srcObject = mediaStream; - audioInputPreviews.push(element.children[0]); - } - } - }); - - Object.keys(render.by_name).forEach((key) => { - if (render.by_name[key].preview == "audioinput") { - let element = render.by_name[key].element; - if (element) { - element.srcObject = mediaStream; - audioInputPreviews.push(element.children[0]); - } - } - }); - - Object.keys(render.by_id).forEach((key) => { - if (render.by_id[key].preview == "videoinput") { - let element = render.by_id[key].element; - if (element) { - element.srcObject = mediaStream; - } - } - }); - - Object.keys(render.by_name).forEach((key) => { - if (render.by_name[key].preview == "videoinput") { - let element = render.by_name[key].element; - if (element) { - element.srcObject = mediaStream; - } - } - }); - }); - this._previewAudioMeter.audioProcessCallback = this._audioProcessCallback( - this._previewAudioMeter, - audioInputPreviews - ); - }); - }); - } - - - _initProperties(config) { - var defaults = { - audiooutput: { - show: "sinkId" in HTMLMediaElement.prototype, - startMuted: false, - preferedDeviceIds: [], - livePreview: true, - preview: { - loopback: { - show: true, - delay: 0.5, - startOnPreview: false, - }, - tone: { - show: true, - frequency: 440, - duration: 1.5, - type: "sine", - startOnPreview: false, - }, - }, - }, - audioinput: { - enabled: true, - show: true, - startMuted: false, - constraints: {}, - preferedDeviceIds: [], - livePreview: true, - }, - videoinput: { - enabled: true, - show: true, - startMuted: true, - constraints: {}, - preferedDeviceIds: [], - livePreview: true, - }, - renderTargets: [], - detectDeviceChanges: true, - startPreview: false, - startStreams: false, - }; - this._config = merge(defaults, config); - - // NOTE: it makes more sense if configured with highest priority to - // lowest, but we use the index number to represent that so flip it - this._config.audiooutput.preferedDeviceIds.reverse(); - this._config.audioinput.preferedDeviceIds.reverse(); - this._config.videoinput.preferedDeviceIds.reverse(); - - this._inputActive = false; - this._previewActive = false; - - this._availableDevices = { - audiooutput: [], - audioinput: [], - videoinput: [ - this._deviceParameters({ - deviceId: "none", - label: "libwebphone:mediaDevices.none", - kind: "videoinput", - displayOrder: 0, - }), - ], - }; - - this._loaded = false; - this._changeStreamMutex = new Mutex(); - this._audioContext = new (window.AudioContext || - window.webkitAudioContext)(); - } \ No newline at end of file diff --git a/src/wip/lwpdtmftonegenerator.js b/src/wip/lwpdtmftonegenerator.js deleted file mode 100644 index e964b4b..0000000 --- a/src/wip/lwpdtmftonegenerator.js +++ /dev/null @@ -1,123 +0,0 @@ -"use strict"; - -import EventEmitter from "events"; -import i18next from "i18next"; -import _ from "lodash"; - -export default class extends EventEmitter { - constructor(libwebphone, config = {}, i18n = null) { - super(); - this._libwebphone = libwebphone; - this._sockets = []; - return this._initInternationalization(config.i18n, i18n) - .then(() => { - return this._initProperties(config.userAgent); - }) - .then(() => { - return this; - }); - } - - - - - /** Init functions */ - - _initInternationalization(config = { fallbackLng: "en" }, i18n = null) { - if (i18n) { - this._translator = i18n; - return Promise.resolve(); - } - - var i18nPromise = i18next.init(config); - i18next.addResourceBundle("en", "libwebphone", { - dialpad: {} - }); - - return i18nPromise.then(translator => (this._translator = translator)); - } - - _initProperties(config) { - var defaults = {}; - - this._config = this._merge(defaults, config); - - - - return Promise.resolve(); - } - - - - - /** Util Functions */ - _merge(...args) { - return _.merge(...args); - } - - - getlwpdtmftonegenerator() { - return this._lwpdtmftonegeneratorPromise; - } -} //end class - -export function eventfordialpadbutton(val) -{ - console.log('DTMF tone for: ' + val); - if (window.__pushed__) return - - const context = window.__context__ || new AudioContext() - const sampleRate = 7000 - const buffer = context.createBuffer(2, sampleRate, sampleRate) - const data = buffer.getChannelData(0) - const data1 = buffer.getChannelData(1) - let currentTime = 0 - - //same frequency for same button - const keymaps = { - '1': [1336, 697], - '2': [1336, 697], - '3': [1336, 697], - 'A': [1336, 697], - '4': [1336, 697], - '5': [1336, 697], - '6': [1336, 697], - 'B': [1336, 697], - '7': [1336, 697], - '8': [1336, 697], - '9': [1336, 697], - 'C': [1336, 697], - '*': [1336, 697], - '0': [1336, 697], - '#': [1336, 697], - 'D': [1336, 697] - } - - if (!keymaps[val]) return - - for (let i = 0; i < 0.5 * sampleRate; i++) { - data[i] = Math.sin((2 * Math.PI) * keymaps[val][0] * (i / sampleRate)) - } - - for (let i = 0; i < 0.5 * sampleRate; i++) { - data1[i] = Math.sin((2 * Math.PI) * keymaps[val][1] * (i / sampleRate)) - } - - const gainNode = context.createGain() - gainNode.connect(context.destination) - - const src = context.createBufferSource() - src.buffer = buffer - src.connect(gainNode) - src.start(currentTime) - - window.__pushed__ = true - setTimeout(() => { - window.__pushed__ = false - }, 100) - if (!window.__context__) window.__context__ = context - return Promise.resolve(); -} //End of eventfordialpadbutton - - -