| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| EncodingChunkReader |
|
| 1.25;1.25 |
| 1 | /* | |
| 2 | * Entagged Audio Tag library | |
| 3 | * Copyright (c) 2004-2005 Christian Laireiter <liree@web.de> | |
| 4 | * | |
| 5 | * This library is free software; you can redistribute it and/or | |
| 6 | * modify it under the terms of the GNU Lesser General Public | |
| 7 | * License as published by the Free Software Foundation; either | |
| 8 | * version 2.1 of the License, or (at your option) any later version. | |
| 9 | * | |
| 10 | * This library is distributed in the hope that it will be useful, | |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 13 | * Lesser General Public License for more details. | |
| 14 | * | |
| 15 | * You should have received a copy of the GNU Lesser General Public | |
| 16 | * License along with this library; if not, write to the Free Software | |
| 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
| 18 | */ | |
| 19 | package org.jaudiotagger.audio.asf.io; | |
| 20 | ||
| 21 | import org.jaudiotagger.audio.asf.data.Chunk; | |
| 22 | import org.jaudiotagger.audio.asf.data.EncodingChunk; | |
| 23 | import org.jaudiotagger.audio.asf.data.GUID; | |
| 24 | import org.jaudiotagger.audio.asf.util.Utils; | |
| 25 | ||
| 26 | import java.io.IOException; | |
| 27 | import java.io.InputStream; | |
| 28 | import java.math.BigInteger; | |
| 29 | ||
| 30 | /** | |
| 31 | * This class reads the chunk containing encoding data <br> | |
| 32 | * <b>Warning:<b><br> | |
| 33 | * Implementation is not completed. More analysis of this chunk is needed. | |
| 34 | * | |
| 35 | * @author Christian Laireiter | |
| 36 | */ | |
| 37 | class EncodingChunkReader implements ChunkReader { | |
| 38 | /** | |
| 39 | * The GUID this reader {@linkplain #getApplyingIds() applies to} | |
| 40 | */ | |
| 41 | 4 | private final static GUID[] APPLYING = { GUID.GUID_ENCODING }; |
| 42 | ||
| 43 | /** | |
| 44 | * Should not be used for now. | |
| 45 | */ | |
| 46 | 4 | protected EncodingChunkReader() { |
| 47 | // NOTHING toDo | |
| 48 | 4 | } |
| 49 | ||
| 50 | /** | |
| 51 | * {@inheritDoc} | |
| 52 | */ | |
| 53 | public boolean canFail() { | |
| 54 | 80 | return false; |
| 55 | } | |
| 56 | ||
| 57 | /** | |
| 58 | * {@inheritDoc} | |
| 59 | */ | |
| 60 | public GUID[] getApplyingIds() { | |
| 61 | 4 | return APPLYING.clone(); |
| 62 | } | |
| 63 | ||
| 64 | /** | |
| 65 | * {@inheritDoc} | |
| 66 | */ | |
| 67 | public Chunk read(final GUID guid, final InputStream stream, | |
| 68 | final long chunkStart) throws IOException { | |
| 69 | 80 | final BigInteger chunkLen = Utils.readBig64(stream); |
| 70 | 80 | final EncodingChunk result = new EncodingChunk(chunkLen); |
| 71 | 80 | int readBytes = 24; |
| 72 | // Can't be interpreted | |
| 73 | /* | |
| 74 | * What do I think of this data, well it seems to be another GUID. Then | |
| 75 | * followed by a UINT16 indicating a length of data following (by half). | |
| 76 | * My test files just had the length of one and a two bytes zero. | |
| 77 | */ | |
| 78 | 80 | stream.skip(20); |
| 79 | 80 | readBytes += 20; |
| 80 | ||
| 81 | /* | |
| 82 | * Read the number of strings which will follow | |
| 83 | */ | |
| 84 | 80 | final int stringCount = Utils.readUINT16(stream); |
| 85 | 80 | readBytes += 2; |
| 86 | ||
| 87 | /* | |
| 88 | * Now reading the specified amount of strings. | |
| 89 | */ | |
| 90 | 240 | for (int i = 0; i < stringCount; i++) { |
| 91 | 160 | final String curr = Utils.readCharacterSizedString(stream); |
| 92 | 160 | result.addString(curr); |
| 93 | 160 | readBytes += 4 + 2 * curr.length(); |
| 94 | } | |
| 95 | 80 | stream.skip(chunkLen.longValue() - readBytes); |
| 96 | 80 | result.setPosition(chunkStart); |
| 97 | 80 | return result; |
| 98 | } | |
| 99 | ||
| 100 | } |