Olive
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
clipqueue.h
Go to the documentation of this file.
1 /***
2 
3  Olive - Non-Linear Video Editor
4  Copyright (C) 2019 Olive Team
5 
6  This program is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 
19 ***/
20 
21 #ifndef CLIPQUEUE_H
22 #define CLIPQUEUE_H
23 
24 extern "C" {
25 #include <libavformat/avformat.h>
26 }
27 
28 #include <QVector>
29 #include <QMutex>
30 
36 class ClipQueue {
37 public:
41  ClipQueue();
42 
48  ~ClipQueue();
49 
50  // Thread safety (QMutex compatible)
57  void lock();
58 
69  bool tryLock();
70 
77  void unlock();
78 
79  // Array handling (QVector compatible)
87  void append(AVFrame* frame);
88 
100  AVFrame* at(int i);
101 
109  AVFrame* first();
110 
118  AVFrame* last();
119 
125  void removeFirst();
126 
132  void removeLast();
133 
143  void removeAt(int i);
144 
150  void clear();
151 
160  int size();
161 
169  bool isEmpty();
170 
178  bool contains(AVFrame* frame);
179 
180 private:
181  QVector<AVFrame*> queue;
182  QMutex queue_lock;
183 };
184 
185 #endif // CLIPQUEUE_H
bool tryLock()
Try to lock queue mutex.
Definition: clipqueue.cpp:39
AVFrame * at(int i)
Retrieve a frame at a certain index.
Definition: clipqueue.cpp:54
QVector< AVFrame * > queue
Definition: clipqueue.h:181
The ClipQueue class.
Definition: clipqueue.h:36
void append(AVFrame *frame)
Add a frame to the end of the queue.
Definition: clipqueue.cpp:49
void removeAt(int i)
Remove frame in the queue at a certain index.
Definition: clipqueue.cpp:79
~ClipQueue()
ClipQueue Destructor.
Definition: clipqueue.cpp:29
void unlock()
Unlock queue mutex.
Definition: clipqueue.cpp:44
void removeFirst()
Remove first frame in the queue.
Definition: clipqueue.cpp:69
void lock()
Lock queue mutex.
Definition: clipqueue.cpp:34
void clear()
Clear entire queue.
Definition: clipqueue.cpp:85
QMutex queue_lock
Definition: clipqueue.h:182
bool contains(AVFrame *frame)
Returns whether the queue contains a frame or not.
Definition: clipqueue.cpp:102
AVFrame * first()
Retrieve first frame in the queue.
Definition: clipqueue.cpp:59
bool isEmpty()
Returns whether the queue is empty of not.
Definition: clipqueue.cpp:97
int size()
Retrieve current size of the queue.
Definition: clipqueue.cpp:92
void removeLast()
Remove last frame in the queue.
Definition: clipqueue.cpp:74
AVFrame * last()
Retrieve last frame in the queue.
Definition: clipqueue.cpp:64
ClipQueue()
ClipQueue Constructor.
Definition: clipqueue.cpp:24