forked from shogo4405/HaishinKit.kt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RTMPAbortMessage.java
51 lines (41 loc) · 1.23 KB
/
RTMPAbortMessage.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package com.haishinkit.rtmp.messages;
import com.haishinkit.rtmp.RTMPConnection;
import com.haishinkit.rtmp.RTMPSocket;
import java.nio.ByteBuffer;
public final class RTMPAbortMessage extends RTMPMessage {
private static final int CAPACITY = 4;
private int discarded = 0;
public RTMPAbortMessage() {
super(Type.ABORT);
}
public final int getDiscarded() {
return discarded;
}
public final RTMPAbortMessage setDiscarded(final int discarded) {
this.discarded = discarded;
return this;
}
@Override
public ByteBuffer encode(final RTMPSocket socket) {
if (socket == null) {
throw new IllegalArgumentException();
}
ByteBuffer buffer = ByteBuffer.allocate(CAPACITY);
buffer.putInt(getDiscarded());
return buffer;
}
@Override
public RTMPMessage decode(final ByteBuffer buffer) {
if (buffer == null) {
throw new IllegalArgumentException();
}
return setDiscarded(buffer.getInt());
}
@Override
public RTMPMessage execute(final RTMPConnection connection) {
if (connection == null) {
throw new IllegalArgumentException();
}
return this;
}
}