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

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


          }
          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

  @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");
          // remove handshake from session now that we are connected
          session.removeAttribute(RTMPConnection.RTMP_HANDSHAKE);
          log.debug("Using encrypted communications");
          //make sure they are not already on the session
          if (session.containsAttribute(RTMPConnection.RTMPE_CIPHER_IN)) {
            log.debug("Ciphers already exist on the session");
          } else {
            log.debug("Adding ciphers to the session");
            session.setAttribute(RTMPConnection.RTMPE_CIPHER_IN, handshake.getCipherIn());
            session.setAttribute(RTMPConnection.RTMPE_CIPHER_OUT, handshake.getCipherOut());
          }         
        }
      }
    }
    Cipher cipher = (Cipher) session.getAttribute(RTMPConnection.RTMPE_CIPHER_IN);
    if (cipher != null) { //may want to verify handshake is complete as well
      // assume message is an IoBuffer
      IoBuffer message = (IoBuffer) obj;
      if (rtmp.getState() == RTMP.STATE_HANDSHAKE) {
        // ensure there are enough bytes to skip
        if (message.limit() > Constants.HANDSHAKE_SIZE) {
            //skip the first 1536
            byte[] handshakeReply = new byte[Constants.HANDSHAKE_SIZE];
            message.get(handshakeReply);
            // TODO verify reply, for now just set to connected
            rtmp.setState(RTMP.STATE_CONNECTED);
        } else {
          log.warn("There may be a network issue on this RTMPE connection: {}", conn);
          return;
        }
      }
View Full Code Here

  @Override
  protected void onChunkSize(RTMPConnection conn, Channel channel, Header source, ChunkSize chunkSize) {
    int requestedChunkSize = chunkSize.getSize();
    log.debug("Chunk size: {}", requestedChunkSize);
    // set chunk size on the connection
    RTMP state = conn.getState();
    // set only the read chunk size since it came from the client
    state.setReadChunkSize(requestedChunkSize);
    //state.setWriteChunkSize(requestedChunkSize);
    // set on each of the streams
    for (IClientStream stream : conn.getStreams()) {
      if (stream instanceof IClientBroadcastStream) {
        IClientBroadcastStream bs = (IClientBroadcastStream) stream;
View Full Code Here

      ByteBuffer cap = ByteBuffer.wrap(capMappedFile);
      ByteBuffer in = ByteBuffer.wrap(rawMappedFile);

      boolean serverMode = (cap.get() == (byte) 0x01);
      out.write("Mode: " + (serverMode ? "UPSTREAM" : "DOWNSTREAM"));
      RTMP state = new RTMP(serverMode);
      int id = 0;
      try {

        int nextTimePos = 0;
        long time = 0;
        long offset = -1;
        long read = 0;

        try {
          while (true) {

            while (in.position() >= nextTimePos) {

              if (cap.remaining() >= 12) {

                time = cap.getLong();
                if (offset == -1) {
                  offset = time;
                }
                time -= offset;

                read = cap.getInt();
                nextTimePos += read;

                out.write("<div class=\"time\">TIME: " + time
                    + " READ: " + read + "</div>");
              }

            }

            final int remaining = in.remaining();
            if (state.canStartDecoding(remaining)) {
              state.startDecoding();
            } else {
              break;
            }

            final Object decodedObject = decoder.decode(state, in);

            if (state.hasDecodedObject()) {
              // log.debug(decodedObject);

              if (decodedObject instanceof Packet) {
                out.write(formatHTML((Packet) decodedObject,
                    id++, 0));
              } else if (decodedObject instanceof ByteBuffer) {
                ByteBuffer buf = (ByteBuffer) decodedObject;
                out
                    .write("<div class=\"handshake\"><pre>"
                        + HexDump.formatHexDump(buf
                            .getHexDump())
                        + "</pre></div>");
              }
            } else if (state.canContinueDecoding()) {
              continue;
            } else {
              break;
            }
View Full Code Here

     * @param session      I/O session, that is, connection between two endpoints
     */
    protected void rawBufferRecieved(ProtocolState state, ByteBuffer in,
      IoSession session) {

    final RTMP rtmp = (RTMP) state;
    if (rtmp.getMode() == RTMP.MODE_SERVER) {
      if (rtmp.getState() != RTMP.STATE_HANDSHAKE) {
        log.warn("Raw buffer after handshake, something odd going on");
      }
      log.debug("Handshake 2nd phase - size: {}", in.remaining());
      ByteBuffer out = ByteBuffer.allocate((Constants.HANDSHAKE_SIZE*2)+1);
      out.put((byte)0x03);
      // TODO: the first four bytes of the handshake reply seem to be the
      //       server uptime - send something better here...
      out.putInt(0x01);
      out.fill((byte)0x00,Constants.HANDSHAKE_SIZE-4);
      out.put(in);
      out.flip();
      // Skip first 8 bytes when comparing the handshake, they seem to
      // be changed when connecting from a Mac client.
      rtmp.setHandshake(out, 9, Constants.HANDSHAKE_SIZE-8);
      //in.release();
      session.write(out);
    } else {
      log.debug("Handshake 3d phase - size: {}", in.remaining());
      in.skip(1);
View Full Code Here

TOP

Related Classes of org.red5.server.net.rtmp.codec.RTMP

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.