コード例 #1
0
        private static void mk_media_play(IntPtr mk_media_info, IntPtr auth_invoker, IntPtr mk_sock_info)
        {
            if (OnMediaPlay == null)
            {
                PInvoke.ZLMediaKitMethod.mk_auth_invoker_do(auth_invoker, null);
                return;
            }
            var mediaInfo = new MediaInfo(mk_media_info);
            var list      = new List <Task <MediaSourceWapper> >();

            foreach (Func <MediaInfo, MediaSourceWapper> item in OnInternalMediaPlay.GetInvocationList())
            {
                list.Add(Task <MediaSourceWapper> .Run(() => item(mediaInfo)));
            }
            Task.WaitAll(list.ToArray());
            var  mediasourceWapper = list.FirstOrDefault(w => w.Result != null)?.Result;
            var  sockinfo          = new SockInfo(mk_sock_info);
            bool notMedia          = mediasourceWapper == null;

            mediasourceWapper = new MediaSourceWapper {
                MediaInfo = new MediaInfo(mk_media_info)
            };
            var result = OnMediaPlay.Invoke(mediasourceWapper, sockinfo);

            if (string.IsNullOrEmpty(result))
            {
                mediasourceWapper._watchClient.Add(new WatchClient(new SockInfo(mk_sock_info)));
            }
            PInvoke.ZLMediaKitMethod.mk_auth_invoker_do(auth_invoker, result);
        }
コード例 #2
0
        private static void mk_media_publish(IntPtr mk_media_info, IntPtr mk_publish_auth_invoker, IntPtr mk_sock_info)
        {
            var response = new dtos.PublishInvokerDto {
                Message = "不允许推流", EnableHls = false, EnableMp4 = false
            };

            if (OnPublish != null)
            {
                var mediaWapper = new MediaSourceWapper();
                mediaWapper.MediaInfo = new MediaInfo(mk_media_info);
                mediaWapper.SockInfo  = new SockInfo(mk_sock_info);
                var result = OnPublish.Invoke(mediaWapper) ?? response;
                PInvoke.ZLMediaKitMethod.mk_publish_auth_invoker_do(mk_publish_auth_invoker, result.Message, result.EnableHls ? 1 : 0, result.EnableMp4 ? 1 : 0);
                return;
            }
            PInvoke.ZLMediaKitMethod.mk_publish_auth_invoker_do(mk_publish_auth_invoker, response.Message, response.EnableHls ? 1 : 0, response.EnableMp4 ? 1 : 0);
        }