RDK Documentation (Open Sourced RDK Components)
AampcliHarvestor.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 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.h
22  * @brief AampcliHarvestor header file
23  */
24 
25 #ifndef AAMPCLIHARVESTOR_H
26 #define AAMPCLIHARVESTOR_H
27 
28 #include <libgen.h>
29 #include <limits.h>
30 #include <unistd.h>
31 #include "AampcliCommandHandler.h"
32 
33 #ifdef __APPLE__
34  #include <mach-o/dyld.h>
35 #endif
36 
37 #ifdef __linux__
38  #if defined(__sun)
39  #define PROC_SELF_EXE "/proc/self/path/a.out"
40  #else
41  #define PROC_SELF_EXE "/proc/self/exe"
42  #endif
43 #endif
44 
45 typedef struct harvestProfileDetails
46 {
47  bool harvestEndFlag;
48  char media[7];
49  int harvestConfig;
50  int harvestFragmentsCount;
51  int harvesterrorCount;
52  int harvestFailureCount;
53  long bitrate;
55 
56 class Harvestor : public Command
57 {
58 
59  public:
60  static bool mHarvestReportFlag;
61  static const int mHarvestCommandLength = 4096;
62  static const int mHarvestSlaveThreadCount = 50;
63  static char exePathName[PATH_MAX];
64  static std::string mHarvestPath;
65  static std::map<std::thread::id, harvestProfileDetails> mHarvestInfo;
66  static std::vector<std::thread::id> mHarvestThreadId;
67  static PlayerInstanceAAMP *mPlayerInstanceAamp;
68 
69  std::thread mMasterHarvestorThreadID;
70  std::thread mSlaveHarvestorThreadID;
71  std::thread mReportThread;
72  std::thread mSlaveIFrameThread;
73  std::thread mSlaveVideoThreads[mHarvestSlaveThreadCount];
74  std::thread mSlaveAudioThreads[mHarvestSlaveThreadCount];
75 
76  static void masterHarvestor(void * arg);
77  static void slaveHarvestor(void * arg);
78  static void slaveDataOutput(void * arg);
79  long getNumberFromString(std::string buffer);
80  void startHarvestReport(char * arg);
81  bool getHarvestReportDetails(char *buffer);
82  void writeHarvestErrorReport(HarvestProfileDetails, char *buffer);
83  void writeHarvestEndReport(HarvestProfileDetails, char *buffer);
84  static void harvestTerminateHandler(int signal);
85  void getExecutablePath();
86  bool execute(char *cmd, PlayerInstanceAAMP *playerInstanceAamp);
87  Harvestor();
88 };
89 
90 
91 #endif // AAMPCLIHARVESTOR_H
harvestProfileDetails
Definition: AampcliHarvestor.h:45
PlayerInstanceAAMP
Player interface class for the JS pluggin.
Definition: main_aamp.h:692
AampcliCommandHandler.h
AampcliCommandHandler header file.
Harvestor
Definition: AampcliHarvestor.h:56
Command
Definition: AampcliCommandHandler.h:35