Commit 1e65d165 by wangguotao

1.modify audio channel list of sdk support values 2.add check ndi audio buffer size

parent eb0862e1
......@@ -58,6 +58,7 @@ private:
NDIlib_send_instance_t Instance;
NDIlib_video_frame_v2_t Frame;
NDIlib_audio_frame_v3_t AudioFrame;
uint32_t audio_size{0};
std::shared_ptr<AudioConvert> AudioCvtPtr;
std::thread audio_thread;
......
......@@ -32,7 +32,7 @@ bool HaveBlackDataFlag = true;
int main_ver = 2;
int mid_ver = 0;
int small_ver = 4;
int small_ver = 5;
bool scale_enable = true;
std::atomic_bool bk_flag = false;
......@@ -40,7 +40,7 @@ cv::Mat bk_mat;
namespace
{
const std::vector<QString> AudioChannels = { "1","2","3","4","5","6","7","8" };
const std::vector<QString> AudioChannels = { "2","8","16","32","64"};
}
MomentaMedia::MomentaMedia(QWidget *parent)
......@@ -133,12 +133,14 @@ MomentaMedia::MomentaMedia(QWidget *parent)
//OutputModeCheck->setChecked(mode);
for(auto channel : AudioChannels)
{
AudioChannelCombo->addItem(channel);
int ch_index = 0;
for(int i = 0; i < AudioChannels.size();i++)
{
auto str = AudioChannels[i];
if (str == QString::number(channel)) ch_index = i;
AudioChannelCombo->addItem(str);
}
AudioChannelCombo->setCurrentIndex(channel - 1);
AudioChannelCombo->setCurrentIndex(ch_index);
connect(AudioChannelCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &MomentaMedia::AudioChannelChanged);
OutputModeCombo->addItem(QString::fromWCharArray(L"跟随输入格式"));
......@@ -743,7 +745,7 @@ void MomentaMedia::ReadSettings()
else if (BlackBottomHeight > 480) BlackBottomHeight = 480;*/
AudioChannel = settings.value("AUDIO_CHANNEL").toInt();
if (AudioChannel <= 0 || AudioChannel > 20) AudioChannel = 2;
if (AudioChannel <= 0) AudioChannel = 2;
//PrvwFlag = settings.value("PRVW_FLAG", "").toInt();
......
......@@ -11,7 +11,7 @@ extern qint64 StartTimeStamp;
extern int AudioChannel;
extern int FrameRate;
#define SAMPLE 2400
#define SAMPLE 9600
#define SAMPLERATE 48000
NDIOutputThread::NDIOutputThread(const QString& Name, int w, int h, qint32 deleyTime) : NDISenderName(Name), width(w), height(h), deleyTime_(deleyTime), isSending(false), Instance(nullptr), cropFlag(false), AudioCvtPtr(nullptr)
......@@ -96,7 +96,8 @@ bool NDIOutputThread::Init()
AudioFrame.FourCC = NDIlib_FourCC_audio_type_FLTP;
AudioFrame.no_channels = AudioChannel;
AudioFrame.sample_rate = SAMPLERATE;
AudioFrame.p_data = (uint8_t*)malloc(AudioChannel * SAMPLE * sizeof(float));
audio_size = AudioChannel * SAMPLE * sizeof(float);
AudioFrame.p_data = (uint8_t*)malloc(audio_size);
AudioCvtPtr = std::make_shared<AudioConvert>(AudioFrame.no_channels, bmdAudioSampleType32bitInteger);
}
......@@ -116,6 +117,13 @@ void NDIOutputThread::SendAudioFunc()
auto audio_tm = frame->frame_time_stamp;
auto dst_data =AudioFrame.p_data;
if (audio_size < size)
{
if (AudioFrame.p_data) free(AudioFrame.p_data);
audio_size = size;
AudioFrame.p_data = (uint8_t*)malloc(audio_size);
}
if (AudioCvtPtr)
{
AudioCvtPtr->SetParams(frame->channel, bmdAudioSampleType32bitInteger);
......
......@@ -4,7 +4,7 @@ FRAME_RATE=50
PRVW_FLAG=0
OUTPUT_PLAY_MODE=0
BLACK_BOTTOM_HEIGHT=0
AUDIO_CHANNEL=1
AUDIO_CHANNEL=8
ASPEC_DEN=9
ASPEC_NUM=16
SCALE_MODE=0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment