diff --git a/Build/Interactivity.UWP.Cpp/Interactivity.UWP.Cpp.sln b/Build/Interactivity.UWP.Cpp/Interactivity.UWP.Cpp.sln index 628d792..0a3abac 100644 --- a/Build/Interactivity.UWP.Cpp/Interactivity.UWP.Cpp.sln +++ b/Build/Interactivity.UWP.Cpp/Interactivity.UWP.Cpp.sln @@ -3,14 +3,14 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 VisualStudioVersion = 14.0.25420.1 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Interactivity.UWP.Cpp", "Interactivity.UWP.Cpp.vcxproj", "{85B33AF2-99F7-49A7-AE3B-F3B167922434}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Interactivity.UWP.Cpp", "Interactivity.UWP.Cpp.vcxproj", "{8F96710E-5169-4917-8874-7DE248F4D243}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cpprestsdk140.uwp.static", "..\..\cpprestsdk\Release\src\build\vs14.uwp\cpprestsdk140.uwp.static.vcxproj", "{47A5CFDC-C244-45A6-9830-38CB303CB495}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cpprestsdk140.uwp.static", "..\..\cpprestsdk\Release\src\build\vs14.uwp\cpprestsdk140.uwp.static.vcxproj", "{9AD285A2-301E-47A0-A299-14AD5D4F2758}" EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution - ..\..\cpprestsdk\Release\src\build\common.vcxitems*{47a5cfdc-c244-45a6-9830-38cb303cb495}*SharedItemsImports = 4 - ..\..\cpprestsdk\Release\src\build\winrt.vcxitems*{47a5cfdc-c244-45a6-9830-38cb303cb495}*SharedItemsImports = 4 + ..\..\cpprestsdk\Release\src\build\common.vcxitems*{9ad285a2-301e-47a0-a299-14ad5d4f2758}*SharedItemsImports = 4 + ..\..\cpprestsdk\Release\src\build\winrt.vcxitems*{9ad285a2-301e-47a0-a299-14ad5d4f2758}*SharedItemsImports = 4 EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -19,22 +19,22 @@ Global Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {85B33AF2-99F7-49A7-AE3B-F3B167922434}.Debug|x64.ActiveCfg = Debug|x64 - {85B33AF2-99F7-49A7-AE3B-F3B167922434}.Debug|x64.Build.0 = Debug|x64 - {85B33AF2-99F7-49A7-AE3B-F3B167922434}.Debug|x86.ActiveCfg = Debug|Win32 - {85B33AF2-99F7-49A7-AE3B-F3B167922434}.Debug|x86.Build.0 = Debug|Win32 - {85B33AF2-99F7-49A7-AE3B-F3B167922434}.Release|x64.ActiveCfg = Release|x64 - {85B33AF2-99F7-49A7-AE3B-F3B167922434}.Release|x64.Build.0 = Release|x64 - {85B33AF2-99F7-49A7-AE3B-F3B167922434}.Release|x86.ActiveCfg = Release|Win32 - {85B33AF2-99F7-49A7-AE3B-F3B167922434}.Release|x86.Build.0 = Release|Win32 - {47A5CFDC-C244-45A6-9830-38CB303CB495}.Debug|x64.ActiveCfg = Debug|x64 - {47A5CFDC-C244-45A6-9830-38CB303CB495}.Debug|x64.Build.0 = Debug|x64 - {47A5CFDC-C244-45A6-9830-38CB303CB495}.Debug|x86.ActiveCfg = Debug|Win32 - {47A5CFDC-C244-45A6-9830-38CB303CB495}.Debug|x86.Build.0 = Debug|Win32 - {47A5CFDC-C244-45A6-9830-38CB303CB495}.Release|x64.ActiveCfg = Release|x64 - {47A5CFDC-C244-45A6-9830-38CB303CB495}.Release|x64.Build.0 = Release|x64 - {47A5CFDC-C244-45A6-9830-38CB303CB495}.Release|x86.ActiveCfg = Release|Win32 - {47A5CFDC-C244-45A6-9830-38CB303CB495}.Release|x86.Build.0 = Release|Win32 + {8F96710E-5169-4917-8874-7DE248F4D243}.Debug|x64.ActiveCfg = Debug|x64 + {8F96710E-5169-4917-8874-7DE248F4D243}.Debug|x64.Build.0 = Debug|x64 + {8F96710E-5169-4917-8874-7DE248F4D243}.Debug|x86.ActiveCfg = Debug|Win32 + {8F96710E-5169-4917-8874-7DE248F4D243}.Debug|x86.Build.0 = Debug|Win32 + {8F96710E-5169-4917-8874-7DE248F4D243}.Release|x64.ActiveCfg = Release|x64 + {8F96710E-5169-4917-8874-7DE248F4D243}.Release|x64.Build.0 = Release|x64 + {8F96710E-5169-4917-8874-7DE248F4D243}.Release|x86.ActiveCfg = Release|Win32 + {8F96710E-5169-4917-8874-7DE248F4D243}.Release|x86.Build.0 = Release|Win32 + {9AD285A2-301E-47A0-A299-14AD5D4F2758}.Debug|x64.ActiveCfg = Debug|x64 + {9AD285A2-301E-47A0-A299-14AD5D4F2758}.Debug|x64.Build.0 = Debug|x64 + {9AD285A2-301E-47A0-A299-14AD5D4F2758}.Debug|x86.ActiveCfg = Debug|Win32 + {9AD285A2-301E-47A0-A299-14AD5D4F2758}.Debug|x86.Build.0 = Debug|Win32 + {9AD285A2-301E-47A0-A299-14AD5D4F2758}.Release|x64.ActiveCfg = Release|x64 + {9AD285A2-301E-47A0-A299-14AD5D4F2758}.Release|x64.Build.0 = Release|x64 + {9AD285A2-301E-47A0-A299-14AD5D4F2758}.Release|x86.ActiveCfg = Release|Win32 + {9AD285A2-301E-47A0-A299-14AD5D4F2758}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Build/Interactivity.UWP.Cpp/Interactivity.UWP.Cpp.vcxproj b/Build/Interactivity.UWP.Cpp/Interactivity.UWP.Cpp.vcxproj index 6e7d2d8..edfb35a 100644 --- a/Build/Interactivity.UWP.Cpp/Interactivity.UWP.Cpp.vcxproj +++ b/Build/Interactivity.UWP.Cpp/Interactivity.UWP.Cpp.vcxproj @@ -59,12 +59,9 @@ + - - - - Create @@ -75,11 +72,10 @@ + - - @@ -142,5 +138,8 @@ $(ProjectDir)..\..\Binaries\$(Configuration)\$(Platform)\$(ProjectFolder)\ $(ProjectDir)..\..\Obj\$(Configuration)\$(Platform)\$(ProjectFolder)\ + + $(VC_IncludePath);$(WindowsSDK_IncludePath); + \ No newline at end of file diff --git a/Build/Interactivity.UWP.Cpp/Interactivity.UWP.Cpp.vcxproj.filters b/Build/Interactivity.UWP.Cpp/Interactivity.UWP.Cpp.vcxproj.filters index cc9ba83..3dcc00d 100644 --- a/Build/Interactivity.UWP.Cpp/Interactivity.UWP.Cpp.vcxproj.filters +++ b/Build/Interactivity.UWP.Cpp/Interactivity.UWP.Cpp.vcxproj.filters @@ -39,16 +39,7 @@ C++ Source - - C++ Source - - - C++ Source - - - C++ Source - - + C++ Source @@ -74,18 +65,15 @@ Includes - - C++ Source - - - C++ Source - Includes Includes + + C++ Source + diff --git a/Build/Interactivity.UWP.Cpp/pch.cpp b/Build/Interactivity.UWP.Cpp/pch.cpp index 1730571..189f237 100644 --- a/Build/Interactivity.UWP.Cpp/pch.cpp +++ b/Build/Interactivity.UWP.Cpp/pch.cpp @@ -1 +1,13 @@ -#include "pch.h" \ No newline at end of file +#include "pch.h" + +#ifdef ANDROID +template< typename T > +std::string std::to_string(const T& item) { + + std::stringstream ss; + ss << item; + return ss.str(); + +} + +#endif \ No newline at end of file diff --git a/Build/Interactivity.Win32.Cpp/Interactivity.Win32.Cpp.sln b/Build/Interactivity.Win32.Cpp/Interactivity.Win32.Cpp.sln index e0c329f..74f2658 100644 --- a/Build/Interactivity.Win32.Cpp/Interactivity.Win32.Cpp.sln +++ b/Build/Interactivity.Win32.Cpp/Interactivity.Win32.Cpp.sln @@ -47,4 +47,7 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {B9B80CFD-EE01-4E7D-BF3A-97EB4AE34A0B} + EndGlobalSection EndGlobal diff --git a/Build/Interactivity.Win32.Cpp/Interactivity.Win32.Cpp.vcxproj b/Build/Interactivity.Win32.Cpp/Interactivity.Win32.Cpp.vcxproj index 7e441df..348e373 100644 --- a/Build/Interactivity.Win32.Cpp/Interactivity.Win32.Cpp.vcxproj +++ b/Build/Interactivity.Win32.Cpp/Interactivity.Win32.Cpp.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -22,9 +22,10 @@ {441F8169-F31E-4653-941E-25AC223CBAFB} Interactivity.Win32.Cpp Win32Proj + 10.0.15063.0 - v140 + v141 @@ -56,10 +57,7 @@ - - - - + Create @@ -73,15 +71,43 @@ - - + + $(MSBuildProjectName) $(ProjectDir)..\..\Binaries\$(Configuration)\$(Platform)\$(ProjectFolder)\ $(ProjectDir)..\..\Obj\$(Configuration)\$(Platform)\$(ProjectFolder)\ + + $(IncludePath) + static + static + static + static + + + $(IncludePath) + static + static + static + static + + + $(IncludePath) + static + static + static + static + + + $(IncludePath) + static + static + static + static + Use @@ -113,7 +139,7 @@ $(ProjectDir)\..\..\External\Packages\zlib.v140.windesktop.msvcstl.static.rt-dyn.1.2.8.8\lib\native\v140\windesktop\msvcstl\static\rt-dyn\$(Platform)\Release;%(AdditionalLibraryDirectories) $(ProjectDir)\..\..\External\Packages\openssl.v140.windesktop.msvcstl.static.rt-dyn.x64.1.0.2.0\lib\native\v140\windesktop\msvcstl\static\rt-dyn\x64\release;%(AdditionalLibraryDirectories) $(ProjectDir)\..\..\External\Packages\openssl.v140.windesktop.msvcstl.static.rt-dyn.x86.1.0.2.0\lib\native\v140\windesktop\msvcstl\static\rt-dyn\x86\release;%(AdditionalLibraryDirectories) - + @@ -135,10 +161,9 @@ address-model-32 address-model-64 - - - + + + - - + \ No newline at end of file diff --git a/Build/Interactivity.Win32.Cpp/Interactivity.Win32.Cpp.vcxproj.filters b/Build/Interactivity.Win32.Cpp/Interactivity.Win32.Cpp.vcxproj.filters index 6182d6b..ae2bd9b 100644 --- a/Build/Interactivity.Win32.Cpp/Interactivity.Win32.Cpp.vcxproj.filters +++ b/Build/Interactivity.Win32.Cpp/Interactivity.Win32.Cpp.vcxproj.filters @@ -12,18 +12,12 @@ Includes - - C++ Source - Includes Includes - - C++ Source - Includes @@ -42,6 +36,12 @@ Includes + + C++ Source + + + C++ Source + @@ -55,18 +55,6 @@ C++ Source - - C++ Source - - - C++ Source - - - C++ Source - - - C++ Source - C++ Source @@ -94,5 +82,8 @@ C++ Source + + C++ Source + \ No newline at end of file diff --git a/Build/Interactivity.Xbox.Cpp/Interactivity.Xbox.Cpp.vcxproj b/Build/Interactivity.Xbox.Cpp/Interactivity.Xbox.Cpp.vcxproj index bd709c7..ec17728 100644 --- a/Build/Interactivity.Xbox.Cpp/Interactivity.Xbox.Cpp.vcxproj +++ b/Build/Interactivity.Xbox.Cpp/Interactivity.Xbox.Cpp.vcxproj @@ -49,12 +49,9 @@ + - - - - Create Create @@ -68,11 +65,10 @@ + - - @@ -80,6 +76,12 @@ $(ProjectDir)..\..\Binaries\$(Configuration)\$(Platform)\$(ProjectFolder)\ $(ProjectDir)..\..\Obj\$(Configuration)\$(Platform)\$(ProjectFolder)\ + + $(IncludePath) + + + $(IncludePath) + Use diff --git a/Build/Interactivity.Xbox.Cpp/Interactivity.Xbox.Cpp.vcxproj.filters b/Build/Interactivity.Xbox.Cpp/Interactivity.Xbox.Cpp.vcxproj.filters index 6182d6b..435e091 100644 --- a/Build/Interactivity.Xbox.Cpp/Interactivity.Xbox.Cpp.vcxproj.filters +++ b/Build/Interactivity.Xbox.Cpp/Interactivity.Xbox.Cpp.vcxproj.filters @@ -12,18 +12,12 @@ Includes - - C++ Source - Includes Includes - - C++ Source - Includes @@ -42,6 +36,9 @@ Includes + + C++ Source + @@ -55,18 +52,6 @@ C++ Source - - C++ Source - - - C++ Source - - - C++ Source - - - C++ Source - C++ Source @@ -94,5 +79,8 @@ C++ Source + + C++ Source + \ No newline at end of file diff --git a/Include/interactivity.h b/Include/interactivity.h index 9b74104..1de405c 100644 --- a/Include/interactivity.h +++ b/Include/interactivity.h @@ -9,12 +9,18 @@ //********************************************************* #pragma once -namespace xbox { - namespace services { - namespace system { - class xbox_live_user; - } - } +#include "interactivity_types.h" +#include "..\Source\Util\mixer_debug.h" + +namespace xbox +{ +namespace services +{ +namespace system +{ +class xbox_live_user; +} +} } #if TV_API | XBOX_UWP @@ -23,12 +29,14 @@ typedef Windows::Xbox::System::User^ xbox_live_user_t; typedef std::shared_ptr xbox_live_user_t; #endif -namespace Microsoft { - /// - /// Contains classes and enumerations that let you incorporate - /// Interactivity functionality into your title. - /// - namespace mixer { +namespace Microsoft +{ +/// +/// Contains classes and enumerations that let you incorporate +/// Interactivity functionality into your title. +/// +namespace mixer +{ class interactivity_manager_impl; class interactivity_manager; @@ -46,20 +54,31 @@ class interactive_button_state; class interactive_joystick_state; class interactive_button_count; +struct ci_less +{ + // case-independent (ci) compare_less binary function + struct nocase_compare + { + bool operator() (const char_t& c1, const char_t& c2) const; + }; + + bool operator() (const string_t & s1, const string_t & s2) const; +}; + /// /// Enum that describes the types of control objects. /// enum interactive_control_type { - /// - /// The button control. - /// - button, - - /// - /// The joystick control. - /// - joystick + /// + /// The button control. + /// + button, + + /// + /// The joystick control. + /// + joystick }; /// @@ -67,35 +86,35 @@ enum interactive_control_type /// enum interactivity_state { - /// - /// The interactivity manager is not initialized. - /// - not_initialized, - - /// - /// The interactivity manager is initializing. - /// - initializing, - - /// - /// The interactivity manager is initialized. - /// - initialized, - - /// - /// The interactivity manager is initialized, but interactivity is not enabled. - /// - interactivity_disabled, - - /// - /// The interactivity manager is currently connecting to the interactive service. - /// - interactivity_pending, - - /// - /// Interactivity is enabled. - /// - interactivity_enabled + /// + /// The interactivity manager is not initialized. + /// + not_initialized, + + /// + /// The interactivity manager is initializing. + /// + initializing, + + /// + /// The interactivity manager is initialized. + /// + initialized, + + /// + /// The interactivity manager is initialized, but interactivity is not enabled. + /// + interactivity_disabled, + + /// + /// The interactivity manager is currently connecting to the interactive service. + /// + interactivity_pending, + + /// + /// Interactivity is enabled. + /// + interactivity_enabled }; @@ -104,20 +123,20 @@ enum interactivity_state /// enum interactive_participant_state { - /// - /// The participant joined the channel. - /// - joined, - - /// - /// The participant's input is disabled. - /// - input_disabled, - - /// - /// The participant left the channel. - /// - left + /// + /// The participant joined the channel. + /// + joined, + + /// + /// The participant's input is disabled. + /// + input_disabled, + + /// + /// The participant left the channel. + /// + left }; @@ -130,104 +149,104 @@ class interactive_participant { public: - /// - /// The Mixer ID of the user. - /// - _MIXERIMP uint32_t mixer_id() const; - - /// - /// The username of the user. - /// - _MIXERIMP const string_t& username() const; - - /// - /// The level of the user. - /// - _MIXERIMP uint32_t level() const; - - /// - /// The current state of the participant. - /// - _MIXERIMP const interactive_participant_state state() const; - - /// - /// Assigns the user to a specified group. This method - /// also updates the list of participants that are in this group. - /// - _MIXERIMP void set_group(std::shared_ptr group); - - /// - /// Returns a pointer to the group that the user is assigned to. - /// By default, participants are placed in a group named "default". - /// - _MIXERIMP const std::shared_ptr group(); - - /// - /// The time (in UTC) at which the user last used the interactive control input. - /// - _MIXERIMP const std::chrono::milliseconds& last_input_at() const; - - /// - /// The time (in UTC) at which the user connected to the Interactive stream. - /// - _MIXERIMP const std::chrono::milliseconds& connected_at() const; - - /// - /// A Boolean value that indicates whether or not the user input is disabled. - /// If TRUE, user input has been disabled. - /// - _MIXERIMP bool input_disabled() const; + /// + /// The Mixer ID of the user. + /// + _MIXERIMP uint32_t mixer_id() const; + + /// + /// The username of the user. + /// + _MIXERIMP const string_t& username() const; + + /// + /// The level of the user. + /// + _MIXERIMP uint32_t level() const; + + /// + /// The current state of the participant. + /// + _MIXERIMP const interactive_participant_state state() const; + + /// + /// Assigns the user to a specified group. This method + /// also updates the list of participants that are in this group. + /// + _MIXERIMP void set_group(std::shared_ptr group); + + /// + /// Returns a pointer to the group that the user is assigned to. + /// By default, participants are placed in a group named "default". + /// + _MIXERIMP const std::shared_ptr group(); + + /// + /// The time (in UTC) at which the user last used the interactive control input. + /// + _MIXERIMP const std::chrono::milliseconds& last_input_at() const; + + /// + /// The time (in UTC) at which the user connected to the Interactive stream. + /// + _MIXERIMP const std::chrono::milliseconds& connected_at() const; + + /// + /// A Boolean value that indicates whether or not the user input is disabled. + /// If TRUE, user input has been disabled. + /// + _MIXERIMP bool input_disabled() const; #if 0 - /// - /// Returns a particular button. If the button does not exist, - /// NULL is returned. - /// - _MIXERIMP const std::shared_ptr button(_In_ const string_t& controlId); - - /// - /// Returns buttons that the participant has interacted with. - /// - _MIXERIMP const std::vector>& buttons(); - - /// - /// Returns a particular joystick. If the joystick does not exist, - /// NULL is returned. - /// - _MIXERIMP const std::shared_ptr joystick(_In_ const string_t& controlId); - - /// - /// Returns joysticks that the participant has interacted with. - /// - _MIXERIMP const std::vector>& joysticks(); + /// + /// Returns a particular button. If the button does not exist, + /// NULL is returned. + /// + _MIXERIMP const std::shared_ptr button(_In_ const string_t& controlId); + + /// + /// Returns buttons that the participant has interacted with. + /// + _MIXERIMP const std::vector>& buttons(); + + /// + /// Returns a particular joystick. If the joystick does not exist, + /// NULL is returned. + /// + _MIXERIMP const std::shared_ptr joystick(_In_ const string_t& controlId); + + /// + /// Returns joysticks that the participant has interacted with. + /// + _MIXERIMP const std::vector>& joysticks(); #endif private: - /// - /// Internal function to construct an intreactive_participant. - /// - interactive_participant( - _In_ uint32_t mixerId, - _In_ string_t username, - _In_ uint32_t level, - _In_ string_t groupId, - _In_ std::chrono::milliseconds lastInputAt, - _In_ std::chrono::milliseconds connectedAt, - _In_ bool disabled - ); - - - /// - /// Internal function to construct a interactive_participant. - /// - interactive_participant(); - - std::shared_ptr m_interactivityManager; - std::shared_ptr m_impl; - - friend interactive_participant_impl; - friend interactivity_manager_impl; + /// + /// Internal function to construct an intreactive_participant. + /// + interactive_participant( + _In_ uint32_t mixerId, + _In_ string_t username, + _In_ uint32_t level, + _In_ string_t groupId, + _In_ std::chrono::milliseconds lastInputAt, + _In_ std::chrono::milliseconds connectedAt, + _In_ bool disabled + ); + + + /// + /// Internal function to construct a interactive_participant. + /// + interactive_participant(); + + std::shared_ptr m_interactivityManager; + std::shared_ptr m_impl; + + friend interactive_participant_impl; + friend interactivity_manager_impl; }; @@ -236,39 +255,39 @@ class interactive_participant /// enum class interactive_event_type { - /// - /// The message is not a message processed by the SDK. It could be a custom - /// message from an interactive control or a message supported by the protocol - /// but not yet supported by the SDK. - /// - custom, - - /// - /// An error message object. This object type is returned when the service - /// or manager encounters an error. The err and err_message members will - /// contain pertinent info. - /// - error, - - /// - /// An interactivity state changed message object. - /// - interactivity_state_changed, - - /// - /// A participant state changed message object. - /// - participant_state_changed, - - /// - /// A button message object. - /// - button, - - /// - /// A joystick message object. - /// - joystick + /// + /// The message is not a message processed by the SDK. It could be a custom + /// message from an interactive control or a message supported by the protocol + /// but not yet supported by the SDK. + /// + custom, + + /// + /// An error message object. This object type is returned when the service + /// or manager encounters an error. The err and err_message members will + /// contain pertinent info. + /// + error, + + /// + /// An interactivity state changed message object. + /// + interactivity_state_changed, + + /// + /// A participant state changed message object. + /// + participant_state_changed, + + /// + /// A button message object. + /// + button, + + /// + /// A joystick message object. + /// + joystick }; @@ -279,15 +298,15 @@ class interactive_event_args { public: - /// - /// Constructor for the interactive event args object. - /// - interactive_event_args(){} + /// + /// Constructor for the interactive event args object. + /// + interactive_event_args() {} - /// - /// Virtual destructor for the interactive event args object. - /// - virtual ~interactive_event_args(){} + /// + /// Virtual destructor for the interactive event args object. + /// + virtual ~interactive_event_args() {} }; /// @@ -298,51 +317,51 @@ class interactive_event { public: - /// - /// Constructor for the interactive event object. - /// - interactive_event( - _In_ std::chrono::milliseconds time, - _In_ std::error_code errorCode, - _In_ string_t errorMessage, - _In_ interactive_event_type eventType, - _In_ std::shared_ptr eventArgs - ); - - /// - /// The time (in UTC) when this event is raised. - /// - _MIXERIMP const std::chrono::milliseconds& time() const; - - /// - /// The error code indicating the result of the operation. - /// - _MIXERIMP const std::error_code& err() const; - - /// - /// Returns call specific error message with debug information. - /// Message is not localized as it is meant to be used for debugging only. - /// - _MIXERIMP const string_t& err_message() const; - - /// - /// Type of the event raised. - /// - _MIXERIMP interactive_event_type event_type() const; - - /// - /// Returns a pointer to an event argument. Cast the event arg to a specific - /// event arg class type before retrieving the data. - /// - _MIXERIMP const std::shared_ptr& event_args() const; + /// + /// Constructor for the interactive event object. + /// + interactive_event( + _In_ std::chrono::milliseconds time, + _In_ std::error_code errorCode, + _In_ string_t errorMessage, + _In_ interactive_event_type eventType, + _In_ std::shared_ptr eventArgs + ); + + /// + /// The time (in UTC) when this event is raised. + /// + _MIXERIMP const std::chrono::milliseconds& time() const; + + /// + /// The error code indicating the result of the operation. + /// + _MIXERIMP const std::error_code& err() const; + + /// + /// Returns call specific error message with debug information. + /// Message is not localized as it is meant to be used for debugging only. + /// + _MIXERIMP const string_t& err_message() const; + + /// + /// Type of the event raised. + /// + _MIXERIMP interactive_event_type event_type() const; + + /// + /// Returns a pointer to an event argument. Cast the event arg to a specific + /// event arg class type before retrieving the data. + /// + _MIXERIMP const std::shared_ptr& event_args() const; private: - std::chrono::milliseconds m_time; - std::error_code m_errorCode; - string_t m_errorMessage; - interactive_event_type m_eventType; - std::shared_ptr m_eventArgs; + std::chrono::milliseconds m_time; + std::error_code m_errorCode; + string_t m_errorMessage; + interactive_event_type m_eventType; + std::shared_ptr m_eventArgs; }; @@ -353,21 +372,21 @@ class interactivity_state_change_event_args : public interactive_event_args { public: - /// - /// The current interactivity state. - /// - _MIXERIMP const interactivity_state new_state() const; + /// + /// The current interactivity state. + /// + _MIXERIMP const interactivity_state new_state() const; - /// - /// Constructor for the interactivity state change event args object. - /// - interactivity_state_change_event_args( - _In_ interactivity_state newState - ); + /// + /// Constructor for the interactivity state change event args object. + /// + interactivity_state_change_event_args( + _In_ interactivity_state newState + ); private: - interactivity_state m_newState; + interactivity_state m_newState; }; @@ -379,29 +398,29 @@ class interactive_participant_state_change_event_args : public interactive_event { public: - /// - /// The participant whose state has changed. For example, a - /// participant who has just joined the Mixer channel. - /// - _MIXERIMP const std::shared_ptr& participant() const; - - /// - /// The current state of the participant. - /// - _MIXERIMP const interactive_participant_state& state() const; - - /// - /// Constructor for the interactive_participant_state_change_event_args object. - /// - interactive_participant_state_change_event_args( - _In_ std::shared_ptr participant, - _In_ interactive_participant_state state - ); + /// + /// The participant whose state has changed. For example, a + /// participant who has just joined the Mixer channel. + /// + _MIXERIMP const std::shared_ptr& participant() const; + + /// + /// The current state of the participant. + /// + _MIXERIMP const interactive_participant_state& state() const; + + /// + /// Constructor for the interactive_participant_state_change_event_args object. + /// + interactive_participant_state_change_event_args( + _In_ std::shared_ptr participant, + _In_ interactive_participant_state state + ); private: - std::shared_ptr m_participant; - interactive_participant_state m_state; + std::shared_ptr m_participant; + interactive_participant_state m_state; }; @@ -412,50 +431,50 @@ class interactive_button_event_args : public interactive_event_args { public: - /// - /// Unique string identifier for this control - /// - _MIXERIMP const string_t& control_id() const; - - /// - /// Unique string identifier for the spark transaction associated with this control event. - /// - _MIXERIMP const string_t& transaction_id() const; - - /// - /// Spark cost assigned to the button control. - /// - _MIXERIMP uint32_t cost() const; - - /// - /// The user who raised this event. - /// - _MIXERIMP const std::shared_ptr& participant() const; - - /// - /// Boolean to indicate if the button is up or down. - /// Returns TRUE if button is down. - /// - _MIXERIMP bool is_pressed() const; - - /// - /// Constructor for the interactive button event args object. - /// - interactive_button_event_args( - _In_ string_t controlId, - _In_ string_t transaction_id, - _In_ uint32_t cost, - _In_ std::shared_ptr participant, - _In_ bool isPressed - ); + /// + /// Unique string identifier for this control + /// + _MIXERIMP const string_t& control_id() const; + + /// + /// Unique string identifier for the spark transaction associated with this control event. + /// + _MIXERIMP const string_t& transaction_id() const; + + /// + /// Spark cost assigned to the button control. + /// + _MIXERIMP uint32_t cost() const; + + /// + /// The user who raised this event. + /// + _MIXERIMP const std::shared_ptr& participant() const; + + /// + /// Boolean to indicate if the button is up or down. + /// Returns TRUE if button is down. + /// + _MIXERIMP bool is_pressed() const; + + /// + /// Constructor for the interactive button event args object. + /// + interactive_button_event_args( + _In_ string_t controlId, + _In_ string_t transaction_id, + _In_ uint32_t cost, + _In_ std::shared_ptr participant, + _In_ bool isPressed + ); private: - string_t m_controlId; - string_t m_transactionId; - uint32_t m_cost; - std::shared_ptr m_participant; - bool m_isPressed; + string_t m_controlId; + string_t m_transactionId; + uint32_t m_cost; + std::shared_ptr m_participant; + bool m_isPressed; }; /// @@ -466,41 +485,41 @@ class interactive_joystick_event_args : public interactive_event_args { public: - /// - /// Unique string identifier for this control. - /// - _MIXERIMP const string_t& control_id() const; - - /// - /// The X coordinate of the joystick, in the range of [-1, 1]. - /// - _MIXERIMP double x() const; - /// - /// The Y coordinate of the joystick, in the range of [-1, 1]. - /// - _MIXERIMP double y() const; - - /// - /// Participant whose action this event represents. - /// - _MIXERIMP const std::shared_ptr& participant() const; - - /// - /// Constructor for the interactive_joystick_event_args object. - /// - interactive_joystick_event_args( - _In_ std::shared_ptr participant, - _In_ double x, - _In_ double y, - _In_ string_t control_id - ); + /// + /// Unique string identifier for this control. + /// + _MIXERIMP const string_t& control_id() const; + + /// + /// The X coordinate of the joystick, in the range of [-1, 1]. + /// + _MIXERIMP double x() const; + /// + /// The Y coordinate of the joystick, in the range of [-1, 1]. + /// + _MIXERIMP double y() const; + + /// + /// Participant whose action this event represents. + /// + _MIXERIMP const std::shared_ptr& participant() const; + + /// + /// Constructor for the interactive_joystick_event_args object. + /// + interactive_joystick_event_args( + _In_ std::shared_ptr participant, + _In_ double x, + _In_ double y, + _In_ string_t control_id + ); private: - string_t m_controlId; - double m_x; - double m_y; - std::shared_ptr m_participant; + string_t m_controlId; + double m_x; + double m_y; + std::shared_ptr m_participant; }; /// @@ -510,21 +529,21 @@ class interactive_custom_message_event_args : public interactive_event_args { public: - /// - /// The raw text of the message. Messages are in JSON format. - /// - _MIXERIMP const string_t& message() const; + /// + /// The raw text of the message. Messages are in JSON format. + /// + _MIXERIMP const string_t& message() const; - /// - /// Constructor for the interactive button event args object. - /// - interactive_custom_message_event_args( - _In_ string_t message - ); + /// + /// Constructor for the interactive button event args object. + /// + interactive_custom_message_event_args( + _In_ string_t message + ); private: - string_t m_message; + string_t m_message; }; /// @@ -535,69 +554,69 @@ class interactive_control { public: - /// - /// The type of control. - /// - _MIXERIMP const interactive_control_type& control_type() const; + /// + /// The type of control. + /// + _MIXERIMP const interactive_control_type& control_type() const; - /// - /// Unique string identifier for the control. - /// - _MIXERIMP const string_t& control_id() const; + /// + /// Unique string identifier for the control. + /// + _MIXERIMP const string_t& control_id() const; - /// - /// Returns the list of meta properties for the control - /// - _MIXERIMP const std::map& meta_properties() const; + /// + /// Returns the list of meta properties for the control + /// + _MIXERIMP const std::map& meta_properties() const; protected: - /// - /// Internal constructor for the interactive_control object. - /// - interactive_control(); - - /// - /// Internal virtual destructor for the interactive_control object. - /// - virtual ~interactive_control() - { - } - - /// - /// Internal constructor for the interactive_control object. - /// - interactive_control( - _In_ string_t parentScene, - _In_ string_t controlId, - _In_ bool disabled - ); - - /// - /// Internal function to clear the state of the interactive_control object. - /// - virtual void clear_state() = 0; - - /// - /// Internal function to update the state of the interactive_control object. - /// - virtual bool update(web::json::value json, bool overwrite) = 0; - - /// - /// Internal function to initialize interactive_control object. - /// - virtual bool init_from_json(_In_ web::json::value json) = 0; - - std::shared_ptr m_interactivityManager; - string_t m_parentScene; - interactive_control_type m_type; - string_t m_controlId; - bool m_disabled; - string_t m_etag; - std::map m_metaProperties; - - friend interactive_control_builder; - friend interactivity_manager_impl; + /// + /// Internal constructor for the interactive_control object. + /// + interactive_control(); + + /// + /// Internal virtual destructor for the interactive_control object. + /// + virtual ~interactive_control() + { + } + + /// + /// Internal constructor for the interactive_control object. + /// + interactive_control( + _In_ string_t parentScene, + _In_ string_t controlId, + _In_ bool disabled + ); + + /// + /// Internal function to clear the state of the interactive_control object. + /// + virtual void clear_state() = 0; + + /// + /// Internal function to update the state of the interactive_control object. + /// + virtual bool update(web::json::value json, bool overwrite) = 0; + + /// + /// Internal function to initialize interactive_control object. + /// + virtual bool init_from_json(_In_ web::json::value json) = 0; + + std::shared_ptr m_interactivityManager; + string_t m_parentScene; + interactive_control_type m_type; + string_t m_controlId; + bool m_disabled; + string_t m_etag; + std::map m_metaProperties; + + friend interactive_control_builder; + friend interactivity_manager_impl; }; @@ -610,159 +629,159 @@ class interactive_button_control : public interactive_control { public: - /// - /// Text displayed on the button control. - /// - _MIXERIMP const string_t& button_text() const; - - /// - /// Spark cost assigned to the button control. - /// - _MIXERIMP uint32_t cost() const; - - /// - /// Indicates whether the button is enabled or disabled. If TRUE, - /// button is disabled. - /// - _MIXERIMP bool disabled() const; - - /// - /// Function to enable or disable the button. - /// - /// Value to enable or disable the button. - /// Set this value to TRUE to disable the button. - _MIXERIMP void set_disabled(_In_ bool disabled); - - /// - /// Sets the cooldown duration (in milliseconds) required between triggers. - /// Disables the button for a period of time. - /// - /// Duration (in milliseconds) required between triggers. - _MIXERIMP void trigger_cooldown(std::chrono::milliseconds cooldown) const; - - /// - /// Time remaining (in milliseconds) before the button can be triggered again. - /// - _MIXERIMP std::chrono::milliseconds remaining_cooldown() const; - - /// - /// Current progress of the button control. - /// - _MIXERIMP float progress() const; - - /// - /// Sets the progress value for the button control. - /// - /// The progress value, in the range of 0.0 to 1.0. - _MIXERIMP void set_progress(_In_ float progress); - - /// - /// Returns the total count of button downs since the last call to do_work(). - /// - _MIXERIMP uint32_t count_of_button_downs(); - - /// - /// Returns the total count of button downs by the specified participant - /// since the last call to do_work(). - /// - _MIXERIMP uint32_t count_of_button_downs(_In_ uint32_t mixerId); - - /// - /// Returns the total count of button presses since the last call to do_work(). - /// - _MIXERIMP uint32_t count_of_button_presses(); - - /// - /// Returns the total count of button presses by the specified participant - /// since the last call to do_work(). - /// - _MIXERIMP uint32_t count_of_button_presses(_In_ uint32_t mixerId); - - /// - /// Returns the total count of button ups since the last call to do_work(). - /// - _MIXERIMP uint32_t count_of_button_ups(); - - /// - /// Returns the total count of button ups by the specified participant - /// since the last call to do_work(). - /// - _MIXERIMP uint32_t count_of_button_ups(_In_ uint32_t mixerId); - - /// - /// Returns TRUE if button is currently pressed. - /// - _MIXERIMP bool is_pressed(); - - /// - /// Returns TRUE if the button is currently pressed by the specified participant. - /// - _MIXERIMP bool is_pressed(_In_ uint32_t mixerId); - - /// - /// Returns TRUE if button is currently down. - /// - _MIXERIMP bool is_down(); - - /// - /// Returns TRUE if the button is clicked down by the specified participant. - /// - _MIXERIMP bool is_down(_In_ uint32_t mixerId); - - /// - /// Returns TRUE if button is currently up. - /// - _MIXERIMP bool is_up(); - - /// - /// Returns TRUE if the button is currently up for the specified participant. - /// - _MIXERIMP bool is_up(_In_ uint32_t mixerId); + /// + /// Text displayed on the button control. + /// + _MIXERIMP const string_t& button_text() const; + + /// + /// Spark cost assigned to the button control. + /// + _MIXERIMP uint32_t cost() const; + + /// + /// Indicates whether the button is enabled or disabled. If TRUE, + /// button is disabled. + /// + _MIXERIMP bool disabled() const; + + /// + /// Function to enable or disable the button. + /// + /// Value to enable or disable the button. + /// Set this value to TRUE to disable the button. + _MIXERIMP void set_disabled(_In_ bool disabled); + + /// + /// Sets the cooldown duration (in milliseconds) required between triggers. + /// Disables the button for a period of time. + /// + /// Duration (in milliseconds) required between triggers. + _MIXERIMP void trigger_cooldown(std::chrono::milliseconds cooldown) const; + + /// + /// Time remaining (in milliseconds) before the button can be triggered again. + /// + _MIXERIMP std::chrono::milliseconds remaining_cooldown() const; + + /// + /// Current progress of the button control. + /// + _MIXERIMP float progress() const; + + /// + /// Sets the progress value for the button control. + /// + /// The progress value, in the range of 0.0 to 1.0. + _MIXERIMP void set_progress(_In_ float progress); + + /// + /// Returns the total count of button downs since the last call to do_work(). + /// + _MIXERIMP uint32_t count_of_button_downs(); + + /// + /// Returns the total count of button downs by the specified participant + /// since the last call to do_work(). + /// + _MIXERIMP uint32_t count_of_button_downs(_In_ uint32_t mixerId); + + /// + /// Returns the total count of button presses since the last call to do_work(). + /// + _MIXERIMP uint32_t count_of_button_presses(); + + /// + /// Returns the total count of button presses by the specified participant + /// since the last call to do_work(). + /// + _MIXERIMP uint32_t count_of_button_presses(_In_ uint32_t mixerId); + + /// + /// Returns the total count of button ups since the last call to do_work(). + /// + _MIXERIMP uint32_t count_of_button_ups(); + + /// + /// Returns the total count of button ups by the specified participant + /// since the last call to do_work(). + /// + _MIXERIMP uint32_t count_of_button_ups(_In_ uint32_t mixerId); + + /// + /// Returns TRUE if button is currently pressed. + /// + _MIXERIMP bool is_pressed(); + + /// + /// Returns TRUE if the button is currently pressed by the specified participant. + /// + _MIXERIMP bool is_pressed(_In_ uint32_t mixerId); + + /// + /// Returns TRUE if button is currently down. + /// + _MIXERIMP bool is_down(); + + /// + /// Returns TRUE if the button is clicked down by the specified participant. + /// + _MIXERIMP bool is_down(_In_ uint32_t mixerId); + + /// + /// Returns TRUE if button is currently up. + /// + _MIXERIMP bool is_up(); + + /// + /// Returns TRUE if the button is currently up for the specified participant. + /// + _MIXERIMP bool is_up(_In_ uint32_t mixerId); private: - /// - /// Constructor for interactive_button_control object. - /// - interactive_button_control(); - - /// - /// Constructor for interactive_button_control object. - /// - interactive_button_control( - _In_ string_t parentSceneId, - _In_ string_t controlId, - _In_ bool enabled, - _In_ float progress, - _In_ std::chrono::milliseconds m_cooldownDeadline, - _In_ string_t buttonText, - _In_ uint32_t sparkCost - ); - - /// - /// Internal function to initialize a interactive_button_control object. - /// - bool init_from_json(web::json::value json); - - /// - /// Internal function to clear the state of the interactive_button_control object. - /// - void clear_state(); - - /// - /// Internal function to update the state of the interactive_control object. - /// - bool update(web::json::value json, bool overwrite); - - float m_progress; - std::chrono::milliseconds m_cooldownDeadline; - string_t m_buttonText; - uint32_t m_sparkCost; - std::map> m_buttonStateByMixerId; - std::shared_ptr m_buttonCount; - - friend interactive_control_builder; - friend interactivity_manager_impl; + /// + /// Constructor for interactive_button_control object. + /// + interactive_button_control(); + + /// + /// Constructor for interactive_button_control object. + /// + interactive_button_control( + _In_ string_t parentSceneId, + _In_ string_t controlId, + _In_ bool enabled, + _In_ float progress, + _In_ std::chrono::milliseconds m_cooldownDeadline, + _In_ string_t buttonText, + _In_ uint32_t sparkCost + ); + + /// + /// Internal function to initialize a interactive_button_control object. + /// + bool init_from_json(web::json::value json); + + /// + /// Internal function to clear the state of the interactive_button_control object. + /// + void clear_state(); + + /// + /// Internal function to update the state of the interactive_control object. + /// + bool update(web::json::value json, bool overwrite); + + float m_progress; + std::chrono::milliseconds m_cooldownDeadline; + string_t m_buttonText; + uint32_t m_sparkCost; + std::map> m_buttonStateByMixerId; + std::shared_ptr m_buttonCount; + + friend interactive_control_builder; + friend interactivity_manager_impl; }; @@ -774,66 +793,66 @@ class interactive_joystick_control : public interactive_control { public: - /// - /// The current X coordinate of the joystick, in the range of [-1, 1]. - /// - _MIXERIMP double x() const; + /// + /// The current X coordinate of the joystick, in the range of [-1, 1]. + /// + _MIXERIMP double x() const; - /// - /// The current X coordinate of the joystick, in the range of [-1, 1] for the specified participant. - /// - _MIXERIMP double x(_In_ uint32_t mixerId); + /// + /// The current X coordinate of the joystick, in the range of [-1, 1] for the specified participant. + /// + _MIXERIMP double x(_In_ uint32_t mixerId); - /// - /// The current Y coordinate of the joystick, in the range of [-1, 1]. - /// - _MIXERIMP double y() const; + /// + /// The current Y coordinate of the joystick, in the range of [-1, 1]. + /// + _MIXERIMP double y() const; - /// - /// The current Y coordinate of the joystick, in the range of [-1, 1] for the specified participant. - /// - _MIXERIMP double y(_In_ uint32_t mixerId); + /// + /// The current Y coordinate of the joystick, in the range of [-1, 1] for the specified participant. + /// + _MIXERIMP double y(_In_ uint32_t mixerId); - /// - /// Internal function to clear the state of the interactive_button_control object. - /// - void clear_state(); + /// + /// Internal function to clear the state of the interactive_button_control object. + /// + void clear_state(); private: - /// - /// Constructor for the interactive_joystick_control object. - /// - interactive_joystick_control(); - - /// - /// Constructor for the interactive_joystick_control object. - /// - interactive_joystick_control( - _In_ string_t parentSceneId, - _In_ string_t controlId, - _In_ bool enabled, - _In_ double x, - _In_ double y - ); - - /// - /// Internal function to initialize a interactive_joystick_control object. - /// - bool init_from_json(web::json::value json); - - /// - /// Internal function to update the state of the interactive_joystick_control object. - /// - bool update(web::json::value json, bool overwrite); - - double m_x; - double m_y; - - std::map> m_joystickStateByMixerId; - - friend interactive_control_builder; - friend interactivity_manager_impl; + /// + /// Constructor for the interactive_joystick_control object. + /// + interactive_joystick_control(); + + /// + /// Constructor for the interactive_joystick_control object. + /// + interactive_joystick_control( + _In_ string_t parentSceneId, + _In_ string_t controlId, + _In_ bool enabled, + _In_ double x, + _In_ double y + ); + + /// + /// Internal function to initialize a interactive_joystick_control object. + /// + bool init_from_json(web::json::value json); + + /// + /// Internal function to update the state of the interactive_joystick_control object. + /// + bool update(web::json::value json, bool overwrite); + + double m_x; + double m_y; + + std::map> m_joystickStateByMixerId; + + friend interactive_control_builder; + friend interactivity_manager_impl; }; @@ -847,58 +866,58 @@ class interactive_group { public: - /// - /// Constructor for the interactive_group object. If no scene is specified, - /// the group is shown the "default" scene. - /// - /// The unique string identifier for the group. - interactive_group( - _In_ string_t groupId - ); - - /// - /// Constructor for the interactive_group object. - /// - /// The unique string identifier for the group. - /// The scene shown to the group. - interactive_group( - _In_ string_t groupId, - _In_ std::shared_ptr scene - ); - - /// - /// Unique string identifier for the group. - /// - _MIXERIMP const string_t& group_id() const; - - /// - /// Returns a pointer to the scene assigned to the group. - /// - _MIXERIMP std::shared_ptr scene(); - - /// - /// Assigns a scene to the group. - /// - _MIXERIMP void set_scene(std::shared_ptr currentScene); - - /// - /// Gets all the participants assigned to the group. The list may be empty. - /// - _MIXERIMP const std::vector> participants(); + /// + /// Constructor for the interactive_group object. If no scene is specified, + /// the group is shown the "default" scene. + /// + /// The unique string identifier for the group. + interactive_group( + _In_ string_t groupId + ); + + /// + /// Constructor for the interactive_group object. + /// + /// The unique string identifier for the group. + /// The scene shown to the group. + interactive_group( + _In_ string_t groupId, + _In_ std::shared_ptr scene + ); + + /// + /// Unique string identifier for the group. + /// + _MIXERIMP const string_t& group_id() const; + + /// + /// Returns a pointer to the scene assigned to the group. + /// + _MIXERIMP std::shared_ptr scene(); + + /// + /// Assigns a scene to the group. + /// + _MIXERIMP void set_scene(std::shared_ptr currentScene); + + /// + /// Gets all the participants assigned to the group. The list may be empty. + /// + _MIXERIMP const std::vector> participants(); private: - /// - /// Internal function to construct a interactive_group object. - /// - interactive_group(); + /// + /// Internal function to construct a interactive_group object. + /// + interactive_group(); - std::shared_ptr m_interactivityManager; - std::shared_ptr m_impl; + std::shared_ptr m_interactivityManager; + std::shared_ptr m_impl; - friend interactive_group_impl; - friend interactivity_manager_impl; - friend interactivity_manager; + friend interactive_group_impl; + friend interactivity_manager_impl; + friend interactivity_manager; }; @@ -910,62 +929,63 @@ class interactive_scene { public: - /// - /// Unique string identifier for the scene. - /// - _MIXERIMP const string_t& scene_id() const; - - /// - /// Returns all the groups that the scene is assigned to. This list may be empty. - /// - _MIXERIMP const std::vector groups(); - - /// - /// Returns a list of all the buttons in the scene. This list may be empty. - /// - _MIXERIMP const std::vector> buttons(); - - /// - /// Returns the pointer to the specified button, if it exist. - /// - /// The unique string identifier of the button. - _MIXERIMP const std::shared_ptr button(_In_ const string_t& controlId); - - /// - /// Returns a list of all the joysticks in the scene. This list may be empty. - /// - _MIXERIMP const std::vector> joysticks(); - - /// - /// Returns the pointer to the specified joystick, if it exist. - /// - /// The unique string identifier of the joystick. - _MIXERIMP const std::shared_ptr joystick(_In_ const string_t& controlId); + /// + /// Unique string identifier for the scene. + /// + _MIXERIMP const string_t& scene_id() const; + + /// + /// Returns all the groups that the scene is assigned to. This list may be empty. + /// + _MIXERIMP const std::vector groups(); + + /// + /// Returns a list of all the buttons in the scene. This list may be empty. + /// + _MIXERIMP const std::vector> buttons(); + + /// + /// Returns the pointer to the specified button, if it exist. + /// + /// The unique string identifier of the button. + _MIXERIMP const std::shared_ptr button(_In_ const string_t& controlId); + + /// + /// Returns a list of all the joysticks in the scene. This list may be empty. + /// + _MIXERIMP const std::vector> joysticks(); + + /// + /// Returns the pointer to the specified joystick, if it exist. + /// + /// The unique string identifier of the joystick. + _MIXERIMP const std::shared_ptr joystick(_In_ const string_t& controlId); private: - /// - /// Constructor for the interactive_scene object. - /// - interactive_scene(); - - /// - /// Constructor for the interactive_scene object. - /// - interactive_scene( - _In_ string_t sceneId, - _In_ bool enabled - ); - - std::shared_ptr m_interactivityManager; - std::shared_ptr m_impl; - - friend interactive_scene_impl; - friend interactivity_manager_impl; - friend interactivity_manager; + /// + /// Constructor for the interactive_scene object. + /// + interactive_scene(); + + /// + /// Constructor for the interactive_scene object. + /// + interactive_scene( + _In_ string_t sceneId, + _In_ bool enabled + ); + + std::shared_ptr m_interactivityManager; + std::shared_ptr m_impl; + + friend interactive_scene_impl; + friend interactivity_manager_impl; + friend interactivity_manager; }; + /// /// Manager service class that handles the interactivity event /// experience between the Mixer service and the title. @@ -974,41 +994,41 @@ class interactivity_manager : public std::enable_shared_from_this - /// Gets the singleton instance of interactivity_manager. - /// - _MIXERIMP static std::shared_ptr get_singleton_instance(); - - /// - /// Sets up the connection for the Mixer interactivity event experience by - /// initializing a background task. - /// - /// Value that indicates whether the initialization request is accepted or not. - /// If TRUE, the initialization request is accepted. - /// The version of the Mixer interactivity experience created for the title. - /// Value that indicates whether or not to start interactivity immediately. - /// If FALSE, you need to actively start_interactive() to intiate interactivity after initialization. - /// - _MIXERIMP bool initialize( - _In_ string_t interactiveVersion, - _In_ bool goInteractive = true, - _In_ string_t sharecode = L"" - ); + /// + /// Gets the singleton instance of interactivity_manager. + /// + _MIXERIMP static std::shared_ptr get_singleton_instance(); + + /// + /// Sets up the connection for the Mixer interactivity event experience by + /// initializing a background task. + /// + /// Value that indicates whether the initialization request is accepted or not. + /// If TRUE, the initialization request is accepted. + /// The version of the Mixer interactivity experience created for the title. + /// Value that indicates whether or not to start interactivity immediately. + /// If FALSE, you need to actively start_interactive() to intiate interactivity after initialization. + /// + _MIXERIMP bool initialize( + _In_ string_t interactiveVersion, + _In_ bool goInteractive = true, + _In_ string_t sharecode = _XPLATSTR("") + ); #if TV_API | XBOX_UWP - /// - /// Sets the local user to be used for authentication for the Mixer interactivity experience. - /// - /// The user's Xbox Live identifier. - /// Returns an interactive event to report any potential error. A nullptr is returned if there's no error. - _MIXERIMP std::shared_ptr set_local_user(_In_ xbox_live_user_t user); + /// + /// Sets the local user to be used for authentication for the Mixer interactivity experience. + /// + /// The user's Xbox Live identifier. + /// Returns an interactive event to report any potential error. A nullptr is returned if there's no error. + _MIXERIMP std::shared_ptr set_local_user(_In_ xbox_live_user_t user); #else - /// - /// Set an xtoken retrieved from a signed in user. This is used to authenticate into the Mixer interactivity experience. - /// - /// The user's xtoken. - /// Returns an interactive event to report any potential error. A nullptr is returned if there's no error. - _MIXERIMP std::shared_ptr set_xtoken(_In_ string_t token); + /// + /// Set an xtoken retrieved from a signed in user. This is used to authenticate into the Mixer interactivity experience. + /// + /// The user's xtoken. + /// Returns an interactive event to report any potential error. A nullptr is returned if there's no error. + _MIXERIMP std::shared_ptr set_xtoken(_In_ string_t token); /// /// Set an OAuth token for the Mixer user obtained via some flow external to the C++ SDK. @@ -1019,193 +1039,145 @@ class interactivity_manager : public std::enable_shared_from_this - /// Requests an OAuth account authorization code from the Mixer services. The title needs to display this - /// code and prompt the user to enter it at mixer.com/go. This process allows the user's Mixer account to - /// be linked to an interactivity stream. - /// - /// The Mixer ID of the user. - _MIXERIMP void request_linking_code(_In_ uint32_t mixer_id) const; + /// + /// Requests an OAuth account authorization code from the Mixer services. The title needs to display this + /// code and prompt the user to enter it at mixer.com/go. This process allows the user's Mixer account to + /// be linked to an interactivity stream. + /// + /// The Mixer ID of the user. + _MIXERIMP void request_linking_code(_In_ uint32_t mixer_id) const; #endif - /// - /// The time of the Mixer interactivity service, in UTC. Used to maintain the - /// title's synchronization with the Mixer interactivity experience. - /// - _MIXERIMP const std::chrono::milliseconds get_server_time(); - - /// - /// Returns the version of the Mixer interactivity experience created. - /// - _MIXERIMP const string_t& interactive_version() const; - - /// - /// The enum value that indicates the interactivity state of the Interactivity manager. - /// - _MIXERIMP const interactivity_state interactivity_state(); - - /// - /// Used by the title to inform the Mixer service that it is ready to receive interactivity input. - /// - /// - _MIXERIMP bool start_interactive(); - - /// - /// Used by the title to inform the Mixer service that it is no longer receiving interactivity input. - /// - /// - /// - _MIXERIMP bool stop_interactive(); - - /// - /// Returns currently active participants of this interactivity experience. - /// - _MIXERIMP std::vector> participants(); - - /// - /// Gets all the groups associated with the current interactivity instance. - /// Empty list is returned if initialization is not yet completed. - /// - _MIXERIMP std::vector> groups(); - - /// - /// Gets the pointer to a specific group. Returns a NULL pointer if initialization - /// is not yet completed or if the group does not exist. - /// - _MIXERIMP std::shared_ptr group(_In_ const string_t& group_id = L"default"); - - /// - /// Gets all the scenes associated with the current interactivity instance. - /// Returns a NULL pointer if initialization is not yet completed. - /// - _MIXERIMP std::vector> scenes(); - - /// - /// Gets the pointer to a specific scene. Returns a NULL pointer if initialization - /// is not yet completed or if the scene does not exist. - /// - _MIXERIMP std::shared_ptr scene(_In_ const string_t& scene_id); - - /// - /// Function to enable or disable the button. - /// - /// The unique string identifier of the control. - /// Value to enable or disable the button. - /// Set this value to TRUE to disable the button. - _MIXERIMP void set_disabled(_In_ const string_t& control_id, _In_ bool disabled) const; - - /// - /// Current progress of the button control. - /// - _MIXERIMP float progress() const; - - /// - /// Sets the progress value for the button control. - /// - /// The progress value, in the range of 0.0 to 1.0. - _MIXERIMP void set_progress(_In_ const string_t& control_id, _In_ float progress); - - /// - /// Disables a specific control for a period of time, specified in milliseconds. - /// - /// The unique string identifier of the control. - /// Cooldown duration (in milliseconds). - _MIXERIMP void trigger_cooldown(_In_ const string_t& control_id, _In_ const std::chrono::milliseconds& cooldown) const; - - /// - /// Sends a JSON RPC message to the interactivity service. - /// - /// The name of the method. - /// A string that can contain any data so long as it is valid JSON. - _MIXERIMP void send_rpc_message(_In_ const string_t& method, _In_ const string_t& parameters) const; - - /// - /// Captures a given interactive event transaction, charging the sparks to the appropriate Participant. - /// - /// The unique string identifier of the transaction to be captured. - _MIXERIMP void capture_transaction(_In_ const string_t& transaction_id) const; - - /// - /// Manages and maintains proper state updates between the title and the Interactivity Service. - /// To ensure best performance, do_work() must be called frequently, such as once per frame. - /// Title needs to be thread safe when calling do_work() since this is when states are changed. - /// This also clears the state of the input controls. - /// - /// A list of all the events the title has to handle. Empty if no events have been triggered - /// during this update. - _MIXERIMP std::vector do_work(); + /// + /// The time of the Mixer interactivity service, in UTC. Used to maintain the + /// title's synchronization with the Mixer interactivity experience. + /// + _MIXERIMP const std::chrono::milliseconds get_server_time(); + + /// + /// Returns the version of the Mixer interactivity experience created. + /// + _MIXERIMP const string_t& interactive_version() const; -private: + /// + /// The enum value that indicates the interactivity state of the Interactivity manager. + /// + _MIXERIMP const interactivity_state interactivity_state(); - /// - /// Internal function - /// - interactivity_manager(); + /// + /// Used by the title to inform the Mixer service that it is ready to receive interactivity input. + /// + /// + _MIXERIMP bool start_interactive(); - std::shared_ptr m_impl; + /// + /// Used by the title to inform the Mixer service that it is no longer receiving interactivity input. + /// + /// + /// + _MIXERIMP bool suspend_interactive(); - friend interactive_control_builder; - friend interactivity_mock_util; - friend interactive_scene_impl; - friend interactive_group; - friend interactive_group_impl; - friend interactive_participant_impl; -}; + /// + /// Used by the title to disconnect from the Mixer service. + /// + /// + /// + _MIXERIMP bool stop_interactive(); -#if 0 -/// -/// Represents mock Interactive events. This class mocks events between the Interactivity -/// service and participants. -/// -class interactivity_mock_util : public std::enable_shared_from_this -{ -public: + /// + /// Returns currently active participants of this interactivity experience. + /// + _MIXERIMP std::vector> participants(); - /// - /// Returns the singleton instance of the mock class. - /// - _MIXERIMP static std::shared_ptr get_singleton_instance(); - - /// - /// Sets the OAuth token; skips the linking code API. - /// - /// The token. - _MIXERIMP void set_oauth_token(_In_ string_t token); - - /// - /// Creates a mock button event. Note: A mocked participant must first join before a mock input - /// such as a mock button event can be sent. Else, it will be ignored by the Interactivity manager. - /// - /// The Mixer ID of the user. - /// The unique string identifier of the button control. - /// TValue that indicates the button is down or not. If TRUE, the button is down. - _MIXERIMP void mock_button_event(_In_ uint32_t mixerId, _In_ string_t buttonId, _In_ bool is_down); - - /// - /// Simulates a specific mock participant joining the interactivity. - /// - /// The Mixer ID of the user. - /// The Mixer username of the user. - _MIXERIMP void mock_participant_join(_In_ uint32_t mixerId, _In_ string_t username); - - /// - /// Simulates a specific mock participant leaving interactivity. - /// - /// The Mixer ID of the user. - /// The Mixer username of the user. - _MIXERIMP void mock_participant_leave(_In_ uint32_t mixerId, _In_ string_t username); + /// + /// Gets all the groups associated with the current interactivity instance. + /// Empty list is returned if initialization is not yet completed. + /// + _MIXERIMP std::vector> groups(); + + /// + /// Gets the pointer to a specific group. Returns a NULL pointer if initialization + /// is not yet completed or if the group does not exist. + /// + _MIXERIMP std::shared_ptr group(_In_ const string_t& group_id = _XPLATSTR("default")); + + /// + /// Gets all the scenes associated with the current interactivity instance. + /// Returns a NULL pointer if initialization is not yet completed. + /// + _MIXERIMP std::vector> scenes(); + + /// + /// Gets the pointer to a specific scene. Returns a NULL pointer if initialization + /// is not yet completed or if the scene does not exist. + /// + _MIXERIMP std::shared_ptr scene(_In_ const string_t& scene_id); + + /// + /// Function to enable or disable the button. + /// + /// The unique string identifier of the control. + /// Value to enable or disable the button. + /// Set this value to TRUE to disable the button. + _MIXERIMP void set_disabled(_In_ const string_t& control_id, _In_ bool disabled) const; + + /// + /// Current progress of the button control. + /// + _MIXERIMP float progress() const; + + /// + /// Sets the progress value for the button control. + /// + /// The progress value, in the range of 0.0 to 1.0. + _MIXERIMP void set_progress(_In_ const string_t& control_id, _In_ float progress); + + /// + /// Disables a specific control for a period of time, specified in milliseconds. + /// + /// The unique string identifier of the control. + /// Cooldown duration (in milliseconds). + _MIXERIMP void trigger_cooldown(_In_ const string_t& control_id, _In_ const std::chrono::milliseconds& cooldown) const; + + /// + /// Sends a JSON RPC message to the interactivity service. + /// + /// The name of the method. + /// A string that can contain any data so long as it is valid JSON. + _MIXERIMP void send_rpc_message(_In_ const string_t& method, _In_ const string_t& parameters) const; + + /// + /// Captures a given interactive event transaction, charging the sparks to the appropriate Participant. + /// + /// The unique string identifier of the transaction to be captured. + _MIXERIMP void capture_transaction(_In_ const string_t& transaction_id) const; + + /// + /// Manages and maintains proper state updates between the title and the Interactivity Service. + /// To ensure best performance, do_work() must be called frequently, such as once per frame. + /// Title needs to be thread safe when calling do_work() since this is when states are changed. + /// This also clears the state of the input controls. + /// + /// A list of all the events the title has to handle. Empty if no events have been triggered + /// during this update. + _MIXERIMP std::vector do_work(); private: - /// - /// Internal function - /// - interactivity_mock_util(); + /// + /// Internal function + /// + interactivity_manager(); - std::shared_ptr m_interactiveManagerImpl; + std::shared_ptr m_impl; - friend interactive_control_builder; - friend interactivity_manager_impl; + friend interactive_control_builder; + friend interactivity_mock_util; + friend interactive_scene_impl; + friend interactive_group; + friend interactive_group_impl; + friend interactive_participant_impl; }; -#endif -}} + +} +} \ No newline at end of file diff --git a/Include/interactivity_types.h b/Include/interactivity_types.h index d569d9f..f8c092e 100644 --- a/Include/interactivity_types.h +++ b/Include/interactivity_types.h @@ -1,3 +1,4 @@ +#pragma once #ifdef _WIN32 #include @@ -29,6 +30,22 @@ #endif //_WIN32 +#ifdef ANDROID +// Android doesn't support std::to_string, so implement it: + +namespace std +{ +template< typename T > +std::string to_string(const T& item) +{ + + std::stringstream ss; + ss << item; + return ss.str(); +} +} +#endif + #ifndef _WIN32 #ifdef _In_ #undef _In_ @@ -44,14 +61,6 @@ #define _Post_writable_byte_size_(X) #endif -#ifndef _T -#ifdef _WIN32 -#define _T(x) L ## x -#else -#define _T(x) x -#endif -#endif - #if defined _WIN32 #ifdef _NO_MIXERIMP #define _MIXERIMP @@ -83,20 +92,44 @@ #endif typedef int32_t function_context; -#ifdef _WIN32 + +#if _WIN32 || UNICODE +#ifndef XPLATSTR +#define __XPLATSTR(x) L ## x +#define XPLATSTR(x) __XPLATSTR(x) +#endif +#ifndef tostring +#define tostring(x) std::to_wstring(x) +#endif +#ifndef char_t typedef wchar_t char_t; +#endif +#ifndef string_t typedef std::wstring string_t; +#endif +#ifndef stringstream_t typedef std::wstringstream stringstream_t; -//typedef std::wregex regex_t; -//typedef std::wsmatch smatch_t; +#endif + #else +#ifndef XPLATSTR +#define XPLATSTR(x) x +#endif +#ifndef tostring +#define tostring(x) std::to_string(x) +#endif +#ifndef char_t typedef char char_t; +#endif +#ifndef string_t typedef std::string string_t; +#endif +#ifndef stringstream_t typedef std::stringstream stringstream_t; -typedef std::regex regex_t; -typedef std::smatch smatch_t; #endif +#endif // _WIN32 || UNICODE + #if _MSC_VER <= 1800 typedef std::chrono::system_clock chrono_clock_t; #else diff --git a/Samples/UWP/Interactivity_UWP.vcxproj b/Samples/UWP/Interactivity_UWP.vcxproj index 524759b..35b10a9 100644 --- a/Samples/UWP/Interactivity_UWP.vcxproj +++ b/Samples/UWP/Interactivity_UWP.vcxproj @@ -99,6 +99,12 @@ false + + D:\interactive-cpp\Include;$(IncludePath) + + + $(VC_IncludePath);$(WindowsSDK_IncludePath); + d2d1.lib; d3d11.lib; dxgi.lib; dxguid.lib; windowscodecs.lib; dwrite.lib; %(AdditionalDependencies) diff --git a/Samples/Xbox/Interactivity.vcxproj.filters b/Samples/Xbox/Interactivity.vcxproj.filters index 526e259..736cae6 100644 --- a/Samples/Xbox/Interactivity.vcxproj.filters +++ b/Samples/Xbox/Interactivity.vcxproj.filters @@ -47,6 +47,7 @@ ATG Tool Kit + diff --git a/Source/Util/debug_output.cpp b/Source/Util/debug_output.cpp deleted file mode 100644 index dd197de..0000000 --- a/Source/Util/debug_output.cpp +++ /dev/null @@ -1,21 +0,0 @@ -//********************************************************* -// -// Copyright (c) Microsoft. All rights reserved. -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//********************************************************* -#include "pch.h" -#include "debug_output.h" - - -NAMESPACE_MICROSOFT_MIXER_BEGIN - -void debug_output::write(_In_ const std::string& msg) -{ - OutputDebugStringA(msg.c_str()); -} - -NAMESPACE_MICROSOFT_MIXER_END diff --git a/Source/Util/debug_output.h b/Source/Util/debug_output.h deleted file mode 100644 index f10c122..0000000 --- a/Source/Util/debug_output.h +++ /dev/null @@ -1,23 +0,0 @@ -//********************************************************* -// -// Copyright (c) Microsoft. All rights reserved. -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//********************************************************* -#pragma once -#include "log.h" - -NAMESPACE_MICROSOFT_MIXER_BEGIN - -class debug_output : public log_output -{ -public: - debug_output() : log_output(log_output_level_setting::use_logger_setting, log_level::off) {} - - void write(_In_ const std::string& msg) override; -}; - -NAMESPACE_MICROSOFT_MIXER_END diff --git a/Source/Util/json_helper.cpp b/Source/Util/json_helper.cpp deleted file mode 100644 index b37e3fe..0000000 --- a/Source/Util/json_helper.cpp +++ /dev/null @@ -1,17 +0,0 @@ -//********************************************************* -// -// Copyright (c) Microsoft. All rights reserved. -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//********************************************************* -#include "pch.h" -#include "beam.h" -//#include "beam_internal.h" - -NAMESPACE_MICROSOFT_XBOX_SERVICES_CPP_BEGIN -static std::mutex s_singletonLock; - -NAMESPACE_MICROSOFT_XBOX_SERVICES_CPP_END \ No newline at end of file diff --git a/Source/Util/log.cpp b/Source/Util/log.cpp deleted file mode 100644 index 846561b..0000000 --- a/Source/Util/log.cpp +++ /dev/null @@ -1,55 +0,0 @@ -//********************************************************* -// -// Copyright (c) Microsoft. All rights reserved. -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//********************************************************* -#include "pch.h" -#include "log.h" - -NAMESPACE_MICROSOFT_MIXER_BEGIN - -std::shared_ptr logger::s_logger = nullptr; - -void logger::add_log_output(std::shared_ptr output) -{ - m_log_outputs.emplace_back(output); - if (output->level_setting() == log_output_level_setting::use_logger_setting) - { - output->set_log_level(m_logLevel); - } -}; - -void logger::set_log_level(log_level level) -{ - m_logLevel = level; - - for (const auto& output : m_log_outputs) - { - if (output->level_setting() == log_output_level_setting::use_logger_setting) - { - output->set_log_level(level); - } - } -} - -void logger::add_log(const log_entry& logEntry) -{ - for(const auto& output : m_log_outputs) - { - if (output->log_level_enabled(logEntry.get_log_level())) - { - output->add_log(logEntry); - } - } -} - -void logger::operator+=(const log_entry& logEntry) -{ - add_log(logEntry); -} - -NAMESPACE_MICROSOFT_MIXER_END diff --git a/Source/Util/log.h b/Source/Util/log.h deleted file mode 100644 index 6c4d9c4..0000000 --- a/Source/Util/log.h +++ /dev/null @@ -1,165 +0,0 @@ -//********************************************************* -// -// Copyright (c) Microsoft. All rights reserved. -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//********************************************************* -#pragma once - - -#define DEFAULT_LOGGER MICROSOFT_MIXER_NAMESPACE::logger::get_logger() -#define IF_LOGGER_ENABLED(logger) if(logger != nullptr) - -#define LOG(logger, level, category, msg) IF_LOGGER_ENABLED(logger) logger->add_log(MICROSOFT_MIXER_NAMESPACE::log_entry(level, category, msg)) -#define LOGS(logger, level, category) IF_LOGGER_ENABLED(logger) *logger += MICROSOFT_MIXER_NAMESPACE::log_entry(level, category) - -// default logging macro -const char defaultCategory[] = ""; -#define IF_LOG_ERROR() IF_LOG_LEVEL_ENABLED(DEFAULT_LOGGER, MICROSOFT_MIXER_NAMESPACE::log_level::error) -#define LOG_ERROR(msg) LOG(DEFAULT_LOGGER, MICROSOFT_MIXER_NAMESPACE::log_level::error, defaultCategory, msg) -#define LOG_ERROR_IF(boolean_expression, msg) if(boolean_expression) LOG_ERROR(msg) -#define LOGS_ERROR LOGS(DEFAULT_LOGGER, MICROSOFT_MIXER_NAMESPACE::log_level::error, defaultCategory) -#define LOGS_ERROR_IF(boolean_expression) if(boolean_expression) LOGS_ERROR - -#define IF_LOG_WARN() IF_LOG_LEVEL_ENABLED(DEFAULT_LOGGER, MICROSOFT_MIXER_NAMESPACE::log_level::warn) -#define LOG_WARN(msg) LOG(DEFAULT_LOGGER, MICROSOFT_MIXER_NAMESPACE::log_level::warn, defaultCategory, msg) -#define LOG_WARN_IF(boolean_expression, msg) if(boolean_expression) LOG_WARN(msg) -#define LOGS_WARN LOGS(DEFAULT_LOGGER, MICROSOFT_MIXER_NAMESPACE::log_level::warn, defaultCategory) -#define LOGS_WARN_IF(boolean_expression) if(boolean_expression) LOGS_WARN - -#define IF_LOG_INFO() IF_LOG_LEVEL_ENABLED(DEFAULT_LOGGER, MICROSOFT_MIXER_NAMESPACE::log_level::info) -#define LOG_INFO(msg) LOG(DEFAULT_LOGGER, MICROSOFT_MIXER_NAMESPACE::log_level::info, defaultCategory, msg) -#define LOG_INFO_IF(boolean_expression, msg) if(boolean_expression) LOG_INFO(msg) -#define LOGS_INFO LOGS(DEFAULT_LOGGER, MICROSOFT_MIXER_NAMESPACE::log_level::info, defaultCategory) -#define LOGS_INFO_IF(boolean_expression) if(boolean_expression) LOGS_INFO - -#define IF_LOG_DEBUG() IF_LOG_LEVEL_ENABLED(DEFAULT_LOGGER, MICROSOFT_MIXER_NAMESPACE::log_level::debug) -#define LOG_DEBUG(msg) LOG(DEFAULT_LOGGER, MICROSOFT_MIXER_NAMESPACE::log_level::debug, defaultCategory, msg) -#define LOG_DEBUG_IF(boolean_expression, msg) if(boolean_expression) LOG_DEBUG(msg) -#define LOGS_DEBUG LOGS(DEFAULT_LOGGER, MICROSOFT_MIXER_NAMESPACE::log_level::debug, defaultCategory) -#define LOGS_DEBUG_IF(boolean_expression) if(boolean_expression) LOGS_DEBUG - -NAMESPACE_MICROSOFT_MIXER_BEGIN - -enum class log_level -{ - off, - error, - warn, - info, - debug -}; - -class log_entry -{ -public: - log_entry(log_level level, std::string category); - - log_entry(log_level level, std::string category, std::string msg); - - std::string level_to_string() const; - - const std::stringstream& msg_stream() const { return m_message; } - - const std::string& category() const { return m_category; } - log_level get_log_level() const { return m_logLevel; } - - log_entry& operator<<(const char* data) - { - m_message << utility::conversions::to_utf8string(data); - return *this; - } - - log_entry& operator<<(const std::string& data) - { - m_message << utility::conversions::to_utf8string(data); - return *this; - } - -#if !BEAM_U - log_entry& operator<<(const wchar_t* data) - { - m_message << utility::conversions::to_utf8string(data); - return *this; - } - - log_entry& operator<<(const std::wstring& data) - { - m_message << utility::conversions::to_utf8string(data); - return *this; - } -#endif - - template - log_entry& operator<<(const T& data) - { - m_message << data; - return *this; - } - -private: - log_level m_logLevel; - std::string m_category; - std::stringstream m_message; -}; - -enum log_output_level_setting -{ - use_logger_setting, - use_own_setting -}; - -class log_output -{ -public: - // When log_output_type is set to use_logger_setting, the level parameter will be ignored. - log_output(log_output_level_setting type, log_level level); - - virtual void add_log(_In_ const log_entry& entry); - - log_output_level_setting level_setting() const { return m_levelSetting; } - - bool log_level_enabled(log_level level) const { return level <= m_logLevel; } - - void set_log_level(log_level level) { m_logLevel = level; } - -protected: - // This function is to write the string to the final output, don't need to be thread safe. - virtual void write(_In_ const std::string& msg); - - virtual std::string format_log(_In_ const log_entry& entry); - -private: - log_output_level_setting m_levelSetting; - log_level m_logLevel; - mutable std::mutex m_mutex; -}; - -class logger -{ -public: - logger() : m_logLevel(log_level::warn) {} - - static void create_logger() { s_logger = std::make_shared(); } - static void release_logger() { s_logger = nullptr; } - static const std::shared_ptr& get_logger() { return s_logger; } - - void set_log_level(log_level level); - - void add_log_output(std::shared_ptr output); - - void add_log(const log_entry& entry); - void operator+=(const log_entry& record); - - -private: - static std::shared_ptr s_logger; - - std::vector> m_log_outputs; - log_level m_logLevel; -}; - -NAMESPACE_MICROSOFT_MIXER_END diff --git a/Source/Util/log_entry.cpp b/Source/Util/log_entry.cpp deleted file mode 100644 index cd35b85..0000000 --- a/Source/Util/log_entry.cpp +++ /dev/null @@ -1,47 +0,0 @@ -//********************************************************* -// -// Copyright (c) Microsoft. All rights reserved. -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//********************************************************* -#include "pch.h" -#include "log.h" - -NAMESPACE_MICROSOFT_MIXER_BEGIN - -log_entry::log_entry(log_level level, std::string category) : - m_logLevel(level), - m_category(std::move(category)) -{ - -} - -log_entry::log_entry(log_level level, std::string category, std::string msg) : - m_logLevel(level), - m_category(std::move(category)) -{ - m_message << msg; -} - -std::string log_entry::level_to_string() const -{ - switch (m_logLevel) - { - case log_level::error: - return "error"; - case log_level::warn: - return "warn"; - case log_level::info: - return "info"; - case log_level::debug: - return "debug"; - } - - return ""; -} - - -NAMESPACE_MICROSOFT_MIXER_END diff --git a/Source/Util/log_output.cpp b/Source/Util/log_output.cpp deleted file mode 100644 index 6fe48a7..0000000 --- a/Source/Util/log_output.cpp +++ /dev/null @@ -1,56 +0,0 @@ -//********************************************************* -// -// Copyright (c) Microsoft. All rights reserved. -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//********************************************************* -#include "pch.h" -#include "log.h" -#include - -NAMESPACE_MICROSOFT_MIXER_BEGIN - -log_output::log_output(log_output_level_setting setting, log_level level): - m_levelSetting(setting), - m_logLevel(level) -{ -} - -void log_output::add_log(_In_ const log_entry& entry) -{ - std::string msg = format_log(entry); - { - std::lock_guard lock(m_mutex); - write(msg); - } -} - -void log_output::write(_In_ const std::string& msg) -{ - UNREFERENCED_PARAMETER(msg); -} - -std::string -log_output::format_log(_In_ const log_entry& entry) -{ - std::stringstream stream; - std::time_t t = std::time(nullptr); - std::tm tm_snapshot; -#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) - localtime_s(&tm_snapshot, &t); -#else - localtime_r(&t, &tm_snapshot); // POSIX -#endif - - // format : "