Search in sources :

Example 6 with Mp4DataBox

use of org.jaudiotagger.tag.mp4.atom.Mp4DataBox in project MusicDNA by harjot-oberai.

the class Mp4TagReverseDnsField method build.

protected void build(ByteBuffer data) throws UnsupportedEncodingException {
    // Read mean box, set the issuer and skip over data
    Mp4BoxHeader meanBoxHeader = new Mp4BoxHeader(data);
    Mp4MeanBox meanBox = new Mp4MeanBox(meanBoxHeader, data);
    setIssuer(meanBox.getIssuer());
    data.position(data.position() + meanBoxHeader.getDataLength());
    // Read name box, identify what type of field it is
    Mp4BoxHeader nameBoxHeader = new Mp4BoxHeader(data);
    Mp4NameBox nameBox = new Mp4NameBox(nameBoxHeader, data);
    setDescriptor(nameBox.getName());
    data.position(data.position() + nameBoxHeader.getDataLength());
    // Issue 198:There is not actually a data atom there cannot cant be because no room for one
    if (parentHeader.getDataLength() == meanBoxHeader.getLength() + nameBoxHeader.getLength()) {
        id = IDENTIFIER + ":" + issuer + ":" + descriptor;
        setContent("");
        logger.warning(ErrorMessage.MP4_REVERSE_DNS_FIELD_HAS_NO_DATA.getMsg(id));
    } else // Usual Case
    {
        // Read data box, identify the data
        Mp4BoxHeader dataBoxHeader = new Mp4BoxHeader(data);
        Mp4DataBox dataBox = new Mp4DataBox(dataBoxHeader, data);
        setContent(dataBox.getContent());
        data.position(data.position() + dataBoxHeader.getDataLength());
        // Now calculate the id which in order to be unique needs to use all htree values
        id = IDENTIFIER + ":" + issuer + ":" + descriptor;
    }
}
Also used : Mp4NameBox(org.jaudiotagger.tag.mp4.atom.Mp4NameBox) Mp4MeanBox(org.jaudiotagger.tag.mp4.atom.Mp4MeanBox) Mp4DataBox(org.jaudiotagger.tag.mp4.atom.Mp4DataBox) Mp4BoxHeader(org.jaudiotagger.audio.mp4.atom.Mp4BoxHeader)

Example 7 with Mp4DataBox

use of org.jaudiotagger.tag.mp4.atom.Mp4DataBox in project MusicDNA by harjot-oberai.

the class Mp4GenreField method build.

protected void build(ByteBuffer data) throws UnsupportedEncodingException {
    // Data actually contains a 'Data' Box so process data using this
    Mp4BoxHeader header = new Mp4BoxHeader(data);
    Mp4DataBox databox = new Mp4DataBox(header, data);
    dataSize = header.getDataLength();
    numbers = databox.getNumbers();
    if (numbers.size() > 0) {
        int genreId = numbers.get(0);
        // Get value, we have to adjust index by one because iTunes labels from one instead of zero
        content = GenreTypes.getInstanceOf().getValueForId(genreId - 1);
        // as null so apps can handle if they wish, but we do display a warning to make them aware.
        if (content == null) {
            logger.warning(ErrorMessage.MP4_GENRE_OUT_OF_RANGE.getMsg(genreId));
        }
    } else {
        logger.warning(ErrorMessage.MP4_NO_GENREID_FOR_GENRE.getMsg(header.getDataLength()));
    }
}
Also used : Mp4DataBox(org.jaudiotagger.tag.mp4.atom.Mp4DataBox) Mp4BoxHeader(org.jaudiotagger.audio.mp4.atom.Mp4BoxHeader)

Aggregations

Mp4BoxHeader (org.jaudiotagger.audio.mp4.atom.Mp4BoxHeader)7 Mp4DataBox (org.jaudiotagger.tag.mp4.atom.Mp4DataBox)7 Mp4MeanBox (org.jaudiotagger.tag.mp4.atom.Mp4MeanBox)1 Mp4NameBox (org.jaudiotagger.tag.mp4.atom.Mp4NameBox)1