Examples of RTMP


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

     * @param state       Protocol state
     * @param in          Byte buffer with input raw data
     */
    private void rawBufferRecieved(RTMPConnection conn, ProtocolState state,
      ByteBuffer in) {
    final RTMP rtmp = (RTMP) state;

    if (rtmp.getState() != RTMP.STATE_HANDSHAKE) {
      log.warn("Raw buffer after handshake, something odd going on");
    }

    ByteBuffer out = ByteBuffer
        .allocate((Constants.HANDSHAKE_SIZE * 2) + 1);

    if (log.isDebugEnabled()) {
      log.debug("Writing handshake reply");
      log.debug("handskake size:" + in.remaining());
    }

    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).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);

    conn.rawWrite(out);
  }
View Full Code Here

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

     * Setter for RTMP events handler
     *
     * @param handler  Handler
     */
    void setRTMPTHandle(RTMPTHandler handler) {
    this.state = new RTMP(RTMP.MODE_SERVER);
    this.buffer = ByteBuffer.allocate(2048);
    this.buffer.setAutoExpand(true);
    this.handler = handler;
    this.decoder = handler.getCodecFactory().getSimpleDecoder();
    this.encoder = handler.getCodecFactory().getSimpleEncoder();
View Full Code Here

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

    RTMPConnection conn = rtmpConnManager.getConnection(clientId);
    if (conn == null) {
      log.debug("Client " + clientId + " is already closed.");
      return;
    }
    RTMP rtmpState = conn.getState();
    switch (mrtmpPacket.getHeader().getType()) {
      case MRTMPPacket.CLOSE:
        synchronized (rtmpState) {
          rtmpState.setState(RTMP.STATE_EDGE_DISCONNECTING);
        }
        conn.close();
        break;
      case MRTMPPacket.RTMP:
        RTMPHeader rtmpHeader = (RTMPHeader) mrtmpPacket.getHeader();
        RTMPBody rtmpBody = (RTMPBody) mrtmpPacket.getBody();
        boolean toDisconnect = false;
        synchronized (rtmpState) {
          if (rtmpState.getState() == RTMP.STATE_ORIGIN_CONNECT_FORWARDED &&
              rtmpHeader.getRtmpType() == TYPE_INVOKE) {
            // we got the connect invocation result from Origin
            // parse the result
            Invoke invoke = (Invoke) rtmpBody.getRtmpPacket().getMessage();
            if ("connect".equals(invoke.getCall().getServiceMethodName())) {
              if (invoke.getCall().getStatus() == Call.STATUS_SUCCESS_RESULT) {
                rtmpState.setState(RTMP.STATE_CONNECTED);
              } else {
                // TODO set EdgeRTMP state to closing ?
                toDisconnect = true;
              }
            }
          }
        }
        log.debug("Forward packet to client: {}", rtmpBody.getRtmpPacket().getMessage());
        // send the packet back to client
        conn.write(rtmpBody.getRtmpPacket());
        if (toDisconnect) {
          conn.close();
        }
        synchronized (rtmpState) {
          if (rtmpState.getState() == RTMP.STATE_CONNECTED) {
            conn.startRoundTripMeasurement();
          }
        }
        break;
      default:
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.