| 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 java.io.IOException; | |
| 22 | import java.io.InputStream; | |
| 23 | import java.math.BigInteger; | |
| 24 | ||
| 25 | import org.jaudiotagger.audio.asf.data.Chunk; | |
| 26 | import org.jaudiotagger.audio.asf.data.EncodingChunk; | |
| 27 | import org.jaudiotagger.audio.asf.data.GUID; | |
| 28 | import org.jaudiotagger.audio.asf.util.Utils; | |
| 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 | /** | |
| 40 | * Should not be used for now. | |
| 41 | */ | |
| 42 | 42 | protected EncodingChunkReader() { |
| 43 | // NOTHING toDo | |
| 44 | 42 | } |
| 45 | ||
| 46 | /** | |
| 47 | * {@inheritDoc} | |
| 48 | */ | |
| 49 | public boolean canFail() | |
| 50 | { | |
| 51 | 16 | return false; |
| 52 | } | |
| 53 | ||
| 54 | /** | |
| 55 | * {@inheritDoc} | |
| 56 | */ | |
| 57 | public GUID getApplyingId() { | |
| 58 | 42 | return GUID.GUID_ENCODING; |
| 59 | } | |
| 60 | ||
| 61 | /** | |
| 62 | * {@inheritDoc} | |
| 63 | */ | |
| 64 | public Chunk read(final GUID guid, final InputStream stream, final long chunkStart) throws IOException | |
| 65 | { | |
| 66 | 16 | BigInteger chunkLen = Utils.readBig64(stream); |
| 67 | 16 | EncodingChunk result = new EncodingChunk(chunkLen); |
| 68 | 16 | int readBytes = 24; |
| 69 | // Can't be interpreted | |
| 70 | /* | |
| 71 | * What do I think of this data, well it seems to be another GUID. Then | |
| 72 | * followed by a UINT16 indicating a length of data following (by half). | |
| 73 | * My test files just had the length of one and a two bytes zero. | |
| 74 | */ | |
| 75 | 16 | stream.skip(20); |
| 76 | 16 | readBytes += 20; |
| 77 | ||
| 78 | /* | |
| 79 | * Read the number of strings which will follow | |
| 80 | */ | |
| 81 | 16 | int stringCount = Utils.readUINT16(stream); |
| 82 | 16 | readBytes += 2; |
| 83 | ||
| 84 | /* | |
| 85 | * Now reading the specified amount of strings. | |
| 86 | */ | |
| 87 | 48 | for (int i = 0; i < stringCount; i++) { |
| 88 | 32 | String curr = Utils.readCharacterSizedString(stream); |
| 89 | 32 | result.addString(curr); |
| 90 | 32 | readBytes += 4 + 2 * curr.length(); |
| 91 | } | |
| 92 | 16 | stream.skip(chunkLen.longValue() - readBytes); |
| 93 | 16 | result.setPosition(chunkStart); |
| 94 | 16 | return result; |
| 95 | } | |
| 96 | ||
| 97 | } |