27 bool AampPlayer::mInitialized =
false;
28 GMainLoop* AampPlayer::mAampGstPlayerMainLoop = NULL;
29 GThread* AampPlayer::mAampMainLoopThread = NULL;
33 AampPlayer :: AampPlayer():
34 mEnableProgressLog(false),
35 mTuneFailureDescription(
"")
39 AampPlayer :: AampPlayer(
const AampPlayer &aampPlayer):
40 mEnableProgressLog(aampPlayer.mEnableProgressLog),
41 mTuneFailureDescription(aampPlayer.mTuneFailureDescription)
47 mEnableProgressLog = aampPlayer.mEnableProgressLog;
48 mTuneFailureDescription = aampPlayer.mTuneFailureDescription;
59 if (mAampPlayer.mAampGstPlayerMainLoop)
61 g_main_loop_run(mAampPlayer.mAampGstPlayerMainLoop);
62 printf(
"aampGstPlayerStreamThread: exited main event loop\n");
65 g_main_loop_unref(mAampPlayer.mAampGstPlayerMainLoop);
66 mAampPlayer.mAampGstPlayerMainLoop = NULL;
80 gst_init(&argc, &argv);
81 mAampGstPlayerMainLoop = g_main_loop_new(NULL, FALSE);
88 printf(
"allocating new SmokeTestEventListener\n");
94 FILE * AampPlayer::getConfigFile(
const std::string& cfgFile)
101 #ifdef SIMULATOR_BUILD
102 std::string cfgBasePath(getenv(
"HOME"));
103 std::string cfgPath = cfgBasePath + cfgFile;
104 FILE *f = fopen(cfgPath.c_str(),
"rb");
106 std::string cfgPath =
"/opt" + cfgFile;
107 FILE *f = fopen(cfgPath.c_str(),
"rb");
114 const char *SmokeTestEventListener::stringifyPrivAAMPState(
PrivAAMPState state)
116 static const char *stateName[] =
135 return stateName[state];
149 switch (e->getType())
153 StateChangedEventPtr ev = std::dynamic_pointer_cast<StateChangedEvent>(e);
154 printf(
"AAMP_EVENT_STATE_CHANGED: %s (%d)\n", mAampPlayer.mEventListener->stringifyPrivAAMPState(ev->getState()), ev->getState());
159 SeekedEventPtr ev = std::dynamic_pointer_cast<SeekedEvent>(e);
160 printf(
"AAMP_EVENT_SEEKED: new positionMs %f\n", ev->getPosition());
165 MediaMetadataEventPtr ev = std::dynamic_pointer_cast<MediaMetadataEvent>(e);
166 std::vector<std::string> languages = ev->getLanguages();
167 int langCount = ev->getLanguagesCount();
168 printf(
"AAMP_EVENT_MEDIA_METADATA\n");
169 for (
int i = 0; i < langCount; i++)
171 printf(
"[] language: %s\n", languages[i].c_str());
173 printf(
"AAMP_EVENT_MEDIA_METADATA\n\tDuration=%ld\n\twidth=%d\n\tHeight=%d\n\tHasDRM=%d\n\tProgreamStartTime=%f\n", ev->getDuration(), ev->getWidth(), ev->getHeight(), ev->hasDrm(), ev->getProgramStartTime());
174 int bitrateCount = ev->getBitratesCount();
175 std::vector<long> bitrates = ev->getBitrates();
176 printf(
"Bitrates:\n");
177 for(
int i = 0; i < bitrateCount; i++)
179 printf(
"\tbitrate(%d)=%ld\n", i, bitrates.at(i));
185 printf(
"AAMP_EVENT_TUNED\n");
190 MediaErrorEventPtr ev = std::dynamic_pointer_cast<MediaErrorEvent>(e);
191 mAampPlayer.mTuneFailureDescription = ev->getDescription();
192 printf(
"AAMP_EVENT_TUNE_FAILED reason=%s\n",mAampPlayer.mTuneFailureDescription.c_str());
197 SpeedChangedEventPtr ev = std::dynamic_pointer_cast<SpeedChangedEvent>(e);
198 printf(
"AAMP_EVENT_SPEED_CHANGED current rate=%f\n", ev->getRate());
203 DrmMetaDataEventPtr ev = std::dynamic_pointer_cast<DrmMetaDataEvent>(e);
204 printf(
"AAMP_DRM_FAILED Tune failure:%d\t\naccess status str:%s\t\naccess status val:%d\t\nResponce code:%ld\t\nIs SecClient error:%d\t\n",ev->getFailure(), ev->getAccessStatus().c_str(), ev->getAccessStatusValue(), ev->getResponseCode(), ev->getSecclientError());
208 printf(
"AAMP_EVENT_EOS\n");
211 printf(
"AAMP_EVENT_PLAYLIST_INDEXED\n");
215 ProgressEventPtr ev = std::dynamic_pointer_cast<ProgressEvent>(e);
216 if(mAampPlayer.mEnableProgressLog)
218 printf(
"AAMP_EVENT_PROGRESS\n\tDuration=%lf\n\tposition=%lf\n\tstart=%lf\n\tend=%lf\n\tcurrRate=%f\n\tBufferedDuration=%lf\n\tPTS=%lld\n\ttimecode=%s\n",ev->getDuration(),ev->getPosition(),ev->getStart(),ev->getEnd(),ev->getSpeed(),ev->getBufferedDuration(),ev->getPTS(),ev->getSEITimeCode());
224 CCHandleEventPtr ev = std::dynamic_pointer_cast<CCHandleEvent>(e);
225 printf(
"AAMP_EVENT_CC_HANDLE_RECEIVED CCHandle=%lu\n",ev->getCCHandle());
230 BitrateChangeEventPtr ev = std::dynamic_pointer_cast<BitrateChangeEvent>(e);
231 printf(
"AAMP_EVENT_BITRATE_CHANGED\n\tbitrate=%ld\n\tdescription=\"%s\"\n\tresolution=%dx%d@%ffps\n\ttime=%d\n\tposition=%lf\n", ev->getBitrate(), ev->getDescription().c_str(), ev->getWidth(), ev->getHeight(), ev->getFrameRate(), ev->getTime(), ev->getPosition());
235 printf(
"AAMP_EVENT_AUDIO_TRACKS_CHANGED\n");
238 printf(
"AAMP_EVENT_TEXT_TRACKS_CHANGED\n");
241 printf(
"AAMP_EVENT_ID3_METADATA\n");
245 BlockedEventPtr ev = std::dynamic_pointer_cast<BlockedEvent>(e);
246 printf(
"AAMP_EVENT_BLOCKED Reason:%s\n" ,ev->getReason().c_str());
251 ContentGapEventPtr ev = std::dynamic_pointer_cast<ContentGapEvent>(e);
252 printf(
"AAMP_EVENT_CONTENT_GAP\n\tStart:%lf\n\tDuration:%lf\n", ev->getTime(), ev->getDuration());
257 WatermarkSessionUpdateEventPtr ev = std::dynamic_pointer_cast<WatermarkSessionUpdateEvent>(e);
258 printf(
"AAMP_EVENT_WATERMARK_SESSION_UPDATE SessionHandle:%d Status:%d System:%s\n" ,ev->getSessionHandle(), ev->getStatus(), ev->getSystem().c_str());
263 BufferingChangedEventPtr ev = std::dynamic_pointer_cast<BufferingChangedEvent>(e);
264 printf(
"AAMP_EVENT_BUFFERING_CHANGED Sending Buffer Change event status (Buffering): %s", (ev->buffering() ?
"End":
"Start"));
269 ContentProtectionDataEventPtr ev = std::dynamic_pointer_cast<ContentProtectionDataEvent>(e);
270 printf(
"AAMP_EVENT_CONTENT_PROTECTION_UPDATE received stream type %s\n",ev->getStreamType().c_str());
271 std::vector<uint8_t> key = ev->getKeyID();
272 printf(
"AAMP_EVENT_CONTENT_PROTECTION_UPDATE received key is ");
273 for(
int i=0;i<key.size();i++)
274 printf(
"%x",key.at(i)&0xff);
276 cJSON *root = cJSON_CreateObject();
277 cJSON *KeyId = cJSON_CreateArray();
278 for(
int i=0;i<key.size();i++)
279 cJSON_AddItemToArray(KeyId, cJSON_CreateNumber(key.at(i)));
280 cJSON_AddItemToObject(root,
"keyID",KeyId);
281 std::string json = cJSON_Print(root);