File indexing completed on 2025-01-19 03:57:06

0001 /*********************************************************
0002  * Copyright (C) 2020, Val Doroshchuk <valbok@gmail.com> *
0003  *                                                       *
0004  * This file is part of QtAVPlayer.                      *
0005  * Free Qt Media Player based on FFmpeg.                 *
0006  *********************************************************/
0007 
0008 #include "qavstreamframe.h"
0009 #include "qavstreamframe_p.h"
0010 #include "qavframe_p.h"
0011 #include "qavcodec_p.h"
0012 #include <QDebug>
0013 
0014 extern "C" {
0015 #include <libavformat/avformat.h>
0016 }
0017 
0018 QT_BEGIN_NAMESPACE
0019 
0020 QAVStreamFrame::QAVStreamFrame()
0021     : QAVStreamFrame(*new QAVStreamFramePrivate)
0022 {
0023 }
0024 
0025 QAVStreamFrame::QAVStreamFrame(const QAVStreamFrame &other)
0026     : QAVStreamFrame()
0027 {
0028     *this = other;
0029 }
0030 
0031 QAVStreamFrame::QAVStreamFrame(QAVStreamFramePrivate &d)
0032     : d_ptr(&d)
0033 {
0034 }
0035 
0036 QAVStreamFrame::~QAVStreamFrame()
0037 {
0038 }
0039 
0040 QAVStream QAVStreamFrame::stream() const
0041 {
0042     return d_ptr->stream;
0043 }
0044 
0045 void QAVStreamFrame::setStream(const QAVStream &stream)
0046 {
0047     Q_D(QAVStreamFrame);
0048     d->stream = stream;
0049 }
0050 
0051 QAVStreamFrame &QAVStreamFrame::operator=(const QAVStreamFrame &other)
0052 {
0053     d_ptr->stream = other.d_ptr->stream;
0054     return *this;
0055 }
0056 
0057 QAVStreamFrame::operator bool() const
0058 {
0059     Q_D(const QAVStreamFrame);
0060     return d->stream;
0061 }
0062 
0063 double QAVStreamFrame::pts() const
0064 {
0065     Q_D(const QAVStreamFrame);
0066     return d->pts();
0067 }
0068 
0069 double QAVStreamFrame::duration() const
0070 {
0071     Q_D(const QAVStreamFrame);
0072     return d->duration();
0073 }
0074 
0075 int QAVStreamFrame::receive()
0076 {
0077     Q_D(QAVStreamFrame);
0078     return d->stream ? d->stream.codec()->read(*this) : 0;
0079 }
0080 
0081 QT_END_NAMESPACE