Пример #1
0
        public async Task StartAsync()
        {
            if (m_mediaCapture != null)
            {
                throw new InvalidOperationException("Cannot start while recording");
            }

            m_mediaCapture = new MediaCapture();
            await m_mediaCapture.InitializeAsync(new MediaCaptureInitializationSettings()
            {
                MediaCategory        = MediaCategory.Speech,
                AudioProcessing      = AudioProcessing.Default,
                MemoryPreference     = MediaCaptureMemoryPreference.Auto,
                SharingMode          = MediaCaptureSharingMode.SharedReadOnly,
                StreamingCaptureMode = StreamingCaptureMode.Audio,
            });

            m_opusSink = await OpusCodec.CreateMediaSinkAsync(m_file);

            var wawEncodingProfile = MediaEncodingProfile.CreateWav(AudioEncodingQuality.High);

            wawEncodingProfile.Audio.BitsPerSample = 16;
            wawEncodingProfile.Audio.SampleRate    = 48000;
            wawEncodingProfile.Audio.ChannelCount  = 1;
            await m_mediaCapture.StartRecordToCustomSinkAsync(wawEncodingProfile, m_opusSink);
        }
Пример #2
0
            public async Task StartAsync()
            {
                m_isRecording = true;

                if (m_isVideo)
                {
                    var profile       = MediaEncodingProfile.CreateMp4(VideoEncodingQuality.Auto);
                    var rotationAngle = CameraRotationHelper.ConvertSimpleOrientationToClockwiseDegrees(_rotationHelper.GetCameraCaptureOrientation());
                    profile.Video.Properties.Add(new Guid("C380465D-2271-428C-9B83-ECEA3B4A85C1"), PropertyValue.CreateInt32(rotationAngle));

                    m_lowLag = await m_mediaCapture.PrepareLowLagRecordToStorageFileAsync(profile, m_file);

                    await m_lowLag.StartAsync();
                }
                else
                {
                    var wavEncodingProfile = MediaEncodingProfile.CreateWav(AudioEncodingQuality.High);
                    wavEncodingProfile.Audio.BitsPerSample = 16;
                    wavEncodingProfile.Audio.SampleRate    = 48000;
                    wavEncodingProfile.Audio.ChannelCount  = 1;

                    m_opusSink = await OpusCodec.CreateMediaSinkAsync(m_file);

                    await m_mediaCapture.StartRecordToCustomSinkAsync(wavEncodingProfile, m_opusSink);
                }
            }
Пример #3
0
            public async Task StartAsync()
            {
                m_isRecording = true;

                if (m_isVideo)
                {
                    var profile = MediaEncodingProfile.CreateMp4(VideoEncodingQuality.Vga);

                    m_lowLag = await m_mediaCapture.PrepareLowLagRecordToStorageFileAsync(profile, m_file);

                    await m_lowLag.StartAsync();
                }
                else
                {
                    var wavEncodingProfile = MediaEncodingProfile.CreateWav(AudioEncodingQuality.High);
                    wavEncodingProfile.Audio.BitsPerSample = 16;
                    wavEncodingProfile.Audio.SampleRate    = 48000;
                    wavEncodingProfile.Audio.ChannelCount  = 1;

                    m_opusSink = await OpusCodec.CreateMediaSinkAsync(m_file);

                    await m_mediaCapture.StartRecordToCustomSinkAsync(wavEncodingProfile, m_opusSink);
                }
            }