public void TestMethod1()
        {
            FfmpegHeaderPacket packet1 = new FfmpegHeaderPacket(1, "streamName", "streamUrl", 80, 1000, 600);

            byte[] buffer = FfmpegHeaderPacket.Encode(packet1);
            Assert.IsNull(HikHeaderPacket.Decode(buffer));
            FfmpegHeaderPacket packet2 = FfmpegHeaderPacket.Decode(buffer);

            Assert.AreNotSame(packet1, packet2);
            Assert.AreEqual(packet1.CodecID, packet2.CodecID);
            Assert.AreEqual(packet1.StreamId, packet2.StreamId);
            Assert.AreEqual(packet1.StreamName, packet2.StreamName);
            Assert.AreEqual(packet1.Width, packet2.Width);
            Assert.AreEqual(packet1.Height, packet2.Height);
            Assert.AreEqual(packet1.StreamUrl, packet2.StreamUrl);
        }
        public void TestHikHeaderPacket()
        {
            HikHeaderPacket packet1 = new HikHeaderPacket(1, "test", "streamUrl", 1, new byte[10]);

            byte[] buffer  = HikHeaderPacket.Encode(packet1);
            var    packet2 = HikHeaderPacket.Decode(buffer);

            Assert.IsNull(FfmpegHeaderPacket.Decode(buffer));

            Assert.AreNotSame(packet1, packet2);
            Assert.AreEqual(packet1.Header.Length, packet2.Header.Length);
            Assert.AreEqual(packet1.StreamId, packet2.StreamId);
            Assert.AreEqual(packet1.StreamName, packet2.StreamName);
            Assert.AreEqual(packet1.StreamUrl, packet2.StreamUrl);
            Assert.AreEqual(packet1.Type, packet2.Type);
        }
Esempio n. 3
0
        IStreamDecoder getDecoder(byte[] buffer)
        {
            FfmpegHeaderPacket fhp = FfmpegHeaderPacket.Decode(buffer);

            if (fhp != null)
            {
                Console.WriteLine($"{(Constants.AVCodecID)fhp.CodecID}, {fhp.Width}, {fhp.Height}");
                return(new FfmpegStreamDecoder((Constants.AVCodecID)fhp.CodecID, fhp.Width, fhp.Height));
            }
            HikHeaderPacket hhp = HikHeaderPacket.Decode(buffer);

            if (hhp != null)
            {
                return(new HikStreamDecoder(hhp.Header));
            }
            return(null);
        }