* VRFS-3509 - case where no device is configured handled
This commit is contained in:
parent
9420cebad4
commit
d07ac009bf
|
|
@ -6,6 +6,24 @@ NAMED_MESSAGES = context.JK.NAMED_MESSAGES
|
||||||
|
|
||||||
VideoActions = @VideoActions
|
VideoActions = @VideoActions
|
||||||
|
|
||||||
|
BackendToFrontend = {
|
||||||
|
1 : "CIF (352x288)",
|
||||||
|
2 : "VGA (640x480)",
|
||||||
|
3 : "4CIF (704x576)",
|
||||||
|
4 : "1/2 720p HD (640x360)",
|
||||||
|
5 : "720p HD (1280x720)",
|
||||||
|
6 : "1080p HD (1920x1080)"
|
||||||
|
}
|
||||||
|
|
||||||
|
BackendToFrontendFPS = {
|
||||||
|
|
||||||
|
0: 30,
|
||||||
|
1: 24,
|
||||||
|
2: 20,
|
||||||
|
3: 15,
|
||||||
|
4: 10
|
||||||
|
}
|
||||||
|
|
||||||
@VideoStore = Reflux.createStore(
|
@VideoStore = Reflux.createStore(
|
||||||
{
|
{
|
||||||
listenables: VideoActions
|
listenables: VideoActions
|
||||||
|
|
@ -22,6 +40,9 @@ VideoActions = @VideoActions
|
||||||
# someone has requested us to refresh our config
|
# someone has requested us to refresh our config
|
||||||
onRefresh: ->
|
onRefresh: ->
|
||||||
|
|
||||||
|
# don't do any check if this is a client with no video enabled
|
||||||
|
return unless context.jamClient.FTUECurrentSelectedVideoDevice?
|
||||||
|
|
||||||
currentDevice = context.jamClient.FTUECurrentSelectedVideoDevice()
|
currentDevice = context.jamClient.FTUECurrentSelectedVideoDevice()
|
||||||
deviceNames = context.jamClient.FTUEGetVideoCaptureDeviceNames()
|
deviceNames = context.jamClient.FTUEGetVideoCaptureDeviceNames()
|
||||||
#deviceCaps = context.jamClient.FTUEGetVideoCaptureDeviceCapabilities()
|
#deviceCaps = context.jamClient.FTUEGetVideoCaptureDeviceCapabilities()
|
||||||
|
|
@ -30,7 +51,29 @@ VideoActions = @VideoActions
|
||||||
encodeResolutions = context.jamClient.FTUEGetAvailableEncodeVideoResolutions()
|
encodeResolutions = context.jamClient.FTUEGetAvailableEncodeVideoResolutions()
|
||||||
frameRates = context.jamClient.FTUEGetSendFrameRates()
|
frameRates = context.jamClient.FTUEGetSendFrameRates()
|
||||||
|
|
||||||
#deviceCaps: deviceCaps,
|
|
||||||
|
autoSelect = false
|
||||||
|
if currentResolution == 0
|
||||||
|
@logger.warn("current resolution not specified; defaulting to VGA")
|
||||||
|
autoSelect = true
|
||||||
|
currentResolution = 2
|
||||||
|
|
||||||
|
if currentFrameRate == 0
|
||||||
|
autoSelect = true
|
||||||
|
@logger.warn("current frame rate not specified; defaulting to 30")
|
||||||
|
currentFrameRate = 30
|
||||||
|
else
|
||||||
|
# backend accepts 10,20,30 etc for FPS, but returns an indexed value (1, 2, 3).
|
||||||
|
convertedFrameRate = BackendToFrontendFPS[currentFrameRate]
|
||||||
|
@logger.debug("translating FPS: backend numeric #{currentFrameRate} to #{convertedFrameRate}")
|
||||||
|
currentFrameRate = convertedFrameRate
|
||||||
|
|
||||||
|
# backend needs to be same as frontend
|
||||||
|
if autoSelect
|
||||||
|
context.jamClient.FTUESetVideoEncodeResolution(currentResolution)
|
||||||
|
context.jamClient.FTUESetSendFrameRates(currentFrameRate)
|
||||||
|
|
||||||
|
#deviceCaps: deviceCaps,
|
||||||
|
|
||||||
@state = {
|
@state = {
|
||||||
currentDevice: currentDevice,
|
currentDevice: currentDevice,
|
||||||
|
|
@ -75,10 +118,16 @@ VideoActions = @VideoActions
|
||||||
@onStartVideo()
|
@onStartVideo()
|
||||||
|
|
||||||
onSetVideoEncodeResolution: (resolution) ->
|
onSetVideoEncodeResolution: (resolution) ->
|
||||||
|
@logger.debug("set capture resolution: #{resolution}")
|
||||||
context.jamClient.FTUESetVideoEncodeResolution(resolution)
|
context.jamClient.FTUESetVideoEncodeResolution(resolution)
|
||||||
|
@state.currentResolution = resolution
|
||||||
|
this.trigger(@state)
|
||||||
|
|
||||||
onSetSendFrameRate: (frameRates) ->
|
onSetSendFrameRate: (frameRates) ->
|
||||||
|
@logger.debug("set capture frame rate: #{frameRates}")
|
||||||
context.jamClient.FTUESetSendFrameRates(frameRates)
|
context.jamClient.FTUESetSendFrameRates(frameRates)
|
||||||
|
@state.currentFrameRate = frameRates
|
||||||
|
this.trigger(@state)
|
||||||
|
|
||||||
onSelectDevice: (device, caps) ->
|
onSelectDevice: (device, caps) ->
|
||||||
result = context.jamClient.FTUESelectVideoCaptureDevice(device, caps)
|
result = context.jamClient.FTUESelectVideoCaptureDevice(device, caps)
|
||||||
|
|
@ -135,12 +184,16 @@ VideoActions = @VideoActions
|
||||||
|
|
||||||
# if the user passes all the safeguards, let's see if we should get them to configure video
|
# if the user passes all the safeguards, let's see if we should get them to configure video
|
||||||
onCheckPromptConfigureVideo: () ->
|
onCheckPromptConfigureVideo: () ->
|
||||||
|
# don't do any check if this is a client with no video enabled
|
||||||
|
return unless context.jamClient.FTUECurrentSelectedVideoDevice?
|
||||||
|
|
||||||
@onRefresh() unless @state?
|
@onRefresh() unless @state?
|
||||||
|
|
||||||
@logger.debug("checkPromptConfigureVideo", @state.currentDevice, @state.deviceNames)
|
@logger.debug("checkPromptConfigureVideo", @state.currentDevice, @state.deviceNames)
|
||||||
|
|
||||||
# if no device configured and this is the native client and if you have at least 1 video
|
# if no device configured and this is the native client and if you have at least 1 video
|
||||||
if (!@state.currentDevice? || Object.keys(@state.currentDevice).length == 0) && gon?.isNativeClient && Object.keys(@state.deviceNames).length > 0
|
# currentDevice, from the backend, is '{'':''}' in the case of no device configured. But we also check for an empty object, or null object.
|
||||||
|
if (!@state.currentDevice? || Object.keys(@state.currentDevice).length == 0 || (Object.keys(@state.currentDevice).length == 1 && @state.currentDevice[''] == '')) && gon?.isNativeClient && Object.keys(@state.deviceNames).length > 0
|
||||||
# and if they haven't said stop bothering me about this
|
# and if they haven't said stop bothering me about this
|
||||||
context.JK.ModUtils.shouldShow(NAMED_MESSAGES.CONFIGURE_VIDEO_NOSHOW).done((shouldShow) =>
|
context.JK.ModUtils.shouldShow(NAMED_MESSAGES.CONFIGURE_VIDEO_NOSHOW).done((shouldShow) =>
|
||||||
@logger.debug("checking if user has 'should show' on video config: #{shouldShow}")
|
@logger.debug("checking if user has 'should show' on video config: #{shouldShow}")
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,6 @@ BackendNumericToBackendString = {
|
||||||
|
|
||||||
|
|
||||||
BackendToFrontendFPS = {
|
BackendToFrontendFPS = {
|
||||||
|
|
||||||
1: 30,
|
1: 30,
|
||||||
2: 24,
|
2: 24,
|
||||||
3: 20,
|
3: 20,
|
||||||
|
|
@ -53,6 +52,7 @@ mixins.push(Reflux.listenTo(VideoStore, 'onVideoStateChanged'))
|
||||||
|
|
||||||
mixins: mixins
|
mixins: mixins
|
||||||
logger: context.JK.logger
|
logger: context.JK.logger
|
||||||
|
visible: false
|
||||||
|
|
||||||
getInitialState: () ->
|
getInitialState: () ->
|
||||||
{
|
{
|
||||||
|
|
@ -93,8 +93,7 @@ mixins.push(Reflux.listenTo(VideoStore, 'onVideoStateChanged'))
|
||||||
# protect against non-video clients pointed at video-enabled server from getting into a session
|
# protect against non-video clients pointed at video-enabled server from getting into a session
|
||||||
resolutions = @state.encodeResolutions
|
resolutions = @state.encodeResolutions
|
||||||
frames = @state.frameRates
|
frames = @state.frameRates
|
||||||
@logger.debug 'FOUND THESE RESOLUTIONS', resolutions
|
@logger.debug("Webcam state on render", @state)
|
||||||
@logger.debug 'FOUND THESE FPS', frames
|
|
||||||
context._.each resolutions, (resolution, resolutionKey, obj) =>
|
context._.each resolutions, (resolution, resolutionKey, obj) =>
|
||||||
|
|
||||||
#{1: "CIF (352X288)", 2: "VGA (640X480)", 3: "4CIF (704X576)", 4: "1/2WHD (640X360)", 5: "WHD (1280X720)", 6: "FHD (1920x1080)"}
|
#{1: "CIF (352X288)", 2: "VGA (640X480)", 3: "4CIF (704X576)", 4: "1/2WHD (640X360)", 5: "WHD (1280X720)", 6: "FHD (1920x1080)"}
|
||||||
|
|
@ -111,24 +110,6 @@ mixins.push(Reflux.listenTo(VideoStore, 'onVideoStateChanged'))
|
||||||
|
|
||||||
captureResolutions.push `<option key={value} value={value} selected={selected}>{text}</option>`
|
captureResolutions.push `<option key={value} value={value} selected={selected}>{text}</option>`
|
||||||
|
|
||||||
autoSelect = false
|
|
||||||
if currentResolution == 0
|
|
||||||
@logger.warn("current resolution not specified; defaulting to VGA")
|
|
||||||
autoSelect = true
|
|
||||||
currentResolution = 2
|
|
||||||
if currentFrameRate == 0
|
|
||||||
autoSelect = true
|
|
||||||
@logger.warn("current frame rate not specified; defaulting to 30")
|
|
||||||
currentFrameRate = 30
|
|
||||||
else
|
|
||||||
convertedFrameRate = BackendToFrontendFPS[currentFrameRate]
|
|
||||||
@logger.debug("translating FPS: backend numeric #{currentFrameRate} to #{convertedFrameRate}")
|
|
||||||
currentFrameRate = convertedFrameRate
|
|
||||||
|
|
||||||
# backend needs to be same as frontend
|
|
||||||
if autoSelect
|
|
||||||
@updateBackend(currentResolution, currentFrameRate)
|
|
||||||
|
|
||||||
if @state.videoShared
|
if @state.videoShared
|
||||||
toggleText = 'STOP WEBCAM'
|
toggleText = 'STOP WEBCAM'
|
||||||
else
|
else
|
||||||
|
|
@ -179,7 +160,7 @@ mixins.push(Reflux.listenTo(VideoStore, 'onVideoStateChanged'))
|
||||||
|
|
||||||
if !@initialScan?
|
if !@initialScan?
|
||||||
@initialScan = true
|
@initialScan = true
|
||||||
else
|
else if @visible
|
||||||
@findChangedWebcams(nextState.deviceNames, @state.deviceNames)
|
@findChangedWebcams(nextState.deviceNames, @state.deviceNames)
|
||||||
|
|
||||||
componentWillReceiveProps:(nextProps) ->
|
componentWillReceiveProps:(nextProps) ->
|
||||||
|
|
@ -190,6 +171,7 @@ mixins.push(Reflux.listenTo(VideoStore, 'onVideoStateChanged'))
|
||||||
|
|
||||||
beforeShow:() ->
|
beforeShow:() ->
|
||||||
|
|
||||||
|
@visible = true
|
||||||
VideoActions.refresh()
|
VideoActions.refresh()
|
||||||
VideoActions.stopVideo()
|
VideoActions.stopVideo()
|
||||||
|
|
||||||
|
|
@ -198,14 +180,15 @@ mixins.push(Reflux.listenTo(VideoStore, 'onVideoStateChanged'))
|
||||||
|
|
||||||
beforeHide: () ->
|
beforeHide: () ->
|
||||||
|
|
||||||
context.JK.offBackendEvent(ALERT_NAMES.USB_CONNECTED, 'webcam-viewer', @onUsbDeviceConnected);
|
@visible = false
|
||||||
context.JK.offBackendEvent(ALERT_NAMES.USB_DISCONNECTED, 'webcam-viewer', @onUsbDeviceDisconnected);
|
context.JK.offBackendEvent(ALERT_NAMES.USB_CONNECTED, 'webcam-viewer', @onUsbDeviceConnected);
|
||||||
|
context.JK.offBackendEvent(ALERT_NAMES.USB_DISCONNECTED, 'webcam-viewer', @onUsbDeviceDisconnected);
|
||||||
|
|
||||||
if @rescanTimeout?
|
if @rescanTimeout?
|
||||||
clearTimeout(@rescanTimeout)
|
clearTimeout(@rescanTimeout)
|
||||||
@rescanTimeout = null
|
@rescanTimeout = null
|
||||||
|
|
||||||
@setVideoOff()
|
@setVideoOff()
|
||||||
|
|
||||||
|
|
||||||
onUsbDeviceConnected: () ->
|
onUsbDeviceConnected: () ->
|
||||||
|
|
@ -256,6 +239,7 @@ mixins.push(Reflux.listenTo(VideoStore, 'onVideoStateChanged'))
|
||||||
@logger.debug 'new capture resolution selected: ' + resolution
|
@logger.debug 'new capture resolution selected: ' + resolution
|
||||||
|
|
||||||
if resolution?
|
if resolution?
|
||||||
|
|
||||||
bits = resolution.split('|')
|
bits = resolution.split('|')
|
||||||
selectedResolution = bits[0]
|
selectedResolution = bits[0]
|
||||||
selectedFps = bits[1]
|
selectedFps = bits[1]
|
||||||
|
|
@ -270,6 +254,13 @@ mixins.push(Reflux.listenTo(VideoStore, 'onVideoStateChanged'))
|
||||||
toggleWebcam:(e) ->
|
toggleWebcam:(e) ->
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
$toggleBtn = $(e.target)
|
$toggleBtn = $(e.target)
|
||||||
|
|
||||||
|
# we should only do this if no device is currently selected
|
||||||
|
$root = $(@getDOMNode())
|
||||||
|
$select = $root.find('.webcam-select-container select')
|
||||||
|
device = $select.val()
|
||||||
|
VideoActions.selectDevice(device, {})
|
||||||
|
|
||||||
VideoActions.toggleVideo()
|
VideoActions.toggleVideo()
|
||||||
|
|
||||||
#if this.isVideoShared()
|
#if this.isVideoShared()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue