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 | {
|
atraczyk | 1e120ad | 2017-02-15 18:36:49 -0500 | [diff] [blame] | 43 | public:
|
| 44 | double aspectRatio();
|
| 45 |
|
atraczyk | 14ba30c | 2016-09-22 18:31:59 -0400 | [diff] [blame] | 46 | internal:
|
| 47 | property bool isPreviewing
|
| 48 | {
|
| 49 | bool get() { return isPreviewing_; }
|
| 50 | void set(bool value) { isPreviewing_ = value; }
|
| 51 | }
|
atraczyk | 1e120ad | 2017-02-15 18:36:49 -0500 | [diff] [blame] | 52 |
|
atraczyk | acc4c41 | 2016-11-10 22:56:52 -0500 | [diff] [blame] | 53 | property bool isSettingsPreviewing
|
| 54 | {
|
| 55 | bool get() { return isSettingsPreviewing_; }
|
| 56 | void set(bool value) { isSettingsPreviewing_ = value; }
|
| 57 | }
|
atraczyk | 14ba30c | 2016-09-22 18:31:59 -0400 | [diff] [blame] | 58 |
|
| 59 | Map<String^,String^>^ getSettings(String^ device);
|
| 60 |
|
| 61 | VideoCaptureManager();
|
| 62 |
|
atraczyk | 14ba30c | 2016-09-22 18:31:59 -0400 | [diff] [blame] | 63 | Windows::Graphics::Display::DisplayOrientations displayOrientation;
|
| 64 |
|
| 65 | Windows::System::Display::DisplayRequest^ displayRequest;
|
| 66 |
|
| 67 | const GUID RotationKey;
|
| 68 |
|
| 69 | bool externalCamera;
|
| 70 | bool mirroringPreview;
|
| 71 | bool isInitialized;
|
| 72 | bool isChangingCamera;
|
| 73 | bool isRendering;
|
| 74 |
|
| 75 | Vector<Device^>^ deviceList;
|
| 76 | Device^ activeDevice;
|
| 77 |
|
| 78 | DeviceInformationCollection^ devInfoCollection;
|
| 79 |
|
| 80 | Platform::Agile<Windows::Media::Capture::MediaCapture^> mediaCapture;
|
| 81 |
|
atraczyk | acc4c41 | 2016-11-10 22:56:52 -0500 | [diff] [blame] | 82 | task<void> InitializeCameraAsync(bool isSettingsPreview);
|
| 83 | task<void> StartPreviewAsync(bool isSettingsPreview);
|
atraczyk | 14ba30c | 2016-09-22 18:31:59 -0400 | [diff] [blame] | 84 | task<void> StopPreviewAsync();
|
| 85 | task<void> EnumerateWebcamsAsync();
|
| 86 | task<void> CleanupCameraAsync();
|
| 87 |
|
| 88 | // event tokens
|
| 89 | EventRegistrationToken mediaCaptureFailedEventToken;
|
atraczyk | 14ba30c | 2016-09-22 18:31:59 -0400 | [diff] [blame] | 90 | EventRegistrationToken visibilityChangedEventToken;
|
| 91 |
|
| 92 | cancellation_token_source* captureTaskTokenSource;
|
| 93 |
|
| 94 | void MediaCapture_Failed(MediaCapture ^currentCaptureObject, MediaCaptureFailedEventArgs^ errorEventArgs);
|
atraczyk | acc4c41 | 2016-11-10 22:56:52 -0500 | [diff] [blame] | 95 | task<void> AddVideoDeviceAsync(uint8_t index);
|
atraczyk | 14ba30c | 2016-09-22 18:31:59 -0400 | [diff] [blame] | 96 | void SetCaptureSettings();
|
| 97 |
|
| 98 | DispatcherTimer^ videoFrameCopyInvoker;
|
| 99 | task<void> CopyFrameAsync();
|
| 100 | void CopyFrame(Object^ sender, Object^ e);
|
atraczyk | 40afd72 | 2016-12-29 19:33:09 -0500 | [diff] [blame] | 101 | void InitializeCopyFrameDispatcher(unsigned frameRate);
|
atraczyk | 14ba30c | 2016-09-22 18:31:59 -0400 | [diff] [blame] | 102 |
|
| 103 | event StartPreviewing^ startPreviewing;
|
| 104 | event StopPreviewing^ stopPreviewing;
|
| 105 | event GetSink^ getSink;
|
atraczyk | acc4c41 | 2016-11-10 22:56:52 -0500 | [diff] [blame] | 106 | event GetSettingsPreviewSink^ getSettingsPreviewSink;
|
| 107 | event CaptureEnumerationComplete^ captureEnumerationComplete;
|
atraczyk | 14ba30c | 2016-09-22 18:31:59 -0400 | [diff] [blame] | 108 |
|
| 109 | private:
|
| 110 | bool isPreviewing_;
|
atraczyk | acc4c41 | 2016-11-10 22:56:52 -0500 | [diff] [blame] | 111 | bool isSettingsPreviewing_;
|
atraczyk | 14ba30c | 2016-09-22 18:31:59 -0400 | [diff] [blame] | 112 |
|
| 113 | };
|
| 114 |
|
| 115 | } /* namespace Video */
|
| 116 | } /* namespace RingClientUWP */ |