code
stringlengths 11
173k
| docstring
stringlengths 2
593k
| func_name
stringlengths 2
189
| language
stringclasses 1
value | repo
stringclasses 833
values | path
stringlengths 11
294
| url
stringlengths 60
339
| license
stringclasses 4
values |
---|---|---|---|---|---|---|---|
public final void addDescriptor(final MetadataDescriptor toAdd) throws IllegalArgumentException
{
// check with throwing exceptions
this.containerType.assertConstraints(toAdd.getName(), toAdd.getRawData(), toAdd.getType(), toAdd.getStreamNumber(), toAdd.getLanguageIndex());
// validate containers capabilities
if (!isAddSupported(toAdd))
{
throw new IllegalArgumentException("Descriptor cannot be added, see isAddSupported(...)");
}
/*
* Check for containers types capabilities.
*/
// Search for descriptor list by name, language and stream.
List<MetadataDescriptor> list;
synchronized (this.perfPoint)
{
list = this.descriptors.get(this.perfPoint.setDescriptor(toAdd));
}
if (list == null)
{
list = new ArrayList<MetadataDescriptor>();
this.descriptors.put(new DescriptorPointer(toAdd), list);
}
else
{
if (!list.isEmpty() && !this.containerType.isMultiValued())
{
throw new IllegalArgumentException("Container does not allow multiple values of descriptors with same name, language index and stream number");
}
}
list.add(toAdd);
} |
Adds a metadata descriptor.
@param toAdd the descriptor to add.
@throws IllegalArgumentException if descriptor does not meet container requirements, or
already exist.
| DescriptorPointer::addDescriptor | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/MetadataContainer.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/MetadataContainer.java | Apache-2.0 |
protected final MetadataDescriptor assertDescriptor(final String key)
{
return assertDescriptor(key, MetadataDescriptor.TYPE_STRING);
} |
This method asserts that this container has a descriptor with the
specified key, means returns an existing or creates a new descriptor.
@param key the descriptor name to look up (or create)
@return the/a descriptor with the specified name (and initial type of
{@link MetadataDescriptor#TYPE_STRING}.
| DescriptorPointer::assertDescriptor | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/MetadataContainer.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/MetadataContainer.java | Apache-2.0 |
protected final MetadataDescriptor assertDescriptor(final String key, final int type)
{
MetadataDescriptor desc;
final List<MetadataDescriptor> descriptorsByName = getDescriptorsByName(key);
if (descriptorsByName == null || descriptorsByName.isEmpty())
{
desc = new MetadataDescriptor(getContainerType(), key, type);
addDescriptor(desc);
}
else
{
desc = descriptorsByName.get(0);
}
return desc;
} |
This method asserts that this container has a descriptor with the
specified key, means returns an existing or creates a new descriptor.
@param key the descriptor name to look up (or create)
@param type if the descriptor is created, this data type is applied.
@return the/a descriptor with the specified name.
| DescriptorPointer::assertDescriptor | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/MetadataContainer.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/MetadataContainer.java | Apache-2.0 |
public final boolean containsDescriptor(final MetadataDescriptor lookup)
{
assert lookup != null;
return this.descriptors.containsKey(this.perfPoint.setDescriptor(lookup));
} |
Checks whether a descriptor already exists.<br>
Name, stream number and language index are compared. Data and data type
are ignored.
@param lookup descriptor to look up.
@return <code>true</code> if such a descriptor already exists.
| DescriptorPointer::containsDescriptor | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/MetadataContainer.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/MetadataContainer.java | Apache-2.0 |
public final ContainerType getContainerType()
{
return this.containerType;
} |
Returns the type of container this instance represents.<br>
@return represented container type.
| DescriptorPointer::getContainerType | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/MetadataContainer.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/MetadataContainer.java | Apache-2.0 |
public final int getDescriptorCount()
{
return this.getDescriptors().size();
} |
Returns the number of contained descriptors.
@return number of descriptors.
| DescriptorPointer::getDescriptorCount | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/MetadataContainer.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/MetadataContainer.java | Apache-2.0 |
public final List<MetadataDescriptor> getDescriptors()
{
final List<MetadataDescriptor> result = new ArrayList<MetadataDescriptor>();
for (final List<MetadataDescriptor> curr : this.descriptors.values())
{
result.addAll(curr);
}
return result;
} |
Returns all stored descriptors.
@return stored descriptors.
| DescriptorPointer::getDescriptors | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/MetadataContainer.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/MetadataContainer.java | Apache-2.0 |
public final List<MetadataDescriptor> getDescriptorsByName(final String name)
{
assert name != null;
final List<MetadataDescriptor> result = new ArrayList<MetadataDescriptor>();
final Collection<List<MetadataDescriptor>> values = this.descriptors.values();
for (final List<MetadataDescriptor> currList : values)
{
if (!currList.isEmpty() && currList.get(0).getName().equals(name))
{
result.addAll(currList);
}
}
return result;
} |
Returns a list of descriptors with the given
{@linkplain MetadataDescriptor#getName() name}.<br>
@param name name of the descriptors to return
@return list of descriptors with given name.
| DescriptorPointer::getDescriptorsByName | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/MetadataContainer.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/MetadataContainer.java | Apache-2.0 |
protected final String getValueFor(final String name)
{
String result = "";
final List<MetadataDescriptor> descs = getDescriptorsByName(name);
if (descs != null)
{
assert descs.size() <= 1;
if (!descs.isEmpty())
{
result = descs.get(0).getString();
}
}
return result;
} |
This method looks up a descriptor with given name and returns its value
as string.<br>
@param name the name of the descriptor to look up.
@return the string representation of a found descriptors value. Even an
empty string if no descriptor has been found.
| DescriptorPointer::getValueFor | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/MetadataContainer.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/MetadataContainer.java | Apache-2.0 |
public final boolean hasDescriptor(final String name)
{
return !getDescriptorsByName(name).isEmpty();
} |
Determines if this container contains a descriptor with given
{@linkplain MetadataDescriptor#getName() name}.<br>
@param name Name of the descriptor to look for.
@return <code>true</code> if descriptor has been found.
| DescriptorPointer::hasDescriptor | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/MetadataContainer.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/MetadataContainer.java | Apache-2.0 |
public boolean isAddSupported(final MetadataDescriptor descriptor)
{
boolean result = getContainerType().checkConstraints(descriptor.getName(), descriptor.getRawData(), descriptor.getType(), descriptor.getStreamNumber(), descriptor.getLanguageIndex()) == null;
// Now check if there is already a value contained.
if (result && !getContainerType().isMultiValued())
{
synchronized (this.perfPoint)
{
final List<MetadataDescriptor> list = this.descriptors.get(this.perfPoint.setDescriptor(descriptor));
if (list != null)
{
result = list.isEmpty();
}
}
}
return result;
} |
Determines/checks if the given descriptor may be added to the container.<br>
This implies a check for the capabilities of the container specified by
its {@linkplain #getContainerType() container type}.<br>
@param descriptor the descriptor to test.
@return <code>true</code> if {@link #addDescriptor(MetadataDescriptor)}
can be called with given descriptor.
| DescriptorPointer::isAddSupported | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/MetadataContainer.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/MetadataContainer.java | Apache-2.0 |
public final void removeDescriptorsByName(final String name)
{
assert name != null;
final Iterator<List<MetadataDescriptor>> iterator = this.descriptors.values().iterator();
while (iterator.hasNext())
{
final List<MetadataDescriptor> curr = iterator.next();
if (!curr.isEmpty() && curr.get(0).getName().equals(name))
{
iterator.remove();
}
}
} |
Removes all stored descriptors with the given
{@linkplain MetadataDescriptor#getName() name}.<br>
@param name the name to remove.
| DescriptorPointer::removeDescriptorsByName | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/MetadataContainer.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/MetadataContainer.java | Apache-2.0 |
protected final void setStringValue(final String name, final String value)
{
assertDescriptor(name).setStringValue(value);
} |
{@linkplain #assertDescriptor(String) asserts} the existence of a
descriptor with given <code>name</code> and
{@linkplain MetadataDescriptor#setStringValue(String) assings} the string
value.
@param name the name of the descriptor to set the value for.
@param value the string value.
| DescriptorPointer::setStringValue | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/MetadataContainer.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/MetadataContainer.java | Apache-2.0 |
public AsfHeader(final long pos, final BigInteger chunkLen, final long chunkCnt)
{
super(GUID.GUID_HEADER, pos, chunkLen);
this.chunkCount = chunkCnt;
} |
Creates an instance.
@param pos see {@link Chunk#position}
@param chunkLen see {@link Chunk#chunkLength}
@param chunkCnt
| AsfHeader::AsfHeader | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/AsfHeader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/AsfHeader.java | Apache-2.0 |
public ContentDescription findContentDescription()
{
ContentDescription result = getContentDescription();
if (result == null && getExtendedHeader() != null)
{
result = getExtendedHeader().getContentDescription();
}
return result;
} |
This method looks for an content description object in this header
instance, if not found there, it tries to get one from a contained ASF
header extension object.
@return content description if found, <code>null</code> otherwise.
| AsfHeader::findContentDescription | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/AsfHeader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/AsfHeader.java | Apache-2.0 |
public MetadataContainer findExtendedContentDescription()
{
MetadataContainer result = getExtendedContentDescription();
if (result == null && getExtendedHeader() != null)
{
result = getExtendedHeader().getExtendedContentDescription();
}
return result;
} |
This method looks for an extended content description object in this
header instance, if not found there, it tries to get one from a contained
ASF header extension object.
@return extended content description if found, <code>null</code>
otherwise.
| AsfHeader::findExtendedContentDescription | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/AsfHeader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/AsfHeader.java | Apache-2.0 |
public EncryptionChunk(final BigInteger chunkLen)
{
super(GUID.GUID_CONTENT_ENCRYPTION, chunkLen);
this.strings = new ArrayList<String>();
this.secretData = "";
this.protectionType = "";
this.keyID = "";
this.licenseURL = "";
} |
Creates an instance.
@param chunkLen Length of current chunk.
| EncryptionChunk::EncryptionChunk | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/EncryptionChunk.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/EncryptionChunk.java | Apache-2.0 |
public void addString(final String toAdd)
{
this.strings.add(toAdd);
} |
This method appends a String.
@param toAdd String to add.
| EncryptionChunk::addString | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/EncryptionChunk.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/EncryptionChunk.java | Apache-2.0 |
public String getKeyID()
{
return this.keyID;
} |
This method gets the keyID.
@return
| EncryptionChunk::getKeyID | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/EncryptionChunk.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/EncryptionChunk.java | Apache-2.0 |
public String getLicenseURL()
{
return this.licenseURL;
} |
This method gets the license URL.
@return
| EncryptionChunk::getLicenseURL | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/EncryptionChunk.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/EncryptionChunk.java | Apache-2.0 |
public String getProtectionType()
{
return this.protectionType;
} |
This method gets the secret data.
@return
| EncryptionChunk::getProtectionType | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/EncryptionChunk.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/EncryptionChunk.java | Apache-2.0 |
public Collection<String> getStrings()
{
return new ArrayList<String>(this.strings);
} |
This method returns a collection of all {@link String}s which were addid
due {@link #addString(String)}.
@return Inserted Strings.
| EncryptionChunk::getStrings | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/EncryptionChunk.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/EncryptionChunk.java | Apache-2.0 |
public void setSecretData(final String toAdd)
{
this.secretData = toAdd;
} |
This method adds the secret data.
@param toAdd String to add.
| EncryptionChunk::setSecretData | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/EncryptionChunk.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/EncryptionChunk.java | Apache-2.0 |
public StreamChunk(final GUID streamType, final BigInteger chunkLen)
{
super(GUID.GUID_STREAM, chunkLen);
assert GUID.GUID_AUDIOSTREAM.equals(streamType) || GUID.GUID_VIDEOSTREAM.equals(streamType);
this.type = streamType;
} |
Creates an instance
@param streamType The GUID which tells the stream type represented (
{@link GUID#GUID_AUDIOSTREAM} or {@link GUID#GUID_VIDEOSTREAM}
):
@param chunkLen length of chunk
| StreamChunk::StreamChunk | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/StreamChunk.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/StreamChunk.java | Apache-2.0 |
public long getStreamSpecificDataSize()
{
return this.streamSpecificDataSize;
} |
@return Returns the streamSpecificDataSize.
| StreamChunk::getStreamSpecificDataSize | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/StreamChunk.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/StreamChunk.java | Apache-2.0 |
public GUID getStreamType()
{
return this.type;
} |
Returns the stream type of the stream chunk.<br>
@return {@link GUID#GUID_AUDIOSTREAM} or {@link GUID#GUID_VIDEOSTREAM}.
| StreamChunk::getStreamType | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/StreamChunk.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/StreamChunk.java | Apache-2.0 |
public long getTimeOffset()
{
return this.timeOffset;
} |
@return Returns the timeOffset.
| StreamChunk::getTimeOffset | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/StreamChunk.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/StreamChunk.java | Apache-2.0 |
public long getTypeSpecificDataSize()
{
return this.typeSpecificDataSize;
} |
@return Returns the typeSpecificDataSize.
| StreamChunk::getTypeSpecificDataSize | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/StreamChunk.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/StreamChunk.java | Apache-2.0 |
public boolean isContentEncrypted()
{
return this.contentEncrypted;
} |
@return Returns the contentEncrypted.
| StreamChunk::isContentEncrypted | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/StreamChunk.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/StreamChunk.java | Apache-2.0 |
public void setContentEncrypted(final boolean cntEnc)
{
this.contentEncrypted = cntEnc;
} |
@param cntEnc The contentEncrypted to set.
| StreamChunk::setContentEncrypted | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/StreamChunk.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/StreamChunk.java | Apache-2.0 |
public void setStreamNumber(final int streamNum)
{
this.streamNumber = streamNum;
} |
@param streamNum The streamNumber to set.
| StreamChunk::setStreamNumber | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/StreamChunk.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/StreamChunk.java | Apache-2.0 |
public void setStreamSpecificDataSize(final long strSpecDataSize)
{
this.streamSpecificDataSize = strSpecDataSize;
} |
@param strSpecDataSize The streamSpecificDataSize to set.
| StreamChunk::setStreamSpecificDataSize | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/StreamChunk.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/StreamChunk.java | Apache-2.0 |
public void setTimeOffset(final long timeOffs)
{
this.timeOffset = timeOffs;
} |
@param timeOffs sets the time offset
| StreamChunk::setTimeOffset | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/StreamChunk.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/StreamChunk.java | Apache-2.0 |
public void setTypeSpecificDataSize(final long typeSpecDataSize)
{
this.typeSpecificDataSize = typeSpecDataSize;
} |
@param typeSpecDataSize The typeSpecificDataSize to set.
| StreamChunk::setTypeSpecificDataSize | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/StreamChunk.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/StreamChunk.java | Apache-2.0 |
public void addBitrateRecord(final int streamNum, final long averageBitrate)
{
this.streamNumbers.add(streamNum);
this.bitRates.add(averageBitrate);
} |
Adds the public values of a stream-record.
@param streamNum The number of the referred stream.
@param averageBitrate Its average bitrate.
| StreamBitratePropertiesChunk::addBitrateRecord | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/StreamBitratePropertiesChunk.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/StreamBitratePropertiesChunk.java | Apache-2.0 |
public long getAvgBitrate(final int streamNumber)
{
final Integer seach = streamNumber;
final int index = this.streamNumbers.indexOf(seach);
long result;
if (index == -1)
{
result = -1;
}
else
{
result = this.bitRates.get(index);
}
return result;
} |
Returns the average bitrate of the given stream.<br>
@param streamNumber Number of the stream whose bitrate to determine.
@return The average bitrate of the numbered stream. <code>-1</code> if no
information was given.
| StreamBitratePropertiesChunk::getAvgBitrate | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/StreamBitratePropertiesChunk.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/StreamBitratePropertiesChunk.java | Apache-2.0 |
public ContentBranding(final long pos, final BigInteger size)
{
super(ContainerType.CONTENT_BRANDING, pos, size);
} |
Creates an instance.
@param pos Position of content description within file or stream
@param size Length of content description.
| ContentBranding::ContentBranding | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/ContentBranding.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/ContentBranding.java | Apache-2.0 |
public String getBannerImageURL()
{
return getValueFor(KEY_BANNER_URL);
} |
Returns the banner image URL.
@return the banner image URL.
| ContentBranding::getBannerImageURL | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/ContentBranding.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/ContentBranding.java | Apache-2.0 |
public String getCopyRightURL()
{
return getValueFor(KEY_COPYRIGHT_URL);
} |
Returns the copyright URL.
@return the banner image URL.
| ContentBranding::getCopyRightURL | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/ContentBranding.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/ContentBranding.java | Apache-2.0 |
public byte[] getImageData()
{
return assertDescriptor(KEY_BANNER_IMAGE, MetadataDescriptor.TYPE_BINARY).getRawData();
} |
Returns the binary image data.
@return binary image data.
| ContentBranding::getImageData | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/ContentBranding.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/ContentBranding.java | Apache-2.0 |
public long getImageType()
{
if (!hasDescriptor(KEY_BANNER_TYPE))
{
final MetadataDescriptor descriptor = new MetadataDescriptor(ContainerType.CONTENT_BRANDING, KEY_BANNER_TYPE, MetadataDescriptor.TYPE_DWORD);
descriptor.setDWordValue(0);
addDescriptor(descriptor);
}
return assertDescriptor(KEY_BANNER_TYPE).getNumber();
} |
Returns the image type.<br>
@return image type
@see #KEY_BANNER_TYPE for known/valid values.
| ContentBranding::getImageType | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/ContentBranding.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/ContentBranding.java | Apache-2.0 |
public void setBannerImageURL(final String imageURL)
{
if (Utils.isBlank(imageURL))
{
removeDescriptorsByName(KEY_BANNER_URL);
}
else
{
assertDescriptor(KEY_BANNER_URL).setStringValue(imageURL);
}
} |
This method sets the banner image URL, if <code>imageURL</code> is not
blank.<br>
@param imageURL image URL to set.
| ContentBranding::setBannerImageURL | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/ContentBranding.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/ContentBranding.java | Apache-2.0 |
public void setCopyRightURL(final String copyRight)
{
if (Utils.isBlank(copyRight))
{
removeDescriptorsByName(KEY_COPYRIGHT_URL);
}
else
{
assertDescriptor(KEY_COPYRIGHT_URL).setStringValue(copyRight);
}
} |
This method sets the copyright URL, if <code>copyRight</code> is not
blank.<br>
@param copyRight copyright URL to set.
| ContentBranding::setCopyRightURL | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/ContentBranding.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/ContentBranding.java | Apache-2.0 |
public void setImage(final long imageType, final byte[] imageData)
{
assert imageType >= 0 && imageType <= 3;
assert imageType > 0 || imageData.length == 0;
assertDescriptor(KEY_BANNER_TYPE, MetadataDescriptor.TYPE_DWORD).setDWordValue(imageType);
assertDescriptor(KEY_BANNER_IMAGE, MetadataDescriptor.TYPE_BINARY).setBinaryValue(imageData);
} |
@param imageType
@param imageData
| ContentBranding::setImage | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/ContentBranding.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/ContentBranding.java | Apache-2.0 |
public LanguageList()
{
super(GUID.GUID_LANGUAGE_LIST, 0, BigInteger.ZERO);
} |
Creates a new instance.<br>
| LanguageList::LanguageList | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/LanguageList.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/LanguageList.java | Apache-2.0 |
public LanguageList(final long pos, final BigInteger size)
{
super(GUID.GUID_LANGUAGE_LIST, pos, size);
} |
Creates an instance.
@param pos position within the ASF file.
@param size size of the chunk
| LanguageList::LanguageList | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/LanguageList.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/LanguageList.java | Apache-2.0 |
public void addLanguage(final String language)
{
if (language.length() < MetadataDescriptor.MAX_LANG_INDEX)
{
if (!this.languages.contains(language))
{
this.languages.add(language);
}
}
else
{
throw new IllegalArgumentException(ErrorMessage.WMA_LENGTH_OF_LANGUAGE_IS_TOO_LARGE.getMsg(language.length() * 2 + 2));
}
} |
This method adds a language.<br>
@param language language code
| LanguageList::addLanguage | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/LanguageList.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/LanguageList.java | Apache-2.0 |
public String getLanguage(final int index)
{
return this.languages.get(index);
} |
Returns the language code at the specified index.
@param index the index of the language code to get.
@return the language code at given index.
| LanguageList::getLanguage | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/LanguageList.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/LanguageList.java | Apache-2.0 |
public int getLanguageCount()
{
return this.languages.size();
} |
Returns the amount of stored language codes.
@return number of stored language codes.
| LanguageList::getLanguageCount | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/LanguageList.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/LanguageList.java | Apache-2.0 |
public List<String> getLanguages()
{
return new ArrayList<String>(this.languages);
} |
Returns all language codes in list.
@return list of language codes.
| LanguageList::getLanguages | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/LanguageList.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/LanguageList.java | Apache-2.0 |
public void removeLanguage(final int index)
{
this.languages.remove(index);
} |
Removes the language entry at specified index.
@param index index of language to remove.
| LanguageList::removeLanguage | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/data/LanguageList.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/data/LanguageList.java | Apache-2.0 |
protected EncodingChunkReader()
{
// NOTHING toDo
} |
Should not be used for now.
| EncodingChunkReader::EncodingChunkReader | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/io/EncodingChunkReader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/io/EncodingChunkReader.java | Apache-2.0 |
public RandomAccessFileOutputStream(final RandomAccessFile target)
{
super();
this.targetFile = target;
} |
Creates an instance.<br>
@param target file to write to.
| RandomAccessFileOutputStream::RandomAccessFileOutputStream | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/io/RandomAccessFileOutputStream.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/io/RandomAccessFileOutputStream.java | Apache-2.0 |
protected StreamChunkReader()
{
// Nothing to do
} |
Shouldn't be used for now.
| StreamChunkReader::StreamChunkReader | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/io/StreamChunkReader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/io/StreamChunkReader.java | Apache-2.0 |
protected ChunkContainerReader(final List<Class<? extends ChunkReader>> toRegister, final boolean readChunkOnce)
{
this.eachChunkOnce = readChunkOnce;
for (final Class<? extends ChunkReader> curr : toRegister)
{
register(curr);
}
} |
Creates a reader instance, which only utilizes the given list of chunk
readers.<br>
@param toRegister List of {@link ChunkReader} class instances, which are to be
utilized by the instance.
@param readChunkOnce if <code>true</code>, each chunk type (identified by chunk
GUID) will handled only once, if a reader is available, other
chunks will be discarded.
| ChunkContainerReader::ChunkContainerReader | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/io/ChunkContainerReader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/io/ChunkContainerReader.java | Apache-2.0 |
protected void checkStream(final InputStream stream) throws IllegalArgumentException
{
if (this.hasFailingReaders && !stream.markSupported())
{
throw new IllegalArgumentException("Stream has to support mark/reset.");
}
} |
Checks for the constraints of this class.
@param stream stream to test.
@throws IllegalArgumentException If stream does not meet the requirements.
| ChunkContainerReader::checkStream | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/io/ChunkContainerReader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/io/ChunkContainerReader.java | Apache-2.0 |
protected ChunkReader getReader(final GUID guid)
{
return this.readerMap.get(guid);
} |
Gets a configured {@linkplain ChunkReader reader} instance for ASF
objects (chunks) with the specified <code>guid</code>.
@param guid GUID which identifies the chunk to be read.
@return an appropriate reader implementation, <code>null</code> if not
{@linkplain #register(Class) registered}.
| ChunkContainerReader::getReader | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/io/ChunkContainerReader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/io/ChunkContainerReader.java | Apache-2.0 |
protected boolean isReaderAvailable(final GUID guid)
{
return this.readerMap.containsKey(guid);
} |
Tests whether {@link #getReader(GUID)} won't return <code>null</code>.<br>
@param guid GUID which identifies the chunk to be read.
@return <code>true</code> if a reader is available.
| ChunkContainerReader::isReaderAvailable | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/io/ChunkContainerReader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/io/ChunkContainerReader.java | Apache-2.0 |
public ChunkType read(final GUID guid, final InputStream stream, final long chunkStart) throws IOException, IllegalArgumentException
{
checkStream(stream);
final CountingInputStream cis = new CountingInputStream(stream);
if (!Arrays.asList(getApplyingIds()).contains(guid))
{
throw new IllegalArgumentException("provided GUID is not supported by this reader.");
}
// For Know the file pointer pointed to an ASF header chunk.
final BigInteger chunkLen = Utils.readBig64(cis);
/*
* now read implementation specific information until the chunk
* collection starts and create the resulting object.
*/
final ChunkType result = createContainer(chunkStart, chunkLen, cis);
// 16 bytes have already been for providing the GUID
long currentPosition = chunkStart + cis.getReadCount() + 16;
final HashSet<GUID> alreadyRead = new HashSet<GUID>();
/*
* Now reading header of chuncks.
*/
while (currentPosition < result.getChunkEnd())
{
final GUID currentGUID = Utils.readGUID(cis);
final boolean skip = this.eachChunkOnce && (!isReaderAvailable(currentGUID) || !alreadyRead.add(currentGUID));
Chunk chunk;
/*
* If one reader tells it could fail (new method), then check the
* input stream for mark/reset. And use it if failed.
*/
if (!skip && isReaderAvailable(currentGUID))
{
final ChunkReader reader = getReader(currentGUID);
if (reader.canFail())
{
cis.mark(READ_LIMIT);
}
chunk = getReader(currentGUID).read(currentGUID, cis, currentPosition);
}
else
{
chunk = ChunkHeaderReader.getInstance().read(currentGUID, cis, currentPosition);
}
if (chunk == null)
{
/*
* Reader failed
*/
cis.reset();
}
else
{
if (!skip)
{
result.addChunk(chunk);
}
currentPosition = chunk.getChunkEnd();
// Always take into account, that 16 bytes have been read prior
// to calling this method
assert cis.getReadCount() + chunkStart + 16 == currentPosition;
}
}
return result;
} |
This Method implements the reading of a chunk container.<br>
@param guid GUID of the currently read container.
@param stream Stream which contains the chunk container.
@param chunkStart The start of the chunk container from stream start.<br>
For direct file streams one can assume <code>0</code> here.
@return <code>null</code> if no valid data found, else a Wrapper
containing all supported data.
@throws IOException Read errors.
@throws IllegalArgumentException If one used {@link ChunkReader} could
{@linkplain ChunkReader#canFail() fail} and the stream source
doesn't support mark/reset.
| ChunkContainerReader::read | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/io/ChunkContainerReader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/io/ChunkContainerReader.java | Apache-2.0 |
private <T extends ChunkReader> void register(final Class<T> toRegister)
{
try
{
final T reader = toRegister.newInstance();
for (final GUID curr : reader.getApplyingIds())
{
this.readerMap.put(curr, reader);
}
}
catch (InstantiationException e)
{
LOGGER.severe(e.getMessage());
}
catch (IllegalAccessException e)
{
LOGGER.severe(e.getMessage());
}
} |
Registers the given reader.<br>
@param <T> The actual reader implementation.
@param toRegister chunk reader which is to be registered.
| ChunkContainerReader::register | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/io/ChunkContainerReader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/io/ChunkContainerReader.java | Apache-2.0 |
public CountingInputStream(final InputStream stream)
{
super(stream);
this.markPos = 0;
this.readCount = 0;
} |
Creates an instance, which delegates the commands to the given stream.
@param stream stream to actually work with.
| CountingInputStream::CountingInputStream | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/io/CountingInputStream.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/io/CountingInputStream.java | Apache-2.0 |
private synchronized void bytesRead(final long amountRead)
{
if (amountRead >= 0)
{
this.readCount += amountRead;
}
} |
Counts the given amount of bytes.
@param amountRead number of bytes to increase.
| CountingInputStream::bytesRead | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/io/CountingInputStream.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/io/CountingInputStream.java | Apache-2.0 |
public synchronized long getReadCount()
{
return this.readCount;
} |
@return the readCount
| CountingInputStream::getReadCount | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/io/CountingInputStream.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/io/CountingInputStream.java | Apache-2.0 |
public WriteableChunkModifer(final WriteableChunk chunk)
{
this.writableChunk = chunk;
} |
Creates an instance.<br>
@param chunk chunk to write
| WriteableChunkModifer::WriteableChunkModifer | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/io/WriteableChunkModifer.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/io/WriteableChunkModifer.java | Apache-2.0 |
public FullRequestInputStream(final InputStream source)
{
super(source);
} |
Creates an instance.
@param source stream to read from.
| FullRequestInputStream::FullRequestInputStream | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/io/FullRequestInputStream.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/io/FullRequestInputStream.java | Apache-2.0 |
private int[] getStringSizes(final InputStream stream) throws IOException
{
final int[] result = new int[5];
for (int i = 0; i < result.length; i++)
{
result[i] = Utils.readUINT16(stream);
}
return result;
} |
Returns the next 5 UINT16 values as an array.<br>
@param stream stream to read from
@return 5 int values read from stream.
@throws IOException on I/O Errors.
| ContentDescriptionReader::getStringSizes | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/io/ContentDescriptionReader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/io/ContentDescriptionReader.java | Apache-2.0 |
public static ChunkHeaderReader getInstance()
{
return INSTANCE;
} |
Returns an instance of the reader.
@return instance.
| ChunkHeaderReader::getInstance | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/io/ChunkHeaderReader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/io/ChunkHeaderReader.java | Apache-2.0 |
private ChunkHeaderReader()
{
// Hidden
} |
Hidden Utility class constructor.
| ChunkHeaderReader::ChunkHeaderReader | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/io/ChunkHeaderReader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/io/ChunkHeaderReader.java | Apache-2.0 |
public RandomAccessFileInputstream(final RandomAccessFile file)
{
super();
if (file == null)
{
throw new IllegalArgumentException("null");
}
this.source = file;
} |
Creates an instance that will provide {@link InputStream} functionality
on the given {@link RandomAccessFile} by delegating calls.<br>
@param file The file to read.
| RandomAccessFileInputstream::RandomAccessFileInputstream | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/io/RandomAccessFileInputstream.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/io/RandomAccessFileInputstream.java | Apache-2.0 |
private boolean readBoolean(final InputStream stream, final int bytes) throws IOException
{
final byte[] tmp = new byte[bytes];
stream.read(tmp);
boolean result = false;
for (int i = 0; i < bytes; i++)
{
if (i == bytes - 1)
{
result = tmp[i] == 1;
assert tmp[i] == 0 || tmp[i] == 1;
}
else
{
assert tmp[i] == 0;
}
}
return result;
} |
Reads the given amount of bytes and checks the last byte, if its equal to
one or zero (true / false).<br>
All other bytes must be zero. (if assertions enabled).
@param stream stream to read from.
@param bytes amount of bytes
@return <code>true</code> or <code>false</code>.
@throws IOException on I/O Errors
| MetadataReader::readBoolean | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/io/MetadataReader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/io/MetadataReader.java | Apache-2.0 |
private static InputStream createStream(final RandomAccessFile raf)
{
return new FullRequestInputStream(new BufferedInputStream(new RandomAccessFileInputstream(raf)));
} |
Creates a Stream that will read from the specified
{@link RandomAccessFile};<br>
@param raf data source to read from.
@return a stream which accesses the source.
| AsfHeaderReader::createStream | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/io/AsfHeaderReader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/io/AsfHeaderReader.java | Apache-2.0 |
public static AsfHeader readHeader(final File file) throws IOException
{
final InputStream stream = new FileInputStream(file);
final AsfHeader result = FULL_READER.read(Utils.readGUID(stream), stream, 0);
stream.close();
return result;
} |
This method extracts the full ASF-Header from the given file.<br>
If no header could be extracted <code>null</code> is returned. <br>
@param file the ASF file to read.<br>
@return AsfHeader-Wrapper, or <code>null</code> if no supported ASF
header was found.
@throws IOException on I/O Errors.
| AsfHeaderReader::readHeader | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/io/AsfHeaderReader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/io/AsfHeaderReader.java | Apache-2.0 |
public static AsfHeader readHeader(final RandomAccessFile file) throws IOException
{
final InputStream stream = createStream(file);
return FULL_READER.read(Utils.readGUID(stream), stream, 0);
} |
This method tries to extract a full ASF-header out of the given stream. <br>
If no header could be extracted <code>null</code> is returned. <br>
@param file File which contains the ASF header.
@return AsfHeader-Wrapper, or <code>null</code> if no supported ASF
header was found.
@throws IOException Read errors
| AsfHeaderReader::readHeader | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/io/AsfHeaderReader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/io/AsfHeaderReader.java | Apache-2.0 |
public static AsfHeader readInfoHeader(final RandomAccessFile file) throws IOException
{
final InputStream stream = createStream(file);
return INFO_READER.read(Utils.readGUID(stream), stream, 0);
} |
This method tries to extract an ASF-header out of the given stream, which
only contains information about the audio stream.<br>
If no header could be extracted <code>null</code> is returned. <br>
@param file File which contains the ASF header.
@return AsfHeader-Wrapper, or <code>null</code> if no supported ASF
header was found.
@throws IOException Read errors
| AsfHeaderReader::readInfoHeader | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/io/AsfHeaderReader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/io/AsfHeaderReader.java | Apache-2.0 |
public static AsfHeader readTagHeader(final RandomAccessFile file) throws IOException
{
final InputStream stream = createStream(file);
return TAG_READER.read(Utils.readGUID(stream), stream, 0);
} |
This method tries to extract an ASF-header out of the given stream, which
only contains metadata.<br>
If no header could be extracted <code>null</code> is returned. <br>
@param file File which contains the ASF header.
@return AsfHeader-Wrapper, or <code>null</code> if no supported ASF
header was found.
@throws IOException Read errors
| AsfHeaderReader::readTagHeader | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/io/AsfHeaderReader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/io/AsfHeaderReader.java | Apache-2.0 |
public AsfHeaderReader(final List<Class<? extends ChunkReader>> toRegister, final boolean readChunkOnce)
{
super(toRegister, readChunkOnce);
} |
Creates an instance of this reader.
@param toRegister The chunk readers to utilize.
@param readChunkOnce if <code>true</code>, each chunk type (identified by chunk
GUID) will handled only once, if a reader is available, other
chunks will be discarded.
| AsfHeaderReader::AsfHeaderReader | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/io/AsfHeaderReader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/io/AsfHeaderReader.java | Apache-2.0 |
public void setExtendedHeaderReader(final AsfExtHeaderReader extReader)
{
for (final GUID curr : extReader.getApplyingIds())
{
this.readerMap.put(curr, extReader);
}
} |
Sets the {@link AsfExtHeaderReader}, which is to be used, when an header
extension object is found.
@param extReader header extension object reader.
| AsfHeaderReader::setExtendedHeaderReader | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/io/AsfHeaderReader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/io/AsfHeaderReader.java | Apache-2.0 |
public CountingOutputstream(final OutputStream outputStream)
{
super();
assert outputStream != null;
this.wrapped = outputStream;
} |
Creates an instance which will delegate the write calls to the given
output stream.
@param outputStream stream to wrap.
| CountingOutputstream::CountingOutputstream | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/io/CountingOutputstream.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/io/CountingOutputstream.java | Apache-2.0 |
public long getCount()
{
return this.count;
} |
@return the count
| CountingOutputstream::getCount | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/io/CountingOutputstream.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/io/CountingOutputstream.java | Apache-2.0 |
public AsfExtHeaderModifier(final List<ChunkModifier> modifiers)
{
assert modifiers != null;
this.modifierList = new ArrayList<ChunkModifier>(modifiers);
} |
Creates an instance.<br>
@param modifiers modifiers to apply.
| AsfExtHeaderModifier::AsfExtHeaderModifier | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/io/AsfExtHeaderModifier.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/io/AsfExtHeaderModifier.java | Apache-2.0 |
private void copyChunk(final GUID guid, final InputStream source, final OutputStream destination) throws IOException
{
final long chunkSize = Utils.readUINT64(source);
destination.write(guid.getBytes());
Utils.writeUINT64(chunkSize, destination);
Utils.copy(source, destination, chunkSize - 24);
} |
Simply copies a chunk from <code>source</code> to
<code>destination</code>.<br>
The method assumes, that the GUID has already been read and will write
the provided one to the destination.<br>
The chunk length however will be read and used to determine the amount of
bytes to copy.
@param guid GUID of the current CHUNK.
@param source source of an ASF chunk, which is to be located at the chunk
length field.
@param destination the destination to copy the chunk to.
@throws IOException on I/O errors.
| AsfExtHeaderModifier::copyChunk | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/io/AsfExtHeaderModifier.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/io/AsfExtHeaderModifier.java | Apache-2.0 |
public void createModifiedCopy(final InputStream source, final OutputStream dest, final List<ChunkModifier> modifiers) throws IOException
{
final List<ChunkModifier> modders = new ArrayList<ChunkModifier>();
if (modifiers != null)
{
modders.addAll(modifiers);
}
// Read and check ASF GUID
final GUID readGUID = Utils.readGUID(source);
if (GUID.GUID_HEADER.equals(readGUID))
{
// used to calculate differences
long totalDiff = 0;
long chunkDiff = 0;
// read header information
final long headerSize = Utils.readUINT64(source);
final long chunkCount = Utils.readUINT32(source);
final byte[] reserved = new byte[2];
reserved[0] = (byte) (source.read() & 0xFF);
reserved[1] = (byte) (source.read() & 0xFF);
/*
* bos will get all unmodified and modified header chunks. This is
* necessary, because the header chunk (and file properties chunk)
* need to be adjusted but are written in front of the others.
*/
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
// fileHeader will get the binary representation of the file
// properties chunk, without GUID
byte[] fileHeader = null;
// Iterate through all chunks
for (long i = 0; i < chunkCount; i++)
{
// Read GUID
final GUID curr = Utils.readGUID(source);
// special case for file properties chunk
if (GUID.GUID_FILE.equals(curr))
{
final ByteArrayOutputStream tmp = new ByteArrayOutputStream();
final long size = Utils.readUINT64(source);
Utils.writeUINT64(size, tmp);
Utils.copy(source, tmp, size - 24);
fileHeader = tmp.toByteArray();
}
else
{
/*
* Now look for ChunkModifier objects which modify the
* current chunk
*/
boolean handled = false;
for (int j = 0; j < modders.size() && !handled; j++)
{
if (modders.get(j).isApplicable(curr))
{
// alter current chunk
final ModificationResult result = modders.get(j).modify(curr, source, bos);
// remember size differences.
chunkDiff += result.getChunkCountDifference();
totalDiff += result.getByteDifference();
// remove current modifier from index.
modders.remove(j);
handled = true;
}
}
if (!handled)
{
// copy chunks which are not modified.
copyChunk(curr, source, bos);
}
}
}
// Now apply the left modifiers.
for (final ChunkModifier curr : modders)
{
// chunks, which were not in the source file, will be added to
// the destination
final ModificationResult result = curr.modify(null, null, bos);
chunkDiff += result.getChunkCountDifference();
totalDiff += result.getByteDifference();
}
/*
* Now all header objects have been read or manipulated and stored
* in the internal buffer (bos).
*/
// write ASF GUID
dest.write(readGUID.getBytes());
// write altered header object size
Utils.writeUINT64(headerSize + totalDiff, dest);
// write altered number of chunks
Utils.writeUINT32(chunkCount + chunkDiff, dest);
// write the reserved 2 bytes (0x01,0x02).
dest.write(reserved);
// write the new file header
modifyFileHeader(new ByteArrayInputStream(fileHeader), dest, totalDiff);
// write the header objects (chunks)
dest.write(bos.toByteArray());
// copy the rest of the file (data and index)
Utils.flush(source, dest);
}
else
{
throw new IllegalArgumentException("No ASF header object.");
}
} |
Reads the <code>source</code> and applies the modifications provided by
the given <code>modifiers</code>, and puts it to <code>dest</code>.<br>
Each {@linkplain ChunkModifier modifier} is used only once, so if one
should be used multiple times, it should be added multiple times into the
list.<br>
@param source the source ASF file
@param dest the destination to write the modified version to.
@param modifiers list of chunk modifiers to apply.
@throws IOException on I/O errors.
| AsfStreamer::createModifiedCopy | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/io/AsfStreamer.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/io/AsfStreamer.java | Apache-2.0 |
private void modifyFileHeader(final InputStream source, final OutputStream destination, final long fileSizeDiff) throws IOException
{
destination.write(GUID.GUID_FILE.getBytes());
final long chunkSize = Utils.readUINT64(source);
Utils.writeUINT64(chunkSize, destination);
destination.write(Utils.readGUID(source).getBytes());
final long fileSize = Utils.readUINT64(source);
Utils.writeUINT64(fileSize + fileSizeDiff, destination);
Utils.copy(source, destination, chunkSize - 48);
} |
This is a slight variation of
{@link #copyChunk(GUID, InputStream, OutputStream)}, it only handles file
property chunks correctly.<br>
The copied chunk will have the file size field modified by the given
<code>fileSizeDiff</code> value.
@param source source of file properties chunk, located at its chunk length
field.
@param destination the destination to copy the chunk to.
@param fileSizeDiff the difference which should be applied. (negative values would
subtract the stored file size)
@throws IOException on I/O errors.
| AsfStreamer::modifyFileHeader | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/io/AsfStreamer.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/io/AsfStreamer.java | Apache-2.0 |
public ModificationResult(final int chunkCountDiff, final long bytesDiffer, final GUID... occurred)
{
assert occurred != null && occurred.length > 0;
this.chunkDifference = chunkCountDiff;
this.byteDifference = bytesDiffer;
this.occuredGUIDs.addAll(Arrays.asList(occurred));
} |
Creates an instance.<br>
@param chunkCountDiff amount of chunks appeared, disappeared
@param bytesDiffer amount of bytes added or removed.
@param occurred all GUIDs which have been occurred, during processing
| ModificationResult::ModificationResult | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/io/ModificationResult.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/io/ModificationResult.java | Apache-2.0 |
public long getByteDifference()
{
return this.byteDifference;
} |
Returns the difference of bytes.
@return the byte difference
| ModificationResult::getByteDifference | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/io/ModificationResult.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/io/ModificationResult.java | Apache-2.0 |
public int getChunkCountDifference()
{
return this.chunkDifference;
} |
Returns the difference of the amount of chunks.
@return the chunk count difference
| ModificationResult::getChunkCountDifference | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/io/ModificationResult.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/io/ModificationResult.java | Apache-2.0 |
public Set<GUID> getOccuredGUIDs()
{
return new HashSet<GUID>(this.occuredGUIDs);
} |
Returns all GUIDs which have been occurred during processing.
@return see description.s
| ModificationResult::getOccuredGUIDs | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/io/ModificationResult.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/io/ModificationResult.java | Apache-2.0 |
public ChunkRemover(final GUID... guids)
{
this.toRemove = new HashSet<GUID>();
for (final GUID current : guids)
{
this.toRemove.add(current);
}
} |
Creates an instance, for removing selected chunks.<br>
@param guids the GUIDs which are about to be removed by this modifier.
| ChunkRemover::ChunkRemover | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/asf/io/ChunkRemover.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/asf/io/ChunkRemover.java | Apache-2.0 |
public OggPageHeader readOggPageHeader(RandomAccessFile raf, int count) throws CannotReadException, IOException
{
OggPageHeader pageHeader = OggPageHeader.read(raf);
while (count > 0)
{
raf.seek(raf.getFilePointer() + pageHeader.getPageLength());
pageHeader = OggPageHeader.read(raf);
count--;
}
return pageHeader;
} |
Return count Ogg Page header, count starts from zero
count=0; should return PageHeader that contains Vorbis Identification Header
count=1; should return Pageheader that contains VorbisComment and possibly SetupHeader
count>=2; should return PageHeader containing remaining VorbisComment,SetupHeader and/or Audio
@param raf
@param count
@return
@throws CannotReadException
@throws IOException
| OggFileReader::readOggPageHeader | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/ogg/OggFileReader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/ogg/OggFileReader.java | Apache-2.0 |
public void summarizeOggPageHeaders(File oggFile) throws CannotReadException, IOException
{
RandomAccessFile raf = new RandomAccessFile(oggFile, "r");
while (raf.getFilePointer() < raf.length())
{
System.out.println("pageHeader starts at absolute file position:" + raf.getFilePointer());
OggPageHeader pageHeader = OggPageHeader.read(raf);
System.out.println("pageHeader finishes at absolute file position:" + raf.getFilePointer());
System.out.println(pageHeader + "\n");
raf.seek(raf.getFilePointer() + pageHeader.getPageLength());
}
System.out.println("Raf File Pointer at:" + raf.getFilePointer() + "File Size is:" + raf.length());
raf.close();
} |
Summarize all the ogg headers in a file
A useful utility function
@param oggFile
@throws CannotReadException
@throws IOException
| OggFileReader::summarizeOggPageHeaders | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/ogg/OggFileReader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/ogg/OggFileReader.java | Apache-2.0 |
public void shortSummarizeOggPageHeaders(File oggFile) throws CannotReadException, IOException
{
RandomAccessFile raf = new RandomAccessFile(oggFile, "r");
int i = 0;
while (raf.getFilePointer() < raf.length())
{
System.out.println("pageHeader starts at absolute file position:" + raf.getFilePointer());
OggPageHeader pageHeader = OggPageHeader.read(raf);
System.out.println("pageHeader finishes at absolute file position:" + raf.getFilePointer());
System.out.println(pageHeader + "\n");
raf.seek(raf.getFilePointer() + pageHeader.getPageLength());
i++;
if(i>=5)
{
break;
}
}
System.out.println("Raf File Pointer at:" + raf.getFilePointer() + "File Size is:" + raf.length());
raf.close();
} |
Summarizes the first five pages, normally all we are interested in
@param oggFile
@throws CannotReadException
@throws IOException
| OggFileReader::shortSummarizeOggPageHeaders | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/ogg/OggFileReader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/ogg/OggFileReader.java | Apache-2.0 |
public Tag read(RandomAccessFile raf) throws CannotReadException, IOException
{
logger.config("Starting to read ogg vorbis tag from file:");
byte[] rawVorbisCommentData = readRawPacketData(raf);
//Begin tag reading
VorbisCommentTag tag = vorbisCommentReader.read(rawVorbisCommentData, true);
logger.fine("CompletedReadCommentTag");
return tag;
} |
Read the Logical VorbisComment Tag from the file
<p>Read the CommenyTag, within an OggVorbis file the VorbisCommentTag is mandatory
@param raf
@return
@throws CannotReadException
@throws IOException
| OggVorbisTagReader::read | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/ogg/OggVorbisTagReader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/ogg/OggVorbisTagReader.java | Apache-2.0 |
public int readOggVorbisRawSize(RandomAccessFile raf) throws CannotReadException, IOException
{
byte[] rawVorbisCommentData = readRawPacketData(raf);
return rawVorbisCommentData.length + VorbisHeader.FIELD_PACKET_TYPE_LENGTH + VorbisHeader.FIELD_CAPTURE_PATTERN_LENGTH;
} |
Retrieve the Size of the VorbisComment packet including the oggvorbis header
@param raf
@return
@throws CannotReadException
@throws IOException
| OggVorbisTagReader::readOggVorbisRawSize | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/ogg/OggVorbisTagReader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/ogg/OggVorbisTagReader.java | Apache-2.0 |
public byte[] readRawPacketData(RandomAccessFile raf) throws CannotReadException, IOException
{
logger.fine("Read 1st page");
//1st page = codec infos
OggPageHeader pageHeader = OggPageHeader.read(raf);
//Skip over data to end of page header 1
raf.seek(raf.getFilePointer() + pageHeader.getPageLength());
logger.fine("Read 2nd page");
//2nd page = comment, may extend to additional pages or not , may also have setup header
pageHeader = OggPageHeader.read(raf);
//Now at start of packets on page 2 , check this is the vorbis comment header
byte[] b = new byte[VorbisHeader.FIELD_PACKET_TYPE_LENGTH + VorbisHeader.FIELD_CAPTURE_PATTERN_LENGTH];
raf.read(b);
if (!isVorbisCommentHeader(b))
{
throw new CannotReadException("Cannot find comment block (no vorbiscomment header)");
}
//Convert the comment raw data which maybe over many pages back into raw packet
byte[] rawVorbisCommentData = convertToVorbisCommentPacket(pageHeader, raf);
return rawVorbisCommentData;
} |
Retrieve the raw VorbisComment packet data, does not include the OggVorbis header
@param raf
@return
@throws CannotReadException if unable to find vorbiscomment header
@throws IOException
| OggVorbisTagReader::readRawPacketData | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/ogg/OggVorbisTagReader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/ogg/OggVorbisTagReader.java | Apache-2.0 |
public boolean isVorbisCommentHeader(byte[] headerData)
{
String vorbis = new String(headerData, VorbisHeader.FIELD_CAPTURE_PATTERN_POS, VorbisHeader.FIELD_CAPTURE_PATTERN_LENGTH, StandardCharsets.ISO_8859_1);
return !(headerData[VorbisHeader.FIELD_PACKET_TYPE_POS] != VorbisPacketType.COMMENT_HEADER.getType() || !vorbis.equals(VorbisHeader.CAPTURE_PATTERN));
} |
Is this a Vorbis Comment header, check
Note this check only applies to Vorbis Comments embedded within an OggVorbis File which is why within here
@param headerData
@return true if the headerData matches a VorbisComment header i.e is a Vorbis header of type COMMENT_HEADER
| OggVorbisTagReader::isVorbisCommentHeader | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/ogg/OggVorbisTagReader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/ogg/OggVorbisTagReader.java | Apache-2.0 |
public boolean isVorbisSetupHeader(byte[] headerData)
{
String vorbis = new String(headerData, VorbisHeader.FIELD_CAPTURE_PATTERN_POS, VorbisHeader.FIELD_CAPTURE_PATTERN_LENGTH, StandardCharsets.ISO_8859_1);
return !(headerData[VorbisHeader.FIELD_PACKET_TYPE_POS] != VorbisPacketType.SETUP_HEADER.getType() || !vorbis.equals(VorbisHeader.CAPTURE_PATTERN));
} |
Is this a Vorbis SetupHeader check
@param headerData
@return true if matches vorbis setupheader
| OggVorbisTagReader::isVorbisSetupHeader | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/ogg/OggVorbisTagReader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/ogg/OggVorbisTagReader.java | Apache-2.0 |
private byte[] convertToVorbisCommentPacket(OggPageHeader startVorbisCommentPage, RandomAccessFile raf) throws IOException, CannotReadException
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] b = new byte[startVorbisCommentPage.getPacketList().get(0).getLength() - (VorbisHeader.FIELD_PACKET_TYPE_LENGTH + VorbisHeader.FIELD_CAPTURE_PATTERN_LENGTH)];
raf.read(b);
baos.write(b);
//Because there is at least one other packet (SetupHeaderPacket) this means the Comment Packet has finished
//on this page so thats all we need and we can return
if (startVorbisCommentPage.getPacketList().size() > 1)
{
logger.config("Comments finish on 2nd Page because there is another packet on this page");
return baos.toByteArray();
}
//There is only the VorbisComment packet on page if it has completed on this page we can return
if (!startVorbisCommentPage.isLastPacketIncomplete())
{
logger.config("Comments finish on 2nd Page because this packet is complete");
return baos.toByteArray();
}
//The VorbisComment extends to the next page, so should be at end of page already
//so carry on reading pages until we get to the end of comment
while (true)
{
logger.config("Reading next page");
OggPageHeader nextPageHeader = OggPageHeader.read(raf);
b = new byte[nextPageHeader.getPacketList().get(0).getLength()];
raf.read(b);
baos.write(b);
//Because there is at least one other packet (SetupHeaderPacket) this means the Comment Packet has finished
//on this page so thats all we need and we can return
if (nextPageHeader.getPacketList().size() > 1)
{
logger.config("Comments finish on Page because there is another packet on this page");
return baos.toByteArray();
}
//There is only the VorbisComment packet on page if it has completed on this page we can return
if (!nextPageHeader.isLastPacketIncomplete())
{
logger.config("Comments finish on Page because this packet is complete");
return baos.toByteArray();
}
}
} |
The Vorbis Comment may span multiple pages so we we need to identify the pages they contain and then
extract the packet data from the pages
@param startVorbisCommentPage
@param raf
@throws org.jaudiotagger.audio.exceptions.CannotReadException
@throws java.io.IOException
@return
| OggVorbisTagReader::convertToVorbisCommentPacket | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/ogg/OggVorbisTagReader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/ogg/OggVorbisTagReader.java | Apache-2.0 |
public byte[] convertToVorbisSetupHeaderPacket(long fileOffsetOfStartingOggPage, RandomAccessFile raf) throws IOException, CannotReadException
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
//Seek to specified offset
raf.seek(fileOffsetOfStartingOggPage);
//Read Page
OggPageHeader setupPageHeader = OggPageHeader.read(raf);
//Assume that if multiple packets first packet is VorbisComment and second packet
//is setupheader
if (setupPageHeader.getPacketList().size() > 1)
{
raf.skipBytes(setupPageHeader.getPacketList().get(0).getLength());
}
//Now should be at start of next packet, check this is the vorbis setup header
byte[] b = new byte[VorbisHeader.FIELD_PACKET_TYPE_LENGTH + VorbisHeader.FIELD_CAPTURE_PATTERN_LENGTH];
raf.read(b);
if (!isVorbisSetupHeader(b))
{
throw new CannotReadException("Unable to find setup header(2), unable to write ogg file");
}
//Go back to start of setupheader data
raf.seek(raf.getFilePointer() - (VorbisHeader.FIELD_PACKET_TYPE_LENGTH + VorbisHeader.FIELD_CAPTURE_PATTERN_LENGTH));
//Read data
if (setupPageHeader.getPacketList().size() > 1)
{
b = new byte[setupPageHeader.getPacketList().get(1).getLength()];
raf.read(b);
baos.write(b);
}
else
{
b = new byte[setupPageHeader.getPacketList().get(0).getLength()];
raf.read(b);
baos.write(b);
}
//Return Data
if (!setupPageHeader.isLastPacketIncomplete() || setupPageHeader.getPacketList().size() > 2)
{
logger.config("Setupheader finishes on this page");
return baos.toByteArray();
}
//The Setupheader extends to the next page, so should be at end of page already
//so carry on reading pages until we get to the end of comment
while (true)
{
logger.config("Reading another page");
OggPageHeader nextPageHeader = OggPageHeader.read(raf);
b = new byte[nextPageHeader.getPacketList().get(0).getLength()];
raf.read(b);
baos.write(b);
//Because there is at least one other packet this means the Setupheader Packet has finished
//on this page so thats all we need and we can return
if (nextPageHeader.getPacketList().size() > 1)
{
logger.config("Setupheader finishes on this page");
return baos.toByteArray();
}
//There is only the Setupheader packet on page if it has completed on this page we can return
if (!nextPageHeader.isLastPacketIncomplete())
{
logger.config("Setupheader finish on Page because this packet is complete");
return baos.toByteArray();
}
}
} |
The Vorbis Setup Header may span multiple(2) pages, athough it doesnt normally. We pass the start of the
file offset of the OggPage it belongs on, it probably won't be first packet.
@param fileOffsetOfStartingOggPage
@param raf
@throws org.jaudiotagger.audio.exceptions.CannotReadException
@throws java.io.IOException
@return
| OggVorbisTagReader::convertToVorbisSetupHeaderPacket | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/ogg/OggVorbisTagReader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/ogg/OggVorbisTagReader.java | Apache-2.0 |
public byte[] convertToVorbisSetupHeaderPacketAndAdditionalPackets(long fileOffsetOfStartingOggPage, RandomAccessFile raf) throws IOException, CannotReadException
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
//Seek to specified offset
raf.seek(fileOffsetOfStartingOggPage);
//Read Page
OggPageHeader setupPageHeader = OggPageHeader.read(raf);
//Assume that if multiple packets first packet is VorbisComment and second packet
//is setupheader
if (setupPageHeader.getPacketList().size() > 1)
{
raf.skipBytes(setupPageHeader.getPacketList().get(0).getLength());
}
//Now should be at start of next packet, check this is the vorbis setup header
byte[] b = new byte[VorbisHeader.FIELD_PACKET_TYPE_LENGTH + VorbisHeader.FIELD_CAPTURE_PATTERN_LENGTH];
raf.read(b);
if (!isVorbisSetupHeader(b))
{
throw new CannotReadException("Unable to find setup header(2), unable to write ogg file");
}
//Go back to start of setupheader data
raf.seek(raf.getFilePointer() - (VorbisHeader.FIELD_PACKET_TYPE_LENGTH + VorbisHeader.FIELD_CAPTURE_PATTERN_LENGTH));
//Read data
if (setupPageHeader.getPacketList().size() > 1)
{
b = new byte[setupPageHeader.getPacketList().get(1).getLength()];
raf.read(b);
baos.write(b);
}
else
{
b = new byte[setupPageHeader.getPacketList().get(0).getLength()];
raf.read(b);
baos.write(b);
}
//Return Data
if (!setupPageHeader.isLastPacketIncomplete() || setupPageHeader.getPacketList().size() > 2)
{
logger.config("Setupheader finishes on this page");
if (setupPageHeader.getPacketList().size() > 2)
{
for (int i = 2; i < setupPageHeader.getPacketList().size(); i++)
{
b = new byte[setupPageHeader.getPacketList().get(i).getLength()];
raf.read(b);
baos.write(b);
}
}
return baos.toByteArray();
}
//The Setupheader extends to the next page, so should be at end of page already
//so carry on reading pages until we get to the end of comment
while (true)
{
logger.config("Reading another page");
OggPageHeader nextPageHeader = OggPageHeader.read(raf);
b = new byte[nextPageHeader.getPacketList().get(0).getLength()];
raf.read(b);
baos.write(b);
//Because there is at least one other packet this means the Setupheader Packet has finished
//on this page so thats all we need and we can return
if (nextPageHeader.getPacketList().size() > 1)
{
logger.config("Setupheader finishes on this page");
return baos.toByteArray();
}
//There is only the Setupheader packet on page if it has completed on this page we can return
if (!nextPageHeader.isLastPacketIncomplete())
{
logger.config("Setupheader finish on Page because this packet is complete");
return baos.toByteArray();
}
}
} |
The Vorbis Setup Header may span multiple(2) pages, athough it doesnt normally. We pass the start of the
file offset of the OggPage it belongs on, it probably won't be first packet, also returns any addditional
packets that immediately follow the setup header in original file
@param fileOffsetOfStartingOggPage
@param raf
@throws org.jaudiotagger.audio.exceptions.CannotReadException
@throws java.io.IOException
@return
| OggVorbisTagReader::convertToVorbisSetupHeaderPacketAndAdditionalPackets | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/ogg/OggVorbisTagReader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/ogg/OggVorbisTagReader.java | Apache-2.0 |
public OggVorbisHeaderSizes readOggVorbisHeaderSizes(RandomAccessFile raf) throws CannotReadException, IOException
{
logger.fine("Started to read comment and setup header sizes:");
//Stores filepointers so return file in same state
long filepointer = raf.getFilePointer();
//Extra Packets on same page as setup header
List<OggPageHeader.PacketStartAndLength> extraPackets = new ArrayList<OggPageHeader.PacketStartAndLength>();
long commentHeaderStartPosition;
long setupHeaderStartPosition;
int commentHeaderSize = 0;
int setupHeaderSize;
//1st page = codec infos
OggPageHeader pageHeader = OggPageHeader.read(raf);
//Skip over data to end of page header 1
raf.seek(raf.getFilePointer() + pageHeader.getPageLength());
//2nd page = comment, may extend to additional pages or not , may also have setup header
pageHeader = OggPageHeader.read(raf);
commentHeaderStartPosition = raf.getFilePointer() - (OggPageHeader.OGG_PAGE_HEADER_FIXED_LENGTH + pageHeader.getSegmentTable().length);
//Now at start of packets on page 2 , check this is the vorbis comment header
byte[] b = new byte[VorbisHeader.FIELD_PACKET_TYPE_LENGTH + VorbisHeader.FIELD_CAPTURE_PATTERN_LENGTH];
raf.read(b);
if (!isVorbisCommentHeader(b))
{
throw new CannotReadException("Cannot find comment block (no vorbiscomment header)");
}
raf.seek(raf.getFilePointer() - (VorbisHeader.FIELD_PACKET_TYPE_LENGTH + VorbisHeader.FIELD_CAPTURE_PATTERN_LENGTH));
logger.config("Found start of comment header at:" + raf.getFilePointer());
//Calculate Comment Size (not inc header)
while (true)
{
List<OggPageHeader.PacketStartAndLength> packetList = pageHeader.getPacketList();
commentHeaderSize += packetList.get(0).getLength();
raf.skipBytes(packetList.get(0).getLength());
//If this page contains multiple packets or if this last packet is complete then the Comment header
//end son this page and we can break
if (packetList.size() > 1 || !pageHeader.isLastPacketIncomplete())
{
//done comment size
logger.config("Found end of comment:size:" + commentHeaderSize + "finishes at file position:" + raf.getFilePointer());
break;
}
pageHeader = OggPageHeader.read(raf);
}
//If there are no more packets on this page we need to go to next page to get the setup header
OggPageHeader.PacketStartAndLength packet;
if(pageHeader.getPacketList().size()==1)
{
pageHeader = OggPageHeader.read(raf);
List<OggPageHeader.PacketStartAndLength> packetList = pageHeader.getPacketList();
packet = pageHeader.getPacketList().get(0);
//Now at start of next packet , check this is the vorbis setup header
b = new byte[VorbisHeader.FIELD_PACKET_TYPE_LENGTH + VorbisHeader.FIELD_CAPTURE_PATTERN_LENGTH];
raf.read(b);
if (!isVorbisSetupHeader(b))
{
throw new CannotReadException(ErrorMessage.OGG_VORBIS_NO_VORBIS_HEADER_FOUND.getMsg());
}
raf.seek(raf.getFilePointer() - (VorbisHeader.FIELD_PACKET_TYPE_LENGTH + VorbisHeader.FIELD_CAPTURE_PATTERN_LENGTH));
logger.config("Found start of vorbis setup header at file position:" + raf.getFilePointer());
//Set this to the start of the OggPage that setupheader was found on
setupHeaderStartPosition = raf.getFilePointer() - (OggPageHeader.OGG_PAGE_HEADER_FIXED_LENGTH + pageHeader.getSegmentTable().length);
//Add packet data to size to the setup header size
setupHeaderSize = packet.getLength();
logger.fine("Adding:" + packet.getLength() + " to setup header size");
//Skip over the packet data
raf.skipBytes(packet.getLength());
//If there are other packets that follow this one, or if the last packet is complete then we must have
//got the size of the setup header.
if (packetList.size() > 1 || !pageHeader.isLastPacketIncomplete())
{
logger.config("Found end of setupheader:size:" + setupHeaderSize + "finishes at:" + raf.getFilePointer());
if (packetList.size() > 1)
{
extraPackets = packetList.subList(1, packetList.size());
}
}
//The setup header continues onto the next page
else
{
pageHeader = OggPageHeader.read(raf);
packetList = pageHeader.getPacketList();
while (true)
{
setupHeaderSize += packetList.get(0).getLength();
logger.fine("Adding:" + packetList.get(0).getLength() + " to setup header size");
raf.skipBytes(packetList.get(0).getLength());
if (packetList.size() > 1 || !pageHeader.isLastPacketIncomplete())
{
//done setup size
logger.fine("Found end of setupheader:size:" + setupHeaderSize + "finishes at:" + raf.getFilePointer());
if (packetList.size() > 1)
{
extraPackets = packetList.subList(1, packetList.size());
}
break;
}
//Continues onto another page
pageHeader = OggPageHeader.read(raf);
}
}
}
//else its next packet on this page
else
{
packet = pageHeader.getPacketList().get(1);
List<OggPageHeader.PacketStartAndLength> packetList = pageHeader.getPacketList();
//Now at start of next packet , check this is the vorbis setup header
b = new byte[VorbisHeader.FIELD_PACKET_TYPE_LENGTH + VorbisHeader.FIELD_CAPTURE_PATTERN_LENGTH];
raf.read(b);
if (!isVorbisSetupHeader(b))
{
logger.warning("Expecting but got:"+new String(b)+ "at "+(raf.getFilePointer() - b.length));
throw new CannotReadException(ErrorMessage.OGG_VORBIS_NO_VORBIS_HEADER_FOUND.getMsg());
}
raf.seek(raf.getFilePointer() - (VorbisHeader.FIELD_PACKET_TYPE_LENGTH + VorbisHeader.FIELD_CAPTURE_PATTERN_LENGTH));
logger.config("Found start of vorbis setup header at file position:" + raf.getFilePointer());
//Set this to the start of the OggPage that setupheader was found on
setupHeaderStartPosition = raf.getFilePointer() - (OggPageHeader.OGG_PAGE_HEADER_FIXED_LENGTH + pageHeader.getSegmentTable().length)
- pageHeader.getPacketList().get(0).getLength();
//Add packet data to size to the setup header size
setupHeaderSize = packet.getLength();
logger.fine("Adding:" + packet.getLength() + " to setup header size");
//Skip over the packet data
raf.skipBytes(packet.getLength());
//If there are other packets that follow this one, or if the last packet is complete then we must have
//got the size of the setup header.
if (packetList.size() > 2 || !pageHeader.isLastPacketIncomplete())
{
logger.fine("Found end of setupheader:size:" + setupHeaderSize + "finishes at:" + raf.getFilePointer());
if (packetList.size() > 2)
{
extraPackets = packetList.subList(2, packetList.size());
}
}
//The setup header continues onto the next page
else
{
pageHeader = OggPageHeader.read(raf);
packetList = pageHeader.getPacketList();
while (true)
{
setupHeaderSize += packetList.get(0).getLength();
logger.fine("Adding:" + packetList.get(0).getLength() + " to setup header size");
raf.skipBytes(packetList.get(0).getLength());
if (packetList.size() > 1 || !pageHeader.isLastPacketIncomplete())
{
//done setup size
logger.fine("Found end of setupheader:size:" + setupHeaderSize + "finishes at:" + raf.getFilePointer());
if (packetList.size() > 1)
{
extraPackets = packetList.subList(1, packetList.size());
}
break;
}
//Continues onto another page
pageHeader = OggPageHeader.read(raf);
}
}
}
//Reset filepointer to location that it was in at start of method
raf.seek(filepointer);
return new OggVorbisHeaderSizes(commentHeaderStartPosition, setupHeaderStartPosition, commentHeaderSize, setupHeaderSize, extraPackets);
} |
Calculate the size of the packet data for the comment and setup headers
@param raf
@return
@throws CannotReadException
@throws IOException
| OggVorbisTagReader::readOggVorbisHeaderSizes | java | ZTFtrue/MonsterMusic | app/src/main/java/org/jaudiotagger/audio/ogg/OggVorbisTagReader.java | https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/audio/ogg/OggVorbisTagReader.java | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.