Package org.cmc.music.common

Examples of org.cmc.music.common.ID3WriteException


    for (int i = 0; i < untranslatedKeys.size(); i++)
    {
      String key = (String) untranslatedKeys.get(i);

      if (strict)
        throw new ID3WriteException(
            "Could not translate metadata key: " + key);
      else if (null != listener)
        listener.log("Could not translate metadata key", key);
    }
View Full Code Here


    if (id3v2_version == 4)
      result[index++] = 0x04; // version
    else if (id3v2_version == 3)
      result[index++] = 0x03; // version
    else
      throw new ID3WriteException("id3v2_version: " + id3v2_version);

    result[index++] = 0x00;

    int flags = 0; // charles
    if (id3v2_version == 4)
      flags |= HEADER_FLAG_ID3v24_FOOTER_PRESENT;
    else if (id3v2_version == 3)
    {
    } else
      throw new ID3WriteException("id3v2_version: " + id3v2_version);

    result[index++] = (byte) flags;

    writeSynchSafeInt(result, index, body_length);
View Full Code Here

    value >>= 7;
    bytes[start + 0] = (byte) (value & 0x7f);

    value >>= 7;
    if (value != 0)
      throw new ID3WriteException("Value to large for synch safe int: "
          + value);
  }
View Full Code Here

    {
      ID3v2OutputFrame frame = (ID3v2OutputFrame) frames.get(i);

      String frame_id = frame.longFrameID;
      if (frame_id.length() != 4)
        throw new ID3WriteException("frame_id has bad length: "
            + frame_id + " (" + frame_id.length() + ")");

      if (filter != null && filter.filter(frame_id))
      {
        continue;
      }

      // baos.write(frame_id );
      baos.write((byte) frame_id.charAt(0));
      baos.write((byte) frame_id.charAt(1));
      baos.write((byte) frame_id.charAt(2));
      baos.write((byte) frame_id.charAt(3));

      int length = frame.bytes.length;

      if (id3v2_version == 4)
      {
        baos.write((byte) (0x7f & (length >> 21)));
        baos.write((byte) (0x7f & (length >> 14)));
        baos.write((byte) (0x7f & (length >> 7)));
        baos.write((byte) (0x7f & (length)));
      } else if (id3v2_version == 3)
      {
        baos.write((byte) (0xff & (length >> 24)));
        baos.write((byte) (0xff & (length >> 16)));
        baos.write((byte) (0xff & (length >> 8)));
        baos.write((byte) (0xff & (length)));
      } else
        throw new ID3WriteException("id3v2_version: " + id3v2_version);

      // int flags = frame.flags;
      int flags = 0;
      if (id3v2_version == 4)
      {
        if (frame.flags.getTagAlterPreservation())
          flags |= FRAME_FLAG_ID3v24_TAG_ALTER_PRESERVATION;
        if (frame.flags.getFileAlterPreservation())
          flags |= FRAME_FLAG_ID3v24_FILE_ALTER_PRESERVATION;
        if (frame.flags.getReadOnly())
          flags |= FRAME_FLAG_ID3v24_READ_ONLY;
        if (frame.flags.getGroupingIdentity())
          flags |= FRAME_FLAG_ID3v24_GROUPING_IDENTITY;
        if (frame.flags.getCompression())
          flags |= FRAME_FLAG_ID3v24_COMPRESSION;
        if (frame.flags.getEncryption())
          flags |= FRAME_FLAG_ID3v24_ENCRYPTION;
        if (frame.flags.getUnsynchronisation())
          flags |= FRAME_FLAG_ID3v24_UNSYNCHRONISATION;
        if (frame.flags.getDataLengthIndicator())
          flags |= FRAME_FLAG_ID3v24_DATA_LENGTH_INDICATOR;
      } else if (id3v2_version == 3)
      {
        if (frame.flags.getTagAlterPreservation())
          flags |= FRAME_FLAG_ID3v23_TAG_ALTER_PRESERVATION;
        if (frame.flags.getFileAlterPreservation())
          flags |= FRAME_FLAG_ID3v23_FILE_ALTER_PRESERVATION;
        if (frame.flags.getReadOnly())
          flags |= FRAME_FLAG_ID3v23_READ_ONLY;
        if (frame.flags.getGroupingIdentity())
          flags |= FRAME_FLAG_ID3v23_GROUPING_IDENTITY;
        if (frame.flags.getCompression())
          flags |= FRAME_FLAG_ID3v23_COMPRESSION;
        if (frame.flags.getEncryption())
          flags |= FRAME_FLAG_ID3v23_ENCRYPTION;
      } else
        throw new ID3WriteException("id3v2_version: " + id3v2_version);

      baos.write((byte) (0xff & (flags >> 8)));
      baos.write((byte) (0xff & (flags)));

      baos.write(frame.bytes);
View Full Code Here

          longFrameID = oldFrame.frameID;
          frameOrder = ID3FrameType.DEFAULT_FRAME_ORDER;
        } else
        {
          if (strict)
            throw new ID3WriteException("unknown frame type: "
                + oldFrame.frameID);
          else if (null != listener)
          {
            listener.log("unknown frame type", oldFrame.frameID);
            listener.log("unknown old_tag", oldFrame);
            listener.log(Debug.getStackTrace());
          }

          continue;
        }
      }

      if (new_frame_ids.contains(longFrameID))
        continue;

      if (null != listener)
        listener.log("adding missing frame", longFrameID);

      if (oldFrame instanceof MyID3v2FrameText)
      {
        MyID3v2FrameText text_frame = (MyID3v2FrameText) oldFrame;

        // ID3FrameType frame_type =
        // ID3FrameType.get(old_frame.frame_id);
        if (null != listener)
        {
          listener.log("text_frame", text_frame);
          listener.log("frame_type", longFrameID);
        }

        ID3v2OutputFrame frame = toFrame(longFrameID, frameOrder,
            text_frame.value, text_frame.value2);

        if (frame != null)
        {
          frames.add(frame);
          final_frame_ids.add(frame.longFrameID);
        } else
        {
          if (strict)
            throw new ID3WriteException("Couldn't write frame: "
                + longFrameID);
          else if (null != listener)
          {
            listener.log("Couldn't write frame", longFrameID);
            listener.log(Debug.getStackTrace());
          }
        }
      } else if (oldFrame instanceof MyID3v2FrameImage)
      {
        MyID3v2FrameImage imageFrame = (MyID3v2FrameImage) oldFrame;

        if (null != listener)
        {
          listener.log("imageFrame", imageFrame);
          listener.log("frame_type", longFrameID);
        }

        ID3v2OutputFrame frame = toFrameImage(longFrameID, frameOrder,
            imageFrame.getImageData());

        frames.add(frame);
        final_frame_ids.add(frame.longFrameID);
      } else
      {
        MyID3v2FrameData data = (MyID3v2FrameData) oldFrame;
        if (data.flags.getTagAlterPreservation())
          continue;
        // if(data.flags.getTagAlterPreservation())
        // continue;
        if (data.frameID.length() == 4)
        {
          // if(data.flags.getCompression() ||
          // data.flags.getUnsynchronisation() || )
          // int flags = data.flags.flags;
          ID3v2OutputFrame frame = new ID3v2OutputFrame(data.frameID,
              data.dataBytes, data.flags);
          frames.add(frame);
          final_frame_ids.add(frame.longFrameID);
          continue;
        }

        if (strict)
          throw new ID3WriteException(
              "Couldn't preserve data frame: " + data.frameID);
        else if (null != listener)
        {
          listener.log("Couldn't preserve data frame", data.frameID);
          listener.log(Debug.getStackTrace());
View Full Code Here

    if (id3v2_version == 4)
      footer = getHeaderFooter(body_length, true);
    else if (id3v2_version == 3)
      footer = null;
    else
      throw new ID3WriteException("id3v2_version: " + id3v2_version);

    // Debug.debug("footer", footer);

    int resultLength = header.length + extended_header.length
        + frame_bytes.length + padding.length;
View Full Code Here

TOP

Related Classes of org.cmc.music.common.ID3WriteException

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.