Ref T730, OPUS de/encoder namespace

This commit is contained in:
Klaus Basan
2019-09-19 01:44:28 +02:00
committed by Mat Sutcliffe
parent 9809acd98c
commit 34d1e8268c
7 changed files with 169 additions and 105 deletions

View File

@@ -1,5 +1,15 @@
#ifndef OPUSENCODER_H
#define OPUSENCODER_H
/* Copyright (C) 2019
* swift project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated,
* or distributed except according to the terms contained in the LICENSE file.
*/
//! \file
#ifndef BLACKSOUND_OPUSENCODER_H
#define BLACKSOUND_OPUSENCODER_H
#include "blacksound/blacksoundexport.h"
#include "opus/opus.h"
@@ -7,28 +17,38 @@
#include <QByteArray>
#include <QVector>
class BLACKSOUND_EXPORT COpusEncoder
namespace BlackSound
{
public:
COpusEncoder(int sampleRate, int channels, int application = OPUS_APPLICATION_VOIP);
~COpusEncoder();
namespace Codecs
{
//! OPUS encoder
class BLACKSOUND_EXPORT COpusEncoder
{
public:
//! Ctor
COpusEncoder(int sampleRate, int channels, int application = OPUS_APPLICATION_VOIP);
void setBitRate(int bitRate);
//! Dtor
~COpusEncoder();
//! \param frameCount Number of audio samples per frame
//! \returns the size of an audio frame in bytes
int frameByteCount(int frameCount);
void setBitRate(int bitRate);
int frameCount(const QVector<qint16> pcmSamples);
//! \param frameCount Number of audio samples per frame
//! \returns the size of an audio frame in bytes
int frameByteCount(int frameCount);
QByteArray encode(const QVector<qint16> pcmSamples, int samplesLength, int *encodedLength);
int frameCount(const QVector<qint16> pcmSamples);
private:
OpusEncoder *opusEncoder;
int m_sampleRate;
int m_channels;
QByteArray encode(const QVector<qint16> pcmSamples, int samplesLength, int *encodedLength);
static constexpr int maxDataBytes = 4000;
};
private:
OpusEncoder *opusEncoder;
int m_sampleRate;
int m_channels;
static constexpr int maxDataBytes = 4000;
};
} // ns
} // ns
#endif // guard