Examples of FLVWriter


Examples of org.red5.io.flv.impl.FLVWriter

    if (writer != null && !this.isClosed) {
      try {
       
        log.debug("#################### -start- closeStream ########################");
        log.debug("#################### -start- closeStream ########################");
        FLVWriter flvWriter = (FLVWriter) writer;
        //log.debug("duration: "+flvWriter.getDuration());
        //log.debug(writer.getClass().getName());
       
        writer.close();
       
View Full Code Here

Examples of org.red5.io.flv.impl.FLVWriter

   */
  public void write(IMetaData meta) throws IOException {
    // Get cue points, FLV reader and writer
    IMetaCue[] metaArr = meta.getMetaCue();
    FLVReader reader = new FLVReader(file, false);
    FLVWriter writer = new FLVWriter(fos, false);
    ITag tag = null;

    // Read first tag
    if (reader.hasMoreTags()) {
      tag = reader.readTag();
      if (tag.getDataType() == IoConstants.TYPE_METADATA) {
        if (!reader.hasMoreTags())
          throw new IOException(
              "File we're writing is metadata only?");
      }
    }

    meta.setDuration(((double) reader.getDuration() / 1000));
    meta.setVideoCodecId(reader.getVideoCodecId());
    meta.setAudioCodecId(reader.getAudioCodecId());

    ITag injectedTag = injectMetaData(meta, tag);
    injectedTag.setPreviousTagSize(0);
    tag.setPreviousTagSize(injectedTag.getBodySize());

    writer.writeHeader();
    writer.writeTag(injectedTag);
    writer.writeTag(tag);

    int cuePointTimeStamp = 0;
    int counter = 0;

    if (metaArr != null) {
      Arrays.sort(metaArr);
      cuePointTimeStamp = getTimeInMilliseconds(metaArr[0]);
    }

    while (reader.hasMoreTags()) {
      tag = reader.readTag();

      // if there are cuePoints in the array
      if (counter < metaArr.length) {

        // If the tag has a greater timestamp than the
        // cuePointTimeStamp, then inject the tag
        while (tag.getTimestamp() > cuePointTimeStamp) {

          injectedTag = injectMetaCue(metaArr[counter], tag);
          writer.writeTag(injectedTag);

          tag.setPreviousTagSize(injectedTag.getBodySize());

          // Advance to the next CuePoint
          counter++;

          if (counter > (metaArr.length - 1)) {
            break;
          }

          cuePointTimeStamp = getTimeInMilliseconds(metaArr[counter]);

        }
      }

      if (tag.getDataType() != IoConstants.TYPE_METADATA) {
        writer.writeTag(tag);
      }

    }
    writer.close();

  }
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.