Esempio n. 1
0
        public void Stop(VideoStopRequest stopRequest)
        {
            _runningInstances.Remove(this);
            _encoder.StopFfmpeg();
            if (!string.IsNullOrEmpty(RecordingPath))
            {
                if (!System.IO.File.Exists(RecordingPath))
                {
                    Console.WriteLine("Recording path " + RecordingPath + " not found.");
                }
                else
                {
                    if (!string.IsNullOrEmpty(stopRequest.FileName))
                    {
                        int fileIndex = 0;
                        while (System.IO.File.Exists(GenerateVideoFilePath(stopRequest.FileName, fileIndex)))
                        {
                            fileIndex += 1;
                        }

                        var finalFile = GenerateVideoFilePath(stopRequest.FileName, fileIndex);
                        Console.WriteLine("Renaming " + RecordingPath + " to " + finalFile);
                        PatientlyRenameFile(RecordingPath, finalFile, 0);
                    }
                }
            }
        }
Esempio n. 2
0
        public HttpResponseMessage StopRecording([FromUri] VideoStopRequest stopRequest)
        {
            if (stopRequest == null)
            {
                stopRequest = new VideoStopRequest();
            }

            if (string.IsNullOrEmpty(stopRequest.FileName))
            {
                stopRequest.FileName = "UnnamedVideo";
            }

            Console.WriteLine("Stopping recording: " + Newtonsoft.Json.JsonConvert.SerializeObject(stopRequest));
            var existingKeys =
                FfmpegInstance.RunningInstances.Where(i => i.StartRequest.RecordingKey == stopRequest.RecordingKey);
            int keysFound = existingKeys.Count();

            foreach (var existingInstance in existingKeys)
            {
                existingInstance.Stop(stopRequest);
            }

            return(GenerateJsonResponse(new { Stopped = (keysFound > 0), StoppedCount = keysFound }));
        }