Skip to content
Snippets Groups Projects
Commit faf1164a authored by Leo Ma's avatar Leo Ma
Browse files

Rename


Signed-off-by: default avatarLeo Ma <begeekmyfriend@gmail.com>
parent f185b820
No related branches found
No related tags found
No related merge requests found
Showing
with 31 additions and 30 deletions
Loading
Loading
@@ -15,11 +15,12 @@ import net.ossrs.yasea.rtmp.packets.RtmpHeader;
*/
public class ChunkStreamInfo {
 
public static final byte RTMP_STREAM_CHANNEL = 0x05;
public static final byte RTMP_COMMAND_CHANNEL = 0x03;
public static final byte RTMP_VIDEO_CHANNEL = 0x06;
public static final byte RTMP_AUDIO_CHANNEL = 0x07;
public static final byte RTMP_CONTROL_CHANNEL = 0x02;
public static final byte RTMP_CID_PROTOCOL_CONTROL = 0x02;
public static final byte RTMP_CID_OVER_CONNECTION = 0x03;
public static final byte RTMP_CID_OVER_CONNECTION2 = 0x04;
public static final byte RTMP_CID_OVER_STREAM = 0x05;
public static final byte RTMP_CID_VIDEO = 0x06;
public static final byte RTMP_CID_AUDIO = 0x07;
private RtmpHeader prevHeaderRx;
private RtmpHeader prevHeaderTx;
private static long sessionBeginTimestamp;
Loading
Loading
Loading
Loading
@@ -25,7 +25,6 @@ import net.ossrs.yasea.rtmp.amf.AmfNumber;
import net.ossrs.yasea.rtmp.amf.AmfObject;
import net.ossrs.yasea.rtmp.amf.AmfString;
import net.ossrs.yasea.rtmp.packets.Abort;
import net.ossrs.yasea.rtmp.packets.Acknowledgement;
import net.ossrs.yasea.rtmp.packets.Data;
import net.ossrs.yasea.rtmp.packets.Handshake;
import net.ossrs.yasea.rtmp.packets.Command;
Loading
Loading
@@ -56,8 +55,8 @@ public class RtmpConnection implements RtmpPublisher {
private Socket socket;
private String srsServerInfo = "";
private String socketExceptionCause = "";
private RtmpSessionInfo rtmpSessionInfo = new RtmpSessionInfo();
private RtmpDecoder rtmpDecoder = new RtmpDecoder(rtmpSessionInfo);
private RtmpSessionInfo rtmpSessionInfo;
private RtmpDecoder rtmpDecoder;
private BufferedInputStream inputStream;
private BufferedOutputStream outputStream;
private Thread rxPacketHandler;
Loading
Loading
@@ -115,6 +114,8 @@ public class RtmpConnection implements RtmpPublisher {
 
// socket connection
Log.d(TAG, "connect() called. Host: " + host + ", port: " + port + ", appName: " + appName + ", publishPath: " + streamName);
rtmpSessionInfo = new RtmpSessionInfo();
rtmpDecoder = new RtmpDecoder(rtmpSessionInfo);
socket = new Socket();
SocketAddress socketAddress = new InetSocketAddress(host, port);
socket.connect(socketAddress, 3000);
Loading
Loading
@@ -151,7 +152,7 @@ public class RtmpConnection implements RtmpPublisher {
ChunkStreamInfo.markSessionTimestampTx();
 
Log.d(TAG, "rtmpConnect(): Building 'connect' invoke packet");
ChunkStreamInfo chunkStreamInfo = rtmpSessionInfo.getChunkStreamInfo(ChunkStreamInfo.RTMP_COMMAND_CHANNEL);
ChunkStreamInfo chunkStreamInfo = rtmpSessionInfo.getChunkStreamInfo(ChunkStreamInfo.RTMP_CID_OVER_CONNECTION);
Command invoke = new Command("connect", ++transactionIdCounter, chunkStreamInfo);
invoke.getHeader().setMessageStreamId(0);
AmfObject args = new AmfObject();
Loading
Loading
@@ -200,7 +201,7 @@ public class RtmpConnection implements RtmpPublisher {
Log.d(TAG, "createStream(): Sending releaseStream command...");
// transactionId == 2
Command releaseStream = new Command("releaseStream", ++transactionIdCounter);
releaseStream.getHeader().setChunkStreamId(ChunkStreamInfo.RTMP_STREAM_CHANNEL);
releaseStream.getHeader().setChunkStreamId(ChunkStreamInfo.RTMP_CID_OVER_STREAM);
releaseStream.addData(new AmfNull()); // command object: null for "createStream"
releaseStream.addData(streamName); // command object: null for "releaseStream"
sendRtmpPacket(releaseStream);
Loading
Loading
@@ -208,13 +209,13 @@ public class RtmpConnection implements RtmpPublisher {
Log.d(TAG, "createStream(): Sending FCPublish command...");
// transactionId == 3
Command FCPublish = new Command("FCPublish", ++transactionIdCounter);
FCPublish.getHeader().setChunkStreamId(ChunkStreamInfo.RTMP_STREAM_CHANNEL);
FCPublish.getHeader().setChunkStreamId(ChunkStreamInfo.RTMP_CID_OVER_STREAM);
FCPublish.addData(new AmfNull()); // command object: null for "FCPublish"
FCPublish.addData(streamName);
sendRtmpPacket(FCPublish);
 
Log.d(TAG, "createStream(): Sending createStream command...");
ChunkStreamInfo chunkStreamInfo = rtmpSessionInfo.getChunkStreamInfo(ChunkStreamInfo.RTMP_COMMAND_CHANNEL);
ChunkStreamInfo chunkStreamInfo = rtmpSessionInfo.getChunkStreamInfo(ChunkStreamInfo.RTMP_CID_OVER_CONNECTION);
// transactionId == 4
Command createStream = new Command("createStream", ++transactionIdCounter, chunkStreamInfo);
createStream.addData(new AmfNull()); // command object: null for "createStream"
Loading
Loading
@@ -247,7 +248,7 @@ public class RtmpConnection implements RtmpPublisher {
Log.d(TAG, "fmlePublish(): Sending publish command...");
// transactionId == 0
Command publish = new Command("publish", 0);
publish.getHeader().setChunkStreamId(ChunkStreamInfo.RTMP_STREAM_CHANNEL);
publish.getHeader().setChunkStreamId(ChunkStreamInfo.RTMP_CID_OVER_STREAM);
publish.getHeader().setMessageStreamId(currentStreamId);
publish.addData(new AmfNull()); // command object: null for "publish"
publish.addData(streamName);
Loading
Loading
@@ -295,7 +296,7 @@ public class RtmpConnection implements RtmpPublisher {
}
Log.d(TAG, "closeStream(): setting current stream ID to 0");
Command closeStream = new Command("closeStream", 0);
closeStream.getHeader().setChunkStreamId(ChunkStreamInfo.RTMP_STREAM_CHANNEL);
closeStream.getHeader().setChunkStreamId(ChunkStreamInfo.RTMP_CID_OVER_STREAM);
closeStream.getHeader().setMessageStreamId(currentStreamId);
closeStream.addData(new AmfNull());
sendRtmpPacket(closeStream);
Loading
Loading
@@ -355,6 +356,8 @@ public class RtmpConnection implements RtmpPublisher {
serverIpAddr = null;
serverPid = null;
serverId = null;
rtmpSessionInfo = null;
rtmpDecoder = null;
}
 
@Override
Loading
Loading
@@ -475,7 +478,7 @@ public class RtmpConnection implements RtmpPublisher {
}
break;
case PING_REQUEST:
ChunkStreamInfo channelInfo = rtmpSessionInfo.getChunkStreamInfo(ChunkStreamInfo.RTMP_CONTROL_CHANNEL);
ChunkStreamInfo channelInfo = rtmpSessionInfo.getChunkStreamInfo(ChunkStreamInfo.RTMP_CID_PROTOCOL_CONTROL);
Log.d(TAG, "handleRxPacketLoop(): Sending PONG reply..");
UserControl pong = new UserControl(user, channelInfo);
sendRtmpPacket(pong);
Loading
Loading
@@ -498,7 +501,7 @@ public class RtmpConnection implements RtmpPublisher {
SetPeerBandwidth bw = (SetPeerBandwidth) rtmpPacket;
rtmpSessionInfo.setAcknowledgmentWindowSize(bw.getAcknowledgementWindowSize());
int acknowledgementWindowsize = rtmpSessionInfo.getAcknowledgementWindowSize();
ChunkStreamInfo chunkStreamInfo = rtmpSessionInfo.getChunkStreamInfo(ChunkStreamInfo.RTMP_CONTROL_CHANNEL);
ChunkStreamInfo chunkStreamInfo = rtmpSessionInfo.getChunkStreamInfo(ChunkStreamInfo.RTMP_CID_PROTOCOL_CONTROL);
Log.d(TAG, "handleRxPacketLoop(): Send acknowledgement window size: " + acknowledgementWindowsize);
sendRtmpPacket(new WindowAckSize(acknowledgementWindowsize, chunkStreamInfo));
// Set socket option
Loading
Loading
Loading
Loading
@@ -21,7 +21,7 @@ public class Abort extends RtmpPacket {
}
 
public Abort(int chunkStreamId) {
super(new RtmpHeader(RtmpHeader.ChunkType.TYPE_1_RELATIVE_LARGE, ChunkStreamInfo.RTMP_CONTROL_CHANNEL, RtmpHeader.MessageType.SET_CHUNK_SIZE));
super(new RtmpHeader(RtmpHeader.ChunkType.TYPE_1_RELATIVE_LARGE, ChunkStreamInfo.RTMP_CID_PROTOCOL_CONTROL, RtmpHeader.MessageType.SET_CHUNK_SIZE));
this.chunkStreamId = chunkStreamId;
}
 
Loading
Loading
Loading
Loading
@@ -28,7 +28,7 @@ public class Acknowledgement extends RtmpPacket {
}
 
public Acknowledgement(int numBytesReadThusFar) {
super(new RtmpHeader(RtmpHeader.ChunkType.TYPE_0_FULL, ChunkStreamInfo.RTMP_CONTROL_CHANNEL, RtmpHeader.MessageType.ACKNOWLEDGEMENT));
super(new RtmpHeader(RtmpHeader.ChunkType.TYPE_0_FULL, ChunkStreamInfo.RTMP_CID_PROTOCOL_CONTROL, RtmpHeader.MessageType.ACKNOWLEDGEMENT));
this.sequenceNumber = numBytesReadThusFar;
}
 
Loading
Loading
Loading
Loading
@@ -14,7 +14,7 @@ public class Audio extends ContentData {
}
 
public Audio() {
super(new RtmpHeader(RtmpHeader.ChunkType.TYPE_0_FULL, ChunkStreamInfo.RTMP_AUDIO_CHANNEL, RtmpHeader.MessageType.AUDIO));
super(new RtmpHeader(RtmpHeader.ChunkType.TYPE_0_FULL, ChunkStreamInfo.RTMP_CID_AUDIO, RtmpHeader.MessageType.AUDIO));
}
 
@Override
Loading
Loading
Loading
Loading
@@ -30,13 +30,13 @@ public class Command extends VariableBodyRtmpPacket {
}
 
public Command(String commandName, int transactionId, ChunkStreamInfo channelInfo) {
super(new RtmpHeader((channelInfo.canReusePrevHeaderTx(RtmpHeader.MessageType.COMMAND_AMF0) ? RtmpHeader.ChunkType.TYPE_1_RELATIVE_LARGE : RtmpHeader.ChunkType.TYPE_0_FULL), ChunkStreamInfo.RTMP_COMMAND_CHANNEL, RtmpHeader.MessageType.COMMAND_AMF0));
super(new RtmpHeader((channelInfo.canReusePrevHeaderTx(RtmpHeader.MessageType.COMMAND_AMF0) ? RtmpHeader.ChunkType.TYPE_1_RELATIVE_LARGE : RtmpHeader.ChunkType.TYPE_0_FULL), ChunkStreamInfo.RTMP_CID_OVER_CONNECTION, RtmpHeader.MessageType.COMMAND_AMF0));
this.commandName = commandName;
this.transactionId = transactionId;
}
public Command(String commandName, int transactionId) {
super(new RtmpHeader(RtmpHeader.ChunkType.TYPE_0_FULL, ChunkStreamInfo.RTMP_COMMAND_CHANNEL, RtmpHeader.MessageType.COMMAND_AMF0));
super(new RtmpHeader(RtmpHeader.ChunkType.TYPE_0_FULL, ChunkStreamInfo.RTMP_CID_OVER_CONNECTION, RtmpHeader.MessageType.COMMAND_AMF0));
this.commandName = commandName;
this.transactionId = transactionId;
}
Loading
Loading
Loading
Loading
@@ -27,7 +27,7 @@ public class Data extends VariableBodyRtmpPacket {
}
 
public Data(String type) {
super(new RtmpHeader(RtmpHeader.ChunkType.TYPE_0_FULL, ChunkStreamInfo.RTMP_COMMAND_CHANNEL, RtmpHeader.MessageType.DATA_AMF0));
super(new RtmpHeader(RtmpHeader.ChunkType.TYPE_0_FULL, ChunkStreamInfo.RTMP_CID_OVER_CONNECTION, RtmpHeader.MessageType.DATA_AMF0));
this.type = type;
}
 
Loading
Loading
Loading
Loading
@@ -11,8 +11,6 @@ import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;
 
import android.util.Log;
import net.ossrs.yasea.rtmp.Util;
import net.ossrs.yasea.rtmp.io.ChunkStreamInfo;
import net.ossrs.yasea.rtmp.io.RtmpSessionInfo;
Loading
Loading
@@ -300,7 +298,6 @@ public class RtmpHeader {
break;
}
default:
Log.e(TAG, "readHeaderImpl(): Invalid chunk type; basic header byte was: " + Util.toHexString((byte) basicHeaderByte));
throw new IOException("Invalid chunk type; basic header byte was: " + Util.toHexString((byte) basicHeaderByte));
}
}
Loading
Loading
Loading
Loading
@@ -21,7 +21,7 @@ public class SetChunkSize extends RtmpPacket {
}
 
public SetChunkSize(int chunkSize) {
super(new RtmpHeader(RtmpHeader.ChunkType.TYPE_1_RELATIVE_LARGE, ChunkStreamInfo.RTMP_CONTROL_CHANNEL, RtmpHeader.MessageType.SET_CHUNK_SIZE));
super(new RtmpHeader(RtmpHeader.ChunkType.TYPE_1_RELATIVE_LARGE, ChunkStreamInfo.RTMP_CID_PROTOCOL_CONTROL, RtmpHeader.MessageType.SET_CHUNK_SIZE));
this.chunkSize = chunkSize;
}
 
Loading
Loading
Loading
Loading
@@ -65,7 +65,7 @@ public class SetPeerBandwidth extends RtmpPacket {
}
public SetPeerBandwidth(int acknowledgementWindowSize, LimitType limitType, ChunkStreamInfo channelInfo) {
super(new RtmpHeader(channelInfo.canReusePrevHeaderTx(RtmpHeader.MessageType.SET_PEER_BANDWIDTH) ? RtmpHeader.ChunkType.TYPE_2_RELATIVE_TIMESTAMP_ONLY : RtmpHeader.ChunkType.TYPE_0_FULL, ChunkStreamInfo.RTMP_CONTROL_CHANNEL, RtmpHeader.MessageType.WINDOW_ACKNOWLEDGEMENT_SIZE));
super(new RtmpHeader(channelInfo.canReusePrevHeaderTx(RtmpHeader.MessageType.SET_PEER_BANDWIDTH) ? RtmpHeader.ChunkType.TYPE_2_RELATIVE_TIMESTAMP_ONLY : RtmpHeader.ChunkType.TYPE_0_FULL, ChunkStreamInfo.RTMP_CID_PROTOCOL_CONTROL, RtmpHeader.MessageType.WINDOW_ACKNOWLEDGEMENT_SIZE));
this.acknowledgementWindowSize = acknowledgementWindowSize;
this.limitType = limitType;
}
Loading
Loading
Loading
Loading
@@ -156,7 +156,7 @@ public class UserControl extends RtmpPacket {
}
 
public UserControl(ChunkStreamInfo channelInfo) {
super(new RtmpHeader(channelInfo.canReusePrevHeaderTx(RtmpHeader.MessageType.USER_CONTROL_MESSAGE) ? RtmpHeader.ChunkType.TYPE_2_RELATIVE_TIMESTAMP_ONLY : RtmpHeader.ChunkType.TYPE_0_FULL, ChunkStreamInfo.RTMP_CONTROL_CHANNEL, RtmpHeader.MessageType.USER_CONTROL_MESSAGE));
super(new RtmpHeader(channelInfo.canReusePrevHeaderTx(RtmpHeader.MessageType.USER_CONTROL_MESSAGE) ? RtmpHeader.ChunkType.TYPE_2_RELATIVE_TIMESTAMP_ONLY : RtmpHeader.ChunkType.TYPE_0_FULL, ChunkStreamInfo.RTMP_CID_PROTOCOL_CONTROL, RtmpHeader.MessageType.USER_CONTROL_MESSAGE));
}
 
/** Convenience construtor that creates a "pong" message for the specified ping */
Loading
Loading
Loading
Loading
@@ -14,7 +14,7 @@ public class Video extends ContentData {
}
 
public Video() {
super(new RtmpHeader(RtmpHeader.ChunkType.TYPE_0_FULL, ChunkStreamInfo.RTMP_VIDEO_CHANNEL, RtmpHeader.MessageType.VIDEO));
super(new RtmpHeader(RtmpHeader.ChunkType.TYPE_0_FULL, ChunkStreamInfo.RTMP_CID_VIDEO, RtmpHeader.MessageType.VIDEO));
}
 
@Override
Loading
Loading
Loading
Loading
@@ -23,7 +23,7 @@ public class WindowAckSize extends RtmpPacket {
}
public WindowAckSize(int acknowledgementWindowSize, ChunkStreamInfo channelInfo) {
super(new RtmpHeader(channelInfo.canReusePrevHeaderTx(RtmpHeader.MessageType.WINDOW_ACKNOWLEDGEMENT_SIZE) ? RtmpHeader.ChunkType.TYPE_2_RELATIVE_TIMESTAMP_ONLY : RtmpHeader.ChunkType.TYPE_0_FULL, ChunkStreamInfo.RTMP_CONTROL_CHANNEL, RtmpHeader.MessageType.WINDOW_ACKNOWLEDGEMENT_SIZE));
super(new RtmpHeader(channelInfo.canReusePrevHeaderTx(RtmpHeader.MessageType.WINDOW_ACKNOWLEDGEMENT_SIZE) ? RtmpHeader.ChunkType.TYPE_2_RELATIVE_TIMESTAMP_ONLY : RtmpHeader.ChunkType.TYPE_0_FULL, ChunkStreamInfo.RTMP_CID_PROTOCOL_CONTROL, RtmpHeader.MessageType.WINDOW_ACKNOWLEDGEMENT_SIZE));
this.acknowledgementWindowSize = acknowledgementWindowSize;
}
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment