CCIMXDesktop
 
Loading...
Searching...
No Matches
VideoPlayer.h
1#ifndef VIDEOPLAYER_H
2#define VIDEOPLAYER_H
3#include "CVImage.h"
4#include "VideoPlayerImpl.h"
5#include <QObject>
6#include <QTimer>
7/* Video Support is limited to OpenCV Due to the RealTime Request */
8namespace cv {
9class VideoCapture;
10};
11
16namespace VideoPlayerTools {
17
24qint64 frame_to_mseconds(int frame, int fps);
25
32qint64 mseconds_to_frame(qint64 msec, int fps);
33}
34
35class VideoPlayer : public QObject {
36 Q_OBJECT
37public:
43 explicit VideoPlayer(QObject* parent = nullptr);
45
51 bool open(const char* video_path);
52
57 QString current_handle() const { return last_open; }
58
63 bool close();
64
69 bool play();
70
75 bool pause();
76 /* get the total frame */
77
82 int total_frame() const;
83
88 inline int total_msecs() const {
90 total_frame(), info.fps);
91 }
92
97 inline VideoPlayerInfo get_info() const { return info; }
102 int current_frame() const;
103
108 bool valid_video() const;
109
114 bool is_playing() const;
115
120 qint64 currentFrameMSec() const;
121
127 bool setCurrentFrameMSec(const qint64 msec);
128
134 void escapeFrame();
135
142 bool peekFrame(CVImage& container, int frame_request);
143signals:
148 void openError(const VideoPlayerOpenErrorCode error);
149
155 void frameReady(const CVImage image);
156
161
165 void videoEnd();
166
167private slots:
171 void time_to_fetch_next_frame();
172
173private:
174 VideoPlayerImpl* impl { nullptr };
175 bool on_play { false };
176 VideoPlayerInfo info;
177 int play_sleep { 0 };
178 QString last_open {};
179};
180
181#endif // VIDEOPLAYER_H
The CVImage class is the image class that provides the image in the frameworks.
Definition CVImage.h:9
The VideoPlayerImpl class VideoPlayerImpl is the interface for video player and the impl class is sup...
Definition VideoPlayerImpl.h:33
Definition VideoPlayer.h:35
bool open(const char *video_path)
open open the video file
Definition VideoPlayer.cpp:24
QString current_handle() const
current_handle get the current handle
Definition VideoPlayer.h:57
void openError(const VideoPlayerOpenErrorCode error)
openError the signal indicating the open error
int total_msecs() const
total_msecs get the total mseconds of the video
Definition VideoPlayer.h:88
void videoEnd()
videoEnd the signal indicating the video end
int current_frame() const
current_frame get the current frame of the video
Definition VideoPlayer.cpp:87
VideoPlayerInfo get_info() const
get_info get the info of the video
Definition VideoPlayer.h:97
void about_fetch_frame()
about_fetch_frame the signal indicating the frame is ready
bool close()
close close the video file
Definition VideoPlayer.cpp:43
void escapeFrame()
escapeFrame escape the current frame
Definition VideoPlayer.cpp:129
qint64 currentFrameMSec() const
currentFrameMSec get the current frame in mseconds
Definition VideoPlayer.cpp:100
bool valid_video() const
valid_video check if the video is valid
Definition VideoPlayer.cpp:91
bool peekFrame(CVImage &container, int frame_request)
peekFrame peek the frame of the video
Definition VideoPlayer.cpp:148
void frameReady(const CVImage image)
frameReady the signal indicating the frame is ready
bool setCurrentFrameMSec(const qint64 msec)
setCurrentFrameMSec set the current frame in mseconds
Definition VideoPlayer.cpp:112
int total_frame() const
total_frame get the total frame of the video
Definition VideoPlayer.cpp:83
bool play()
play start the video play
Definition VideoPlayer.cpp:51
bool pause()
pause stop the video play
Definition VideoPlayer.cpp:67
bool is_playing() const
is_playing check if the video is playing
Definition VideoPlayer.cpp:95
VideoPlayerTools provides the tools for video player.
Definition VideoPlayer.cpp:3
qint64 mseconds_to_frame(qint64 msec, int fps)
mseconds_to_frame convert the mseconds to frame
Definition VideoPlayer.cpp:8
qint64 frame_to_mseconds(int frame, int fps)
frame_to_mseconds convert the frame to mseconds
Definition VideoPlayer.cpp:4
The VideoPlayerInfo struct provides the video information.
Definition VideoPlayerImpl.h:22
int fps
fps
Definition VideoPlayerImpl.h:23