Пример #1
0
        /// <summary>
        /// Play a specific IPlayItem.
        /// The strategy for now is VOD first, Live second.
        /// </summary>
        /// <param name="item">Item to play</param>
        protected void Play(IPlayItem item)
        {
            // Return if already playing
            if (_state != State.STOPPED)
            {
                return;
            }
            // Assume this is not live stream
            bool             isLive          = false;
            IProviderService providerService = ScopeUtils.GetScopeService(this.Scope, typeof(IProviderService)) as IProviderService;

            _msgIn = providerService.GetVODProviderInput(this.Scope, item.Name);
            if (_msgIn == null)
            {
                _msgIn = providerService.GetLiveProviderInput(this.Scope, item.Name, true);
                isLive = true;
            }
            if (_msgIn == null)
            {
                log.Warn("Can't get both VOD and Live input from providerService");
                return;
            }
            _state       = State.PLAYING;
            _currentItem = item;
            SendResetMessage();
            _msgIn.Subscribe(this, null);
            if (isLive)
            {
                if (item.Length >= 0)
                {
                    PlayItemScheduledJob job = new PlayItemScheduledJob(this);
                    _liveJobName = _schedulingService.AddScheduledOnceJob(item.Length, job);
                }
            }
            else
            {
                long start = item.Start;
                if (start < 0)
                {
                    start = 0;
                }
                SendVODInitCM(_msgIn, (int)start);
                StartBroadcastVOD();
            }
        }
Пример #2
0
 /// <summary>
 /// Start waiting for a valid handshake.
 /// </summary>
 internal override void StartWaitForHandshake()
 {
     _lock.AcquireWriterLock();
     try {
         if (FluorineConfiguration.Instance.FluorineSettings.RtmpServer.RtmpConnectionSettings.MaxHandshakeTimeout > 0)
         {
             ISchedulingService schedulingService = _endpoint.GetMessageBroker().GlobalScope.GetService(typeof(ISchedulingService)) as ISchedulingService;
             _waitForHandshakeJob = schedulingService.AddScheduledOnceJob(FluorineConfiguration.Instance.FluorineSettings.RtmpServer.RtmpConnectionSettings.MaxHandshakeTimeout, new WaitForHandshakeJob(this));
         }
     } finally {
         _lock.ReleaseWriterLock();
     }
 }