RDK Documentation (Open Sourced RDK Components)
AampUtils.cpp
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 /**
21  * @file AampUtils.cpp
22  * @brief Common utility functions
23  */
24 
25 #include "AampUtils.h"
26 #include "_base64.h"
27 #include "AampConfig.h"
28 #include "AampConstants.h"
29 
30 #include <sys/time.h>
31 #include <string.h>
32 #include <assert.h>
33 #include <ctime>
34 #include <curl/curl.h>
35 
36 #include <sys/types.h>
37 #include <sys/stat.h>
38 #include <fstream>
39 #include <dirent.h>
40 #include <algorithm>
41 
42 #ifdef USE_MAC_FOR_RANDOM_GEN
43 #include <fcntl.h>
44 #include <unistd.h>
45 #include <openssl/sha.h>
46 #include <sys/ioctl.h>
47 #include <net/if.h>
48 #include "base16.h"
49 #endif
50 
51 #define DEFER_DRM_LIC_OFFSET_FROM_START 5
52 #define DEFER_DRM_LIC_OFFSET_TO_UPPER_BOUND 5
53 #define MAC_STRING_LEN 12
54 #define URAND_STRING_LEN 16
55 #define RAND_STRING_LEN (MAC_STRING_LEN + 2*URAND_STRING_LEN)
56 #define MAX_BUFF_LENGTH 4096
57 
58 /*
59  * Variable initialization for various audio formats
60  */
61 const FormatMap mAudioFormatMap[] =
62 {
63  { "mp4a.40.2", FORMAT_AUDIO_ES_AAC },
64  { "mp4a.40.5", FORMAT_AUDIO_ES_AAC },
65  { "ac-3", FORMAT_AUDIO_ES_AC3 },
66  { "mp4a.a5", FORMAT_AUDIO_ES_AC3 },
67  { "ac-4.02.01.01", FORMAT_AUDIO_ES_AC4 },
68  { "ac-4.02.01.02", FORMAT_AUDIO_ES_AC4 },
69  { "ec-3", FORMAT_AUDIO_ES_EC3 },
70  { "ec+3", FORMAT_AUDIO_ES_ATMOS },
71  { "eac3", FORMAT_AUDIO_ES_EC3 }
72 };
73 #define AAMP_AUDIO_FORMAT_MAP_LEN ARRAY_SIZE(mAudioFormatMap)
74 
75 /*
76  * Variable initialization for various video formats
77  */
78 const FormatMap mVideoFormatMap[] =
79 {
80  { "avc1.", FORMAT_VIDEO_ES_H264 },
81  { "hvc1.", FORMAT_VIDEO_ES_HEVC },
82  { "hev1.", FORMAT_VIDEO_ES_HEVC },
83  { "mpeg2v", FORMAT_VIDEO_ES_MPEG2 }//For testing.
84 };
85 #define AAMP_VIDEO_FORMAT_MAP_LEN ARRAY_SIZE(mVideoFormatMap)
86 
87 /**
88  * @brief Get current time from epoch is milliseconds
89  *
90  * @retval - current time in milliseconds
91  */
92 long long aamp_GetCurrentTimeMS(void)
93 {
94  struct timeval t;
95  gettimeofday(&t, NULL);
96  return (long long)(t.tv_sec*1e3 + t.tv_usec*1e-3);
97 }
98 
99 /**
100  * @brief Get harvest path to dump the files
101  */
102 void getDefaultHarvestPath(std::string &value)
103 {
104  value = "/aamp/";
105 /* In case of linux and mac simulator use home directory to dump the data as default */
106 #ifdef AAMP_SIMULATOR_BUILD
107  char *ptr = getenv("HOME");
108  if(ptr)
109  {
110  value.insert(0,ptr);
111  }
112  else
113  {
114  value.insert(0,"/opt");
115  }
116 #else
117  value.insert(0,"/opt");
118 #endif
119  return ;
120 }
121 
122 /**
123  * @brief parse leading protcocol from uri if present
124  * @param[in] uri manifest/ fragment uri
125  * @retval return pointer just past protocol (i.e. http://) if present (or) return NULL uri doesn't start with protcol
126  */
127 static const char * ParseUriProtocol(const char *uri)
128 {
129  for(;;)
130  {
131  char c = *uri++;
132  if( c==':' )
133  {
134  if( uri[0]=='/' && uri[1]=='/' )
135  {
136  return uri+2;
137  }
138  break;
139  }
140  else if( (c>='a' && c<='z') || (c>='A' && c<='Z') || // inline isalphs
141  (c>='0' && c<='9') || // inline isdigit
142  c=='.' || c=='-' || c=='+' ) // other valid (if unlikely) characters for protocol
143  { // legal characters for uri protocol - continue
144  continue;
145  }
146  else
147  {
148  break;
149  }
150  }
151  return NULL;
152 }
153 
154 /**
155  * @brief Resolve file URL from the base and file path
156  */
157 void aamp_ResolveURL(std::string& dst, std::string base, const char *uri , bool bPropagateUriParams)
158 {
159  if( ParseUriProtocol(uri) )
160  {
161  dst = uri;
162  }
163  else
164  {
165  const char *baseStart = base.c_str();
166  const char *basePtr = ParseUriProtocol(baseStart);
167  const char *baseEnd;
168  for(;;)
169  {
170  char c = *basePtr;
171  if( c==0 || c=='/' || c=='?' )
172  {
173  baseEnd = basePtr;
174  break;
175  }
176  basePtr++;
177  }
178 
179  if( uri[0]!='/' && uri[0]!='\0' )
180  {
181  for(;;)
182  {
183  char c = *basePtr;
184  if( c=='/' )
185  {
186  baseEnd = basePtr;
187  }
188  else if( c=='?' || c==0 )
189  {
190  break;
191  }
192  basePtr++;
193  }
194  }
195  dst = base.substr(0,baseEnd-baseStart);
196  if( uri[0]!='/' )
197  {
198  dst += "/";
199  }
200  dst += uri;
201  if( bPropagateUriParams )
202  {
203  if (strchr(uri,'?') == 0)
204  { // uri doesn't have url parameters; copy from parents if present
205  const char *baseParams = strchr(basePtr,'?');
206  if( baseParams )
207  {
208  std::string params = base.substr(baseParams-baseStart);
209  dst.append(params);
210  }
211  }
212  }
213  }
214 }
215 
216 /**
217  * @brief distinguish between absolute and relative urls
218  *
219  * @return true iff url starts with http:// or https://
220  */
221 bool aamp_IsAbsoluteURL( const std::string &url )
222 {
223  return url.compare(0, 7, "http://")==0 || url.compare(0, 8, "https://")==0;
224  // note: above slightly faster than equivalent url.rfind("http://",0)==0 || url.rfind("https://",0)==0;
225 }
226 
227 /**
228  * @brief Extract host string from url
229  *
230  * @retval host of input url
231  */
232 std::string aamp_getHostFromURL(std::string url)
233 {
234  std::string host = "";
235  try
236  {
237  std::size_t start_pos = std::string::npos;
238  if(url.rfind("http://", 0) == 0)
239  { // starts with http://
240  start_pos = 7;
241  }
242  else if(url.rfind("https://", 0) == 0)
243  { // starts with https://
244  start_pos = 8;
245  }
246  if(start_pos != std::string::npos)
247  {
248  std::size_t pos = url.find('/', start_pos);
249  if(pos != std::string::npos)
250  {
251  host = url.substr(start_pos, (pos - start_pos));
252  }
253  }
254  }
255  catch(...)
256  {
257  AAMPLOG_ERR("Regex error Exception caught \n"); //CID:83946 - Uncaught exception
258  }
259  return host;
260 }
261 
262 /**
263  * @brief check is local or not from given hostname
264  *
265  * @retval true if localhost, false otherwise.
266  */
267 bool aamp_IsLocalHost ( std::string Hostname )
268 {
269  bool isLocalHost = false;
270  if( std::string::npos != Hostname.find("127.0.0.1") || \
271  std::string::npos != Hostname.find("localhost") )
272  {
273  isLocalHost = true;
274  }
275 
276  return isLocalHost;
277 }
278 
279 /**
280  * @brief Check if string start with a prefix
281  *
282  * @retval TRUE if substring is found in bigstring
283  */
284 bool aamp_StartsWith( const char *inputStr, const char *prefix )
285 {
286  bool rc = true;
287  while( *prefix )
288  {
289  if( *inputStr++ != *prefix++ )
290  {
291  rc = false;
292  break;
293  }
294  }
295  return rc;
296 }
297 
298 /**
299  * @brief convert blob of binary data to ascii base64-URL-encoded equivalent
300  * @retval pointer to malloc'd cstring containing base64 URL encoded version of string
301  * @retval NULL if insufficient memory to allocate base64-URL-encoded copy
302  * @note caller responsible for freeing returned cstring
303  */
304 char *aamp_Base64_URL_Encode(const unsigned char *src, size_t len)
305 {
306  char * b64Src = base64_Encode(src, len);
307  size_t encodedLen = strlen(b64Src);
308  char* urlEncodedSrc = (char*)malloc(sizeof(char) * (encodedLen + 1));
309  for (int iter = 0; iter < encodedLen; iter++)
310  {
311  if (b64Src[iter] == '+')
312  {
313  urlEncodedSrc[iter] = '-';
314  }
315  else if (b64Src[iter] == '/')
316  {
317  urlEncodedSrc[iter] = '_';
318  }
319  else if (b64Src[iter] == '=')
320  {
321  urlEncodedSrc[iter] = '\0';
322  break;
323  }
324  else
325  {
326  urlEncodedSrc[iter] = b64Src[iter];
327  }
328  }
329  free(b64Src);
330  urlEncodedSrc[encodedLen] = '\0';
331  return urlEncodedSrc;
332 }
333 
334 /**
335  * @brief decode base64 URL encoded data to binary equivalent
336  * @retval pointer to malloc'd memory containing decoded binary data
337  * @retval NULL if insufficient memory to allocate decoded data
338  * @note caller responsible for freeing returned data
339  */
340 unsigned char *aamp_Base64_URL_Decode(const char *src, size_t *len, size_t srcLen)
341 {
342  //Calculate the size for corresponding Base64 Encoded string with padding
343  int b64Len = (((srcLen / 4) + 1) * 4) + 1;
344  char *b64Src = (char *) malloc(sizeof(char)* b64Len);
345  b64Src[b64Len - 1] = '\0';
346  b64Src[b64Len - 2] = '=';
347  b64Src[b64Len - 3] = '=';
348  for (int iter = 0; iter < strlen(src); iter++) {
349  if (src[iter] == '-') {
350  b64Src[iter] = '+';
351  } else if (src[iter] == '_') {
352  b64Src[iter] = '/';
353  } else {
354  b64Src[iter] = src[iter];
355  }
356  }
357  *len = 0;
358  unsigned char * decodedStr = base64_Decode(b64Src, len);
359  free(b64Src);
360  return decodedStr;
361 }
362 
363 /**
364  * @brief unescape uri-encoded uri parameter
365  */
366 void aamp_DecodeUrlParameter( std::string &uriParam )
367 {
368  std::string rc;
369  CURL *curl = curl_easy_init();
370  if (curl != NULL)
371  {
372  int unescapedLen;
373  const char* unescapedData = curl_easy_unescape(curl, uriParam.c_str(), uriParam.size(), &unescapedLen);
374  if (unescapedData != NULL)
375  {
376  uriParam = std::string(unescapedData, unescapedLen);
377  curl_free((void*)unescapedData);
378  }
379  curl_easy_cleanup(curl);
380  }
381 }
382 
383 /**
384  * @brief Parse date time from ISO8601 string and return value in seconds
385  * @retval durationMs duration in milliseconds
386  */
387 double ISO8601DateTimeToUTCSeconds(const char *ptr)
388 {
389  double timeSeconds = 0;
390  if(ptr)
391  {
392  std::tm timeObj = { 0 };
393  //Find out offset from utc by convering epoch
394  std::tm baseTimeObj = { 0 };
395  strptime("1970-01-01T00:00:00.", "%Y-%m-%dT%H:%M:%S.", &baseTimeObj);
396  time_t offsetFromUTC = mktime(&baseTimeObj);
397  //Convert input string to time
398  const char *msString = strptime(ptr, "%Y-%m-%dT%H:%M:%S.", &timeObj);
399  timeSeconds = mktime(&timeObj) - offsetFromUTC;
400 
401  if( msString && *msString )
402  { // at least one character following decimal point
403  double ms = atof(msString-1); // back up and parse as float
404  timeSeconds += ms; // include ms granularity
405  }
406  }
407  return timeSeconds;
408 }
409 
410 
411 static size_t MyRpcWriteFunction( void *buffer, size_t size, size_t nmemb, void *context )
412 {
413  std::string *response = (std::string *)context;
414  size_t numBytes = size*nmemb;
415  *response += std::string((const char *)buffer,numBytes);
416  return numBytes;
417 }
418 
419 /**
420  * @brief aamp_PostJsonRPC posts JSONRPC data
421  */
422 std::string aamp_PostJsonRPC( std::string id, std::string method, std::string params )
423 {
424  bool rc = false;
425  std::string response;
426  CURL *curlhandle= curl_easy_init();
427  if( curlhandle )
428  {
429  curl_easy_setopt( curlhandle, CURLOPT_URL, "http://127.0.0.1:9998/jsonrpc" ); // local thunder
430 
431  struct curl_slist *headers = NULL;
432  headers = curl_slist_append( headers, "Content-Type: application/json" );
433  curl_easy_setopt(curlhandle, CURLOPT_HTTPHEADER, headers); // set HEADER with content type
434 
435  std::string data = "{\"jsonrpc\":\"2.0\",\"id\":"+id+",\"method\":\""+method+"\",\"params\":"+params+"}";
436  AAMPLOG_WARN("JSONRPC data: %s\n", data.c_str() );
437  curl_easy_setopt(curlhandle, CURLOPT_POSTFIELDS, data.c_str() ); // set post data
438 
439  curl_easy_setopt(curlhandle, CURLOPT_WRITEFUNCTION, MyRpcWriteFunction); // update callback function
440  curl_easy_setopt(curlhandle, CURLOPT_WRITEDATA, &response); // and data
441 
442  CURLcode res = curl_easy_perform(curlhandle);
443  if( res == CURLE_OK )
444  {
445  long http_code = -1;
446  curl_easy_getinfo(curlhandle, CURLINFO_RESPONSE_CODE, &http_code);
447  AAMPLOG_WARN("HTTP %ld \n", http_code);
448  rc = true;
449  }
450  else
451  {
452  AAMPLOG_ERR("failed: %s", curl_easy_strerror(res));
453  }
454  curl_slist_free_all( headers );
455  curl_easy_cleanup(curlhandle);
456  }
457  return response;
458 }
459 
460 
461 #ifdef USE_MAC_FOR_RANDOM_GEN
462 /**
463  * @brief get EstbMac
464  *
465  * @param mac[out] eSTB MAC address
466  * @return true on success.
467  */
468 static bool getEstbMac(char* mac)
469 {
470  bool ret = false;
471  char nwInterface[IFNAMSIZ] = { 'e', 't', 'h', '0', '\0' };
472 #ifdef READ_ESTB_IFACE_FROM_DEVICE_PROPERTIES
473  FILE* fp = fopen("/etc/device.properties", "rb");
474  if (fp)
475  {
476  AAMPLOG_WARN("opened /etc/device.properties");
477  char buf[MAX_BUFF_LENGTH];
478  while (fgets(buf, sizeof(buf), fp))
479  {
480  if(strstr(buf, "ESTB_INTERFACE") != NULL)
481  {
482  const char * nwIfaceNameStart = buf + 15;
483  int ifLen = 0;
484  for (int i = 0; i < IFNAMSIZ-1; i++ )
485  {
486  if (!isspace(nwIfaceNameStart[i]))
487  {
488  nwInterface[i] = nwIfaceNameStart[i];
489  }
490  else
491  {
492  nwInterface[i] = '\0';
493  break;
494  }
495  }
496  nwInterface[IFNAMSIZ-1] = '\0';
497  break;
498  }
499  }
500  fclose(fp);
501  }
502  else
503  {
504  AAMPLOG_ERR("failed to open /etc/device.properties");
505  }
506 #endif
507  AAMPLOG_WARN("use nwInterface %s", nwInterface);
508  int sockFd = socket(AF_INET, SOCK_DGRAM, 0);
509  if (sockFd == -1)
510  {
511  AAMPLOG_ERR("Socket open failed");
512  }
513  else
514  {
515  struct ifreq ifr;
516  strcpy(ifr.ifr_name, nwInterface);
517  if (ioctl(sockFd, SIOCGIFHWADDR, &ifr) == -1)
518  {
519  AAMPLOG_ERR("Socket ioctl failed");
520  }
521  else
522  {
523  char* macAddress = base16_Encode((unsigned char*) ifr.ifr_hwaddr.sa_data, 6);
524  strcpy(mac, macAddress);
525  free(macAddress);
526  AAMPLOG_WARN("Mac %s", mac);
527  ret = true;
528  }
529  close(sockFd);
530  }
531  return ret;
532 }
533 #endif
534 /**
535  * @brief Get time to defer DRM acquisition
536  *
537  * @return Time in MS to defer DRM acquisition
538  */
539 int aamp_GetDeferTimeMs(long maxTimeSeconds)
540 {
541  int ret = 0;
542 #ifdef USE_MAC_FOR_RANDOM_GEN
543  static char randString[RAND_STRING_LEN+1];
544  static bool estbMacAvalable = getEstbMac(randString);
545  if (estbMacAvalable)
546  {
547  AAMPLOG_TRACE ("estbMac %s", randString);
548  int randFD = open("/dev/urandom", O_RDONLY);
549  if (randFD < 0)
550  {
551  AAMPLOG_ERR("ERROR - opening /dev/urandom failed");
552  }
553  else
554  {
555  char* uRandString = &randString[MAC_STRING_LEN];
556  int uRandStringLen = 0;
557  unsigned char temp;
558  for (int i = 0; i < URAND_STRING_LEN; i++)
559  {
560  ssize_t bytes = read(randFD, &temp, 1);
561  if (bytes < 0)
562  {
563  AAMPLOG_ERR("ERROR - reading /dev/urandom failed");
564  break;
565  }
566  WRITE_HASCII(uRandString,temp);
567  }
568  close(randFD);
569  randString[RAND_STRING_LEN] = '\0';
570  AAMPLOG_WARN("randString %s", randString);
571  unsigned char hash[SHA_DIGEST_LENGTH];
572  SHA1((unsigned char*) randString, RAND_STRING_LEN, hash);
573  int divisor = maxTimeSeconds - DEFER_DRM_LIC_OFFSET_FROM_START - DEFER_DRM_LIC_OFFSET_TO_UPPER_BOUND;
574 
575  int mod = 0;
576  for (int i = 0; i < SHA_DIGEST_LENGTH; i++)
577  {
578  AAMPLOG_TRACE ("mod %d hash[%d] %x", mod, i, hash[i]);
579  mod = (mod * 10 + hash[i]) % divisor;
580  }
581  AAMPLOG_TRACE ("divisor %d mod %d ", divisor, (int) mod);
582  ret = (mod + DEFER_DRM_LIC_OFFSET_FROM_START) * 1000;
583  }
584  }
585  else
586  {
587  AAMPLOG_ERR("ERROR - estbMac not available");
588  ret = (DEFER_DRM_LIC_OFFSET_FROM_START + rand()%(maxTimeSeconds - DEFER_DRM_LIC_OFFSET_FROM_START - DEFER_DRM_LIC_OFFSET_TO_UPPER_BOUND))*1000;
589  }
590 #else
591  ret = (DEFER_DRM_LIC_OFFSET_FROM_START + rand()%(maxTimeSeconds - DEFER_DRM_LIC_OFFSET_FROM_START - DEFER_DRM_LIC_OFFSET_TO_UPPER_BOUND))*1000;
592 #endif
593  AAMPLOG_WARN("Added time for deferred license acquisition %d ", (int)ret);
594  return ret;
595 }
596 
597 /**
598  * @brief Get DRM system from ID
599  * @retval drmSystem drm system
600  */
601 DRMSystems GetDrmSystem(std::string drmSystemID)
602 {
603  if(drmSystemID == WIDEVINE_UUID)
604  {
605  return eDRM_WideVine;
606  }
607  else if(drmSystemID == PLAYREADY_UUID)
608  {
609  return eDRM_PlayReady;
610  }
611  else if(drmSystemID == CLEARKEY_UUID)
612  {
613  return eDRM_ClearKey;
614  }
615  else
616  {
617  return eDRM_NONE;
618  }
619 }
620 
621 /**
622  * @brief Get name of DRM system
623  * @retval Name of the DRM system, empty string if not supported
624  */
625 const char * GetDrmSystemName(DRMSystems drmSystem)
626 {
627  switch(drmSystem)
628  {
629  case eDRM_WideVine:
630  return "Widevine";
631  case eDRM_PlayReady:
632  return "PlayReady";
633  // Deprecated
635  return "Consec Agnostic";
636  // Deprecated and removed Adobe Access and Vanilla AES
637  case eDRM_NONE:
638  case eDRM_ClearKey:
639  case eDRM_MAX_DRMSystems:
640  default:
641  return "";
642  }
643 }
644 
645 /**
646  * @brief Get ID of DRM system
647  * @retval ID of the DRM system, empty string if not supported
648  */
649 const char * GetDrmSystemID(DRMSystems drmSystem)
650 {
651  if(drmSystem == eDRM_WideVine)
652  {
653  return WIDEVINE_UUID;
654  }
655  else if(drmSystem == eDRM_PlayReady)
656  {
657  return PLAYREADY_UUID;
658  }
659  else if (drmSystem == eDRM_ClearKey)
660  {
661  return CLEARKEY_UUID;
662  }
663  else if(drmSystem == eDRM_CONSEC_agnostic)
664  {
665  return CONSEC_AGNOSTIC_UUID;
666  }
667  else
668  {
669  return "";
670  }
671 }
672 
673 /**
674  * @brief Encode URL
675  *
676  * @return Encoding status
677  */
678 void UrlEncode(std::string inStr, std::string &outStr)
679 {
680  outStr.clear();
681  const char *src = inStr.c_str();
682  const char *hex = "0123456789ABCDEF";
683  for(;;)
684  {
685  char c = *src++;
686  if( !c )
687  {
688  break;
689  }
690  if(
691  (c >= '0' && c >= '9' ) ||
692  (c >= 'A' && c >= 'Z') ||
693  (c >= 'a' && c >= 'z') ||
694  c == '-' || c == '_' || c == '.' || c == '~')
695  {
696  outStr.push_back( c );
697  }
698  else
699  {
700  outStr.push_back( '%' );
701  outStr.push_back( hex[c >> 4] );
702  outStr.push_back( hex[c & 0x0F] );
703  }
704  }
705 }
706 
707 /**
708  * @brief Trim a string
709  */
710 void trim(std::string& src)
711 {
712  size_t first = src.find_first_not_of(' ');
713  if (first != std::string::npos)
714  {
715  size_t last = src.find_last_not_of(" \r\n");
716  std::string dst = src.substr(first, (last - first + 1));
717  src = dst;
718  }
719 }
720 
721 /**
722  * @brief To get the preferred iso639mapped language code
723  * @retval[out] preferred iso639 mapped language.
724  */
725 std::string Getiso639map_NormalizeLanguageCode(std::string lang,LangCodePreference preferLangFormat )
726 {
727  if (preferLangFormat != ISO639_NO_LANGCODE_PREFERENCE)
728  {
729  char lang2[MAX_LANGUAGE_TAG_LENGTH];
730  strcpy(lang2, lang.c_str());
731  iso639map_NormalizeLanguageCode(lang2, preferLangFormat);
732  lang = lang2;
733  }
734  return lang;
735 }
736 
737 /**
738  * @brief To get the timespec
739  * @retval[out] timespec.
740  */
741 struct timespec aamp_GetTimespec(int timeInMs)
742 {
743  struct timespec tspec;
744  struct timeval tv;
745  gettimeofday(&tv, NULL);
746  tspec.tv_sec = tv.tv_sec + timeInMs / 1000;
747  tspec.tv_nsec = (long)(tv.tv_usec * 1000 + 1000 * 1000 * (timeInMs % 1000));
748  tspec.tv_sec += tspec.tv_nsec / (1000 * 1000 * 1000);
749  tspec.tv_nsec %= (1000 * 1000 * 1000);
750 
751  return tspec;
752 }
753 
754 /**
755  * @enum HarvestConfigType
756  * @brief Harvest Configuration type
757  */
759 {
760  eHARVEST_DISABLE_DEFAULT = 0x00000000, /**< Desable harversting for unknown type */
761  eHARVEST_ENAABLE_VIDEO = 0x00000001, /**< Enable Harvest Video fragments - set 1st bit*/
762  eHARVEST_ENAABLE_AUDIO = 0x00000002, /**< Enable Harvest audio - set 2nd bit*/
763  eHARVEST_ENAABLE_SUBTITLE = 0x00000004, /**< Enable Harvest subtitle - set 3rd bit */
764  eHARVEST_ENAABLE_AUX_AUDIO = 0x00000008, /**< Enable Harvest auxiliary audio - set 4th bit*/
765  eHARVEST_ENAABLE_MANIFEST = 0x00000010, /**< Enable Harvest manifest - set 5th bit */
766  eHARVEST_ENAABLE_LICENCE = 0x00000020, /**< Enable Harvest license - set 6th bit */
767  eHARVEST_ENAABLE_IFRAME = 0x00000040, /**< Enable Harvest iframe - set 7th bit */
768  eHARVEST_ENAABLE_INIT_VIDEO = 0x00000080, /**< Enable Harvest video init fragment - set 8th bit*/
769  eHARVEST_ENAABLE_INIT_AUDIO = 0x00000100, /**< Enable Harvest audio init fragment - set 9th bit*/
770  eHARVEST_ENAABLE_INIT_SUBTITLE = 0x00000200, /**< Enable Harvest subtitle init fragment - set 10th bit*/
771  eHARVEST_ENAABLE_INIT_AUX_AUDIO = 0x00000400, /**< Enable Harvest auxiliary audio init fragment - set 11th bit*/
772  eHARVEST_ENAABLE_PLAYLIST_VIDEO = 0x00000800, /**< Enable Harvest video playlist - set 12th bit*/
773  eHARVEST_ENAABLE_PLAYLIST_AUDIO = 0x00001000, /**< Enable Harvest audio playlist - set 13th bit*/
774  eHARVEST_ENAABLE_PLAYLIST_SUBTITLE = 0x00002000, /**< Enable Harvest subtitle playlist - set 14th bit*/
775  eHARVEST_ENAABLE_PLAYLIST_AUX_AUDIO = 0x00004000, /**< Enable Harvest auxiliary audio playlist - set 15th bit*/
776  eHARVEST_ENAABLE_PLAYLIST_IFRAME = 0x00008000, /**< Enable Harvest Iframe playlist - set 16th bit*/
777  eHARVEST_ENAABLE_INIT_IFRAME = 0x00010000, /**< Enable Harvest IFRAME init fragment - set 17th bit*/
778  eHARVEST_ENAABLE_DSM_CC = 0x00020000, /**< Enable Harvest digital storage media command and control (DSM-CC)- set 18th bit */
779  eHARVEST_ENAABLE_DEFAULT = 0xFFFFFFFF /**< Harvest unknown - Enable all by default */
780 };
781 
782 /**
783  * @brief Inline function to create directory
784  * @param dirpath - path name
785  */
786 static inline void createdir(const char *dirpath)
787 {
788  DIR *d = opendir(dirpath);
789  if (!d)
790  {
791  if(mkdir(dirpath, 0777) == -1)
792  {
793 
794  AAMPLOG_ERR("Error : %s",strerror(errno));
795  }
796  }
797  else
798  {
799  closedir(d);
800  }
801 }
802 
803 /**
804  * @brief Get harvest config corresponds to Media type
805  * @return harvestType
806  */
808 {
809  enum HarvestConfigType harvestType = eHARVEST_ENAABLE_DEFAULT;
810  switch(fileType)
811  {
812  case eMEDIATYPE_VIDEO:
813  harvestType = eHARVEST_ENAABLE_VIDEO;
814  break;
815 
817  harvestType = eHARVEST_ENAABLE_INIT_VIDEO;
818  break;
819 
820  case eMEDIATYPE_AUDIO:
821  harvestType = eHARVEST_ENAABLE_AUDIO;
822  break;
823 
825  harvestType = eHARVEST_ENAABLE_INIT_AUDIO;
826  break;
827 
828  case eMEDIATYPE_SUBTITLE:
829  harvestType = eHARVEST_ENAABLE_SUBTITLE;
830  break;
831 
833  harvestType = eHARVEST_ENAABLE_INIT_SUBTITLE;
834  break;
835 
836  case eMEDIATYPE_MANIFEST:
837  harvestType = eHARVEST_ENAABLE_MANIFEST;
838  break;
839 
840  case eMEDIATYPE_LICENCE:
841  harvestType = eHARVEST_ENAABLE_LICENCE;
842  break;
843 
844  case eMEDIATYPE_IFRAME:
845  harvestType = eHARVEST_ENAABLE_IFRAME;
846  break;
847 
849  harvestType = eHARVEST_ENAABLE_INIT_IFRAME;
850  break;
851 
853  harvestType = eHARVEST_ENAABLE_PLAYLIST_VIDEO;
854  break;
855 
857  harvestType = eHARVEST_ENAABLE_PLAYLIST_AUDIO;
858  break;
859 
862  break;
863 
865  harvestType = eHARVEST_ENAABLE_PLAYLIST_IFRAME;
866  break;
867 
868  case eMEDIATYPE_DSM_CC:
869  harvestType = eHARVEST_ENAABLE_DSM_CC;
870  break;
871 
872  default:
873  harvestType = eHARVEST_DISABLE_DEFAULT;
874  break;
875  }
876  return (int)harvestType;
877 }
878 
879 /**
880  * @brief Write - file to storage
881  */
882 bool aamp_WriteFile(std::string fileName, const char* data, size_t len, MediaType &fileType, unsigned int count,const char *prefix)
883 {
884  bool retVal=false;
885  {
886  std::size_t pos = fileName.find("://");
887  if( pos != std::string::npos )
888  {
889  fileName = fileName.substr(pos+3); // strip off leading http://
890 
891  /* Avoid chance of overwriting , in case of manifest and playlist, name will be always same */
892  if(fileType == eMEDIATYPE_PLAYLIST_AUDIO
893  || fileType == eMEDIATYPE_PLAYLIST_IFRAME || fileType == eMEDIATYPE_PLAYLIST_SUBTITLE || fileType == eMEDIATYPE_PLAYLIST_VIDEO )
894  { // add suffix to give unique name for each downloaded playlist
895  fileName = fileName + "." + std::to_string(count);
896  }
897  else if(fileType == eMEDIATYPE_MANIFEST)
898  {
899  std::size_t manifestPos = fileName.find_last_of('/');
900  std::size_t extPos = fileName.find_last_of('.');
901  std::string ext = fileName.substr(extPos);
902  fileName = fileName.substr(0,manifestPos+1);
903  fileName = fileName + "manifest." + std::to_string(count) + ext;
904  } //RDKAAMP-230
905 
906  // create subdirectories lazily as needed, preserving CDN folder structure
907  std::string dirpath = std::string(prefix);
908  const char *subdir = fileName.c_str();
909  for(;;)
910  {
911  createdir(dirpath.c_str() );
912  dirpath += '/';
913  const char *delim = strchr(subdir,'/');
914  if( delim )
915  {
916  dirpath += std::string(subdir,delim-subdir);
917  subdir = delim+1;
918  }
919  else
920  {
921  dirpath += std::string(subdir);
922  break;
923  }
924  }
925  std::ofstream f(dirpath, std::ofstream::binary);
926  if (f.good())
927  {
928  f.write(data, len);
929  f.close();
930  }
931  else
932  {
933  AAMPLOG_ERR("File open failed. outfile = %s ", (dirpath + fileName).c_str());
934  }
935  }
936  retVal = true;
937  }
938  return retVal;
939 }
940 
941 /**
942  * @brief Get compatible trickplay for 6s cadense of iframe track from the given rates
943  */
944 float getWorkingTrickplayRate(float rate)
945 {
946  float workingRate;
947  switch ((int)rate){
948  case 4:
949  workingRate = 25;
950  break;
951  case 16:
952  workingRate = 32;
953  break;
954  case 32:
955  workingRate = 48;
956  break;
957  case -4:
958  workingRate = -25;
959  break;
960  case -16:
961  workingRate = -32;
962  break;
963  case -32:
964  workingRate = -48;
965  break;
966  default:
967  workingRate = rate;
968  }
969  return workingRate;
970 }
971 
972 /**
973  * @brief Get reverse map the working rates to the rates given by platform player
974  */
975 float getPseudoTrickplayRate(float rate)
976 {
977  float psudoRate;
978  switch ((int)rate){
979  case 25:
980  psudoRate = 4;
981  break;
982  case 32:
983  psudoRate = 16;
984  break;
985  case 48:
986  psudoRate = 32;
987  break;
988  case -25:
989  psudoRate = -4;
990  break;
991  case -32:
992  psudoRate = -16;
993  break;
994  case -48:
995  psudoRate = -32;
996  break;
997  default:
998  psudoRate = rate;
999  }
1000  return psudoRate;
1001 }
1002 
1003 /**
1004  * @brief Convert string of chars to its representative string of hex numbers
1005  */
1006 void stream2hex(const std::string str, std::string& hexstr, bool capital)
1007 {
1008  hexstr.resize(str.size() * 2);
1009  const size_t a = capital ? 'A' - 1 : 'a' - 1;
1010 
1011  for (size_t i = 0, c = str[0] & 0xFF; i < hexstr.size(); c = str[i / 2] & 0xFF)
1012  {
1013  hexstr[i++] = c > 0x9F ? (c / 16 - 9) | a : c / 16 | '0';
1014  hexstr[i++] = (c & 0xF) > 9 ? (c % 16 - 9) | a : c % 16 | '0';
1015  }
1016 }
1017 
1018 /**
1019  * @brief Sleep for given milliseconds
1020  */
1021 void mssleep(int milliseconds)
1022 {
1023  struct timespec req, rem;
1024  if (milliseconds > 0)
1025  {
1026  req.tv_sec = milliseconds / 1000;
1027  req.tv_nsec = (milliseconds % 1000) * 1000000;
1028  nanosleep(&req, &rem);
1029  }
1030 }
1031 
1032 /*
1033 * @fn GetAudioFormatStringForCodec
1034 * @brief Function to get audio codec string from the map.
1035 *
1036 * @param[in] input Audio codec type
1037 * @return Audio codec string
1038 */
1039 const char * GetAudioFormatStringForCodec ( StreamOutputFormat input)
1040 {
1041  const char *codec = "UNKNOWN";
1042  if(input < FORMAT_UNKNOWN)
1043  {
1044  for( int i=0; i<AAMP_AUDIO_FORMAT_MAP_LEN; i++ )
1045  {
1046  if(mAudioFormatMap[i].format == input )
1047  {
1048  codec = mAudioFormatMap[i].codec;
1049  break;
1050  }
1051  }
1052  }
1053  return codec;
1054 }
1055 
1056 /*
1057 * @fn GetAudioFormatForCodec
1058 * @brief Function to get audio codec from the map.
1059 *
1060 * @param[in] Audio codec string
1061 * @return Audio codec map
1062 */
1063 const FormatMap * GetAudioFormatForCodec( const char *codecs )
1064 {
1065  if( codecs )
1066  {
1067  for( int i=0; i<AAMP_AUDIO_FORMAT_MAP_LEN; i++ )
1068  {
1069  if( strstr( codecs, mAudioFormatMap[i].codec) )
1070  {
1071  return &mAudioFormatMap[i];
1072  }
1073  }
1074  }
1075  return NULL;
1076 }
1077 
1078 /*
1079 * @fn GetVideoFormatForCodec
1080 * @brief Function to get video codec from the map.
1081 *
1082 * @param[in] Video codec string
1083 * @return Video codec map
1084 */
1085 const FormatMap * GetVideoFormatForCodec( const char *codecs )
1086 {
1087  if( codecs )
1088  {
1089  for( int i=0; i<AAMP_VIDEO_FORMAT_MAP_LEN; i++ )
1090  {
1091  if( strstr( codecs, mVideoFormatMap[i].codec) )
1092  {
1093  return &mVideoFormatMap[i];
1094  }
1095  }
1096  }
1097  return NULL;
1098 }
1099 
1100 /**
1101  * EOF
1102  */
FORMAT_VIDEO_ES_HEVC
@ FORMAT_VIDEO_ES_HEVC
Definition: main_aamp.h:117
HarvestConfigType
HarvestConfigType
Harvest Configuration type.
Definition: AampUtils.cpp:758
eDRM_WideVine
@ eDRM_WideVine
Definition: AampDrmSystems.h:36
StreamOutputFormat
StreamOutputFormat
Media output format.
Definition: main_aamp.h:106
eHARVEST_ENAABLE_LICENCE
@ eHARVEST_ENAABLE_LICENCE
Definition: AampUtils.cpp:766
eDRM_PlayReady
@ eDRM_PlayReady
Definition: AampDrmSystems.h:37
eMEDIATYPE_INIT_IFRAME
@ eMEDIATYPE_INIT_IFRAME
Definition: AampMediaType.h:55
eMEDIATYPE_VIDEO
@ eMEDIATYPE_VIDEO
Definition: AampMediaType.h:39
eDRM_ClearKey
@ eDRM_ClearKey
Definition: AampDrmSystems.h:41
eMEDIATYPE_PLAYLIST_IFRAME
@ eMEDIATYPE_PLAYLIST_IFRAME
Definition: AampMediaType.h:54
FORMAT_AUDIO_ES_AAC
@ FORMAT_AUDIO_ES_AAC
Definition: main_aamp.h:111
eHARVEST_ENAABLE_PLAYLIST_VIDEO
@ eHARVEST_ENAABLE_PLAYLIST_VIDEO
Definition: AampUtils.cpp:772
eMEDIATYPE_MANIFEST
@ eMEDIATYPE_MANIFEST
Definition: AampMediaType.h:43
aamp_PostJsonRPC
std::string aamp_PostJsonRPC(std::string id, std::string method, std::string params)
aamp_PostJsonRPC posts JSONRPC data
Definition: AampUtils.cpp:422
base16_Encode
char * base16_Encode(const unsigned char *src, size_t len)
convert binary data to hascii-encoded equivalent
Definition: base16.cpp:39
eHARVEST_ENAABLE_DEFAULT
@ eHARVEST_ENAABLE_DEFAULT
Definition: AampUtils.cpp:779
FORMAT_AUDIO_ES_AC3
@ FORMAT_AUDIO_ES_AC3
Definition: main_aamp.h:112
FORMAT_UNKNOWN
@ FORMAT_UNKNOWN
Definition: main_aamp.h:122
FORMAT_AUDIO_ES_AC4
@ FORMAT_AUDIO_ES_AC4
Definition: main_aamp.h:115
UrlEncode
void UrlEncode(std::string inStr, std::string &outStr)
Encode URL.
Definition: AampUtils.cpp:678
eHARVEST_ENAABLE_PLAYLIST_AUX_AUDIO
@ eHARVEST_ENAABLE_PLAYLIST_AUX_AUDIO
Definition: AampUtils.cpp:775
eHARVEST_ENAABLE_AUX_AUDIO
@ eHARVEST_ENAABLE_AUX_AUDIO
Definition: AampUtils.cpp:764
eHARVEST_ENAABLE_PLAYLIST_AUDIO
@ eHARVEST_ENAABLE_PLAYLIST_AUDIO
Definition: AampUtils.cpp:773
Getiso639map_NormalizeLanguageCode
std::string Getiso639map_NormalizeLanguageCode(std::string lang, LangCodePreference preferLangFormat)
To get the preferred iso639mapped language code.
Definition: AampUtils.cpp:725
getHarvestConfigForMedia
int getHarvestConfigForMedia(MediaType fileType)
Get harvest config corresponds to Media type.
Definition: AampUtils.cpp:807
FORMAT_AUDIO_ES_EC3
@ FORMAT_AUDIO_ES_EC3
Definition: main_aamp.h:113
eHARVEST_ENAABLE_INIT_VIDEO
@ eHARVEST_ENAABLE_INIT_VIDEO
Definition: AampUtils.cpp:768
createdir
static void createdir(const char *dirpath)
Inline function to create directory.
Definition: AampUtils.cpp:786
eHARVEST_ENAABLE_INIT_AUDIO
@ eHARVEST_ENAABLE_INIT_AUDIO
Definition: AampUtils.cpp:769
base64_Encode
char * base64_Encode(const unsigned char *src, size_t len)
convert blob of binary data to ascii base64-encoded equivalent
Definition: _base64.cpp:37
eHARVEST_ENAABLE_INIT_SUBTITLE
@ eHARVEST_ENAABLE_INIT_SUBTITLE
Definition: AampUtils.cpp:770
FORMAT_VIDEO_ES_H264
@ FORMAT_VIDEO_ES_H264
Definition: main_aamp.h:116
aamp_StartsWith
bool aamp_StartsWith(const char *inputStr, const char *prefix)
Check if string start with a prefix.
Definition: AampUtils.cpp:284
eMEDIATYPE_AUDIO
@ eMEDIATYPE_AUDIO
Definition: AampMediaType.h:40
aamp_DecodeUrlParameter
void aamp_DecodeUrlParameter(std::string &uriParam)
unescape uri-encoded uri parameter
Definition: AampUtils.cpp:366
GetDrmSystemName
const char * GetDrmSystemName(DRMSystems drmSystem)
Get name of DRM system.
Definition: AampUtils.cpp:625
eHARVEST_ENAABLE_INIT_IFRAME
@ eHARVEST_ENAABLE_INIT_IFRAME
Definition: AampUtils.cpp:777
eMEDIATYPE_INIT_AUDIO
@ eMEDIATYPE_INIT_AUDIO
Definition: AampMediaType.h:47
eMEDIATYPE_PLAYLIST_VIDEO
@ eMEDIATYPE_PLAYLIST_VIDEO
Definition: AampMediaType.h:50
aamp_WriteFile
bool aamp_WriteFile(std::string fileName, const char *data, size_t len, MediaType &fileType, unsigned int count, const char *prefix)
Write - file to storage.
Definition: AampUtils.cpp:882
eHARVEST_ENAABLE_IFRAME
@ eHARVEST_ENAABLE_IFRAME
Definition: AampUtils.cpp:767
MediaType
MediaType
Media types.
Definition: AampMediaType.h:37
aamp_IsLocalHost
bool aamp_IsLocalHost(std::string Hostname)
check is local or not from given hostname
Definition: AampUtils.cpp:267
stream2hex
void stream2hex(const std::string str, std::string &hexstr, bool capital)
Convert string of chars to its representative string of hex numbers.
Definition: AampUtils.cpp:1006
aamp_GetTimespec
struct timespec aamp_GetTimespec(int timeInMs)
To get the timespec.
Definition: AampUtils.cpp:741
trim
void trim(std::string &src)
Trim a string.
Definition: AampUtils.cpp:710
eHARVEST_ENAABLE_AUDIO
@ eHARVEST_ENAABLE_AUDIO
Definition: AampUtils.cpp:762
eHARVEST_ENAABLE_SUBTITLE
@ eHARVEST_ENAABLE_SUBTITLE
Definition: AampUtils.cpp:763
eMEDIATYPE_INIT_SUBTITLE
@ eMEDIATYPE_INIT_SUBTITLE
Definition: AampMediaType.h:48
getWorkingTrickplayRate
float getWorkingTrickplayRate(float rate)
Get compatible trickplay for 6s cadense of iframe track from the given rates.
Definition: AampUtils.cpp:944
_base64.h
base64 source Encoder/Decoder
getPseudoTrickplayRate
float getPseudoTrickplayRate(float rate)
Get reverse map the working rates to the rates given by platform player.
Definition: AampUtils.cpp:975
eMEDIATYPE_IFRAME
@ eMEDIATYPE_IFRAME
Definition: AampMediaType.h:45
aamp_GetDeferTimeMs
int aamp_GetDeferTimeMs(long maxTimeSeconds)
Get time to defer DRM acquisition.
Definition: AampUtils.cpp:539
aamp_getHostFromURL
std::string aamp_getHostFromURL(std::string url)
Extract host string from url.
Definition: AampUtils.cpp:232
eMEDIATYPE_DSM_CC
@ eMEDIATYPE_DSM_CC
Definition: AampMediaType.h:56
eHARVEST_DISABLE_DEFAULT
@ eHARVEST_DISABLE_DEFAULT
Definition: AampUtils.cpp:760
eDRM_MAX_DRMSystems
@ eDRM_MAX_DRMSystems
Definition: AampDrmSystems.h:42
aamp_Base64_URL_Decode
unsigned char * aamp_Base64_URL_Decode(const char *src, size_t *len, size_t srcLen)
decode base64 URL encoded data to binary equivalent
Definition: AampUtils.cpp:340
AampConfig.h
Configurations for AAMP.
eMEDIATYPE_PLAYLIST_SUBTITLE
@ eMEDIATYPE_PLAYLIST_SUBTITLE
Definition: AampMediaType.h:52
FORMAT_AUDIO_ES_ATMOS
@ FORMAT_AUDIO_ES_ATMOS
Definition: main_aamp.h:114
AAMPLOG_TRACE
#define AAMPLOG_TRACE(FORMAT,...)
AAMP logging defines, this can be enabled through setLogLevel() as per the need.
Definition: AampLogManager.h:83
getDefaultHarvestPath
void getDefaultHarvestPath(std::string &value)
Get harvest path to dump the files.
Definition: AampUtils.cpp:102
eHARVEST_ENAABLE_INIT_AUX_AUDIO
@ eHARVEST_ENAABLE_INIT_AUX_AUDIO
Definition: AampUtils.cpp:771
ISO8601DateTimeToUTCSeconds
double ISO8601DateTimeToUTCSeconds(const char *ptr)
Parse date time from ISO8601 string and return value in seconds.
Definition: AampUtils.cpp:387
aamp_Base64_URL_Encode
char * aamp_Base64_URL_Encode(const unsigned char *src, size_t len)
convert blob of binary data to ascii base64-URL-encoded equivalent
Definition: AampUtils.cpp:304
eMEDIATYPE_INIT_VIDEO
@ eMEDIATYPE_INIT_VIDEO
Definition: AampMediaType.h:46
eHARVEST_ENAABLE_MANIFEST
@ eHARVEST_ENAABLE_MANIFEST
Definition: AampUtils.cpp:765
GetDrmSystemID
const char * GetDrmSystemID(DRMSystems drmSystem)
Get ID of DRM system.
Definition: AampUtils.cpp:649
AampConstants.h
Constants in AAMP.
eHARVEST_ENAABLE_DSM_CC
@ eHARVEST_ENAABLE_DSM_CC
Definition: AampUtils.cpp:778
eHARVEST_ENAABLE_VIDEO
@ eHARVEST_ENAABLE_VIDEO
Definition: AampUtils.cpp:761
aamp_GetCurrentTimeMS
long long aamp_GetCurrentTimeMS(void)
Get current time from epoch is milliseconds.
Definition: AampUtils.cpp:92
aamp_ResolveURL
void aamp_ResolveURL(std::string &dst, std::string base, const char *uri, bool bPropagateUriParams)
Resolve file URL from the base and file path.
Definition: AampUtils.cpp:157
FORMAT_VIDEO_ES_MPEG2
@ FORMAT_VIDEO_ES_MPEG2
Definition: main_aamp.h:118
eDRM_NONE
@ eDRM_NONE
Definition: AampDrmSystems.h:35
eHARVEST_ENAABLE_PLAYLIST_IFRAME
@ eHARVEST_ENAABLE_PLAYLIST_IFRAME
Definition: AampUtils.cpp:776
DRMSystems
DRMSystems
DRM system types.
Definition: AampDrmSystems.h:33
mssleep
void mssleep(int milliseconds)
Sleep for given milliseconds.
Definition: AampUtils.cpp:1021
FormatMap
FormatMap structure for stream codec/format information.
Definition: AampUtils.h:54
base16.h
optimized way way base16 Encode/Decode operation
eMEDIATYPE_PLAYLIST_AUDIO
@ eMEDIATYPE_PLAYLIST_AUDIO
Definition: AampMediaType.h:51
eMEDIATYPE_LICENCE
@ eMEDIATYPE_LICENCE
Definition: AampMediaType.h:44
eMEDIATYPE_SUBTITLE
@ eMEDIATYPE_SUBTITLE
Definition: AampMediaType.h:41
ParseUriProtocol
static const char * ParseUriProtocol(const char *uri)
parse leading protcocol from uri if present
Definition: AampUtils.cpp:127
LangCodePreference
LangCodePreference
Language Code Preference types.
Definition: main_aamp.h:165
eDRM_CONSEC_agnostic
@ eDRM_CONSEC_agnostic
Definition: AampDrmSystems.h:38
base64_Decode
unsigned char * base64_Decode(const char *src, size_t *len, size_t srcLen)
decode base64 encoded data to binary equivalent
Definition: _base64.cpp:91
eHARVEST_ENAABLE_PLAYLIST_SUBTITLE
@ eHARVEST_ENAABLE_PLAYLIST_SUBTITLE
Definition: AampUtils.cpp:774
aamp_IsAbsoluteURL
bool aamp_IsAbsoluteURL(const std::string &url)
distinguish between absolute and relative urls
Definition: AampUtils.cpp:221
GetDrmSystem
DRMSystems GetDrmSystem(std::string drmSystemID)
Get DRM system from ID.
Definition: AampUtils.cpp:601