Package entagged.audioformats.asf.data

Examples of entagged.audioformats.asf.data.ContentDescriptor


         * Now search for a content descriptor whose id is not one of
         * ignoreDescriptors. These descriptors cannot be modified by entagged
         * and will be preserved
         */
        while (it.hasNext() && !found) {
            ContentDescriptor current = (ContentDescriptor) it.next();
            found = !ignoreDescriptors.contains(current.getName());
        }
        return !found && !isExtendedContentDescriptionMandatory(tag);
    }
View Full Code Here


            result = new ExtendedContentDescription(chunkStart, chunkLen);

            for (long i = 0; i < descriptorCount; i++) {
                String tagElement = Utils.readUTF16LEStr(raf);
                int type = Utils.readUINT16(raf);
                ContentDescriptor prop = new ContentDescriptor(tagElement, type);
                switch (type) {
                case ContentDescriptor.TYPE_STRING:
                    prop.setStringValue(Utils.readUTF16LEStr(raf));
                    break;
                case ContentDescriptor.TYPE_BINARY:
                    prop.setBinaryValue(readBinaryData(raf));
                    break;
                case ContentDescriptor.TYPE_BOOLEAN:
                    prop.setBooleanValue(readBoolean(raf));
                    break;
                case ContentDescriptor.TYPE_DWORD:
                    raf.skipBytes(2);
                    prop.setDWordValue(Utils.readUINT32(raf));
                    break;
                case ContentDescriptor.TYPE_WORD:
                    raf.skipBytes(2);
                    prop.setWordValue(Utils.readUINT16(raf));
                    break;
                case ContentDescriptor.TYPE_QWORD:
                    raf.skipBytes(2);
                    prop.setQWordValue(Utils.readUINT64(raf));
                    break;
                default:
                    // Unknown, hopefully the convention for the size of the
                    // value
                    // is given, so we could read it binary
                    prop.setStringValue("Invalid datatype: "
                            + new String(readBinaryData(raf)));
                }
                result.addDescriptor(prop);
            }
        }
View Full Code Here

            int errors = testContentDescription(header, okString);
            assertTrue(errors == 0);
            errors = testContentDescription(header, errorString);
            assertTrue(errors == 5);
        }
        ContentDescriptor desc;
        try {
            desc = new ContentDescriptor(errorString,
                    ContentDescriptor.TYPE_STRING);
            Assert
                    .fail("Construction shouldn't be possible with such a large name");
        } catch (Exception e) {
            // Here is all OK
        }
        desc = new ContentDescriptor(okString, ContentDescriptor.TYPE_STRING);
        try {
            desc.setStringValue(errorString);
            Assert.fail("Value is too long but accepted");
        } catch (Exception e) {
            // Here is all OK
        }
        desc.setStringValue(okString);

        assertTrue(header.getFileHeader().getFileSize().equals(
                BigInteger.valueOf(this.file.length())));
    }
View Full Code Here

   *            values. <br>
   *            <b>Warning: </b> the common values will be replaced.
   */
  public static void assignCommonTagValues(Tag tag,
      ExtendedContentDescription description) {
    ContentDescriptor tmp = null;
    if (tag.getFirstAlbum() != null && tag.getFirstAlbum().length() > 0) {
      tmp = new ContentDescriptor(ContentDescriptor.ID_ALBUM,
          ContentDescriptor.TYPE_STRING);
      tmp.setStringValue(tag.getFirstAlbum());
      description.addOrReplace(tmp);
    } else {
      description.remove(ContentDescriptor.ID_ALBUM);
    }
    if (tag.getFirstTrack() != null && tag.getFirstTrack().length() > 0) {
      tmp = new ContentDescriptor(ContentDescriptor.ID_TRACKNUMBER,
          ContentDescriptor.TYPE_STRING);
      tmp.setStringValue(tag.getFirstTrack());
      description.addOrReplace(tmp);
    } else {
      description.remove(ContentDescriptor.ID_TRACKNUMBER);
    }
    if (tag.getFirstYear() != null && tag.getFirstYear().length() > 0) {
      tmp = new ContentDescriptor(ContentDescriptor.ID_YEAR,
          ContentDescriptor.TYPE_STRING);
      tmp.setStringValue(tag.getFirstYear());
      description.addOrReplace(tmp);
    } else {
      description.remove(ContentDescriptor.ID_YEAR);
    }
    if (tag.getFirstGenre() != null && tag.getFirstGenre().length() > 0) {
      tmp = new ContentDescriptor(ContentDescriptor.ID_GENRE,
          ContentDescriptor.TYPE_STRING);
      tmp.setStringValue(tag.getFirstGenre());
      description.addOrReplace(tmp);
      int index = Arrays.asList(Tag.DEFAULT_GENRES).indexOf(
          tag.getFirstGenre());
      if (index != -1) {
        tmp = new ContentDescriptor(ContentDescriptor.ID_GENREID,
            ContentDescriptor.TYPE_STRING);
        tmp.setStringValue("(" + index + ")");
        description.addOrReplace(tmp);
      } else {
        description.remove(ContentDescriptor.ID_GENREID);
      }
    } else {
View Full Code Here

   *            the extended content description.
   */
  public static void assignOptionalTagValues(Tag tag,
      ExtendedContentDescription descriptor) {
    Iterator it = tag.getFields();
    ContentDescriptor tmp = null;
    while (it.hasNext()) {
      try {
        TagField currentField = (TagField) it.next();
        if (!currentField.isCommon()) {
          tmp = new ContentDescriptor(currentField.getId(),
              ContentDescriptor.TYPE_STRING);
          if (currentField.isBinary()) {
            tmp.setBinaryValue(currentField.getRawContent());
          } else {
            tmp.setStringValue(currentField.toString());
          }
          descriptor.addOrReplace(tmp);
        }
      } catch (UnsupportedEncodingException uee) {
        uee.printStackTrace();
View Full Code Here

       */
      ExtendedContentDescription extDesc = source
          .getExtendedContentDescription();
      Iterator it = extDesc.getDescriptors().iterator();
      while (it.hasNext()) {
        ContentDescriptor current = (ContentDescriptor) it.next();
        // If common, it has been added to the result some lines upward.
        if (!current.isCommon()) {
          result.add(new ContentDescriptorTagField(current));
        }
      }
    }
    return result;
View Full Code Here

TOP

Related Classes of entagged.audioformats.asf.data.ContentDescriptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.