本文整理汇总了Java中org.jaudiotagger.audio.generic.Utils类的典型用法代码示例。如果您正苦于以下问题:Java Utils类的具体用法?Java Utils怎么用?Java Utils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Utils类属于org.jaudiotagger.audio.generic包,在下文中一共展示了Utils类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getRawContentDataOnly
import org.jaudiotagger.audio.generic.Utils; //导入依赖的package包/类
/**
* Get raw content for the data component only
*
* @return
* @throws UnsupportedEncodingException
*/
public byte[] getRawContentDataOnly() throws UnsupportedEncodingException
{
logger.fine("Getting Raw data for:" + getId());
try
{
//Create Data Box
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] data = getDataBytes();
baos.write(Utils.getSizeBEInt32(Mp4DataBox.DATA_HEADER_LENGTH + data.length));
baos.write(Mp4DataBox.IDENTIFIER.getBytes(StandardCharsets.ISO_8859_1));
baos.write(new byte[]{0});
baos.write(new byte[]{0, 0, (byte) getFieldType().getFileClassId()});
baos.write(new byte[]{0, 0, 0, 0});
baos.write(data);
return baos.toByteArray();
}
catch (IOException ioe)
{
//This should never happen as were not actually writing to/from a file
throw new RuntimeException(ioe);
}
}
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:29,代码来源:Mp4TagField.java
示例2: getRawContentDataOnly
import org.jaudiotagger.audio.generic.Utils; //导入依赖的package包/类
@Override
public byte[] getRawContentDataOnly() throws UnsupportedEncodingException
{
logger.fine("Getting Raw data for:" + getId());
try
{
//Create DataBox data
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] dataRawData = content.getBytes(getEncoding());
baos.write(Utils.getSizeBEInt32(Mp4BoxHeader.HEADER_LENGTH + Mp4DataBox.PRE_DATA_LENGTH + dataRawData.length));
baos.write(Mp4DataBox.IDENTIFIER.getBytes(StandardCharsets.ISO_8859_1));
baos.write(new byte[]{0});
baos.write(new byte[]{0, 0, (byte) getFieldType().getFileClassId()});
baos.write(new byte[]{0, 0, 0, 0});
baos.write(dataRawData);
return baos.toByteArray();
}
catch (IOException ioe)
{
//This should never happen as were not actually writing to/from a file
throw new RuntimeException(ioe);
}
}
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:24,代码来源:Mp4TagReverseDnsField.java
示例3: getRawContent
import org.jaudiotagger.audio.generic.Utils; //导入依赖的package包/类
public byte[] getRawContent() throws UnsupportedEncodingException
{
logger.fine("Getting Raw data for:" + getId());
try
{
ByteArrayOutputStream outerbaos = new ByteArrayOutputStream();
outerbaos.write(Utils.getSizeBEInt32(Mp4BoxHeader.HEADER_LENGTH + dataSize));
outerbaos.write(getId().getBytes(StandardCharsets.ISO_8859_1));
outerbaos.write(dataBytes);
return outerbaos.toByteArray();
}
catch (IOException ioe)
{
//This should never happen as were not actually writing to/from a file
throw new RuntimeException(ioe);
}
}
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:18,代码来源:Mp4TagRawBinaryField.java
示例4: getDataBytes
import org.jaudiotagger.audio.generic.Utils; //导入依赖的package包/类
/**
* Recreate the raw data content from the list of numbers
*
* @return
*/
protected byte[] getDataBytes()
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
for (Short number : numbers)
{
try
{
baos.write(Utils.getSizeBEInt16(number));
}
catch (IOException e)
{
//This should never happen because we are not writing to file at this point.
throw new RuntimeException(e);
}
}
return baos.toByteArray();
}
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:23,代码来源:Mp4TagTextNumberField.java
示例5: Mp4MeanBox
import org.jaudiotagger.audio.generic.Utils; //导入依赖的package包/类
/**
* @param header parentHeader info
* @param dataBuffer data of box (doesnt include parentHeader data)
*/
public Mp4MeanBox(Mp4BoxHeader header, ByteBuffer dataBuffer)
{
this.header = header;
//Double check
if (!header.getId().equals(IDENTIFIER))
{
throw new RuntimeException("Unable to process data box because identifier is:" + header.getId());
}
//Make slice so operations here don't effect position of main buffer
this.dataBuffer = dataBuffer.slice();
//issuer
this.issuer = Utils.getString(this.dataBuffer, PRE_DATA_LENGTH, header.getDataLength() - PRE_DATA_LENGTH, header.getEncoding());
}
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:22,代码来源:Mp4MeanBox.java
示例6: Mp4NameBox
import org.jaudiotagger.audio.generic.Utils; //导入依赖的package包/类
/**
* @param header parentHeader info
* @param dataBuffer data of box (doesnt include parentHeader data)
*/
public Mp4NameBox(Mp4BoxHeader header, ByteBuffer dataBuffer)
{
this.header = header;
//Double check
if (!header.getId().equals(IDENTIFIER))
{
throw new RuntimeException("Unable to process name box because identifier is:" + header.getId());
}
//Make slice so operations here don't effect position of main buffer
this.dataBuffer = dataBuffer.slice();
//issuer
this.name = Utils.getString(this.dataBuffer, PRE_DATA_LENGTH, header.getDataLength() - PRE_DATA_LENGTH, header.getEncoding());
}
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:21,代码来源:Mp4NameBox.java
示例7: getBytes
import org.jaudiotagger.audio.generic.Utils; //导入依赖的package包/类
public byte[] getBytes() {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
baos.write(Utils.getSizeBEInt32(pictureType));
baos.write(Utils.getSizeBEInt32(mimeType.length()));
baos.write(mimeType.getBytes("ISO-8859-1"));
baos.write(Utils.getSizeBEInt32(description.length()));
baos.write(description.getBytes("UTF-8"));
baos.write(Utils.getSizeBEInt32(width));
baos.write(Utils.getSizeBEInt32(height));
baos.write(Utils.getSizeBEInt32(colourDepth));
baos.write(Utils.getSizeBEInt32(indexedColouredCount));
baos.write(Utils.getSizeBEInt32(imageData.length));
baos.write(imageData);
return baos.toByteArray();
} catch (IOException ioe) {
throw new RuntimeException(ioe.getMessage());
}
}
开发者ID:openaudible,项目名称:openaudible,代码行数:21,代码来源:MetadataBlockDataPicture.java
示例8: deleteTagChunk
import org.jaudiotagger.audio.generic.Utils; //导入依赖的package包/类
/**
* <p>Deletes the given ID3-{@link Tag}/{@link Chunk} from the file by moving all following chunks up.</p>
* <pre>
* [chunk][-id3-][chunk][chunk]
* [chunk] <<--- [chunk][chunk]
* [chunk][chunk][chunk]
* </pre>
*
* @param fc, filechannel
* @param existingTag existing tag
* @param tagChunkHeader existing chunk header for the tag
* @throws IOException if something goes wrong
*/
private void deleteTagChunk(FileChannel fc, final AiffTag existingTag, final ChunkHeader tagChunkHeader, String fileName) throws IOException {
int lengthTagChunk = (int) tagChunkHeader.getSize() + ChunkHeader.CHUNK_HEADER_SIZE;
if (Utils.isOddLength(lengthTagChunk)) {
if (existingTag.getStartLocationInFileOfId3Chunk() + lengthTagChunk < fc.size()) {
lengthTagChunk++;
}
}
final long newLength = fc.size() - lengthTagChunk;
logger.severe(fileName + " Size of id3 chunk to delete is:" + lengthTagChunk + ":Location:" + existingTag.getStartLocationInFileOfId3Chunk());
// position for reading after the id3 tag
fc.position(existingTag.getStartLocationInFileOfId3Chunk() + lengthTagChunk);
deleteTagChunkUsingSmallByteBufferSegments(existingTag, fc, newLength, lengthTagChunk);
// truncate the file after the last chunk
logger.severe(fileName + " Setting new length to:" + newLength);
fc.truncate(newLength);
}
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:32,代码来源:AiffTagWriter.java
示例9: readChunk
import org.jaudiotagger.audio.generic.Utils; //导入依赖的package包/类
/**
* Reads a chunk and extracts information.
*
* @return <code>false</code> if the chunk is structurally
* invalid, otherwise <code>true</code>
*/
public boolean readChunk() throws IOException
{
final int numComments = Utils.u(chunkData.getShort());
//For each comment
for (int i = 0; i < numComments; i++)
{
final long timestamp = Utils.u(chunkData.getInt());
final Date jTimestamp = AiffUtil.timestampToDate(timestamp);
final int marker = Utils.u(chunkData.getShort());
final int count = Utils.u(chunkData.getShort());
// Append a timestamp to the comment
final String text = Utils.getString(chunkData, 0, count, StandardCharsets.ISO_8859_1) + " " + AiffUtil.formatDate(jTimestamp);
if (count % 2 != 0) {
// if count is odd, text is padded with an extra byte that we need to consume
chunkData.get();
}
aiffHeader.addComment(text);
}
return true;
}
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:28,代码来源:CommentsChunk.java
示例10: readChunk
import org.jaudiotagger.audio.generic.Utils; //导入依赖的package包/类
/**
* Reads a chunk and puts an Application property into
* the RepInfo object.
*
* @return <code>false</code> if the chunk is structurally
* invalid, otherwise <code>true</code>
*/
public boolean readChunk() throws IOException
{
final String applicationSignature = Utils.readFourBytesAsChars(chunkData);
String applicationName = null;
/* If the application signature is 'pdos' or 'stoc',
* then the beginning of the data area is a Pascal
* string naming the application. Otherwise, we
* ignore the data. ('pdos' is for Apple II
* applications, 'stoc' for the entire non-Apple world.)
*/
if (SIGNATURE_STOC.equals(applicationSignature) || SIGNATURE_PDOS.equals(applicationSignature))
{
applicationName = Utils.readPascalString(chunkData);
}
aiffHeader.addApplicationIdentifier(applicationSignature + ": " + applicationName);
return true;
}
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:27,代码来源:ApplicationChunk.java
示例11: isValidHeader
import org.jaudiotagger.audio.generic.Utils; //导入依赖的package包/类
public static boolean isValidHeader(FileChannel fc) throws IOException, CannotReadException
{
if (fc.size() - fc.position() < HEADER_LENGTH)
{
throw new CannotReadException("This is not a WAV File (<12 bytes)");
}
ByteBuffer headerBuffer = Utils.readFileDataIntoBufferLE(fc, HEADER_LENGTH);
if(Utils.readFourBytesAsChars(headerBuffer).equals(RIFF_SIGNATURE))
{
headerBuffer.getInt(); //Size
if(Utils.readFourBytesAsChars(headerBuffer).equals(WAVE_SIGNATURE))
{
return true;
}
}
return false;
}
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:18,代码来源:WavRIFFHeader.java
示例12: writeInfoDataToFile
import org.jaudiotagger.audio.generic.Utils; //导入依赖的package包/类
/**
* Write LISTINFOChunk of specified size to current file location
* ensuring it is on even file boundary
*
* @param fc random access file
* @param bb data to write
* @param chunkSize chunk size
* @throws java.io.IOException
*/
private void writeInfoDataToFile(FileChannel fc, final ByteBuffer bb, final long chunkSize) throws IOException {
if (Utils.isOddLength(fc.position())) {
writePaddingToFile(fc, 1);
}
//Write LIST header
final ByteBuffer listHeaderBuffer = ByteBuffer.allocate(ChunkHeader.CHUNK_HEADER_SIZE);
listHeaderBuffer.order(ByteOrder.LITTLE_ENDIAN);
listHeaderBuffer.put(WavChunkType.LIST.getCode().getBytes(StandardCharsets.US_ASCII));
listHeaderBuffer.putInt((int) chunkSize);
listHeaderBuffer.flip();
fc.write(listHeaderBuffer);
//Now write actual data
fc.write(bb);
writeExtraByteIfChunkOddSize(fc, chunkSize);
}
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:26,代码来源:WavTagWriter.java
示例13: writeID3DataToFile
import org.jaudiotagger.audio.generic.Utils; //导入依赖的package包/类
/**
* Write Id3Chunk of specified size to current file location
* ensuring it is on even file boundary
*
* @param fc random access file
* @param bb data to write
* @throws java.io.IOException
*/
private void writeID3DataToFile(final FileChannel fc, final ByteBuffer bb) throws IOException {
if (Utils.isOddLength(fc.position())) {
writePaddingToFile(fc, 1);
}
//Write ID3Data header
final ByteBuffer listBuffer = ByteBuffer.allocate(ChunkHeader.CHUNK_HEADER_SIZE);
listBuffer.order(ByteOrder.LITTLE_ENDIAN);
listBuffer.put(WavChunkType.ID3.getCode().getBytes(StandardCharsets.US_ASCII));
listBuffer.putInt(bb.limit());
listBuffer.flip();
fc.write(listBuffer);
//Now write actual data
fc.write(bb);
}
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:25,代码来源:WavTagWriter.java
示例14: readChunk
import org.jaudiotagger.audio.generic.Utils; //导入依赖的package包/类
/**
*
* @return true if successfully read chunks
*
* @throws IOException
*/
public boolean readChunk() throws IOException
{
boolean result = false;
String subIdentifier = Utils.readFourBytesAsChars(chunkData);
if(subIdentifier.equals(WavChunkType.INFO.getCode()))
{
WavInfoChunk chunk = new WavInfoChunk(tag, loggingName);
result = chunk.readChunks(chunkData);
//This is the start of the enclosing LIST element
tag.getInfoTag().setStartLocationInFile(chunkHeader.getStartLocationInFile());
tag.getInfoTag().setEndLocationInFile(chunkHeader.getStartLocationInFile() + ChunkHeader.CHUNK_HEADER_SIZE + chunkHeader.getSize());
tag.setExistingInfoTag(true);
}
return result;
}
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:22,代码来源:WavListChunk.java
示例15: Mp4StcoBox
import org.jaudiotagger.audio.generic.Utils; //导入依赖的package包/类
/**
* Construct box from data and show contents
*
* @param header header info
* @param buffer data of box (doesnt include header data)
*/
public Mp4StcoBox(Mp4BoxHeader header, ByteBuffer buffer) {
this.header = header;
//Make a slice of databuffer then we can work with relative or absolute methods safetly
dataBuffer = buffer.slice();
//Skip the flags
dataBuffer.position(dataBuffer.position() + VERSION_FLAG_LENGTH + OTHER_FLAG_LENGTH);
//No of offsets
this.noOfOffSets = Utils.getIntBE(dataBuffer, dataBuffer.position(), (dataBuffer.position() + NO_OF_OFFSETS_LENGTH - 1));
dataBuffer.position(dataBuffer.position() + NO_OF_OFFSETS_LENGTH);
//First Offset, useful for sanity checks
firstOffSet = Utils.getIntBE(dataBuffer, dataBuffer.position(), (dataBuffer.position() + OFFSET_LENGTH - 1));
}
开发者ID:openaudible,项目名称:openaudible,代码行数:23,代码来源:Mp4StcoBox.java
示例16: update
import org.jaudiotagger.audio.generic.Utils; //导入依赖的package包/类
/**
* Create header using headerdata, expected to find header at headerdata current position
*
* Note after processing adjusts position to immediately after header
*
* @param headerData
*/
public void update(ByteBuffer headerData)
{
//Read header data into byte array
byte[] b = new byte[HEADER_LENGTH];
headerData.get(b);
//Keep reference to copy of RawData
dataBuffer = ByteBuffer.wrap(b);
dataBuffer.order(ByteOrder.BIG_ENDIAN);
//Calculate box size and id
this.length = dataBuffer.getInt();
this.id = Utils.readFourBytesAsChars(dataBuffer);
logger.finest("Mp4BoxHeader id:"+id+":length:"+length);
if (id.equals("\0\0\0\0"))
{
throw new NullBoxIdException(ErrorMessage.MP4_UNABLE_TO_FIND_NEXT_ATOM_BECAUSE_IDENTIFIER_IS_INVALID.getMsg(id));
}
if(length<HEADER_LENGTH)
{
throw new InvalidBoxHeaderException(ErrorMessage.MP4_UNABLE_TO_FIND_NEXT_ATOM_BECAUSE_IDENTIFIER_IS_INVALID.getMsg(id,length));
}
}
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:32,代码来源:Mp4BoxHeader.java
示例17: processData
import org.jaudiotagger.audio.generic.Utils; //导入依赖的package包/类
public void processData() throws CannotReadException
{
//Skip version/other flags
dataBuffer.position(dataBuffer.position() + OTHER_FLAG_LENGTH);
dataBuffer.order(ByteOrder.BIG_ENDIAN);
maxSamplePerFrame = dataBuffer.getInt();
unknown1 = Utils.u(dataBuffer.get());
sampleSize = Utils.u(dataBuffer.get());
historyMult = Utils.u(dataBuffer.get());
initialHistory = Utils.u(dataBuffer.get());
kModifier = Utils.u(dataBuffer.get());
channels = Utils.u(dataBuffer.get());
unknown2 = dataBuffer.getShort();
maxCodedFrameSize = dataBuffer.getInt();
bitRate = dataBuffer.getInt();
sampleRate = dataBuffer.getInt();
}
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:19,代码来源:Mp4AlacBox.java
示例18: Mp4StcoBox
import org.jaudiotagger.audio.generic.Utils; //导入依赖的package包/类
/**
* Construct box from data and adjust offets accordingly
*
* @param header header info
* @param originalDataBuffer data of box (doesnt include header data)
* @param adjustment
*/
public Mp4StcoBox(Mp4BoxHeader header, ByteBuffer originalDataBuffer, int adjustment)
{
this.header = header;
//Make a slice of databuffer then we can work with relative or absolute methods safetly
this.dataBuffer = originalDataBuffer.slice();
//Skip the flags
dataBuffer.position(dataBuffer.position() + VERSION_FLAG_LENGTH + OTHER_FLAG_LENGTH);
//No of offsets
this.noOfOffSets = Utils.getIntBE(dataBuffer, dataBuffer.position(), (dataBuffer.position() + NO_OF_OFFSETS_LENGTH - 1));
dataBuffer.position(dataBuffer.position() + NO_OF_OFFSETS_LENGTH);
for (int i = 0; i < noOfOffSets; i++)
{
int offset = Utils.getIntBE(dataBuffer, dataBuffer.position(), (dataBuffer.position() + NO_OF_OFFSETS_LENGTH - 1));
//Calculate new offset and update buffer
offset = offset + adjustment;
dataBuffer.put(Utils.getSizeBEInt32(offset));
}
}
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:31,代码来源:Mp4StcoBox.java
示例19: Mp4MvhdBox
import org.jaudiotagger.audio.generic.Utils; //导入依赖的package包/类
/**
* @param header header info
* @param dataBuffer data of box (doesnt include header data)
*/
public Mp4MvhdBox(Mp4BoxHeader header, ByteBuffer dataBuffer)
{
this.header = header;
dataBuffer.order(ByteOrder.BIG_ENDIAN);
byte version = dataBuffer.get(VERSION_FLAG_POS);
if (version == LONG_FORMAT)
{
timeScale = dataBuffer.getInt(TIMESCALE_LONG_POS);
timeLength = dataBuffer.getLong(DURATION_LONG_POS);
}
else
{
timeScale = dataBuffer.getInt(TIMESCALE_SHORT_POS);
timeLength = Utils.u(dataBuffer.getInt(DURATION_SHORT_POS));
}
}
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:23,代码来源:Mp4MvhdBox.java
示例20: Mp4MdhdBox
import org.jaudiotagger.audio.generic.Utils; //导入依赖的package包/类
/**
* @param header header info
* @param dataBuffer data of box (doesnt include header data)
*/
public Mp4MdhdBox(Mp4BoxHeader header, ByteBuffer dataBuffer)
{
this.header = header;
dataBuffer.order(ByteOrder.BIG_ENDIAN);
byte version = dataBuffer.get(VERSION_FLAG_POS);
if (version == LONG_FORMAT)
{
this.samplingRate = dataBuffer.getInt(TIMESCALE_LONG_POS);
timeLength = dataBuffer.getLong(DURATION_LONG_POS);
}
else
{
this.samplingRate = dataBuffer.getInt(TIMESCALE_SHORT_POS);
timeLength = Utils.u(dataBuffer.getInt(DURATION_SHORT_POS));
}
}
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:24,代码来源:Mp4MdhdBox.java
注:本文中的org.jaudiotagger.audio.generic.Utils类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论