public override void Clear(VideoLayer aVideoLayer)
 {
     var channel = _casparChannel;
     if (_checkConnected() && channel != null)
     {
         channel.Clear((int)aVideoLayer);
         Debug.WriteLine(aVideoLayer, "CasparClear");
     }
 }
예제 #2
0
        internal Event(
            Engine engine,
            UInt64 idRundownEvent,
            UInt64 idEventBinding,
            VideoLayer videoLayer,
            TEventType eventType,
            TStartType startType,
            TPlayState playState,
            DateTime scheduledTime,
            TimeSpan duration,
            TimeSpan scheduledDelay,
            TimeSpan scheduledTC,
            Guid mediaGuid,
            string eventName,
            DateTime startTime,
            TimeSpan startTC,
            TimeSpan?requestedStartTime,
            TimeSpan transitionTime,
            TimeSpan transitionPauseTime,
            TTransitionType transitionType,
            TEasing transitionEasing,
            decimal?audioVolume,
            UInt64 idProgramme,
            string idAux,
            bool isEnabled,
            bool isHold,
            bool isLoop,
            AutoStartFlags autoStartFlags,
            bool isCGEnabled,
            byte crawl,
            byte logo,
            byte parental)
        {
            _engine              = engine;
            _id                  = idRundownEvent;
            _idEventBinding      = idEventBinding;
            _layer               = videoLayer;
            _eventType           = eventType;
            _startType           = startType;
            _playState           = playState == TPlayState.Paused ? TPlayState.Scheduled: playState == TPlayState.Fading ? TPlayState.Played : playState;
            _scheduledTime       = scheduledTime;
            _duration            = duration;
            _scheduledDelay      = scheduledDelay;
            _scheduledTc         = scheduledTC;
            _eventName           = eventName;
            _startTime           = startTime;
            _startTc             = startTC;
            _requestedStartTime  = requestedStartTime;
            _transitionTime      = transitionTime;
            _transitionPauseTime = transitionPauseTime;
            _transitionType      = transitionType;
            _transitionEasing    = transitionEasing;
            _audioVolume         = audioVolume;
            _idProgramme         = idProgramme;
            _idAux               = idAux;
            _isEnabled           = isEnabled;
            _isHold              = isHold;
            _isLoop              = isLoop;
            _isCGEnabled         = isCGEnabled;
            _crawl               = crawl;
            _logo                = logo;
            _parental            = parental;
            _autoStartFlags      = autoStartFlags;
            _setMedia(null, mediaGuid);
            _subEvents = new Lazy <SynchronizedCollection <Event> >(() =>
            {
                var result = new SynchronizedCollection <Event>();
                if (_id != 0)
                {
                    var seList = Engine.DbReadSubEvents(this);
                    foreach (Event e in seList)
                    {
                        e.Parent = this;
                        result.Add(e);
                    }
                }
                return(result);
            });

            _next = new Lazy <Event>(() =>
            {
                var next = (Event)Engine.DbReadNext(this);
                if (next != null)
                {
                    next.Prior = this;
                }
                return(next);
            });
            _prior = new Lazy <Event>(() =>
            {
                Event prior = null;
                if (startType == TStartType.After && _idEventBinding > 0)
                {
                    prior = (Event)Engine.DbReadEvent(_idEventBinding);
                }
                return(prior);
            });

            _parent = new Lazy <Event>(() =>
            {
                if ((startType == TStartType.WithParent || startType == TStartType.WithParentFromEnd) && _idEventBinding > 0)
                {
                    return((Event)Engine.DbReadEvent(_idEventBinding));
                }
                return(null);
            });
        }
 public abstract void SetVolume(VideoLayer videolayer, decimal volume);
 public abstract void ReStart(VideoLayer aVideoLayer);
 public abstract bool Pause(VideoLayer videolayer);
 public abstract bool Load(ServerMedia media, VideoLayer videolayer, long seek, long duration);
 public override bool Stop(VideoLayer videolayer)
 {
     var channel = _casparChannel;
     if (_checkConnected() && channel != null)
     {
         {
             channel.Stop((int)videolayer);
             Debug.WriteLine("CasparStop Layer {0}", videolayer);
             return true;
         }
     }
     return false;
 }
 public bool Load(System.Drawing.Color color, VideoLayer layer)
 {
     throw new NotImplementedException();
 }
 public bool Load(IMedia media, VideoLayer videolayer, long seek, long duration)
 {
     throw new NotImplementedException();
 }
 public void SetVolume(VideoLayer videolayer, double volume)
 {
     throw new NotImplementedException();
 }
 public void Clear(VideoLayer aVideoLayer)
 {
     Invoke(parameters: new[] { aVideoLayer });
 }
 public void SetAspect(VideoLayer layer, bool narrow)
 {
     throw new NotImplementedException();
 }
 public MediaSearchViewmodel(IPreview preview, IEngine engine, TMediaType mediaType, VideoLayer layer,
                             bool closeAfterAdd, VideoFormatDescription videoFormatDescription)
 {
     Engine = engine;
     Layer  = layer;
     if (mediaType == TMediaType.Movie)
     {
         _videoFormatDescription = engine.FormatDescription;
         if (preview != null)
         {
             _preview = new PreviewViewmodel(preview, false, false)
             {
                 IsSegmentsVisible = true
             }
         }
         ;
     }
     else
     {
         _videoFormatDescription = videoFormatDescription;
     }
     _mediaType = mediaType;
     if (_preview != null)
     {
         _preview.PropertyChanged += _onPreviewViewModelPropertyChanged;
     }
     CommandAdd        = new UiCommand(_add, _allowAdd);
     _mediaCategory    = MediaCategories.FirstOrDefault();
     NewEventStartType = TStartType.After;
     SetupSearchDirectory(closeAfterAdd, mediaType);
 }
        public MediaSearchViewmodel(IPreview preview, IMediaManager manager, TMediaType mediaType, VideoLayer layer, bool closeAfterAdd, VideoFormatDescription videoFormatDescription)
        {
            _manager = manager;
            _engine  = manager.Engine;
            Layer    = layer;
            if (mediaType == TMediaType.Movie)
            {
                _videoFormatDescription = manager.FormatDescription;
                _frameRate = _videoFormatDescription.FrameRate;
                if (preview != null)
                {
                    _previewViewmodel = new PreviewViewmodel(preview)
                    {
                        IsSegmentsVisible = true
                    }
                }
                ;
                WindowWidth = _previewViewmodel != null ? 950 : 650;
            }
            else
            {
                _videoFormatDescription = videoFormatDescription;
                _frameRate  = videoFormatDescription?.FrameRate;
                WindowWidth = 750;
            }
            _mediaType = mediaType;
            if (_previewViewmodel != null)
            {
                _previewViewmodel.PropertyChanged += _onPreviewViewModelPropertyChanged;
            }
            IMediaDirectory pri = mediaType == TMediaType.Animation ? (IMediaDirectory)_manager.AnimationDirectoryPRI : _manager.MediaDirectoryPRI;
            IMediaDirectory sec = mediaType == TMediaType.Animation ? (IMediaDirectory)_manager.AnimationDirectorySEC : _manager.MediaDirectorySEC;

            _searchDirectory                = pri != null && pri.DirectoryExists() ? pri : sec != null && sec.DirectoryExists() ? sec : null;
            _searchDirectory.MediaAdded    += _searchDirectory_MediaAdded;
            _searchDirectory.MediaRemoved  += _searchDirectory_MediaRemoved;
            _searchDirectory.MediaVerified += _searchDirectory_MediaVerified;

            _closeAfterAdd    = closeAfterAdd;
            _mediaCategory    = MediaCategories.FirstOrDefault();
            NewEventStartType = TStartType.After;
            if (!closeAfterAdd)
            {
                OkButtonText = resources._button_Add;
            }
            _createCommands();
            _items = new ObservableCollection <MediaViewViewmodel>(_searchDirectory.GetFiles()
                                                                   .Where(m => _canAddMediaToCollection(m, mediaType))
                                                                   .Select(m => new MediaViewViewmodel(m)));
            _itemsView = CollectionViewSource.GetDefaultView(_items);
            _itemsView.SortDescriptions.Add(new SortDescription(nameof(MediaViewViewmodel.MediaName), ListSortDirection.Ascending));
            _itemsView.Filter += _itemsFilter;
            _view              = new MediaSearchView()
            {
                DataContext = this
            };
            _view.Closed += _windowClosed;
            _view.Show();
        }
 public override bool Seek(VideoLayer videolayer, long position)
 {
     var channel = _casparChannel;
     if (_checkConnected() && channel != null)
     {
         channel.CustomCommand(string.Format("CALL {0}-{1} SEEK {2}", ChannelNumber, (int)videolayer, position));
         Debug.WriteLine("CasparSeek Channel {0} Layer {1} Position {2}", ChannelNumber, (int)videolayer, position);
         return true;
     }
     return false;
 }
 public bool Play(VideoLayer videolayer)
 {
     throw new NotImplementedException();
 }
 public override void SetVolume(VideoLayer videolayer, decimal volume)
 {
     var channel = _casparChannel;
     if (_checkConnected() && channel != null)
     {
         channel.CustomCommand(string.Format(CultureInfo.InvariantCulture, "MIXER {0}-{1} VOLUME {2:F3}", ChannelNumber, (int)videolayer, volume));
         if (OnVolumeChanged != null)
             OnVolumeChanged(this, videolayer, volume);
     }
 }
 public bool Seek(VideoLayer videolayer, long position)
 {
     throw new NotImplementedException();
 }
 private CasparItem _getItem(ServerMedia media, VideoLayer videolayer, long seek)
 {
     if (media != null)
     {
         CasparItem item = new CasparItem(string.Empty);
         if (media.MediaType == TMediaType.Movie || media.MediaType == TMediaType.Movie)
             item.Clipname = "\"" + Path.GetFileNameWithoutExtension(media.FileName) + "\"" +
                 ((media.MediaType == TMediaType.Movie && media.HasExtraLines) ? " FILTER CROP=720:576:0:32" : string.Empty) +
                 ((media.MediaType == TMediaType.Movie) ? " CHANNEL_LAYOUT STEREO" : string.Empty);
         item.VideoLayer = (int)videolayer;
         item.Seek = (int)seek;
         return item;
     }
     else
         return null;
 }
        public MediaSearchViewmodel(IPreview preview, IEngine engine, TMediaType mediaType, VideoLayer layer,
                                    bool closeAfterAdd, VideoFormatDescription videoFormatDescription)
        {
            _engine = engine;
            Layer   = layer;
            if (mediaType == TMediaType.Movie)
            {
                _videoFormatDescription = engine.FormatDescription;
                if (preview != null)
                {
                    PreviewViewmodel = new PreviewViewmodel(engine, preview)
                    {
                        IsSegmentsVisible = true
                    }
                }
                ;
            }
            else
            {
                _videoFormatDescription = videoFormatDescription;
            }
            _mediaType = mediaType;
            if (PreviewViewmodel != null)
            {
                PreviewViewmodel.PropertyChanged += _onPreviewViewModelPropertyChanged;
            }
            IMediaDirectory pri = mediaType == TMediaType.Animation
                ? (IMediaDirectory)engine.MediaManager.AnimationDirectoryPRI
                : engine.MediaManager.MediaDirectoryPRI;
            IMediaDirectory sec = mediaType == TMediaType.Animation
                ? (IMediaDirectory)engine.MediaManager.AnimationDirectorySEC
                : engine.MediaManager.MediaDirectorySEC;

            _searchDirectory = pri != null && pri.DirectoryExists()
                ? pri
                : sec != null && sec.DirectoryExists()
                    ? sec
                    : null;
            if (_searchDirectory != null)
            {
                _searchDirectory.MediaAdded    += _searchDirectory_MediaAdded;
                _searchDirectory.MediaRemoved  += _searchDirectory_MediaRemoved;
                _searchDirectory.MediaVerified += _searchDirectory_MediaVerified;
            }
            _mediaCategory    = MediaCategories.FirstOrDefault();
            NewEventStartType = TStartType.After;
            if (!closeAfterAdd)
            {
                OkButtonText = resources._button_Add;
            }
            _createCommands();
            Items = new ObservableCollection <MediaViewViewmodel>(_searchDirectory.GetFiles()
                                                                  .Where(m => _canAddMediaToCollection(m, mediaType))
                                                                  .Select(m => new MediaViewViewmodel(m)));
            _itemsView = CollectionViewSource.GetDefaultView(Items);
            _itemsView.SortDescriptions.Add(mediaType == TMediaType.Movie
                ? new SortDescription(nameof(MediaViewViewmodel.LastUpdated), ListSortDirection.Descending)
                : new SortDescription(nameof(MediaViewViewmodel.MediaName), ListSortDirection.Ascending));
            _itemsView.Filter += _itemsFilter;
        }
 public abstract void Clear(VideoLayer aVideoLayer);
 public override bool Load(ServerMedia media, VideoLayer videolayer, long seek, long duration)
 {
     var channel = _casparChannel;
     if (_checkConnected()
         && media != null
         && channel != null)
     {
         CasparItem item = _getItem(media, videolayer, seek);
         if (item != null)
         {
             item.Length = (int)duration;
             channel.Load(item);
             Debug.WriteLine("CasparLoad media {0} Layer {1} Seek {2}", media, videolayer, seek);
             return true;
         }
     }
     return false;
 }
 public abstract bool Load(System.Drawing.Color color, VideoLayer layer);
 public override bool Load(System.Drawing.Color color, VideoLayer videolayer)
 {
     var channel = _casparChannel;
     if (_checkConnected() && channel != null)
     {
         var scolor = '#' + color.ToArgb().ToString("X8");
         CasparItem item = new CasparItem((int)videolayer, scolor);
         channel.Load(item);
         Debug.WriteLine("CasparLoad color {0} Layer {1}", scolor, videolayer);
         return true;
     }
     return false;
 }
 public abstract bool Play(VideoLayer videolayer);
 public override bool Pause(VideoLayer videolayer)
 {
     var channel = _casparChannel;
     if (_checkConnected() && channel != null)
     {
         {
             channel.CustomCommand(string.Format("PAUSE {0}-{1}", ChannelNumber, (int)videolayer));
             Debug.WriteLine("CasparPause Layer {0}", videolayer);
             return true;
         }
     }
     return false;
 }
 public abstract bool Seek(VideoLayer videolayer, long position);
 public override void ReStart(VideoLayer aVideoLayer)
 {
     Event ev = Engine._visibleEvents[aVideoLayer];
     var channel = _casparChannel;
     if (_checkConnected()
         && ev != null
         && channel != null)
     {
         CasparItem item = _getItem(ev);
         if (item != null)
         {
             if (ev.EventType == TEventType.Movie && ev.Media != null)
                 item.Seek = (int)ev.Position + (int)((ev.ScheduledTC.Ticks - ev.Media.TCPlay.Ticks) / Engine.FrameTicks);
             item.Transition.Duration = 3;
             item.Transition.Type = TransitionType.MIX;
             channel.LoadBG(item);
             channel.Play(item.VideoLayer);
             Debug.WriteLine("CasparChanner.ReStart: restarted {0} from frame {1}", item.Clipname, item.Seek);
         }
         Event le;
         Engine._loadedNextEvents.TryRemove(aVideoLayer, out le);
         if (le != null)
         {
             LoadNext(le); // workaround to reload event removed with CasarChanenel.Stop()
             Debug.WriteLine("CasparChanner.ReStart: reloaded {0}", le.ToString());
         }
     }
 }
 public abstract bool Stop(VideoLayer videolayer);
예제 #30
0
        internal Event(
            Engine engine,
            UInt64 idRundownEvent,
            UInt64 idEventBinding,
            VideoLayer videoLayer,
            TEventType eventType,
            TStartType startType,
            TPlayState playState,
            DateTime scheduledTime,
            TimeSpan duration,
            TimeSpan scheduledDelay,
            TimeSpan scheduledTC,
            Guid mediaGuid,
            string eventName,
            DateTime startTime,
            TimeSpan startTC,
            TimeSpan?requestedStartTime,
            TimeSpan transitionTime,
            TimeSpan transitionPauseTime,
            TTransitionType transitionType,
            TEasing transitionEasing,
            double?audioVolume,
            UInt64 idProgramme,
            string idAux,
            bool isEnabled,
            bool isHold,
            bool isLoop,
            AutoStartFlags autoStartFlags,
            bool isCGEnabled,
            byte crawl,
            byte logo,
            byte parental,
            short routerPort,
            RecordingInfo recordingInfo)
        {
            _engine              = engine;
            _rundownSync         = engine.RundownSync;
            Id                   = idRundownEvent;
            IdEventBinding       = idEventBinding;
            _layer               = videoLayer;
            _eventType           = eventType;
            _startType           = startType;
            _playState           = playState == TPlayState.Paused ? TPlayState.Scheduled: playState == TPlayState.Fading ? TPlayState.Played : playState;
            _scheduledTime       = scheduledTime;
            _duration            = duration;
            _scheduledDelay      = scheduledDelay;
            _scheduledTc         = scheduledTC;
            _eventName           = eventName;
            _startTime           = startTime;
            _startTc             = startTC;
            _requestedStartTime  = requestedStartTime;
            _transitionTime      = transitionTime;
            _transitionPauseTime = transitionPauseTime;
            _transitionType      = transitionType;
            _transitionEasing    = transitionEasing;
            _audioVolume         = audioVolume;
            _idProgramme         = idProgramme;
            _idAux               = idAux;
            _isEnabled           = isEnabled;
            _isHold              = isHold;
            _isLoop              = isLoop;
            _isCGEnabled         = isCGEnabled;
            _crawl               = crawl;
            _logo                = logo;
            _parental            = parental;
            _autoStartFlags      = autoStartFlags;
            _mediaGuid           = mediaGuid;
            _subEvents           = new Lazy <SynchronizedCollection <Event> >(() =>
            {
                var result = new SynchronizedCollection <Event>();
                if (Id == 0)
                {
                    return(result);
                }
                var seList = DatabaseProvider.Database.ReadSubEvents(_engine, this);
                foreach (Event e in seList)
                {
                    e.Parent = this;
                    result.Add(e);
                }
                return(result);
            });

            _next = new Lazy <Event>(() =>
            {
                var next = (Event)DatabaseProvider.Database.ReadNext(_engine, this);
                if (next != null)
                {
                    next.Prior = this;
                }
                return(next);
            });

            _prior = new Lazy <Event>(() =>
            {
                Event prior = null;
                if (startType == TStartType.After && IdEventBinding > 0)
                {
                    prior = (Event)DatabaseProvider.Database.ReadEvent(_engine, IdEventBinding);
                }
                if (prior != null)
                {
                    prior.Next = this;
                }
                return(prior);
            });

            _parent = new Lazy <Event>(() =>
            {
                if ((startType == TStartType.WithParent || startType == TStartType.WithParentFromEnd) && IdEventBinding > 0)
                {
                    return((Event)DatabaseProvider.Database.ReadEvent(_engine, IdEventBinding));
                }
                return(null);
            });

            _rights = new Lazy <List <IAclRight> >(() =>
            {
                var rights = DatabaseProvider.Database.ReadEventAclList <EventAclRight>(this, _engine.AuthenticationService as IAuthenticationServicePersitency);
                rights.ForEach(r => ((EventAclRight)r).Saved += AclEvent_Saved);
                return(rights);
            });
            _routerPort    = routerPort;
            _recordingInfo = recordingInfo;

            FieldLengths = DatabaseProvider.Database.EventFieldLengths;
        }