Skip to content

Commit

Permalink
OboeTester: Add MediaCodecInfo (#1998)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertwu1 authored Apr 16, 2024
1 parent cb6a4d8 commit 36d5c3a
Showing 1 changed file with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import android.media.AudioDeviceCallback;
import android.media.AudioDeviceInfo;
import android.media.AudioManager;
import android.media.MediaCodecInfo;
import android.media.MediaCodecList;
import android.media.MicrophoneInfo;
import android.media.midi.MidiDeviceInfo;
import android.media.midi.MidiManager;
Expand All @@ -39,6 +41,7 @@
import com.mobileer.audio_device.AudioDeviceInfoConverter;

import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -145,6 +148,7 @@ private void reportDeviceInfo(Collection<AudioDeviceInfo> devices) {
report.append(reportAllMicrophones());
report.append(reportUsbDevices());
report.append(reportMidiDevices());
report.append(reportMediaCodecs());
log(report.toString());
}

Expand Down Expand Up @@ -253,6 +257,53 @@ private String reportExtraDeviceInfo() {
return report.toString();
}

public String reportMediaCodecs() {
StringBuffer report = new StringBuffer();
report.append("\n############################");
report.append("\nMedia Codec Device Report:\n");
try {
MediaCodecList mediaCodecList = new MediaCodecList(MediaCodecList.REGULAR_CODECS);
MediaCodecInfo[] mediaCodecInfos = mediaCodecList.getCodecInfos();
for (MediaCodecInfo mediaCodecInfo : mediaCodecInfos) {
report.append("\n==== MediaCodecInfo ========= " + mediaCodecInfo.getName());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
report.append("\nCanonical Name : " + mediaCodecInfo.getCanonicalName());
report.append("\nIs Alias : " + mediaCodecInfo.isAlias());
report.append("\nIs Hardware Accelerated: " + mediaCodecInfo.isHardwareAccelerated());
report.append("\nIs Software Only : " + mediaCodecInfo.isSoftwareOnly());
report.append("\nIs Vendor : " + mediaCodecInfo.isVendor());
}
report.append("\nIs Encoder : " + mediaCodecInfo.isEncoder());
report.append("\nSupported Types : " + Arrays.toString(mediaCodecInfo.getSupportedTypes()));
for(String type : mediaCodecInfo.getSupportedTypes()){
MediaCodecInfo.CodecCapabilities codecCapabilities =
mediaCodecInfo.getCapabilitiesForType(type);
MediaCodecInfo.AudioCapabilities audioCapabilities =
codecCapabilities.getAudioCapabilities();
if (audioCapabilities != null) {
report.append("\nAudio Type: " + type);
report.append("\nBitrate Range: " + audioCapabilities.getBitrateRange());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
report.append("\nInput Channel Count Ranges: " + Arrays.toString(audioCapabilities.getInputChannelCountRanges()));
report.append("\nMin Input Channel Count: " + audioCapabilities.getMinInputChannelCount());
}
report.append("\nMax Input Channel Count: " + audioCapabilities.getMaxInputChannelCount());
report.append("\nSupported Sample Rate Ranges: " + Arrays.toString(audioCapabilities.getSupportedSampleRateRanges()));
report.append("\nSupported Sample Rates: " + Arrays.toString(audioCapabilities.getSupportedSampleRates()));
}
report.append("\nIs Encoder : " + mediaCodecInfo.isEncoder());

}
report.append("\n");
}
} catch (Exception e) {
Log.e(TestAudioActivity.TAG, "Caught ", e);
showErrorToast(e.getMessage());
report.append("\nERROR: " + e.getMessage() + "\n");
}
return report.toString();
}

// Write to scrollable TextView
private void log(final String text) {
runOnUiThread(new Runnable() {
Expand Down

0 comments on commit 36d5c3a

Please sign in to comment.