RDK Documentation (Open Sourced RDK Components)
LifeCycle.h
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2018 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 
20 #ifndef _GRAPHICS_LIFECYCLE_H_
21 #define _GRAPHICS_LIFECYCLE_H_
22 
23 /**
24  * @defgroup FIREBOLT Firebolt
25  *
26  * RDK Firebolt SDK (previously called RNE) is intended to provide a development environment for applications targeted to run on RDK.
27  * Firebolt SDK can be used by application developers to develop HTML5, Spark & Native applications for RDK.
28  * The SDK comes with an RDK image which can be loaded on the target platform on which applications can be developed and executed.
29  *
30  * @defgroup Graphics Sample Graphics Sample
31  *
32  * rne-triangle sample app demonstrates a simple graphics app that uses opengl es and wayland to render a spinning triangle to the screen * The following key features are demostrated:
33  * - How to use wayland and OpenGL ES to render graphics
34  * - How to get keyboard/remote input
35  * - How to get screen resolution
36  * @ingroup FIREBOLT
37  *
38  * @defgroup Graphics-lifecycle Graphics-lifecycle
39  *
40  * Graphics-lifecycle sample app extends the rne-triangle sample app to support rt and suspend/resume.
41  * The following key features are demonstrated:
42  * - How to use wayland and OpenGL ES to render graphics
43  * - How to get keyboard/remote input
44  * - How to get screen resolution
45  * - How to setup and register an object with rt
46  * - How to handle suspend/resume
47  * @ingroup FIREBOLT
48  *
49  * @defgroup MSE Player Sample MSE Player Sample
50  *
51  * The MSE (Media Source Extensions) player sample app demos how to put everything together for a more real world example.
52  * The app will show how to build a gstreamer pipeline that can be fed raw H264 and AAC frames asynchronously.
53  * The sample content contains three separate fragments of the same video to show how to simulate a seek by flushing the video pipeline
54  * and providing new samples at different period in time.
55  * The app also uses the essos library which simplifies setting up wayland for graphics and keyboard/remote input.
56  * The following key features are demonstrated:
57  * - How to setup and use a more complicated gstreamer pipeline with a custom source
58  * - How to setup and register an object with rt
59  * - How to handle suspend/resume
60  * @ingroup FIREBOLT
61  *
62  * @defgroup Player Sample Player Sample
63  *
64  * rne-player sample app shows how to build and use a simple gstreamer pipeline that uses westerosink.
65  * It will load a movie from a URL, buffer it, and play it back. The following key features are demonstrated:
66  * - How to build a simple gstreamer pipeline with westerossink
67  * - How to get screen resolution
68  * @ingroup FIREBOLT
69  */
70 
71 #include <rtRemote.h>
72 #include <rtError.h>
73 
74 #include "RtUtils.h"
75 
76 /**
77  * @addtogroup Graphics-lifecycle
78  * @{
79  */
80 
81 class GraphicsLifeCycle : public rtObject {
82 public:
83  rtDeclareObject(GraphicsLifeCycle, rtObject);
84  rtMethodNoArgAndNoReturn("suspend", suspend);
85  rtMethodNoArgAndNoReturn("resume", resume);
86 
88  virtual ~GraphicsLifeCycle();
89 
90  /**
91  * @brief This API is called by the app manager to suspend the currently running application.
92  *
93  * Apps when suspended should free all graphics and AV resources.
94  * Uses minimal CPU and RAM while running in the background.
95  * The app manager invokes suspend call from the app through rt.
96  *
97  * @return Returns RT_OK on success, appropriate error code otherwise.
98  */
99  rtError suspend();
100 
101  /**
102  * @brief This API is used to resume the application suspended by the app manager.
103  *
104  * @return Returns RT_OK on success, appropriate error code otherwise.
105  */
106  rtError resume();
107 
108  /**
109  * @brief This initializes the rt object, sets the event listeners and also set the remote ready flag.
110  *
111  * @param[in] rtUtils rt object.
112  *
113  * @return Returns RMF_SUCCESS on success, appropriate error code otherwise.
114  */
115  void setRtUtils(RtUtils* rtUtils);
116 
117  struct Callbacks {
118  void (*onResume)(const char* p);
119  void (*onSuspend)();
120  };
121 
122  /**
123  * @brief This API sets the callback functions.
124  *
125  * Apps should support a suspend and resume option if needed
126  * so they can start quickly and stay running in the background.
127  *
128  * @param[in] cb Callback functions to set.
129  *
130  * @return Returns RMF_SUCCESS on success, appropiate error code otherwise.
131  */
132  void setCallbacks(const Callbacks &cb);
133 private:
134  RtUtils* mRtUtils;
135  Callbacks mCb;
136 };
137 
138 #endif
139 /**
140  * @}
141  */
142 
GraphicsLifeCycle::resume
rtError resume()
This API is used to resume the application suspended by the app manager.
Definition: LifeCycle.cpp:53
RtUtils
Definition: RtUtils.h:27
GraphicsLifeCycle::Callbacks
Definition: LifeCycle.h:117
GraphicsLifeCycle::setRtUtils
void setRtUtils(RtUtils *rtUtils)
This initializes the rt object, sets the event listeners and also set the remote ready flag.
Definition: LifeCycle.cpp:37
GraphicsLifeCycle
Definition: LifeCycle.h:81
GraphicsLifeCycle::setCallbacks
void setCallbacks(const Callbacks &cb)
Definition: LifeCycle.cpp:42
GraphicsLifeCycle::suspend
rtError suspend()
Definition: LifeCycle.cpp:47