public int DecodeArray(byte[] buffer, int offset, int size, int arrayLength, bool decodeName) { bool error = false; int originalSize = size; while (arrayLength > 0) { arrayLength--; AMFObjectProperty prop = new AMFObjectProperty(); int nRes = prop.Decode(buffer, offset, size, decodeName); if (nRes == -1) { error = true; } else { size -= nRes; offset += nRes; properties.Add(prop); } } if (error) { return(-1); } return(originalSize - size); }
public void FindMatchingProperty(string name, List <AMFObjectProperty> p, int stopAt) { for (int n = 0; n < properties.Count; n++) { AMFObjectProperty prop = GetProperty(n); if (prop.PropertyName.ToLower() == name.ToLower()) { if (p == null) { p = new List <AMFObjectProperty>(); } p.Add(GetProperty(n)); if (p.Count >= stopAt) { return; } } if (prop.DataType == AMFDataType.AMF_OBJECT) { prop.ObjectValue.FindMatchingProperty(name, p, stopAt); } } }
/// <summary> /// Deep copy! /// </summary> public object Clone() { AMFObjectProperty clone = new AMFObjectProperty(); clone.stringName = stringName; clone.type = type; clone.numVal = numVal; if (objVal != null) { clone.objVal = (AMFObject)objVal.Clone(); } clone.stringVal = stringVal; clone.dateUTCOffset = dateUTCOffset; clone.date = date; return clone; }
/// <summary> /// Deep copy! /// </summary> public object Clone() { AMFObjectProperty clone = new AMFObjectProperty(); clone.stringName = stringName; clone.type = type; clone.numVal = numVal; if (objVal != null) { clone.objVal = (AMFObject)objVal.Clone(); } clone.stringVal = stringVal; clone.dateUTCOffset = dateUTCOffset; clone.date = date; return(clone); }
public int Decode(byte[] pBuffer, int bufferOffset, int size, bool bDecodeName) { int originalSize = size; bool error = false; // if there is an error while decoding - try to at least find the end mark 0x000009 while (size >= 3) { if (RTMPHelper.ReadInt24(pBuffer, bufferOffset) == 0x00000009) { size -= 3; error = false; break; } if (error) { size--; bufferOffset++; continue; } AMFObjectProperty prop = new AMFObjectProperty(); int result = prop.Decode(pBuffer, bufferOffset, size, bDecodeName); if (result == -1) { error = true; } else { size -= result; bufferOffset += result; properties.Add(prop); } } if (error) { return(-1); } return(originalSize - size); }
public int Decode(byte[] pBuffer, int bufferOffset, int size, bool bDecodeName) { int originalSize = size; bool error = false; // if there is an error while decoding - try to at least find the end mark 0x000009 while (size >= 3) { if (RTMPHelper.ReadInt24(pBuffer, bufferOffset) == 0x00000009) { size -= 3; error = false; break; } if (error) { size--; bufferOffset++; continue; } AMFObjectProperty prop = new AMFObjectProperty(); int result = prop.Decode(pBuffer, bufferOffset, size, bDecodeName); if (result == -1) error = true; else { size -= result; bufferOffset += result; properties.Add(prop); } } if (error) return -1; return originalSize - size; }
/// <summary> /// Stream_id checks "netStreams" /// Is orginal call pattern: private bool MQInternal_SendPlay(NetStream netStream, string mediafile, int start, int lenToPlay, bool resetPlayList, AMFObjectProperty properties) /// </summary> private bool MQInternal_SendPlay(NetStream netStream, string mediaFile, int start, int lenToPlay, bool resetPlayList, AMFObjectProperty properties) { RTMPPacket packet = new RTMPPacket(); packet.Channel = netStream.CommandChannel; // 0x08 ??? packet.HeaderType = HeaderType.Large; packet.PacketType = PacketType.Invoke; packet.InfoField2 = netStream.Stream_ID; List<byte> enc = new List<byte>(); RTMPHelper.EncodeString(enc, "play"); RTMPHelper.EncodeNumber(enc, 0); // 0 according to spec adobe enc.Add(0x05); // NULL RTMPHelper.EncodeString(enc, mediaFile); /* Optional parameters start and len. * * start: -2, -1, 0, positive number * -2: looks for a live stream, then a recorded stream, if not found any open a live stream * -1: plays a live stream * >=0: plays a recorded streams from 'start' milliseconds */ // RTMPHelper.EncodeNumber(enc, -1000.0d); (liveStream) if (start > 0) { RTMPHelper.EncodeNumber(enc, start); } else { RTMPHelper.EncodeNumber(enc, 0.0d); } // len: -1, 0, positive number // -1: plays live or recorded stream to the end (default) // 0: plays a frame 'start' ms away from the beginning // >0: plays a live or recoded stream for 'len' milliseconds RTMPHelper.EncodeNumber(enc, lenToPlay); // Reset. Optional wether to flush previous playlist if (properties == null) { RTMPHelper.EncodeBoolean(enc, resetPlayList); } else { properties.Encode(enc); } packet.Body = enc.ToArray(); packet.BodySize = (uint)enc.Count; LibRTMPLogger.Log(LibRTMPLogLevel.Trace, string.Format("[CDR.LibRTMP.NetConnection] Sending play: '{0}'", mediaFile)); return MQInternal_SendPacket(packet); }
public virtual void Play(string mediaFile, int start, int lenToPlay, bool resetPlayList, AMFObjectProperty properties) { if (!CheckConnection()) { return; } MQ_RTMPMessage message = new MQ_RTMPMessage(); message.MethodCall = MethodCall.Play; message.Params = new object[] { this, mediaFile, start, lenToPlay, resetPlayList, properties }; netConnection.PostMessage(message); }
public int DecodeArray(byte[] buffer, int offset, int size, int arrayLength, bool decodeName) { bool error = false; int originalSize = size; while (arrayLength > 0) { arrayLength--; AMFObjectProperty prop = new AMFObjectProperty(); int nRes = prop.Decode(buffer, offset, size, decodeName); if (nRes == -1) { error = true; } else { size -= nRes; offset += nRes; properties.Add(prop); } } if (error) { return -1; } return originalSize - size; }
public void AddProperty(AMFObjectProperty prop) { properties.Add(prop); }