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); }
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); }
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); } }
public static void SetVideoBoxType(DependencyObject d, VideoBoxType boxType) { d.SetValue(VideoBoxTypeProperty, boxType); }