Commit 92bb7113 by wangguotao

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

parent 8763f0e0
/.vs /.vs
/*.pdb /*.pdb
/*.log /*.log
/MomentaMedia/*.log
/MomentaMedia/x64/ /MomentaMedia/x64/
/x64/Debug/MomentaMedia.exe /x64/Debug/*.exe
/x64/Debug/MomentaMedia.pdb /x64/Debug/MomentaMedia.pdb
/x64/Release/MomentaMedia.exe /x64/Release/MomentaMedia.exe
/x64/Release/MomentaMedia.log /x64/Release/*.log
/x64/Release/MomentaMedia.pdb /x64/Release/*.pdb
\ No newline at end of file /x64/Release/*.exe
/x64/Release/*.ilk
\ No newline at end of file
...@@ -64,6 +64,7 @@ private: ...@@ -64,6 +64,7 @@ private:
NDIlib_send_instance_t Instance; NDIlib_send_instance_t Instance;
NDIlib_video_frame_v2_t Frame; NDIlib_video_frame_v2_t Frame;
NDIlib_audio_frame_v3_t AudioFrame; NDIlib_audio_frame_v3_t AudioFrame;
uint32_t audio_size{ 0 };
VideoScale* m_scale; VideoScale* m_scale;
std::shared_ptr<AudioConvert> AudioCvtPtr; std::shared_ptr<AudioConvert> AudioCvtPtr;
......
...@@ -32,7 +32,7 @@ bool HaveBlackDataFlag = true; ...@@ -32,7 +32,7 @@ bool HaveBlackDataFlag = true;
int main_ver = 2; int main_ver = 2;
int mid_ver = 0; int mid_ver = 0;
int small_ver = 2; int small_ver = 5;
int crop_threads = 2; int crop_threads = 2;
int crop_on = 1; int crop_on = 1;
...@@ -42,7 +42,7 @@ int hdr_flag = 1; ...@@ -42,7 +42,7 @@ int hdr_flag = 1;
namespace 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) MomentaMedia::MomentaMedia(QWidget *parent)
...@@ -134,11 +134,14 @@ MomentaMedia::MomentaMedia(QWidget *parent) ...@@ -134,11 +134,14 @@ MomentaMedia::MomentaMedia(QWidget *parent)
//OutputModeCheck->setChecked(mode); //OutputModeCheck->setChecked(mode);
for(auto channel : AudioChannels) int ch_index = 0;
for (int i = 0; i < AudioChannels.size(); i++)
{ {
AudioChannelCombo->addItem(channel); 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); connect(AudioChannelCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &MomentaMedia::AudioChannelChanged);
OutputModeCombo->addItem(QString::fromWCharArray(L"跟随输入格式")); OutputModeCombo->addItem(QString::fromWCharArray(L"跟随输入格式"));
......
...@@ -10,6 +10,11 @@ ...@@ -10,6 +10,11 @@
#include "libyuv.h" #include "libyuv.h"
extern qint64 StartTimeStamp; extern qint64 StartTimeStamp;
extern int AudioChannel;
extern int FrameRate;
#define SAMPLE 9600
#define SAMPLERATE 48000
NDIOutputThread::NDIOutputThread(const QString& Name, int w, int h, qint32 deleyTime) : NDISenderName(Name), deleyTime_(deleyTime), width(w), height(h), isSending(false), Instance(nullptr), cropFlag(false), NDIOutputThread::NDIOutputThread(const QString& Name, int w, int h, qint32 deleyTime) : NDISenderName(Name), deleyTime_(deleyTime), width(w), height(h), isSending(false), Instance(nullptr), cropFlag(false),
m_lastTS(TimeMilliSecond()), m_lastTS(TimeMilliSecond()),
...@@ -113,7 +118,7 @@ bool NDIOutputThread::Init() ...@@ -113,7 +118,7 @@ bool NDIOutputThread::Init()
Frame.line_stride_in_bytes = Frame.xres * 2; Frame.line_stride_in_bytes = Frame.xres * 2;
//Frame.p_data = (uint8_t*)malloc(Frame.xres * Frame.yres * 2); //Frame.p_data = (uint8_t*)malloc(Frame.xres * Frame.yres * 2);
Frame.frame_rate_D = 1; Frame.frame_rate_D = 1;
Frame.frame_rate_N = 50; Frame.frame_rate_N = FrameRate;
Frame.frame_format_type = NDIlib_frame_format_type_progressive; Frame.frame_format_type = NDIlib_frame_format_type_progressive;
Frame.picture_aspect_ratio = 16.0 / 9; Frame.picture_aspect_ratio = 16.0 / 9;
//Frame.timecode = NDIlib_send_timecode_synthesize; //Frame.timecode = NDIlib_send_timecode_synthesize;
...@@ -122,9 +127,10 @@ bool NDIOutputThread::Init() ...@@ -122,9 +127,10 @@ bool NDIOutputThread::Init()
if (cropFlag) if (cropFlag)
{ {
AudioFrame.FourCC = NDIlib_FourCC_audio_type_FLTP; AudioFrame.FourCC = NDIlib_FourCC_audio_type_FLTP;
AudioFrame.no_channels = 2; AudioFrame.no_channels = AudioChannel;
AudioFrame.sample_rate = 48000; AudioFrame.sample_rate = SAMPLERATE;
AudioFrame.p_data = (uint8_t*)malloc(MAXCHANNEL * 1600 * 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); AudioCvtPtr = std::make_shared<AudioConvert>(AudioFrame.no_channels, bmdAudioSampleType32bitInteger);
} }
...@@ -141,6 +147,14 @@ void NDIOutputThread::SendAudioFunc() ...@@ -141,6 +147,14 @@ void NDIOutputThread::SendAudioFunc()
auto buffer = frame->buffer; auto buffer = frame->buffer;
auto size = frame->size; auto size = frame->size;
auto audio_tm = frame->frame_time_stamp; auto audio_tm = frame->frame_time_stamp;
if (audio_size < size)
{
if (AudioFrame.p_data) free(AudioFrame.p_data);
audio_size = size;
AudioFrame.p_data = (uint8_t*)malloc(audio_size);
}
auto dst_data = AudioFrame.p_data; auto dst_data = AudioFrame.p_data;
if (AudioCvtPtr) if (AudioCvtPtr)
......
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