mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-01 21:56:43 +08:00
57 lines
1.5 KiB
C++
57 lines
1.5 KiB
C++
/* 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_CODECS_OPUSENCODER_H
|
|
#define BLACKSOUND_CODECS_OPUSENCODER_H
|
|
|
|
#include "opus/opus.h"
|
|
#include "blacksound/blacksoundexport.h"
|
|
|
|
#include <QByteArray>
|
|
#include <QVector>
|
|
|
|
namespace BlackSound
|
|
{
|
|
namespace Codecs
|
|
{
|
|
//! OPUS encoder
|
|
class BLACKSOUND_EXPORT COpusEncoder
|
|
{
|
|
public:
|
|
//! Ctor
|
|
COpusEncoder(int sampleRate, int channels, int application = OPUS_APPLICATION_VOIP);
|
|
|
|
//! Dtor
|
|
~COpusEncoder();
|
|
|
|
//! Bit rate
|
|
void setBitRate(int bitRate);
|
|
|
|
//! \param frameCount Number of audio samples per frame
|
|
//! \returns the size of an audio frame in bytes
|
|
int frameByteCount(int frameCount);
|
|
|
|
//! Frame count
|
|
int frameCount(const QVector<qint16> pcmSamples);
|
|
|
|
QByteArray encode(const QVector<qint16> pcmSamples, int samplesLength, int *encodedLength);
|
|
|
|
private:
|
|
OpusEncoder *opusEncoder = nullptr;
|
|
int m_sampleRate;
|
|
int m_channels;
|
|
|
|
static constexpr int maxDataBytes = 4000;
|
|
};
|
|
} // ns
|
|
} // ns
|
|
|
|
#endif // guard
|