예제 #1
0
        private TsMediaStreamSource.Operation HandleOperation(TsMediaStreamSource.Operation operation)
        {
            int num1      = (int)operation;
            int comparand = this._pendingOperations;

            while (true)
            {
                int num2 = comparand & ~num1;
                if (num2 != comparand)
                {
                    int num3 = Interlocked.CompareExchange(ref this._pendingOperations, num2, comparand);
                    if (num3 != comparand)
                    {
                        comparand = num3;
                    }
                    else
                    {
                        goto label_3;
                    }
                }
                else
                {
                    break;
                }
            }
            return(TsMediaStreamSource.Operation.None);

label_3:
            return((TsMediaStreamSource.Operation)(comparand & num1));
        }
예제 #2
0
        private bool RequestOperation(TsMediaStreamSource.Operation operation)
        {
            int num1      = (int)operation;
            int comparand = this._pendingOperations;

            while (true)
            {
                int num2 = comparand | num1;
                if (num2 != comparand)
                {
                    int num3 = Interlocked.CompareExchange(ref this._pendingOperations, num2, comparand);
                    if (num3 != comparand)
                    {
                        comparand = num3;
                    }
                    else
                    {
                        goto label_3;
                    }
                }
                else
                {
                    break;
                }
            }
            return(false);

label_3:
            return(true);
        }
예제 #3
0
 private void RequestOperationAndSignal(TsMediaStreamSource.Operation operation)
 {
     if (!this.RequestOperation(operation))
     {
         return;
     }
     this._taskScheduler.Signal();
 }
예제 #4
0
 private void ForceClose()
 {
     TsMediaStreamSource.Operation operation = this.HandleOperation(TsMediaStreamSource.Operation.Audio | TsMediaStreamSource.Operation.Video | TsMediaStreamSource.Operation.Seek);
     if (TsMediaStreamSource.Operation.None != (operation & TsMediaStreamSource.Operation.Seek))
     {
         this.ValidateEvent(MediaStreamFsm.MediaEvent.CallingReportSeekCompleted);
         this.ReportSeekCompleted(0L);
     }
     if ((operation & TsMediaStreamSource.Operation.Video) != TsMediaStreamSource.Operation.None && null != this._videoStreamDescription)
     {
         this.SendLastStreamSample(this._videoStreamDescription);
     }
     if ((operation & TsMediaStreamSource.Operation.Audio) == TsMediaStreamSource.Operation.None || null == this._audioStreamDescription)
     {
         return;
     }
     this.SendLastStreamSample(this._audioStreamDescription);
 }
예제 #5
0
        private void SignalHandler()
        {
            this._taskScheduler.ThrowIfNotOnThread();
            TsMediaStreamSource.Operation operation1 = TsMediaStreamSource.Operation.None;
            TsMediaStreamSource.Operation operation2 = TsMediaStreamSource.Operation.None;
            try
            {
                if (this._isClosed)
                {
                    this.ForceClose();
                }
                else
                {
                    bool flag;
                    do
                    {
                        if (TsMediaStreamSource.Operation.None == this.HandleOperation(TsMediaStreamSource.Operation.Seek))
                        {
                            if (TsMediaStreamSource.SourceState.Play == this.State)
                            {
                                operation1  = this.HandleOperation(TsMediaStreamSource.Operation.Audio | TsMediaStreamSource.Operation.Video);
                                operation2 |= operation1;
                                if (TsMediaStreamSource.Operation.None != operation2)
                                {
                                    TsMediaStreamSource.Operation operation3 = this._streamOpenFlags;
                                    bool canCallReportBufferingProgress      = operation3 == (operation2 & operation3);
                                    flag = false;
                                    if (TsMediaStreamSource.Operation.None != (operation2 & TsMediaStreamSource.Operation.Video) && null != this.VideoStreamSource && this.SendStreamSample(this.VideoStreamSource, this._videoStreamDescription, canCallReportBufferingProgress))
                                    {
                                        operation2 &= ~TsMediaStreamSource.Operation.Video;
                                        flag        = true;
                                    }
                                    if (TsMediaStreamSource.Operation.None != (operation2 & TsMediaStreamSource.Operation.Audio) && null != this.AudioStreamSource && this.SendStreamSample(this.AudioStreamSource, this._audioStreamDescription, canCallReportBufferingProgress))
                                    {
                                        operation2 &= ~TsMediaStreamSource.Operation.Audio;
                                        flag        = true;
                                    }
                                }
                                else
                                {
                                    goto label_3;
                                }
                            }
                            else
                            {
                                goto label_8;
                            }
                        }
                        else
                        {
                            goto label_4;
                        }
                    }while (flag);
                    goto label_20;
label_4:
                    if (TsMediaStreamSource.Operation.None != operation1)
                    {
                        operation2 |= operation1;
                    }
                    Task task = this.SeekHandler();
                    TaskCollector.Default.Add(task, "TsMediaStreamSource.SignalHandler SeekHandler()");
                    return;

label_8:
                    return;

label_3:
                    return;

                    label_20 :;
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("TsMediaStreamSource.SignalHandler() failed: " + ExceptionExtensions.ExtendedMessage(ex));
            }
            finally
            {
                if (TsMediaStreamSource.Operation.None != operation2)
                {
                    Debug.WriteLine("TsMediaStreamSource.SignalHandler() re-requesting " + (object)operation2);
                    this.RequestOperation(operation2);
                }
            }
        }