Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package xiphias3.client;
- import javax.media.Buffer;
- import java.io.*;
- /*
- * Author: Xiphias3
- * Date: Oct 19, 2010
- * Time: 10:02:09 AM
- */
- public class ULAWPacket extends Object implements Serializable
- {
- public byte[] abData;
- public long lDuration;
- public long lTimestamp;
- public byte[] abHeader;
- public ULAWPacket() {
- }
- public ULAWPacket(Buffer buffer) {
- abData = (byte[]) buffer.getData();
- lDuration = buffer.getDuration();
- lTimestamp = buffer.getTimeStamp();
- if (buffer.getHeader() != null)
- abHeader = (byte[]) buffer.getHeader();
- }
- public byte[] toByteAray() {
- try {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(baos);
- oos.writeObject(this);
- oos.flush();
- oos.close();
- return baos.toByteArray();
- }
- catch (IOException iox) {
- iox.printStackTrace();
- }
- return null;
- }
- public ULAWPacket fromByteArray(byte[] abPacket) {
- try {
- ByteArrayInputStream bais = new ByteArrayInputStream(abPacket);
- ObjectInputStream ois = new ObjectInputStream(bais);
- ULAWPacket packet = (ULAWPacket) ois.readObject();
- ois.close();
- return packet;
- }
- catch (IOException iox) {
- iox.printStackTrace();
- }
- catch (ClassNotFoundException cnfx) {
- cnfx.printStackTrace();
- }
- return null;
- }
- public String toString() {
- return "Data: " + ((abData == null) ? "Null" : abData.toString()) +
- ", Header: " + ((abHeader == null) ? "Null" : abHeader.toString()) +
- ", Duration: " + lDuration +
- ", Timestamp: " + lTimestamp;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement