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

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 #ifndef QAVAUDIOFORMAT_H
0009 #define QAVAUDIOFORMAT_H
0010 
0011 #include <QtAVPlayer/qtavplayerglobal.h>
0012 
0013 QT_BEGIN_NAMESPACE
0014 
0015 class QAVAudioFormat
0016 {
0017 public:
0018     enum SampleFormat
0019     {
0020         Unknown,
0021         UInt8,
0022         Int16,
0023         Int32,
0024         Float
0025     };
0026 
0027     SampleFormat sampleFormat() const { return m_sampleFormat; }
0028     void setSampleFormat(SampleFormat f) { m_sampleFormat = f; }
0029 
0030     int sampleRate() const { return m_sampleRate; }
0031     void setSampleRate(int sampleRate) { m_sampleRate = sampleRate; }
0032 
0033     int channelCount() const { return m_channelCount; }
0034     void setChannelCount(int channelCount) { m_channelCount = channelCount; }
0035 
0036     operator bool() const
0037     {
0038         return m_sampleFormat != SampleFormat::Unknown && m_sampleRate != 0 && m_channelCount != 0;
0039     }
0040 
0041     friend bool operator==(const QAVAudioFormat &a, const QAVAudioFormat &b)
0042     {
0043         return a.m_sampleRate == b.m_sampleRate &&
0044                a.m_channelCount == b.m_channelCount &&
0045                a.m_sampleFormat == b.m_sampleFormat;
0046     }
0047 
0048     friend bool operator!=(const QAVAudioFormat &a, const QAVAudioFormat &b)
0049     {
0050         return !(a == b);
0051     }
0052 
0053 private:
0054     SampleFormat m_sampleFormat = Unknown;
0055     int m_sampleRate = 0;
0056     int m_channelCount = 0;
0057 };
0058 
0059 QT_END_NAMESPACE
0060 
0061 #endif