RDK Documentation (Open Sourced RDK Components)
AampDefine.h
Go to the documentation of this file.
1 /*
2  * If not stated otherwise in this file or this component's license 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 __AAMP_DEFINE_H__
21 #define __AAMP_DEFINE_H__
22 
23 /**
24  * @file AampDefine.h
25  * @brief Macros for Aamp
26  */
27 
28 #include <limits.h>
29 
30 #ifdef UNIT_TEST_ENABLED
31 #define AAMP_CFG_PATH "aamp.cfg"
32 #define AAMP_JSON_PATH "aampcfg.json"
33 #else
34 #define AAMP_CFG_PATH "/opt/aamp.cfg"
35 #define AAMP_JSON_PATH "/opt/aampcfg.json"
36 #endif
37 
38 
39 #define AAMP_VERSION "5.1"
40 #define AAMP_TUNETIME_VERSION 5
41 
42 //Stringification of Macro : use two levels of macros
43 #define MACRO_TO_STRING(s) X_STR(s)
44 #define X_STR(s) #s
45 
46 #if defined(REALTEKCE)
47 #define GST_VIDEOBUFFER_SIZE_BYTES_BASE 5242880 /**< XIONE-6722 more generous buffering - RealTek UHD specific */
48 #else
49 #define GST_VIDEOBUFFER_SIZE_BYTES_BASE 4194304
50 #endif
51 #define GST_AUDIOBUFFER_SIZE_BYTES_BASE 512000
52 #if defined(CONTENT_4K_SUPPORTED)
53 #define GST_VIDEOBUFFER_SIZE_BYTES (GST_VIDEOBUFFER_SIZE_BYTES_BASE*3)
54 #define GST_AUDIOBUFFER_SIZE_BYTES (GST_AUDIOBUFFER_SIZE_BYTES_BASE*3)
55 #else
56 #define GST_VIDEOBUFFER_SIZE_BYTES (GST_VIDEOBUFFER_SIZE_BYTES_BASE)
57 #define GST_AUDIOBUFFER_SIZE_BYTES (GST_AUDIOBUFFER_SIZE_BYTES_BASE)
58 #endif
59 
60 #define DEFAULT_ENCODED_CONTENT_BUFFER_SIZE (512*1024) /**< 512KB buffer is allocated for a content encoded curl download to minimize buffer reallocation*/
61 #define MAX_PTS_ERRORS_THRESHOLD 4
62 #define DEFAULT_WAIT_TIME_BEFORE_RETRY_HTTP_5XX_MS (1000) /**< Wait time in milliseconds before retry for 5xx errors */
63 #define MAX_PLAYLIST_CACHE_SIZE (3*1024) /**< Approx 3MB -> 2 video profiles + one audio profile + one iframe profile, 500-700K MainManifest */
64 
65 #define DEFAULT_ABR_CACHE_LIFE 5000 /**< Default ABR cache life in milli secs*/
66 #define DEFAULT_ABR_OUTLIER 5000000 /**< ABR outlier: 5 MB */
67 #define DEFAULT_ABR_SKIP_DURATION 6 /**< Initial skip duration of ABR - 6 sec */
68 #define DEFAULT_ABR_NW_CONSISTENCY_CNT 2 /**< ABR network consistency count */
69 #define DEFAULT_BUFFER_HEALTH_MONITOR_DELAY 10
70 #define DEFAULT_BUFFER_HEALTH_MONITOR_INTERVAL 5
71 #define DEFAULT_ABR_CACHE_LENGTH 3 /**< Default ABR cache length */
72 #define DEFAULT_REPORT_PROGRESS_INTERVAL 1 /**< Progress event reporting interval: 1sec */
73 #define DEFAULT_LICENSE_REQ_RETRY_WAIT_TIME 500 /**< Wait time in milliseconds before retrying for DRM license */
74 #define MIN_LICENSE_KEY_ACQUIRE_WAIT_TIME 500 /**<minimum wait time in milliseconds for DRM license to ACQUIRE */
75 #define DEFAULT_LICENSE_KEY_ACQUIRE_WAIT_TIME 5000 /**< Wait time in milliseconds for DRM license to ACQUIRE */
76 #define MAX_LICENSE_ACQ_WAIT_TIME 12000 /**< 12 secs Increase from 10 to 12 sec(DELIA-33528) */
77 #define DEFAULT_INIT_BITRATE 2500000 /**< Initial bitrate: 2.5 mb - for non-4k playback */
78 #define DEFAULT_BITRATE_OFFSET_FOR_DOWNLOAD 500000 /**< Offset in bandwidth window for checking buffer download expiry */
79 #define DEFAULT_INIT_BITRATE_4K 13000000 /**< Initial bitrate for 4K playback: 13mb ie, 3/4 profile */
80 #define AAMP_LIVE_OFFSET 15 /**< Live offset in seconds */
81 #define AAMP_DEFAULT_PLAYBACK_OFFSET -99999 /**< default 'unknown' offset value */
82 #define AAMP_CDVR_LIVE_OFFSET 30 /**< Live offset in seconds for CDVR hot recording */
83 #define MIN_DASH_DRM_SESSIONS 3
84 #ifdef XIONE_UK
85 #define DEFAULT_CACHED_FRAGMENTS_PER_TRACK 3 /**< Default cached fragements per track - decreased only for XIONE UK per XIONE-6823 */
86 #else
87 #define DEFAULT_CACHED_FRAGMENTS_PER_TRACK 4 /**< Default cached fragements per track */
88 #endif
89 #define TRICKPLAY_VOD_PLAYBACK_FPS 4 /**< Frames rate for trickplay from CDN server */
90 #define TRICKPLAY_LINEAR_PLAYBACK_FPS 8 /**< Frames rate for trickplay from TSB */
91 #define DEFAULT_DOWNLOAD_RETRY_COUNT (1) /**< max download failure retry attempt count */
92 #define DEFAULT_DISCONTINUITY_TIMEOUT 3000 /**< Default discontinuity timeout after cache is empty in MS */
93 #define CURL_FRAGMENT_DL_TIMEOUT 10L /**< Curl timeout for fragment download */
94 #define DEFAULT_STALL_ERROR_CODE (7600) /**< Default stall error code: 7600 */
95 #define DEFAULT_STALL_DETECTION_TIMEOUT (10000) /**< Stall detection timeout: 10000 millisec */
96 #define DEFAULT_MINIMUM_INIT_CACHE_SECONDS 0 /**< Default initial cache size of playback */
97 #define DEFAULT_MAXIMUM_PLAYBACK_BUFFER_SECONDS 30 /**< Default maximum playback buffer size */
98 #define DEFAULT_TIMEOUT_FOR_SOURCE_SETUP (1000) /**< Default timeout value in milliseconds */
99 #define MAX_SEG_DRM_DECRYPT_FAIL_COUNT 10 /**< Max segment decryption failures to identify a playback failure. */
100 #define MAX_SEG_INJECT_FAIL_COUNT 10 /**< Max segment injection failure to identify a playback failure. */
101 #define AAMP_USERAGENT_BASE_STRING "Mozilla/5.0 (Linux; x86_64 GNU/Linux) AppleWebKit/601.1 (KHTML, like Gecko) Version/8.0 Safari/601.1 WPE" /**< Base User agent string,it will be appneded with AAMP_USERAGENT_SUFFIX */
102 #define AAMP_USERAGENT_SUFFIX "AAMP/"+AAMP_VERSION /**< Version string of AAMP Player */
103 #define DEFAULT_AAMP_ABR_THRESHOLD_SIZE (6000) /**< aamp abr threshold size */
104 #define DEFAULT_PREBUFFER_COUNT (2)
105 #define AAMP_LOW_BUFFER_BEFORE_RAMPDOWN 10 /**< 10sec buffer before rampdown */
106 #define AAMP_HIGH_BUFFER_BEFORE_RAMPUP 15 /**< 15sec buffer before rampup */
107 #define MAX_DASH_DRM_SESSIONS 30
108 #define MAX_AD_SEG_DOWNLOAD_FAIL_COUNT 2 /**< Max Ad segment download failures to identify as the ad playback failure. */
109 #define FRAGMENT_DOWNLOAD_WARNING_THRESHOLD 2000 /**< MAX Fragment download threshold time in Msec*/
110 #define BITRATE_ALLOWED_VARIATION_BAND 500000 /**< NW BW change beyond this will be ignored */
111 #define MAX_DIFF_BETWEEN_PTS_POS_MS (3600*1000)
112 #define MAX_SEG_DOWNLOAD_FAIL_COUNT 10 /**< Max segment download failures to identify a playback failure. */
113 #define MAX_DOWNLOAD_DELAY_LIMIT_MS 30000
114 #define MAX_ERROR_DESCRIPTION_LENGTH 128
115 #define MAX_ANOMALY_BUFF_SIZE 256
116 #define MAX_WAIT_TIMEOUT_MS 200 /**< Max Timeout furation for wait until cache is available to inject next*/
117 #define MAX_INIT_FRAGMENT_CACHE_PER_TRACK 5 /**< Max No Of cached Init fragements per track */
118 #define MIN_SEG_DURTION_THREASHOLD (0.25) /**< Min Segment Duration threshold for pushing to pipeline at period End*/
119 #define MAX_CURL_SOCK_STORE 10 /**< Maximum no of host to be maintained in curl store*/
120 
121 // Player supported play/trick-play rates.
122 #define AAMP_RATE_TRICKPLAY_MAX 64
123 #define AAMP_NORMAL_PLAY_RATE 1
124 #define AAMP_SLOWMOTION_RATE 0.5
125 #define AAMP_RATE_PAUSE 0
126 #define AAMP_RATE_INVALID INT_MAX
127 
128 // Defines used for PauseAt functionality
129 #define AAMP_PAUSE_POSITION_POLL_PERIOD_MS (250)
130 #define AAMP_PAUSE_POSITION_INVALID_POSITION (-1)
131 
132 #define STRLEN_LITERAL(STRING) (sizeof(STRING)-1)
133 #define STARTS_WITH_IGNORE_CASE(STRING, PREFIX) (0 == strncasecmp(STRING, PREFIX, STRLEN_LITERAL(PREFIX)))
134 
135 #define MAX_GST_VIDEO_BUFFER_BYTES (GST_VIDEOBUFFER_SIZE_BYTES)
136 #define MAX_GST_AUDIO_BUFFER_BYTES (GST_AUDIOBUFFER_SIZE_BYTES)
137 
138 #define DEFAULT_LATENCY_MONITOR_DELAY 9 /**< Latency Monitor Delay */
139 #define DEFAULT_LATENCY_MONITOR_INTERVAL 6 /**< Latency monitor Interval */
140 #define DEFAULT_MIN_LOW_LATENCY 3 /**< min Default Latency */
141 #define DEFAULT_MAX_LOW_LATENCY 9 /**< max Default Latency */
142 #define DEFAULT_TARGET_LOW_LATENCY 6 /**< Target Default Latency */
143 #define DEFAULT_MIN_RATE_CORRECTION_SPEED 0.90f /**< min Rate correction speed */
144 #define DEFAULT_MAX_RATE_CORRECTION_SPEED 1.10f /**< max Rate correction speed */
145 #define AAMP_NORMAL_LL_PLAY_RATE 1.01f /**< LL Normal play rate adjusted to 1.01 */
146 #define DEFAULT_CACHED_FRAGMENT_CHUNKS_PER_TRACK 20 /**< Default cached fragement chunks per track */
147 #define DEFAULT_ABR_CHUNK_CACHE_LENGTH 10 /**< Default ABR chunk cache length */
148 #define DEFAULT_AAMP_ABR_CHUNK_THRESHOLD_SIZE (DEFAULT_AAMP_ABR_THRESHOLD_SIZE) /**< aamp abr Chunk threshold size */
149 #define DEFAULT_ABR_CHUNK_SPEEDCNT 10 /**< Chunk Speed Count Store Size */
150 #define DEFAULT_ABR_ELAPSED_MILLIS_FOR_ESTIMATE 100 /**< Duration(ms) to check Chunk Speed */
151 #define DEFAULT_ABR_BYTES_TRANSFERRED_FOR_ESTIMATE (512 * 1024) /**< 512K */
152 #define MAX_MDAT_NOT_FOUND_COUNT 500 /**< Max MDAT not found count*/
153 #define DEFAULT_CONTENT_PROTECTION_DATA_UPDATE_TIMEOUT 5000 /**< Default Timeout for Content Protection Data Update on Dynamic Key Rotation */
154 
155 // Player configuration for Fog download
156 #define FOG_MAX_CONCURRENT_DOWNLOADS 4 /**< Max concurrent downloads in Fog*/
157 
158 #define AAMP_MAX_EVENT_PRIORITY (-70) /**< Maximum allowed priority value for events */
159 #define AAMP_TASK_ID_INVALID 0
160 
161 //License acquistion related configuration
162 #define MAX_LICENSE_REQUEST_ATTEMPTS 2
163 //Secmanager error class codes
164 #define SECMANGER_DRM_FAILURE 200
165 #define SECMANGER_WM_FAILURE 300 /**< If secmanager couldn't initialize watermark service */
166 
167 //Secmanager error reason codes
168 #define SECMANGER_DRM_GEN_FAILURE 1 /**< General or internal failure */
169 #define SECMANGER_SERVICE_TIMEOUT 3
170 #define SECMANGER_SERVICE_CON_FAILURE 4
171 #define SECMANGER_SERVICE_BUSY 5
172 #define SECMANGER_ACCTOKEN_EXPIRED 8
173 #define SECMANGER_ENTITLEMENT_FAILURE 102
174 
175 //delay for the first speed set event
176 #define SECMANGER_SPEED_SET_DELAY 500
177 
178 //DELIA-53727 change this into #define to extract the raw YCrCb colors from each frame of video
179 #undef RENDER_FRAMES_IN_APP_CONTEXT
180 
181 /**
182  * @brief Enumeration for TUNED Event Configuration
183  */
185 {
186  eTUNED_EVENT_ON_PLAYLIST_INDEXED, /**< Send TUNED event after playlist indexed*/
187  eTUNED_EVENT_ON_FIRST_FRAGMENT_DECRYPTED, /**< Send TUNED event after first fragment decryption*/
188  eTUNED_EVENT_ON_GST_PLAYING, /**< Send TUNED event on gstreamer's playing event*/
189  eTUNED_EVENT_MAX
190 };
191 
192 /**
193  * @brief Enumeration for Paused state behavior
194  */
196 {
197  ePAUSED_BEHAVIOR_AUTOPLAY_IMMEDIATE, /**< automatically begin playback from eldest portion of live window*/
198  ePAUSED_BEHAVIOR_LIVE_IMMEDIATE, /**< automatically jump to live*/
199  ePAUSED_BEHAVIOR_AUTOPLAY_DEFER, /**< video remains paused indefinitely till play() call, resume playback from new start portion of live window*/
200  ePAUSED_BEHAVIOR_LIVE_DEFER, /**< video remains paused indefinitely till play() call, resume playback from live position*/
201  ePAUSED_BEHAVIOR_MAX
202 };
203 
204 /**
205  * @brief AAMP Config Ownership values
206  */
207 
208 typedef enum
209 {
210  AAMP_DEFAULT_SETTING = 0, /**< Lowest priority */
211  AAMP_OPERATOR_SETTING = 1,
212  AAMP_STREAM_SETTING = 2,
213  AAMP_APPLICATION_SETTING = 3,
214  AAMP_TUNE_SETTING = 4,
215  AAMP_DEV_CFG_SETTING = 5,
216  AAMP_CUSTOM_DEV_CFG_SETTING = 6, /**< Highest priority */
217  AAMP_MAX_SETTING
219 
220 /**
221  * @brief Latency status
222  */
224 {
225  LATENCY_STATUS_UNKNOWN=-1, /**< The latency is Unknown */
226  LATENCY_STATUS_MIN, /**< The latency is within range but less than mimium latency */
227  LATENCY_STATUS_THRESHOLD_MIN, /**< The latency is within range but less than target latency but greater than minimum latency */
228  LATENCY_STATUS_THRESHOLD, /**< The latency is equal to given latency from mpd */
229  LATENCY_STATUS_THRESHOLD_MAX, /**< The latency is more that target latency but less than maximum latency */
230  LATENCY_STATUS_MAX /**< The latency is more than maximum latency */
231 };
232 
233 
234 typedef enum {
235  SECMANAGER_CLASS_RESULT_SUCCESS = 0,
236  SECMANAGER_CLASS_RESULT_API_FAIL = 100,
237  SECMANAGER_CLASS_RESULT_DRM_FAIL = 200,
238  SECMANAGER_CLASS_RESULT_WATERMARK_FAIL = 300,
239  SECMANAGER_CLASS_RESULT_SECCLIENT_FAIL = 400,
240  SECMANAGER_CLASS_RESULT_UNDEFINED = 9999
241 } SecManagerResultClassStatusCode;
242 
243 typedef enum {
244  SECMANAGER_SUCCESS = 0,
245  SECMANAGER_SUCCESS_WATERMARK_SESSION_ENGAGED = 100,
246  SECMANAGER_SUCCESS_WATERMARK_NOT_REQUIRED = 101
247 } SecManagerResultSuccessCode;
248 
249 typedef enum {
250  SECMANAGER_REASON_API_INVALID_SESSION_CONFIG = 1,
251  SECMANAGER_REASON_API_INVALID_ASPECT_DIMENSION = 2,
252  SECMANAGER_REASON_API_INVALID_KEY_SYSTEM_PARAM = 3,
253  SECMANAGER_REASON_API_INVALID_DRM_LICENSE_PARAM = 4,
254  SECMANAGER_REASON_API_INVALID_CONTENT_METADATA = 5,
255  SECMANAGER_REASON_API_INVALID_MEDIA_USAGE = 6,
256  SECMANAGER_REASON_API_INVALID_ACCESS_TOKEN = 7,
257  SECMANAGER_REASON_API_INVALID_ACCESS_ATTRIBUTE = 8,
258  SECMANAGER_REASON_API_INVALID_SESSION_ID = 9,
259  SECMANAGER_REASON_API_INVALID_APPLICATION_ID = 10,
260  SECMANAGER_REASON_API_INVALID_EVENT_ID = 11,
261  SECMANAGER_REASON_API_INVALID_CLIENT_ID = 12,
262  SECMANAGER_REASON_API_INVALID_PERCEPTION_ID = 13,
263  SECMANAGER_REASON_API_INVALID_WATERMARK_PARAMETER = 14,
264  SECMANAGER_REASON_API_INVALID_CONTENT_PARAMETER = 15,
265  SECMANAGER_REASON_API_UNDEFINED_ERROR = 9999
266 } SecManagerResultApiCode;
267 
268 typedef enum {
269  SECMANAGER_REASON_DRM_GENERAL_FAILURE = 1,
270  SECMANAGER_REASON_DRM_NO_PLAYBACK_SESSION = 2,
271  SECMANAGER_REASON_DRM_LICENSE_TIMEOUT = 3,
272  SECMANAGER_REASON_DRM_LICENSE_NETWORK_FAIL = 4,
273  SECMANAGER_REASON_DRM_LICENSE_BUSY = 5,
274  SECMANAGER_REASON_DRM_ACCESS_TOKEN_ERROR = 6,
275  SECMANAGER_REASON_DRM_ACCESS_TOKEN_IP_DIFF = 7,
276  SECMANAGER_REASON_DRM_ACCESS_TOKEN_EXPIRED = 8,
277  SECMANAGER_REASON_DRM_DEVICE_TOKEN_EXPIRED = 9,
278  SECMANAGER_REASON_DRM_MAC_TOKEN_MISSING = 10,
279  SECMANAGER_REASON_DRM_MAC_TOKEN_NO_PROV = 11,
280  SECMANAGER_REASON_DRM_MEMORY_ALLOCATION_ERROR = 12,
281  SECMANAGER_REASON_DRM_SECAPI_USAGE_FAILURE = 13,
282  SECMANAGER_REASON_DRM_PERMISSION_DENIED = 100,
283  SECMANAGER_REASON_DRM_RULE_ERROR = 101,
284  SECMANAGER_REASON_DRM_ENTITLEMENT_ERROR = 102,
285  SECMANAGER_REASON_DRM_AUTHENTICATION_FAIL = 103
286 } SecManagerResultDRMCode;
287 #endif
288 
289 
eTUNED_EVENT_ON_GST_PLAYING
@ eTUNED_EVENT_ON_GST_PLAYING
Definition: AampDefine.h:188
LATENCY_STATUS_THRESHOLD
@ LATENCY_STATUS_THRESHOLD
Definition: AampDefine.h:228
LATENCY_STATUS_MAX
@ LATENCY_STATUS_MAX
Definition: AampDefine.h:230
AAMP_DEFAULT_SETTING
@ AAMP_DEFAULT_SETTING
Definition: AampDefine.h:210
LATENCY_STATUS_MIN
@ LATENCY_STATUS_MIN
Definition: AampDefine.h:226
PausedBehavior
PausedBehavior
Enumeration for Paused state behavior.
Definition: AampDefine.h:195
ePAUSED_BEHAVIOR_LIVE_DEFER
@ ePAUSED_BEHAVIOR_LIVE_DEFER
Definition: AampDefine.h:200
TunedEventConfig
TunedEventConfig
Enumeration for TUNED Event Configuration.
Definition: AampDefine.h:184
LATENCY_STATUS_THRESHOLD_MAX
@ LATENCY_STATUS_THRESHOLD_MAX
Definition: AampDefine.h:229
LatencyStatus
LatencyStatus
Latency status.
Definition: AampDefine.h:223
AAMP_CUSTOM_DEV_CFG_SETTING
@ AAMP_CUSTOM_DEV_CFG_SETTING
Definition: AampDefine.h:216
ConfigPriority
ConfigPriority
AAMP Config Ownership values.
Definition: AampDefine.h:208
LATENCY_STATUS_THRESHOLD_MIN
@ LATENCY_STATUS_THRESHOLD_MIN
Definition: AampDefine.h:227
LATENCY_STATUS_UNKNOWN
@ LATENCY_STATUS_UNKNOWN
Definition: AampDefine.h:225
ePAUSED_BEHAVIOR_AUTOPLAY_DEFER
@ ePAUSED_BEHAVIOR_AUTOPLAY_DEFER
Definition: AampDefine.h:199
eTUNED_EVENT_ON_PLAYLIST_INDEXED
@ eTUNED_EVENT_ON_PLAYLIST_INDEXED
Definition: AampDefine.h:186
ePAUSED_BEHAVIOR_LIVE_IMMEDIATE
@ ePAUSED_BEHAVIOR_LIVE_IMMEDIATE
Definition: AampDefine.h:198
eTUNED_EVENT_ON_FIRST_FRAGMENT_DECRYPTED
@ eTUNED_EVENT_ON_FIRST_FRAGMENT_DECRYPTED
Definition: AampDefine.h:187
ePAUSED_BEHAVIOR_AUTOPLAY_IMMEDIATE
@ ePAUSED_BEHAVIOR_AUTOPLAY_IMMEDIATE
Definition: AampDefine.h:197