Beispiel #1
0
        static void Test1()
        {
            string configPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config.ini");

            MediaServer.Config config = new MediaServer.Config();
            config.ini_is_path = 1;
            config.ini         = configPath;
            MediaServer.mk_env_init(ref config);
            uint ret;

            ret = MediaServer.mk_http_server_start(8500, 0);
            ret = MediaServer.mk_rtsp_server_start(554, 0);
            ret = MediaServer.mk_rtmp_server_start(1935, 0);
            DoMedia.StartPlaySDK("fh", "sdklive1", "", "10.128.24.60", "admin", "0123456a?", "8000");
            Console.Read();
        }
Beispiel #2
0
 public static void del_on_mk_media_source_find_cb(IntPtr userdata, ref IntPtr mk_media_source)
 {
     try
     {
         //IntPtr ptr = mk_media_source;
         string schema = Marshal.PtrToStringAnsi(MediaServer.mk_media_source_get_schema(ref mk_media_source));
         if (schema != "rtsp")
         {
             return;
         }
         string vhost     = Marshal.PtrToStringAnsi(MediaServer.mk_media_source_get_vhost(ref mk_media_source));
         string app       = Marshal.PtrToStringAnsi(MediaServer.mk_media_source_get_app(ref mk_media_source));
         string stream    = Marshal.PtrToStringAnsi(MediaServer.mk_media_source_get_stream(ref mk_media_source));
         int    readCount = MediaServer.mk_media_source_get_total_reader_count(ref mk_media_source);
         string key       = GetKey(app, stream);
         if (!dic_readerCount.ContainsKey(key))
         {
             dic_readerCount.Add(key, readCount);
         }
         else
         {
             if (dic_readerCount[key] == 0 && readCount == 0)
             {
                 string ret = DoMedia.Stop(app, stream);
             }
             else
             {
                 dic_readerCount[key] = readCount;
             }
         }
         //Thread thread = new Thread(new ParameterizedThreadStart(GetTotalReaderCount));
         //thread.Start(mk_media_source);
         //Task.Run(() => GetTotalReaderCount(ref ptr));
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         Console.WriteLine(ex.StackTrace);
     }
 }
Beispiel #3
0
        public HttpServer()
        {
            Get("/startplay", param =>
            {
                var code   = Request.Query["code"];
                string ret = DoMedia.StartRealPlay(code);
                return(ret);
            }
                );
            Get("/stopplay", param =>
            {
                var code   = Request.Query["code"];
                string ret = DoMedia.StopRealPlay(code);
                return(ret);
            }
                );
            //app:fh,stream:live1
            //mk_proxy_player_create("__defaultVhost__", "fh", "live1", 1, 0);
            //Get("/startplayrtsp", param =>
            //{
            //    var app = Request.Query["app"];
            //    var stream = Request.Query["stream"];
            //    var url = Request.Query["url"];
            //    //url = DoMedia.Escape(url);
            //    return DoMedia.StartRealPlayRtsp(app, stream, url);
            //}
            //);


            Post("/startplayrtsp", param =>
            {
                //var app = Request.Query["app"];
                //var stream = Request.Query["stream"];
                //var url = Request.Query["url"];
                PlayRtspModel playRtspModel = new PlayRtspModel();
                try
                {
                    byte[] data     = new byte[Request.Body.Length];
                    int ret         = Request.Body.Read(data, 0, data.Length);
                    string postData = Encoding.Default.GetString(data);
                    playRtspModel   = JsonConvert.DeserializeObject <PlayRtspModel>(postData);
                }
                catch (Exception ex)
                {
                    return("ʧ°Ü:" + ex.Message);
                }
                return(DoMedia.StartRealPlayRtsp(playRtspModel.App, playRtspModel.Stream, playRtspModel.Url));
            }
                 );

            Get("/stopplayrtsp", param =>
            {
                var app    = Request.Query["app"];
                var stream = Request.Query["stream"];
                return(DoMedia.StopRealPlayRtsp(app, stream));
            }
                );
            Get("/startplaysdk", param =>
            {
                var app             = Request.Query["app"];
                var stream          = Request.Query["stream"];
                var device_ip       = Request.Query["device_ip"];
                var device_username = Request.Query["device_username"];
                var device_password = Request.Query["device_password"];
                var device_port     = Request.Query["device_port"];
                return(DoMedia.StartPlaySDK(app, stream, "", device_ip, device_username, device_password, device_port));
            }
                );
            Get("/stopplaysdk", param =>
            {
                var app    = Request.Query["app"];
                var stream = Request.Query["stream"];
                return(DoMedia.StopPlaySDK(app, stream));
            }
                );
        }