Commit de9f659f authored by Alexander Smorkalov's avatar Alexander Smorkalov

Several transforms added to sample IMFTransform.

parent 9e062871
...@@ -40,7 +40,8 @@ ...@@ -40,7 +40,8 @@
<Button x:Name="btnTakePhoto2" Click="btnTakePhoto_Click" IsEnabled="false" Margin="0,0,10,0">TakePhoto</Button> <Button x:Name="btnTakePhoto2" Click="btnTakePhoto_Click" IsEnabled="false" Margin="0,0,10,0">TakePhoto</Button>
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="2" Margin="0,10,0,0"> <StackPanel Orientation="Horizontal" Grid.Row="2" Margin="0,10,0,0">
<CheckBox x:Name="chkAddRemoveEffect" Margin="0,0,10,0" Content="Grayscale Effect" IsEnabled="False" Checked="chkAddRemoveEffect_Checked" Unchecked="chkAddRemoveEffect_Unchecked"/> <CheckBox x:Name="chkAddRemoveEffect" Margin="0,0,10,0" Content="Add Effect" IsEnabled="False" Checked="chkAddRemoveEffect_Checked" Unchecked="chkAddRemoveEffect_Unchecked"/>
<ComboBox Width="120"/>
</StackPanel> </StackPanel>
</Grid> </Grid>
......
...@@ -122,7 +122,7 @@ void AdvancedCapture::ScenarioReset() ...@@ -122,7 +122,7 @@ void AdvancedCapture::ScenarioReset()
void AdvancedCapture::SoundLevelChanged(Object^ sender, Object^ e) void AdvancedCapture::SoundLevelChanged(Object^ sender, Object^ e)
{ {
create_task(Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::High, ref new Windows::UI::Core::DispatchedHandler([this]() create_task(Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::High, ref new Windows::UI::Core::DispatchedHandler([this]()
{ {
if(Windows::Media::MediaControl::SoundLevel != Windows::Media::SoundLevel::Muted) if(Windows::Media::MediaControl::SoundLevel != Windows::Media::SoundLevel::Muted)
{ {
ScenarioReset(); ScenarioReset();
...@@ -220,7 +220,7 @@ void AdvancedCapture::RecordLimitationExceeded(Windows::Media::Capture::MediaCap ...@@ -220,7 +220,7 @@ void AdvancedCapture::RecordLimitationExceeded(Windows::Media::Capture::MediaCap
void AdvancedCapture::Failed(Windows::Media::Capture::MediaCapture ^currentCaptureObject, Windows::Media::Capture::MediaCaptureFailedEventArgs^ currentFailure) void AdvancedCapture::Failed(Windows::Media::Capture::MediaCapture ^currentCaptureObject, Windows::Media::Capture::MediaCaptureFailedEventArgs^ currentFailure)
{ {
String ^message = "Fatal error" + currentFailure->Message; String ^message = "Fatal error" + currentFailure->Message;
create_task(Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::High, create_task(Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::High,
ref new Windows::UI::Core::DispatchedHandler([this, message]() ref new Windows::UI::Core::DispatchedHandler([this, message]()
{ {
ShowStatusMessage(message); ShowStatusMessage(message);
...@@ -325,7 +325,7 @@ void AdvancedCapture::btnTakePhoto_Click(Platform::Object^ sender, Windows::UI:: ...@@ -325,7 +325,7 @@ void AdvancedCapture::btnTakePhoto_Click(Platform::Object^ sender, Windows::UI::
EnableButton(false, "TakePhoto"); EnableButton(false, "TakePhoto");
auto currentRotation = GetCurrentPhotoRotation(); auto currentRotation = GetCurrentPhotoRotation();
task<StorageFile^>(KnownFolders::PicturesLibrary->CreateFileAsync(TEMP_PHOTO_FILE_NAME, Windows::Storage::CreationCollisionOption::GenerateUniqueName)).then([this, currentRotation](task<StorageFile^> getFileTask) task<StorageFile^>(KnownFolders::PicturesLibrary->CreateFileAsync(TEMP_PHOTO_FILE_NAME, Windows::Storage::CreationCollisionOption::GenerateUniqueName)).then([this, currentRotation](task<StorageFile^> getFileTask)
{ {
try try
{ {
...@@ -520,7 +520,7 @@ void AdvancedCapture::lstEnumedDevices_SelectionChanged(Platform::Object^ sender ...@@ -520,7 +520,7 @@ void AdvancedCapture::lstEnumedDevices_SelectionChanged(Platform::Object^ sender
} }
}); });
} }
btnStartDevice2->IsEnabled = true; btnStartDevice2->IsEnabled = true;
btnStartPreview2->IsEnabled = false; btnStartPreview2->IsEnabled = false;
btnStartStopRecord2->IsEnabled = false; btnStartStopRecord2->IsEnabled = false;
...@@ -581,12 +581,12 @@ void AdvancedCapture::EnumerateWebcamsAsync() ...@@ -581,12 +581,12 @@ void AdvancedCapture::EnumerateWebcamsAsync()
} }
void AdvancedCapture::AddEffectToImageStream() void AdvancedCapture::AddEffectToImageStream()
{ {
auto mediaCapture = m_mediaCaptureMgr.Get(); auto mediaCapture = m_mediaCaptureMgr.Get();
Windows::Media::Capture::VideoDeviceCharacteristic charecteristic = mediaCapture->MediaCaptureSettings->VideoDeviceCharacteristic; Windows::Media::Capture::VideoDeviceCharacteristic charecteristic = mediaCapture->MediaCaptureSettings->VideoDeviceCharacteristic;
if((charecteristic != Windows::Media::Capture::VideoDeviceCharacteristic::AllStreamsIdentical) && if((charecteristic != Windows::Media::Capture::VideoDeviceCharacteristic::AllStreamsIdentical) &&
(charecteristic != Windows::Media::Capture::VideoDeviceCharacteristic::PreviewPhotoStreamsIdentical) && (charecteristic != Windows::Media::Capture::VideoDeviceCharacteristic::PreviewPhotoStreamsIdentical) &&
(charecteristic != Windows::Media::Capture::VideoDeviceCharacteristic::RecordPhotoStreamsIdentical)) (charecteristic != Windows::Media::Capture::VideoDeviceCharacteristic::RecordPhotoStreamsIdentical))
{ {
Windows::Media::MediaProperties::IMediaEncodingProperties ^props = mediaCapture->VideoDeviceController->GetMediaStreamProperties(Windows::Media::Capture::MediaStreamType::Photo); Windows::Media::MediaProperties::IMediaEncodingProperties ^props = mediaCapture->VideoDeviceController->GetMediaStreamProperties(Windows::Media::Capture::MediaStreamType::Photo);
...@@ -596,13 +596,13 @@ void AdvancedCapture::AddEffectToImageStream() ...@@ -596,13 +596,13 @@ void AdvancedCapture::AddEffectToImageStream()
Windows::Foundation::Collections::IVectorView<Windows::Media::MediaProperties::IMediaEncodingProperties^>^ supportedPropsList = mediaCapture->VideoDeviceController->GetAvailableMediaStreamProperties(Windows::Media::Capture::MediaStreamType::Photo); Windows::Foundation::Collections::IVectorView<Windows::Media::MediaProperties::IMediaEncodingProperties^>^ supportedPropsList = mediaCapture->VideoDeviceController->GetAvailableMediaStreamProperties(Windows::Media::Capture::MediaStreamType::Photo);
{ {
unsigned int i = 0; unsigned int i = 0;
while (i< supportedPropsList->Size) while (i < supportedPropsList->Size)
{ {
Windows::Media::MediaProperties::IMediaEncodingProperties^ props = supportedPropsList->GetAt(i); Windows::Media::MediaProperties::IMediaEncodingProperties^ props = supportedPropsList->GetAt(i);
String^ s = props->Type; String^ s = props->Type;
if(props->Type->Equals("Video")) if(props->Type->Equals("Video"))
{ {
task<void>(mediaCapture->VideoDeviceController->SetMediaStreamPropertiesAsync(Windows::Media::Capture::MediaStreamType::Photo,props)).then([this](task<void> changeTypeTask) task<void>(mediaCapture->VideoDeviceController->SetMediaStreamPropertiesAsync(Windows::Media::Capture::MediaStreamType::Photo,props)).then([this](task<void> changeTypeTask)
{ {
try try
...@@ -616,7 +616,7 @@ void AdvancedCapture::AddEffectToImageStream() ...@@ -616,7 +616,7 @@ void AdvancedCapture::AddEffectToImageStream()
{ {
effectTask3.get(); effectTask3.get();
m_bEffectAddedToPhoto = true; m_bEffectAddedToPhoto = true;
ShowStatusMessage("Adding effect to photo stream successful"); ShowStatusMessage("Adding effect to photo stream successful");
chkAddRemoveEffect->IsEnabled = true; chkAddRemoveEffect->IsEnabled = true;
} }
...@@ -633,8 +633,7 @@ void AdvancedCapture::AddEffectToImageStream() ...@@ -633,8 +633,7 @@ void AdvancedCapture::AddEffectToImageStream()
{ {
ShowExceptionMessage(e); ShowExceptionMessage(e);
chkAddRemoveEffect->IsEnabled = true; chkAddRemoveEffect->IsEnabled = true;
chkAddRemoveEffect->IsChecked = false; chkAddRemoveEffect->IsChecked = false;
} }
}); });
...@@ -686,8 +685,8 @@ void AdvancedCapture::chkAddRemoveEffect_Checked(Platform::Object^ sender, Windo ...@@ -686,8 +685,8 @@ void AdvancedCapture::chkAddRemoveEffect_Checked(Platform::Object^ sender, Windo
auto mediaCapture = m_mediaCaptureMgr.Get(); auto mediaCapture = m_mediaCaptureMgr.Get();
Windows::Media::Capture::VideoDeviceCharacteristic charecteristic = mediaCapture->MediaCaptureSettings->VideoDeviceCharacteristic; Windows::Media::Capture::VideoDeviceCharacteristic charecteristic = mediaCapture->MediaCaptureSettings->VideoDeviceCharacteristic;
ShowStatusMessage("Add effect successful to preview stream successful"); ShowStatusMessage("Add effect successful to preview stream successful");
if((charecteristic != Windows::Media::Capture::VideoDeviceCharacteristic::AllStreamsIdentical) && if((charecteristic != Windows::Media::Capture::VideoDeviceCharacteristic::AllStreamsIdentical) &&
(charecteristic != Windows::Media::Capture::VideoDeviceCharacteristic::PreviewRecordStreamsIdentical)) (charecteristic != Windows::Media::Capture::VideoDeviceCharacteristic::PreviewRecordStreamsIdentical))
{ {
Windows::Media::MediaProperties::IMediaEncodingProperties ^props = mediaCapture->VideoDeviceController->GetMediaStreamProperties(Windows::Media::Capture::MediaStreamType::VideoRecord); Windows::Media::MediaProperties::IMediaEncodingProperties ^props = mediaCapture->VideoDeviceController->GetMediaStreamProperties(Windows::Media::Capture::MediaStreamType::VideoRecord);
...@@ -703,14 +702,14 @@ void AdvancedCapture::chkAddRemoveEffect_Checked(Platform::Object^ sender, Windo ...@@ -703,14 +702,14 @@ void AdvancedCapture::chkAddRemoveEffect_Checked(Platform::Object^ sender, Windo
m_bEffectAddedToRecord = true; m_bEffectAddedToRecord = true;
AddEffectToImageStream(); AddEffectToImageStream();
chkAddRemoveEffect->IsEnabled = true; chkAddRemoveEffect->IsEnabled = true;
} }
catch(Exception ^e) catch(Exception ^e)
{ {
ShowExceptionMessage(e); ShowExceptionMessage(e);
chkAddRemoveEffect->IsEnabled = true; chkAddRemoveEffect->IsEnabled = true;
chkAddRemoveEffect->IsChecked = false; chkAddRemoveEffect->IsChecked = false;
} }
}); });
} }
else else
{ {
...@@ -718,7 +717,7 @@ void AdvancedCapture::chkAddRemoveEffect_Checked(Platform::Object^ sender, Windo ...@@ -718,7 +717,7 @@ void AdvancedCapture::chkAddRemoveEffect_Checked(Platform::Object^ sender, Windo
chkAddRemoveEffect->IsEnabled = true; chkAddRemoveEffect->IsEnabled = true;
} }
} }
else else
{ {
AddEffectToImageStream(); AddEffectToImageStream();
...@@ -777,7 +776,7 @@ void AdvancedCapture::chkAddRemoveEffect_Unchecked(Platform::Object^ sender, Win ...@@ -777,7 +776,7 @@ void AdvancedCapture::chkAddRemoveEffect_Unchecked(Platform::Object^ sender, Win
{ {
ShowExceptionMessage(e); ShowExceptionMessage(e);
chkAddRemoveEffect->IsEnabled = true; chkAddRemoveEffect->IsEnabled = true;
chkAddRemoveEffect->IsChecked = true; chkAddRemoveEffect->IsChecked = true;
} }
}); });
...@@ -791,7 +790,7 @@ void AdvancedCapture::chkAddRemoveEffect_Unchecked(Platform::Object^ sender, Win ...@@ -791,7 +790,7 @@ void AdvancedCapture::chkAddRemoveEffect_Unchecked(Platform::Object^ sender, Win
{ {
ShowExceptionMessage(e); ShowExceptionMessage(e);
chkAddRemoveEffect->IsEnabled = true; chkAddRemoveEffect->IsEnabled = true;
chkAddRemoveEffect->IsChecked = true; chkAddRemoveEffect->IsChecked = true;
} }
...@@ -813,7 +812,7 @@ void AdvancedCapture::chkAddRemoveEffect_Unchecked(Platform::Object^ sender, Win ...@@ -813,7 +812,7 @@ void AdvancedCapture::chkAddRemoveEffect_Unchecked(Platform::Object^ sender, Win
{ {
ShowExceptionMessage(e); ShowExceptionMessage(e);
chkAddRemoveEffect->IsEnabled = true; chkAddRemoveEffect->IsEnabled = true;
chkAddRemoveEffect->IsChecked = true; chkAddRemoveEffect->IsChecked = true;
} }
}); });
...@@ -821,7 +820,7 @@ void AdvancedCapture::chkAddRemoveEffect_Unchecked(Platform::Object^ sender, Win ...@@ -821,7 +820,7 @@ void AdvancedCapture::chkAddRemoveEffect_Unchecked(Platform::Object^ sender, Win
else else
{ {
chkAddRemoveEffect->IsEnabled = true; chkAddRemoveEffect->IsEnabled = true;
chkAddRemoveEffect->IsChecked = true; chkAddRemoveEffect->IsChecked = true;
} }
} }
catch (Exception ^e) catch (Exception ^e)
...@@ -1032,3 +1031,9 @@ Windows::Media::Capture::VideoRotation AdvancedCapture::VideoRotationLookup( ...@@ -1032,3 +1031,9 @@ Windows::Media::Capture::VideoRotation AdvancedCapture::VideoRotationLookup(
} }
} }
void SDKSample::MediaCapture::AdvancedCapture::EffectType_SelectionChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ e)
{
}
...@@ -98,6 +98,7 @@ namespace SDKSample ...@@ -98,6 +98,7 @@ namespace SDKSample
bool m_bRotateVideoOnOrientationChange; bool m_bRotateVideoOnOrientationChange;
bool m_bReversePreviewRotation; bool m_bReversePreviewRotation;
Windows::Foundation::EventRegistrationToken m_orientationChangedEventToken; Windows::Foundation::EventRegistrationToken m_orientationChangedEventToken;
void EffectType_SelectionChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ e);
}; };
} }
} }
...@@ -116,17 +116,7 @@ ...@@ -116,17 +116,7 @@
<ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Image Grid.Row="0" Source="Assets/microsoft-sdk.png" AutomationProperties.Name="Microsoft Logo" Stretch="None" HorizontalAlignment="Left"/> <StackPanel x:Name="FooterPanel" Orientation="Horizontal" Grid.Row="1" Grid.Column="1" HorizontalAlignment="Right"/>
<TextBlock Style="{StaticResource FooterStyle}" Text="© Microsoft Corporation. All rights reserved." TextWrapping="Wrap" Grid.Row="1" HorizontalAlignment="Left"/>
<StackPanel x:Name="FooterPanel" Orientation="Horizontal" Grid.Row="1" Grid.Column="1" HorizontalAlignment="Right">
<HyperlinkButton Content="Terms of use" Tag="http://www.microsoft.com/About/Legal/EN/US/IntellectualProperty/Copyright/default.aspx"
Click="Footer_Click" FontSize="12" Style="{StaticResource HyperlinkStyle}"/>
<TextBlock Text="|" Style="{StaticResource SeparatorStyle}" VerticalAlignment="Center"/>
<HyperlinkButton Content="Trademarks" Tag="http://www.microsoft.com/About/Legal/EN/US/IntellectualProperty/Trademarks/EN-US.aspx"
Click="Footer_Click" FontSize="12" Style="{StaticResource HyperlinkStyle}"/>
<TextBlock Text="|" Style="{StaticResource SeparatorStyle}" VerticalAlignment="Center"/>
<HyperlinkButton Content="Privacy Statement" Tag="http://privacy.microsoft.com" Click="Footer_Click" FontSize="12" Style="{StaticResource HyperlinkStyle}"/>
</StackPanel>
</Grid> </Grid>
......
...@@ -37,18 +37,18 @@ DEFINE_GUID(CLSID_GrayscaleMFT, ...@@ -37,18 +37,18 @@ DEFINE_GUID(CLSID_GrayscaleMFT,
// Configuration attributes // Configuration attributes
// {698649BE-8EAE-4551-A4CB-3EC98FBD3D86}
DEFINE_GUID(MFT_IMAGE_EFFECT,
0x698649be, 0x8eae, 0x4551, 0xa4, 0xcb, 0x3e, 0xc9, 0x8f, 0xbd, 0x3d, 0x86);
// {7BBBB051-133B-41F5-B6AA-5AFF9B33A2CB}
DEFINE_GUID(MFT_GRAYSCALE_DESTINATION_RECT,
0x7bbbb051, 0x133b, 0x41f5, 0xb6, 0xaa, 0x5a, 0xff, 0x9b, 0x33, 0xa2, 0xcb);
enum ProcessingType enum ProcessingType
{ {
Preview, GrayScale,
GrayScale, Canny,
Canny, Sobel,
Zoom, Histogram,
Sepia InvalidEffect
}; };
template <class T> void SafeRelease(T **ppT) template <class T> void SafeRelease(T **ppT)
...@@ -63,9 +63,9 @@ template <class T> void SafeRelease(T **ppT) ...@@ -63,9 +63,9 @@ template <class T> void SafeRelease(T **ppT)
// CGrayscale class: // CGrayscale class:
// Implements a grayscale video effect. // Implements a grayscale video effect.
class CGrayscale class CGrayscale
: public Microsoft::WRL::RuntimeClass< : public Microsoft::WRL::RuntimeClass<
Microsoft::WRL::RuntimeClassFlags< Microsoft::WRL::RuntimeClassType::WinRtClassicComMix >, Microsoft::WRL::RuntimeClassFlags< Microsoft::WRL::RuntimeClassType::WinRtClassicComMix >,
ABI::Windows::Media::IMediaExtension, ABI::Windows::Media::IMediaExtension,
IMFTransform > IMFTransform >
{ {
...@@ -231,7 +231,7 @@ private: ...@@ -231,7 +231,7 @@ private:
CRITICAL_SECTION m_critSec; CRITICAL_SECTION m_critSec;
// Transformation parameters // Transformation parameters
ProcessingType m_TransformType; ProcessingType m_TransformType;
D2D_RECT_U m_rcDest; // Destination rectangle for the effect. D2D_RECT_U m_rcDest; // Destination rectangle for the effect.
// Streaming // Streaming
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment