Example #1
0
        void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            FileInfo file = new FileInfo(Source.GetTranscodingFileName());

            if (Status != TranscodingStatus.Initializing)
            {
                Utilities.DebugLine("Timer: stopping timer, file={0}, status={1}", file.Name, Status);
                Timer.Stop();
                return;
            }

            Utilities.DebugLine("Timer: outfile {0}, exists: {1}, size: {2}", file.Name, file.Exists, file.Exists ? file.Length : -1);
            if (file.Exists && file.Length > 5 * 1024 * 1024)
            {
                Timer.Stop();
                lock (this)
                {
                    if (Status == TranscodingStatus.Initializing)
                    {
                        Status = TranscodingStatus.BufferReady;
                        TranscodingService.NotifyAll(Source.Key, Status);
                    }
                }
            }
        }
Example #2
0
 void TranscodingProcess_Exited(object sender, EventArgs e)
 {
     lock (this)
         if (Status != TranscodingStatus.Stopped)
         {
             Status = TranscodingProcess.Process.ExitCode != 0 ? TranscodingStatus.Error : TranscodingStatus.Done;
         }
     TranscodingService.NotifyAll(Source.Key, Status);
 }
Example #3
0
 internal Transcoder(MediaSource source)
 {
     TranscodingProcess         = new Transcode(source);
     TranscodingProcess.Exited += TranscodingProcess_Exited;
     Timer           = new System.Timers.Timer(1000);
     Timer.AutoReset = true;
     Timer.Elapsed  += Timer_Elapsed;
     Timer.Start();
     lock (this)
         Status = TranscodingProcess.BeginTranscodeJob() != 0 ? TranscodingStatus.Error : TranscodingStatus.Initializing;
     TranscodingService.NotifyAll(source.Key, Status);
 }