Skip to content

Commit 3314d1d

Browse files
author
Mark Williams
committed
LIMS-2057: Allow custom resolutions for webcams
1 parent ad33811 commit 3314d1d

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

api/config_sample.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,13 @@
356356
# - These are show on the beamline status and active datacollection lists
357357
$webcams = array('i03' => array('1.2.3.4'),
358358
);
359+
# Allow overriding of default resolution (480x270) and fps (5) or any other URL parameters
360+
$webcamParameters = array(
361+
'1.2.3.4' => array(
362+
'resolution' => '480x360',
363+
'fps' => 1,
364+
),
365+
);
359366

360367
# On-axis viewing (OAV) camera addresses
361368
# - Shown on beamline status page for staff, for remote debugging

api/src/Page/Image.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ function _forward_oav() {
309309
# ------------------------------------------------------------------------
310310
# Forward beamline webcams
311311
function _forward_webcam() {
312-
global $webcams;
312+
global $webcams, $webcamParameters;
313313

314314
if (!array_key_exists($this->arg('bl'), $webcams)) return;
315315

@@ -327,9 +327,18 @@ function _forward_webcam() {
327327

328328
while (@ob_end_clean());
329329
header('content-type: multipart/x-mixed-replace; boundary=myboundary');
330+
331+
$params = array(
332+
'fps' => 5,
333+
'resolution' => '480x270',
334+
);
335+
if (isset($webcamParameters[$img])) {
336+
$params = array_merge($params, $webcamParameters[$img]);
337+
}
338+
$url = 'http://' . $img . '/axis-cgi/mjpg/video.cgi?' . http_build_query($params);
330339

331340
$ch = curl_init();
332-
curl_setopt($ch, CURLOPT_URL, 'http://'.$img.'/axis-cgi/mjpg/video.cgi?fps=5&resolution=CIF&resolution=480x270');
341+
curl_setopt($ch, CURLOPT_URL, $url);
333342
curl_setopt($ch, CURLOPT_HEADER, 0);
334343
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
335344
$im = curl_exec($ch);

0 commit comments

Comments
 (0)