Examples of RTMPMinaConnection


Examples of org.red5.server.net.rtmp.RTMPMinaConnection

  @Override
  public void messageReceived(NextFilter nextFilter, IoSession session, Object obj) throws Exception {
    String sessionId = (String) session.getAttribute(RTMPConnection.RTMP_SESSION_ID);
    log.trace("Session id: {}", sessionId);
    RTMPMinaConnection conn = (RTMPMinaConnection) RTMPConnManager.getInstance().getConnectionBySessionId(sessionId);   
    RTMP rtmp = conn.getState();
    //if there is a handshake on the session, ensure the type has been set
    if (session.containsAttribute(RTMPConnection.RTMP_HANDSHAKE)) {
      log.trace("Handshake exists on the session");
      //get the handshake from the session
      RTMPHandshake handshake = (RTMPHandshake) session.getAttribute(RTMPConnection.RTMP_HANDSHAKE);
      int handshakeType = handshake.getHandshakeType();
      if (handshakeType == 0) {
        log.trace("Handshake type is not currently set");
        // holds the handshake type, default is un-encrypted
        byte handshakeByte = RTMPConnection.RTMP_NON_ENCRYPTED;
        //get the current message
        if (obj instanceof IoBuffer) {
          IoBuffer message = (IoBuffer) obj;
          message.mark();
          handshakeByte = message.get();
          message.reset();
        }
        //set the type
        handshake.setHandshakeType(handshakeByte);
        //set on the rtmp state
        rtmp.setEncrypted(handshakeByte == RTMPConnection.RTMP_ENCRYPTED ? true : false);
      } else if (handshakeType == 3) {
        if (rtmp.getState() == RTMP.STATE_CONNECTED) {
          log.debug("In connected state");
          // remove handshake from session now that we are connected
          session.removeAttribute(RTMPConnection.RTMP_HANDSHAKE);
          log.debug("Using non-encrypted communications");
        }
      } else if (handshakeType == 6) {
        // ensure we have received enough bytes to be encrypted
        long readBytesCount = conn.getReadBytes();
        long writeBytesCount = conn.getWrittenBytes();
        log.trace("Bytes read: {} written: {}", readBytesCount, writeBytesCount);
        // don't remove the handshake when using RTMPE until we've written all the handshake data
        if (writeBytesCount >= (Constants.HANDSHAKE_SIZE * 2)) {
          //if we are connected and doing encryption, add the ciphers
          log.debug("Assumed to be in a connected state");
View Full Code Here

Examples of org.red5.server.net.rtmp.RTMPMinaConnection

    // add rtmpe filter after ssl
    session.getFilterChain().addAfter("sslFilter", "rtmpeFilter", new RTMPEIoFilter());
    // add protocol filter next
    session.getFilterChain().addLast("protocolFilter", new ProtocolCodecFilter(codecFactory));
    // create a connection
    RTMPMinaConnection conn = createRTMPMinaConnection();
    // add session to the connection
    conn.setIoSession(session);
    // add the handler
    conn.setHandler(handler);
    // add the connections session id for look up using the connection manager
    session.setAttribute(RTMPConnection.RTMP_SESSION_ID, conn.getSessionId());
    // add the in-bound handshake
    session.setAttribute(RTMPConnection.RTMP_HANDSHAKE, new InboundHandshake());
 
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.