forked from edman007/chiton
-
Notifications
You must be signed in to change notification settings - Fork 0
/
motion_controller.hpp
61 lines (55 loc) · 2.74 KB
/
motion_controller.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef __MOTION_CONTROLLER_HPP__
#define __MOTION_CONTROLLER_HPP__
/**************************************************************************
*
* This file is part of Chiton.
*
* Chiton 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.
*
* Chiton 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 Chiton. If not, see <https://www.gnu.org/licenses/>.
*
* Copyright 2022 Ed Martin <[email protected]>
*
**************************************************************************
*/
#include "config_build.hpp"
#include "chiton_ffmpeg.hpp"
#include "chiton_config.hpp"
#include "module_controller.hpp"
class MotionController;
#include "motion_algo.hpp"
#include <list>
#include "stream_unwrap.hpp"
#include "event_notification.hpp"
//this class runs all motion detection algorithms
class MotionController : public ModuleController<MotionAlgo, MotionController> {
public:
MotionController(Database &db, Config &cfg, StreamUnwrap &stream);
~MotionController();
bool process_frame(int index, const AVFrame *frame);//process the frame, return false on error
bool set_streams(void);//identify the streams (by looking at the StreamUnwrap instance)
bool decode_video(void);//true if video is required (configured to do video motion detection)
bool decode_audio(void);//true if audio is required (configured to do audio motion detection)
//returns the motion algorithm with name, will be executed before algo, returns null if the algorithm does not exist, calls init() on the algorithm
void get_frame_timestamp(const AVFrame *frame, bool video, struct timeval &time);//wrapper for StreamUnwrap timestamp(), assumes from video stream if video is true
EventController& get_event_controller(void);//return a handle to the event controller
private:
StreamUnwrap &stream;
EventController events;
int video_idx;//index of the video stream
int audio_idx;//index of the audio stream
double skip_ratio;//the configured skip_ratio
bool set_video_stream(const AVStream *stream, const AVCodecContext *codec);//identify the video stream
bool set_audio_stream(const AVStream *stream, const AVCodecContext *codec);//identify the audio stream
bool should_skip(void);//check if we are falling behind and skip if required, return true when we need to skip
};
#endif