RDK Documentation (Open Sourced RDK Components)
AampcliHarvestor.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 2022 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 AampcliHarvestor.cpp
22  * @brief Stand alone AAMP player with command line interface.
23  */
24 
25 #include <unistd.h>
26 #include <exception>
27 #include "AampcliHarvestor.h"
28 
29 Harvestor::Harvestor() : mMasterHarvestorThreadID(),
30  mSlaveHarvestorThreadID(),
31  mReportThread(),
32  mSlaveVideoThreads{},
33  mSlaveAudioThreads{},
34  mSlaveIFrameThread()
35 {}
36 
37 std::map<std::thread::id, HarvestProfileDetails> Harvestor::mHarvestInfo = std::map<std::thread::id, HarvestProfileDetails>();
38 std::vector<std::thread::id> Harvestor::mHarvestThreadId(0);
39 PlayerInstanceAAMP * Harvestor::mPlayerInstanceAamp = NULL;
40 bool Harvestor::mHarvestReportFlag = false;
41 std::string Harvestor::mHarvestPath = "";
42 char Harvestor::exePathName[PATH_MAX] = "";
43 Harvestor mHarvestor;
44 
45 bool Harvestor::execute(char *cmd, PlayerInstanceAAMP *playerInstanceAamp)
46 {
47  char harvestCmd[mHarvestCommandLength] = {'\0'};
48  bool slaveFlag = false;
49 
50  Harvestor::mPlayerInstanceAamp = playerInstanceAamp;
51 
52  int len = strlen(cmd) - 8;
53  strncpy(harvestCmd, cmd+8, len);
54 
55  if(memcmp(harvestCmd,"harvestMode=Master",18) == 0)
56  {
57  printf("%s:%d: thread create:MasterHarvestor thread\n", __FUNCTION__, __LINE__);
58  try {
59  mMasterHarvestorThreadID = std::thread (&Harvestor::masterHarvestor, harvestCmd);
60  }
61  catch (std::exception& e)
62  {
63  printf("%s:%d: Error at thread create:MasterHarvestor thread : %s\n", __FUNCTION__, __LINE__, e.what());
64  }
65  }
66  else if(memcmp(harvestCmd,"harvestMode=Slave",17) == 0)
67  {
68  printf("%s:%d: thread create:SlaveHarvestor thread\n", __FUNCTION__, __LINE__);
69  try {
70  mSlaveHarvestorThreadID = std::thread (&Harvestor::slaveHarvestor, harvestCmd);
71  }catch (std::exception& e)
72  {
73  printf("%s:%d: Error at thread create:SlaveHarvestor thread : %s\n", __FUNCTION__, __LINE__, e.what());
74  }
75  }
76  else
77  {
78  printf("[AAMPCLI] Invalid harvest command %s\n", cmd);
79  }
80 
81  if (mMasterHarvestorThreadID.joinable())
82  {
83  mMasterHarvestorThreadID.join();
84  }
85 
86  if (mSlaveHarvestorThreadID.joinable())
87  {
88  mSlaveHarvestorThreadID.join();
89  }
90 
91  return true;
92 }
93 
94 void Harvestor::masterHarvestor(void * arg)
95 {
96  char * cmd = (char *)arg;
97  std::map<std::string, std::string> cmdlineParams;
98  std::vector<std::string> params;
99  std::stringstream ss(cmd);
100  std::string item;
101  long currentAudioBitrate = 0,currentVideoBitrate = 0,currentIFrameBitrate = 0;
102  FILE * pIframe;
103  int videoThreadId = 0;
104  int audioThreadId = 0;
105 
106  if(aamp_pthread_setname(pthread_self(), "MasterHarvestor"))
107  {
108  printf("%s:%d: aamp_pthread_setname failed\n",__FUNCTION__,__LINE__);
109  }
110 
111  mHarvestor.getExecutablePath();
112 
113  while(std::getline(ss, item, ' ')) {
114  params.push_back(item);
115  }
116 
117  params.push_back("harvestCountLimit=9999999");
118  params.push_back("harvestConfig=65535");
119  params.push_back("defaultBitrate=9999999");
120  params.push_back("defaultBitrate4K=9999999");
121  params.push_back("abr");
122  params.push_back("suppressDecode=true");
123 
124  for(std::string param : params)
125  {
126  mHarvestor.mPlayerInstanceAamp->mConfig.ProcessConfigText(param, AAMP_DEV_CFG_SETTING);
127  mHarvestor.mPlayerInstanceAamp->mConfig.DoCustomSetting(AAMP_DEV_CFG_SETTING);
128 
129  std::size_t delimiterPos = param.find("=");
130 
131  if(delimiterPos != std::string::npos)
132  {
133  cmdlineParams[ param.substr(0, delimiterPos) ] = param.substr(delimiterPos + 1);
134  }
135  }
136 
137  if(cmdlineParams.find("harvestUrl") != cmdlineParams.end())
138  {
139  mHarvestor.mPlayerInstanceAamp->Tune(cmdlineParams["harvestUrl"].c_str());
140 
141  Harvestor::mHarvestPath = cmdlineParams["harvestPath"];
142  try{
143  mHarvestor.mReportThread = std::thread(&Harvestor::startHarvestReport, &mHarvestor, (char *) cmdlineParams["harvestUrl"].c_str());
144  }catch(std::exception& e)
145  {
146  printf("%s:%d: Error at thread create: startHarvestReport thread : %s\n",__FUNCTION__,__LINE__, e.what());
147  }
148 
149  std::string iFrameCommand;
150  if(Harvestor::exePathName[0] != '\0')
151  {
152  iFrameCommand.append(Harvestor::exePathName);
153  }
154 
155  iFrameCommand = iFrameCommand +" harvest harvestMode=Slave harvestUrl="+cmdlineParams["harvestUrl"]+" harvestCountLimit=9999999"+" harvestConfig="+std::to_string(getHarvestConfigForMedia(eMEDIATYPE_VIDEO)|getHarvestConfigForMedia(eMEDIATYPE_IFRAME)|getHarvestConfigForMedia(eMEDIATYPE_INIT_VIDEO))+" abr suppressDecode=true";
156 
157  if(cmdlineParams.find("harvestPath") != cmdlineParams.end())
158  {
159  iFrameCommand = iFrameCommand+" harvestPath="+cmdlineParams["harvestPath"];
160  }
161 
162  printf("%s:%d: Start process of IFrame command %s \n",__FUNCTION__,__LINE__,iFrameCommand.c_str());
163 
164  pIframe = popen(iFrameCommand.c_str(), "r");
165 
166  if (!pIframe)
167  {
168  puts("Can't connect to bc");
169  }
170  else
171  {
172  bool failed = false;
173  try {
174  mHarvestor.mSlaveIFrameThread = std::thread(&Harvestor::slaveDataOutput, pIframe);
175  }catch (std::exception& e)
176  {
177  printf("%s:%d: Error at thread create: slaveDataOutput thread : %s\n",__FUNCTION__,__LINE__, e.what());
178  failed = true;
179  }
180 
181  if (!failed)
182  {
183  printf("%s:%d: Sucessfully launched harvest for IFrame\n",__FUNCTION__,__LINE__);
184  }
185 
186  }
187 
188  currentVideoBitrate = mHarvestor.mPlayerInstanceAamp->GetVideoBitrate();
189  currentAudioBitrate = mHarvestor.mPlayerInstanceAamp->GetAudioBitrate();
190 
191  std::vector<long> cacheVideoBitrates,cacheAudioBitrates,cacheTextTracks;
192 
193  while(1)
194  {
195 
196  std::vector<long> tempVideoBitrates,tempAudioBitrates;
197  std::vector<long> diffVideoBitrates,diffAudioBitrates;
198  long tempIFrameBitrate,cacheIFrameBitrate;
199  sleep (1);
200 
201  if(mHarvestor.mPlayerInstanceAamp->GetState() == eSTATE_COMPLETE)
202  {
203  sleep(5); //Waiting for slave process to complete
204  }
205 
206  if ((mHarvestor.mPlayerInstanceAamp->GetState() != eSTATE_COMPLETE) && (mHarvestor.mPlayerInstanceAamp->GetState() > eSTATE_PLAYING))
207  {
208  printf("%s:%d: Tune stopped\n",__FUNCTION__,__LINE__);
209  mHarvestor.mPlayerInstanceAamp->Tune(cmdlineParams["harvestUrl"].c_str());
210  }
211 
212  tempAudioBitrates = mHarvestor.mPlayerInstanceAamp->GetAudioBitrates();
213  std::sort(tempAudioBitrates.begin(), tempAudioBitrates.end());
214 
215  tempVideoBitrates = mHarvestor.mPlayerInstanceAamp->GetVideoBitrates();
216  std::sort(tempVideoBitrates.begin(), tempVideoBitrates.end());
217 
218  std::vector<long>::iterator position = std::find(tempVideoBitrates.begin(), tempVideoBitrates.end(), mHarvestor.mPlayerInstanceAamp->GetVideoBitrate());
219  if (position != tempVideoBitrates.end())
220  tempVideoBitrates.erase(position);
221 
222  if (cacheVideoBitrates.size() == 0)
223  {
224  diffVideoBitrates = tempVideoBitrates;
225  }
226  else
227  {
228  for (long tempVideoBitrate: tempVideoBitrates)
229  {
230  if ( ! (std::find(cacheVideoBitrates.begin(), cacheVideoBitrates.end(), tempVideoBitrate) != cacheVideoBitrates.end()) )
231  {
232  diffVideoBitrates.push_back(tempVideoBitrate);
233  }
234  }
235  }
236 
237  if (cacheAudioBitrates.size() == 0)
238  {
239  diffAudioBitrates = tempAudioBitrates;
240  }
241  else
242  {
243  for (long tempAudioBitrate: tempAudioBitrates)
244  {
245  if ( ! (std::find(cacheAudioBitrates.begin(), cacheAudioBitrates.end(), tempAudioBitrate) != cacheAudioBitrates.end()) )
246  {
247  diffAudioBitrates.push_back(tempAudioBitrate);
248  }
249  }
250  }
251 
252  if(diffVideoBitrates.size())
253  {
254  for(auto bitrate:diffVideoBitrates)
255  {
256 
257  FILE *p;
258 
259  std::string videoCommand;
260  if(Harvestor::exePathName[0] != '\0' )
261  {
262  videoCommand.append(Harvestor::exePathName);
263  }
264 
265  videoCommand = videoCommand +" harvest harvestMode=Slave harvestUrl="+cmdlineParams["harvestUrl"]+" harvestCountLimit=9999999"+" harvestConfig="+std::to_string(getHarvestConfigForMedia(eMEDIATYPE_VIDEO)|getHarvestConfigForMedia(eMEDIATYPE_INIT_VIDEO)|getHarvestConfigForMedia(eMEDIATYPE_LICENCE))+" abr suppressDecode=true defaultBitrate="+std::to_string(bitrate);
266 
267  if(cmdlineParams.find("harvestPath") != cmdlineParams.end())
268  {
269  videoCommand = videoCommand+" harvestPath="+cmdlineParams["harvestPath"];
270  }
271 
272  printf("%s:%d: Start process of video command %s \n",__FUNCTION__,__LINE__,videoCommand.c_str());
273 
274  p = popen(videoCommand.c_str(), "r");
275 
276  if (!p)
277  {
278  puts("Can't connect to bc");
279  printf("%s:%d: Process fails ",__FUNCTION__,__LINE__);
280  }
281  else
282  {
283  bool failed = false ;
284  try{
285  mHarvestor.mSlaveVideoThreads[videoThreadId] = std::thread(&Harvestor::slaveDataOutput, p);
286  }catch (std::exception& e)
287  {
288  printf("%s:%d: Error at thread create: slaveDataOutput thread : %s\n",__FUNCTION__,__LINE__, e.what());
289  failed = true;
290  }
291 
292  if (!failed)
293  {
294  printf("%s:%d: Sucessfully launched harvest for video bitrate = %ld\n",__FUNCTION__,__LINE__,bitrate );
295  videoThreadId++;
296  }
297 
298  }
299  }
300 
301  cacheVideoBitrates = tempVideoBitrates;
302  }
303 
304  if(diffAudioBitrates.size())
305  {
306  for(auto bitrate:diffAudioBitrates)
307  {
308 
309  FILE * p;
310 
311  std::string audioCommand;
312  if(Harvestor::exePathName[0] != '\0' )
313  {
314  audioCommand.append(Harvestor::exePathName);
315  }
316 
317  audioCommand = audioCommand +" harvest harvestMode=Slave harvestUrl="+cmdlineParams["harvestUrl"]+" harvestCountLimit=9999999"+" harvestConfig="+std::to_string(getHarvestConfigForMedia(eMEDIATYPE_AUDIO))+" abr suppressDecode=true defaultBitrate="+std::to_string(bitrate);
318 
319  if(cmdlineParams.find("harvestPath") != cmdlineParams.end())
320  {
321  audioCommand = audioCommand+" harvestPath="+cmdlineParams["harvestPath"];
322  }
323 
324  printf("%s:%d: Start process Audio command %s \n",__FUNCTION__,__LINE__,audioCommand.c_str());
325  p = popen(audioCommand.c_str(), "r");
326 
327  if (!p)
328  {
329  puts("Can't connect to bc");
330  }
331  else
332  {
333  bool failed = false;
334  try {
335  mHarvestor.mSlaveAudioThreads[audioThreadId] = std::thread (&Harvestor::slaveDataOutput, p);
336  }catch (std::exception& e)
337  {
338  printf("%s:%d: Error at thread create: slaveDataOutput thread : %s\n",__FUNCTION__,__LINE__, e.what());
339  failed = true;
340  }
341 
342  if (!failed)
343  {
344  printf("%s:%d: Sucessfully launched harvest for audio bitrate = %ld\n ",__FUNCTION__,__LINE__,bitrate );
345  audioThreadId++;
346  }
347  }
348  }
349 
350  cacheAudioBitrates = tempAudioBitrates;
351  }
352  }
353 
354  if (mHarvestor.mReportThread.joinable())
355  {
356  mHarvestor.mReportThread.join();
357  }
358 
359  if (mHarvestor.mSlaveIFrameThread.joinable())
360  {
361  mHarvestor.mSlaveIFrameThread.join();
362  }
363 
364  for(int i = 0; i < videoThreadId; i++)
365  {
366  if (mHarvestor.mSlaveVideoThreads[i].joinable())
367  {
368  mHarvestor.mSlaveVideoThreads[i].join();
369  }
370  }
371 
372  for(int i =0; i < audioThreadId; i++)
373  {
374  if(mHarvestor.mSlaveAudioThreads[i].joinable())
375  {
376  mHarvestor.mSlaveAudioThreads[i].join();
377  }
378  }
379  }
380  else
381  {
382  printf("%s:%d: harvestUrl not found\n",__FUNCTION__,__LINE__);
383  }
384 
385  return;
386 }
387 
388 void Harvestor::slaveHarvestor(void * arg)
389 {
390  char * cmd = (char *)arg;
391  std::map<std::string, std::string> cmdlineParams;
392  std::vector<std::string> params;
393  std::stringstream ss(cmd);
394  std::string item,harvestUrl;
395 
396  if(aamp_pthread_setname(pthread_self(), "SlaveHarvestor"))
397  {
398  printf("%s:%d: SlaveHarvestor_thread aamp_pthread_setname failed\n",__FUNCTION__,__LINE__);
399  }
400 
401  while(std::getline(ss, item, ' ')) {
402  params.push_back(item);
403  }
404 
405  params.push_back("suppressDecode=true");
406 
407  for(std::string param : params)
408  {
409 
410  mHarvestor.mPlayerInstanceAamp->mConfig.ProcessConfigText(param, AAMP_DEV_CFG_SETTING);
411  mHarvestor.mPlayerInstanceAamp->mConfig.DoCustomSetting(AAMP_DEV_CFG_SETTING);
412 
413  std::size_t delimiterPos = param.find("=");
414 
415  if(delimiterPos != std::string::npos)
416  {
417  cmdlineParams[ param.substr(0, delimiterPos) ] = param.substr(delimiterPos + 1);
418  }
419  }
420 
421 
422  int harvestConfig = 0;
423  mHarvestor.mPlayerInstanceAamp->mConfig.GetConfigValue(eAAMPConfig_HarvestConfig,harvestConfig) ;
424 
425  mHarvestor.mPlayerInstanceAamp->Tune(cmdlineParams["harvestUrl"].c_str());
426 
428  {
429  float rate = 2;
430  mHarvestor.mPlayerInstanceAamp->SetRate(rate);
431 
432  }
433 
434  while (1)
435  {
436  sleep(1);
437 
438  if(mHarvestor.mPlayerInstanceAamp->GetState() == eSTATE_COMPLETE)
439  {
440  printf("%s:%d: Tune completed exiting harvesting mode\n",__FUNCTION__,__LINE__);
441  break;
442  }
443 
444  if (mHarvestor.mPlayerInstanceAamp->GetState() > eSTATE_PLAYING)
445  {
446  mHarvestor.mPlayerInstanceAamp->Tune(cmdlineParams["harvestUrl"].c_str());
447 
449  {
450  float rate = 2;
451  mHarvestor.mPlayerInstanceAamp->SetRate(rate);
452 
453  }
454  }
455  }
456 
457  return;
458 }
459 
460 void Harvestor::slaveDataOutput(void * arg)
461 {
462  FILE * pipe;
463  pipe = (FILE *) arg;
464  char buffer[500] = {'\0'};
465  if(aamp_pthread_setname(pthread_self(), "SlaveOutput"))
466  {
467  printf("%s:%d: slaveDataOutput aamp_pthread_setname failed\n",__FUNCTION__, __LINE__);
468  }
469 
470  while (!feof(pipe))
471  {
472  if (fgets(buffer, 500, pipe) != NULL)
473  {
474  mHarvestor.getHarvestReportDetails(buffer);
475  printf("%s:%d: [0x%p] %s",__FUNCTION__, __LINE__,pipe,buffer);
476  }
477  }
478 
479  return;
480 }
481 
482 long Harvestor::getNumberFromString(std::string buffer)
483 {
484  std::stringstream strm;
485  strm << buffer;
486  std::string tempStr;
487  long value = 0;
488  while(!strm.eof()) {
489  strm >> tempStr;
490  if(std::stringstream(tempStr) >> value)
491  {
492  return value;
493  }
494 
495  tempStr = "";
496  }
497 
498  return value;
499 }
500 
501 void Harvestor::startHarvestReport(char * harvesturl)
502 {
503  FILE *fp;
504  FILE *errorfp;
505  std::string filename;
506  std::string errorFilename;
507 
508  filename = Harvestor::mHarvestPath+"/HarvestReport.txt";
509  errorFilename = Harvestor::mHarvestPath+"/HarvestErrorReport.txt";
510 
511  fp = fopen(filename.c_str(), "w");
512 
513  if (fp == NULL)
514  {
515  printf("Error opening the file %s\n", filename.c_str());
516  return;
517  }
518 
519  fprintf(fp, "Harvest Profile Details\n\n");
520  fprintf(fp, "Harvest url : %s\n",harvesturl);
521  fprintf(fp, "Harvest mode : Master\n");
522  fclose(fp);
523 
524  Harvestor::mHarvestReportFlag = true;
525 
526  errorfp = fopen(errorFilename.c_str(), "w");
527 
528  if (errorfp == NULL)
529  {
530  printf("Error opening the file %s\n", errorFilename.c_str());
531  return;
532  }
533 
534  fprintf(errorfp, "Harvest Error Report\n\n");
535  fprintf(errorfp, "Harvest url : %s\n",harvesturl);
536  fclose(errorfp);
537  return;
538 }
539 
540 bool Harvestor::getHarvestReportDetails(char *buffer)
541 {
542  char *harvestPath = NULL;
543  char *token = NULL;
544  std::thread::id threadId;
545  HarvestProfileDetails l_harvestProfileDetails;
546  std::map<std::thread::id, HarvestProfileDetails>::iterator itr;
547 
548  memset(&l_harvestProfileDetails,'\0',sizeof(l_harvestProfileDetails));
549  threadId = std::this_thread::get_id();
550 
551  if(mHarvestInfo.find(threadId) == mHarvestInfo.end())
552  {
553  mHarvestInfo.insert( std::make_pair(threadId, l_harvestProfileDetails) );
554  mHarvestThreadId.push_back(threadId);
555  }
556 
557  itr = mHarvestInfo.find(threadId);
558 
559  if ((itr->second.harvestConfig == 0) && (strstr(buffer, "harvestConfig -") != NULL))
560  {
561  token = strstr(buffer, "harvestConfig -");
562 
563  itr->second.harvestConfig = getNumberFromString(token);
564 
565  if(itr->second.harvestConfig == 193)
566  strcpy(itr->second.media,"IFrame");
567 
568  if(itr->second.harvestConfig == 161)
569  strcpy(itr->second.media,"Video");
570 
571  if(itr->second.harvestConfig == 2)
572  strcpy(itr->second.media,"Audio");
573  }
574 
575  if ((itr->second.bitrate == 0) && (strstr(buffer, "defaultBitrate -") != NULL))
576  {
577  token = strstr(buffer, "defaultBitrate -");
578  itr->second.bitrate = getNumberFromString(token);
579  }
580 
581  if (strstr(buffer, "harvestCountLimit:") != NULL)
582  {
583  token = strstr(buffer, "harvestCountLimit:");
584  itr->second.harvestFragmentsCount = getNumberFromString(token);
585  }
586 
587  if ((strstr(buffer, "error") != NULL) || (strstr(buffer, "File open failed") != NULL) )
588  {
589  writeHarvestErrorReport(itr->second,buffer);
590 
591  }
592 
593  if ( (itr->second.harvestEndFlag == false) && (strstr(buffer, "EndOfStreamReached") != NULL))
594  {
595  writeHarvestEndReport(itr->second,buffer);
596  itr->second.harvestEndFlag = true;
597  }
598 
599  return true;
600 }
601 
602 void Harvestor::writeHarvestErrorReport(HarvestProfileDetails harvestProfileDetails, char *buffer)
603 {
604 
605  FILE *errorfp;
606  std::string errorFilename;
607  errorFilename = Harvestor::mHarvestPath+"/HarvestErrorReport.txt";
608 
609  errorfp = fopen(errorFilename.c_str(), "a");
610 
611  if (errorfp == NULL)
612  {
613  printf("Error opening the file %s\n", errorFilename.c_str());
614  return;
615  }
616 
617  if (strstr(buffer, "error") != NULL)
618  {
619  harvestProfileDetails.harvesterrorCount++;
620  fprintf(errorfp, "Error : %s",buffer);
621  }
622 
623  if (strstr(buffer, "File open failed") != NULL)
624  {
625  harvestProfileDetails.harvestFailureCount++;
626  fprintf(errorfp, "Failed : %s",buffer);
627  }
628 
629  fclose(errorfp);
630 }
631 
632 void Harvestor::writeHarvestEndReport(HarvestProfileDetails harvestProfileDetails, char *buffer)
633 {
634  FILE *fp;
635  std::string filename;
636  int harvestCountLimit = 0;
637 
638  filename = Harvestor::mHarvestPath+"/HarvestReport.txt";
639  fp = fopen(filename.c_str(), "a");
640 
641  if (fp == NULL)
642  {
643  printf("Error opening the file %s\n", filename.c_str());
644  return;
645  }
646 
647  mHarvestor.mPlayerInstanceAamp->mConfig.GetConfigValue(eAAMPConfig_HarvestCountLimit,harvestCountLimit);
648  harvestProfileDetails.harvestFragmentsCount = harvestCountLimit - harvestProfileDetails.harvestFragmentsCount;
649 
650  fprintf(fp, "\nMedia : %s\nBitrate : %lu\nTotal fragments count : %d\nError fragments count : %d\nFailure fragments count : %d\n",harvestProfileDetails.media,harvestProfileDetails.bitrate,harvestProfileDetails.harvestFragmentsCount,harvestProfileDetails.harvesterrorCount,harvestProfileDetails.harvestFailureCount);
651 
652  fclose(fp);
653 
654 }
655 
656 void Harvestor::harvestTerminateHandler(int signal)
657 {
658 
659  if((Harvestor::mHarvestReportFlag == true) && (!mHarvestThreadId.empty()))
660  {
661  FILE *fp;
662  std::string filename;
663  int harvestCountLimit = 0;
664 
665  filename = Harvestor::mHarvestPath+"/HarvestReport.txt";
666  fp = fopen(filename.c_str(), "a");
667 
668  if (fp == NULL)
669  {
670  printf("Error opening the file %s\n", filename.c_str());
671  return;
672  }
673 
674  for(auto item: mHarvestThreadId)
675  {
676  auto itr = mHarvestInfo.find(item);
677 
678  if((itr != mHarvestInfo.end()) && (itr->second.harvestEndFlag == false))
679  {
680  mHarvestor.mPlayerInstanceAamp->mConfig.GetConfigValue(eAAMPConfig_HarvestCountLimit,harvestCountLimit);
681  itr->second.harvestFragmentsCount = harvestCountLimit - itr->second.harvestFragmentsCount;
682 
683  fprintf(fp, "\nMedia : %s\nBitrate : %lu\nTotal fragments count : %d\nError fragments count : %d\nFailure fragments count : %d\n",itr->second.media,itr->second.bitrate,itr->second.harvestFragmentsCount,itr->second.harvesterrorCount,itr->second.harvestFailureCount);
684 
685  itr->second.harvestEndFlag = true;
686  }
687  }
688 
689  fclose(fp);
690  }
691 
692  printf("%s:%d: Signal handler\n",__FUNCTION__, __LINE__);
693 
694  exit(signal);
695 }
696 
697 #ifdef __linux__
698 void Harvestor::getExecutablePath()
699 {
700  realpath(PROC_SELF_EXE, Harvestor::exePathName);
701 }
702 #endif
703 
704 #ifdef __APPLE__
705 void Harvestor::getExecutablePath()
706 {
707  char rawPathName[PATH_MAX];
708  uint32_t rawPathSize = (uint32_t)sizeof(rawPathName);
709 
710  if(!_NSGetExecutablePath(rawPathName, &rawPathSize))
711  {
712  realpath(rawPathName, Harvestor::exePathName);
713  }
714 }
715 #endif
PlayerInstanceAAMP::GetVideoBitrate
long GetVideoBitrate(void)
To get the bitrate of current video profile.
Definition: main_aamp.cpp:1787
eMEDIATYPE_VIDEO
@ eMEDIATYPE_VIDEO
Definition: AampMediaType.h:39
eAAMPConfig_HarvestCountLimit
@ eAAMPConfig_HarvestCountLimit
Definition: AampConfig.h:211
harvestProfileDetails
Definition: AampcliHarvestor.h:45
getHarvestConfigForMedia
int getHarvestConfigForMedia(MediaType fileType)
Get harvest config corresponds to Media type.
Definition: AampUtils.cpp:807
PlayerInstanceAAMP::GetVideoBitrates
std::vector< long > GetVideoBitrates(void)
To get the available video bitrates.
Definition: main_aamp.cpp:1893
AampConfig::GetConfigValue
bool GetConfigValue(AAMPConfigSettings cfg, std::string &value)
GetConfigValue - Gets configuration for string data type.
Definition: AampConfig.cpp:748
eMEDIATYPE_AUDIO
@ eMEDIATYPE_AUDIO
Definition: AampMediaType.h:40
PlayerInstanceAAMP
Player interface class for the JS pluggin.
Definition: main_aamp.h:692
AampConfig::ProcessConfigText
bool ProcessConfigText(std::string &cfg, ConfigPriority owner)
ProcessConfigText - Function to parse and process configuration text.
Definition: AampConfig.cpp:1347
AampConfig::DoCustomSetting
void DoCustomSetting(ConfigPriority owner)
DoCustomSetting - Function to do override , to avoid complexity with multiple configs.
Definition: AampConfig.cpp:1993
eMEDIATYPE_IFRAME
@ eMEDIATYPE_IFRAME
Definition: AampMediaType.h:45
eAAMPConfig_HarvestConfig
@ eAAMPConfig_HarvestConfig
Definition: AampConfig.h:212
PlayerInstanceAAMP::GetState
PrivAAMPState GetState(void)
To get the current AAMP state.
Definition: main_aamp.cpp:1765
PlayerInstanceAAMP::SetRate
void SetRate(float rate, int overshootcorrection=0)
Set playback rate.
Definition: main_aamp.cpp:561
PlayerInstanceAAMP::Tune
void Tune(const char *mainManifestUrl, const char *contentType, bool bFirstAttempt, bool bFinalAttempt, const char *traceUUID, bool audioDecoderStreamSync)
Tune to a URL. DEPRECATED! This is included for backwards compatibility with current Sky AS integrati...
Definition: main_aamp.cpp:312
PlayerInstanceAAMP::GetAudioBitrate
long GetAudioBitrate(void)
To get the bitrate of current audio profile.
Definition: main_aamp.cpp:1826
Harvestor
Definition: AampcliHarvestor.h:56
eMEDIATYPE_INIT_VIDEO
@ eMEDIATYPE_INIT_VIDEO
Definition: AampMediaType.h:46
PlayerInstanceAAMP::GetAudioBitrates
std::vector< long > GetAudioBitrates(void)
To get the available audio bitrates.
Definition: main_aamp.cpp:1935
AampcliHarvestor.h
AampcliHarvestor header file.
eMEDIATYPE_LICENCE
@ eMEDIATYPE_LICENCE
Definition: AampMediaType.h:44
eSTATE_PLAYING
@ eSTATE_PLAYING
Definition: AampEvent.h:166
eSTATE_COMPLETE
@ eSTATE_COMPLETE
Definition: AampEvent.h:169