[Merge] lp:~abreu-alexandre/webbrowser-app/front-camera-as-default-capture into lp:webbrowser-app
Alexandre Abreu
alexandre.abreu at canonical.com
Tue Jun 14 12:54:42 UTC 2016
Diff comments:
> === modified file 'src/Ubuntu/Web/UbuntuWebContext.qml'
> --- src/Ubuntu/Web/UbuntuWebContext.qml 2015-12-11 10:30:42 +0000
> +++ src/Ubuntu/Web/UbuntuWebContext.qml 2016-06-10 18:02:02 +0000
> @@ -99,4 +99,80 @@
> devtoolsIp: webviewDevtoolsDebugHost
>
> hostMappingRules: webviewHostMappingRules
> +
> + /**
> + * The goal of this chunk of code is to allow one to setup
> + * a default selection for the camera based on its position.
> + * As requested by:
> + * https://launchpad.net/bugs/1563398
> + *
> + * At the moment though, there is an Oxide bug that prevents
> + * camera positions to be properly reported.
> + *
> + * https://launchpad.net/bugs/1568145
> + *
> + * In order to workaround this for now, we use a hack based on the fact
> + * that in hybris backed systems, the various video capture devices' names
> + * are reported as "Front Camera" & "Back Camera", the string being translated.
> + * We used this dirty heuristic instead of the position as a fallback for now.
> + */
> + property QtObject __internal : QtObject {
> + readonly property string cameraNamePrefixVideoCaptureDefault: (cameraPositionVideoCaptureDefault === "frontface") ? i18n.tr("Front") : ""
because you pushed an update to oxide recently that made those user visible names localized,
> + readonly property string cameraPositionUnspecified: "unspecified"
> + }
> +
> + property string cameraIdVideoCaptureDefault: webcontextDefaultCameraIdVideoCapture
> + property string cameraPositionVideoCaptureDefault: webcontextDefaultVideoCaptureCameraPosition
> + Component.onCompleted: {
> + var OxideGlobals = Oxide.Oxide
> +
> + function updateDefaultVideoCaptureDevice() {
> + var devices = OxideGlobals.availableVideoCaptureDevices
> +
> + if (! oxideContext.defaultVideoCaptureDeviceId
> + && devices
> + && devices.length > 0) {
> +
> + for (var i = 0; i < devices.length; ++i) {
> + /**
> + * cameraIdVideoCaptureDefault has precedence
> + */
> +
> + if (cameraIdVideoCaptureDefault
> + && devices[i].id === cameraIdVideoCaptureDefault) {
> + oxideContext.defaultVideoCaptureDeviceId = devices[i].id
> + break
> + }
> +
> + if (cameraPositionVideoCaptureDefault) {
> + if (devices[i].position === cameraPositionVideoCaptureDefault) {
> + oxideContext.defaultVideoCaptureDeviceId = devices[i].id
> + break
> + }
> +
> + /**
> + * This is only there to act as a fallback with a reasonnable
> + * heuristic that tracks the case described above.
> + */
> + var displayName = devices[i].displayName
> + if (__internal.cameraNamePrefixVideoCaptureDefault
> + && __internal.cameraPositionUnspecified === devices[i].position
> + && displayName.indexOf(
> + __internal.cameraNamePrefixVideoCaptureDefault) === 0) {
> + oxideContext.defaultVideoCaptureDeviceId = devices[i].id
> + break
> + }
> + }
> + }
> + }
> + }
> +
> + var devices = OxideGlobals.availableVideoCaptureDevices
> + if (devices.length !== 0) {
> + updateDefaultVideoCaptureDevice()
> + }
> + OxideGlobals.availableVideoCaptureDevicesChanged.connect(function(){
> + updateDefaultVideoCaptureDevice()
> + })
> + }
> }
--
https://code.launchpad.net/~abreu-alexandre/webbrowser-app/front-camera-as-default-capture/+merge/291527
Your team Ubuntu Phablet Team is requested to review the proposed merge of lp:~abreu-alexandre/webbrowser-app/front-camera-as-default-capture into lp:webbrowser-app.
More information about the Ubuntu-reviews
mailing list