From 949ce8a513fc8ee6015d1795da04662bd36eca7b Mon Sep 17 00:00:00 2001 From: Seth Call Date: Fri, 4 Dec 2015 11:16:40 -0600 Subject: [PATCH] * VRFS-3756 - webcam audio --- .../actions/VideoActions.js.coffee | 3 +- .../stores/VideoStore.js.coffee | 53 +++------------- .../stores/WebcamViewer.js.jsx.coffee | 61 ++++++------------- .../javascripts/webcam_viewer.js.coffee | 55 +++++------------ web/lib/tasks/jam_tracks.rake | 2 +- 5 files changed, 46 insertions(+), 128 deletions(-) diff --git a/web/app/assets/javascripts/react-components/actions/VideoActions.js.coffee b/web/app/assets/javascripts/react-components/actions/VideoActions.js.coffee index 90bc00bbd..662610fa9 100644 --- a/web/app/assets/javascripts/react-components/actions/VideoActions.js.coffee +++ b/web/app/assets/javascripts/react-components/actions/VideoActions.js.coffee @@ -4,8 +4,7 @@ context = window refresh: {} stopVideo: {} startVideo: {} - setVideoEncodeResolution: {} - setSendFrameRate: {} + setCaptureResolution: {} selectDevice: {} videoWindowOpened : {} videoWindowClosed : {} diff --git a/web/app/assets/javascripts/react-components/stores/VideoStore.js.coffee b/web/app/assets/javascripts/react-components/stores/VideoStore.js.coffee index f067f19ff..fa1f7282c 100644 --- a/web/app/assets/javascripts/react-components/stores/VideoStore.js.coffee +++ b/web/app/assets/javascripts/react-components/stores/VideoStore.js.coffee @@ -6,15 +6,6 @@ NAMED_MESSAGES = context.JK.NAMED_MESSAGES 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, @@ -53,39 +44,17 @@ BackendToFrontendFPS = { currentDevice = context.jamClient.FTUECurrentSelectedVideoDevice() deviceNames = context.jamClient.FTUEGetVideoCaptureDeviceNames() #deviceCaps = context.jamClient.FTUEGetVideoCaptureDeviceCapabilities() - currentResolution = context.jamClient.GetCurrentVideoResolution() - currentFrameRate = context.jamClient.GetCurrentVideoFrameRate() - encodeResolutions = context.jamClient.FTUEGetAvailableEncodeVideoResolutions() - frameRates = context.jamClient.FTUEGetSendFrameRates() + captureResolutions = context.jamClient.FTUEGetCaptureResolution() + currentCaptureResolution = context.jamClient.FTUEGetCurrentCaptureResolution() - 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) + logger.debug("captureResolutions, currentCaptureResolution", captureResolutions, currentCaptureResolution) else @everDisabled = true # don't talk to the backend when video is disabled; avoiding crashes currentDevice = null deviceNames = {} - currentResolution: 0 - currentFrameRate: 0 - encodeResolutions: {} + captureResolutions: {} + currentCaptureResolution: null frameRates: {} @@ -94,10 +63,8 @@ BackendToFrontendFPS = { @state = { currentDevice: currentDevice, deviceNames: deviceNames, - currentResolution: currentResolution, - currentFrameRate: currentFrameRate, - encodeResolutions: encodeResolutions, - frameRates: frameRates, + captureResolutions: captureResolutions, + currentCaptureResolution: currentCaptureResolution, videoShared: @videoShared videoOpen: @videoOpen, videoEnabled: videoEnabled, @@ -158,10 +125,10 @@ BackendToFrontendFPS = { else @onStartVideo() - onSetVideoEncodeResolution: (resolution) -> + onSetCaptureResolution: (resolution) -> @logger.debug("set capture resolution: #{resolution}") - context.jamClient.FTUESetVideoEncodeResolution(resolution) - @state.currentResolution = resolution + context.jamClient.FTUESetCaptureResolution(resolution) + @state.currentCaptureResolution = resolution this.trigger(@state) onSetSendFrameRate: (frameRates) -> diff --git a/web/app/assets/javascripts/react-components/stores/WebcamViewer.js.jsx.coffee b/web/app/assets/javascripts/react-components/stores/WebcamViewer.js.jsx.coffee index b4588cfc4..077b60508 100644 --- a/web/app/assets/javascripts/react-components/stores/WebcamViewer.js.jsx.coffee +++ b/web/app/assets/javascripts/react-components/stores/WebcamViewer.js.jsx.coffee @@ -21,15 +21,6 @@ PlatformStore = reactContext.PlatformStore ALERT_NAMES = context.JK.ALERT_NAMES; -BackendToFrontend = { - 1 : "CIF (352x288)", - 2 : "VGA (640x480)", - 3 : "4CIF (704x576)", - 4 : "1/2 720p HD (640x360)", - 5 : "720p HD (1280x720)", - 6 : "1080p HD (1920x1080)" -} - BackendNumericToBackendString = { 1 : "CIF (352X288)", 2 : "VGA (640X480)", @@ -47,9 +38,6 @@ BackendToFrontendFPS = { 4: 15, 5: 10 } -FrontendToBackend = {} -for key, value of BackendToFrontend - FrontendToBackend[value] = key mixins = [] mixins.push(Reflux.listenTo(VideoStore, 'onVideoStateChanged')) @@ -65,9 +53,8 @@ mixins.push(Reflux.listenTo(VideoStore, 'onVideoStateChanged')) currentDevice: null deviceNames: {} deviceCaps: null - currentResolution: 0 - currentFrameRate: 0 - encodeResolutions: {} + currentCaptureResolution: 0 + captureResolutions: {} frameRates: {} rescanning: false } @@ -101,27 +88,17 @@ mixins.push(Reflux.listenTo(VideoStore, 'onVideoStateChanged')) captureResolutions = [] # load current settings from backend - currentResolution = @state.currentResolution - currentFrameRate = @state.currentFrameRate + captureResolution = @state.currentCaptureResolution - # protect against non-video clients pointed at video-enabled server from getting into a session - resolutions = @state.encodeResolutions - frames = @state.frameRates + resolutions = @state.captureResolutions 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)"} - context._.each frames, (frame, key, obj) => + value = resolutionKey + text = resolution - frontendResolution = BackendToFrontend[resolutionKey] + selected = captureResolution.toString() == value.toString() - @logger.error("unknown resolution! #{resolution}", BackendToFrontend) unless frontendResolution - - value = "#{resolutionKey}|#{frame}" - text = "#{frontendResolution} at #{frame} fps" - - selected = currentResolution + '|' + currentFrameRate == value - - captureResolutions.push `` + captureResolutions.push `` testBtnClassNames = {'button-orange' : true, 'webcam-test-btn' : true} @@ -193,7 +170,7 @@ mixins.push(Reflux.listenTo(VideoStore, 'onVideoStateChanged')) {webcams} -

select video capture resolution & frame rate:

+

select video capture resolution: