Examples of AsfHeader


Examples of entagged.audioformats.asf.data.AsfHeader

     *           java.io.RandomAccessFile)
     */
    protected void deleteTag(RandomAccessFile raf, RandomAccessFile tempRaf)
            throws CannotWriteException, IOException {
        try {
            AsfHeader header = AsfHeaderReader.readHeader(raf);
            if (header == null) {
                throw new NullPointerException(
                        "Header is null, so file couldn't be read properly. "
                                + "(Interpretation of data, not file access rights.)");
            }
View Full Code Here

Examples of entagged.audioformats.asf.data.AsfHeader

     *           java.io.RandomAccessFile, java.io.RandomAccessFile)
     */
    protected void writeTag(Tag tag, RandomAccessFile raf,
            RandomAccessFile rafTemp) throws CannotWriteException, IOException {
        try {
            AsfHeader header = AsfHeaderReader.readHeader(raf);
            if (header == null) {
                throw new NullPointerException(
                        "Header is null, so file couldn't be read properly. "
                                + "(Interpretation of data, not file access rights.)");
            }
View Full Code Here

Examples of entagged.audioformats.asf.data.AsfHeader

  protected EncodingInfo getEncodingInfo(RandomAccessFile raf)
      throws CannotReadException, IOException {
    raf.seek(0);
    EncodingInfo info = new EncodingInfo();
    try {
      AsfHeader header = AsfHeaderReader.readHeader(raf);
      if (header == null) {
        throw new CannotReadException(
            "Some values must have been "
                + "incorrect for interpretation as asf with wma content.");
      }
      info.setBitrate(header.getAudioStreamChunk().getKbps());
      info.setChannelNumber((int) header.getAudioStreamChunk()
          .getChannelCount());
      info.setEncodingType("ASF (audio): "
          + header.getAudioStreamChunk().getCodecDescription());
      info.setPreciseLength(header.getFileHeader().getPreciseDuration());
      info.setSamplingRate((int) header.getAudioStreamChunk()
          .getSamplingRate());
    } catch (Exception e) {
      if (e instanceof IOException)
        throw (IOException) e;
      else if (e instanceof CannotReadException)
View Full Code Here

Examples of entagged.audioformats.asf.data.AsfHeader

   *         containing all supported data.
   * @throws IOException
   *             Read errors.
   */
  private AsfHeader parseData(RandomAccessFile in) throws IOException {
    AsfHeader result = null;
    long chunkStart = in.getFilePointer();
    GUID possibleGuid = Utils.readGUID(in);

    if (GUID.GUID_HEADER.equals(possibleGuid)) {
      // For Know the filepointer pointed to an ASF header chunk.
      BigInteger chunkLen = Utils.readBig64(in);

      long chunkCount = Utils.readUINT32(in);
      // They are of unknown use.
      in.skipBytes(2);

      /*
       * Now reading header of chuncks.
       */
      ArrayList chunks = new ArrayList();
      while (chunkLen.compareTo(BigInteger.valueOf(in.getFilePointer())) > 0) {
        Chunk chunk = ChunkHeaderReader.readChunckHeader(in);
        chunks.add(chunk);
        in.seek(chunk.getChunckEnd());
      }

      /*
       * Creating the resulting object because streamchunks will be added.
       */
      result = new AsfHeader(chunkStart, chunkLen, chunkCount);
      /*
       * Now we know all positions and guids of chunks which are contained
       * whithin asf header. Further we need to identify the type of those
       * chunks and parse the interesting ones.
       */
      FileHeader fileHeader = null;
      ExtendedContentDescription extendedDescription = null;
      EncodingChunk encodingChunk = null;
      StreamChunk streamChunk = null;
      ContentDescription contentDescription = null;
      StreamBitratePropertiesChunk bitratePropertiesChunk = null;

      Iterator iterator = chunks.iterator();
      while (iterator.hasNext()) {
        Chunk currentChunk = (Chunk) iterator.next();
        if (fileHeader == null
            && (fileHeader = FileHeaderReader
                .read(in, currentChunk)) != null) {
          continue;
        }
        if (extendedDescription == null
            && (extendedDescription = ExtContentDescReader.read(in,
                currentChunk)) != null) {
          continue;
        }
        if (encodingChunk == null
            && (encodingChunk = EncodingChunkReader.read(in,
                currentChunk)) != null) {
          continue;
        }
        if (streamChunk == null
            && (streamChunk = StreamChunkReader.read(in,
                currentChunk)) != null) {
          result.addStreamChunk(streamChunk);
          streamChunk = null;
          continue;
        }
        if (contentDescription == null
            && (contentDescription = ContentDescriptionReader.read(
                in, currentChunk)) != null) {
          continue;
        }
        if (bitratePropertiesChunk == null
            && (bitratePropertiesChunk = StreamBitratePropertiesReader
                .read(in, currentChunk)) != null) {
          continue;
        }
        /*
         * If none of the above statements executed the "continue", this
         * chunk couldn't be interpreted. Despite this the chunk is
         * remembered
         */
        result.addUnspecifiedChunk(currentChunk);
      }
      /*
       * Finally store the parsed chunks in the resulting ASFHeader
       * object.
       */
      result.setFileHeader(fileHeader);
      result.setEncodingChunk(encodingChunk);
      /*
       * Warning, extendedDescription, contentDescription and
       * bitratePropertiesChunk maybe null since they are optional fields.
       */
      result.setExtendedContentDescription(extendedDescription);
      result.setContentDescription(contentDescription);
      result.setStreamBitratePropertiesChunk(bitratePropertiesChunk);
    }
    return result;
  }
View Full Code Here

Examples of entagged.audioformats.asf.data.AsfHeader

  protected Tag getTag(RandomAccessFile raf) throws CannotReadException,
      IOException {
    raf.seek(0);
    Tag tag = null;
    try {
      AsfHeader header = AsfHeaderReader.readHeader(raf);
      if (header == null) {
        throw new CannotReadException(
            "Some values must have been "
                + "incorrect for interpretation as asf with wma content.");
      }
View Full Code Here

Examples of entagged.audioformats.asf.data.AsfHeader

     * (overridden)
     *
     * @see junit.framework.TestCase#runTest()
     */
    protected void runTest() throws Throwable {
        AsfHeader header = AsfHeaderReader.readHeader(new RandomAccessFile(
                this.file, "r"));
        String okString = createString('a', 100);
        String errorString = createString('a', 65536);
        if (header.getContentDescription() != null) {
            int errors = testContentDescription(header, okString);
            assertTrue(errors == 0);
            errors = testContentDescription(header, errorString);
            assertTrue(errors == 5);
        }
        ContentDescriptor desc;
        try {
            desc = new ContentDescriptor(errorString,
                    ContentDescriptor.TYPE_STRING);
            Assert
                    .fail("Construction shouldn't be possible with such a large name");
        } catch (Exception e) {
            // Here is all OK
        }
        desc = new ContentDescriptor(okString, ContentDescriptor.TYPE_STRING);
        try {
            desc.setStringValue(errorString);
            Assert.fail("Value is too long but accepted");
        } catch (Exception e) {
            // Here is all OK
        }
        desc.setStringValue(okString);

        assertTrue(header.getFileHeader().getFileSize().equals(
                BigInteger.valueOf(this.file.length())));
    }
View Full Code Here

Examples of org.jaudiotagger.audio.asf.data.AsfHeader

   */
    @Override
  public void process(RandomAccessFile file, String filename) throws Exception {
      file.seek(0);
    // Let the audio library read the ASF file.
    AsfHeader header = AsfHeaderReader.readHeader(file);

    VideoStreamChunk video = null;
    for (Chunk chunk : header.getChunks()) {
            if (chunk instanceof VideoStreamChunk)
                video = (VideoStreamChunk) chunk;
    }
   
    this.videoStreamPresent = video != null;

    if (this.videoStreamPresent) {
      setVideoResolution(video.getPictureWidth() + "x" + video.getPictureHeight());
      setVideoCodec(video.getCodecIdAsString());
      setDuration(header.getFileHeader().getDurationInSeconds());
     
      // The average bit rate of the video is as hard to gather as the FPS.
      // However in this case there is a recommended chunk in ASF files
      // which contains this information.
      StreamBitratePropertiesChunk propertiesChunk = header.getStreamBitratePropertiesChunk();
      if (propertiesChunk != null)
        setVideoBitRate((int) propertiesChunk.getAvgBitrate(video.getStreamNumber()));

      // The audio part of the video. (optional)
      if (header.getAudioStreamChunk() != null) {
        setAudioCodec(header.getAudioStreamChunk().getCodecDescription());
        setAudioRate((int) header.getAudioStreamChunk().getSamplingRate());
        setAudioBitRate(header.getAudioStreamChunk().getKbps() * 1000);
        setAudioChannels((int) header.getAudioStreamChunk().getChannelCount());
      }
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.