/* * myLib - https://github.com/taktod/myLib * Copyright (c) 2014 ttProject. All rights reserved. * * Licensed under The MIT license. */ package com.ttProject.frame.aac; import java.nio.ByteBuffer; import com.ttProject.frame.AudioFrame; import com.ttProject.frame.CodecType; import com.ttProject.frame.aac.type.Frame; import com.ttProject.nio.channels.ByteReadChannel; import com.ttProject.nio.channels.IReadChannel; import com.ttProject.util.HexUtil; /** * base of aacFrame * @author taktod */ public abstract class AacFrame extends AudioFrame { /** * get mutedFrame. * @param sampleRate * @param channels * @param bitSize aac doesn't consider this. * @return */ public static Frame getMutedFrame(int sampleRate, int channels, int bitSize) throws Exception { String bufferString = null; if(channels != 2 && channels != 1) { throw new RuntimeException("channel setting is unexpected.:" + channels); } // data is according bitrate. switch(sampleRate) { case 44100: if(channels == 2) { // bufferString = "FFF9508022FFFC21100520A41BFE80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000038"; bufferString = "FFF9508005FFFC21100520A41BC4800000000000000000000000000000000000000000000000000000000000000038"; } else { bufferString = "FFF9504005DFFC01482006F13000000000000000000000000000000000000000000000000000000000000000000E"; } break; case 22050: if(channels == 2) { bufferString = "FFF95C800BBFFC21100520A41BD000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000038"; } else { bufferString = "FFF95C400BBFFC01482006F420000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000E"; } break; case 11025: if(channels == 2) { bufferString = "FFF96880175FFC21416C5401020408A802040811BE540000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000380"; } else { bufferString = "FFF96840175FFC015082D808102046F9B00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000E"; } break; default: throw new RuntimeException("unexpected sampleRate"); } IReadChannel channel = new ByteReadChannel(HexUtil.makeBuffer(bufferString)); Frame frame = new Frame(); frame.minimumLoad(channel); frame.load(channel); return frame; } /** * {@inheritDoc} */ @Override public CodecType getCodecType() { return CodecType.AAC; } /** * ref the body data, global data is missing. * @return buffer */ public abstract ByteBuffer getBuffer(); /** * ref the decoderSpecificInfo * @return decoderSpecificInfo */ public abstract DecoderSpecificInfo getDecoderSpecificInfo(); }