2018-03-20 10:03:12 -04:00
|
|
|
// vim: set et sw=2 ts=2:
|
|
|
|
//
|
|
|
|
// This file is part of Moonfire NVR, a security camera digital video recorder.
|
|
|
|
// Copyright (C) 2018 Dolf Starreveld <dolf@starreveld.com>
|
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// In addition, as a special exception, the copyright holders give
|
|
|
|
// permission to link the code of portions of this program with the
|
|
|
|
// OpenSSL library under certain conditions as described in each
|
|
|
|
// individual source file, and distribute linked combinations including
|
|
|
|
// the two.
|
|
|
|
//
|
|
|
|
// You must obey the GNU General Public License in all respects for all
|
|
|
|
// of the code used other than OpenSSL. If you modify file(s) with this
|
|
|
|
// exception, you may extend this exception to your version of the
|
|
|
|
// file(s), but you are not obligated to do so. If you do not wish to do
|
|
|
|
// so, delete this exception statement from your version. If you delete
|
|
|
|
// this exception statement from all source files in the program, then
|
|
|
|
// also delete it here.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
import RecordingsView from './RecordingsView';
|
|
|
|
|
|
|
|
/**
|
2018-04-27 09:42:39 -04:00
|
|
|
* Stream view: a list of available recording segments for playback.
|
2018-03-20 10:03:12 -04:00
|
|
|
*/
|
2018-04-27 09:42:39 -04:00
|
|
|
export default class StreamView {
|
2018-03-20 10:03:12 -04:00
|
|
|
/**
|
|
|
|
* @param {Camera} cameraModel Model object for camera
|
2018-04-27 09:42:39 -04:00
|
|
|
* @param {String} streamType "main" or "sub"
|
2018-03-20 10:03:12 -04:00
|
|
|
* @param {[type]} recordingFormatter Formatter to be used by recordings
|
|
|
|
* @param {[type]} trimmed True if rec. ranges should be trimmed
|
|
|
|
* @param {[type]} recordingsParent Parent element to attach to or null)
|
|
|
|
*/
|
|
|
|
constructor(
|
2020-03-02 01:26:26 -05:00
|
|
|
cameraModel,
|
|
|
|
streamType,
|
|
|
|
recordingFormatter,
|
|
|
|
trimmed,
|
|
|
|
recordingsParent = null
|
2018-03-20 10:03:12 -04:00
|
|
|
) {
|
|
|
|
this.camera = cameraModel;
|
2018-04-27 09:42:39 -04:00
|
|
|
this.streamType = streamType;
|
|
|
|
this.stream = cameraModel.streams[streamType];
|
2018-03-20 10:03:12 -04:00
|
|
|
this.recordingsView = new RecordingsView(
|
2020-03-02 01:26:26 -05:00
|
|
|
this.camera,
|
|
|
|
this.streamType,
|
|
|
|
recordingFormatter,
|
|
|
|
trimmed,
|
|
|
|
recordingsParent
|
2018-03-20 10:03:12 -04:00
|
|
|
);
|
|
|
|
this._enabled = true;
|
|
|
|
this.recordingsUrl = null;
|
|
|
|
this.recordingsReq = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get whether the view is enabled or not.
|
|
|
|
*
|
|
|
|
* @return {Boolean}
|
|
|
|
*/
|
|
|
|
get enabled() {
|
|
|
|
return this._enabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Change enabled state of the view.
|
|
|
|
*
|
|
|
|
* @param {Boolean} enabled Whether view should be enabled
|
|
|
|
*/
|
|
|
|
set enabled(enabled) {
|
|
|
|
this._enabled = enabled;
|
|
|
|
this.recordingsView.show = enabled;
|
2018-04-27 09:42:39 -04:00
|
|
|
console.log('Stream %s-%s %s', this.camera.shortName, this.streamType,
|
|
|
|
this.enabled ? 'enabled' : 'disabled');
|
2018-03-20 10:03:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the currently remembered recordings range for this camera.
|
|
|
|
*
|
|
|
|
* This is just passed on to the recordings view.
|
|
|
|
*
|
|
|
|
* @return {Range90k} Currently remembered range
|
|
|
|
*/
|
|
|
|
get recordingsRange() {
|
|
|
|
return this.recordingsView.recordingsRange;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the recordings range for this view.
|
|
|
|
*
|
|
|
|
* This is just passed on to the recordings view.
|
|
|
|
*
|
|
|
|
* @param {Range90k} range90k Range to remember
|
|
|
|
*/
|
|
|
|
set recordingsRange(range90k) {
|
|
|
|
this.recordingsView.recordingsRange = range90k;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set whether loading indicator should be shown or not.
|
|
|
|
*
|
|
|
|
* This indicator is really on the recordings list.
|
|
|
|
*
|
|
|
|
* @param {Boolean} show True if indicator should be showing
|
|
|
|
*/
|
|
|
|
set showLoading(show) {
|
|
|
|
this.recordingsView.showLoading = show;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the loading indicated after a delay, unless the timer has been
|
|
|
|
* cleared already.
|
|
|
|
*
|
|
|
|
* @param {Number} timeOutMs Delay (in ms) before indicator should appear
|
|
|
|
*/
|
|
|
|
delayedShowLoading(timeOutMs) {
|
|
|
|
this.recordingsView.delayedShowLoading(timeOutMs);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set new recordings from JSON data.
|
|
|
|
*
|
|
|
|
* @param {Object} dataJSON JSON data (array)
|
|
|
|
*/
|
|
|
|
set recordingsJSON(dataJSON) {
|
|
|
|
this.recordingsView.recordingsJSON = dataJSON;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set a new time format string for the recordings list.
|
|
|
|
*
|
|
|
|
* @param {String} formatStr Formatting string
|
|
|
|
*/
|
|
|
|
set timeFormat(formatStr) {
|
|
|
|
this.recordingsView.timeFormat = formatStr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the trimming option of the cameraview as desired.
|
|
|
|
*
|
|
|
|
* This is really just passed on to the recordings view.
|
|
|
|
*
|
|
|
|
* @param {Boolean} enabled True if trimming should be enabled
|
|
|
|
*/
|
|
|
|
set trimmed(enabled) {
|
|
|
|
this.recordingsView.trimmed = enabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set a handler for clicks on a recording.
|
|
|
|
*
|
|
|
|
* The handler will be called with one argument, the recording model.
|
|
|
|
*
|
|
|
|
* @param {Function} h Handler function
|
|
|
|
*/
|
|
|
|
set onRecordingClicked(h) {
|
|
|
|
this.recordingsView.onRecordingClicked = h;
|
|
|
|
}
|
|
|
|
}
|