Merge lp:~abreu-alexandre/webbrowser-app/front-camera-as-default-capture into lp:webbrowser-app
- front-camera-as-default-capture
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Olivier Tilloy |
Approved revision: | 1484 |
Merged at revision: | 1489 |
Proposed branch: | lp:~abreu-alexandre/webbrowser-app/front-camera-as-default-capture |
Merge into: | lp:webbrowser-app |
Diff against target: |
217 lines (+119/-0) 6 files modified
src/app/BrowserView.qml (+90/-0) src/app/webbrowser/Browser.qml (+10/-0) src/app/webcontainer/WebApp.qml (+2/-0) src/app/webcontainer/webapp-container.cpp (+12/-0) src/app/webcontainer/webapp-container.h (+1/-0) src/app/webcontainer/webapp-container.qml (+4/-0) |
To merge this branch: | bzr merge lp:~abreu-alexandre/webbrowser-app/front-camera-as-default-capture |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Olivier Tilloy | functional | Approve | |
system-apps-ci-bot | continuous-integration | Needs Fixing | |
Review via email: mp+291527@code.launchpad.net |
Commit message
Set the front camera as the default for video media requests
Description of the change
Set the front camera as the default for video media requests
Olivier Tilloy (osomon) wrote : | # |
Alexandre Abreu (abreu-alexandre) wrote : | # |
> Can you please revert the changes to webbrowser-app.pot ?
yes, a missed bit,
done
system-apps-ci-bot (system-apps-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:1401
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
system-apps-ci-bot (system-apps-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:1474
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
system-apps-ci-bot (system-apps-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:1475
https:/
Executed test runs:
SUCCESS: https:/
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
system-apps-ci-bot (system-apps-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:1478
https:/
Executed test runs:
SUCCESS: https:/
UNSTABLE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Olivier Tilloy (osomon) wrote : | # |
I’m probably missing something: why can’t this hack reside solely in the apps’ code? At app startup, check whether a specific default camera has been requested (via command-line flag), if not default to front, then enumerate all video capture devices, and set the default one accordingly if any matches.
See also a couple of inline comments.
- 1479. By Alexandre Abreu
-
tweak camera names in comments
Alexandre Abreu (abreu-alexandre) wrote : | # |
> I’m probably missing something: why can’t this hack reside solely in the apps’
> code? At app startup, check whether a specific default camera has been
> requested (via command-line flag), if not default to front, then enumerate all
> video capture devices, and set the default one accordingly if any matches.
>
> See also a couple of inline comments.
It was a conscious decision not to go for that, and to make it something that works
across all apps out-of-the-box,
Alexandre Abreu (abreu-alexandre) : | # |
system-apps-ci-bot (system-apps-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:1479
https:/
Executed test runs:
SUCCESS: https:/
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
- 1480. By Alexandre Abreu
-
Move the changes back to the app code instead of webview context
system-apps-ci-bot (system-apps-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:1480
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
- 1481. By Alexandre Abreu
-
tweak default
system-apps-ci-bot (system-apps-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:1481
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
- 1482. By Alexandre Abreu
-
Make sure that the settings are properly up to date if a default front camera is set
system-apps-ci-bot (system-apps-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:1482
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Olivier Tilloy (osomon) wrote : | # |
In src/app/
Is there really a need for a currentWebviewC
In BrowserView.qml, __internal doesn’t need to be a property, it can simply be a child of the FocusScope.
Can 'cameraIdVideoC
Can 'cameraPosition
In BrowserView.qml, instead of connecting to 'changed' signals in an imperative manner, could you do it in a declarative way (using a Connections element)?
Alexandre Abreu (abreu-alexandre) wrote : | # |
> In src/app/
> the translated string from oxide.
right, done,
> Is there really a need for a currentWebviewC
> refer to SharedWebContex
> of having a null currentWebviewC
> yet? The context being a singleton, its lifetime should be independent from
> that of the webviews using it, no?
no, the container does not use the shared context, and the webview is delay loaded,
> In BrowserView.qml, __internal doesn’t need to be a property, it can simply be
> a child of the FocusScope.
right, done,
> Can 'cameraIdVideoC
> Can 'cameraPosition
> 'defaultVideoCa
yes, done
> In BrowserView.qml, instead of connecting to 'changed' signals in an
> imperative manner, could you do it in a declarative way (using a Connections
> element)?
thank you yes, it makes things cleaner,
- 1483. By Alexandre Abreu
-
Tweaks: renaming, use Connections, use domain based translations
system-apps-ci-bot (system-apps-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:1483
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Olivier Tilloy (osomon) wrote : | # |
I just realized that i18n.dtr(
Olivier Tilloy (osomon) wrote : | # |
As a consequence of the above remark, the "Prefix" part of 'cameraNamePref
For consistency with the rest of the codebase, can you please rename "__internal" to "internal" (without the leading underscores) ?
Can 'currentWebview
Is the 'defaultVideoCa
The added 'browserView' id seems to be unused. Can it be removed?
- 1484. By Alexandre Abreu
-
Update some var names; fix translation string
Alexandre Abreu (abreu-alexandre) wrote : | # |
all comments addressed,
Alexandre Abreu (abreu-alexandre) wrote : | # |
> Is the 'defaultVideoCa
> connect to currentWebviewC
no, the intent is to update the *initial* settings when none have been set so that it
properly reflects the current device id.
This should not be done for every video capture device changed since this part
is handled by the settings page itself,
system-apps-ci-bot (system-apps-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:1484
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Olivier Tilloy (osomon) wrote : | # |
Code changes look ok. I haven’t tested the actual functionality on a touch device though, this should be carefully tested from a silo.
Olivier Tilloy (osomon) wrote : | # |
Tested from silo 19 on arale (with webbrowser-app and appear.in webapp), this seems to work as intended.
Preview Diff
1 | === modified file 'src/app/BrowserView.qml' |
2 | --- src/app/BrowserView.qml 2016-02-09 17:04:23 +0000 |
3 | +++ src/app/BrowserView.qml 2016-06-16 18:22:11 +0000 |
4 | @@ -19,6 +19,7 @@ |
5 | import QtQuick 2.4 |
6 | import Ubuntu.Components 1.3 |
7 | import Ubuntu.Unity.Action 1.1 as UnityActions |
8 | +import com.canonical.Oxide 1.15 as Oxide |
9 | |
10 | FocusScope { |
11 | property bool developerExtrasEnabled: false |
12 | @@ -54,4 +55,93 @@ |
13 | id: _osk |
14 | } |
15 | } |
16 | + |
17 | + signal defaultVideoCaptureMediaIdUpdated(string defaultVideoCaptureDeviceId) |
18 | + |
19 | + /** |
20 | + * The goal of this chunk of code is to allow one to setup |
21 | + * a default selection for the camera based on its position. |
22 | + * As requested by: |
23 | + * https://launchpad.net/bugs/1563398 |
24 | + * |
25 | + * At the moment though, there is an Oxide bug that prevents |
26 | + * camera positions to be properly reported. |
27 | + * |
28 | + * https://launchpad.net/bugs/1568145 |
29 | + * |
30 | + * In order to workaround this for now, we use a hack based on the fact |
31 | + * that in hybris backed systems, the various video capture devices' names |
32 | + * are reported as "Front camera" & "Back camera", the string being translated. |
33 | + * We used this dirty heuristic instead of the position as a fallback for now. |
34 | + */ |
35 | + |
36 | + property var currentWebcontext |
37 | + property string defaultVideoCaptureDeviceId |
38 | + property string defaultVideoCaptureDevicePosition: "frontface" |
39 | + |
40 | + QtObject { |
41 | + id: internal |
42 | + |
43 | + // "Front camera" is the user facing string returned by oxide |
44 | + // https://git.launchpad.net/oxide/tree/shared/browser/media/oxide_video_capture_device_factory_linux.cc#n49 |
45 | + // It should be kept in sync. |
46 | + readonly property string defaultVideoCaptureDeviceUserName: |
47 | + (defaultVideoCaptureDevicePosition === "frontface") ? |
48 | + i18n.dtr("oxide-qt", "Front camera") : "" |
49 | + |
50 | + readonly property string cameraPositionUnspecified: "unspecified" |
51 | + |
52 | + function setupDefaultVideoCaptureDevice() { |
53 | + if ( ! currentWebcontext) { |
54 | + return |
55 | + } |
56 | + |
57 | + var devices = Oxide.Oxide.availableVideoCaptureDevices |
58 | + |
59 | + if (! currentWebcontext.defaultVideoCaptureDeviceId |
60 | + && devices |
61 | + && devices.length > 0) { |
62 | + |
63 | + for (var i = 0; i < devices.length; ++i) { |
64 | + /** |
65 | + * defaultVideoCaptureDeviceId has precedence |
66 | + */ |
67 | + |
68 | + if (defaultVideoCaptureDeviceId |
69 | + && devices[i].id === defaultVideoCaptureDeviceId) { |
70 | + currentWebcontext.defaultVideoCaptureDeviceId = devices[i].id |
71 | + defaultVideoCaptureMediaIdUpdated(devices[i].id) |
72 | + break |
73 | + } |
74 | + |
75 | + if (defaultVideoCaptureDevicePosition) { |
76 | + if (devices[i].position === defaultVideoCaptureDevicePosition) { |
77 | + currentWebcontext.defaultVideoCaptureDeviceId = devices[i].id |
78 | + defaultVideoCaptureMediaIdUpdated(devices[i].id) |
79 | + break |
80 | + } |
81 | + |
82 | + /** |
83 | + * This is only there to act as a fallback with a reasonnable |
84 | + * heuristic that tracks the case described above. |
85 | + */ |
86 | + var displayName = devices[i].displayName |
87 | + if (internal.defaultVideoCaptureDeviceUserName |
88 | + && internal.cameraPositionUnspecified === devices[i].position |
89 | + && displayName.indexOf( |
90 | + internal.defaultVideoCaptureDeviceUserName) === 0) { |
91 | + currentWebcontext.defaultVideoCaptureDeviceId = devices[i].id |
92 | + defaultVideoCaptureMediaIdUpdated(devices[i].id) |
93 | + break |
94 | + } |
95 | + } |
96 | + } |
97 | + } |
98 | + } |
99 | + } |
100 | + |
101 | + Connections { |
102 | + target: Oxide.Oxide |
103 | + onAvailableVideoCaptureDevicesChanged: internal.setupDefaultVideoCaptureDevice() |
104 | + } |
105 | } |
106 | |
107 | === modified file 'src/app/webbrowser/Browser.qml' |
108 | --- src/app/webbrowser/Browser.qml 2016-05-23 15:49:49 +0000 |
109 | +++ src/app/webbrowser/Browser.qml 2016-06-16 18:22:11 +0000 |
110 | @@ -19,6 +19,7 @@ |
111 | import QtQuick 2.4 |
112 | import QtQuick.Window 2.2 |
113 | import Qt.labs.settings 1.0 |
114 | +import Ubuntu.Web 0.2 |
115 | import com.canonical.Oxide 1.15 as Oxide |
116 | import Ubuntu.Components 1.3 |
117 | import Ubuntu.Components.Popups 1.3 |
118 | @@ -81,6 +82,15 @@ |
119 | onMediaAccessPermissionRequested: PopupUtils.open(mediaAccessDialogComponent, null, { request: request }) |
120 | } |
121 | |
122 | + currentWebcontext: SharedWebContext.sharedContext |
123 | + defaultVideoCaptureDeviceId: settings.defaultVideoDevice ? settings.defaultVideoDevice : "" |
124 | + |
125 | + onDefaultVideoCaptureMediaIdUpdated: { |
126 | + if (!settings.defaultVideoDevice) { |
127 | + settings.defaultVideoDevice = defaultVideoCaptureDeviceId |
128 | + } |
129 | + } |
130 | + |
131 | InputDeviceModel { |
132 | id: miceModel |
133 | deviceFilter: InputInfo.Mouse |
134 | |
135 | === modified file 'src/app/webcontainer/WebApp.qml' |
136 | --- src/app/webcontainer/WebApp.qml 2016-04-29 20:19:23 +0000 |
137 | +++ src/app/webcontainer/WebApp.qml 2016-06-16 18:22:11 +0000 |
138 | @@ -62,6 +62,8 @@ |
139 | // not possible https://bugs.launchpad.net/autopilot-qt/+bug/1273956 |
140 | property alias generatedUrlPatterns: urlPatternSettings.generatedUrlPatterns |
141 | |
142 | + currentWebcontext: currentWebview ? currentWebview.context : null |
143 | + |
144 | actions: [ |
145 | Actions.Back { |
146 | enabled: webapp.backForwardButtonsVisible && containerWebView.currentWebview && containerWebView.currentWebview.canGoBack |
147 | |
148 | === modified file 'src/app/webcontainer/webapp-container.cpp' |
149 | --- src/app/webcontainer/webapp-container.cpp 2016-05-09 22:51:50 +0000 |
150 | +++ src/app/webcontainer/webapp-container.cpp 2016-06-16 18:22:11 +0000 |
151 | @@ -154,6 +154,7 @@ |
152 | m_window->setProperty("accountProvider", m_accountProvider); |
153 | m_window->setProperty("accountSwitcher", m_accountSwitcher); |
154 | m_window->setProperty("openExternalUrlInOverlay", m_openExternalUrlInOverlay); |
155 | + m_window->setProperty("defaultVideoCaptureCameraPosition", m_defaultVideoCaptureCameraPosition); |
156 | |
157 | m_window->setProperty("webappUrlPatterns", m_webappUrlPatterns); |
158 | QQmlContext* context = m_engine->rootContext(); |
159 | @@ -324,6 +325,15 @@ |
160 | out << " --enable-media-hub-audio enable media-hub for audio playback" << endl; |
161 | out << " --user-agent-string=USER_AGENT overrides the default User Agent with the provided one." << endl; |
162 | out << " --open-external-url-in-overlay if url patterns are defined, all external urls are opened in overlay instead of browser" << endl; |
163 | + |
164 | + // The options should be kept in sync with: |
165 | + // http://bazaar.launchpad.net/~oxide-developers/oxide/oxide.trunk/view/head:/qt/quick/api/oxideqquickglobal.cc#L43 |
166 | + out << " --camera-capture-default=position set a default for the camera capture device in W3C Media API, 'position' should be" |
167 | + " 'frontface', 'backface' or 'none'. If 'none' is selected the default" |
168 | + " selection mechanism applied in Oxide is used. If this command line option" |
169 | + " is not used, the default is set to 'frontface'. If the position is not found" |
170 | + " the behavior is the same as if the option was not set."<< endl; |
171 | + |
172 | out << "Chrome options (if none specified, no chrome is shown by default):" << endl; |
173 | out << " --enable-back-forward enable the display of the back and forward buttons (implies --enable-addressbar)" << endl; |
174 | out << " --enable-addressbar enable the display of a minimal chrome (favicon and title)" << endl; |
175 | @@ -381,6 +391,8 @@ |
176 | m_userAgentOverride = argument.split("--user-agent-string=")[1]; |
177 | } else if (argument == "--open-external-url-in-overlay") { |
178 | m_openExternalUrlInOverlay = true; |
179 | + } else if (argument.startsWith("--camera-capture-default=")) { |
180 | + m_defaultVideoCaptureCameraPosition = argument.split("--camera-capture-default=")[1]; |
181 | } |
182 | } |
183 | } |
184 | |
185 | === modified file 'src/app/webcontainer/webapp-container.h' |
186 | --- src/app/webcontainer/webapp-container.h 2016-05-05 15:20:35 +0000 |
187 | +++ src/app/webcontainer/webapp-container.h 2016-06-16 18:22:11 +0000 |
188 | @@ -73,6 +73,7 @@ |
189 | QString m_userAgentOverride; |
190 | QScopedPointer<WebappContainerHelper> m_webappContainerHelper; |
191 | QScopedPointer<SchemeFilter> m_schemeFilter; |
192 | + QString m_defaultVideoCaptureCameraPosition; |
193 | |
194 | static const QString URL_PATTERN_SEPARATOR; |
195 | static const QString LOCAL_SCHEME_FILTER_FILENAME; |
196 | |
197 | === modified file 'src/app/webcontainer/webapp-container.qml' |
198 | --- src/app/webcontainer/webapp-container.qml 2016-04-22 13:52:07 +0000 |
199 | +++ src/app/webcontainer/webapp-container.qml 2016-06-16 18:22:11 +0000 |
200 | @@ -46,6 +46,7 @@ |
201 | property string localUserAgentOverride: "" |
202 | property bool blockOpenExternalUrls: false |
203 | property bool openExternalUrlInOverlay: false |
204 | + property string defaultVideoCaptureCameraPosition: "" |
205 | property bool popupBlockerEnabled: true |
206 | |
207 | currentWebview: webappViewLoader.item ? webappViewLoader.item.currentWebview : null |
208 | @@ -90,6 +91,9 @@ |
209 | webappUrlPatterns: root.webappUrlPatterns |
210 | blockOpenExternalUrls: root.blockOpenExternalUrls |
211 | openExternalUrlInOverlay: root.openExternalUrlInOverlay |
212 | + defaultVideoCaptureDevicePosition: root.defaultVideoCaptureCameraPosition ? |
213 | + root.defaultVideoCaptureCameraPosition |
214 | + : browser.defaultVideoCaptureDevicePosition |
215 | popupBlockerEnabled: root.popupBlockerEnabled |
216 | |
217 | popupRedirectionUrlPrefixPattern: root.popupRedirectionUrlPrefixPattern |
Can you please revert the changes to webbrowser-app.pot ?