本文整理汇总了C++中CAEChannelInfo::HasChannel方法的典型用法代码示例。如果您正苦于以下问题:C++ CAEChannelInfo::HasChannel方法的具体用法?C++ CAEChannelInfo::HasChannel怎么用?C++ CAEChannelInfo::HasChannel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CAEChannelInfo
的用法示例。
在下文中一共展示了CAEChannelInfo::HasChannel方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AEChannelMapToAUDIOTRACKChannelMask
static int AEChannelMapToAUDIOTRACKChannelMask(CAEChannelInfo info)
{
info.ResolveChannels(CAEChannelInfo(KnownChannels));
// Detect layouts with 6 channels including one LFE channel
// We currently support the following layouts:
// 5.1 FL+FR+FC+LFE+BL+BR
// 5.1(side) FL+FR+FC+LFE+SL+SR
// According to CEA-861-D only RR and RL are defined
// Therefore we let Android decide about the 5.1 mapping
// For 8 channel layouts including one LFE channel
// we leave the same decision to Android
if (info.Count() == 6 && info.HasChannel(AE_CH_LFE))
return CJNIAudioFormat::CHANNEL_OUT_5POINT1;
if (info.Count() == 8 && info.HasChannel(AE_CH_LFE))
return CJNIAudioFormat::CHANNEL_OUT_7POINT1_SURROUND;
int atMask = 0;
for (unsigned int i = 0; i < info.Count(); i++)
atMask |= AEChannelToAUDIOTRACKChannel(info[i]);
return atMask;
}
示例2: GetAVChannelLayout
uint64_t CAEUtil::GetAVChannelLayout(const CAEChannelInfo &info)
{
uint64_t channelLayout = 0;
if (info.HasChannel(AE_CH_FL)) channelLayout |= AV_CH_FRONT_LEFT;
if (info.HasChannel(AE_CH_FR)) channelLayout |= AV_CH_FRONT_RIGHT;
if (info.HasChannel(AE_CH_FC)) channelLayout |= AV_CH_FRONT_CENTER;
if (info.HasChannel(AE_CH_LFE)) channelLayout |= AV_CH_LOW_FREQUENCY;
if (info.HasChannel(AE_CH_BL)) channelLayout |= AV_CH_BACK_LEFT;
if (info.HasChannel(AE_CH_BR)) channelLayout |= AV_CH_BACK_RIGHT;
if (info.HasChannel(AE_CH_FLOC)) channelLayout |= AV_CH_FRONT_LEFT_OF_CENTER;
if (info.HasChannel(AE_CH_FROC)) channelLayout |= AV_CH_FRONT_RIGHT_OF_CENTER;
if (info.HasChannel(AE_CH_BC)) channelLayout |= AV_CH_BACK_CENTER;
if (info.HasChannel(AE_CH_SL)) channelLayout |= AV_CH_SIDE_LEFT;
if (info.HasChannel(AE_CH_SR)) channelLayout |= AV_CH_SIDE_RIGHT;
if (info.HasChannel(AE_CH_TC)) channelLayout |= AV_CH_TOP_CENTER;
if (info.HasChannel(AE_CH_TFL)) channelLayout |= AV_CH_TOP_FRONT_LEFT;
if (info.HasChannel(AE_CH_TFC)) channelLayout |= AV_CH_TOP_FRONT_CENTER;
if (info.HasChannel(AE_CH_TFR)) channelLayout |= AV_CH_TOP_FRONT_RIGHT;
if (info.HasChannel(AE_CH_TBL)) channelLayout |= AV_CH_TOP_BACK_LEFT;
if (info.HasChannel(AE_CH_TBC)) channelLayout |= AV_CH_TOP_BACK_CENTER;
if (info.HasChannel(AE_CH_TBR)) channelLayout |= AV_CH_TOP_BACK_RIGHT;
return channelLayout;
}
示例3: Initialize
bool CAERemap::Initialize(CAEChannelInfo input, CAEChannelInfo output, bool finalStage, bool forceNormalize/* = false */, enum AEStdChLayout stdChLayout/* = AE_CH_LAYOUT_INVALID */)
{
if (!input.Count() || !output.Count())
return false;
/* build the downmix matrix */
memset(m_mixInfo, 0, sizeof(m_mixInfo));
m_output = output;
/* figure which channels we have */
for (unsigned int o = 0; o < output.Count(); ++o)
m_mixInfo[output[o]].in_dst = true;
/* flag invalid channels for forced downmix */
if (stdChLayout != AE_CH_LAYOUT_INVALID)
{
CAEChannelInfo layout = stdChLayout;
for (unsigned int o = 0; o < output.Count(); ++o)
if (!layout.HasChannel(output[o]))
m_mixInfo[output[o]].in_dst = false;
}
m_outChannels = output.Count();
/* lookup the channels that exist in the output */
for (unsigned int i = 0; i < input.Count(); ++i)
{
AEMixInfo *info = &m_mixInfo[input[i]];
AEMixLevel *lvl = &info->srcIndex[info->srcCount++];
info->in_src = true;
lvl->index = i;
lvl->level = 1.0f;
if (!info->in_dst)
{
for (unsigned int o = 0; o < output.Count(); ++o)
{
if (input[i] == output[o])
{
info->outIndex = o;
break;
}
}
}
m_inChannels = i;
}
++m_inChannels;
/* the final stage does not need any down/upmix */
if (finalStage)
return true;
/* downmix from the specified channel to the specified list of channels */
#define RM(from, ...) \
static AEChannel downmix_##from[] = {__VA_ARGS__, AE_CH_NULL}; \
ResolveMix(from, CAEChannelInfo(downmix_##from));
/*
the order of this is important as we can not mix channels
into ones that have already been resolved... eg
TBR -> BR
TBC -> TBL & TBR
TBR will get resolved to BR, and then TBC will get
resolved to TBL, but since TBR has been resolved it will
never make it to the output. The order has to be reversed
as the TBC center depends on the TBR downmix... eg
TBC -> TBL & TBR
TBR -> BR
if for any reason out of order mapping becomes required
looping this list should resolve the channels.
*/
RM(AE_CH_TBC , AE_CH_TBL, AE_CH_TBR);
RM(AE_CH_TBR , AE_CH_BR);
RM(AE_CH_TBL , AE_CH_BL);
RM(AE_CH_TC , AE_CH_TFL, AE_CH_TFR);
RM(AE_CH_TFC , AE_CH_TFL, AE_CH_TFR);
RM(AE_CH_TFR , AE_CH_FR);
RM(AE_CH_TFL , AE_CH_FL);
RM(AE_CH_SR , AE_CH_BR, AE_CH_FR);
RM(AE_CH_SL , AE_CH_BL, AE_CH_FL);
RM(AE_CH_BC , AE_CH_BL, AE_CH_BR);
RM(AE_CH_FROC, AE_CH_FR, AE_CH_FC);
RM(AE_CH_FLOC, AE_CH_FL, AE_CH_FC);
RM(AE_CH_BL , AE_CH_FL);
RM(AE_CH_BR , AE_CH_FR);
RM(AE_CH_LFE , AE_CH_FL, AE_CH_FR);
RM(AE_CH_FL , AE_CH_FC);
RM(AE_CH_FR , AE_CH_FC);
RM(AE_CH_BROC, AE_CH_BR, AE_CH_BC);
RM(AE_CH_BLOC, AE_CH_BL, AE_CH_BC);
/* since everything eventually mixes down to FC we need special handling for it */
if (m_mixInfo[AE_CH_FC].in_src)
{
/* if there is no output FC channel, try to mix it the best possible way */
if (!m_mixInfo[AE_CH_FC].in_dst)
//.........这里部分代码省略.........
示例4: ResolveChannels
void CAEChannelInfo::ResolveChannels(const CAEChannelInfo& rhs)
{
/* mono gets upmixed to dual mono */
if (m_channelCount == 1 && m_channels[0] == AE_CH_FC)
{
Reset();
*this += AE_CH_FL;
*this += AE_CH_FR;
return;
}
bool srcHasSL = false;
bool srcHasSR = false;
bool srcHasRL = false;
bool srcHasRR = false;
bool srcHasBC = false;
bool dstHasSL = false;
bool dstHasSR = false;
bool dstHasRL = false;
bool dstHasRR = false;
bool dstHasBC = false;
for (unsigned int c = 0; c < rhs.m_channelCount; ++c)
switch(rhs.m_channels[c])
{
case AE_CH_SL: dstHasSL = true; break;
case AE_CH_SR: dstHasSR = true; break;
case AE_CH_BL: dstHasRL = true; break;
case AE_CH_BR: dstHasRR = true; break;
case AE_CH_BC: dstHasBC = true; break;
default:
break;
}
CAEChannelInfo newInfo;
for (unsigned int i = 0; i < m_channelCount; ++i)
{
switch (m_channels[i])
{
case AE_CH_SL: srcHasSL = true; break;
case AE_CH_SR: srcHasSR = true; break;
case AE_CH_BL: srcHasRL = true; break;
case AE_CH_BR: srcHasRR = true; break;
case AE_CH_BC: srcHasBC = true; break;
default:
break;
}
bool found = false;
for (unsigned int c = 0; c < rhs.m_channelCount; ++c)
if (m_channels[i] == rhs.m_channels[c])
{
found = true;
break;
}
if (found)
newInfo += m_channels[i];
}
/* we need to ensure we end up with rear or side channels for downmix to work */
if (srcHasSL && !dstHasSL && dstHasRL && !newInfo.HasChannel(AE_CH_BL))
newInfo += AE_CH_BL;
if (srcHasSR && !dstHasSR && dstHasRR && !newInfo.HasChannel(AE_CH_BR))
newInfo += AE_CH_BR;
if (srcHasRL && !dstHasRL && dstHasSL && !newInfo.HasChannel(AE_CH_SL))
newInfo += AE_CH_SL;
if (srcHasRR && !dstHasRR && dstHasSR && !newInfo.HasChannel(AE_CH_SR))
newInfo += AE_CH_SR;
// mix back center if not available in destination layout
// prefer mixing into backs if available
if (srcHasBC && !dstHasBC)
{
if (dstHasRL && !newInfo.HasChannel(AE_CH_BL))
newInfo += AE_CH_BL;
else if (dstHasSL && !newInfo.HasChannel(AE_CH_SL))
newInfo += AE_CH_SL;
if (dstHasRR && !newInfo.HasChannel(AE_CH_BR))
newInfo += AE_CH_BR;
else if (dstHasSR && !newInfo.HasChannel(AE_CH_SR))
newInfo += AE_CH_SR;
}
*this = newInfo;
}
示例5: GetAEChannelMap
//Note: in multichannel mode CA will either pull 2 channels of data (stereo) or 6/8 channels of data
//(every speaker setup with more then 2 speakers). The difference between the number of real speakers
//and 6/8 channels needs to be padded with unknown channels so that the sample size fits 6/8 channels
//
//device [in] - the device whose channel layout should be used
//channelMap [in/out] - if filled it will it indicates that we are called from initialize and we log the requested map, out returns the channelMap for device
//channelsPerFrame [in] - the number of channels this device is configured to (e.x. 2 or 6/8)
void AEDeviceEnumerationOSX::GetAEChannelMap(CAEChannelInfo &channelMap, unsigned int channelsPerFrame) const
{
CCoreAudioChannelLayout calayout;
bool logMapping = channelMap.Count() > 0; // only log if the engine requests a layout during init
bool mapAvailable = false;
unsigned int numberChannelsInDeviceLayout = CA_MAX_CHANNELS; // default number of channels from CAChannelMap
AudioChannelLayout *layout = NULL;
// try to fetch either the multichannel or the stereo channel layout from the device
if (channelsPerFrame == 2 || channelMap.Count() == 2)
mapAvailable = m_caDevice.GetPreferredChannelLayoutForStereo(calayout);
else
mapAvailable = m_caDevice.GetPreferredChannelLayout(calayout);
// if a map was fetched - check if it is usable
if (mapAvailable)
{
layout = calayout;
if (layout == NULL || layout->mChannelLayoutTag != kAudioChannelLayoutTag_UseChannelDescriptions)
mapAvailable = false;// wrong map format
else
numberChannelsInDeviceLayout = layout->mNumberChannelDescriptions;
}
// start the mapping action
// the number of channels to be added to the outgoing channelmap
// this is CA_MAX_CHANNELS at max and might be lower for some output devices (channelsPerFrame)
unsigned int numChannelsToMap = std::min((unsigned int)CA_MAX_CHANNELS, (unsigned int)channelsPerFrame);
// if there was a map fetched we force the number of
// channels to map to channelsPerFrame (this allows mapping
// of more then CA_MAX_CHANNELS if needed)
if (mapAvailable)
numChannelsToMap = channelsPerFrame;
std::string layoutStr;
if (logMapping)
{
CLog::Log(LOGDEBUG, "%s Engine requests layout %s", __FUNCTION__, ((std::string)channelMap).c_str());
if (mapAvailable)
CLog::Log(LOGDEBUG, "%s trying to map to %s layout: %s", __FUNCTION__, channelsPerFrame == 2 ? "stereo" : "multichannel", calayout.ChannelLayoutToString(*layout, layoutStr));
else
CLog::Log(LOGDEBUG, "%s no map available - using static multichannel map layout", __FUNCTION__);
}
channelMap.Reset();// start with an empty map
for (unsigned int channel = 0; channel < numChannelsToMap; channel++)
{
// we only try to map channels which are defined in the device layout
enum AEChannel currentChannel;
if (channel < numberChannelsInDeviceLayout)
{
// get the channel from the fetched map
if (mapAvailable)
currentChannel = caChannelToAEChannel(layout->mChannelDescriptions[channel].mChannelLabel);
else// get the channel from the default map
currentChannel = CAChannelMap[channel];
}
else// fill with unknown channels
currentChannel = caChannelToAEChannel(kAudioChannelLabel_Unknown);
if(!channelMap.HasChannel(currentChannel))// only add if not already added
channelMap += currentChannel;
}
if (logMapping)
CLog::Log(LOGDEBUG, "%s mapped channels to layout %s", __FUNCTION__, ((std::string)channelMap).c_str());
}