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;
|
| 26 | using namespace Concurrency;
|
| 27 |
|
| 28 | namespace RingClientUWP
|
| 29 | {
|
| 30 |
|
| 31 | delegate void StartPreviewing();
|
| 32 | delegate void StopPreviewing();
|
| 33 | delegate Windows::UI::Xaml::Controls::CaptureElement^ GetSink();
|
| 34 |
|
| 35 | namespace Video
|
| 36 | {
|
| 37 |
|
| 38 | public ref class VideoCaptureManager sealed
|
| 39 | {
|
| 40 | internal:
|
| 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 |
|
| 97 | private:
|
| 98 | bool isPreviewing_;
|
| 99 |
|
| 100 | };
|
| 101 |
|
| 102 | } /* namespace Video */
|
| 103 | } /* namespace RingClientUWP */ |