org.jaudiotagger.tag.id3
Class ID3Unsynchronization

java.lang.Object
  extended by org.jaudiotagger.tag.id3.ID3Unsynchronization

public class ID3Unsynchronization
extends java.lang.Object

Performs unsynchronization and synchronization tasks on a buffer.

Is currently required for V23Tags and V24Frames


Field Summary
static java.util.logging.Logger logger
           
 
Constructor Summary
ID3Unsynchronization()
           
 
Method Summary
static boolean requiresUnsynchronization(byte[] abySource)
          Check if a byte array will require unsynchronization before being written as a tag.
static java.nio.ByteBuffer synchronize(java.nio.ByteBuffer source)
          Synchronize an array of bytes, this should only be called if it has been determined the tag is unsynchronised

Any patterns of the form $FF $00 should be replaced by $FF

static byte[] unsynchronize(byte[] abySource)
          Unsynchronize an array of bytes, this should only be called if the decision has already been made to unsynchronize the byte array

In order to prevent a media player from incorrectly interpreting the contents of a tag, all $FF bytes followed by a byte with value >=224 must be followed by a $00 byte (thus, $FF $F0 sequences become $FF $00 $F0).

 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

public static java.util.logging.Logger logger
Constructor Detail

ID3Unsynchronization

public ID3Unsynchronization()
Method Detail

requiresUnsynchronization

public static boolean requiresUnsynchronization(byte[] abySource)
Check if a byte array will require unsynchronization before being written as a tag. If the byte array contains any $FF $E0 bytes, then it will require unsynchronization.

Parameters:
abySource - the byte array to be examined
Returns:
true if unsynchronization is required, false otherwise

unsynchronize

public static byte[] unsynchronize(byte[] abySource)
Unsynchronize an array of bytes, this should only be called if the decision has already been made to unsynchronize the byte array

In order to prevent a media player from incorrectly interpreting the contents of a tag, all $FF bytes followed by a byte with value >=224 must be followed by a $00 byte (thus, $FF $F0 sequences become $FF $00 $F0). Additionally because unsynchronisation is being applied any existing $FF $00 have to be converted to $FF $00 $00

Parameters:
abySource - a byte array to be unsynchronized
Returns:
a unsynchronized representation of the source

synchronize

public static java.nio.ByteBuffer synchronize(java.nio.ByteBuffer source)
Synchronize an array of bytes, this should only be called if it has been determined the tag is unsynchronised

Any patterns of the form $FF $00 should be replaced by $FF

Parameters:
source - a ByteBuffer to be unsynchronized
Returns:
a synchronized representation of the source