19 #include "aampplayer.h"
20 #include "rdkmediaplayer.h"
31 #ifndef DISABLE_CLOSEDCAPTIONS
38 void setComcastSessionToken(
const char* token);
39 void loadAVEJavaScriptBindings(
void* context);
42 void* GetPlatformCallbackManager()
47 void ClearClosedCaptionSurface()
52 void HideClosedCaptionSurface()
56 void ShowClosedCaptionSurface()
65 void DestroySurface(
void* surface)
69 void GetSurfaceScale(
double *pScaleX,
double *pScaleY)
73 void SetSurfaceSize(
void* surface,
int width,
int height)
77 void SetSurfacePos(
void* surface,
int x,
int y)
81 #define CALL_ON_MAIN_THREAD(body) \
86 [](gpointer data) -> gboolean \
88 AAMPListener &self = *static_cast<AAMPListener*>(data); \
90 return G_SOURCE_REMOVE; \
105 m_eventTuned = m_eventPlaying = m_didProgress = m_tuned =
false;
106 m_lastPosition = std::numeric_limits<double>::max();
108 m_tuneStartTime = g_get_monotonic_time();
113 if(!m_tuned && (m_eventTuned && m_eventPlaying && m_didProgress))
115 LOG_WARNING(
"AAMP TUNETIME %.2fs\n", (
float)(g_get_monotonic_time() - m_tuneStartTime)/1000000.0f);
118 progress.data.progress.positionMiliseconds = 0;
119 progress.data.progress.durationMiliseconds = m_duration;
120 progress.data.progress.playbackSpeed = 1;
121 progress.data.progress.startMiliseconds = 0;
122 progress.data.progress.endMiliseconds = m_duration;
123 m_player->onProgress(progress);
136 LOG_INFO(
"tune failed. code:%d desc:%s failure:%d", e.data.mediaError.code, e.data.mediaError.description, e.data.mediaError.failure);
144 m_player->getParent()->
stop();
152 m_player->onProgress(e);
154 else if(m_eventTuned)
161 m_didProgress =
true;
176 for(
int i = 0; i < e.data.metadata.languageCount; ++i)
180 lang.append(e.data.metadata.languages[i]);
182 m_player->getParent()->
updateVideoMetadata(lang,
"-64,-32,-16,-4,-1,0,1,4,16,32,64", e.data.metadata.durationMiliseconds, e.data.metadata.width, e.data.metadata.height);
183 m_duration = e.data.metadata.durationMiliseconds;
194 switch(e.data.stateChanged.state)
210 m_eventPlaying =
true;
229 bool m_eventTuned, m_eventPlaying, m_didProgress, m_tuned;
231 double m_lastPosition;
232 gint64 m_tuneStartTime;
235 bool AAMPPlayer::canPlayURL(
const std::string& url)
237 std::string contentType;
249 AAMPPlayer::~AAMPPlayer()
252 delete m_aampListener;
254 delete m_aampInstance;
258 bool AAMPPlayer::doCanPlayURL(
const std::string& url)
260 return AAMPPlayer::canPlayURL(url);
263 void AAMPPlayer::doInit()
269 m_aampListener =
new AAMPListener(
this, m_aampInstance);
273 #ifndef DISABLE_CLOSEDCAPTIONS
279 LOG_INFO(
"DeviceSettings exception caught in %s\n", __FUNCTION__);
283 void AAMPPlayer::doLoad(
const std::string& url)
290 m_aampListener->reset();
294 m_aampInstance->
Tune(url.c_str());
299 LOG_INFO(
"Device Illegal argument exception caught in %s\n", __FUNCTION__);
303 void AAMPPlayer::doSetVideoRectangle(
const IntRect& rect)
305 if (rect.width() > 0 && rect.height() > 0)
307 LOG_INFO(
"set video rectangle: %dx%d %dx%d", rect.x(), rect.y(), rect.width(), rect.height());
308 m_aampInstance->
SetVideoRectangle(rect.x(), rect.y(), rect.width(), rect.height());
312 void AAMPPlayer::doSetAudioLanguage(std::string& lang)
316 LOG_INFO(
"set lang: %s", lang.c_str());
321 LOG_INFO(
"Device Illegal Argument Exception caught in %s\n", __FUNCTION__);
325 void AAMPPlayer::doPlay()
335 LOG_INFO(
"device IllegalArgumentException exception caught in %s\n", __FUNCTION__);
339 void AAMPPlayer::doPause()
349 LOG_INFO(
"device IllegalArgumentException exception caught in %s\n", __FUNCTION__);
353 void AAMPPlayer::doSetPosition(
float position)
357 if (!std::isnan(position))
359 LOG_INFO(
"set currentTime: %f", position);
361 m_aampInstance->
Seek(position/1000);
366 LOG_INFO(
"device IllegalArgumentException exception caught in %s\n", __FUNCTION__);
371 void AAMPPlayer::doSeekToLive()
383 LOG_INFO(
"device IllegalArgumentException exception caught in %s\n", __FUNCTION__);
388 void AAMPPlayer::doStop()
393 m_aampInstance->
Stop();
398 void AAMPPlayer::doChangeSpeed(
float speed, int32_t overshootTime)
402 LOG_INFO(
"doChangeSpeed(%f, %d)", speed, overshootTime);
404 m_aampInstance->
SetRate(speed, overshootTime);
408 LOG_INFO(
"device IllegalArgumentException exception caught in %s\n", __FUNCTION__);
412 void AAMPPlayer::doSetSpeed(
float speed)
418 m_aampInstance->
SetRate(speed);
422 LOG_INFO(
"device IllegalArgumentException exception caught in %s\n", __FUNCTION__);
426 void AAMPPlayer::doSetBlocked(
bool blocked)
433 void AAMPPlayer::doSetVolume(
float volume)
440 void AAMPPlayer::doSetZoom(
int zoom)
447 void AAMPPlayer::doSetNetworkBufferSize(int32_t networkBufferSize)
449 LOG_INFO(
"doSetNetworkBufferSize()");
452 void AAMPPlayer::doSetVideoBufferLength(
float videoBufferLength)
454 LOG_INFO(
"doSetVideoBufferLength()");
457 void AAMPPlayer::doSetEISSFilterStatus(
bool status)
459 LOG_INFO(
"doSetEISSFilterStatus()");
462 void AAMPPlayer::doSetIsInProgressRecording(
bool isInProgressRecording)
464 LOG_INFO(
"doSetIsInProgressRecording()");
467 void AAMPPlayer::getProgressData(
ProgressData* progressData)
469 *progressData = m_progressData;
474 void AAMPPlayer::onProgress(
const AAMPEvent & e)
476 m_progressData.position = e.data.progress.positionMiliseconds;
477 m_progressData.duration = e.data.progress.durationMiliseconds;
478 m_progressData.speed = e.data.progress.playbackSpeed;
479 m_progressData.start = e.data.progress.startMiliseconds;
480 m_progressData.end = e.data.progress.endMiliseconds;
492 LOG_INFO(
"setContentType(%s)", url.c_str());
497 if (strstr(url.c_str(),
".mp4"))
502 else if (strstr(url.c_str(),
".mp3"))
507 else if(url.find(
".m3u8") != std::string::npos || url.find(
".mpd") != std::string::npos)
511 if(url.find(
"cdvr") != std::string::npos)
516 else if(url.find(
"col") != std::string::npos)
521 else if(url.find(
"linear") != std::string::npos)
524 contentStr =
"ip-linear";
526 else if(url.find(
"ivod") != std::string::npos)
531 else if(url.find(
"ip-eas") != std::string::npos)
534 contentStr =
"ip-eas";
536 else if(url.find(
"xfinityhome") != std::string::npos)
539 contentStr =
"camera";
543 contentStr =
"unknown";
550 contentStr =
"unsupported";
553 LOG_INFO(
"contentID=%d", contentId);