Skip to content

Commit

Permalink
Add audio codec configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
yrom committed Dec 5, 2017
1 parent d5ec173 commit 7bdf6f1
Show file tree
Hide file tree
Showing 7 changed files with 539 additions and 236 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "net.yrom.screenrecorder"
minSdkVersion 21
targetSdkVersion 26
versionCode 9
versionName '2.0'
versionCode 10
versionName '2.1'
}

compileOptions {
Expand Down
19 changes: 16 additions & 3 deletions app/src/main/java/net/yrom/screenrecorder/AudioEncodeConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package net.yrom.screenrecorder;

import android.media.MediaCodecInfo;
import android.media.MediaFormat;

import java.util.Objects;
Expand All @@ -31,21 +30,35 @@ public class AudioEncodeConfig {
final int bitRate;
final int sampleRate;
final int channelCount;
final int profile;

public AudioEncodeConfig(String codecName, String mimeType,
int bitRate, int sampleRate, int channelCount) {
int bitRate, int sampleRate, int channelCount, int profile) {
this.codecName = codecName;
this.mimeType = Objects.requireNonNull(mimeType);
this.bitRate = bitRate;
this.sampleRate = sampleRate;
this.channelCount = channelCount;
this.profile = profile;
}

MediaFormat toFormat() {
MediaFormat format = MediaFormat.createAudioFormat(mimeType, sampleRate, channelCount);
format.setInteger(MediaFormat.KEY_AAC_PROFILE, MediaCodecInfo.CodecProfileLevel.AACObjectHE);
format.setInteger(MediaFormat.KEY_AAC_PROFILE, profile);
format.setInteger(MediaFormat.KEY_BIT_RATE, bitRate);
//format.setInteger(MediaFormat.KEY_MAX_INPUT_SIZE, 4096 * 4);
return format;
}

@Override
public String toString() {
return "AudioEncodeConfig{" +
"codecName='" + codecName + '\'' +
", mimeType='" + mimeType + '\'' +
", bitRate=" + bitRate +
", sampleRate=" + sampleRate +
", channelCount=" + channelCount +
", profile=" + profile +
'}';
}
}
Loading

0 comments on commit 7bdf6f1

Please sign in to comment.