drm/aes/aamp_aes.cpp
/**
 * @brief Set information required for decryption
 *
 * @param[in] aamp AAMP instance to be associated with this decryptor
 * @param[in] drmInfo Drm information
 *
 * @retval eDRM_SUCCESS on success
 */
@brief Set information required for decryption
@param[in] aamp AAMP instance to be associated with this decryptor
@param[in] drmInfo Drm information

@retval eDRM_SUCCESS on success
@brief Set information required for decryption @param [ in ] aamp AAMP instance to be associated with this decryptor @param [ in ] drmInfo Drm information @retval eDRM_SUCCESS on success
DrmReturn AesDec::SetDecryptInfo( PrivateInstanceAAMP *aamp, const struct DrmInfo *drmInfo)
{
	DrmReturn err = eDRM_ERROR;
	pthread_mutex_lock(&mMutex);
	if (mDrmState == eDRM_ACQUIRING_KEY )
	{
		logprintf("AesDec::%s:%d acquiring key in progress\n",__FUNCTION__, __LINE__);
		WaitForKeyAcquireCompleteUnlocked(20*1000, err);
	}
	mpAamp = aamp;
	mDrmInfo = *drmInfo;
	if (mDrmUrl)
	{
		if ((eDRM_KEY_ACQUIRED == mDrmState) && (0 == strcmp(mDrmUrl, drmInfo->uri)))
		{
			logprintf("AesDec::%s:%d same url:%s - not acquiring key\n",__FUNCTION__, __LINE__, mDrmUrl);
			pthread_mutex_unlock(&mMutex);
			return eDRM_SUCCESS;
		}
		free(mDrmUrl);
	}
	mDrmUrl = strdup(drmInfo->uri);
	mDrmState = eDRM_ACQUIRING_KEY;
	if (-1 == mCurlInstance)
	{
		mCurlInstance = AAMP_TRACK_COUNT;
		aamp->CurlInit(mCurlInstance, 1);
	}
	if (licenseAcquisitionThreadStarted)
	{
		int ret = pthread_join(licenseAcquisitionThreadId, NULL);
		if (ret != 0)
		{
			logprintf("AesDec::%s:%d pthread_join failed for license acquisition thread: %d\n", __FUNCTION__, __LINE__, licenseAcquisitionThreadId);
		}
		licenseAcquisitionThreadStarted = false;
	}
	int ret = pthread_create(&licenseAcquisitionThreadId, NULL, acquire_key, this);
	if(ret != 0)
	{
		logprintf("AesDec::%s:%d pthread_create failed for acquire_key with errno = %d, %s\n", __FUNCTION__, __LINE__, errno, strerror(errno));
		mDrmState = eDRM_KEY_FAILED;
		licenseAcquisitionThreadStarted = false;
	}
	else
	{
		err = eDRM_SUCCESS;
		licenseAcquisitionThreadStarted = true;
	}
	pthread_mutex_unlock(&mMutex);
	AAMPLOG_INFO("AesDec::%s:%d drmState:%d \n",__FUNCTION__, __LINE__, mDrmState);
	return err;
}
DrmReturn AesDec :: SetDecryptInfo ( PrivateInstanceAAMP * aamp , const struct DrmInfo * drmInfo ) { DrmReturn err = eDRM_ERROR ; pthread_mutex_lock ( & mMutex ) ; if ( mDrmState == eDRM_ACQUIRING_KEY ) { logprintf ( " \n " , __FUNCTION__ , __LINE__ ) ; WaitForKeyAcquireCompleteUnlocked ( 20 * 1000 , err ) ; } mpAamp = aamp ; mDrmInfo = * drmInfo ; if ( mDrmUrl ) { if ( ( eDRM_KEY_ACQUIRED == mDrmState ) && ( 0 == strcmp ( mDrmUrl , drmInfo -> uri ) ) ) { logprintf ( " \n " , __FUNCTION__ , __LINE__ , mDrmUrl ) ; pthread_mutex_unlock ( & mMutex ) ; return eDRM_SUCCESS ; } free ( mDrmUrl ) ; } mDrmUrl = strdup ( drmInfo -> uri ) ; mDrmState = eDRM_ACQUIRING_KEY ; if ( -1 == mCurlInstance ) { mCurlInstance = AAMP_TRACK_COUNT ; aamp -> CurlInit ( mCurlInstance , 1 ) ; } if ( licenseAcquisitionThreadStarted ) { int ret = pthread_join ( licenseAcquisitionThreadId , NULL ) ; if ( ret != 0 ) { logprintf ( " \n " , __FUNCTION__ , __LINE__ , licenseAcquisitionThreadId ) ; } licenseAcquisitionThreadStarted = false ; } int ret = pthread_create ( & licenseAcquisitionThreadId , NULL , acquire_key , this ) ; if ( ret != 0 ) { logprintf ( " \n " , __FUNCTION__ , __LINE__ , errno , strerror ( errno ) ) ; mDrmState = eDRM_KEY_FAILED ; licenseAcquisitionThreadStarted = false ; } else { err = eDRM_SUCCESS ; licenseAcquisitionThreadStarted = true ; } pthread_mutex_unlock ( & mMutex ) ; AAMPLOG_INFO ( " \n " , __FUNCTION__ , __LINE__ , mDrmState ) ; return err ; }
@brief Set information required for decryption
 @param[in] aamp AAMP instance to be associated with this decryptor
 @param[in] drmInfo Drm information
@brief Set information required for decryption @param [ in ] aamp AAMP instance to be associated with this decryptor @param [ in ] drmInfo Drm information