Esempio n. 1
0
        // opc = new OPCReadAuto(opcServerIp);


        public string getM3u8Url(string devId)
        {
            //办公室视频监控
            //return "rtsp://*****:*****@192.168.1.134:554/cam/realmonitor?channel=1&subtype=0";

            HttpUtillib.SetPlatformInfo("21762820", "yvtbOgoYSPOh2fA1Kvbv", "10.146.33.21", 80, false);
            string body = "{\"cameraIndexCode\": \"" + devId + "\",\"streamType\": \"1\",\"protocol\": \"rtsp\",\"expand\": \"streamform=rtp\",\"transmode\": \"1\"}";
            string uri  = "/artemis/api/video/v1/cameras/previewURLs";

            byte[] result = HttpUtillib.HttpPost(uri, body, 15);
            if (null == result)
            {
                Log.Info("/artemis/api/visitor/v1/record/previewURLs: POST fail");
                return("");
            }
            else
            {
                string tmp = System.Text.Encoding.UTF8.GetString(result);
                try
                {
                    UrlData obj     = JsonConvert.DeserializeObject <UrlData>(tmp);
                    string  m3u8Url = obj.data.url.ToString();
                    return(m3u8Url);
                }
                catch (Exception e)
                {
                    return("");
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 公用方法,根据URL跟参数,获取返回信息
        /// </summary>
        /// <param name="body"></param>
        /// <param name="uri"></param>
        /// <returns></returns>
        public static string getString(string body, string uri)
        {
            try
            {
                HttpUtillib.SetPlatformInfo("21762820", "yvtbOgoYSPOh2fA1Kvbv", "10.146.33.21", 80, false);
                byte[] result = HttpUtillib.HttpPost(uri, body, 15);
                if (null == result)
                {
                    Console.WriteLine("");
                    Console.WriteLine();
                    return(null);
                }
                else
                {
                    string tmp = System.Text.Encoding.UTF8.GetString(result);
                    Console.WriteLine(tmp);
                    //
                    JObject obj = null;
                    try
                    {
                        obj = (JObject)JsonConvert.DeserializeObject(tmp);

                        // 说明是字符串,并且请求失败了
                        Console.WriteLine(tmp);
                    }
                    catch (Exception e)
                    {
                        // 转换成json对象异常说明响应是字节流
                        File.WriteAllBytes("D://test.jpeg", result);
                        Console.WriteLine("写入图片成功:D://test.jpeg\n");
                    }
                    return(tmp);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                return(null);
            }
        }