Package org.red5.server.net.rtmp.event

Examples of org.red5.server.net.rtmp.event.Ping


  /**
   * Send reset message
   */
  private void sendReset() {
    if (pullMode) {
      Ping recorded = new Ping();
      recorded.setEventType(Ping.RECORDED_STREAM);
      recorded.setValue2(streamId);
      // recorded
      RTMPMessage recordedMsg = RTMPMessage.build(recorded);
      doPushMessage(recordedMsg);
    }

    Ping begin = new Ping();
    begin.setEventType(Ping.STREAM_BEGIN);
    begin.setValue2(streamId);
    // begin
    RTMPMessage beginMsg = RTMPMessage.build(begin);
    doPushMessage(beginMsg);
    // reset
    ResetMessage reset = new ResetMessage();
View Full Code Here


                      result.setAdditional("mode", Integer.valueOf(1));
                      result.setAdditional("data", Red5.getDataVersion());
                      pc.setResult(result);
                    }
                    // Measure initial roundtrip time after connecting
                    conn.ping(new Ping(Ping.STREAM_BEGIN, 0, -1));
                    disconnectOnReturn = false;
                  } else {
                    log.debug("Connect failed");
                    call.setStatus(Call.STATUS_ACCESS_DENIED);
                    if (call instanceof IPendingServiceCall) {
View Full Code Here

   *
   * @param in IoBuffer
   * @return Ping event
   */
  public Ping decodePing(IoBuffer in) {
    Ping ping = null;
    if (log.isTraceEnabled()) {
      // gets the raw data as hex without changing the data or pointer
      String hexDump = in.getHexDump();
      log.trace("Ping dump: {}", hexDump);
    }
    // control type
    short type = in.getShort();
    switch (type) {
      case Ping.CLIENT_BUFFER:
        ping = new SetBuffer(in.getInt(), in.getInt());
        break;
      case Ping.PING_SWF_VERIFY:
        // only contains the type (2 bytes)
        ping = new Ping(type);
        break;
      case Ping.PONG_SWF_VERIFY:
        byte[] bytes = new byte[42];
        in.get(bytes);
        ping = new SWFResponse(bytes);
        break;
      default:
        //STREAM_BEGIN, STREAM_PLAYBUFFER_CLEAR, STREAM_DRY, RECORDED_STREAM
        //PING_CLIENT, PONG_SERVER
        //BUFFER_EMPTY, BUFFER_FULL
        ping = new Ping(type, in.getInt());
        break;
    }
    return ping;
  }
View Full Code Here

        /**
         * Send clear ping, that is, just to check if connection is alive
         */
    private void sendClearPing() {
      Ping ping1 = new Ping();
      ping1.setValue1((short) Ping.STREAM_PLAYBUFFER_CLEAR);
      ping1.setValue2(getStreamId());

      RTMPMessage ping1Msg = new RTMPMessage();
      ping1Msg.setBody(ping1);
      doPushMessage(ping1Msg);
    }
View Full Code Here

        /**
         * Send reset message
         */
    private void sendReset() {
      if (isPullMode) {
        Ping ping1 = new Ping();
        ping1.setValue1((short) Ping.STREAM_RESET);
        ping1.setValue2(getStreamId());

        RTMPMessage ping1Msg = new RTMPMessage();
        ping1Msg.setBody(ping1);
        doPushMessage(ping1Msg);
      }

      Ping ping2 = new Ping();
      ping2.setValue1((short) Ping.STREAM_CLEAR);
      ping2.setValue2(getStreamId());

      RTMPMessage ping2Msg = new RTMPMessage();
      ping2Msg.setBody(ping2);
      doPushMessage(ping2Msg);

View Full Code Here

          audioData.setHeader(header);
          audioData.setTimestamp(header.getTimer());
          audio.write(audioData);
          break;
        case Constants.TYPE_PING:
          Ping ping = new Ping(((Ping) msg).getValue1(), ((Ping) msg)
              .getValue2(), ((Ping) msg).getValue3(),
              ((Ping) msg).getValue4());
          header.setTimerRelative(false);
          header.setTimer(0);
          ping.setHeader(header);
          ping.setTimestamp(header.getTimer());
          conn.ping(ping);
          break;
        case Constants.TYPE_BYTES_READ:
          BytesRead bytesRead = new BytesRead(((BytesRead) msg)
              .getBytesRead());
View Full Code Here

  public void ping() {
    long newPingTime = System.currentTimeMillis();
    if (lastPingSent == 0) {
      lastPongReceived = newPingTime;
    }
    Ping pingRequest = new Ping();
    pingRequest.setValue1((short) Ping.PING_CLIENT);
    lastPingSent = newPingTime;
    int now = (int) (lastPingSent & 0xffffffff);
    pingRequest.setValue2(now);
    pingRequest.setValue3(Ping.UNDEFINED);
    ping(pingRequest);
  }
View Full Code Here

  protected void onPing(RTMPConnection conn, Channel channel,
      Header source, Ping ping) {
    switch (ping.getValue1()) {
      case 6:
        // The server wants to measure the RTT
        Ping pong = new Ping();
        pong.setValue1((short) Ping.PONG_SERVER);
        int now = (int) (System.currentTimeMillis() & 0xffffffff);
        pong.setValue2(now);
        pong.setValue3(Ping.UNDEFINED);
        conn.ping(pong);
        break;
       
      default:
        log.warn("Unhandled ping: " + ping);
View Full Code Here

   *
     * @param in            Byte buffer
     * @return              Ping event
     */
  public Ping decodePing(ByteBuffer in) {
    final Ping ping = new Ping();
    ping.setDebug(in.getHexDump());
    ping.setValue1(in.getShort());
    ping.setValue2(in.getInt());
    if (in.hasRemaining()) {
      ping.setValue3(in.getInt());
    }
    if (in.hasRemaining()) {
      ping.setValue4(in.getInt());
    }
    return ping;
  }
View Full Code Here

                      pc.setResult(getStatus(NC_CONNECT_SUCCESS));
                    }
                    // Measure initial roundtrip time after
                    // connecting
                    conn.getChannel(2).write(
                        new Ping(Ping.STREAM_CLEAR, 0,
                            -1));
                    conn.startRoundTripMeasurement();
                  } else {
                    log.debug("Connect failed");
                    call
View Full Code Here

TOP

Related Classes of org.red5.server.net.rtmp.event.Ping

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.