forked from shogo4405/HaishinKit.kt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add RTMPAbortMessage
- Loading branch information
Showing
5 changed files
with
134 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
app/src/main/java/com/haishinkit/rtmp/messages/RTMPAbortMessage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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; | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
app/src/main/java/com/haishinkit/rtmp/messages/RTMPAcknowledgementMessage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.haishinkit.rtmp.messages; | ||
|
||
import com.haishinkit.rtmp.RTMPConnection; | ||
import com.haishinkit.rtmp.RTMPSocket; | ||
import java.nio.ByteBuffer; | ||
|
||
/** | ||
* 5.4.3 Acknowledgement (3) | ||
*/ | ||
public final class RTMPAcknowledgementMessage extends RTMPMessage { | ||
private static final int CAPACITY = 4; | ||
|
||
private byte[] sequence = null; | ||
|
||
public RTMPAcknowledgementMessage() { | ||
super(Type.ACK); | ||
sequence = new byte[CAPACITY]; | ||
} | ||
|
||
public final byte[] getSequence() { | ||
return sequence; | ||
} | ||
|
||
public final RTMPAcknowledgementMessage setSequence(final byte[] sequence) { | ||
this.sequence = sequence; | ||
return this; | ||
} | ||
|
||
@Override | ||
public ByteBuffer encode(final RTMPSocket socket) { | ||
if (socket == null) { | ||
throw new IllegalArgumentException(); | ||
} | ||
ByteBuffer buffer = ByteBuffer.allocate(CAPACITY); | ||
buffer.put(sequence); | ||
return buffer; | ||
} | ||
|
||
@Override | ||
public RTMPMessage decode(final ByteBuffer buffer) { | ||
if (buffer == null) { | ||
throw new IllegalArgumentException(); | ||
} | ||
buffer.get(getSequence()); | ||
return this; | ||
} | ||
|
||
@Override | ||
public RTMPMessage execute(final RTMPConnection connection) { | ||
if (connection == null) { | ||
throw new IllegalArgumentException(); | ||
} | ||
return this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters