Esempio n. 1
0
        public bool TryGet(AccountModel accountModel, VideoBoxType videoBoxType, MediaType mediaType, out VideoBox videoBox)
        {
            videoBox = null;
            try
            {
                Monitor.Enter(_items);
                foreach (var item in _items.Values.Where(m => m.VideoBoxType == videoBoxType))
                {
                    if (videoBox == null && item.AccountResource == null)
                    {
                        videoBox = item;
                    }

                    if (item.AccountResource?.AccountModel.AccountId == accountModel.AccountId)
                    {
                        videoBox = item;
                    }
                }
                if (videoBox != null)
                {
                    videoBox.AccountResource = new AccountResource(accountModel, 0, mediaType);
                    videoBox.Sequence        = _items.Values.DefaultIfEmpty().Max(v => v.Sequence) + 1;
                }
            }
            finally
            {
                Monitor.Exit(_items);
            }
            return(videoBox != null);
        }
Esempio n. 2
0
        public static bool TryConvertVideoBoxType(this MediaType mediaType, out VideoBoxType videoBoxType)
        {
            var result = false;

            videoBoxType = VideoBoxType.None;
            switch (mediaType)
            {
            case MediaType.Camera:
                videoBoxType = VideoBoxType.Camera;
                result       = true;
                break;

            case MediaType.Microphone:
                break;

            case MediaType.VideoDoc:
                videoBoxType = VideoBoxType.DataCard;
                result       = true;
                break;

            case MediaType.AudioDoc:
                break;

            case MediaType.VideoCaptureCard:
                videoBoxType = VideoBoxType.WinCapture;
                result       = true;
                break;

            case MediaType.AudioCaptureCard:
                break;

            case MediaType.StreamMedia:
                break;

            case MediaType.File:
                break;

            case MediaType.WhiteBoard:
                break;

            case MediaType.RemoteControl:
                break;

            case MediaType.MediaTypeMax:
                break;
            }
            return(result);
        }
Esempio n. 3
0
 public void Release(int accountId, VideoBoxType videoBoxType)
 {
     try
     {
         Monitor.Enter(_items);
         foreach (var item in _items.Values.Where(
                      m => m.AccountResource?.AccountModel.AccountId == accountId &&
                      m.VideoBoxType == videoBoxType))
         {
             _eventAggregator.GetEvent <VideoBoxRemovedEvent>().Publish(item);
             item.AccountResource = null;
         }
     }
     finally
     {
         Monitor.Exit(_items);
     }
 }
Esempio n. 4
0
 public static void SetVideoBoxType(DependencyObject d, VideoBoxType boxType)
 {
     d.SetValue(VideoBoxTypeProperty, boxType);
 }