forked from wang-bin/QtAV
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AVThread_p.h
106 lines (92 loc) · 3.24 KB
/
AVThread_p.h
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/******************************************************************************
QtAV: Media play library based on Qt and FFmpeg
Copyright (C) 2012-2016 Wang Bin <[email protected]>
* This file is part of QtAV
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
******************************************************************************/
#ifndef QTAV_AVTHREAD_P_H
#define QTAV_AVTHREAD_P_H
#include <QtCore/QMutex>
#include <QtCore/QMutexLocker>
#include <QtCore/QSemaphore>
#include <QtCore/QVariant>
#include <QtCore/QWaitCondition>
#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
#include <QtCore/QElapsedTimer>
#else
#include <QtCore/QTime>
typedef QTime QElapsedTimer;
#endif
#include "PacketBuffer.h"
#include "utils/ring.h"
QT_BEGIN_NAMESPACE
class QRunnable;
QT_END_NAMESPACE
namespace QtAV {
const double kSyncThreshold = 0.2; // 200 ms
class AVDecoder;
class AVOutput;
class AVClock;
class Filter;
class Statistics;
class OutputSet;
class AVThreadPrivate : public DPtrPrivate<AVThread>
{
public:
AVThreadPrivate():
paused(false)
, next_pause(false)
, stop(false)
, clock(0)
, dec(0)
, outputSet(0)
, delay(0)
, statistics(0)
, seek_requested(false)
, render_pts0(-1)
, drop_frame_seek(true)
, pts_history(30)
, wait_err(0)
{
tasks.blockFull(false);
QVariantHash opt;
opt[QString::fromLatin1("skip_frame")] = 8; // 8 for "avcodec", "NoRef" for "FFmpeg". see AVDiscard
dec_opt_framedrop[QString::fromLatin1("avcodec")] = opt;
opt[QString::fromLatin1("skip_frame")] = 0; // 0 for "avcodec", "Default" for "FFmpeg". see AVDiscard
dec_opt_normal[QString::fromLatin1("avcodec")] = opt; // avcodec need correct string or value in libavcodec
}
virtual ~AVThreadPrivate();
bool paused, next_pause;
volatile bool stop; //true when packets is empty and demux is end.
AVClock *clock;
PacketBuffer packets;
AVDecoder *dec;
OutputSet *outputSet;
QMutex mutex;
QWaitCondition cond; //pause
qreal delay;
QList<Filter*> filters;
Statistics *statistics; //not obj. Statistics is unique for the player, which is in AVPlayer
BlockingQueue<QRunnable*> tasks;
QSemaphore sem;
bool seek_requested;
//only decode video without display or skip decode audio until pts reaches
qreal render_pts0;
static QVariantHash dec_opt_framedrop, dec_opt_normal;
bool drop_frame_seek;
ring<qreal> pts_history;
qint64 wait_err;
QElapsedTimer wait_timer;
};
} //namespace QtAV
#endif // QTAV_AVTHREAD_P_H