atraczyk | 14ba30c | 2016-09-22 18:31:59 -0400 | [diff] [blame] | 1 | /**************************************************************************
|
| 2 | * Copyright (C) 2016 by Savoir-faire Linux *
|
| 3 | * Author: Jäger Nicolas <nicolas.jager@savoirfairelinux.com> *
|
| 4 | * Author: Traczyk Andreas <andreas.traczyk@savoirfairelinux.com> *
|
| 5 | * *
|
| 6 | * This program is free software; you can redistribute it and/or modify *
|
| 7 | * it under the terms of the GNU General Public License as published by *
|
| 8 | * the Free Software Foundation; either version 3 of the License, or *
|
| 9 | * (at your option) any later version. *
|
| 10 | * *
|
| 11 | * This program is distributed in the hope that it will be useful, *
|
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
| 14 | * GNU General Public License for more details. *
|
| 15 | * *
|
| 16 | * You should have received a copy of the GNU General Public License *
|
| 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
| 18 | **************************************************************************/
|
| 19 | #pragma once
|
| 20 |
|
| 21 | using namespace Windows::UI::Xaml;
|
| 22 | using namespace Windows::ApplicationModel::Core;
|
| 23 | using namespace Windows::Devices::Enumeration;
|
| 24 | using namespace Windows::Media::Capture;
|
| 25 | using namespace Windows::Foundation;
|
atraczyk | acc4c41 | 2016-11-10 22:56:52 -0500 | [diff] [blame] | 26 | using namespace Windows::UI::Xaml::Controls;
|
atraczyk | 14ba30c | 2016-09-22 18:31:59 -0400 | [diff] [blame] | 27 | using namespace Concurrency;
|
| 28 |
|
| 29 | namespace RingClientUWP
|
| 30 | {
|
| 31 |
|
| 32 | delegate void StartPreviewing();
|
| 33 | delegate void StopPreviewing();
|
atraczyk | acc4c41 | 2016-11-10 22:56:52 -0500 | [diff] [blame] | 34 | delegate CaptureElement^ GetSink();
|
| 35 | delegate CaptureElement^ GetSettingsPreviewSink();
|
| 36 | delegate void CaptureEnumerationComplete();
|
atraczyk | 14ba30c | 2016-09-22 18:31:59 -0400 | [diff] [blame] | 37 |
|
| 38 | namespace Video
|
| 39 | {
|
| 40 |
|
| 41 | public ref class VideoCaptureManager sealed
|
| 42 | {
|
| 43 | internal:
|
| 44 | property bool isPreviewing
|
| 45 | {
|
| 46 | bool get() { return isPreviewing_; }
|
| 47 | void set(bool value) { isPreviewing_ = value; }
|
| 48 | }
|
atraczyk | acc4c41 | 2016-11-10 22:56:52 -0500 | [diff] [blame] | 49 | property bool isSettingsPreviewing
|
| 50 | {
|
| 51 | bool get() { return isSettingsPreviewing_; }
|
| 52 | void set(bool value) { isSettingsPreviewing_ = value; }
|
| 53 | }
|
atraczyk | 14ba30c | 2016-09-22 18:31:59 -0400 | [diff] [blame] | 54 |
|
| 55 | Map<String^,String^>^ getSettings(String^ device);
|
| 56 |
|
| 57 | VideoCaptureManager();
|
| 58 |
|
atraczyk | 14ba30c | 2016-09-22 18:31:59 -0400 | [diff] [blame] | 59 | Windows::Graphics::Display::DisplayOrientations displayOrientation;
|
| 60 |
|
| 61 | Windows::System::Display::DisplayRequest^ displayRequest;
|
| 62 |
|
| 63 | const GUID RotationKey;
|
| 64 |
|
| 65 | bool externalCamera;
|
| 66 | bool mirroringPreview;
|
| 67 | bool isInitialized;
|
| 68 | bool isChangingCamera;
|
| 69 | bool isRendering;
|
| 70 |
|
| 71 | Vector<Device^>^ deviceList;
|
| 72 | Device^ activeDevice;
|
| 73 |
|
| 74 | DeviceInformationCollection^ devInfoCollection;
|
| 75 |
|
| 76 | Platform::Agile<Windows::Media::Capture::MediaCapture^> mediaCapture;
|
| 77 |
|
atraczyk | acc4c41 | 2016-11-10 22:56:52 -0500 | [diff] [blame] | 78 | task<void> InitializeCameraAsync(bool isSettingsPreview);
|
| 79 | task<void> StartPreviewAsync(bool isSettingsPreview);
|
atraczyk | 14ba30c | 2016-09-22 18:31:59 -0400 | [diff] [blame] | 80 | task<void> StopPreviewAsync();
|
| 81 | task<void> EnumerateWebcamsAsync();
|
| 82 | task<void> CleanupCameraAsync();
|
| 83 |
|
| 84 | // event tokens
|
| 85 | EventRegistrationToken mediaCaptureFailedEventToken;
|
atraczyk | 14ba30c | 2016-09-22 18:31:59 -0400 | [diff] [blame] | 86 | EventRegistrationToken visibilityChangedEventToken;
|
| 87 |
|
| 88 | cancellation_token_source* captureTaskTokenSource;
|
| 89 |
|
| 90 | void MediaCapture_Failed(MediaCapture ^currentCaptureObject, MediaCaptureFailedEventArgs^ errorEventArgs);
|
atraczyk | acc4c41 | 2016-11-10 22:56:52 -0500 | [diff] [blame] | 91 | task<void> AddVideoDeviceAsync(uint8_t index);
|
atraczyk | 14ba30c | 2016-09-22 18:31:59 -0400 | [diff] [blame] | 92 | void SetCaptureSettings();
|
| 93 |
|
| 94 | DispatcherTimer^ videoFrameCopyInvoker;
|
| 95 | task<void> CopyFrameAsync();
|
| 96 | void CopyFrame(Object^ sender, Object^ e);
|
| 97 | void InitializeCopyFrameDispatcher();
|
| 98 |
|
| 99 | event StartPreviewing^ startPreviewing;
|
| 100 | event StopPreviewing^ stopPreviewing;
|
| 101 | event GetSink^ getSink;
|
atraczyk | acc4c41 | 2016-11-10 22:56:52 -0500 | [diff] [blame] | 102 | event GetSettingsPreviewSink^ getSettingsPreviewSink;
|
| 103 | event CaptureEnumerationComplete^ captureEnumerationComplete;
|
atraczyk | 14ba30c | 2016-09-22 18:31:59 -0400 | [diff] [blame] | 104 |
|
| 105 | private:
|
| 106 | bool isPreviewing_;
|
atraczyk | acc4c41 | 2016-11-10 22:56:52 -0500 | [diff] [blame] | 107 | bool isSettingsPreviewing_;
|
atraczyk | 14ba30c | 2016-09-22 18:31:59 -0400 | [diff] [blame] | 108 |
|
| 109 | };
|
| 110 |
|
| 111 | } /* namespace Video */
|
| 112 | } /* namespace RingClientUWP */ |