1 //*********************************************************
3 // Copyright (c) Microsoft. All rights reserved.
4 // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
5 // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
6 // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
7 // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
9 //*********************************************************
12 // AdvancedCapture.xaml.h
13 // Declaration of the AdvancedCapture class
19 #include "AdvancedCapture.g.h"
20 #include "MainPage.xaml.h"
23 #define VIDEO_FILE_NAME "video.mp4"
24 #define PHOTO_FILE_NAME "photo.jpg"
25 #define TEMP_PHOTO_FILE_NAME "photoTmp.jpg"
27 using namespace concurrency;
28 using namespace Windows::Devices::Enumeration;
32 namespace MediaCapture
35 /// An empty page that can be used on its own or navigated to within a Frame.
37 [Windows::Foundation::Metadata::WebHostHidden]
38 public ref class AdvancedCapture sealed
44 virtual void OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) override;
45 virtual void OnNavigatedFrom(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) override;
52 void Failed(Windows::Media::Capture::MediaCapture ^ mediaCapture, Windows::Media::Capture::MediaCaptureFailedEventArgs ^ args);
54 void btnStartDevice_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
56 void btnStartPreview_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
58 void lstEnumedDevices_SelectionChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ e);
59 void EnumerateWebcamsAsync();
61 void AddEffectToImageStream();
63 void ShowStatusMessage(Platform::String^ text);
64 void ShowExceptionMessage(Platform::Exception^ ex);
66 void EnableButton(bool enabled, Platform::String ^name);
68 task<Windows::Storage::StorageFile^> ReencodePhotoAsync(
69 Windows::Storage::StorageFile ^tempStorageFile,
70 Windows::Storage::FileProperties::PhotoOrientation photoRotation);
71 Windows::Storage::FileProperties::PhotoOrientation GetCurrentPhotoRotation();
72 void PrepareForVideoRecording();
73 void DisplayProperties_OrientationChanged(Platform::Object^ sender);
74 Windows::Storage::FileProperties::PhotoOrientation PhotoRotationLookup(
75 Windows::Graphics::Display::DisplayOrientations displayOrientation, bool counterclockwise);
76 Windows::Media::Capture::VideoRotation VideoRotationLookup(
77 Windows::Graphics::Display::DisplayOrientations displayOrientation, bool counterclockwise);
79 Platform::Agile<Windows::Media::Capture::MediaCapture> m_mediaCaptureMgr;
80 Windows::Storage::StorageFile^ m_recordStorageFile;
83 bool m_bEffectAddedToRecord;
84 bool m_bEffectAddedToPhoto;
87 DeviceInformationCollection^ m_devInfoCollection;
88 Windows::Foundation::EventRegistrationToken m_eventRegistrationToken;
89 bool m_bRotateVideoOnOrientationChange;
90 bool m_bReversePreviewRotation;
91 Windows::Foundation::EventRegistrationToken m_orientationChangedEventToken;
92 void Button_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);