/*
* myLib - https://github.com/taktod/myLib
* Copyright (c) 2014 ttProject. All rights reserved.
*
* Licensed under The MIT license.
*/
package com.ttProject.frame.pcmmulaw.type;
import java.nio.ByteBuffer;
import org.apache.log4j.Logger;
import com.ttProject.frame.pcmmulaw.PcmmulawFrame;
import com.ttProject.nio.channels.IReadChannel;
import com.ttProject.util.BufferUtil;
/**
* pcm_mulaw frame
* 160 : 0.02sec 160byte
* 8000 : 1sec
* @author taktod
*/
public class Frame extends PcmmulawFrame {
/** logger */
@SuppressWarnings("unused")
private Logger logger = Logger.getLogger(Frame.class);
/** frameBuffer */
private ByteBuffer frameBuffer = null;
/**
* {@inheritDoc}
*/
@Override
public void minimumLoad(IReadChannel channel) throws Exception {
super.setSize(channel.size());
super.setSampleRate(8000);
super.setSampleNum(getSize());
super.setChannel(1);
super.update();
}
/**
* {@inheritDoc}
*/
@Override
public void load(IReadChannel channel) throws Exception {
frameBuffer = BufferUtil.safeRead(channel, channel.size());
super.update();
}
/**
* {@inheritDoc}
*/
@Override
protected void requestUpdate() throws Exception {
if(frameBuffer == null) {
throw new Exception("frameBuffer is null");
}
super.setData(frameBuffer);
}
/**
* {@inheritDoc}
*/
@Override
public ByteBuffer getPackBuffer() throws Exception{
return getData();
}
}