1 /*
   2  * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.media.sound;
  27 
  28 import javax.sound.sampled.AudioFormat;
  29 
  30 /**
  31  * AIFF file format.
  32  *
  33  * @author Jan Borgersen
  34  */
  35 final class AiffFileFormat extends StandardFileFormat {
  36 
  37     static final int AIFF_MAGIC         = 1179603533;
  38 
  39     // for writing AIFF
  40     static final int AIFC_MAGIC                 = 0x41494643;   // 'AIFC'
  41     static final int AIFF_MAGIC2                = 0x41494646;   // 'AIFF'
  42     static final int FVER_MAGIC                 = 0x46564552;   // 'FVER'
  43     static final int FVER_TIMESTAMP             = 0xA2805140;   // timestamp of last AIFF-C update
  44     static final int COMM_MAGIC                 = 0x434f4d4d;   // 'COMM'
  45     static final int SSND_MAGIC                 = 0x53534e44;   // 'SSND'
  46 
  47     // compression codes
  48     static final int AIFC_PCM                   = 0x4e4f4e45;   // 'NONE' PCM
  49     static final int AIFC_ACE2                  = 0x41434532;   // 'ACE2' ACE 2:1 compression
  50     static final int AIFC_ACE8                  = 0x41434538;   // 'ACE8' ACE 8:3 compression
  51     static final int AIFC_MAC3                  = 0x4d414333;   // 'MAC3' MACE 3:1 compression
  52     static final int AIFC_MAC6                  = 0x4d414336;   // 'MAC6' MACE 6:1 compression
  53     static final int AIFC_ULAW                  = 0x756c6177;   // 'ulaw' ITU G.711 u-Law
  54     static final int AIFC_IMA4                  = 0x696d6134;   // 'ima4' IMA ADPCM
  55 
  56     // $$fb static approach not good, but needed for estimation
  57     static final int AIFF_HEADERSIZE    = 54;
  58 
  59     //$$fb 2001-07-13: added management of header size in this class
  60 
  61     /** header size in bytes */
  62     private final int headerSize=AIFF_HEADERSIZE;
  63 
  64     /** comm chunk size in bytes, inclusive magic and length field */
  65     private final int commChunkSize=26;
  66 
  67     /** FVER chunk size in bytes, inclusive magic and length field */
  68     private final int fverChunkSize=0;
  69 
  70     AiffFileFormat(final Type type, final long byteLength,
  71                    final AudioFormat format, final long frameLength) {
  72         super(type, byteLength, format, frameLength);
  73     }
  74 
  75     int getHeaderSize() {
  76         return headerSize;
  77     }
  78 
  79     int getCommChunkSize() {
  80         return commChunkSize;
  81     }
  82 
  83     int getFverChunkSize() {
  84         return fverChunkSize;
  85     }
  86 
  87     int getSsndChunkOffset() {
  88         return getHeaderSize()-16;
  89     }
  90 
  91 }