~ubuntu-branches/ubuntu/utopic/libjaudiotagger-java/utopic

« back to all changes in this revision

Viewing changes to src/org/jaudiotagger/audio/mp4/atom/Mp4FreeBox.java

  • Committer: Bazaar Package Importer
  • Author(s): Damien Raude-Morvan
  • Date: 2011-04-28 23:52:43 UTC
  • mfrom: (3.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20110428235243-pzalvw6lncis3ukf
Tags: 2.0.3-1
* d/control: Drop Depends on default-jre per Debian Java Policy as its
  a library package.
* d/watch: Fix to directly monitor SVN tags.
* Switch to 3.0 (quilt) format.
* Bump Standards-Version to 3.9.2 (no changes needed).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
package org.jaudiotagger.audio.mp4.atom;
2
 
 
3
 
import org.jaudiotagger.audio.generic.Utils;
4
 
import org.jaudiotagger.audio.mp4.Mp4NotMetaFieldKey;
5
 
 
6
 
import java.io.ByteArrayOutputStream;
7
 
import java.io.IOException;
8
 
import java.nio.ByteBuffer;
9
 
 
10
 
/**
11
 
 * FreeBox ( padding)
12
 
 * <p/>
13
 
 * <p>There are usually two free boxes, one beneath the meta atom and one toplevel atom
14
 
 */
15
 
public class Mp4FreeBox extends AbstractMp4Box
16
 
{
17
 
    /**
18
 
     * Construct a new FreeBox containing datasize padding (i.e doesnt include header size)
19
 
     *
20
 
     * @param datasize padding size
21
 
     */
22
 
    public Mp4FreeBox(int datasize)
23
 
    {
24
 
        try
25
 
        {
26
 
            //Header
27
 
            header = new Mp4BoxHeader();
28
 
            ByteArrayOutputStream headerBaos = new ByteArrayOutputStream();
29
 
            headerBaos.write(Utils.getSizeBEInt32(Mp4BoxHeader.HEADER_LENGTH + datasize));
30
 
            headerBaos.write(Utils.getDefaultBytes(Mp4NotMetaFieldKey.FREE.getFieldName(), "ISO-8859-1"));
31
 
            header.update(ByteBuffer.wrap(headerBaos.toByteArray()));
32
 
 
33
 
            //Body
34
 
            ByteArrayOutputStream freeBaos = new ByteArrayOutputStream();
35
 
            for (int i = 0; i < datasize; i++)
36
 
            {
37
 
                freeBaos.write(0x0);
38
 
            }
39
 
            dataBuffer = ByteBuffer.wrap(freeBaos.toByteArray());
40
 
        }
41
 
        catch (IOException ioe)
42
 
        {
43
 
            //This should never happen as were not actually writing to/from a file
44
 
            throw new RuntimeException(ioe);
45
 
        }
46
 
    }
47
 
 
48
 
}
 
1
package org.jaudiotagger.audio.mp4.atom;
 
2
 
 
3
import org.jaudiotagger.audio.generic.Utils;
 
4
import org.jaudiotagger.audio.mp4.Mp4NotMetaFieldKey;
 
5
 
 
6
import java.io.ByteArrayOutputStream;
 
7
import java.io.IOException;
 
8
import java.nio.ByteBuffer;
 
9
 
 
10
/**
 
11
 * FreeBox ( padding)
 
12
 * <p/>
 
13
 * <p>There are usually two free boxes, one beneath the meta atom and one toplevel atom
 
14
 */
 
15
public class Mp4FreeBox extends AbstractMp4Box
 
16
{
 
17
    /**
 
18
     * Construct a new FreeBox containing datasize padding (i.e doesnt include header size)
 
19
     *
 
20
     * @param datasize padding size
 
21
     */
 
22
    public Mp4FreeBox(int datasize)
 
23
    {
 
24
        try
 
25
        {
 
26
            //Header
 
27
            header = new Mp4BoxHeader();
 
28
            ByteArrayOutputStream headerBaos = new ByteArrayOutputStream();
 
29
            headerBaos.write(Utils.getSizeBEInt32(Mp4BoxHeader.HEADER_LENGTH + datasize));
 
30
            headerBaos.write(Utils.getDefaultBytes(Mp4NotMetaFieldKey.FREE.getFieldName(), "ISO-8859-1"));
 
31
            header.update(ByteBuffer.wrap(headerBaos.toByteArray()));
 
32
 
 
33
            //Body
 
34
            ByteArrayOutputStream freeBaos = new ByteArrayOutputStream();
 
35
            for (int i = 0; i < datasize; i++)
 
36
            {
 
37
                freeBaos.write(0x0);
 
38
            }
 
39
            dataBuffer = ByteBuffer.wrap(freeBaos.toByteArray());
 
40
        }
 
41
        catch (IOException ioe)
 
42
        {
 
43
            //This should never happen as were not actually writing to/from a file
 
44
            throw new RuntimeException(ioe);
 
45
        }
 
46
    }
 
47
 
 
48
}