blob: 32bc635a869d502b2558ebc71446bd35ef41e388 [file] [log] [blame]
atraczyk14ba30c2016-09-22 18:31:59 -04001/**************************************************************************
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
21using namespace Windows::UI::Xaml;
22using namespace Windows::ApplicationModel::Core;
23using namespace Windows::Devices::Enumeration;
24using namespace Windows::Media::Capture;
25using namespace Windows::Foundation;
atraczykacc4c412016-11-10 22:56:52 -050026using namespace Windows::UI::Xaml::Controls;
atraczyk14ba30c2016-09-22 18:31:59 -040027using namespace Concurrency;
28
29namespace RingClientUWP
30{
31
32delegate void StartPreviewing();
33delegate void StopPreviewing();
atraczykacc4c412016-11-10 22:56:52 -050034delegate CaptureElement^ GetSink();
35delegate CaptureElement^ GetSettingsPreviewSink();
36delegate void CaptureEnumerationComplete();
atraczyk14ba30c2016-09-22 18:31:59 -040037
38namespace Video
39{
40
41public ref class VideoCaptureManager sealed
42{
43internal:
44 property bool isPreviewing
45 {
46 bool get() { return isPreviewing_; }
47 void set(bool value) { isPreviewing_ = value; }
48 }
atraczykacc4c412016-11-10 22:56:52 -050049 property bool isSettingsPreviewing
50 {
51 bool get() { return isSettingsPreviewing_; }
52 void set(bool value) { isSettingsPreviewing_ = value; }
53 }
atraczyk14ba30c2016-09-22 18:31:59 -040054
55 Map<String^,String^>^ getSettings(String^ device);
56
57 VideoCaptureManager();
58
atraczyk14ba30c2016-09-22 18:31:59 -040059 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
atraczykacc4c412016-11-10 22:56:52 -050078 task<void> InitializeCameraAsync(bool isSettingsPreview);
79 task<void> StartPreviewAsync(bool isSettingsPreview);
atraczyk14ba30c2016-09-22 18:31:59 -040080 task<void> StopPreviewAsync();
81 task<void> EnumerateWebcamsAsync();
82 task<void> CleanupCameraAsync();
83
84 // event tokens
85 EventRegistrationToken mediaCaptureFailedEventToken;
atraczyk14ba30c2016-09-22 18:31:59 -040086 EventRegistrationToken visibilityChangedEventToken;
87
88 cancellation_token_source* captureTaskTokenSource;
89
90 void MediaCapture_Failed(MediaCapture ^currentCaptureObject, MediaCaptureFailedEventArgs^ errorEventArgs);
atraczykacc4c412016-11-10 22:56:52 -050091 task<void> AddVideoDeviceAsync(uint8_t index);
atraczyk14ba30c2016-09-22 18:31:59 -040092 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;
atraczykacc4c412016-11-10 22:56:52 -0500102 event GetSettingsPreviewSink^ getSettingsPreviewSink;
103 event CaptureEnumerationComplete^ captureEnumerationComplete;
atraczyk14ba30c2016-09-22 18:31:59 -0400104
105private:
106 bool isPreviewing_;
atraczykacc4c412016-11-10 22:56:52 -0500107 bool isSettingsPreviewing_;
atraczyk14ba30c2016-09-22 18:31:59 -0400108
109};
110
111} /* namespace Video */
112} /* namespace RingClientUWP */