Package org.red5.server.net.rtmp.event

Examples of org.red5.server.net.rtmp.event.IRTMPEvent


        /**
         * Releases pending message body, nullifies pending message object
         */
    private synchronized void releasePendingMessage() {
      if (pendingMessage != null) {
        IRTMPEvent body = pendingMessage.getBody();
        if (body instanceof IStreamData && ((IStreamData) body).getData() != null) {
          ((IStreamData) body).getData().release();
        }
        pendingMessage.setBody(null);
        pendingMessage = null;
View Full Code Here


    }
    if (writer == null) {
      init();
    }
    RTMPMessage rtmpMsg = (RTMPMessage) message;
    final IRTMPEvent msg = rtmpMsg.getBody();
    if (startTimestamp == -1) {
      startTimestamp = msg.getTimestamp();
    }
    int timestamp = msg.getTimestamp() - startTimestamp;
    if (timestamp < 0) {
      log.warn("Skipping message with negative timestamp.");
      return;
    }
    lastTimestamp = timestamp;

    ITag tag = new Tag();

    tag.setDataType(msg.getDataType());
    tag.setTimestamp(timestamp + offset);
    if (msg instanceof IStreamData) {
      ByteBuffer data = ((IStreamData) msg).getData().asReadOnlyBuffer();
      tag.setBodySize(data.limit());
      tag.setBody(data);
View Full Code Here

    this.state = state;
  }

  /** {@inheritDoc} */
    public boolean canSendPacket(RTMPMessage message, long pending) {
    IRTMPEvent packet = message.getBody();
    if (!(packet instanceof VideoData)) {
      // We currently only drop video packets.
      return true;
    }

View Full Code Here

    return result;
  }

  /** {@inheritDoc} */
    public void dropPacket(RTMPMessage message) {
    IRTMPEvent packet = message.getBody();
    if (!(packet instanceof VideoData)) {
      // Only check video packets.
      return;
    }

View Full Code Here

      return creationTime;
    }
   
    /** {@inheritDoc} */
    public int getCurrentTimestamp() {
      final IRTMPEvent msg = engine.lastMessage;
      if (msg == null) {
        return 0;
      }
     
      return msg.getTimestamp();
    }
View Full Code Here

      return bytesSent;
    }
   
    /** {@inheritDoc} */
    public double getEstimatedBufferFill() {
      final IRTMPEvent msg = engine.lastMessage;
      if (msg == null) {
        // Nothing has been sent yet
        return 0.0;
      }
     
    // Buffer size as requested by the client
    final long buffer = getClientBufferDuration();
    if (buffer == 0) {
      return 100.0;
    }
   
    // Duration the stream is playing
    final long delta = System.currentTimeMillis() - engine.playbackStart;
    // Expected amount of data present in client buffer
    final long buffered = msg.getTimestamp() - delta;
      return (buffered * 100.0) / buffer;
    }
View Full Code Here

    if (!reader.hasMoreTags()) {
      return null;
    }
    ITag tag = reader.readTag();

    IRTMPEvent msg;
    switch (tag.getDataType()) {
      case TYPE_AUDIO_DATA:
        msg = new AudioData(tag.getBody());
        break;
      case TYPE_VIDEO_DATA:
        msg = new VideoData(tag.getBody());
        break;
      case TYPE_INVOKE:
        msg = new Invoke(tag.getBody());
        break;
      case 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(tag.getTimestamp());
    //msg.setSealed(true);
    return msg;
  }
View Full Code Here

   * @param message          RTMP message
   * @return <tt>true</tt> indicates success and <tt>false</tt>
   * indicates buffer is full.
   */
  public boolean putMessage(RTMPMessage message) {
    IRTMPEvent body = message.getBody();
    if (!(body instanceof IStreamData)) {
      throw new RuntimeException("expected IStreamData but got " + body);
    }

    int size = ((IStreamData) body).getData().limit();
View Full Code Here

   * @return <tt>null</tt> if buffer is empty.
   */
  public RTMPMessage takeMessage() {
    RTMPMessage message = messageQueue.poll();
    if (message != null) {
      IRTMPEvent body = message.getBody();
      if (!(body instanceof IStreamData)) {
        throw new RuntimeException("expected IStreamData but got "
            + body);
      }

View Full Code Here

    } else if (message instanceof StatusMessage) {
      StatusMessage statusMsg = (StatusMessage) message;
      data.sendStatus(statusMsg.getBody());
    } else if (message instanceof RTMPMessage) {
      RTMPMessage rtmpMsg = (RTMPMessage) message;
      IRTMPEvent msg = rtmpMsg.getBody();
      Header header = new Header();
      int timestamp = streamTracker.add(msg);
      if (timestamp < 0) {
        log.warn("Skipping message with negative timestamp.");
        return;
      }
      header.setTimerRelative(streamTracker.isRelative());
      header.setTimer(timestamp);

      switch (msg.getDataType()) {
        case Constants.TYPE_STREAM_METADATA:
          Notify notify = new Notify(((Notify) msg).getData()
              .asReadOnlyBuffer());
          notify.setHeader(header);
          notify.setTimestamp(header.getTimer());
View Full Code Here

TOP

Related Classes of org.red5.server.net.rtmp.event.IRTMPEvent

Copyright © 2018 www.massapicom. 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.