本文整理汇总了Java中org.red5.server.stream.message.RTMPMessage.getBody方法的典型用法代码示例。如果您正苦于以下问题:Java RTMPMessage.getBody方法的具体用法?Java RTMPMessage.getBody怎么用?Java RTMPMessage.getBody使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.red5.server.stream.message.RTMPMessage
的用法示例。
在下文中一共展示了RTMPMessage.getBody方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: putMessage
import org.red5.server.stream.message.RTMPMessage; //导入方法依赖的package包/类
/**
* Put a message into this buffer.
*
* @param message
* RTMP message
* @return <tt>true</tt> indicates success and <tt>false</tt> indicates buffer is full.
*/
public boolean putMessage(RTMPMessage message) {
IRTMPEvent body = message.getBody();
if (!(body instanceof IStreamData)) {
throw new RuntimeException("Expected IStreamData but got " + body);
}
int size = ((IStreamData<?>) body).getData().limit();
if (messageSize + size > capacity) {
return false;
}
messageSize += size;
messageQueue.offer(message);
return true;
}
示例2: takeMessage
import org.red5.server.stream.message.RTMPMessage; //导入方法依赖的package包/类
/**
* Take a message from this buffer. The message count decreases.
*
* @return <tt>null</tt> if buffer is empty.
*/
public RTMPMessage takeMessage() {
RTMPMessage message = messageQueue.poll();
if (message != null) {
IRTMPEvent body = message.getBody();
if (!(body instanceof IStreamData)) {
throw new RuntimeException("Expected IStreamData but got " + body);
}
messageSize -= ((IStreamData<?>) body).getData().limit();
}
return message;
}
示例3: putMessage
import org.red5.server.stream.message.RTMPMessage; //导入方法依赖的package包/类
/**
* Put a message into this buffer.
*
* @param message RTMP message
* @return <tt>true</tt> indicates success and <tt>false</tt>
* indicates buffer is full.
*/
public boolean putMessage(RTMPMessage message) {
IRTMPEvent body = message.getBody();
if (!(body instanceof IStreamData)) {
throw new RuntimeException("Expected IStreamData but got " + body);
}
int size = ((IStreamData<?>) body).getData().limit();
if (messageSize + size > capacity) {
return false;
}
messageSize += size;
messageQueue.offer(message);
return true;
}
示例4: takeMessage
import org.red5.server.stream.message.RTMPMessage; //导入方法依赖的package包/类
/**
* Take a message from this buffer. The message count decreases.
*
* @return <tt>null</tt> if buffer is empty.
*/
public RTMPMessage takeMessage() {
RTMPMessage message = messageQueue.poll();
if (message != null) {
IRTMPEvent body = message.getBody();
if (!(body instanceof IStreamData)) {
throw new RuntimeException("Expected IStreamData but got " + body);
}
messageSize -= ((IStreamData<?>) body).getData().limit();
}
return message;
}
示例5: canSendPacket
import org.red5.server.stream.message.RTMPMessage; //导入方法依赖的package包/类
/** {@inheritDoc} */
public boolean canSendPacket(RTMPMessage message, long pending) {
IRTMPEvent packet = message.getBody();
boolean result = true;
// We currently only drop video packets.
if (packet instanceof VideoData) {
VideoData video = (VideoData) packet;
FrameType type = video.getFrameType();
switch (state) {
case SEND_ALL:
// All packets will be sent
break;
case SEND_INTERFRAMES:
// Only keyframes and interframes will be sent.
if (type == FrameType.KEYFRAME) {
if (pending == 0) {
// Send all frames from now on.
state = SEND_ALL;
}
} else if (type == FrameType.INTERFRAME) {
}
break;
case SEND_KEYFRAMES:
// Only keyframes will be sent.
result = (type == FrameType.KEYFRAME);
if (result && pending == 0) {
// Maybe switch back to SEND_INTERFRAMES after the next keyframe
state = SEND_KEYFRAMES_CHECK;
}
break;
case SEND_KEYFRAMES_CHECK:
// Only keyframes will be sent.
result = (type == FrameType.KEYFRAME);
if (result && pending == 0) {
// Continue with sending interframes as well
state = SEND_INTERFRAMES;
}
break;
default:
}
}
return result;
}
示例6: dropPacket
import org.red5.server.stream.message.RTMPMessage; //导入方法依赖的package包/类
/** {@inheritDoc} */
public void dropPacket(RTMPMessage message) {
IRTMPEvent packet = message.getBody();
// Only check video packets.
if (packet instanceof VideoData) {
VideoData video = (VideoData) packet;
FrameType type = video.getFrameType();
switch (state) {
case SEND_ALL:
if (type == FrameType.DISPOSABLE_INTERFRAME) {
// Remain in state, packet is safe to drop.
return;
} else if (type == FrameType.INTERFRAME) {
// Drop all frames until the next keyframe.
state = SEND_KEYFRAMES;
return;
} else if (type == FrameType.KEYFRAME) {
// Drop all frames until the next keyframe.
state = SEND_KEYFRAMES;
return;
}
break;
case SEND_INTERFRAMES:
if (type == FrameType.INTERFRAME) {
// Drop all frames until the next keyframe.
state = SEND_KEYFRAMES_CHECK;
return;
} else if (type == FrameType.KEYFRAME) {
// Drop all frames until the next keyframe.
state = SEND_KEYFRAMES;
return;
}
break;
case SEND_KEYFRAMES:
// Remain in state.
break;
case SEND_KEYFRAMES_CHECK:
if (type == FrameType.KEYFRAME) {
// Switch back to sending keyframes, but don't move to
// SEND_INTERFRAMES afterwards.
state = SEND_KEYFRAMES;
return;
}
break;
default:
}
}
}
示例7: canSendPacket
import org.red5.server.stream.message.RTMPMessage; //导入方法依赖的package包/类
/** {@inheritDoc} */
public boolean canSendPacket(RTMPMessage message, long pending) {
IRTMPEvent packet = message.getBody();
boolean result = true;
// We currently only drop video packets.
if (packet instanceof VideoData) {
VideoData video = (VideoData) packet;
FrameType type = video.getFrameType();
switch (state) {
case SEND_ALL:
// All packets will be sent
break;
case SEND_INTERFRAMES:
// Only keyframes and interframes will be sent.
if (type == FrameType.KEYFRAME) {
if (pending == 0) {
// Send all frames from now on.
state = SEND_ALL;
}
} else if (type == FrameType.INTERFRAME) {
}
break;
case SEND_KEYFRAMES:
// Only keyframes will be sent.
result = (type == FrameType.KEYFRAME);
if (result && pending == 0) {
// Maybe switch back to SEND_INTERFRAMES after the next keyframe
state = SEND_KEYFRAMES_CHECK;
}
break;
case SEND_KEYFRAMES_CHECK:
// Only keyframes will be sent.
result = (type == FrameType.KEYFRAME);
if (result && pending == 0) {
// Continue with sending interframes as well
state = SEND_INTERFRAMES;
}
break;
default:
}
}
return result;
}
示例8: dropPacket
import org.red5.server.stream.message.RTMPMessage; //导入方法依赖的package包/类
/** {@inheritDoc} */
public void dropPacket(RTMPMessage message) {
IRTMPEvent packet = message.getBody();
// Only check video packets.
if (packet instanceof VideoData) {
VideoData video = (VideoData) packet;
FrameType type = video.getFrameType();
switch (state) {
case SEND_ALL:
if (type == FrameType.DISPOSABLE_INTERFRAME) {
// Remain in state, packet is safe to drop.
return;
} else if (type == FrameType.INTERFRAME) {
// Drop all frames until the next keyframe.
state = SEND_KEYFRAMES;
return;
} else if (type == FrameType.KEYFRAME) {
// Drop all frames until the next keyframe.
state = SEND_KEYFRAMES;
return;
}
break;
case SEND_INTERFRAMES:
if (type == FrameType.INTERFRAME) {
// Drop all frames until the next keyframe.
state = SEND_KEYFRAMES_CHECK;
return;
} else if (type == FrameType.KEYFRAME) {
// Drop all frames until the next keyframe.
state = SEND_KEYFRAMES;
return;
}
break;
case SEND_KEYFRAMES:
// Remain in state.
break;
case SEND_KEYFRAMES_CHECK:
if (type == FrameType.KEYFRAME) {
// Switch back to sending keyframes, but don't move to
// SEND_INTERFRAMES afterwards.
state = SEND_KEYFRAMES;
return;
}
break;
default:
}
}
}