blob: 74ad03d78277e8ff1b552a02a50b0d549cf60146 [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;
26using namespace Concurrency;
27
28namespace RingClientUWP
29{
30
31delegate void StartPreviewing();
32delegate void StopPreviewing();
33delegate Windows::UI::Xaml::Controls::CaptureElement^ GetSink();
34
35namespace Video
36{
37
38public ref class VideoCaptureManager sealed
39{
40internal:
41 property bool isPreviewing
42 {
43 bool get() { return isPreviewing_; }
44 void set(bool value) { isPreviewing_ = value; }
45 }
46
47 Map<String^,String^>^ getSettings(String^ device);
48
49 VideoCaptureManager();
50
51 Windows::Graphics::Display::DisplayInformation^ displayInformation;
52 Windows::Graphics::Display::DisplayOrientations displayOrientation;
53
54 Windows::System::Display::DisplayRequest^ displayRequest;
55
56 const GUID RotationKey;
57
58 bool externalCamera;
59 bool mirroringPreview;
60 bool isInitialized;
61 bool isChangingCamera;
62 bool isRendering;
63
64 Vector<Device^>^ deviceList;
65 Device^ activeDevice;
66
67 DeviceInformationCollection^ devInfoCollection;
68
69 Platform::Agile<Windows::Media::Capture::MediaCapture^> mediaCapture;
70
71 task<void> InitializeCameraAsync();
72 task<void> StartPreviewAsync();
73 task<void> StopPreviewAsync();
74 task<void> EnumerateWebcamsAsync();
75 task<void> CleanupCameraAsync();
76
77 // event tokens
78 EventRegistrationToken mediaCaptureFailedEventToken;
79 EventRegistrationToken displayInformationEventToken;
80 EventRegistrationToken visibilityChangedEventToken;
81
82 cancellation_token_source* captureTaskTokenSource;
83
84 void MediaCapture_Failed(MediaCapture ^currentCaptureObject, MediaCaptureFailedEventArgs^ errorEventArgs);
85 void AddVideoDevice(uint8_t index);
86 void SetCaptureSettings();
87
88 DispatcherTimer^ videoFrameCopyInvoker;
89 task<void> CopyFrameAsync();
90 void CopyFrame(Object^ sender, Object^ e);
91 void InitializeCopyFrameDispatcher();
92
93 event StartPreviewing^ startPreviewing;
94 event StopPreviewing^ stopPreviewing;
95 event GetSink^ getSink;
96
97private:
98 bool isPreviewing_;
99
100};
101
102} /* namespace Video */
103} /* namespace RingClientUWP */