本文整理汇总了Java中org.red5.server.net.rtmp.event.Ping.getEventType方法的典型用法代码示例。如果您正苦于以下问题:Java Ping.getEventType方法的具体用法?Java Ping.getEventType怎么用?Java Ping.getEventType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.red5.server.net.rtmp.event.Ping
的用法示例。
在下文中一共展示了Ping.getEventType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
示例2: 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);
}
}
示例3: 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;
}
示例4: onPing
import org.red5.server.net.rtmp.event.Ping; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
protected void onPing(RTMPConnection conn, Channel channel, Header source, Ping ping) {
log.trace("onPing");
switch (ping.getEventType()) {
case Ping.PING_CLIENT:
case Ping.STREAM_BEGIN:
case Ping.RECORDED_STREAM:
case Ping.STREAM_PLAYBUFFER_CLEAR:
// the server wants to measure the RTT
Ping pong = new Ping();
pong.setEventType(Ping.PONG_SERVER);
pong.setValue2((int) (System.currentTimeMillis() & 0xffffffff));
conn.ping(pong);
break;
case Ping.STREAM_DRY:
log.debug("Stream indicates there is no data available");
break;
case Ping.CLIENT_BUFFER:
// set the client buffer
IClientStream stream = null;
// get the stream id
Number streamId = ping.getValue2();
// get requested buffer size in milliseconds
int buffer = ping.getValue3();
log.debug("Client sent a buffer size: {} ms for stream id: {}", buffer, streamId);
// the client wants to set the buffer time
stream = conn.getStreamById(streamId);
if (stream != null) {
stream.setClientBufferDuration(buffer);
log.info("Setting client buffer on stream: {}", buffer);
}
// catch-all to make sure buffer size is set
if (stream == null) {
// remember buffer time until stream is created
conn.rememberStreamBufferDuration(streamId.intValue(), buffer);
log.info("Remembering client buffer on stream: {}", buffer);
}
break;
case Ping.PING_SWF_VERIFY:
log.debug("SWF verification ping");
// TODO get the swf verification bytes from the handshake
SWFResponse swfPong = new SWFResponse(new byte[42]);
conn.ping(swfPong);
break;
case Ping.BUFFER_EMPTY:
log.debug("Buffer empty ping");
break;
case Ping.BUFFER_FULL:
log.debug("Buffer full ping");
break;
default:
log.warn("Unhandled ping: {}", ping);
}
}
示例5: 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());
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());
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;
}