@@ -102,7 +102,6 @@ static void InitializePlayerConfigs(AAMPGstPlayer *_this, void *playerInstance)
102102 interfacePlayer->m_gstConfigParam ->audioOnlyMode = _this->aamp ->mAudioOnlyPb ;
103103 interfacePlayer->m_gstConfigParam ->gstreamerSubsEnabled = _this->aamp ->IsGstreamerSubsEnabled ();
104104 interfacePlayer->m_gstConfigParam ->media = _this->aamp ->GetMediaFormatTypeEnum ();
105- interfacePlayer->m_gstConfigParam ->useMp4Demux = config->IsConfigSet (eAAMPConfig_UseMp4Demux);
106105}
107106
108107/*
@@ -679,7 +678,7 @@ void AAMPGstPlayer::NotifyInjectorToResume()
679678/* *
680679 * @brief Inject stream buffer to gstreamer pipeline
681680 */
682- bool AAMPGstPlayer::SendHelper (AampMediaType mediaType, const void *ptr, size_t len, double fpts, double fdts, double fDuration , bool copy, double fragmentPTSoffset , bool initFragment, bool discontinuity)
681+ bool AAMPGstPlayer::SendHelper (AampMediaType mediaType, MediaSample sample, bool copy, bool initFragment, bool discontinuity)
683682{
684683 if (ISCONFIGSET (eAAMPConfig_SuppressDecode))
685684 {
@@ -707,10 +706,10 @@ bool AAMPGstPlayer::SendHelper(AampMediaType mediaType, const void *ptr, size_t
707706 namespace aih = aamp::id3_metadata::helpers;
708707
709708 if (aih::IsValidMediaType (mediaType) &&
710- aih::IsValidHeader (static_cast <const uint8_t *>(ptr ), len ))
709+ aih::IsValidHeader (static_cast <const uint8_t *>(sample. data ), sample. dataSize ))
711710 {
712- m_ID3MetadataHandler (mediaType, static_cast <const uint8_t *>(ptr ), len ,
713- {fpts, fdts, fDuration }, nullptr );
711+ m_ID3MetadataHandler (mediaType, static_cast <const uint8_t *>(sample. data ), sample. dataSize ,
712+ {sample. pts , sample. dts , sample. duration }, nullptr );
714713 }
715714 }
716715
@@ -723,7 +722,7 @@ bool AAMPGstPlayer::SendHelper(AampMediaType mediaType, const void *ptr, size_t
723722 {
724723 sendNewSegmentEvent = true ;
725724 }
726- bool bPushBuffer = playerInstance->SendHelper (mediaType, ptr, len, fpts, fdts, fDuration , fragmentPTSoffset , copy, initFragment, discontinuity, notifyFirstBufferProcessed, sendNewSegmentEvent, resetTrickUTC, firstBufferPushed);
725+ bool bPushBuffer = playerInstance->SendHelper (mediaType, std::move (sample) , copy, initFragment, discontinuity, notifyFirstBufferProcessed, sendNewSegmentEvent, resetTrickUTC, firstBufferPushed);
727726 if (sendNewSegmentEvent)
728727 {
729728 aamp->mbNewSegmentEvtSent [mediaType] = true ;
@@ -734,7 +733,8 @@ bool AAMPGstPlayer::SendHelper(AampMediaType mediaType, const void *ptr, size_t
734733 }
735734 if (bPushBuffer)
736735 {
737- privateContext->mBufferControl [mediaType].notifyFragmentInject (this , mediaType, fpts, fdts, fDuration , discontinuity);
736+ // TODO: Accessing values from a moved object
737+ privateContext->mBufferControl [mediaType].notifyFragmentInject (this , mediaType, sample.pts , sample.dts , sample.duration , discontinuity);
738738 }
739739 if (eMEDIATYPE_VIDEO == mediaType)
740740 {
@@ -763,15 +763,29 @@ bool AAMPGstPlayer::SendHelper(AampMediaType mediaType, const void *ptr, size_t
763763 */
764764bool AAMPGstPlayer::SendCopy (AampMediaType mediaType, const void *ptr, size_t len, double fpts, double fdts, double fDuration )
765765{
766- return SendHelper ( mediaType, ptr, len, fpts, fdts, fDuration , true /* copy*/ , 0.0 );
766+ MediaSample sample;
767+ sample.data = ptr;
768+ sample.dataSize = len;
769+ sample.pts = fpts;
770+ sample.dts = fdts;
771+ sample.duration = fDuration ;
772+ sample.ptsOffset = 0.0 ;
773+ return SendHelper ( mediaType, std::move (sample), true /* copy*/ );
767774}
768775
769776/* *
770777 * @brief inject mp4 segment to gstreamer pipeline
771778 */
772779bool AAMPGstPlayer::SendTransfer (AampMediaType mediaType, void *ptr, size_t len, double fpts, double fdts, double fDuration , double fragmentPTSoffset, bool initFragment, bool discontinuity)
773780{
774- return SendHelper ( mediaType, ptr, len, fpts, fdts, fDuration , false /* transfer*/ , fragmentPTSoffset, initFragment, discontinuity );
781+ MediaSample sample;
782+ sample.data = ptr;
783+ sample.dataSize = len;
784+ sample.pts = fpts;
785+ sample.dts = fdts;
786+ sample.duration = fDuration ;
787+ sample.ptsOffset = fragmentPTSoffset;
788+ return SendHelper ( mediaType, std::move (sample), false /* transfer*/ , initFragment, discontinuity );
775789}
776790
777791/* *
@@ -1312,3 +1326,63 @@ void AAMPGstPlayer::StopMonitorAvTimer()
13121326 AAMPLOG_MIL (" MonitorAvTimer stopped" );
13131327 }
13141328}
1329+
1330+ void AAMPGstPlayer::SetStreamCaps (AampMediaType type, const AampCodecInfo &codecInfo)
1331+ {
1332+ CodecInfo gstCodecInfo;
1333+ gstCodecInfo.codecFormat = (GstStreamOutputFormat)codecInfo.mCodecFormat ;
1334+ gstCodecInfo.codecData = std::move (codecInfo.mCodecData );
1335+ gstCodecInfo.isEncrypted = codecInfo.mIsEncrypted ;
1336+ if (codecInfo.mType == eMEDIATYPE_VIDEO)
1337+ {
1338+ gstCodecInfo.info .video .width = codecInfo.mInfo .video .mWidth ;
1339+ gstCodecInfo.info .video .height = codecInfo.mInfo .video .mHeight ;
1340+ }
1341+ else if (codecInfo.mType == eMEDIATYPE_AUDIO)
1342+ {
1343+ gstCodecInfo.info .audio .channelCount = codecInfo.mInfo .audio .mChannelCount ;
1344+ gstCodecInfo.info .audio .sampleRate = codecInfo.mInfo .audio .mSampleRate ;
1345+ }
1346+ playerInstance->SetStreamCaps ((GstMediaType)type, gstCodecInfo);
1347+ }
1348+
1349+ bool AAMPGstPlayer::SendSample (AampMediaType mediaType, AampMediaSample& sample)
1350+ {
1351+ bool ret = false ;
1352+ MediaSample gstSample;
1353+
1354+ // Convert AampMediaSample to MediaSample
1355+ gstSample.data = sample.mData .GetPtr ();
1356+ gstSample.dataSize = sample.mData .GetLen ();
1357+ gstSample.pts = static_cast <double >(sample.mPts );
1358+ gstSample.dts = static_cast <double >(sample.mDts );
1359+ gstSample.duration = static_cast <double >(sample.mDuration );
1360+ // Sample is encrypted, set the DRM metadata
1361+ if (sample.mDrmMetadata .mIsEncrypted )
1362+ {
1363+ gstSample.drmMetadata .isEncrypted = true ;
1364+ gstSample.drmMetadata .subSamples = std::move (sample.mDrmMetadata .mSubSamples );
1365+ gstSample.drmMetadata .keyId = std::move (sample.mDrmMetadata .mKeyId );
1366+ gstSample.drmMetadata .iv = std::move (sample.mDrmMetadata .mIV );
1367+ gstSample.drmMetadata .cipher = std::move (sample.mDrmMetadata .mCipher );
1368+ gstSample.drmMetadata .cryptByteBlock = sample.mDrmMetadata .mCryptByteBlock ;
1369+ gstSample.drmMetadata .skipByteBlock = sample.mDrmMetadata .mSkipByteBlock ;
1370+ gstSample.drmMetadata .originalMediaType = std::move (sample.mDrmMetadata .mOriginalMediaType );
1371+ }
1372+ else
1373+ {
1374+ gstSample.drmMetadata .isEncrypted = false ;
1375+ }
1376+
1377+ ret = SendHelper ( mediaType, std::move (gstSample), false /* transfer*/ );
1378+
1379+ if (ret)
1380+ {
1381+ sample.mData .Transfer ();
1382+ }
1383+ else
1384+ {
1385+ sample.mData .Free ();
1386+ }
1387+ return ret;
1388+ }
0 commit comments