Examples of ITag


Examples of org.red5.io.ITag

      // TODO send OOBCM to notify EOF
      // Do not unsubscribe as this kills VOD seek while in buffer
      // this.pipe.unsubscribe(this);
      return null;
    }
    ITag tag = reader.readTag();
    IRTMPEvent msg = null;
    int timestamp = tag.getTimestamp();
    switch (tag.getDataType()) {
      case Constants.TYPE_AUDIO_DATA:
        msg = new AudioData(tag.getBody());
        break;
      case Constants.TYPE_VIDEO_DATA:
        msg = new VideoData(tag.getBody());
        break;
      case Constants.TYPE_INVOKE:
        msg = new Invoke(tag.getBody());
        break;
      case Constants.TYPE_NOTIFY:
        msg = new Notify(tag.getBody());
        break;
      default:
        log.warn("Unexpected type? " + tag.getDataType());
        msg = new Unknown(tag.getDataType(), tag.getBody());
        break;
    }
    msg.setTimestamp(timestamp);
    RTMPMessage rtmpMsg = new RTMPMessage();
    rtmpMsg.setBody(msg);
View Full Code Here

Examples of org.red5.io.ITag

  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)) {
View Full Code Here

Examples of org.red5.io.ITag

    }
    props.put("canSeekToEnd", true);
    out.writeMap(props, new Serializer());
    buf.flip();

    ITag result = new Tag(IoConstants.TYPE_METADATA, 0, buf.limit(), null,
        prevSize);
    result.setBody(buf);
    return result;
  }
View Full Code Here

Examples of org.red5.io.ITag

    int count = 0;

    if (!generateMetadata) {
      try {
        FLVReader reader = new FLVReader(this.file);
        ITag tag = null;
        while (reader.hasMoreTags() && (++count < 5)) {
          tag = reader.readTag();
          if (tag.getDataType() == IoConstants.TYPE_METADATA) {
            if (metaService == null)
              metaService = new MetaService(this.file);
            metaData = metaService.readMetaData(tag.getBody());
          }
        }
        reader.close();
      } catch (Exception e) {
        log.error("An error occured looking for metadata:", e);
View Full Code Here

Examples of org.red5.io.ITag

    /**
     * Post-initialization hook, reads keyframe metadata and decodes header (if any).
     */
    private void postInitialize() {
    ITag tag = null;

    if (log.isDebugEnabled()) {
      log.debug("FLVReader 1 - Buffer size: " + getTotalBytes()
          + " position: " + getCurrentPosition() + " remaining: "
          + getRemainingBytes());
View Full Code Here

Examples of org.red5.io.ITag

    }
    props.put("canSeekToEnd", true);
    out.writeMap(props, new Serializer());
    buf.flip();

    ITag result = new Tag(IoConstants.TYPE_METADATA, 0, buf.limit(), null,
        0);
    result.setBody(buf);
    return result;
  }
View Full Code Here

Examples of org.red5.io.ITag

  /** {@inheritDoc}
   */
    public synchronized ITag readTag() {
    long oldPos = getCurrentPosition();
    ITag tag = readTagHeader();

    if (tagPosition == 0 && tag.getDataType() != TYPE_METADATA
        && generateMetadata) {
      // Generate initial metadata automatically
      setCurrentPosition(oldPos);
      KeyFrameMeta meta = analyzeKeyFrames();
      tagPosition++;
      if (meta != null) {
        return createFileMeta();
      }
    }

    ByteBuffer body = ByteBuffer.allocate(tag.getBodySize(), false);

    // XXX Paul: this assists in 'properly' handling damaged FLV files   
    long newPosition = getCurrentPosition() + tag.getBodySize();
    if (newPosition <= getTotalBytes()) {
      int limit;
      while (getCurrentPosition() < newPosition) {
        fillBuffer(newPosition - getCurrentPosition());
        if (getCurrentPosition() + in.remaining() > newPosition) {
          limit = in.limit();
          in.limit((int) (newPosition - getCurrentPosition()) + in.position());
          body.put(in);
          in.limit(limit);
        } else {
          body.put(in);
        }
      }

      body.flip();
      tag.setBody(body);
      tagPosition++;
    }

    return tag;
  }
View Full Code Here

Examples of org.red5.io.ITag

    boolean audioOnly = true;
    while (this.hasMoreTags()) {
      long pos = getCurrentPosition();
      posTagMap.put(pos, idx++);
            // Read tag header and duration
            ITag tmpTag = this.readTagHeader();
      duration = tmpTag.getTimestamp();
      if (tmpTag.getDataType() == IoConstants.TYPE_VIDEO) {
        if (audioOnly) {
          audioOnly = false;
          audioPositionList.clear();
          audioTimestampList.clear();
        }
        if (firstVideoTag == -1) {
          firstVideoTag = pos;
        }

        // Grab Frame type
        fillBuffer(1);
        byte frametype = in.get();
        if (((frametype & MASK_VIDEO_FRAMETYPE) >> 4) == FLAG_FRAMETYPE_KEYFRAME) {
          positionList.add(pos);
          timestampList.add(tmpTag.getTimestamp());
        }

      } else if (tmpTag.getDataType() == IoConstants.TYPE_AUDIO) {
        if (firstAudioTag == -1) {
          firstAudioTag = pos;
        }
        if (audioOnly) {
          audioPositionList.add(pos);
          audioTimestampList.add(tmpTag.getTimestamp());
        }
      }
      // XXX Paul: this 'properly' handles damaged FLV files - as far as
      // duration/size is concerned
      long newPosition = pos + tmpTag.getBodySize() + 15;
      // log.debug("---->" + in.remaining() + " limit=" + in.limit() + "
      // new pos=" + newPosition);
      if (newPosition >= getTotalBytes()) {
        log.info("New position exceeds limit");
        if (log.isDebugEnabled()) {
          log.debug("-----");
          log.debug("Keyframe analysis");
          log.debug(" data type=" + tmpTag.getDataType()
              + " bodysize=" + tmpTag.getBodySize());
          log.debug(" remaining=" + getRemainingBytes() + " limit="
              + getTotalBytes() + " new pos=" + newPosition);
          log.debug(" pos=" + pos);
          log.debug("-----");
        }
View Full Code Here

Examples of org.red5.io.ITag

          metaDeltaDao.addFlvRecordingMetaDelta(metaDelta);
        }

        log.trace("timeStamp :: " + timeStamp);
        ITag tag = new Tag();
        tag.setDataType(streampacket.getDataType());

        // log.debug("data.limit() :: "+data.limit());
        tag.setBodySize(data.limit());
        tag.setTimestamp(timeStamp);
        tag.setBody(data);

        writer.writeTag(tag);

      }
    } catch (Exception e) {
View Full Code Here

Examples of org.red5.io.ITag

      }

      timeStamp -= startTimeStamp;

      log.trace("timeStamp :: " + timeStamp);
      ITag tag = new Tag();
      tag.setDataType(streampacket.getDataType());

      tag.setBodySize(data.limit());
      tag.setTimestamp(timeStamp);
      tag.setBody(data);

      writer.writeTag(tag);
    } catch (Exception e) {
      log.error("[packetReceived]", e);
    }
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.