Ignore pause and seek for live streaming.
diff --git a/android/playerdriver.cpp b/android/playerdriver.cpp
index 74d4c37..92c4d02 100644
--- a/android/playerdriver.cpp
+++ b/android/playerdriver.cpp
@@ -231,9 +231,10 @@
void handleGetPosition(PlayerGetPosition* command);
void handleGetDuration(PlayerGetDuration* command);
void handleGetStatus(PlayerGetStatus* command);
+ void handleCheckLiveStreaming(PlayerCheckLiveStreaming* cmd);
- void endOfData();
-
+ //void endOfData();
+ PVMFFormatType getFormatType();
void CommandCompleted(const PVCmdResponse& aResponse);
void HandleErrorEvent(const PVAsyncErrorEvent& aEvent);
void HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent);
@@ -244,6 +245,7 @@
void FinishSyncCommand(PlayerCommand* command);
void handleGetDurationComplete(PlayerGetDuration* cmd);
+ void handleCheckLiveStreamingComplete(PlayerCheckLiveStreaming* cmd);
int setupHttpStreamPre();
int setupHttpStreamPost();
@@ -277,6 +279,9 @@
PVPMetadataList mMetaKeyList;
Oscl_Vector<PvmiKvp,OsclMemAllocator> mMetaValueList;
int mNumMetaValues;
+ PVPMetadataList mCheckLiveKey;
+ Oscl_Vector<PvmiKvp,OsclMemAllocator> mCheckLiveValue;
+ int mCheckLiveMetaValues;
// Semaphore used for synchronous commands.
OsclSemaphore *mSyncSem;
@@ -295,7 +300,7 @@
int mRecentSeek;
bool mSeekComp;
bool mSeekPending;
-
+ bool mIsLiveStreaming;
bool mEmulation;
void* mLibHandle;
@@ -314,6 +319,7 @@
mRecentSeek(0),
mSeekComp(true),
mSeekPending(false),
+ mIsLiveStreaming(false),
mEmulation(false)
{
LOGV("constructor");
@@ -440,7 +446,7 @@
void PlayerDriver::FinishSyncCommand(PlayerCommand* command)
{
- command->complete(0, false);
+ command->complete(NO_ERROR, false);
delete command;
}
@@ -511,11 +517,26 @@
break;
case PlayerCommand::PLAYER_PAUSE:
- handlePause(static_cast<PlayerPause*>(command));
+ {
+ if(mIsLiveStreaming) {
+ LOGW("Pause denied");
+ FinishSyncCommand(command);
+ return;
+ }
+ handlePause(static_cast<PlayerPause*>(command));
+ }
break;
case PlayerCommand::PLAYER_SEEK:
- handleSeek(static_cast<PlayerSeek*>(command));
+ {
+ if(mIsLiveStreaming) {
+ LOGW("Seek denied");
+ mPvPlayer->sendEvent(MEDIA_SEEK_COMPLETE);
+ FinishSyncCommand(command);
+ return;
+ }
+ handleSeek(static_cast<PlayerSeek*>(command));
+ }
break;
case PlayerCommand::PLAYER_GET_POSITION:
@@ -528,6 +549,10 @@
FinishSyncCommand(command);
return;
+ case PlayerCommand::PLAYER_CHECK_LIVE_STREAMING:
+ handleCheckLiveStreaming(static_cast<PlayerCheckLiveStreaming*>(command));
+ break;
+
case PlayerCommand::PLAYER_GET_DURATION:
handleGetDuration(static_cast<PlayerGetDuration*>(command));
break;
@@ -569,14 +594,7 @@
}
LOGV("Command failed: %d", command->code());
- // FIXME: Ignore seek failure because it might not work when streaming
- if (mSeekPending) {
- LOGV("Ignoring failed seek");
- command->complete(NO_ERROR, false);
- mSeekPending = false;
- } else {
- command->complete(UNKNOWN_ERROR, false);
- }
+ command->complete(UNKNOWN_ERROR, false);
delete command;
}
@@ -916,6 +934,17 @@
}
}
+void PlayerDriver::handleCheckLiveStreaming(PlayerCheckLiveStreaming* command)
+{
+ LOGV("handleCheckLiveStreaming ...");
+ mCheckLiveKey.clear();
+ mCheckLiveKey.push_back(OSCL_HeapString<OsclMemAllocator>("pause-denied"));
+ mCheckLiveValue.clear();
+ int error = 0;
+ OSCL_TRY(error, mPlayer->GetMetadataValues(mCheckLiveKey, 0, 1, mCheckLiveMetaValues, mCheckLiveValue, command));
+ OSCL_FIRST_CATCH_ANY(error, commandFailed(command));
+}
+
void PlayerDriver::handleGetDuration(PlayerGetDuration* command)
{
command->set(-1);
@@ -996,6 +1025,11 @@
sched->StopScheduler();
}
+PVMFFormatType PlayerDriver::getFormatType()
+{
+ return mDataSource->GetDataSourceFormatType();
+}
+
/*static*/ int PlayerDriver::startPlayerThread(void *cookie)
{
LOGV("startPlayerThread");
@@ -1092,6 +1126,20 @@
ed->mSyncSem->Signal();
}
+void PlayerDriver::handleCheckLiveStreamingComplete(PlayerCheckLiveStreaming* cmd)
+{
+ if (mCheckLiveValue.empty())
+ return;
+
+ const char* substr = oscl_strstr((char*)(mCheckLiveValue[0].key), _STRLIT_CHAR("pause-denied;valtype=bool"));
+ if (substr!=NULL) {
+ if ( mCheckLiveValue[0].value.bool_value == true ) {
+ LOGI("Live Streaming ... \n");
+ mIsLiveStreaming = true;
+ }
+ }
+}
+
void PlayerDriver::handleGetDurationComplete(PlayerGetDuration* cmd)
{
cmd->set(-1);
@@ -1166,6 +1214,10 @@
handleGetDurationComplete(static_cast<PlayerGetDuration*>(command));
break;
+ case PlayerCommand::PLAYER_CHECK_LIVE_STREAMING:
+ handleCheckLiveStreamingComplete(static_cast<PlayerCheckLiveStreaming*>(command));
+ break;
+
case PlayerCommand::PLAYER_PAUSE:
LOGV("pause complete");
break;
@@ -1493,7 +1545,21 @@
// prepare
LOGV(" prepare");
- return mPlayerDriver->enqueueCommand(new PlayerPrepare(0,0));
+ return mPlayerDriver->enqueueCommand(new PlayerPrepare(check_for_live_streaming, this));
+
+
+}
+
+void PVPlayer::check_for_live_streaming(status_t s, void *cookie, bool cancelled)
+{
+ LOGV("check_for_live_streaming s=%d, cancelled=%d", s, cancelled);
+ if (s == NO_ERROR && !cancelled) {
+ PVPlayer *p = (PVPlayer*)cookie;
+ if ( (p->mPlayerDriver->getFormatType() == PVMF_MIME_DATA_SOURCE_RTSP_URL) ||
+ (p->mPlayerDriver->getFormatType() == PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL) ) {
+ p->mPlayerDriver->enqueueCommand(new PlayerCheckLiveStreaming( do_nothing, NULL));
+ }
+ }
}
void PVPlayer::run_init(status_t s, void *cookie, bool cancelled)
@@ -1533,7 +1599,7 @@
LOGV("run_prepare s=%d, cancelled=%d", s, cancelled);
if (s == NO_ERROR && !cancelled) {
PVPlayer *p = (PVPlayer*)cookie;
- p->mPlayerDriver->enqueueCommand(new PlayerPrepare(do_nothing,0));
+ p->mPlayerDriver->enqueueCommand(new PlayerPrepare(check_for_live_streaming, cookie));
}
}
@@ -1550,7 +1616,7 @@
} else { // If data source has been already set.
// No need to run a sequence of commands.
// The only code needed to run is PLAYER_PREPARE.
- ret = mPlayerDriver->enqueueCommand(new PlayerPrepare(do_nothing, NULL));
+ ret = mPlayerDriver->enqueueCommand(new PlayerPrepare(check_for_live_streaming, this));
}
return ret;
diff --git a/android/playerdriver.h b/android/playerdriver.h
index 7b4edd5..1fb3564 100644
--- a/android/playerdriver.h
+++ b/android/playerdriver.h
@@ -71,6 +71,7 @@
// TODO: clarify the scope of PLAYER_CANCEL_ALL_COMMANDS, does it work
// for asynchronous commands only or for synchronous as well?
PLAYER_CANCEL_ALL_COMMANDS = 18,
+ PLAYER_CHECK_LIVE_STREAMING = 19,
};
virtual ~PlayerCommand() {}
@@ -249,6 +250,15 @@
int* mMsec;
};
+class PlayerCheckLiveStreaming: public PlayerCommand
+{
+ public:
+ PlayerCheckLiveStreaming(media_completion_f cbf, void* cookie) :
+ PlayerCommand(PLAYER_CHECK_LIVE_STREAMING, cbf, cookie) {}
+ private:
+ PlayerCheckLiveStreaming();
+};
+
class PlayerGetStatus: public PlayerCommand
{
public: