Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #11286 from yurenju/896425
Browse files Browse the repository at this point in the history
Bug 896425 - Add customization support for recording profile r=djf
  • Loading branch information
yurenju committed Aug 9, 2013
2 parents 10bb868 + 06ea875 commit c354940
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 8 deletions.
49 changes: 41 additions & 8 deletions apps/camera/js/camera.js
Expand Up @@ -170,6 +170,7 @@ var Camera = {

_videoProfile: {},

preferredRecordingSizes: null,
_shutterKey: 'camera.shutter.enabled',
_shutterSound: null,
_shutterSoundEnabled: true,
Expand Down Expand Up @@ -352,6 +353,8 @@ var Camera = {
navigator.mozSettings.addObserver(this._shutterKey, (function(e) {
this._shutterSoundEnabled = e.settingValue;
}).bind(this));

this.getPreferredSizes();
}

this._storageState = this.STORAGE_INIT;
Expand Down Expand Up @@ -875,9 +878,15 @@ var Camera = {
camera.capabilities.focusModes.indexOf('auto') !== -1;
this._pictureSize =
this.pickPictureSize(camera.capabilities.pictureSizes);
this._videoProfile =
this.pickVideoProfile(camera.capabilities.recorderProfiles);

this.getPreferredSizes((function() {
this._videoProfile =
this.pickVideoProfile(camera.capabilities.recorderProfiles);
if (this._captureMode === this.VIDEO) {
this._videoProfile.rotation = this._phoneOrientation;
this._cameraObj.getPreviewStreamVideoMode(
this._videoProfile, gotPreviewScreen.bind(this));
}
}).bind(this));
this.setPreviewSize(camera);
this.enableCameraFeatures(camera.capabilities);

Expand All @@ -890,10 +899,6 @@ var Camera = {
if (this._captureMode === this.CAMERA) {
camera.getPreviewStream(this._previewConfig,
gotPreviewScreen.bind(this));
} else {
this._videoProfile.rotation = this._phoneOrientation;
this._cameraObj.getPreviewStreamVideoMode(this._videoProfile,
gotPreviewScreen.bind(this));
}
}

Expand Down Expand Up @@ -1366,11 +1371,23 @@ var Camera = {
},

pickVideoProfile: function camera_pickVideoProfile(profiles) {
var profileName;
var profileName, matchedProfileName;

if (this.preferredRecordingSizes) {
for (var i = 0; i < this.preferredRecordingSizes.length; i++) {
if (this.preferredRecordingSizes[i] in profiles) {
matchedProfileName = this.preferredRecordingSizes[i];
break;
}
}
}

// Attempt to find low resolution profile if accessed via pick activity
if (this._pendingPick && this._pendingPick.source.data.maxFileSizeBytes &&
'qcif' in profiles) {
profileName = 'qcif';
} else if (matchedProfileName) {
profileName = matchedProfileName;
// Default to cif profile
} else if ('cif' in profiles) {
profileName = 'cif';
Expand Down Expand Up @@ -1422,6 +1439,22 @@ var Camera = {
if (callback)
callback.call(Camera);
});
},

getPreferredSizes: function camera_getPreferredSized(callback) {
var key = 'camera.recording.preferredSizes';
if (this.preferredRecordingSizes && callback) {
callback();
return;
}

var req = navigator.mozSettings.createLock().get(key);
req.onsuccess = (function onsuccess() {
this.preferredRecordingSizes = req.result[key] || [];
if (callback) {
callback();
}
}.bind(this));
}
};

Expand Down
1 change: 1 addition & 0 deletions build/settings.py
Expand Up @@ -27,6 +27,7 @@
"bluetooth.debugging.enabled": False,
"bluetooth.suspended": False,
"camera.shutter.enabled": True,
"camera.recording.preferredSizes": [],
"clear.remote-windows.data": False,
"debug.console.enabled": False,
"debug.grid.enabled": False,
Expand Down

0 comments on commit c354940

Please sign in to comment.