mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-18 03:15:34 +08:00
Ref T730, namespace for BlackCore::Afv
* added namespace * removed some *.pri files and added files to blackcore.pro * added copyright etc.
This commit is contained in:
committed by
Mat Sutcliffe
parent
d064da13b5
commit
384aa3ce19
@@ -1,5 +1,15 @@
|
||||
#ifndef AUDIO_INPUT_H
|
||||
#define AUDIO_INPUT_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 BLACKCORE_AFV_AUDIO_AUDIO_INPUT_H
|
||||
#define BLACKCORE_AFV_AUDIO_AUDIO_INPUT_H
|
||||
|
||||
#include "blacksound/sampleprovider/bufferedwaveprovider.h"
|
||||
#include "blacksound/codecs/opusencoder.h"
|
||||
@@ -10,85 +20,95 @@
|
||||
#include <QDateTime>
|
||||
#include <QSharedPointer>
|
||||
|
||||
class AudioInputBuffer : public QIODevice
|
||||
namespace BlackCore
|
||||
{
|
||||
Q_OBJECT
|
||||
namespace Afv
|
||||
{
|
||||
namespace Audio
|
||||
{
|
||||
//! Input buffer
|
||||
class AudioInputBuffer : public QIODevice
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AudioInputBuffer() {}
|
||||
public:
|
||||
AudioInputBuffer() {}
|
||||
|
||||
void start();
|
||||
void stop();
|
||||
void start();
|
||||
void stop();
|
||||
|
||||
qint64 readData(char *data, qint64 maxlen) override;
|
||||
qint64 writeData(const char *data, qint64 len) override;
|
||||
qint64 readData(char *data, qint64 maxlen) override;
|
||||
qint64 writeData(const char *data, qint64 len) override;
|
||||
|
||||
signals:
|
||||
void frameAvailable(const QByteArray &frame);
|
||||
signals:
|
||||
void frameAvailable(const QByteArray &frame);
|
||||
|
||||
private:
|
||||
static constexpr qint64 frameSize = 960;
|
||||
QByteArray m_buffer;
|
||||
};
|
||||
private:
|
||||
static constexpr qint64 frameSize = 960;
|
||||
QByteArray m_buffer;
|
||||
};
|
||||
|
||||
struct OpusDataAvailableArgs
|
||||
{
|
||||
uint sequenceCounter = 0;
|
||||
QByteArray audio;
|
||||
};
|
||||
struct OpusDataAvailableArgs
|
||||
{
|
||||
uint sequenceCounter = 0;
|
||||
QByteArray audio;
|
||||
};
|
||||
|
||||
struct InputVolumeStreamArgs
|
||||
{
|
||||
QAudioDeviceInfo DeviceNumber;
|
||||
float PeakRaw = 0.0;
|
||||
float PeakDB = -1 * std::numeric_limits<float>::infinity();
|
||||
float PeakVU = 0.0;
|
||||
};
|
||||
struct InputVolumeStreamArgs
|
||||
{
|
||||
QAudioDeviceInfo DeviceNumber;
|
||||
float PeakRaw = 0.0;
|
||||
float PeakDB = -1 * std::numeric_limits<float>::infinity();
|
||||
float PeakVU = 0.0;
|
||||
};
|
||||
|
||||
class Input : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
class Input : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Input(int sampleRate, QObject *parent = nullptr);
|
||||
public:
|
||||
Input(int sampleRate, QObject *parent = nullptr);
|
||||
|
||||
bool started() const;
|
||||
bool started() const;
|
||||
|
||||
int opusBytesEncoded() const;
|
||||
void setOpusBytesEncoded(int opusBytesEncoded);
|
||||
int opusBytesEncoded() const;
|
||||
void setOpusBytesEncoded(int opusBytesEncoded);
|
||||
|
||||
float volume() const;
|
||||
void setVolume(float volume);
|
||||
float volume() const;
|
||||
void setVolume(float volume);
|
||||
|
||||
void start(const QAudioDeviceInfo &inputDevice);
|
||||
void stop();
|
||||
void start(const QAudioDeviceInfo &inputDevice);
|
||||
void stop();
|
||||
|
||||
signals:
|
||||
void inputVolumeStream(const InputVolumeStreamArgs &args);
|
||||
void opusDataAvailable(const OpusDataAvailableArgs &args);
|
||||
signals:
|
||||
void inputVolumeStream(const InputVolumeStreamArgs &args);
|
||||
void opusDataAvailable(const OpusDataAvailableArgs &args);
|
||||
|
||||
private:
|
||||
void audioInDataAvailable(const QByteArray &frame);
|
||||
private:
|
||||
void audioInDataAvailable(const QByteArray &frame);
|
||||
|
||||
static constexpr qint64 c_frameSize = 960;
|
||||
int m_sampleRate = 0;
|
||||
static constexpr qint64 c_frameSize = 960;
|
||||
int m_sampleRate = 0;
|
||||
|
||||
COpusEncoder m_encoder;
|
||||
QScopedPointer<QAudioInput> m_audioInput;
|
||||
COpusEncoder m_encoder;
|
||||
QScopedPointer<QAudioInput> m_audioInput;
|
||||
|
||||
bool m_started = false;
|
||||
int m_opusBytesEncoded = 0;
|
||||
float m_volume = 1.0f;
|
||||
int m_sampleCount = 0;
|
||||
float m_maxSampleInput = 0;
|
||||
bool m_started = false;
|
||||
int m_opusBytesEncoded = 0;
|
||||
float m_volume = 1.0f;
|
||||
int m_sampleCount = 0;
|
||||
float m_maxSampleInput = 0;
|
||||
|
||||
const int c_sampleCountPerEvent = 4800;
|
||||
const float maxDb = 0;
|
||||
const float minDb = -40;
|
||||
const int c_sampleCountPerEvent = 4800;
|
||||
const float maxDb = 0;
|
||||
const float minDb = -40;
|
||||
|
||||
uint m_audioSequenceCounter = 0;
|
||||
uint m_audioSequenceCounter = 0;
|
||||
|
||||
AudioInputBuffer m_audioInputBuffer;
|
||||
};
|
||||
AudioInputBuffer m_audioInputBuffer;
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
#endif // AIRCRAFTVHFINPUT_H
|
||||
#endif // guard
|
||||
|
||||
Reference in New Issue
Block a user