Package org.red5.server.net.rtmp.codec.RTMP

Examples of org.red5.server.net.rtmp.codec.RTMP.LiveTimestampMapping


  public synchronized RoomClient setUsernameReconnect(String SID, Long userId,
          String username, String firstname, String lastname,
          String picture_uri){
    try {
      log.debug("#*#*#*#*#*#*# setUsername userId: "+userId+" username: "+username+" firstname: "+firstname+" lastname: "+lastname);
      IConnection current = Red5.getConnectionLocal();     
      String streamid = current.getClient().getId();
      RoomClient currentClient = this.clientListManager.getClientByStreamId(streamid);
     
      log.debug("[setUsername] id: "+currentClient.getStreamid());
     
      currentClient.setUsername(username);
View Full Code Here


          }
          String scopeName = "hibernate";
          if (rcl.getRoom_id() != null) {
            scopeName = rcl.getRoom_id().toString();
          }
          IScope currentScope = ScopeApplicationAdapter.getInstance()
              .getRoomScope(scopeName);
          ScopeApplicationAdapter.getInstance().roomLeaveByScope(rcl,
              currentScope);

          HashMap<Integer, String> messageObj = new HashMap<Integer, String>();
View Full Code Here

        String scopeName = "hibernate";
        if (rcl.getRoom_id() != null) {
          scopeName = rcl.getRoom_id().toString();
        }
        IScope currentScope = ScopeApplicationAdapter.getInstance()
            .getRoomScope(scopeName);
        ScopeApplicationAdapter.getInstance().roomLeaveByScope(rcl,
            currentScope);

        HashMap<Integer, String> messageObj = new HashMap<Integer, String>();
View Full Code Here

         }
         String scopeName = "hibernate";
         if (rcl.getRoom_id() != null) {
           scopeName = rcl.getRoom_id().toString();
         }
         IScope currentScope = this.scopeApplicationAdapter.getRoomScope(scopeName);
         this.scopeApplicationAdapter.roomLeaveByScope(rcl, currentScope);
        
        
         HashMap<Integer,String> messageObj = new HashMap<Integer,String>();
         messageObj.put(0, "kick");
View Full Code Here

          }
          String scopeName = "hibernate";
          if (rcl.getRoom_id() != null) {
            scopeName = rcl.getRoom_id().toString();
          }
          IScope currentScope = this.scopeApplicationAdapter.getRoomScope(scopeName);
         
          HashMap<Integer,String> messageObj = new HashMap<Integer,String>();
          messageObj.put(0, "kick");
         
          this.scopeApplicationAdapter.sendMessageById(messageObj, rcl.getStreamid(), currentScope);
View Full Code Here

    // ------------------------------------------------------------------------

    private void createPlayStream( IPendingServiceCallback callback ) {

        logger.debug( "create play stream" );
        IPendingServiceCallback wrapper = new CreatePlayStreamCallBack( callback );
        invoke( "createStream", null, wrapper );
    }
View Full Code Here

      if (stream.getStreamListeners() != null) {
       
        for (Iterator<IStreamListener> iter = stream.getStreamListeners().iterator();iter.hasNext();) {
         
          IStreamListener iStreamListener = iter.next();
         
          ListenerAdapter listenerAdapter = (ListenerAdapter) iStreamListener;
         
          log.debug("Stream Closing ?? "+listenerAdapter.getFlvRecordingMetaDataId()+ " " +flvRecordingMetaDataId);
         
View Full Code Here

      log.trace("Connection: {}", conn);
      // get state
      RTMP rtmp = conn.getState();
      // determine working type
      long timestamp = (message.getTimestamp() & 0xFFFFFFFFL);
      LiveTimestampMapping mapping = rtmp.getLastTimestampMapping(channelId);
      // just get the current time ONCE per packet
      long now = System.currentTimeMillis();
      if (mapping == null || timestamp < mapping.getLastStreamTime()) {
        log.trace("Resetting clock time ({}) to stream time ({})", now, timestamp);
        // either first time through, or time stamps were reset
        mapping = rtmp.new LiveTimestampMapping(now, timestamp);
        rtmp.setLastTimestampMapping(channelId, mapping);
      }
      mapping.setLastStreamTime(timestamp);
      long clockTimeOfMessage = mapping.getClockStartTime() + timestamp - mapping.getStreamStartTime();
      //determine tardiness / how late it is
      long tardiness = clockTimeOfMessage - now;
      //TDJ: EXPERIMENTAL dropping for LIVE packets in future (default false)
      if (isLive && dropLiveFuture) {
        tardiness = Math.abs(tardiness);
      }
      //subtract the ping time / latency from the tardiness value
      if (conn != null) {
        int lastPingTime = conn.getLastPingTime();
        log.trace("Last ping time for connection: {} {} ms", conn.getId(), lastPingTime);
        if (lastPingTime > 0) {
          tardiness -= lastPingTime;
        }
        //subtract the buffer time
        int streamId = conn.getStreamIdForChannel(channelId);
        IClientStream stream = conn.getStreamById(streamId);
        if (stream != null) {
          int clientBufferDuration = stream.getClientBufferDuration();
          if (clientBufferDuration > 0) {
            //two times the buffer duration seems to work best with vod
            if (isLive) {
              tardiness -= clientBufferDuration;
            } else {
              tardiness -= clientBufferDuration * 2;
            }
          }
          log.trace("Client buffer duration: {}", clientBufferDuration);
        }
      }

      //TODO: how should we differ handling based on live or vod?

      //TODO: if we are VOD do we "pause" the provider when we are consistently late?

      if (log.isTraceEnabled()) {
        log.trace("Packet timestamp: {}; tardiness: {}; now: {}; message clock time: {}, dropLiveFuture: {}", new Object[] { timestamp, tardiness, now, clockTimeOfMessage,
          dropLiveFuture });
      }
      //anything coming in less than the base will be allowed to pass, it will not be
      //dropped or manipulated
      if (tardiness < baseTolerance) {
        //frame is below lowest bounds, let it go
      } else if (tardiness > highestTolerance) {
        //frame is really late, drop it no matter what type
        log.trace("Dropping late message: {}", message);
        //if we're working with video, indicate that we will need a key frame to proceed
        if (isVideo) {
          mapping.setKeyFrameNeeded(true);
        }
        //drop it
        drop = true;
      } else {
        if (isVideo) {
          VideoData video = (VideoData) message;
          if (video.getFrameType() == FrameType.KEYFRAME) {
            //if its a key frame the inter and disposible checks can be skipped
            log.trace("Resuming stream with key frame; message: {}", message);
            mapping.setKeyFrameNeeded(false);
          } else if (tardiness >= baseTolerance && tardiness < midTolerance) {
            //drop disposable frames
            if (video.getFrameType() == FrameType.DISPOSABLE_INTERFRAME) {
              log.trace("Dropping disposible frame; message: {}", message);
              drop = true;
View Full Code Here

                //audio and video channels
                int[] channels = new int[] { 5, 6 };
                //if its a seek notification, reset the "mapping" for audio (5) and video (6)
                RTMP rtmp = ((RTMPConnection) Red5.getConnectionLocal()).getState();
                for (int channelId : channels) {
                  LiveTimestampMapping mapping = rtmp.getLastTimestampMapping(channelId);
                  if (mapping != null) {
                    long timestamp = mapping.getClockStartTime() + (seekTime & 0xFFFFFFFFL);
                    log.trace("Setting last stream time to: {}", timestamp);
                    mapping.setLastStreamTime(timestamp);
                  } else {
                    log.trace("No ts mapping for channel id: {}", channelId);
                  }
                }
              }
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.net.rtmp.codec.RTMP.LiveTimestampMapping

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.