예제 #1
0
        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);
        }
예제 #2
0
        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;
        }
예제 #4
0
        /// <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);
        }
예제 #5
0
        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);
        }
예제 #6
0
        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;
        }
예제 #7
0
        /// <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);
        }
예제 #8
0
        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);
            
        }
예제 #9
0
        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;
        }
예제 #10
0
 public void AddProperty(AMFObjectProperty prop)
 {
     properties.Add(prop);
 }
예제 #11
0
 public void AddProperty(AMFObjectProperty prop)
 {
     properties.Add(prop);
 }