Skip to content

Commit 5c43a0b

Browse files
committed
APL-CORE: October 2022 Release of APL 2022.2 compilant core engine (2022.2.0)
For more details on this release refer to CHANGELOG.md To learn about APL see: https://developer.amazon.com/docs/alexa-presentation-language/understand-apl.html
1 parent 5fcb4d4 commit 5c43a0b

File tree

247 files changed

+24160
-592
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

247 files changed

+24160
-592
lines changed

CHANGELOG.md

+15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
# Changelog
22

3+
## [2022.2]
4+
5+
This release adds support for version 2022.2 of the APL specification.
6+
7+
### Added
8+
9+
- Support selective preservation of sequencers and associated state upon re-inflation.
10+
- Allow easy synchronization of visual and audio with onSpeechMark handler.
11+
- Alpha feature: Scene graph rendering to provide simplified drawing instructions to the view host.
12+
13+
### Changed
14+
15+
- Bug fixes.
16+
- Videos can be muted/unmuted by setting the corresponding property.
17+
318
## [2022.1.1]
419

520
### Changed

CMakeLists.txt

+2-3
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,13 @@
1616
include(FetchContent OPTIONAL RESULT_VARIABLE HAS_FETCH_CONTENT)
1717

1818
cmake_minimum_required(VERSION 3.5)
19+
set(CMAKE_CXX_STANDARD 11)
20+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
1921

2022
project(APLCoreEngine
2123
VERSION 1.0.0
2224
LANGUAGES CXX)
2325

24-
set(CMAKE_CXX_STANDARD 11)
25-
set(CMAKE_CXX_STANDARD_REQUIRED ON)
26-
2726
if (NOT APL_CORE_DIR)
2827
set(APL_CORE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
2928
endif()

apl-dev-env.sh

+8
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,14 @@ function apl-build-core { # Run make for the core build
109109
)
110110
}
111111

112+
function apl-install-core { # Run make install
113+
(
114+
apl-switch-to-build-directory build $@ && \
115+
$CMAKE -DBUILD_TESTS=ON -DCOVERAGE=OFF .. && \
116+
make install -j$APL_BUILD_PROCS
117+
)
118+
}
119+
112120
function apl-check-core { # Run make for the core build with -Werror
113121
(
114122
apl-switch-to-build-directory build $@ && \

aplcore/CMakeLists.txt

+14-2
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,18 @@ if (TARGET yoga)
5353
add_dependencies(apl yoga)
5454
endif()
5555

56-
add_dependencies(apl pegtl-build)
56+
if (NOT HAS_FETCH_CONTENT)
57+
add_dependencies(apl pegtl-build)
58+
endif()
5759

5860
# When not using the system rapidjson build the library, add a dependency on the build step
59-
if (NOT USE_SYSTEM_RAPIDJSON)
61+
if (NOT USE_SYSTEM_RAPIDJSON AND NOT HAS_FETCH_CONTENT)
6062
add_dependencies(apl rapidjson-build)
6163
endif()
6264

6365
add_subdirectory(src/action)
6466
add_subdirectory(src/animation)
67+
add_subdirectory(src/audio)
6568
add_subdirectory(src/command)
6669
add_subdirectory(src/component)
6770
add_subdirectory(src/content)
@@ -76,6 +79,9 @@ add_subdirectory(src/livedata)
7679
add_subdirectory(src/media)
7780
add_subdirectory(src/primitives)
7881
add_subdirectory(src/scaling)
82+
if(ENABLE_SCENEGRAPH)
83+
add_subdirectory(src/scenegraph)
84+
endif(ENABLE_SCENEGRAPH)
7985
add_subdirectory(src/time)
8086
add_subdirectory(src/touch)
8187
add_subdirectory(src/utils)
@@ -99,7 +105,9 @@ if (ENABLE_PIC)
99105
)
100106
endif()
101107

108+
# Generate a pkg-config file
102109
configure_file(apl.pc.in apl.pc @ONLY)
110+
103111
target_include_directories(apl
104112
PUBLIC
105113
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>
@@ -157,6 +165,10 @@ install(DIRECTORY ${PROJECT_SOURCE_DIR}/aplcore/include/apl
157165
DESTINATION include
158166
FILES_MATCHING PATTERN "*.h")
159167

168+
# Put the generated pkg-config file in the right directory?
169+
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/apl.pc
170+
DESTINATION lib/pkgconfig)
171+
160172
if (NOT USE_SYSTEM_RAPIDJSON)
161173
install(DIRECTORY ${RAPIDJSON_INCLUDE}/rapidjson
162174
DESTINATION include

aplcore/apl.pc.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ Description: @PROJECT_DESCRIPTION@
88
Version: @PROJECT_VERSION@
99

1010
Requires:
11-
Libs: -L${libdir} -lapl
11+
Libs: -L${libdir} -lapl @YOGA_PC_LIBS@
1212
Cflags: -I${includedir}

aplcore/include/apl/action/action.h

+13
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,19 @@ class Action : public std::enable_shared_from_this<Action>,
192192

193193
friend streamer& operator<<(streamer&, Action&);
194194

195+
/**
196+
* Freeze action state and memoize any of state required to "revive" this action in the different
197+
* context.
198+
*/
199+
virtual void freeze();
200+
201+
/**
202+
* Revive an action in the new context.
203+
* @param context new RootContext.
204+
* @return true if successful, false otherwise.
205+
*/
206+
virtual bool rehydrate(const RootContext& context);
207+
195208
protected:
196209
virtual void onFinish() {}
197210

aplcore/include/apl/action/animatedscrollaction.h

+6
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#define _APL_ANIMATED_SCROLL_ACTION_H
1818

1919
#include "apl/action/resourceholdingaction.h"
20+
#include "apl/primitives/object.h"
2021

2122
namespace apl {
2223

@@ -27,6 +28,10 @@ class AnimatedScrollAction : public ResourceHoldingAction {
2728
public:
2829
CoreComponentPtr getScrollableContainer() const { return mContainer; }
2930

31+
32+
void freeze() override;
33+
bool rehydrate(const RootContext& context) override;
34+
3035
protected:
3136
AnimatedScrollAction(const TimersPtr& timers,
3237
const ContextPtr& context,
@@ -43,6 +48,7 @@ class AnimatedScrollAction : public ResourceHoldingAction {
4348
std::shared_ptr<AutoScroller> mScroller;
4449
ActionPtr mCurrentAction;
4550
apl_duration_t mDuration;
51+
std::string mFrozenContainerId;
4652
};
4753

4854

aplcore/include/apl/action/animateitemaction.h

+4
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,14 @@ class AnimateItemAction : public ResourceHoldingAction {
3737
const std::shared_ptr<CoreCommand>& command,
3838
bool fastMode);
3939

40+
void freeze() override;
41+
bool rehydrate(const RootContext& context) override;
42+
4043
private:
4144
void start();
4245
void advance();
4346
void finalize();
47+
void extractAnimators();
4448

4549
private:
4650
std::shared_ptr<CoreCommand> mCommand;

aplcore/include/apl/action/autopageaction.h

+4-6
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,6 @@ class Component;
2626

2727
/**
2828
* Scroll or page to bring a target component into view.
29-
*
30-
* This action results in either a kEventScrollTo or kEventPageTo event being fired.
31-
* The following properties are passed with the event:
32-
*
33-
* kCommandPropertyDirection Set to forward/back (only for PageTo)
34-
* kCommandPropertyPosition The scroll position or the page number.
3529
*/
3630
class AutoPageAction : public ResourceHoldingAction {
3731
public:
@@ -45,13 +39,17 @@ class AutoPageAction : public ResourceHoldingAction {
4539
int end,
4640
apl_time_t duration);
4741

42+
void freeze() override;
43+
bool rehydrate(const RootContext& context) override;
44+
4845
private:
4946
void advance();
5047

5148
private:
5249
std::shared_ptr<CoreCommand> mCommand;
5350
ComponentPtr mContainer;
5451
ActionPtr mCurrentAction;
52+
size_t mCurrentIndex;
5553
size_t mNextIndex;
5654
size_t mEndIndex;
5755
apl_time_t mDuration;

aplcore/include/apl/action/delayaction.h

+3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ class DelayAction : public Action {
3535
*/
3636
DelayAction(const TimersPtr& timers, const CommandPtr& command, bool fastMode);
3737

38+
void freeze() override;
39+
bool rehydrate(const RootContext& context) override;
40+
3841
private:
3942
/**
4043
* This method must be called to start the action running.

aplcore/include/apl/action/playmediaaction.h

+7
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#define _APL_PLAY_MEDIA_ACTION_H
1818

1919
#include "apl/action/resourceholdingaction.h"
20+
#include "apl/primitives/object.h"
2021

2122
namespace apl {
2223

@@ -38,12 +39,18 @@ class PlayMediaAction : public ResourceHoldingAction {
3839
const std::shared_ptr<CoreCommand>& command,
3940
const ComponentPtr& target);
4041

42+
void freeze() override;
43+
bool rehydrate(const RootContext& context) override;
44+
4145
private:
4246
void start();
4347

4448
private:
4549
std::shared_ptr<CoreCommand> mCommand;
4650
ComponentPtr mTarget;
51+
MediaPlayerPtr mPlayer;
52+
Object mSource;
53+
Object mPlayingState;
4754
};
4855

4956
} // namespace apl

aplcore/include/apl/action/resourceholdingaction.h

+3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ class ResourceHoldingAction : public Action {
2828
ResourceHoldingAction(const TimersPtr& timers,
2929
const ContextPtr& context);
3030

31+
void freeze() override;
32+
bool rehydrate(const RootContext& context) override;
33+
3134
protected:
3235
void onFinish() override;
3336

aplcore/include/apl/action/scrollaction.h

+4-6
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@ class AnimatedProperty;
2626

2727
/**
2828
* Scroll to position in scrollable component.
29-
*
30-
* This action results in a kEventTypeScrollTo event being fired.
31-
* The following properties are passed with the event:
32-
*
33-
* kEventPropertyPosition The scroll position.
3429
*/
3530
class ScrollAction : public AnimatedScrollAction {
3631
public:
@@ -54,14 +49,17 @@ class ScrollAction : public AnimatedScrollAction {
5449
const ContextPtr& context,
5550
const CoreComponentPtr& target,
5651
const Object& targetDistance,
57-
apl_duration_t duration = 0);
52+
apl_duration_t duration = -1);
5853

5954
ScrollAction(const TimersPtr& timers,
6055
const ContextPtr& context,
6156
const CoreComponentPtr& target,
6257
const Object& targetDistance,
6358
apl_duration_t duration);
6459

60+
void freeze() override;
61+
bool rehydrate(const RootContext& context) override;
62+
6563
private:
6664
void start();
6765

aplcore/include/apl/action/scrolltoaction.h

+27-16
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,6 @@ class Component;
2626

2727
/**
2828
* Scroll or page to bring a target component into view.
29-
*
30-
* This action results in either a kEventScrollTo or kEventPageTo event being fired.
31-
* The following properties are passed with the event:
32-
*
33-
* kCommandPropertyDirection Set to forward/back (only for PageTo)
34-
* kCommandPropertyPosition The scroll position or the page number.
3529
*/
3630
class ScrollToAction : public AnimatedScrollAction {
3731
public:
@@ -62,7 +56,7 @@ class ScrollToAction : public AnimatedScrollAction {
6256
/**
6357
* Called from rootcontext by viewhost during line karaoke.
6458
* @param timers Timer reference.
65-
* @param align Scroll slignment.
59+
* @param align Scroll alignment.
6660
* @param subBounds Bounds within the target to scroll to.
6761
* @param context Target context.
6862
* @param target Component to scroll to.
@@ -74,6 +68,25 @@ class ScrollToAction : public AnimatedScrollAction {
7468
const ContextPtr& context,
7569
const CoreComponentPtr& target = nullptr);
7670

71+
/**
72+
* @param timers Timer reference.
73+
* @param align Scroll alignment.
74+
* @param subBounds Bounds within the target to scroll to.
75+
* @param context Target context.
76+
* @param scrollToSubBounds Scroll to sub-bounds.
77+
* @param target Component to scroll to.
78+
* @param duration Scrolling duration.
79+
* @return The scroll to action or null if it is not needed.
80+
*/
81+
static std::shared_ptr<ScrollToAction> make(const TimersPtr& timers,
82+
const CommandScrollAlign& align,
83+
const Rect& subBounds,
84+
const ContextPtr& context,
85+
bool scrollToSubBounds,
86+
const CoreComponentPtr& target = nullptr,
87+
apl_duration_t duration = -1,
88+
bool useSnap = false);
89+
7790
/**
7891
* Called in order to bring child into view, utilizing snap setting if exists.
7992
* @param timers Timer reference.
@@ -94,16 +107,10 @@ class ScrollToAction : public AnimatedScrollAction {
94107
const CoreComponentPtr& scrollableParent,
95108
apl_duration_t duration);
96109

97-
private:
98-
static std::shared_ptr<ScrollToAction> make(const TimersPtr& timers,
99-
const CommandScrollAlign& align,
100-
const Rect& subBounds,
101-
const ContextPtr& context,
102-
bool scrollToSubBounds,
103-
const CoreComponentPtr& target = nullptr,
104-
apl_duration_t duration = 0,
105-
bool useSnap = false);
110+
void freeze() override;
111+
bool rehydrate(const RootContext& context) override;
106112

113+
private:
107114
void start();
108115
void pageTo();
109116
void scrollTo();
@@ -113,6 +120,10 @@ class ScrollToAction : public AnimatedScrollAction {
113120
Rect mSubBounds;
114121
bool mScrollToSubBounds;
115122
CoreComponentPtr mTarget;
123+
124+
std::string mFrozenContainerId;
125+
std::string mFrozenTargetId;
126+
size_t mFrozenTargetIndex = -1;
116127
};
117128

118129

aplcore/include/apl/action/sequentialaction.h

+9-7
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,22 @@ namespace apl {
2424
class SequentialAction : public Action {
2525
public:
2626
static std::shared_ptr<SequentialAction> make(const TimersPtr& timers,
27-
std::shared_ptr<const CoreCommand> command, bool fastMode) {
28-
auto ptr = std::make_shared<SequentialAction>(timers, command, fastMode);
29-
ptr->advance();
30-
return ptr;
31-
}
27+
std::shared_ptr<CoreCommand>& command,
28+
bool fastMode);
3229

33-
SequentialAction(const TimersPtr& timers, std::shared_ptr<const CoreCommand> command, bool fastMode);
30+
SequentialAction(const TimersPtr& timers,
31+
std::shared_ptr<CoreCommand>& command,
32+
bool fastMode);
33+
34+
void freeze() override;
35+
bool rehydrate(const RootContext& context) override;
3436

3537
private:
3638
void advance();
3739
bool doCommand(const Object& command);
3840

3941
private:
40-
std::shared_ptr<const CoreCommand> mCommand;
42+
std::shared_ptr<CoreCommand> mCommand;
4143
bool mFastMode;
4244
bool mStateFinally;
4345

0 commit comments

Comments
 (0)