Example #1
0
        public byte[] Encode()
        {
            using (var ms = new MemoryStream())
            {
                var aw = new AmfWriter(ms);

                aw.Write(CommandName);

                int transid = 0;
                switch (transid)
                {
                case -2:
                    transid = CurrentTransactionID++;
                    break;

                case -1:
                    transid = 0;
                    break;

                default:
                    transid = TransactionID;
                    break;
                }
                aw.Write(transid);

                aw.Write(CommandObject);

                if (Arguments != null)
                {
                    Arguments.ForEach(aw.Write);
                }

                return(ms.ToArray());
            }
        }
Example #2
0
        void WritePacket(RtmpPacket packet)
        {
            var flv_packet = RtmpPacketToFlvPacket(packet);
            var header     = flv_packet.Header;
            var streamId   = header.StreamId;
            var message    = flv_packet.Body;

            var buffer = GetMessageBytes(header, message);

            header.DataSize = buffer.Length;
            WriteTagHeader(header);
            writer.Write(buffer);
            WritePrevTagLength(buffer);
        }
        public byte[] Encode()
        {
            using (var ms = new MemoryStream())
            {
                var aw = new AmfWriter(ms);

                aw.Write(Name);
                Data.ForEach(aw.Write);

                return ms.ToArray();
            }
        }
Example #4
0
        public byte[] Encode()
        {
            using (var ms = new MemoryStream())
            {
                var aw = new AmfWriter(ms);

                aw.Write(Name);
                Data.ForEach(aw.Write);

                return(ms.ToArray());
            }
        }
Example #5
0
        void WritePacket(RtmpPacket packet)
        {
            //Debugger.Break();
            var header   = packet.Header;
            var streamId = header.StreamId;
            var message  = packet.Body;

            var buffer = GetMessageBytes(header, message);

            header.PacketLength = buffer.Length;

            RtmpHeader previousHeader;

            rtmpHeaders.TryGetValue(streamId, out previousHeader);

            rtmpHeaders[streamId] = header;
            rtmpPackets[streamId] = packet;

            WriteMessageHeader(header, previousHeader);

            var first = true;

            for (int i = 0; i < header.PacketLength; i += writeChunkSize)
            {
                if (!first)
                {
                    WriteBasicHeader(ChunkMessageHeaderType.Continuation, header.StreamId);
                }

                var bytesToWrite = i + writeChunkSize > header.PacketLength ? header.PacketLength - i : writeChunkSize;
                writer.Write(buffer, i, bytesToWrite);
                first = false;
            }

            var chunkSizeMsg = message as ChunkSize;

            if (chunkSizeMsg != null)
            {
                writeChunkSize = chunkSizeMsg.Size;
            }
        }
        public byte[] Encode()
        {
            using (var ms = new MemoryStream())
            {
                var aw = new AmfWriter(ms);

                aw.Write(CommandName);

                int transid = 0;
                switch (transid)
                {
                    case -2:
                        transid = CurrentTransactionID++;
                        break;
                    case -1:
                        transid = 0;
                        break;
                    default:
                        transid = TransactionID;
                        break;
                }
                aw.Write(transid);

                aw.Write(CommandObject);

                if (Arguments != null)
                {
                    Arguments.ForEach(aw.Write);
                }

                return ms.ToArray();
            }
        }