• 大小: 101KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-06-03
  • 语言: C#
  • 标签: onvif  

资源简介

C#使用onvif协议获取网络摄像头rtsp视频流地址和图片地址,将rtsp视频流地址保存到本地mp4可以参考我的另一个资源

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;

namespace DoneWin.BPM
{
    class DigestPassword
    {
        private static String validChars = “abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ“;
        private static Random randomNum = new Random();

        public static String getNonce(int length)
        {
            var nonceString = new StringBuilder();

            for (int i = 0; i < length; i++)
            {
                nonceString.Append(validChars[randomNum.Next(0 validChars.Length - 1)]);
            }

            return nonceString.ToString();
        }

        public static DateTime getCurrentTime(DateTime startDate DateTime baseDateTime)
        {
            /* get synced-time */
            try
            {
                DateTime currentDate = DateTime.Now;
                long elapsedTicks = currentDate.Ticks - startDate.Ticks;

                TimeSpan elapsedSpan = new TimeSpan(elapsedTicks);

                baseDateTime = baseDateTime.AddTicks(elapsedTicks);
            }
            catch (ArgumentNullException ane)
            {
                Console.WriteLine(“ArgumentNullException: {0}“ ane.Message);
            }
            return baseDateTime;
        }
        public static String getCreatedTimeString(DateTime baseDateTime)
        {
            var timeString = new StringBuilder();

            DateTime baseTime = baseDateTime;

            timeString.Append(baseTime.Year.ToString() + “-“);
            timeString.Append(baseTime.Month.ToString(“D2“) + “-“);
            timeString.Append(baseTime.Day.ToString(“D2“) + “T“);
            timeString.Append(baseTime.Hour.ToString(“D2“) + “:“);
            timeString.Append(baseTime.Minute.ToString(“D2“) + “:“);
            timeString.Append(baseTime.Second.ToString(“D2“) + “.“);
            timeString.Append(baseTime.Millisecond.ToString(“D3“) + “Z“);

            return timeString.ToString();
        }

        public static String getPasswordDigest(String noncebase64 String createTime String password)
        {
            byte[] nonceBinary = EncodingHelper.base64Decode(noncebase64);
            byte[] utctimeBinary = EncodingHelper.String2Byte(createTime);
            byte[] pwdBinary = EncodingHelper.String2Byte(password);

            byte[] combined = new byte[nonceBinary.Length + utctimeBinary.Length + pwdBinary.Length];

            System.Buffer.BlockCopy(nonceBinary 0 combined 0 nonceBinary.Length);
            System.Buffer.BlockCopy(utctimeBinary 0 combined nonceBinary.Length utctimeBinary.Length);
            System.Buffer.BlockCopy(pwdBinary 0 combined nonceBinary.Length + utctimeBinary.Length pwdBinary.Length);

            SHA1Managed sha1 = new SHA1Managed();

            byte[] passwordHash = sha1.ComputeHash(combined);

            String hashValue = System.Convert.Tobase64String(passwordHash);

            return hashValue

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-01-18 09:03  onvifTest\
     目录           0  2018-01-18 09:03  onvifTest\.vs\
     目录           0  2018-01-18 09:03  onvifTest\.vs\onvifTest\
     目录           0  2018-01-18 09:03  onvifTest\.vs\onvifTest\v14\
     文件       57344  2018-01-19 15:29  onvifTest\.vs\onvifTest\v14\.suo
     目录           0  2018-01-19 14:56  onvifTest\onvifTest\
     文件         189  2018-01-18 09:03  onvifTest\onvifTest\App.config
     文件        3025  2017-09-26 09:43  onvifTest\onvifTest\DigestPassword.cs
     文件        1070  2017-09-26 09:25  onvifTest\onvifTest\EncodingHelper.cs
     文件        2029  2018-01-18 09:03  onvifTest\onvifTest\Form1.Designer.cs
     文件         983  2018-01-19 14:56  onvifTest\onvifTest\Form1.cs
     文件        5817  2018-01-18 09:03  onvifTest\onvifTest\Form1.resx
     文件        2054  2017-11-14 15:33  onvifTest\onvifTest\HttpControl.cs
     文件       33025  2018-01-19 14:56  onvifTest\onvifTest\OnvifHelper.cs
     文件         521  2018-01-18 09:03  onvifTest\onvifTest\Program.cs
     目录           0  2018-01-18 09:03  onvifTest\onvifTest\Properties\
     文件        1344  2018-01-18 09:03  onvifTest\onvifTest\Properties\AssemblyInfo.cs
     文件        2831  2018-01-18 09:03  onvifTest\onvifTest\Properties\Resources.Designer.cs
     文件        5612  2018-01-18 09:03  onvifTest\onvifTest\Properties\Resources.resx
     文件        1096  2018-01-18 09:03  onvifTest\onvifTest\Properties\Settings.Designer.cs
     文件         249  2018-01-18 09:03  onvifTest\onvifTest\Properties\Settings.settings
     文件        1131  2018-01-18 14:54  onvifTest\onvifTest\ToolboxGroup.Designer.cs
     文件       23743  2018-01-18 14:55  onvifTest\onvifTest\ToolboxGroup.cs
     文件        5401  2017-09-26 10:12  onvifTest\onvifTest\xmlControl.cs
     目录           0  2018-01-18 14:54  onvifTest\onvifTest\bin\
     目录           0  2018-01-18 09:10  onvifTest\onvifTest\bin\Debug\
     文件       47104  2018-01-19 14:57  onvifTest\onvifTest\bin\Debug\onvifTest.exe
     文件         189  2018-01-18 09:03  onvifTest\onvifTest\bin\Debug\onvifTest.exe.config
     文件       58880  2018-01-19 14:57  onvifTest\onvifTest\bin\Debug\onvifTest.pdb
     文件       22696  2018-01-19 14:57  onvifTest\onvifTest\bin\Debug\onvifTest.vshost.exe
     文件         189  2018-01-18 09:03  onvifTest\onvifTest\bin\Debug\onvifTest.vshost.exe.config
............此处省略20个文件信息

评论

共有 条评论