Skip to content

Commit

Permalink
Interfaces for "Enhanced UX Notification for Video and Audio Call Fea…
Browse files Browse the repository at this point in the history
…ture" (#4783)
  • Loading branch information
satkh authored Nov 22, 2024
1 parent c9eebef commit 5a41e3b
Show file tree
Hide file tree
Showing 26 changed files with 537 additions and 24 deletions.
13 changes: 13 additions & 0 deletions dev/AppNotifications/AppNotification.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,17 @@ namespace winrt::Microsoft::Windows::AppNotifications::implementation
auto lock{ m_lock.lock_exclusive() };
m_notificationId = id;
}

winrt::Microsoft::Windows::AppNotifications::AppNotificationConferencingConfig AppNotification::ConferencingConfig()
{
auto lock{ m_lock.lock_shared() };
return m_conferencingConfig;
}

void AppNotification::ConferencingConfig(winrt::Microsoft::Windows::AppNotifications::AppNotificationConferencingConfig const& conferencingConfig)
{
THROW_HR_IF(E_NOTIMPL, !AppNotificationConferencingConfig::IsCallingPreviewSupported());
auto lock{ m_lock.lock_exclusive() };
m_conferencingConfig = conferencingConfig;
}
}
5 changes: 5 additions & 0 deletions dev/AppNotifications/AppNotification.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ namespace winrt::Microsoft::Windows::AppNotifications::implementation
// IAppNotificationInternal
void SetNotificationId(uint32_t id);

winrt::Microsoft::Windows::AppNotifications::AppNotificationConferencingConfig ConferencingConfig();
void ConferencingConfig(winrt::Microsoft::Windows::AppNotifications::AppNotificationConferencingConfig const& value);

private:
winrt::hstring m_tag{};
winrt::hstring m_group{};
Expand All @@ -49,6 +52,8 @@ namespace winrt::Microsoft::Windows::AppNotifications::implementation
{ winrt::Microsoft::Windows::AppNotifications::AppNotificationPriority::Default };
bool m_suppressDisplay{ false };
wil::srwlock m_lock;

winrt::Microsoft::Windows::AppNotifications::AppNotificationConferencingConfig m_conferencingConfig{ nullptr };
};
}
namespace winrt::Microsoft::Windows::AppNotifications::factory_implementation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

#include "pch.h"
Expand Down Expand Up @@ -376,14 +376,15 @@ namespace winrt::Microsoft::Windows::AppNotifications::Builder::implementation
// Build the actions string and fill m_useButtonStyle
std::wstring actions{ GetActions() };

auto xmlResult{ wil::str_printf<std::wstring>(L"<toast%ls%ls%ls%ls%ls><visual><binding template='ToastGeneric'>%ls%ls%ls%ls</binding></visual>%ls%ls</toast>",
auto xmlResult{ wil::str_printf<std::wstring>(L"<toast%ls%ls%ls%ls%ls><visual><binding template='ToastGeneric'>%ls%ls%ls%ls%ls</binding></visual>%ls%ls</toast>",
m_timeStamp.c_str(),
GetDuration().c_str(),
GetScenario().c_str(),
GetArguments().c_str(),
GetButtonStyle().c_str(),
GetText().c_str(),
m_attributionText.c_str(),
GetCameraPreview().c_str(),
GetImages().c_str(),
GetProgressBars().c_str(),
m_audio.c_str(),
Expand All @@ -399,4 +400,19 @@ namespace winrt::Microsoft::Windows::AppNotifications::Builder::implementation

return appNotification;
}

winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationBuilder AppNotificationBuilder::AddCameraPreview()
{
THROW_HR_IF(E_NOTIMPL, !AppNotificationConferencingConfig::IsCallingPreviewSupported());

THROW_HR_IF_MSG(E_INVALIDARG, m_useCameraPreview, "CameraPreview element is already added, only one is allowed");

m_useCameraPreview = true;
return *this;
}

std::wstring AppNotificationBuilder::GetCameraPreview()
{
return m_useCameraPreview ? L"<cameraPreview/>" : L"";
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

#pragma once
Expand Down Expand Up @@ -65,6 +65,8 @@ namespace winrt::Microsoft::Windows::AppNotifications::Builder::implementation

static bool IsUrgentScenarioSupported();

winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationBuilder AddCameraPreview();

private:
void ThrowIfMaxInputItemsExceeded();
std::wstring GetDuration();
Expand All @@ -75,6 +77,7 @@ namespace winrt::Microsoft::Windows::AppNotifications::Builder::implementation
std::wstring GetImages();
std::wstring GetActions();
std::wstring GetProgressBars();
std::wstring GetCameraPreview();

std::wstring m_timeStamp{};
AppNotificationDuration m_duration{ AppNotificationDuration::Default };
Expand All @@ -93,6 +96,7 @@ namespace winrt::Microsoft::Windows::AppNotifications::Builder::implementation
std::vector<AppNotificationComboBox> m_comboBoxList{};
winrt::hstring m_tag{};
winrt::hstring m_group{};
bool m_useCameraPreview{false};
};
}
namespace winrt::Microsoft::Windows::AppNotifications::Builder::factory_implementation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

import "..\AppNotifications\AppNotifications.idl";
#include <TerminalVelocityFeatures-CallingPreviewSupport.h>

namespace Microsoft.Windows.AppNotifications.Builder
{
[contractversion(1)]
[contractversion(2)]
apicontract AppNotificationBuilderContract {}

[contract(AppNotificationBuilderContract, 1)]
Expand All @@ -31,6 +32,14 @@ namespace Microsoft.Windows.AppNotifications.Builder
Critical,
};

[contract(AppNotificationBuilderContract, 2), feature(Feature_CallingPreviewSupport)]
enum AppNotificationButtonSettingStyle
{
None,
VideoCallConfig,
AudioCallConfig,
};

[contract(AppNotificationBuilderContract, 1)]
runtimeclass AppNotificationButton
{
Expand Down Expand Up @@ -69,6 +78,10 @@ namespace Microsoft.Windows.AppNotifications.Builder
// Launches the URI passed into the button when activated.
AppNotificationButton SetInvokeUri(Windows.Foundation.Uri protocolUri);
AppNotificationButton SetInvokeUri(Windows.Foundation.Uri protocolUri, String targetAppId);

// Sets the setting type for the button.
[contract(AppNotificationBuilderContract, 2), feature(Feature_CallingPreviewSupport)]
AppNotificationButton SetSettingStyle(AppNotificationButtonSettingStyle value);
};

[contract(AppNotificationBuilderContract, 1)]
Expand Down Expand Up @@ -242,5 +255,9 @@ namespace Microsoft.Windows.AppNotifications.Builder
// AppNotification properties
AppNotificationBuilder SetTag(String value);
AppNotificationBuilder SetGroup(String group);

// Adds a camera preview to the AppNotification
[contract(AppNotificationBuilderContract, 2), feature(Feature_CallingPreviewSupport)]
AppNotificationBuilder AddCameraPreview();
};
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

#include "pch.h"
Expand Down Expand Up @@ -121,17 +121,39 @@ namespace winrt::Microsoft::Windows::AppNotifications::Builder::implementation
{
auto logTelemetry{ AppNotificationBuilderTelemetry::ButtonToString::Start(g_telemetryHelper) };

std::wstring xmlResult{ wil::str_printf<std::wstring>(L"<action content='%ls'%ls%ls%ls%ls%ls%ls/>",
std::wstring xmlResult{ wil::str_printf<std::wstring>(L"<action content='%ls'%ls%ls%ls%ls%ls%ls%ls/>",
m_content.c_str(),
GetActivationArguments().c_str(),
m_useContextMenuPlacement ? L" placement='contextMenu'" : L"",
m_iconUri ? wil::str_printf<std::wstring>(L" imageUri='%ls'", m_iconUri.ToString().c_str()).c_str() : L"",
!m_inputId.empty() ? wil::str_printf<std::wstring>(L" hint-inputId='%ls'", m_inputId.c_str()).c_str() : L"",
GetButtonStyle().c_str(),
!m_toolTip.empty() ? wil::str_printf<std::wstring>(L" hint-toolTip='%ls'", m_toolTip.c_str()).c_str() : L"") };
!m_toolTip.empty() ? wil::str_printf<std::wstring>(L" hint-toolTip='%ls'", m_toolTip.c_str()).c_str() : L"",
GetSettingStyle().c_str()) };

logTelemetry.Stop();

return xmlResult.c_str();
}

winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationButton AppNotificationButton::SetSettingStyle(AppNotificationButtonSettingStyle const& value)
{
THROW_HR_IF(E_NOTIMPL, !AppNotificationConferencingConfig::IsCallingPreviewSupported());

m_settingType = value;
return *this;
}

std::wstring AppNotificationButton::GetSettingStyle()
{
switch (m_settingType)
{
case AppNotificationButtonSettingStyle::VideoCallConfig:
return L" settingType='videoDevices'";
case AppNotificationButtonSettingStyle::AudioCallConfig:
return L" settingType='audioDevices'";
default: // AppNotificationButtonSettingStyle::None
return L"";
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

#pragma once
Expand Down Expand Up @@ -60,9 +60,12 @@ namespace winrt::Microsoft::Windows::AppNotifications::Builder::implementation

winrt::hstring ToString();

winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationButton SetSettingStyle(AppNotificationButtonSettingStyle const& value);

private:
std::wstring GetActivationArguments();
std::wstring GetButtonStyle();
std::wstring GetSettingStyle();

winrt::hstring m_content{};
winrt::Windows::Foundation::Collections::IMap<winrt::hstring, winrt::hstring> m_arguments { winrt::single_threaded_map<winrt::hstring, winrt::hstring>() };
Expand All @@ -73,6 +76,7 @@ namespace winrt::Microsoft::Windows::AppNotifications::Builder::implementation
winrt::hstring m_inputId{};
bool m_useContextMenuPlacement{};
AppNotificationButtonStyle m_buttonStyle { AppNotificationButtonStyle::Default };
AppNotificationButtonSettingStyle m_settingType{ AppNotificationButtonSettingStyle::None };
};
}
namespace winrt::Microsoft::Windows::AppNotifications::Builder::factory_implementation
Expand Down
50 changes: 50 additions & 0 deletions dev/AppNotifications/AppNotificationConferencingConfig.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

#include "pch.h"
#include "AppNotificationConferencingConfig.h"
#include "Microsoft.Windows.AppNotifications.AppNotificationConferencingConfig.g.cpp"
#include <IsWindowsVersion.h>

namespace winrt::Microsoft::Windows::AppNotifications::implementation
{
hstring AppNotificationConferencingConfig::VideoDeviceId()
{
return m_videoDeviceId;
}

void AppNotificationConferencingConfig::VideoDeviceId(hstring const& value)
{
THROW_HR_IF(E_NOTIMPL, !IsCallingPreviewSupported());
m_videoDeviceId = value;
}

hstring AppNotificationConferencingConfig::AudioInputDeviceId()
{
return m_audioInputDeviceId;
}

void AppNotificationConferencingConfig::AudioInputDeviceId(hstring const& value)
{
THROW_HR_IF(E_NOTIMPL, !IsCallingPreviewSupported());
m_audioInputDeviceId = value;
}

hstring AppNotificationConferencingConfig::AudioOutputDeviceId()
{
return m_audioOutputDeviceId;
}

void AppNotificationConferencingConfig::AudioOutputDeviceId(hstring const& value)
{
THROW_HR_IF(E_NOTIMPL, !IsCallingPreviewSupported());
m_audioOutputDeviceId = value;
}

///Checks if the calling preview feature is supported on the current OS version
///TO DO - This method needs implementation on framework UDK, for now it always returns false
bool AppNotificationConferencingConfig::IsCallingPreviewSupported()
{
return false;
}
}
37 changes: 37 additions & 0 deletions dev/AppNotifications/AppNotificationConferencingConfig.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

#pragma once
#include "Microsoft.Windows.AppNotifications.AppNotificationConferencingConfig.g.h"

namespace winrt::Microsoft::Windows::AppNotifications::implementation
{
struct AppNotificationConferencingConfig : AppNotificationConferencingConfigT<AppNotificationConferencingConfig>
{
AppNotificationConferencingConfig() = default;

// Getters
hstring VideoDeviceId();
hstring AudioInputDeviceId();
hstring AudioOutputDeviceId();

// Setters
void VideoDeviceId(hstring const& value);
void AudioInputDeviceId(hstring const& value);
void AudioOutputDeviceId(hstring const& value);

static bool IsCallingPreviewSupported();

private:

hstring m_videoDeviceId{};
hstring m_audioInputDeviceId{};
hstring m_audioOutputDeviceId{};
};
}
namespace winrt::Microsoft::Windows::AppNotifications::factory_implementation
{
struct AppNotificationConferencingConfig : AppNotificationConferencingConfigT<AppNotificationConferencingConfig, implementation::AppNotificationConferencingConfig>
{
};
}
3 changes: 2 additions & 1 deletion dev/AppNotifications/AppNotificationManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,8 @@ namespace winrt::Microsoft::Windows::AppNotifications::implementation
m_appId,
notification.Payload(),
notification.Tag(),
notification.Group()) };
notification.Group(),
winrt::AppNotificationConferencingConfig::IsCallingPreviewSupported()) };

THROW_HR_IF(WPN_E_NOTIFICATION_POSTED, notification.Id() != 0);

Expand Down
8 changes: 5 additions & 3 deletions dev/AppNotifications/AppNotificationTelemetry.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT license.

#pragma once
Expand Down Expand Up @@ -62,7 +62,8 @@ class AppNotificationTelemetry : public wil::TraceLoggingProvider
std::wstring const& appId,
winrt::hstring const& payload,
winrt::hstring const& tag,
winrt::hstring const& group) noexcept try
winrt::hstring const& group,
bool isCallingPreviewSupported) noexcept try
{
TraceLoggingClassWriteStart(
Show,
Expand All @@ -72,7 +73,8 @@ class AppNotificationTelemetry : public wil::TraceLoggingProvider
TraceLoggingUInt32(tag.size(), "TagSize"),
TraceLoggingUInt32(group.size(), "GroupSize"),
TraceLoggingBool(notificationTelemetryHelper.IsPackagedApp(), "IsAppPackaged"),
TraceLoggingWideString(notificationTelemetryHelper.GetAppName().c_str(), "AppName"));
TraceLoggingWideString(notificationTelemetryHelper.GetAppName().c_str(), "AppName"),
TraceLoggingBool(isCallingPreviewSupported, "IsCallingPreviewSupported"));
}
CATCH_LOG()
END_ACTIVITY_CLASS();
Expand Down
Loading

0 comments on commit 5a41e3b

Please sign in to comment.