Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AampStreamSinkManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ void AampStreamSinkManager::SetActive(PrivateInstanceAAMP *aamp, double position
if(!aamp->IsTuneCompleted() && aamp->IsPlayEnabled() && (mPipelineMode == ePIPELINEMODE_SINGLE))
{
mGstPlayer->ResetFirstFrame();
mGstPlayer->ArmBufferingBeforePlay(aamp->rate);
}
}

Expand Down
7 changes: 7 additions & 0 deletions aampgstplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,13 @@ void AAMPGstPlayer::ResetFirstFrame(void)
{
playerInstance->ResetFirstFrame();
}
/**
* @brief Arm buffering before play
*/
void AAMPGstPlayer::ArmBufferingBeforePlay(int rate)
{
playerInstance->ArmBufferingBeforePlay(rate);
}

/**
* @brief Set video mute
Expand Down
4 changes: 4 additions & 0 deletions aampgstplayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ class AAMPGstPlayer : public StreamSink
* @fn ResetFirstFrame
*/
void ResetFirstFrame(void);
/**
* @fn ArmBufferingBeforePlay
*/
void ArmBufferingBeforePlay(int rate);
/**
* @fn SetVideoMute
* @param[in] muted true to mute video otherwise false
Expand Down
1 change: 1 addition & 0 deletions middleware/InterfacePlayerPriv.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ struct GstPlayerPriv
gboolean buffering_enabled; /**< enable buffering based on multiqueue */
gboolean buffering_in_progress; /**< buffering is in progress */
guint buffering_timeout_cnt; /**< make sure buffering_timeout doesn't get stuck */
bool armBufferingBeforePlayPending; /**< Set when ArmBufferingBeforePlay() is requested before the pipeline exists*/
GstState buffering_target_state; /**< the target state after buffering */
gint64 lastKnownPTS; /**< To store the PTS of last displayed video */
long long ptsUpdatedTimeMS; /**< Timestamp when PTS was last updated */
Expand Down
50 changes: 49 additions & 1 deletion middleware/InterfacePlayerRDK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ audioVolume(1.0), eosCallbackIdleTaskId(GST_TASK_ID_INVALID), eosCallbackIdleTas
firstFrameReceived(false), pendingPlayState(false), decoderHandleNotified(false),
firstFrameCallbackIdleTaskId(GST_TASK_ID_INVALID), firstFrameCallbackIdleTaskPending(false),
using_westerossink(false), usingRialtoSink(false), usingClosedCaptionsControl(false), pauseOnStartPlayback(false), eosSignalled(false),
buffering_enabled(FALSE), buffering_in_progress(FALSE), buffering_timeout_cnt(0),
buffering_enabled(FALSE), buffering_in_progress(FALSE), buffering_timeout_cnt(0), armBufferingBeforePlayPending(FALSE),
buffering_target_state(GST_STATE_NULL),
lastKnownPTS(0), ptsUpdatedTimeMS(0), ptsCheckForEosOnUnderflowIdleTaskId(GST_TASK_ID_INVALID),
numberOfVideoBuffersSent(0), segmentStart(0), positionQuery(NULL),
Expand Down Expand Up @@ -4020,6 +4020,15 @@ bool InterfacePlayerRDK::CreatePipeline(const char *pipelineName, int PipelinePr
interfacePlayerPriv->gstPrivateContext->buffering_timeout_cnt = DEFAULT_BUFFERING_MAX_CNT;
interfacePlayerPriv->gstPrivateContext->buffering_target_state = GST_STATE_NULL;
MW_LOG_MIL("%s buffering_enabled %u", GST_ELEMENT_NAME(interfacePlayerPriv->gstPrivateContext->pipeline), interfacePlayerPriv->gstPrivateContext->buffering_enabled);

/* A buffering-before-play arm was requested (from SetActive) before this pipeline existed. The pipeline is now created, so apply it here. */
if (interfacePlayerPriv->gstPrivateContext->armBufferingBeforePlayPending)
{
interfacePlayerPriv->gstPrivateContext->armBufferingBeforePlayPending = false;
ArmBufferingBeforePlay(GST_NORMAL_PLAY_RATE);
MW_LOG_MIL("Triggered ArmBufferingBeforePlay ");
}

if (interfacePlayerPriv->gstPrivateContext->positionQuery == NULL)
{

Expand Down Expand Up @@ -5373,3 +5382,42 @@ double InterfacePlayerRDK::FlushTrack(int mediaType, double pos, double audioDel

return rate;
}
/**
* @brief Arm buffering before play
* @param[in] rate - playback rate
*/
void InterfacePlayerRDK::ArmBufferingBeforePlay(int rate)
{
auto *ctx = interfacePlayerPriv->gstPrivateContext;
if (ctx->buffering_enabled && (GST_NORMAL_PLAY_RATE == rate) && !ctx->paused)
{
if (ctx->pipeline)
{
ctx->buffering_target_state = GST_STATE_PLAYING;
ctx->buffering_in_progress = true;
ctx->buffering_timeout_cnt = DEFAULT_BUFFERING_MAX_CNT;
ctx->pendingPlayState = false;
if (ctx->bufferingTimeoutTimerId == 0)
{
ctx->bufferingTimeoutTimerId =
g_timeout_add(DEFAULT_BUFFERING_TO_MS, buffering_timeout, this);
}
ctx->armBufferingBeforePlayPending = false;
MW_LOG_MIL("Re-armed buffering-before-play on reactivation");
}
else
{
/* Single-pipeline reactivation: AampStreamSinkManager::SetActive() calls this
* before the pipeline is (re)created in CreatePipeline(). Defer the arm so it
* is applied once the pipeline exists.
*/
ctx->armBufferingBeforePlayPending = true;
MW_LOG_MIL("Deferred buffering-before-play; pipeline not yet created");
}
}
else
{
if (ctx->buffering_enabled && (GST_NORMAL_PLAY_RATE == rate) && !ctx->paused)
MW_LOG_MIL("invalid buffer[%u]rate[%d]pause[%u]",ctx->buffering_enabled,rate,ctx->paused);
}
}
5 changes: 5 additions & 0 deletions middleware/InterfacePlayerRDK.h
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,11 @@ class InterfacePlayerRDK
* @return A pointer to the MonitorAVState structure containing the AV status or nullptr.
*/
const MonitorAVState& GetMonitorAVState();

/**
* @brief Arm buffering before play
*/
void ArmBufferingBeforePlay(int rate);

private:
InterfacePlayerPriv *interfacePlayerPriv;
Expand Down