Miam-Player  0.8.0
A nice music player
Packet.h
Go to the documentation of this file.
1 /******************************************************************************
2  QtAV: Multimedia framework based on Qt and FFmpeg
3  Copyright (C) 2012-2016 Wang Bin <wbsecg1@gmail.com>
4 
5 * This file is part of QtAV
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Lesser General Public
9  License as published by the Free Software Foundation; either
10  version 2.1 of the License, or (at your option) any later version.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public
18  License along with this library; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 ******************************************************************************/
21 
22 #ifndef QAV_PACKET_H
23 #define QAV_PACKET_H
24 
25 #include <QtCore/QSharedData>
26 #include <QtAV/QtAV_Global.h>
27 
28 struct AVPacket;
29 
30 namespace QtAV {
31 
32 class PacketPrivate;
34 {
35 public:
36  static Packet fromAVPacket(const AVPacket* avpkt, double time_base);
37  static bool fromAVPacket(Packet *pkt, const AVPacket *avpkt, double time_base);
38  static Packet createEOF();
39 
40  Packet();
41  ~Packet();
42 
43  // required if no defination of PacketPrivate
44  Packet(const Packet& other);
45  Packet& operator =(const Packet& other);
46 
47  bool isEOF()const;
48  inline bool isValid() const;
55  const AVPacket* asAVPacket() const;
61  void skip(int bytes);
62 
64  bool isCorrupt;
65  QByteArray data;
66  // time unit is s.
67  qreal pts, duration;
68  qreal dts;
69  qint64 position; // position in source file byte stream
70 
71 private:
72  // we must define default/copy ctor, dtor and operator= so that we can provide only forward declaration of PacketPrivate
73  mutable QSharedDataPointer<PacketPrivate> d;
74 };
75 
76 bool Packet::isValid() const
77 {
78  return !isCorrupt && !data.isEmpty() && pts >= 0 && duration >= 0;
79 }
80 
81 #ifndef QT_NO_DEBUG_STREAM
82 Q_AV_EXPORT QDebug operator<<(QDebug debug, const Packet &pkt);
83 #endif
84 } //namespace QtAV
85 Q_DECLARE_METATYPE(QtAV::Packet)
86 #endif // QAV_PACKET_H
qreal pts
Definition: Packet.h:67
#define Q_AV_EXPORT
Definition: QtAV_Global.h:40
Definition: avcodec.h:1578
Q_AV_EXPORT QDebug operator<<(QDebug debug, const AudioFormat &fmt)
qreal dts
Definition: Packet.h:68
Definition: Packet.h:33
QByteArray data
Definition: Packet.h:65
bool isCorrupt
Definition: Packet.h:64
AudioOutput ao; ao.setAudioFormat(fmt); ao.open(); while (has_data) { data = read_data(ao->bufferSize...
Definition: AudioDecoder.h:31
bool isValid() const
Definition: Packet.h:76
qint64 position
Definition: Packet.h:69
bool hasKeyFrame
Definition: Packet.h:63