Package org.red5.server.messaging

Examples of org.red5.server.messaging.IMessage


      switch (subscriberStream.getState()) {
        case PAUSED:
        case STOPPED:
          // we send a single snapshot on pause
          if (sendCheckVideoCM(msgIn)) {
            IMessage msg = null;
            do {
              try {
                msg = msgIn.pullMessage();
              } catch (Throwable err) {
                log.error("Error while pulling message", err);
                msg = null;
              }
              if (msg instanceof RTMPMessage) {
                RTMPMessage rtmpMessage = (RTMPMessage) msg;
                IRTMPEvent body = rtmpMessage.getBody();
                if (body instanceof VideoData && ((VideoData) body).getFrameType() == FrameType.KEYFRAME) {
                  //body.setTimestamp(seekPos);
                  doPushMessage(rtmpMessage);
                  rtmpMessage.getBody().release();
                  messageSent = true;
                  lastMessageTs = body.getTimestamp();
                  break;
                }
              }
            } while (msg != null);
          }
      }
      // seeked past end of stream
      if (currentItem.getLength() >= 0 && (position - streamOffset) >= currentItem.getLength()) {
        stop();
      }
      // if no message has been sent by this point send an audio packet
      if (!messageSent) {
        // Send blank audio packet to notify client about new position
        log.debug("Sending blank audio packet");
        AudioData audio = new AudioData();
        audio.setTimestamp(seekPos);
        audio.setHeader(new Header());
        audio.getHeader().setTimer(seekPos);
        RTMPMessage audioMessage = RTMPMessage.build(audio);
        lastMessageTs = seekPos;
        doPushMessage(audioMessage);
        audioMessage.getBody().release();
      }

      if (!messageSent && subscriberStream.getState() == StreamState.PLAYING) {
        boolean isRTMPTPlayback = subscriberStream.getConnection() instanceof RTMPTConnection;

        // send all frames from last keyframe up to requested position and fill client buffer
        if (sendCheckVideoCM(msgIn)) {
          final long clientBuffer = subscriberStream.getClientBufferDuration();
          IMessage msg = null;
          int msgSent = 0;

          do {
            try {
              msg = msgIn != null ? msgIn.pullMessage() : null;
View Full Code Here


                releasePendingMessage();
              } else {
                return;
              }
            } else {
              IMessage msg = null;
              do {
                msg = msgIn.pullMessage();
                if (msg != null) {
                  if (msg instanceof RTMPMessage) {
                    RTMPMessage rtmpMessage = (RTMPMessage) msg;
View Full Code Here

          playDecision = 1;
        }
        break;
    }
    log.debug("Play decision is {} (0=Live, 1=File, 2=Wait, 3=N/A)", playDecision);
    IMessage msg = null;
    currentItem = item;
    long itemLength = item.getLength();
    log.debug("Item length: {}", itemLength);
    switch (playDecision) {
      case 0:
View Full Code Here

   * @param itemLength length of the item to be played
   * @return message for the consumer
   * @throws IOException
   */
  private final IMessage playVOD(boolean withReset, long itemLength) throws IOException {
    IMessage msg = null;
    //change state
    subscriberStream.setState(StreamState.PLAYING);
    streamOffset = 0;
    streamStartTS = -1;
    if (withReset) {
View Full Code Here

        default:
          sendStreamNotFoundStatus(currentItem);
          throw new StreamNotFoundException(item.getName());
      }
      state = State.PLAYING;
      IMessage msg = null;
      streamOffset = 0;
      if (decision == 1) {
        if (withReset) {
          releasePendingMessage();
        }
View Full Code Here

      boolean startPullPushThread = false;
      if ((state == State.PAUSED || state == State.STOPPED) && sendCheckVideoCM(msgIn)) {
        // we send a single snapshot on pause.
        // XXX we need to take BWC into account, for
        // now send forcefully.
        IMessage msg;
        try {
          msg = msgIn.pullMessage();
        } catch (Throwable err) {
          log.error("Error while pulling message.", err);
          msg = null;
View Full Code Here

         
          sendMessage(pendingMessage);
          releasePendingMessage();
        } else {
          while (true) {
            IMessage msg = msgIn.pullMessage();
            if (msg == null) {
              // No more packets to send
              stop();
              break;
            } else {
View Full Code Here

  /** {@inheritDoc} */
    public void run() {
    while (isStarted && providerPipe != null && consumerPipe != null) {
      try {
        IMessage message = providerPipe.pullMessage();
        if (log.isDebugEnabled()) {
          log.debug("got message: " + message);
        }
        consumerPipe.pushMessage(message);
      } catch (Exception e) {
View Full Code Here

     * Getter for next RTMP message.
     *
     * @return  Next RTMP message
     */
    protected RTMPMessage getNextRTMPMessage() {
    IMessage message;
    do {
            // Pull message from message input object...
      try {
        message = msgIn.pullMessage();
      } catch (IOException err) {
View Full Code Here

            if ( !( event instanceof IRTMPEvent ) ) {
                logger.debug( "skipping non rtmp event: " + event );
                return;
            }

            IRTMPEvent rtmpEvent = (IRTMPEvent) event;

            if ( logger.isDebugEnabled() ) {
                // logger.debug("rtmp event: " + rtmpEvent.getHeader() + ", " +
                // rtmpEvent.getClass().getSimpleName());
            }

            if ( !( rtmpEvent instanceof IStreamData ) ) {
                logger.debug( "skipping non stream data" );
                return;
            }

            if ( rtmpEvent.getHeader().getSize() == 0 ) {
                logger.debug( "skipping event where size == 0" );
                return;
            }

            if ( rtmpEvent instanceof VideoData ) {
View Full Code Here

TOP

Related Classes of org.red5.server.messaging.IMessage

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.