Пример #1
0
        private void ffMpegAsyncHandlerActivation(object sendingProcess, DataReceivedEventArgs outLine)
        {
            onCancel();

            if (outLine.Data is null)
            {
                return;
            }

#if TRACE && EXTRA
            Trace.WriteLine(outLine.Data);
#endif
            Log(4, this, () => ID + outLine.Data.SubstitUser());

            Match match = null;
            if (!Chapters.IsNull() && !_listComplete)
            {
                match = _rgxChapter.Match(outLine.Data);
                if (match.Success)
                {
                    var chapter = new Chapter();
                    Chapters.Add(chapter);
                    chapter.Time.Begin = tryParseSeconds(match);
                    chapter.Time.End   = tryParseSeconds(match, 2);
                    return;
                }
                else
                {
                    match = _rgxAnyStream.Match(outLine.Data);
                    if (match.Success)
                    {
                        _listComplete = true;
                    }
                    else
                    {
                        var chapter = Chapters.LastOrDefault();
                        if (!chapter.IsNull())
                        {
                            match = _rgxChapterMeta.Match(outLine.Data);
                            if (match.Success)
                            {
                                chapter.Name = string.Empty;
                                return;
                            }
                            else
                            {
                                if (chapter.Name == string.Empty)
                                {
                                    match = _rgxChapterTitle.Match(outLine.Data);
                                    if (match.Success)
                                    {
                                        chapter.Name = match.Groups[1].Value;
                                    }
                                    return;
                                }
                            }
                        }
                    }
                }
            }

            match = _rgxErrorHeader.Match(outLine.Data);
            if (match.Success)
            {
                _success = false;
            }
            else
            {
                match = _rgxErrorActivationOption.Match(outLine.Data);
                if (match.Success)
                {
                    _success = false;
                }
                else
                {
                    match = _rgxInvalid.Match(outLine.Data);
                    if (match.Success)
                    {
                        _success = false;
                    }
                    else
                    {
                        match = _rgxNoActivatonOpt.Match(outLine.Data);
                        if (match.Success)
                        {
                            HasNoActivation = true;
                        }
                        else
                        {
                            match = _rgxAudioStream.Match(outLine.Data);
                            if (match.Success)
                            {
                                string format = match.Groups[1].Value;
                                IsMp3Stream = format.ToLowerInvariant() == "mp3";
                            }
                            else
                            {
                                match = _rgxAaFile.Match(outLine.Data);
                                if (match.Success)
                                {
                                    IsAaFile = true;
                                }
                                else
                                {
                                    match = _rgxAaxFile.Match(outLine.Data);
                                    if (match.Success)
                                    {
                                        IsAaxFile = true;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }