116 lines
3.5 KiB
CoffeeScript
116 lines
3.5 KiB
CoffeeScript
$ = jQuery
|
|
context = window
|
|
context.JK ||= {};
|
|
|
|
context.JK.WebcamViewer = class WebcamViewer
|
|
constructor: (@root) ->
|
|
@client = context.jamClient
|
|
@logger = context.JK.logger
|
|
@initialScan = false
|
|
@toggleBtn = null
|
|
@webcamSelect = null
|
|
@resolutionSelect = null
|
|
@videoShared=false
|
|
@resolution=null
|
|
|
|
init: (root) =>
|
|
@root = root
|
|
@toggleBtn = @root.find(".webcam-test-btn")
|
|
@webcamSelect = @root.find(".webcam-select-container select")
|
|
@resolutionSelect = @root.find(".webcam-resolution-select-container select")
|
|
@webcamSelect.on("change", this.selectWebcam)
|
|
@toggleBtn.on 'click', @toggleWebcam
|
|
|
|
beforeShow:() =>
|
|
this.loadWebCams()
|
|
this.selectWebcam()
|
|
this.loadResolutions()
|
|
this.selectResolution()
|
|
@initialScan = true
|
|
@client.SessStopVideoSharing()
|
|
#client.SessSetInsetPosition(5)
|
|
#client.SessSetInsetSize(1)
|
|
#client.FTUESetAutoSelectVideoLayout(false)
|
|
#client.SessSelectVideoDisplayLayoutGroup(1)
|
|
|
|
|
|
selectWebcam:(e, data) =>
|
|
device = @webcamSelect.val()
|
|
if device?
|
|
caps = @client.FTUEGetVideoCaptureDeviceCapabilities(device)
|
|
@logger.debug("Got capabilities from device", caps, device)
|
|
@client.FTUESelectVideoCaptureDevice(device, caps)
|
|
|
|
selectResolution:() =>
|
|
@logger.debug 'Selecting res control: ', @resolutionSelect
|
|
@resolution = @resolutionSelect.val()
|
|
if @resolution?
|
|
@logger.debug 'Selecting res: ', @resolution
|
|
@client.FTUESetVideoEncodeResolution @resolution
|
|
# if @isVideoShared
|
|
# this.setVideoOff()
|
|
# this.toggleWebcam()
|
|
|
|
setVideoOff:() =>
|
|
if this.isVideoShared()
|
|
@client.SessStopVideoSharing()
|
|
|
|
isVideoShared:() =>
|
|
@videoShared
|
|
|
|
setToggleState:() =>
|
|
available = @webcamSelect.find('option').size() > 0
|
|
shared = this.isVideoShared()
|
|
@toggleBtn.prop 'disabled', true
|
|
@toggleBtn.prop 'disabled', !available
|
|
|
|
toggleWebcam:() =>
|
|
@logger.debug 'Toggling webcam from: ', this.isVideoShared()
|
|
if this.isVideoShared()
|
|
@toggleBtn.removeClass("selected")
|
|
@client.SessStopVideoSharing()
|
|
@videoShared = false
|
|
else
|
|
@toggleBtn.addClass("selected")
|
|
@client.SessStartVideoSharing 0
|
|
@videoShared = true
|
|
|
|
selectedDeviceName:() =>
|
|
webcamName="None Configured"
|
|
webcam = @client.FTUECurrentSelectedVideoDevice()
|
|
if (webcam? && Object.keys(webcam).length>0)
|
|
webcamName = _.values(webcam)[0]
|
|
|
|
webcamName
|
|
|
|
loadWebCams:() =>
|
|
devices = @client.FTUEGetVideoCaptureDeviceNames()
|
|
selectedDevice = this.selectedDeviceName()
|
|
selectControl = @webcamSelect
|
|
context._.each devices, (device) ->
|
|
selected = device == selectedDevice
|
|
option = $('<option/>',
|
|
id: device
|
|
value: device
|
|
text: device)
|
|
selectControl.append option
|
|
selectControl.val selectedDevice
|
|
|
|
if devices.length == 0
|
|
@root.find('.no-webcam-msg').removeClass 'hidden'
|
|
else
|
|
@root.find('.no-webcam-msg').addClass 'hidden'
|
|
|
|
loadResolutions:() =>
|
|
resolutions = @client.FTUEGetAvailableEncodeVideoResolutions()
|
|
selectControl = @resolutionSelect
|
|
@logger.debug 'FOUND THESE RESOLUTIONS', resolutions, selectControl
|
|
context._.each resolutions, (value, key, obj) ->
|
|
option = $('<option/>',
|
|
value: value
|
|
text: value)
|
|
selectControl.append option
|
|
|
|
if @resolution != null and @resolution != ''
|
|
selectControl.val(@resolution)
|