Initial commit

This commit is contained in:
alexpete
2021-03-05 11:26:34 -08:00
commit a10351f38d
27091 changed files with 5521199 additions and 0 deletions
@@ -0,0 +1,67 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
ly_add_target(
NAME VideoPlaybackFramework.Static STATIC
NAMESPACE Gem
FILES_CMAKE
videoplaybackframework_files.cmake
INCLUDE_DIRECTORIES
PRIVATE
Source
PUBLIC
.
Include
BUILD_DEPENDENCIES
PUBLIC
AZ::AzCore
PRIVATE
AZ::AzFramework
)
ly_add_target(
NAME VideoPlaybackFramework ${PAL_TRAIT_MONOLITHIC_DRIVEN_MODULE_TYPE}
NAMESPACE Gem
OUTPUT_NAME Gem.VideoPlaybackFramework.560d69cbaafd40bea8a09bccfe7f77e6.v0.1.0
FILES_CMAKE
videoplaybackframework_shared_files.cmake
INCLUDE_DIRECTORIES
PRIVATE
Source
PUBLIC
Include
BUILD_DEPENDENCIES
PRIVATE
Gem::VideoPlaybackFramework.Static
)
################################################################################
# Tests
################################################################################
if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
ly_add_target(
NAME VideoPlaybackFramework.Tests ${PAL_TRAIT_TEST_TARGET_TYPE}
NAMESPACE Gem
FILES_CMAKE
videoplaybackframework_tests_files.cmake
INCLUDE_DIRECTORIES
PRIVATE
Source
Tests
BUILD_DEPENDENCIES
PRIVATE
AZ::AzTest
Gem::VideoPlaybackFramework.Static
)
ly_add_googletest(
NAME Gem::VideoPlaybackFramework.Tests
)
endif()
@@ -0,0 +1,28 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/std/string/string.h>
namespace VideoPlaybackFramework
{
class VideoPlaybackAsset
{
public:
AZ_TYPE_INFO(VideoPlaybackAsset, "{DDFEE0B2-9E5A-412C-8C77-AB100E24C1DF}");
static const char* GetFileFilter()
{
return "*.mp4;*.mkv;*.webm;*.mov";
}
};
} // namespace VideoPlaybackFramework
@@ -0,0 +1,174 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/EBus/EBus.h>
#include <AzCore/Component/EntityId.h>
namespace VideoPlaybackFramework
{
class VideoPlaybackRequests
: public AZ::EBusTraits
{
public:
//////////////////////////////////////////////////////////////////////////
// EBusTraits overrides
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById;
typedef AZ::EntityId BusIdType;
//////////////////////////////////////////////////////////////////////////
VideoPlaybackRequests() = default;
virtual ~VideoPlaybackRequests() = default;
/*
* Start/resume playing a movie that is attached to the current entity.
*/
virtual void Play() = 0;
/*
* Pause a movie that is attached to the current entity.
*/
virtual void Pause() = 0;
/*
* Stop playing a movie that is attached to the current entity.
*/
virtual void Stop() = 0;
/*
* Returns whether or not the video is currently playing
*
* @return True if the video is currently playing. False if the video is paused or stopped
*/
virtual bool IsPlaying() = 0;
/*
* Get how many frames ahead the decoder should try to be when decoding this video
*
* @return Returns How many frames ahead the decoder should try to be when decoding this video
*/
virtual AZ::u32 GetQueueAheadCount() = 0;
/* Sets how many frames ahead the decoder should try to be when decoding this video
*
* @param queueAheadCount How many frames ahead the decoder should try to be when decoding this video
*/
virtual void SetQueueAheadCount(AZ::u32 queueAheadCount) = 0;
/*
* Get whether or not the movie attached to the current entity should loop
*
* @return True if the video is set to loop. False otherwise
*/
virtual bool GetIsLooping() = 0;
/*
* Set whether or not the movie attached to the current entity should loop
*
* @param isLooping Whether the video should loop
*/
virtual void SetIsLooping(bool isLooping) = 0;
/*
* Get whether or not the video should start playing automatically on activate
*
* @return True if the video is set to start playing automatically. False otherwise
*/
virtual bool GetIsAutoPlay() = 0;
/*
* Set whether or not the video should start playing automatically on activate
*
* @param isAutoPlay Whether the video should play automatically
*/
virtual void SetIsAutoPlay(bool isAutoPlay) = 0;
/*
* Get the playback speed factor
*
* @return Returns the playback speed factor
*/
virtual float GetPlaybackSpeed() = 0;
/* Sets the playback speed based on a factor of the current playback speed
*
* For example you can play at half speed by passing 0.5f or play at double speed by
* passing 2.0f.
*
* @param speedFactor The speed modification factor to apply to playback speed
*/
virtual void SetPlaybackSpeed(float speedFactor) = 0;
/*
* Get the source location of the video
* @return Returns the source location of the video
*/
virtual AZStd::string GetVideoPathname() const = 0;
/*
* Set the source location of the video
*
* @param videoPath The source location of the video
*/
virtual void SetVideoPathname(const AZStd::string& videoPath) = 0;
virtual AZStd::string GetDestinationTextureName() const = 0;
virtual void SetDestinationTextureName(const AZStd::string& destinationTextureName) = 0;
};
using VideoPlaybackRequestBus = AZ::EBus<VideoPlaybackRequests>;
class VideoPlaybackNotifications
: public AZ::EBusTraits
{
public:
//////////////////////////////////////////////////////////////////////////
// EBusTraits overrides
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById;
typedef AZ::EntityId BusIdType;
//////////////////////////////////////////////////////////////////////////
VideoPlaybackNotifications() = default;
virtual ~VideoPlaybackNotifications() = default;
/*
* Event that fires when the movie starts playback.
*/
virtual void OnPlaybackStarted() = 0;
/*
* Event that fires when the movie pauses playback.
*/
virtual void OnPlaybackPaused() = 0;
/*
* Event that fires when the movie stops playback.
*/
virtual void OnPlaybackStopped() = 0;
/*
* Event that fires when the movie completes playback.
*/
virtual void OnPlaybackFinished() = 0;
/*
* Event that fires when the first frame gets presented.
*/
virtual void OnFirstFramePresented() = 0;
};
using VideoPlaybackNotificationBus = AZ::EBus<VideoPlaybackNotifications>;
} // namespace VideoPlaybackFramework
@@ -0,0 +1,32 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/EBus/EBus.h>
namespace VideoPlaybackFramework
{
class VideoPlaybackFrameworkRequests
: public AZ::EBusTraits
{
public:
//////////////////////////////////////////////////////////////////////////
// EBusTraits overrides
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
//////////////////////////////////////////////////////////////////////////
// Put your public methods here
};
using VideoPlaybackFrameworkRequestBus = AZ::EBus<VideoPlaybackFrameworkRequests>;
} // namespace VideoPlaybackFramework
@@ -0,0 +1,37 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include "VideoPlaybackFrameworkModule.h"
#include "VideoPlaybackFrameworkSystemComponent.h"
namespace VideoPlaybackFramework
{
VideoPlaybackFrameworkModule::VideoPlaybackFrameworkModule()
{
// Push results of [MyComponent]::CreateDescriptor() into m_descriptors here.
m_descriptors.insert(m_descriptors.end(), {
VideoPlaybackFrameworkSystemComponent::CreateDescriptor(),
});
}
AZ::ComponentTypeList VideoPlaybackFrameworkModule::GetRequiredSystemComponents() const
{
return AZ::ComponentTypeList{
azrtti_typeid<VideoPlaybackFrameworkSystemComponent>(),
};
}
}
// DO NOT MODIFY THIS LINE UNLESS YOU RENAME THE GEM
// The first parameter should be GemName_GemIdLower
// The second should be the fully qualified name of the class above
AZ_DECLARE_MODULE_CLASS(Gem_VideoPlaybackFramework, VideoPlaybackFramework::VideoPlaybackFrameworkModule)
@@ -0,0 +1,34 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/Module/Module.h>
#include <AzCore/Memory/SystemAllocator.h>
namespace VideoPlaybackFramework
{
class VideoPlaybackFrameworkModule
: public AZ::Module
{
public:
AZ_RTTI(VideoPlaybackFrameworkModule, "{5FCBDEE8-C3EC-45DD-9B71-B37D1F7A299A}", AZ::Module);
AZ_CLASS_ALLOCATOR(VideoPlaybackFrameworkModule, AZ::SystemAllocator, 0);
VideoPlaybackFrameworkModule();
/**
* Add required SystemComponents to the SystemEntity.
*/
AZ::ComponentTypeList GetRequiredSystemComponents() const override;
};
}
@@ -0,0 +1,155 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/EditContext.h>
#include <AzCore/RTTI/BehaviorContext.h>
#include <AzFramework/Asset/SimpleAsset.h>
#include <AzCore/Asset/AssetManagerBus.h>
#include "VideoPlaybackFrameworkSystemComponent.h"
#include "Include/VideoPlaybackFramework/VideoPlaybackAsset.h"
#include "Include/VideoPlaybackFramework/VideoPlaybackBus.h"
namespace VideoPlaybackFramework
{
class BehaviorVideoPlaybackNotificationBusHandler
: public VideoPlaybackNotificationBus::Handler
, public AZ::BehaviorEBusHandler
{
public:
AZ_EBUS_BEHAVIOR_BINDER(BehaviorVideoPlaybackNotificationBusHandler, "{F3116FA1-3F81-4ADE-9941-C5A5C838197B}", AZ::SystemAllocator,
OnPlaybackStarted,
OnPlaybackPaused,
OnPlaybackStopped,
OnPlaybackFinished,
OnFirstFramePresented
);
// Sent when playback starts or resumes
void OnPlaybackStarted() override
{
Call(FN_OnPlaybackStarted);
}
// Sent when the video is paused
void OnPlaybackPaused() override
{
Call(FN_OnPlaybackPaused);
}
// Sent when the video is stopped
void OnPlaybackStopped() override
{
Call(FN_OnPlaybackStopped);
}
// Sent when the video finishes
void OnPlaybackFinished() override
{
Call(FN_OnPlaybackFinished);
}
// Sent when the video decodes first frame
void OnFirstFramePresented() override
{
Call(FN_OnFirstFramePresented);
}
};
void VideoPlaybackFrameworkSystemComponent::Reflect(AZ::ReflectContext* context)
{
if (AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context))
{
AzFramework::SimpleAssetReference<VideoPlaybackAsset>::Register(*serialize);
serialize->Class<VideoPlaybackFrameworkSystemComponent, AZ::Component>()
->Version(0)
;
if (AZ::EditContext* ec = serialize->GetEditContext())
{
ec->Class<VideoPlaybackFrameworkSystemComponent>("VideoPlaybackFramework", "Interface framework to play back video during gameplay.")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("System"))
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
;
}
}
if (AZ::BehaviorContext* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
{
behaviorContext->EBus<VideoPlaybackRequestBus>("VideoPlaybackRequestBus")
->Event("Play", &VideoPlaybackRequestBus::Events::Play)
->Event("Pause", &VideoPlaybackRequestBus::Events::Pause)
->Event("Stop", &VideoPlaybackRequestBus::Events::Stop)
->Event("IsPlaying", &VideoPlaybackRequestBus::Events::IsPlaying)
->Event("GetQueueAheadCount", &VideoPlaybackRequestBus::Events::GetQueueAheadCount)
->Event("SetQueueAheadCount", &VideoPlaybackRequestBus::Events::SetQueueAheadCount)
->Event("GetIsLooping", &VideoPlaybackRequestBus::Events::GetIsLooping)
->Event("SetIsLooping", &VideoPlaybackRequestBus::Events::SetIsLooping)
->Event("GetIsAutoPlay", &VideoPlaybackRequestBus::Events::GetIsAutoPlay)
->Event("SetIsAutoPlay", &VideoPlaybackRequestBus::Events::SetIsAutoPlay)
->Event("GetPlaybackSpeed", &VideoPlaybackRequestBus::Events::GetPlaybackSpeed)
->Event("SetPlaybackSpeed", &VideoPlaybackRequestBus::Events::SetPlaybackSpeed)
->Event("GetVideoPathname", &VideoPlaybackRequestBus::Events::GetVideoPathname)
->Event("SetVideoPathname", &VideoPlaybackRequestBus::Events::SetVideoPathname)
->Event("GetDestinationTextureName", &VideoPlaybackRequestBus::Events::GetDestinationTextureName)
->Event("SetDestinationTextureName", &VideoPlaybackRequestBus::Events::SetDestinationTextureName)
;
behaviorContext->EBus<VideoPlaybackNotificationBus>("VideoPlaybackNotificationBus")
->Handler<BehaviorVideoPlaybackNotificationBusHandler>()
;
}
}
void VideoPlaybackFrameworkSystemComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
{
provided.push_back(AZ_CRC("VideoPlaybackFrameworkService"));
}
void VideoPlaybackFrameworkSystemComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
{
incompatible.push_back(AZ_CRC("VideoPlaybackFrameworkService"));
}
void VideoPlaybackFrameworkSystemComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
{
(void)required;
}
void VideoPlaybackFrameworkSystemComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
{
(void)dependent;
}
void VideoPlaybackFrameworkSystemComponent::Init()
{
}
void VideoPlaybackFrameworkSystemComponent::Activate()
{
VideoPlaybackFrameworkRequestBus::Handler::BusConnect();
EBUS_EVENT(AZ::Data::AssetCatalogRequestBus, EnableCatalogForAsset, azrtti_typeid<VideoPlaybackAsset>());
EBUS_EVENT(AZ::Data::AssetCatalogRequestBus, AddExtension, "mp4");
EBUS_EVENT(AZ::Data::AssetCatalogRequestBus, AddExtension, "mkv");
EBUS_EVENT(AZ::Data::AssetCatalogRequestBus, AddExtension, "webm");
EBUS_EVENT(AZ::Data::AssetCatalogRequestBus, AddExtension, "mov");
}
void VideoPlaybackFrameworkSystemComponent::Deactivate()
{
VideoPlaybackFrameworkRequestBus::Handler::BusDisconnect();
}
}
@@ -0,0 +1,48 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/Component/Component.h>
#include <VideoPlaybackFramework/VideoPlaybackFrameworkBus.h>
namespace VideoPlaybackFramework
{
class VideoPlaybackFrameworkSystemComponent
: public AZ::Component
, protected VideoPlaybackFrameworkRequestBus::Handler
{
public:
AZ_COMPONENT(VideoPlaybackFrameworkSystemComponent, "{4E65B365-7BFF-46BB-96E1-2129822CB30E}");
static void Reflect(AZ::ReflectContext* context);
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
protected:
////////////////////////////////////////////////////////////////////////
// VideoPlaybackFrameworkRequestBus interface implementation
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
// AZ::Component interface implementation
void Init() override;
void Activate() override;
void Deactivate() override;
////////////////////////////////////////////////////////////////////////
};
}
@@ -0,0 +1,43 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <AzTest/AzTest.h>
#include <AzCore/Component/ComponentApplication.h>
#include <AzCore/Component/Entity.h>
#include <AzCore/UserSettings/UserSettingsComponent.h>
#include <VideoPlaybackFrameworkModule.h>
#include <VideoPlaybackFrameworkSystemComponent.h>
TEST(VideoPlaybackFrameworkTest, ComponentsWithComponentApplication)
{
AZ::ComponentApplication::Descriptor appDesc;
appDesc.m_memoryBlocksByteSize = 10 * 1024 * 1024;
appDesc.m_recordingMode = AZ::Debug::AllocationRecords::RECORD_FULL;
appDesc.m_stackRecordLevels = 20;
AZ::ComponentApplication app;
AZ::Entity* systemEntity = app.Create(appDesc);
ASSERT_TRUE(systemEntity != nullptr);
app.RegisterComponentDescriptor(VideoPlaybackFramework::VideoPlaybackFrameworkSystemComponent::CreateDescriptor());
systemEntity->CreateComponent<VideoPlaybackFramework::VideoPlaybackFrameworkSystemComponent>();
systemEntity->Init();
systemEntity->Activate();
app.Destroy();
ASSERT_TRUE(true);
}
AZ_UNIT_TEST_HOOK(DEFAULT_UNIT_TEST_ENV);
@@ -0,0 +1,18 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
set(FILES
Include/VideoPlaybackFramework/VideoPlaybackFrameworkBus.h
Include/VideoPlaybackFramework/VideoPlaybackBus.h
Include/VideoPlaybackFramework/VideoPlaybackAsset.h
Source/VideoPlaybackFrameworkSystemComponent.cpp
Source/VideoPlaybackFrameworkSystemComponent.h
)
@@ -0,0 +1,15 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
set(FILES
Source/VideoPlaybackFrameworkModule.cpp
Source/VideoPlaybackFrameworkModule.h
)
@@ -0,0 +1,16 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
set(FILES
Source/VideoPlaybackFrameworkModule.cpp
Source/VideoPlaybackFrameworkModule.h
Tests/VideoPlaybackFrameworkTest.cpp
)