RDK Documentation (Open Sourced RDK Components)
AampcliGet.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 AampcliGet.cpp
22  * @brief Aampcli Get command handler
23  */
24 
25 #include <iomanip>
26 #include"AampcliGet.h"
27 
28 std::map<string,getCommandInfo> Get::getCommands = std::map<string,getCommandInfo>();
29 std::vector<std::string> Get::commands(0);
30 
31 bool Get::execute(char *cmd, PlayerInstanceAAMP *playerInstanceAamp)
32 {
33  char help[8];
34  int opt, value1, value2;
35  char command[100];
36  int getCmd;
37 
38 
39  if (sscanf(cmd, "get %s", command) == 1)
40  {
41  if(isdigit(command[0]))
42  {
43  getCmd = atoi(command);
44  }
45  else
46  {
47  std::map<string,getCommandInfo>::iterator getCmdItr;
48  getCmdItr = getCommands.find(command);
49 
50  if(getCmdItr != getCommands.end())
51  {
52  getCmd = getCmdItr->second.value;
53  }
54  }
55 
56  if(0 == strncmp("help", command, 4))
57  {
58  ShowHelpGet();
59  }
60  else
61  {
62  switch(getCmd){
63  case 32:
64  printf("[AAMPCLI] GETTING AVAILABLE THUMBNAIL TRACKS: %s\n", playerInstanceAamp->GetAvailableThumbnailTracks().c_str() );
65  break;
66 
67  case 1:
68  printf("[AAMPCLI] GETTING CURRENT STATE: %d\n", (int) playerInstanceAamp->GetState());
69  break;
70 
71  case 33:
72  sscanf(cmd, "get %d %d %d",&opt, &value1, &value2);
73  printf("[AAMPCLI] GETTING THUMBNAIL TIME RANGE DATA for duration(%d,%d): %s\n",value1,value2,playerInstanceAamp->GetThumbnails(value1, value2).c_str());
74  break;
75 
76  case 24:
77  printf("[AAMPCLI] CURRENT AUDIO TRACK NUMBER: %d\n", playerInstanceAamp->GetAudioTrack() );
78  break;
79 
80  case 25:
81  printf("[AAMPCLI] INITIAL BUFFER DURATION: %d\n", playerInstanceAamp->GetInitialBufferDuration() );
82  break;
83 
84  case 26:
85  printf("[AAMPCLI] CURRENT AUDIO TRACK INFO: %s\n", playerInstanceAamp->GetAudioTrackInfo().c_str() );
86  break;
87 
88  case 27:
89  printf("[AAMPCLI] CURRENT TEXT TRACK INFO: %s\n", playerInstanceAamp->GetTextTrackInfo().c_str() );
90  break;
91 
92  case 28:
93  printf("[AAMPCLI] CURRENT PREPRRED AUDIO PROPERTIES: %s\n", playerInstanceAamp->GetPreferredAudioProperties().c_str() );
94  break;
95 
96  case 29:
97  printf("[AAMPCLI] CURRENT PREPRRED TEXT PROPERTIES: %s\n", playerInstanceAamp->GetPreferredTextProperties().c_str() );
98  break;
99 
100  case 30:
101  printf("[AAMPCLI] CC VISIBILITY STATUS: %s\n",playerInstanceAamp->GetCCStatus()?"ENABLED":"DISABLED");
102  break;
103 
104  case 31:
105  printf("[AAMPCLI] CURRENT TEXT TRACK: %d\n", playerInstanceAamp->GetTextTrack() );
106  break;
107 
108  case 20:
109  printf("[AAMPCLI] AVAILABLE AUDIO TRACKS: %s\n", playerInstanceAamp->GetAvailableAudioTracks(false).c_str() );
110  break;
111  case 34:
112  printf("[AAMPCLI] AVAILABLE VIDEO TRACKS: %s\n", playerInstanceAamp->GetAvailableVideoTracks().c_str() );
113  break;
114 
115  case 21:
116  printf("[AAMPCLI] ALL AUDIO TRACKS: %s\n", playerInstanceAamp->GetAvailableAudioTracks(true).c_str() );
117  break;
118 
119  case 23:
120  printf("[AAMPCLI] ALL TEXT TRACKS: %s\n", playerInstanceAamp->GetAvailableTextTracks(true).c_str() );
121  break;
122 
123  case 22:
124  printf("[AAMPCLI] AVAILABLE TEXT TRACKS: %s\n", playerInstanceAamp->GetAvailableTextTracks(false).c_str() );
125  break;
126 
127  case 2:
128  printf("[AAMPCLI] CURRRENT AUDIO LANGUAGE = %s\n",
129  playerInstanceAamp->GetCurrentAudioLanguage());
130  break;
131 
132  case 3:
133  printf("[AAMPCLI] CURRRENT DRM = %s\n",
134  playerInstanceAamp->GetCurrentDRM());
135  break;
136 
137  case 4:
138  printf("[AAMPCLI] PLAYBACK POSITION = %lf\n",
139  playerInstanceAamp->GetPlaybackPosition());
140  break;
141 
142  case 5:
143  printf("[AAMPCLI] PLAYBACK DURATION = %lf\n",
144  playerInstanceAamp->GetPlaybackDuration());
145  break;
146 
147  case 6:
148  printf("[AAMPCLI] CURRENT VIDEO PROFILE BITRATE = %ld\n",
149  playerInstanceAamp->GetVideoBitrate());
150  break;
151 
152  case 7:
153  printf("[AAMPCLI] INITIAL BITRATE = %ld \n",
154  playerInstanceAamp->GetInitialBitrate());
155  break;
156 
157  case 8:
158  printf("[AAMPCLI] INITIAL BITRATE 4K = %ld \n",
159  playerInstanceAamp->GetInitialBitrate4k());
160  break;
161 
162  case 9:
163  printf("[AAMPCLI] MINIMUM BITRATE = %ld \n",
164  playerInstanceAamp->GetMinimumBitrate());
165  break;
166 
167  case 10:
168  printf("[AAMPCLI] MAXIMUM BITRATE = %ld \n",
169  playerInstanceAamp->GetMaximumBitrate());
170  break;
171 
172  case 11:
173  printf("[AAMPCLI] AUDIO BITRATE = %ld\n",
174  playerInstanceAamp->GetAudioBitrate());
175  break;
176 
177  case 12:
178  printf("[AAMPCLI] Video Zoom mode: %s\n",
179  (playerInstanceAamp->GetVideoZoom())?"None(Normal)":"Full(Enabled)");
180  break;
181 
182  case 13:
183  printf("[AAMPCLI] Video Mute status:%s\n",
184  (playerInstanceAamp->GetVideoMute())?"ON":"OFF");
185  break;
186 
187  case 14:
188  printf("[AAMPCLI] AUDIO VOLUME = %d\n",
189  playerInstanceAamp->GetAudioVolume());
190  break;
191 
192  case 15:
193  printf("[AAMPCLI] PLAYBACK RATE = %d\n",
194  playerInstanceAamp->GetPlaybackRate());
195  break;
196 
197  case 16:
198  {
199  std::vector<long int> videoBitrates;
200  printf("[AAMPCLI] VIDEO BITRATES = [ ");
201  videoBitrates = playerInstanceAamp->GetVideoBitrates();
202  for(int i=0; i < videoBitrates.size(); i++){
203  printf("%ld, ", videoBitrates[i]);
204  }
205  printf(" ]\n");
206  break;
207  }
208 
209  case 17:
210  {
211  std::vector<long int> audioBitrates;
212  printf("[AAMPCLI] AUDIO BITRATES = [ ");
213  audioBitrates = playerInstanceAamp->GetAudioBitrates();
214  for(int i=0; i < audioBitrates.size(); i++){
215  printf("%ld, ", audioBitrates[i]);
216  }
217  printf(" ]\n");
218  break;
219  }
220  case 18:
221  {
222  const char *prefferedLanguages = playerInstanceAamp->GetPreferredLanguages();
223  printf("[AAMPCLI] PREFERRED LANGUAGES = \"%s\"\n", prefferedLanguages? prefferedLanguages : "<NULL>");
224  break;
225  }
226 
227  case 19:
228  {
229  printf("[AAMPCLI] RAMP DOWN LIMIT= %d\n", playerInstanceAamp->GetRampDownLimit());
230  break;
231  }
232 
233  default:
234  printf("[AAMPCLI] Invalid get command %s\n", cmd);
235  break;
236  }
237 
238  }
239  }
240  else
241  {
242  printf("[AAMPCLI] Invalid get command = %s\n", cmd);
243  }
244 
245  return true;
246 }
247 
248 /**
249  * @brief Show help menu with aamp command line interface
250  */
252 {
253  addCommand(1,"currentState","Get current player state");
254  addCommand(2,"currentAudioLan","Get Current audio language");
255  addCommand(3,"currentDrm","Get Current DRM");
256  addCommand(4,"playbackPosition","Get Current Playback position");
257  addCommand(5,"playbackDuration","Get Playback Duration");
258  addCommand(6,"videoBitrate","Get current video bitrate");
259  addCommand(7,"initialBitrate","Get Initial Bitrate");
260  addCommand(8,"initialBitrate4k","Get Initial Bitrate 4K");
261  addCommand(9,"minimumBitrate","Get Minimum Bitrate");
262  addCommand(10,"maximumBitrate","Get Maximum Bitrate");
263  addCommand(11,"audioBitrate","Get current Audio bitrate");
264  addCommand(12,"videoZoom","Get Video Zoom mode");
265  addCommand(13,"videoMute","Get Video Mute status");
266  addCommand(14,"audioVolume","Get current Audio volume");
267  addCommand(15,"playbackRate","Get Current Playback rate");
268  addCommand(16,"videoBitrates","Get Video bitrates supported");
269  addCommand(17,"audioBitrates","Get Audio bitrates supported");
270  addCommand(18,"currentPreferredLanguages","Get Current preferred languages");
271  addCommand(19,"rampDownLimit","Get number of Ramp down limit during playback");
272  addCommand(20,"availableAudioTracks","Get Available Audio Tracks");
273  addCommand(21,"allAvailableAudioTracks","Get All Available Audio Tracks information from manifest");
274  addCommand(22,"availableTextTracks","Get Available Text Tracks");
275  addCommand(23,"allAvailableTextTracks","Get All Available Text Tracks information from manifest");
276  addCommand(24,"audioTrack","Get Audio Track");
277  addCommand(25,"initialBufferDuration","Get Initial Buffer Duration( in sec)");
278  addCommand(26,"audioTrackInfo","Get current Audio Track information in json format");
279  addCommand(27,"textTrackInfo","Get current Text Track information in json format");
280  addCommand(28,"preferredAudioProperties","Get current Preferred Audio properties in json format");
281  addCommand(29,"preferredTextProperties","Get current Preferred Text properties in json format");
282  addCommand(30,"ccStatus","Get CC Status");
283  addCommand(31,"textTrack","Get Text Track");
284  addCommand(32,"thumbnailConfig","Get Available ThumbnailTracks");
285  addCommand(33,"thumbnailData","Get Thumbnail timerange data(int startpos, int endpos)");
286  addCommand(34,"availableVideoTracks","Get All Available Video Tracks information from manifest");
287  commands.push_back("help");
288 }
289 
290 void Get::addCommand(int value,string command,string description)
291 {
292  getCommandInfo lCmdInfo;
293  lCmdInfo.value = value;
294  lCmdInfo.description = description;
295 
296  getCommands.insert(std::make_pair(command,lCmdInfo));
297  commands.push_back(command);
298 }
299 
300 /**
301  * @brief Display Help menu for get
302  * @param none
303  */
305 
306  std::map<string,getCommandInfo>::iterator getCmdItr;
307 
308  printf("******************************************************************************************\n");
309  printf("* get <command> [<arguments>]\n");
310  printf("* Usage of Commands, and arguments expected\n");
311  printf("******************************************************************************************\n");
312 
313  if(!commands.empty())
314  {
315  for(auto itr:commands)
316  {
317  getCmdItr = getCommands.find(itr);
318  if(getCmdItr != getCommands.end())
319  {
320  std::cout << "get " << std::right << std::setw(2) << (getCmdItr->second).value << " / " << std::setw(35) << std::left << (getCmdItr->first).c_str() << "// "<< (getCmdItr->second.description).c_str() << "\n";
321  }
322  }
323  }
324 
325  printf("****************************************************************************\n");
326 }
327 
328 char * Get::getCommandRecommender(const char *text, int state)
329 {
330  char *name;
331  static int len;
332  static std::vector<std::string>::iterator itr;
333 
334  if (!state)
335  {
336  itr = commands.begin();
337  len = strlen(text);
338  }
339 
340  while (itr != commands.end())
341  {
342  name = (char *) itr->c_str();
343  itr++;
344  if (strncmp(name, text, len) == 0)
345  {
346  return strdup(name);
347  }
348  }
349 
350  return NULL;
351 }
352 
PlayerInstanceAAMP::GetInitialBitrate
long GetInitialBitrate(void)
To get the initial bitrate value.
Definition: main_aamp.cpp:1962
PlayerInstanceAAMP::GetInitialBufferDuration
int GetInitialBufferDuration(void)
Get initial buffer duration in seconds.
Definition: main_aamp.cpp:444
Get::registerGetCommands
void registerGetCommands()
Show help menu with aamp command line interface.
Definition: AampcliGet.cpp:251
PlayerInstanceAAMP::GetMinimumBitrate
long GetMinimumBitrate(void)
Get minimum bitrate value.
Definition: main_aamp.cpp:511
PlayerInstanceAAMP::GetVideoBitrate
long GetVideoBitrate(void)
To get the bitrate of current video profile.
Definition: main_aamp.cpp:1787
PlayerInstanceAAMP::GetPlaybackPosition
double GetPlaybackPosition(void)
To get the current playback position.
Definition: main_aamp.cpp:1729
PlayerInstanceAAMP::GetTextTrackInfo
std::string GetTextTrackInfo()
Get current audio track index.
Definition: main_aamp.cpp:2448
AampcliGet.h
AampcliGet header file.
PlayerInstanceAAMP::GetPlaybackRate
int GetPlaybackRate(void)
To get the current playback rate.
Definition: main_aamp.cpp:1884
PlayerInstanceAAMP::GetAudioTrack
int GetAudioTrack()
Get current audio track index.
Definition: main_aamp.cpp:2556
PlayerInstanceAAMP::GetPreferredLanguages
const char * GetPreferredLanguages()
Get current preferred language list.
Definition: main_aamp.cpp:2387
PlayerInstanceAAMP::GetVideoZoom
int GetVideoZoom(void)
To get video zoom mode.
Definition: main_aamp.cpp:1852
PlayerInstanceAAMP::GetAvailableVideoTracks
std::string GetAvailableVideoTracks()
Get available video tracks.
Definition: main_aamp.cpp:2410
PlayerInstanceAAMP::GetAvailableAudioTracks
std::string GetAvailableAudioTracks(bool allTrack=false)
Get available audio tracks.
Definition: main_aamp.cpp:2428
PlayerInstanceAAMP::GetVideoBitrates
std::vector< long > GetVideoBitrates(void)
To get the available video bitrates.
Definition: main_aamp.cpp:1893
PlayerInstanceAAMP::GetCurrentDRM
const char * GetCurrentDRM()
Get current drm.
Definition: main_aamp.cpp:1547
GetCommandInfo
Definition: AampcliGet.h:32
PlayerInstanceAAMP::GetMaximumBitrate
long GetMaximumBitrate(void)
Get maximum bitrate value.
Definition: main_aamp.cpp:537
PlayerInstanceAAMP::GetPreferredTextProperties
std::string GetPreferredTextProperties()
Get preferred text prioperties.
Definition: main_aamp.cpp:2355
PlayerInstanceAAMP
Player interface class for the JS pluggin.
Definition: main_aamp.h:692
PlayerInstanceAAMP::GetAudioTrackInfo
std::string GetAudioTrackInfo()
Get current audio track index.
Definition: main_aamp.cpp:2438
PlayerInstanceAAMP::GetCCStatus
bool GetCCStatus(void)
Get CC visibility on/off.
Definition: main_aamp.cpp:2630
PlayerInstanceAAMP::GetInitialBitrate4k
long GetInitialBitrate4k(void)
To get the initial bitrate value for 4K assets.
Definition: main_aamp.cpp:1981
PlayerInstanceAAMP::GetPreferredAudioProperties
std::string GetPreferredAudioProperties()
Get preferred audio prioperties.
Definition: main_aamp.cpp:2345
PlayerInstanceAAMP::GetState
PrivAAMPState GetState(void)
To get the current AAMP state.
Definition: main_aamp.cpp:1765
PlayerInstanceAAMP::GetCurrentAudioLanguage
const char * GetCurrentAudioLanguage()
Get current audio language.
Definition: main_aamp.cpp:1523
Get::ShowHelpGet
void ShowHelpGet()
Display Help menu for get.
Definition: AampcliGet.cpp:304
PlayerInstanceAAMP::GetThumbnails
std::string GetThumbnails(double sduration, double eduration)
To get preferred thumbnails for the duration.
Definition: main_aamp.cpp:2703
PlayerInstanceAAMP::GetPlaybackDuration
double GetPlaybackDuration(void)
To get the current asset's duration.
Definition: main_aamp.cpp:1738
PlayerInstanceAAMP::GetTextTrack
int GetTextTrack()
Get current text track index.
Definition: main_aamp.cpp:2610
PlayerInstanceAAMP::GetAudioBitrate
long GetAudioBitrate(void)
To get the bitrate of current audio profile.
Definition: main_aamp.cpp:1826
PlayerInstanceAAMP::GetAvailableTextTracks
std::string GetAvailableTextTracks(bool allTrack=false)
Get available text tracks.
Definition: main_aamp.cpp:2460
PlayerInstanceAAMP::GetVideoMute
bool GetVideoMute(void)
To get video mute status.
Definition: main_aamp.cpp:1861
PlayerInstanceAAMP::GetAudioBitrates
std::vector< long > GetAudioBitrates(void)
To get the available audio bitrates.
Definition: main_aamp.cpp:1935
PlayerInstanceAAMP::GetRampDownLimit
int GetRampDownLimit(void)
Get profile ramp down limit.
Definition: main_aamp.cpp:470
PlayerInstanceAAMP::GetAvailableThumbnailTracks
std::string GetAvailableThumbnailTracks(void)
To get the available bitrates for thumbnails.
Definition: main_aamp.cpp:2678
PlayerInstanceAAMP::GetAudioVolume
int GetAudioVolume(void)
To get the current audio volume.
Definition: main_aamp.cpp:1870