下面列出了怎么用android.media.MediaCodecInfo.AudioCapabilities的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* Whether the decoder supports audio with a given sample rate.
* <p>
* Must not be called if the device SDK version is less than 21.
*
* @param sampleRate The sample rate in Hz.
* @return Whether the decoder supports audio with the given sample rate.
*/
@TargetApi(21)
public boolean isAudioSampleRateSupportedV21(int sampleRate) {
if (capabilities == null) {
logNoSupport("sampleRate.caps");
return false;
}
AudioCapabilities audioCapabilities = capabilities.getAudioCapabilities();
if (audioCapabilities == null) {
logNoSupport("sampleRate.aCaps");
return false;
}
if (!audioCapabilities.isSampleRateSupported(sampleRate)) {
logNoSupport("sampleRate.support, " + sampleRate);
return false;
}
return true;
}
/**
* Whether the decoder supports audio with a given channel count.
* <p>
* Must not be called if the device SDK version is less than 21.
*
* @param channelCount The channel count.
* @return Whether the decoder supports audio with the given channel count.
*/
@TargetApi(21)
public boolean isAudioChannelCountSupportedV21(int channelCount) {
if (capabilities == null) {
logNoSupport("channelCount.caps");
return false;
}
AudioCapabilities audioCapabilities = capabilities.getAudioCapabilities();
if (audioCapabilities == null) {
logNoSupport("channelCount.aCaps");
return false;
}
int maxInputChannelCount = adjustMaxInputChannelCount(name, mimeType,
audioCapabilities.getMaxInputChannelCount());
if (maxInputChannelCount < channelCount) {
logNoSupport("channelCount.support, " + channelCount);
return false;
}
return true;
}
/**
* Whether the decoder supports audio with a given sample rate.
* <p>
* Must not be called if the device SDK version is less than 21.
*
* @param sampleRate The sample rate in Hz.
* @return Whether the decoder supports audio with the given sample rate.
*/
@TargetApi(21)
public boolean isAudioSampleRateSupportedV21(int sampleRate) {
if (capabilities == null) {
logNoSupport("sampleRate.caps");
return false;
}
AudioCapabilities audioCapabilities = capabilities.getAudioCapabilities();
if (audioCapabilities == null) {
logNoSupport("sampleRate.aCaps");
return false;
}
if (!audioCapabilities.isSampleRateSupported(sampleRate)) {
logNoSupport("sampleRate.support, " + sampleRate);
return false;
}
return true;
}
/**
* Whether the decoder supports audio with a given channel count.
* <p>
* Must not be called if the device SDK version is less than 21.
*
* @param channelCount The channel count.
* @return Whether the decoder supports audio with the given channel count.
*/
@TargetApi(21)
public boolean isAudioChannelCountSupportedV21(int channelCount) {
if (capabilities == null) {
logNoSupport("channelCount.caps");
return false;
}
AudioCapabilities audioCapabilities = capabilities.getAudioCapabilities();
if (audioCapabilities == null) {
logNoSupport("channelCount.aCaps");
return false;
}
int maxInputChannelCount = adjustMaxInputChannelCount(name, mimeType,
audioCapabilities.getMaxInputChannelCount());
if (maxInputChannelCount < channelCount) {
logNoSupport("channelCount.support, " + channelCount);
return false;
}
return true;
}
/**
* Whether the decoder supports audio with a given sample rate.
* <p>
* Must not be called if the device SDK version is less than 21.
*
* @param sampleRate The sample rate in Hz.
* @return Whether the decoder supports audio with the given sample rate.
*/
@TargetApi(21)
public boolean isAudioSampleRateSupportedV21(int sampleRate) {
if (capabilities == null) {
logNoSupport("sampleRate.caps");
return false;
}
AudioCapabilities audioCapabilities = capabilities.getAudioCapabilities();
if (audioCapabilities == null) {
logNoSupport("sampleRate.aCaps");
return false;
}
if (!audioCapabilities.isSampleRateSupported(sampleRate)) {
logNoSupport("sampleRate.support, " + sampleRate);
return false;
}
return true;
}
/**
* Whether the decoder supports audio with a given channel count.
* <p>
* Must not be called if the device SDK version is less than 21.
*
* @param channelCount The channel count.
* @return Whether the decoder supports audio with the given channel count.
*/
@TargetApi(21)
public boolean isAudioChannelCountSupportedV21(int channelCount) {
if (capabilities == null) {
logNoSupport("channelCount.caps");
return false;
}
AudioCapabilities audioCapabilities = capabilities.getAudioCapabilities();
if (audioCapabilities == null) {
logNoSupport("channelCount.aCaps");
return false;
}
int maxInputChannelCount = adjustMaxInputChannelCount(name, mimeType,
audioCapabilities.getMaxInputChannelCount());
if (maxInputChannelCount < channelCount) {
logNoSupport("channelCount.support, " + channelCount);
return false;
}
return true;
}
/**
* Whether the decoder supports audio with a given sample rate.
* <p>
* Must not be called if the device SDK version is less than 21.
*
* @param sampleRate The sample rate in Hz.
* @return Whether the decoder supports audio with the given sample rate.
*/
@TargetApi(21)
public boolean isAudioSampleRateSupportedV21(int sampleRate) {
if (capabilities == null) {
logNoSupport("sampleRate.caps");
return false;
}
AudioCapabilities audioCapabilities = capabilities.getAudioCapabilities();
if (audioCapabilities == null) {
logNoSupport("sampleRate.aCaps");
return false;
}
if (!audioCapabilities.isSampleRateSupported(sampleRate)) {
logNoSupport("sampleRate.support, " + sampleRate);
return false;
}
return true;
}
/**
* Whether the decoder supports audio with a given channel count.
* <p>
* Must not be called if the device SDK version is less than 21.
*
* @param channelCount The channel count.
* @return Whether the decoder supports audio with the given channel count.
*/
@TargetApi(21)
public boolean isAudioChannelCountSupportedV21(int channelCount) {
if (capabilities == null) {
logNoSupport("channelCount.caps");
return false;
}
AudioCapabilities audioCapabilities = capabilities.getAudioCapabilities();
if (audioCapabilities == null) {
logNoSupport("channelCount.aCaps");
return false;
}
if (audioCapabilities.getMaxInputChannelCount() < channelCount) {
logNoSupport("channelCount.support, " + channelCount);
return false;
}
return true;
}
/**
* Whether the decoder supports audio with a given sample rate.
* <p>
* Must not be called if the device SDK version is less than 21.
*
* @param sampleRate The sample rate in Hz.
* @return Whether the decoder supports audio with the given sample rate.
*/
@TargetApi(21)
public boolean isAudioSampleRateSupportedV21(int sampleRate) {
if (capabilities == null) {
logNoSupport("sampleRate.caps");
return false;
}
AudioCapabilities audioCapabilities = capabilities.getAudioCapabilities();
if (audioCapabilities == null) {
logNoSupport("sampleRate.aCaps");
return false;
}
if (!audioCapabilities.isSampleRateSupported(sampleRate)) {
logNoSupport("sampleRate.support, " + sampleRate);
return false;
}
return true;
}
/**
* Whether the decoder supports audio with a given channel count.
* <p>
* Must not be called if the device SDK version is less than 21.
*
* @param channelCount The channel count.
* @return Whether the decoder supports audio with the given channel count.
*/
@TargetApi(21)
public boolean isAudioChannelCountSupportedV21(int channelCount) {
if (capabilities == null) {
logNoSupport("channelCount.caps");
return false;
}
AudioCapabilities audioCapabilities = capabilities.getAudioCapabilities();
if (audioCapabilities == null) {
logNoSupport("channelCount.aCaps");
return false;
}
int maxInputChannelCount = adjustMaxInputChannelCount(name, mimeType,
audioCapabilities.getMaxInputChannelCount());
if (maxInputChannelCount < channelCount) {
logNoSupport("channelCount.support, " + channelCount);
return false;
}
return true;
}
/**
* Whether the decoder supports audio with a given sample rate.
* <p>
* Must not be called if the device SDK version is less than 21.
*
* @param sampleRate The sample rate in Hz.
* @return Whether the decoder supports audio with the given sample rate.
*/
@TargetApi(21)
public boolean isAudioSampleRateSupportedV21(int sampleRate) {
if (capabilities == null) {
logNoSupport("sampleRate.caps");
return false;
}
AudioCapabilities audioCapabilities = capabilities.getAudioCapabilities();
if (audioCapabilities == null) {
logNoSupport("sampleRate.aCaps");
return false;
}
if (!audioCapabilities.isSampleRateSupported(sampleRate)) {
logNoSupport("sampleRate.support, " + sampleRate);
return false;
}
return true;
}
/**
* Whether the decoder supports audio with a given channel count.
* <p>
* Must not be called if the device SDK version is less than 21.
*
* @param channelCount The channel count.
* @return Whether the decoder supports audio with the given channel count.
*/
@TargetApi(21)
public boolean isAudioChannelCountSupportedV21(int channelCount) {
if (capabilities == null) {
logNoSupport("channelCount.caps");
return false;
}
AudioCapabilities audioCapabilities = capabilities.getAudioCapabilities();
if (audioCapabilities == null) {
logNoSupport("channelCount.aCaps");
return false;
}
int maxInputChannelCount = adjustMaxInputChannelCount(name, mimeType,
audioCapabilities.getMaxInputChannelCount());
if (maxInputChannelCount < channelCount) {
logNoSupport("channelCount.support, " + channelCount);
return false;
}
return true;
}