当前位置: 首页>>代码示例>>Java>>正文


Java Ping类代码示例

本文整理汇总了Java中org.red5.server.net.rtmp.event.Ping的典型用法代码示例。如果您正苦于以下问题:Java Ping类的具体用法?Java Ping怎么用?Java Ping使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Ping类属于org.red5.server.net.rtmp.event包,在下文中一共展示了Ping类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sendReset

import org.red5.server.net.rtmp.event.Ping; //导入依赖的package包/类
/**
 * 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();
    doPushMessage(reset);
}
 
开发者ID:Red5,项目名称:red5-server-common,代码行数:23,代码来源:PlayEngine.java

示例2: ping

import org.red5.server.net.rtmp.event.Ping; //导入依赖的package包/类
/** {@inheritDoc} */
public void ping() {
    long newPingTime = System.currentTimeMillis();
    if (log.isDebugEnabled()) {
        log.debug("Send Ping: session=[{}], currentTime=[{}], lastPingTime=[{}]", new Object[] { getSessionId(), newPingTime, lastPingSentOn.get() });
    }
    if (lastPingSentOn.get() == 0) {
        lastPongReceivedOn.set(newPingTime);
    }
    Ping pingRequest = new Ping();
    pingRequest.setEventType(Ping.PING_CLIENT);
    lastPingSentOn.set(newPingTime);
    int now = (int) (newPingTime & 0xffffffffL);
    pingRequest.setValue2(now);
    ping(pingRequest);
}
 
开发者ID:Red5,项目名称:red5-server-common,代码行数:17,代码来源:RTMPConnection.java

示例3: pingReceived

import org.red5.server.net.rtmp.event.Ping; //导入依赖的package包/类
/**
 * Marks that ping back was received.
 * 
 * @param pong
 *            Ping object
 */
public void pingReceived(Ping pong) {
    long now = System.currentTimeMillis();
    long previousPingTime = lastPingSentOn.get();
    int previousPingValue = (int) (previousPingTime & 0xffffffffL);
    int pongValue = pong.getValue2().intValue();
    if (log.isDebugEnabled()) {
        log.debug("Pong received: session=[{}] at {} with value {}, previous received at {}", new Object[] { getSessionId(), now, pongValue, previousPingValue });
    }
    if (pongValue == previousPingValue) {
        lastPingRoundTripTime.set((int) ((now - previousPingTime) & 0xffffffffL));
        if (log.isDebugEnabled()) {
            log.debug("Ping response session=[{}], RTT=[{} ms]", new Object[] { getSessionId(), lastPingRoundTripTime.get() });
        }
    } else {
        // don't log the congestion entry unless there are more than X messages waiting
        if (getPendingMessages() > 4) {
            int pingRtt = (int) ((now & 0xffffffffL)) - pongValue;
            log.info("Pong delayed: session=[{}], ping response took [{} ms] to arrive. Connection may be congested, or loopback", new Object[] { getSessionId(), pingRtt });
        }
    }
    lastPongReceivedOn.set(now);
}
 
开发者ID:Red5,项目名称:red5-server-common,代码行数:29,代码来源:RTMPConnection.java

示例4: play

import org.red5.server.net.rtmp.event.Ping; //导入依赖的package包/类
@Override
public void play(Number streamId, String name, int start, int length) {
    log.debug("play stream {}, name: {}, start {}, length {}", new Object[] { streamId, name, start, length });
    if (conn != null) {
        // get the channel
        int channel = getChannelForStreamId(streamId);
        // send our requested buffer size
        ping(Ping.CLIENT_BUFFER, streamId, 2000);
        // send our request for a/v
        PendingCall receiveAudioCall = new PendingCall("receiveAudio");
        conn.invoke(receiveAudioCall, channel);
        PendingCall receiveVideoCall = new PendingCall("receiveVideo");
        conn.invoke(receiveVideoCall, channel);
        // call play
        Object[] params = new Object[3];
        params[0] = name;
        params[1] = (start >= 1000 || start <= -1000) ? start : start * 1000;
        params[2] = (length >= 1000 || length <= -1000) ? length : length * 1000;
        PendingCall pendingCall = new PendingCall("play", params);
        conn.invoke(pendingCall, channel);
    } else {
        log.info("Connection was null ?");
    }
}
 
开发者ID:Red5,项目名称:red5-client,代码行数:25,代码来源:BaseRTMPClientHandler.java

示例5: sendReset

import org.red5.server.net.rtmp.event.Ping; //导入依赖的package包/类
/**
 * 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();
	doPushMessage(reset);
}
 
开发者ID:cwpenhale,项目名称:red5-mobileconsole,代码行数:24,代码来源:PlayEngine.java

示例6: sendClearPing

import org.red5.server.net.rtmp.event.Ping; //导入依赖的package包/类
/**
 * Send clear ping. Lets client know that stream has no more data to send.
 */
private void sendClearPing() {
    Ping eof = new Ping();
    eof.setEventType(Ping.STREAM_PLAYBUFFER_CLEAR);
    eof.setValue2(streamId);
    // eos 
    RTMPMessage eofMsg = RTMPMessage.build(eof);
    doPushMessage(eofMsg);
}
 
开发者ID:Red5,项目名称:red5-server-common,代码行数:12,代码来源:PlayEngine.java

示例7: onPing

import org.red5.server.net.rtmp.event.Ping; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
protected void onPing(RTMPConnection conn, Channel channel, Header source, Ping ping) {
    switch (ping.getEventType()) {
        case Ping.CLIENT_BUFFER:
            SetBuffer setBuffer = (SetBuffer) ping;
            // get the stream id
            int streamId = setBuffer.getStreamId();
            // get requested buffer size in milliseconds
            int buffer = setBuffer.getBufferLength();
            log.debug("Client sent a buffer size: {} ms for stream id: {}", buffer, streamId);
            IClientStream stream = null;
            if (streamId != 0) {
                // The client wants to set the buffer time
                stream = conn.getStreamById(streamId);
                if (stream != null) {
                    stream.setClientBufferDuration(buffer);
                    log.trace("Stream type: {}", stream.getClass().getName());
                }
            }
            //catch-all to make sure buffer size is set
            if (stream == null) {
                // Remember buffer time until stream is created
                conn.rememberStreamBufferDuration(streamId, buffer);
                log.debug("Remembering client buffer on stream: {}", buffer);
            }
            break;
        case Ping.PONG_SERVER:
            // This is the response to an IConnection.ping request
            conn.pingReceived(ping);
            break;
        default:
            log.warn("Unhandled ping: {}", ping);
    }
}
 
开发者ID:Red5,项目名称:red5-server-common,代码行数:36,代码来源:RTMPHandler.java

示例8: resultReceived

import org.red5.server.net.rtmp.event.Ping; //导入依赖的package包/类
@Override
public void resultReceived(IPendingServiceCall call) {
    Number streamId = (Number) call.getResult();
    // live buffer 0.5s / vod buffer 4s
    if (Boolean.valueOf(PropertiesReader.getProperty("live"))) {
        conn.ping(new Ping(Ping.CLIENT_BUFFER, streamId, 500));
        play(streamId, PropertiesReader.getProperty("name"), -1, -1);
    } else {
        conn.ping(new Ping(Ping.CLIENT_BUFFER, streamId, 4000));
        play(streamId, PropertiesReader.getProperty("name"), 0, -1);
    }
}
 
开发者ID:Red5,项目名称:red5-client,代码行数:13,代码来源:ClientTest.java

示例9: resultReceived

import org.red5.server.net.rtmp.event.Ping; //导入依赖的package包/类
@Override
public void resultReceived(IPendingServiceCall call) {
    int streamId = (Integer) call.getResult();
    // live buffer 0.5s / vod buffer 4s
    if (Boolean.valueOf(PropertiesReader.getProperty("rtmpts.live"))) {
        conn.ping(new Ping(Ping.CLIENT_BUFFER, streamId, 500));
        play(streamId, PropertiesReader.getProperty("rtmpts.name"), -1, -1);
    } else {
        conn.ping(new Ping(Ping.CLIENT_BUFFER, streamId, 4000));
        play(streamId, PropertiesReader.getProperty("rtmpts.name"), 0, -1);
    }
}
 
开发者ID:Red5,项目名称:red5-client,代码行数:13,代码来源:RTMPTSClientTest.java

示例10: resultReceived

import org.red5.server.net.rtmp.event.Ping; //导入依赖的package包/类
@Override
public void resultReceived(IPendingServiceCall call) {
    int streamId = (Integer) call.getResult();
    // live buffer 0.5s / vod buffer 4s
    if (Boolean.valueOf(PropertiesReader.getProperty("rtmpt.live"))) {
        conn.ping(new Ping(Ping.CLIENT_BUFFER, streamId, 500));
        play(streamId, PropertiesReader.getProperty("rtmpt.name"), -1, -1);
    } else {
        conn.ping(new Ping(Ping.CLIENT_BUFFER, streamId, 4000));
        play(streamId, PropertiesReader.getProperty("rtmpt.name"), 0, -1);
    }
}
 
开发者ID:Red5,项目名称:red5-client,代码行数:13,代码来源:RTMPTClientTest.java

示例11: sendClearPing

import org.red5.server.net.rtmp.event.Ping; //导入依赖的package包/类
/**
 * Send clear ping. Lets client know that stream has no more data to
 * send.
 */
private void sendClearPing() {
	Ping eof = new Ping();
	eof.setEventType(Ping.STREAM_PLAYBUFFER_CLEAR);
	eof.setValue2(streamId);
	// eos 
	RTMPMessage eofMsg = RTMPMessage.build(eof);
	doPushMessage(eofMsg);
}
 
开发者ID:cwpenhale,项目名称:red5-mobileconsole,代码行数:13,代码来源:PlayEngine.java

示例12: ping

import org.red5.server.net.rtmp.event.Ping; //导入依赖的package包/类
/** {@inheritDoc} */
public void ping() {
	long newPingTime = System.currentTimeMillis();
	log.debug("Pinging client with id {} at {}, last ping sent at {}", new Object[] { getId(), newPingTime, lastPingSent.get() });
	if (lastPingSent.get() == 0) {
		lastPongReceived.set(newPingTime);
	}
	Ping pingRequest = new Ping();
	pingRequest.setEventType(Ping.PING_CLIENT);
	lastPingSent.set(newPingTime);
	int now = (int) (newPingTime & 0xffffffff);
	pingRequest.setValue2(now);
	ping(pingRequest);
}
 
开发者ID:cwpenhale,项目名称:red5-mobileconsole,代码行数:15,代码来源:RTMPConnection.java

示例13: pingReceived

import org.red5.server.net.rtmp.event.Ping; //导入依赖的package包/类
/**
 * Marks that ping back was received.
 * 
 * @param pong
 *            Ping object
 */
public void pingReceived(Ping pong) {
	long now = System.currentTimeMillis();
	long previousReceived = (int) (lastPingSent.get() & 0xffffffff);
	log.debug("Pong from client id {} at {} with value {}, previous received at {}", new Object[] { getId(), now, pong.getValue2(), previousReceived });
	if (pong.getValue2() == previousReceived) {
		lastPingTime.set((int) (now & 0xffffffff) - pong.getValue2());
	}
	lastPongReceived.set(now);
}
 
开发者ID:cwpenhale,项目名称:red5-mobileconsole,代码行数:16,代码来源:RTMPConnection.java

示例14: onPing

import org.red5.server.net.rtmp.event.Ping; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
protected void onPing(RTMPConnection conn, Channel channel, Header source, Ping ping) {
	switch (ping.getEventType()) {
		case Ping.CLIENT_BUFFER:
			SetBuffer setBuffer = (SetBuffer) ping;
			// get the stream id
			int streamId = setBuffer.getStreamId();
			// get requested buffer size in milliseconds
			int buffer = setBuffer.getBufferLength();
			log.debug("Client sent a buffer size: {} ms for stream id: {}", buffer, streamId);
			IClientStream stream = null;
			if (streamId != 0) {
				// The client wants to set the buffer time
				stream = conn.getStreamById(streamId);
				if (stream != null) {
					stream.setClientBufferDuration(buffer);
					log.trace("Stream type: {}", stream.getClass().getName());
				}
			}
			//catch-all to make sure buffer size is set
			if (stream == null) {
				// Remember buffer time until stream is created
				conn.rememberStreamBufferDuration(streamId, buffer);
				log.info("Remembering client buffer on stream: {}", buffer);
			}
			break;
		case Ping.PONG_SERVER:
			// This is the response to an IConnection.ping request
			conn.pingReceived(ping);
			break;
		default:
			log.warn("Unhandled ping: {}", ping);
	}
}
 
开发者ID:cwpenhale,项目名称:red5-mobileconsole,代码行数:36,代码来源:RTMPHandler.java

示例15: encodePing

import org.red5.server.net.rtmp.event.Ping; //导入依赖的package包/类
/** {@inheritDoc} */
public IoBuffer encodePing(Ping ping) {
    int len;
    short type = ping.getEventType();
    switch (type) {
        case Ping.CLIENT_BUFFER:
            len = 10;
            break;
        case Ping.PONG_SWF_VERIFY:
            len = 44;
            break;
        default:
            len = 6;
    }
    final IoBuffer out = IoBuffer.allocate(len);
    out.putShort(type);
    switch (type) {
        case Ping.STREAM_BEGIN:
        case Ping.STREAM_PLAYBUFFER_CLEAR:
        case Ping.STREAM_DRY:
        case Ping.RECORDED_STREAM:
        case Ping.PING_CLIENT:
        case Ping.PONG_SERVER:
        case Ping.BUFFER_EMPTY:
        case Ping.BUFFER_FULL:
            out.putInt(ping.getValue2().intValue());
            break;
        case Ping.CLIENT_BUFFER:
            if (ping instanceof SetBuffer) {
                SetBuffer setBuffer = (SetBuffer) ping;
                out.putInt(setBuffer.getStreamId());
                out.putInt(setBuffer.getBufferLength());
            } else {
                out.putInt(ping.getValue2().intValue());
                out.putInt(ping.getValue3());
            }
            break;
        case Ping.PING_SWF_VERIFY:
            break;
        case Ping.PONG_SWF_VERIFY:
            out.put(((SWFResponse) ping).getBytes());
            break;
    }
    // this may not be needed anymore
    if (ping.getValue4() != Ping.UNDEFINED) {
        out.putInt(ping.getValue4());
    }
    return out;
}
 
开发者ID:Red5,项目名称:red5-server-common,代码行数:50,代码来源:RTMPProtocolEncoder.java


注:本文中的org.red5.server.net.rtmp.event.Ping类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。