fragmentcollector_mpd.cpp
/**
 * @brief Fragment downloader thread
 *
 * @param[in] arg Pointer to FragmentDownloadParams  object
 *
 * @retval NULL
 */
@brief Fragment downloader thread
@param[in] arg Pointer to FragmentDownloadParams  object

@retval NULL
@brief Fragment downloader thread @param [ in ] arg Pointer to FragmentDownloadParams object @retval NULL
void * FragmentDownloader(void *arg)
{
	struct FragmentDownloadParams* downloadParams = (struct FragmentDownloadParams*) arg;
	if(aamp_pthread_setname(pthread_self(), "aampFragDown"))
	{
		logprintf("%s:%d: aamp_pthread_setname failed\n", __FUNCTION__, __LINE__);
	}
	if (downloadParams->pMediaStreamContext->adaptationSet)
	{
		while (downloadParams->context->aamp->DownloadsAreEnabled() && !downloadParams->pMediaStreamContext->profileChanged)
		{
			int timeoutMs = downloadParams->context->GetMinUpdateDuration() - (int)(aamp_GetCurrentTimeMS() - downloadParams->lastPlaylistUpdateMS);
			if(downloadParams->pMediaStreamContext->WaitForFreeFragmentAvailable(timeoutMs))
			{
				downloadParams->context->PushNextFragment(downloadParams->pMediaStreamContext, 1);
				if (downloadParams->pMediaStreamContext->eos)
				{
					if(!downloadParams->context->aamp->IsLive() && downloadParams->playingLastPeriod)
					{
						downloadParams->pMediaStreamContext->eosReached = true;
						downloadParams->pMediaStreamContext->AbortWaitForCachedFragment(false);
					}
					AAMPLOG_INFO("%s:%d %s EOS - Exit fetch loop\n", __FUNCTION__, __LINE__, downloadParams->pMediaStreamContext->name);
					break;
				}
				if (downloadParams->pMediaStreamContext->endTimeReached)
				{
					AAMPLOG_INFO("%s:%d - endTimeReached\n", __FUNCTION__, __LINE__);
					downloadParams->context->aamp->EndTimeReached(eMEDIATYPE_AUDIO);
					break;
				}
			}
			timeoutMs = downloadParams->context->GetMinUpdateDuration() - (int)(aamp_GetCurrentTimeMS() - downloadParams->lastPlaylistUpdateMS);
			if(timeoutMs <= 0 && downloadParams->context->aamp->IsLive())
			{
				break;
			}
		}
	}
	else
	{
		logprintf("%s:%d NULL adaptationSet\n", __FUNCTION__, __LINE__);
	}
	return NULL;
}
void * FragmentDownloader ( void * arg ) { struct FragmentDownloadParams * downloadParams = ( struct FragmentDownloadParams * ) arg ; if ( aamp_pthread_setname ( pthread_self ( ) , " " ) ) { logprintf ( " \n " , __FUNCTION__ , __LINE__ ) ; } if ( downloadParams -> pMediaStreamContext -> adaptationSet ) { while ( downloadParams -> context -> aamp -> DownloadsAreEnabled ( ) && ! downloadParams -> pMediaStreamContext -> profileChanged ) { int timeoutMs = downloadParams -> context -> GetMinUpdateDuration ( ) - ( int ) ( aamp_GetCurrentTimeMS ( ) - downloadParams -> lastPlaylistUpdateMS ) ; if ( downloadParams -> pMediaStreamContext -> WaitForFreeFragmentAvailable ( timeoutMs ) ) { downloadParams -> context -> PushNextFragment ( downloadParams -> pMediaStreamContext , 1 ) ; if ( downloadParams -> pMediaStreamContext -> eos ) { if ( ! downloadParams -> context -> aamp -> IsLive ( ) && downloadParams -> playingLastPeriod ) { downloadParams -> pMediaStreamContext -> eosReached = true ; downloadParams -> pMediaStreamContext -> AbortWaitForCachedFragment ( false ) ; } AAMPLOG_INFO ( " \n " , __FUNCTION__ , __LINE__ , downloadParams -> pMediaStreamContext -> name ) ; break ; } if ( downloadParams -> pMediaStreamContext -> endTimeReached ) { AAMPLOG_INFO ( " \n " , __FUNCTION__ , __LINE__ ) ; downloadParams -> context -> aamp -> EndTimeReached ( eMEDIATYPE_AUDIO ) ; break ; } } timeoutMs = downloadParams -> context -> GetMinUpdateDuration ( ) - ( int ) ( aamp_GetCurrentTimeMS ( ) - downloadParams -> lastPlaylistUpdateMS ) ; if ( timeoutMs <= 0 && downloadParams -> context -> aamp -> IsLive ( ) ) { break ; } } } else { logprintf ( " \n " , __FUNCTION__ , __LINE__ ) ; } return NULL ; }
@brief Fragment downloader thread
 @param[in] arg Pointer to FragmentDownloadParams  object
@brief Fragment downloader thread @param [ in ] arg Pointer to FragmentDownloadParams object