Java Code Examples for org.red5.server.stream.message.RTMPMessage#getBody()
The following examples show how to use
org.red5.server.stream.message.RTMPMessage#getBody() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VideoFrameDropper.java From red5-server-common with Apache License 2.0 | 4 votes |
/** {@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; }
Example 2
Source File: VideoFrameDropper.java From red5-server-common with Apache License 2.0 | 4 votes |
/** {@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: } } }