summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNorman Kerr 柯念北2017-02-02 07:15:13 (GMT)
committerNorman Kerr 柯念北2017-02-02 07:15:13 (GMT)
commit4510553da1360f8b347f15760018ebf406a6d513 (patch)
treebf81f73cafcf7835e8b9baf5aadd9578fab6d5df
parent16160caa6af55b61b6b9b0dcf07cacf2cc69b58f (diff)
Updates video constraint settings to more accurately reflect current getUserMedia.
-rw-r--r--includes/media_recorder.admin.inc52
-rw-r--r--js/media-recorder-api-kaltura.js47
-rw-r--r--js/media-recorder-api.js47
-rw-r--r--js/media-recorder-flash-kaltura.js54
-rw-r--r--media_recorder.install21
-rw-r--r--media_recorder.module79
6 files changed, 166 insertions, 134 deletions
diff --git a/includes/media_recorder.admin.inc b/includes/media_recorder.admin.inc
index a442026..527c3de 100644
--- a/includes/media_recorder.admin.inc
+++ b/includes/media_recorder.admin.inc
@@ -41,16 +41,48 @@ function media_recorder_admin_form($form, $form_state) {
'#title' => t('Video'),
'#default_value' => $settings['constraints']['video'],
);
- $form['media_recorder']['constraints']['video_resolution'] = array(
- '#type' => 'radios',
- '#title' => t('Video Resolution'),
- '#default_value' => $settings['constraints']['video_resolution'],
- '#options' => array(
- 640 => t('640 x 480'),
- 480 => t('480 x 360'),
- 320 => t('320 x 240'),
- 240 => t('240 x 180'),
- 180 => t('180 x 135'),
+ $form['media_recorder']['constraints']['video_width'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Width'),
+ 'min' => array(
+ '#type' => 'textfield',
+ '#title' => t('Minimum Width'),
+ '#default_value' => $settings['constraints']['video_width']['min'],
+ '#element_validate' => array('element_validate_integer_positive'),
+ ),
+ 'ideal' => array(
+ '#type' => 'textfield',
+ '#title' => t('Ideal Width'),
+ '#default_value' => $settings['constraints']['video_width']['ideal'],
+ '#element_validate' => array('element_validate_integer_positive'),
+ ),
+ 'max' => array(
+ '#type' => 'textfield',
+ '#title' => t('Maximum Width'),
+ '#default_value' => $settings['constraints']['video_width']['max'],
+ '#element_validate' => array('element_validate_integer_positive'),
+ ),
+ );
+ $form['media_recorder']['constraints']['video_height'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Height'),
+ 'min' => array(
+ '#type' => 'textfield',
+ '#title' => t('Minimum Height'),
+ '#default_value' => $settings['constraints']['video_height']['min'],
+ '#element_validate' => array('element_validate_integer_positive'),
+ ),
+ 'ideal' => array(
+ '#type' => 'textfield',
+ '#title' => t('Ideal Height'),
+ '#default_value' => $settings['constraints']['video_height']['ideal'],
+ '#element_validate' => array('element_validate_integer_positive'),
+ ),
+ 'max' => array(
+ '#type' => 'textfield',
+ '#title' => t('Maximum Height'),
+ '#default_value' => $settings['constraints']['video_height']['max'],
+ '#element_validate' => array('element_validate_integer_positive'),
),
);
diff --git a/js/media-recorder-api-kaltura.js b/js/media-recorder-api-kaltura.js
index 070f879..c3e8dc2 100644
--- a/js/media-recorder-api-kaltura.js
+++ b/js/media-recorder-api-kaltura.js
@@ -67,42 +67,17 @@
constraints.audio = true;
constraints.video = {};
if (settings.constraints.video) {
- switch (settings.constraints.video_resolution) {
- case '640':
- constraints.video = {
- width: 640,
- height: 480
- };
- break;
- case '480':
- constraints.video = {
- width: 480,
- height: 360
- };
- break;
- case '320':
- constraints.video = {
- width: 320,
- height: 240
- };
- break;
- case '240':
- constraints.video = {
- width: 240,
- height: 180
- };
- break;
- case '180':
- constraints.video = {
- width: 180,
- height: 135
- };
- break;
- }
- constraints.video.frameRate = {
- min: 30,
- ideal: 30,
- max: 30
+ constraints.video = {
+ width: {
+ min: settings.constraints.video_width.min,
+ ideal: settings.constraints.video_width.ideal,
+ max: settings.constraints.video_width.max
+ },
+ height: {
+ min: settings.constraints.video_height.min,
+ ideal: settings.constraints.video_height.ideal,
+ max: settings.constraints.video_height.max
+ }
};
}
diff --git a/js/media-recorder-api.js b/js/media-recorder-api.js
index a9aa7f0..88af3b1 100644
--- a/js/media-recorder-api.js
+++ b/js/media-recorder-api.js
@@ -66,42 +66,17 @@
constraints.audio = true;
constraints.video = {};
if (settings.constraints.video) {
- switch (settings.constraints.video_resolution) {
- case '640':
- constraints.video = {
- width: 640,
- height: 480
- };
- break;
- case '480':
- constraints.video = {
- width: 480,
- height: 360
- };
- break;
- case '320':
- constraints.video = {
- width: 320,
- height: 240
- };
- break;
- case '240':
- constraints.video = {
- width: 240,
- height: 180
- };
- break;
- case '180':
- constraints.video = {
- width: 180,
- height: 135
- };
- break;
- }
- constraints.video.frameRate = {
- min: 30,
- ideal: 30,
- max: 30
+ constraints.video = {
+ width: {
+ min: settings.constraints.video_width.min,
+ ideal: settings.constraints.video_width.ideal,
+ max: settings.constraints.video_width.max
+ },
+ height: {
+ min: settings.constraints.video_height.min,
+ ideal: settings.constraints.video_height.ideal,
+ max: settings.constraints.video_height.max
+ }
};
}
diff --git a/js/media-recorder-flash-kaltura.js b/js/media-recorder-flash-kaltura.js
index 7aa066b..7463fb9 100644
--- a/js/media-recorder-flash-kaltura.js
+++ b/js/media-recorder-flash-kaltura.js
@@ -51,46 +51,20 @@
// TODO: Add audio only support if this gets resolved: https://github.com/kaltura/krecord/issues/2
settings.constraints.audio = false;
settings.constraints.video = true;
- settings.constraints.video_resolution = settings.constraints.video_resolution || 640;
- constraints.audio = false;
+ constraints.audio = true;
constraints.video = {};
if (settings.constraints.video) {
- switch (settings.constraints.video_resolution) {
- case '640':
- constraints.video = {
- width: 640,
- height: 480
- };
- break;
- case '480':
- constraints.video = {
- width: 480,
- height: 360
- };
- break;
- case '320':
- constraints.video = {
- width: 320,
- height: 240
- };
- break;
- case '240':
- constraints.video = {
- width: 240,
- height: 180
- };
- break;
- case '180':
- constraints.video = {
- width: 180,
- height: 135
- };
- break;
- }
- constraints.video.frameRate = {
- min: 30,
- ideal: 30,
- max: 30
+ constraints.video = {
+ width: {
+ min: settings.constraints.video_width.min,
+ ideal: settings.constraints.video_width.ideal,
+ max: settings.constraints.video_width.max
+ },
+ height: {
+ min: settings.constraints.video_height.min,
+ ideal: settings.constraints.video_height.ideal,
+ max: settings.constraints.video_height.max
+ }
};
}
@@ -186,7 +160,7 @@
'https://' + conf.kaltura.flashVars.host + '/krecord/ui_conf_id/' + conf.kaltura.recorderUI + '/',
'krecorder',
$element.width(),
- $element.width() * 0.75,
+ $element.width() * (constraints.video.height.ideal / constraints.video.width.ideal),
'9.0.0',
'expressInstall.swf',
conf.kaltura.flashVars,
@@ -455,7 +429,7 @@
};
Drupal.kRecord.connected = function () {
- kRecorder.setQuality(100, 0, constraints.video.width, constraints.video.height, constraints.video.frameRate.ideal, constraints.video.frameRate.ideal, 70);
+ kRecorder.setQuality(0, 0, constraints.video.width.ideal, constraints.video.height.ideal, 25, 25, 70);
$settingsButton.show();
setStatus('Press record to start recording.');
};
diff --git a/media_recorder.install b/media_recorder.install
index cc3cd3b..1482fad 100644
--- a/media_recorder.install
+++ b/media_recorder.install
@@ -123,3 +123,24 @@ function media_recorder_update_7200(&$sandbox) {
variable_set('media_recorder', $settings);
}
+
+/**
+ * Updates admin settings to new constraints format.
+ */
+function media_recorder_update_7201(&$sandbox) {
+ $settings = media_recorder_get_settings();
+ $settings['constraints']['video_width'] = array(
+ 'min' => 640,
+ 'ideal' => 1280,
+ 'max' => 1920,
+ );
+ $settings['constraints']['video_height'] = array(
+ 'min' => 480,
+ 'ideal' => 720,
+ 'max' => 1080,
+ );
+ if (isset($settings['constraints']['video_resolution'])) {
+ unset($settings['constraints']['video_resolution']);
+ }
+ variable_set('media_recorder', $settings);
+}
diff --git a/media_recorder.module b/media_recorder.module
index 9faa9df..a879e68 100644
--- a/media_recorder.module
+++ b/media_recorder.module
@@ -170,7 +170,16 @@ function media_recorder_get_settings() {
'constraints' => array(
'audio' => TRUE,
'video' => TRUE,
- 'video_resolution' => 320,
+ 'video_width' => array(
+ 'min' => 640,
+ 'ideal' => 1280,
+ 'max' => 1920,
+ ),
+ 'video_height' => array(
+ 'min' => 480,
+ 'ideal' => 720,
+ 'max' => 1080,
+ ),
),
'css' => TRUE,
'time_limit' => 300,
@@ -1097,7 +1106,16 @@ function media_recorder_field_widget_info() {
'constraints' => array(
'audio' => TRUE,
'video' => TRUE,
- 'video_resolution' => 320,
+ 'video_width' => array(
+ 'min' => 640,
+ 'ideal' => 1280,
+ 'max' => 1920,
+ ),
+ 'video_height' => array(
+ 'min' => 480,
+ 'ideal' => 720,
+ 'max' => 1080,
+ ),
),
),
'behaviors' => array(
@@ -1138,16 +1156,53 @@ function media_recorder_field_widget_settings_form($field, $instance) {
'#title' => t('Video'),
'#default_value' => $settings['constraints']['video'],
);
- $form['constraints']['video_resolution'] = array(
- '#type' => 'radios',
- '#title' => t('Video Resolution'),
- '#default_value' => $settings['constraints']['video_resolution'],
- '#options' => array(
- 640 => t('640 x 480'),
- 480 => t('480 x 360'),
- 320 => t('320 x 240'),
- 240 => t('240 x 180'),
- 180 => t('180 x 135'),
+ $form['constraints']['video'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Video'),
+ '#default_value' => $settings['constraints']['video'],
+ );
+ $form['constraints']['video_width'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Width'),
+ 'min' => array(
+ '#type' => 'textfield',
+ '#title' => t('Minimum Width'),
+ '#default_value' => $settings['constraints']['video_width']['min'],
+ '#element_validate' => array('element_validate_integer_positive'),
+ ),
+ 'ideal' => array(
+ '#type' => 'textfield',
+ '#title' => t('Ideal Width'),
+ '#default_value' => $settings['constraints']['video_width']['ideal'],
+ '#element_validate' => array('element_validate_integer_positive'),
+ ),
+ 'max' => array(
+ '#type' => 'textfield',
+ '#title' => t('Maximum Width'),
+ '#default_value' => $settings['constraints']['video_width']['max'],
+ '#element_validate' => array('element_validate_integer_positive'),
+ ),
+ );
+ $form['constraints']['video_height'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Height'),
+ 'min' => array(
+ '#type' => 'textfield',
+ '#title' => t('Minimum Height'),
+ '#default_value' => $settings['constraints']['video_height']['min'],
+ '#element_validate' => array('element_validate_integer_positive'),
+ ),
+ 'ideal' => array(
+ '#type' => 'textfield',
+ '#title' => t('Ideal Height'),
+ '#default_value' => $settings['constraints']['video_height']['ideal'],
+ '#element_validate' => array('element_validate_integer_positive'),
+ ),
+ 'max' => array(
+ '#type' => 'textfield',
+ '#title' => t('Maximum Height'),
+ '#default_value' => $settings['constraints']['video_height']['max'],
+ '#element_validate' => array('element_validate_integer_positive'),
),
);