use of org.easydarwin.audio.EasyAACMuxer in project EasyPlayer-RTMP-Android by EasyDSS.
the class EasyPlayerClient method startRecord1.
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
public synchronized void startRecord1(String path) {
if (mMediaInfo == null || mWidth == 0 || mHeight == 0 || mCSD0 == null || mCSD1 == null)
return;
mRecordingPath = path;
mObject = new EasyAACMuxer(path, mMediaInfo.sample != 0, Integer.MAX_VALUE);
MediaFormat format = new MediaFormat();
format.setInteger(MediaFormat.KEY_WIDTH, mWidth);
format.setInteger(MediaFormat.KEY_HEIGHT, mHeight);
mCSD0.clear();
format.setByteBuffer("csd-0", mCSD0);
mCSD1.clear();
format.setByteBuffer("csd-1", mCSD1);
format.setString(MediaFormat.KEY_MIME, "video/avc");
format.setInteger(MediaFormat.KEY_FRAME_RATE, 0);
// format.setInteger(MediaFormat.KEY_BIT_RATE, mWidth*mHeight*0.7*2);
mObject.addTrack(format, true);
format = new MediaFormat();
int audioObjectType = 2;
int sampleRateIndex = getSampleIndex(mMediaInfo.sample);
if (sampleRateIndex > 0) {
int channelConfig = mMediaInfo.channel;
byte[] audioSpecificConfig = CodecSpecificDataUtil.buildAacAudioSpecificConfig(audioObjectType, sampleRateIndex, channelConfig);
Pair<Integer, Integer> audioParams = CodecSpecificDataUtil.parseAacAudioSpecificConfig(audioSpecificConfig);
// format.setInteger(MediaFormat.KEY_MAX_INPUT_SIZE, 0);
format.setString(MediaFormat.KEY_MIME, MediaFormat.MIMETYPE_AUDIO_AAC);
format.setInteger(MediaFormat.KEY_CHANNEL_COUNT, audioParams.second);
format.setInteger(MediaFormat.KEY_SAMPLE_RATE, audioParams.first);
List<byte[]> bytes = Collections.singletonList(audioSpecificConfig);
for (int j = 0; j < bytes.size(); j++) {
format.setByteBuffer("csd-" + j, ByteBuffer.wrap(bytes.get(j)));
}
mObject.addTrack(format, false);
}
ResultReceiver rr = mRR;
if (rr != null) {
rr.send(RESULT_RECORD_BEGIN, null);
}
}
Aggregations