예제 #1
0
        public void StartRecording(RecordType type)
        {
            _type = type;

            if (_type == RecordType.None)
            {
                return;
            }

            try
            {
                _recorder        = new MediaRecorder();
                _recorder.Error += (o, e) =>
                {
                    _isRecording = false;
                    OnServiceChanged.Invoke(this, EventArgs.Empty);
                };

                _recorder.Reset();


                if (_type == RecordType.Video)
                {
                    _recorder.SetAudioSource(AudioSource.Camcorder);
                    _recorder.SetVideoSource(VideoSource.Camera);
                    _recorder.SetOutputFormat(OutputFormat.Mpeg4);
                    _recorder.SetVideoSize(640, 480);
                    _recorder.SetCaptureRate(30);
                    _recorder.SetVideoEncoder(VideoEncoder.Mpeg4Sp);
                    _recorder.SetAudioEncoder(AudioEncoder.Aac);
                }
                else if (_type == RecordType.Audio)
                {
                    _recorder.SetAudioSource(AudioSource.Mic);
                    _recorder.SetOutputFormat(OutputFormat.Default);
                    _recorder.SetAudioEncoder(AudioEncoder.Default);
                }

                _recorder.SetOutputFile(GetFilePath());
                _recorder.Prepare();
                _recorder.Start();
                _isRecording = true;
                OnServiceChanged.Invoke(this, EventArgs.Empty);
            }
            catch (Exception ex)
            {
                _isRecording = false;
                OnServiceChanged.Invoke(this, new UnhandledExceptionEventArgs(ex, false));
            }
        }
예제 #2
0
        public void OnSIPServiceChange(string msg, ServiceStatus state)
        {
            _serviceState = ServiceStatus.Complete;

            try { OnServiceChanged.Invoke(msg, state); }
            catch { }
            //OnServiceChanged?.GetInvocationList().ToList().ForEach((item) =>
            //{
            //    var handler = item as Action<string, ServiceStatus>;
            //    try { handler?.Invoke(msg, state); }
            //    catch { }
            //});

            //foreach (Action<string, ServiceStatus> handler in OnServiceChanged.GetInvocationList())
            //{
            //    try { OnServiceChanged(msg, state); }
            //    catch { continue; }
            //}
        }