未验证 提交 f7ec6043 编写于 作者: J Jim 提交者: GitHub

Merge pull request #3179 from pkviet/coreaudio4

coreaudio-encoder: Fix encoding of 4.0 speaker layout
......@@ -597,14 +597,34 @@ static void *aac_create(obs_data_t *settings, obs_encoder_t *encoder)
/*
* Fix channel map differences between CoreAudio AAC, FFmpeg, Wav
* New channel mappings below assume 2.1, 4.1, 5.1, 7.1 resp.
* New channel mappings below assume 2.1, 4.0, 4.1, 5.1, 7.1 resp.
*/
if (ca->channels == 3) {
SInt32 channelMap3[3] = {2, 0, 1};
AudioConverterSetProperty(ca->converter,
kAudioConverterChannelMap,
sizeof(channelMap3), channelMap3);
} else if (ca->channels == 4) {
/*
* For four channels coreaudio encoder has default channel "quad"
* instead of 4.0. So explicitly set channel layout to
* kAudioChannelLayoutTag_MPEG_4_0_B = (116L << 16) | 4.
*/
AudioChannelLayout inAcl = {0};
inAcl.mChannelLayoutTag = (116L << 16) | 4;
AudioConverterSetProperty(ca->converter,
kAudioConverterInputChannelLayout,
sizeof(inAcl), &inAcl);
AudioConverterSetProperty(ca->converter,
kAudioConverterOutputChannelLayout,
sizeof(inAcl), &inAcl);
SInt32 channelMap4[4] = {2, 0, 1, 3};
AudioConverterSetProperty(ca->converter,
kAudioConverterChannelMap,
sizeof(channelMap4), channelMap4);
} else if (ca->channels == 5) {
SInt32 channelMap5[5] = {2, 0, 1, 3, 4};
AudioConverterSetProperty(ca->converter,
......
......@@ -61,6 +61,24 @@ struct AudioStreamPacketDescription {
};
typedef struct AudioStreamPacketDescription AudioStreamPacketDescription;
typedef UInt32 AudioChannelLabel;
typedef UInt32 AudioChannelLayoutTag;
struct AudioChannelDescription {
AudioChannelLabel mChannelLabel;
UInt32 mChannelFlags;
float mCoordinates[3];
};
typedef struct AudioChannelDescription AudioChannelDescription;
struct AudioChannelLayout {
AudioChannelLayoutTag mChannelLayoutTag;
UInt32 mChannelBitmap;
UInt32 mNumberChannelDescriptions;
AudioChannelDescription mChannelDescriptions[kVariableLengthArray];
};
typedef struct AudioChannelLayout AudioChannelLayout;
typedef OSStatus (*AudioConverterComplexInputDataProc)(
AudioConverterRef inAudioConverter, UInt32 *ioNumberDataPackets,
AudioBufferList *ioData,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册