Esempio n. 1
0
        public static string StartRealPlayRtsp(string app, string stream, string url)
        {
            IntPtr playProxy = MediaServer.mk_proxy_player_create("__defaultVhost__", app, stream, 1, 0);

            MediaServer.mk_proxy_player_play(playProxy, url);
            string key = GetKey(app, stream);

            if (dic_playProxy_media.ContainsKey(key))
            {
                return(key + ":已经在拉流");
            }
            dic_playProxy_media.Add(key, new MediaCache()
            {
                ctx = playProxy, mediaSrcType = MediaSrcType.net_url
            });
            return(key + ":开始拉流");
        }
Esempio n. 2
0
        static void AddStreamProxyTest()
        {
            try
            {
                mediaServerConfig = new MediaServerConfig();
                string configPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config.ini");
                ushort ret        = MediaInit(configPath);
                Console.WriteLine("初始化完成");
                RegisterEvent();
                Console.WriteLine("事件注册完成");
                int i = 0;
                foreach (var item in System.Configuration.ConfigurationManager.AppSettings.AllKeys)
                {
                    if (item.Contains("rtspurl"))
                    {
                        i++;
                        string stream = "live" + i.ToString();
                        string url    = System.Configuration.ConfigurationManager.AppSettings[item];
                        Console.WriteLine("开始拉流:" + url);
                        IntPtr playProxy = MediaServer.mk_proxy_player_create("__defaultVhost__", "fh", stream, 1, 0);
                        //rtsp://admin:123456a%[email protected]:554/h264/ch33/main/av_stream
                        MediaServer.mk_proxy_player_play(playProxy, url);
                        Task.Run(() => media_source_no_reader_check());
                    }
                }


                //IntPtr playProxy = MediaServer.mk_proxy_player_create("__defaultVhost__", "fh", "live1", 1, 0);
                ////rtsp://admin:123456a%[email protected]:554/h264/ch33/main/av_stream
                //MediaServer.mk_proxy_player_play(playProxy, "rtsp://*****:*****@10.128.23.51:554/h264/ch33/main/av_stream");
                //IntPtr playProxy1 = MediaServer.mk_proxy_player_create("__defaultVhost__", "fh", "live2", 1, 0);
                //MediaServer.mk_proxy_player_play(playProxy1, "rtsp://*****:*****@10.128.23.67:554/h264/ch33/main/av_stream");
                Console.Read();
                MediaServer.mk_stop_all_server();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
            }
            finally
            {
                Console.Read();
            }
        }