Skip to content

Commit

Permalink
Merge pull request #680 from MartinMueller2003/main
Browse files Browse the repository at this point in the history
Remote play updates
  • Loading branch information
forkineye authored Oct 31, 2023
2 parents 43f361d + 5d88be1 commit 973b06f
Show file tree
Hide file tree
Showing 18 changed files with 175 additions and 122 deletions.
12 changes: 5 additions & 7 deletions ESPixelStick/src/WebMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -622,24 +622,22 @@ void c_WebMgr::ProcessXJRequest (AsyncWebServerRequest* client)
system[F ("SDinstalled")] = FileMgr.SdCardIsInstalled ();
system[F ("DiscardedRxData")] = DiscardedRxData;

// DEBUG_V ("");

// Ask WiFi Stats
// DEBUG_V ("NetworkMgr.GetStatus");
NetworkMgr.GetStatus (system);
// DEBUG_V ("");

// DEBUG_V ("FPPDiscovery.GetStatus");
FPPDiscovery.GetStatus (system);
// DEBUG_V ("");

// DEBUG_V ("InputMgr.GetStatus");
// Ask Input Stats
InputMgr.GetStatus (status);
// DEBUG_V ("");

// Ask Output Stats
// DEBUG_V ("OutputMgr.GetStatus");
OutputMgr.GetStatus (status);
// DEBUG_V ("");

// Get File Manager Stats
// DEBUG_V ("FileMgr.GetStatus");
FileMgr.GetStatus (system);
// DEBUG_V ("");

Expand Down
46 changes: 37 additions & 9 deletions ESPixelStick/src/input/InputFPPRemote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,13 @@ void c_InputFPPRemote::Process ()
}
else if (PlayingRemoteFile ())
{
// DEBUG_V ("PlayingRemoteFile");
FPPDiscovery.ReadNextFrame ();
// DEBUG_V ("Remote File Play");
while(Poll ()) {}
}
else if (PlayingFile ())
{
// DEBUG_V ("Local File Play");
pInputFPPRemotePlayItem->Poll ();
while(Poll ()) {}

if (pInputFPPRemotePlayItem->IsIdle ())
{
Expand All @@ -216,6 +216,21 @@ void c_InputFPPRemote::Process ()

} // process

//-----------------------------------------------------------------------------
bool c_InputFPPRemote::Poll ()
{
// DEBUG_START;
bool Response = false;
if(pInputFPPRemotePlayItem)
{
Response = pInputFPPRemotePlayItem->Poll ();
}

// DEBUG_END;
return Response;

} // Poll

//-----------------------------------------------------------------------------
void c_InputFPPRemote::ProcessButtonActions(c_ExternalInput::InputValue_t value)
{
Expand Down Expand Up @@ -291,6 +306,7 @@ void c_InputFPPRemote::StopPlaying ()

if(PlayingFile())
{
// DEBUG_V(String("pInputFPPRemotePlayItem: ") = String(uint32_t(pInputFPPRemotePlayItem), HEX));
pInputFPPRemotePlayItem->Stop ();

while (!pInputFPPRemotePlayItem->IsIdle ())
Expand All @@ -302,9 +318,6 @@ void c_InputFPPRemote::StopPlaying ()
delete pInputFPPRemotePlayItem;
pInputFPPRemotePlayItem = nullptr;
}

FileBeingPlayed = "";

} while (false);

// DEBUG_END;
Expand All @@ -320,14 +333,14 @@ void c_InputFPPRemote::StartPlaying (String& FileName)
{
// DEBUG_V (String ("FileName: '") + FileName + "'");
if ((0 == FileName.length ()) ||
(FileName == String ("null")))
(FileName.equals("null")))
{
// DEBUG_V ("No file to play");
StopPlaying ();
break;
}

if (FileName == No_LocalFileToPlay)
if (FileName.equals(No_LocalFileToPlay))
{
StartPlayingRemoteFile (FileName);
}
Expand Down Expand Up @@ -358,6 +371,11 @@ void c_InputFPPRemote::StartPlayingLocalFile (String& FileName)
if (String(CN_Dotpl) == Last_pl_Text)
{
// DEBUG_V ("Start Playlist");
if(pInputFPPRemotePlayItem)
{
delete pInputFPPRemotePlayItem;
pInputFPPRemotePlayItem = nullptr;
}
pInputFPPRemotePlayItem = new c_InputFPPRemotePlayList (GetInputChannelId ());
StatusType = F ("PlayList");
}
Expand All @@ -373,6 +391,11 @@ void c_InputFPPRemote::StartPlayingLocalFile (String& FileName)
break;
}

if(pInputFPPRemotePlayItem)
{
delete pInputFPPRemotePlayItem;
pInputFPPRemotePlayItem = nullptr;
}
// DEBUG_V ("Start Local FSEQ file player");
pInputFPPRemotePlayItem = new c_InputFPPRemotePlayFile (GetInputChannelId ());
StatusType = CN_File;
Expand Down Expand Up @@ -407,6 +430,11 @@ void c_InputFPPRemote::StartPlayingRemoteFile (String& FileName)
StopPlaying ();

// DEBUG_V ("Instantiate an FSEQ file player");
if(pInputFPPRemotePlayItem)
{
delete pInputFPPRemotePlayItem;
pInputFPPRemotePlayItem = nullptr;
}
pInputFPPRemotePlayItem = new c_InputFPPRemotePlayFile (GetInputChannelId ());
pInputFPPRemotePlayItem->SetSyncOffsetMS (SyncOffsetMS);
pInputFPPRemotePlayItem->SetSendFppSync (SendFppSync);
Expand Down Expand Up @@ -466,7 +494,7 @@ bool c_InputFPPRemote::PlayingRemoteFile ()
break;
}

if (FileBeingPlayed != No_LocalFileToPlay)
if (!FileBeingPlayed.equals(No_LocalFileToPlay))
{
break;
}
Expand Down
3 changes: 2 additions & 1 deletion ESPixelStick/src/input/InputFPPRemote.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,14 @@ class c_InputFPPRemote : public c_InputCommon
bool PlayingFile ();
bool PlayingRemoteFile ();
void PlayNextFile ();
bool Poll ();

void load (); ///< Load configuration from File System
void save (); ///< Save configuration to File System

int32_t SyncOffsetMS = 0;
bool SendFppSync = false;
String FileBeingPlayed;
String FileBeingPlayed = No_LocalFileToPlay;

# define JSON_NAME_FILE_TO_PLAY CN_fseqfilename

Expand Down
4 changes: 2 additions & 2 deletions ESPixelStick/src/input/InputFPPRemotePlayEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ void c_InputFPPRemotePlayEffect::Sync (String& FileName, float SecondsElapsed)
} // Sync

//-----------------------------------------------------------------------------
void c_InputFPPRemotePlayEffect::Poll ()
bool c_InputFPPRemotePlayEffect::Poll ()
{
// DEBUG_START;

pCurrentFsmState->Poll ();
return pCurrentFsmState->Poll ();

// DEBUG_END;

Expand Down
2 changes: 1 addition & 1 deletion ESPixelStick/src/input/InputFPPRemotePlayEffect.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class c_InputFPPRemotePlayEffect : public c_InputFPPRemotePlayItem
virtual void Start (String & FileName, float duration, uint32_t PlayCount);
virtual void Stop ();
virtual void Sync (String & FileName, float SecondsElapsed);
virtual void Poll ();
virtual bool Poll ();
virtual void GetStatus (JsonObject & jsonStatus);
virtual bool IsIdle () { return (pCurrentFsmState == &fsm_PlayEffect_state_Idle_imp); }

Expand Down
8 changes: 5 additions & 3 deletions ESPixelStick/src/input/InputFPPRemotePlayEffectFsm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@
#include "../utility/SaferStringConversion.hpp"

//-----------------------------------------------------------------------------
void fsm_PlayEffect_state_Idle::Poll ()
bool fsm_PlayEffect_state_Idle::Poll ()
{
// DEBUG_START;

// do nothing

// DEBUG_END;

return false;

} // fsm_PlayEffect_state_Idle::Poll

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -117,7 +118,7 @@ void fsm_PlayEffect_state_Idle::GetStatus (JsonObject& jsonStatus)
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void fsm_PlayEffect_state_PlayingEffect::Poll ()
bool fsm_PlayEffect_state_PlayingEffect::Poll ()
{
// DEBUG_START;

Expand All @@ -131,6 +132,7 @@ void fsm_PlayEffect_state_PlayingEffect::Poll ()
}

// DEBUG_END;
return false;

} // fsm_PlayEffect_state_PlayingEffect::Poll

Expand Down
6 changes: 3 additions & 3 deletions ESPixelStick/src/input/InputFPPRemotePlayEffectFsm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class fsm_PlayEffect_state
fsm_PlayEffect_state() {}
virtual ~fsm_PlayEffect_state() {}

virtual void Poll () = 0;
virtual bool Poll () = 0;
virtual void Init (c_InputFPPRemotePlayEffect * Parent) = 0;
virtual void GetStateName (String & sName) = 0;
virtual void Start (String & FileName, float SecondsElapsed) = 0;
Expand All @@ -56,7 +56,7 @@ class fsm_PlayEffect_state_Idle : public fsm_PlayEffect_state
fsm_PlayEffect_state_Idle() {}
virtual ~fsm_PlayEffect_state_Idle() {}

virtual void Poll ();
virtual bool Poll ();
virtual void Init (c_InputFPPRemotePlayEffect* Parent);
virtual void GetStateName (String & sName) { sName = CN_Idle; }
virtual void Start (String & FileName, float SecondsElapsed);
Expand All @@ -73,7 +73,7 @@ class fsm_PlayEffect_state_PlayingEffect : public fsm_PlayEffect_state
fsm_PlayEffect_state_PlayingEffect() {}
virtual ~fsm_PlayEffect_state_PlayingEffect() {}

virtual void Poll ();
virtual bool Poll ();
virtual void Init (c_InputFPPRemotePlayEffect* Parent);
virtual void GetStateName (String & sName) { sName = CN_Effect; }
virtual void Start (String & FileName, float SecondsElapsed);
Expand Down
15 changes: 5 additions & 10 deletions ESPixelStick/src/input/InputFPPRemotePlayFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,7 @@ void c_InputFPPRemotePlayFile::Stop ()
{
// DEBUG_START;

while (pCurrentFsmState != &fsm_PlayFile_state_Idle_imp)
{
pCurrentFsmState->Stop ();
pCurrentFsmState->Poll ();
pCurrentFsmState->TimerPoll ();
}
pCurrentFsmState->Stop ();

// DEBUG_END;
} // Stop
Expand All @@ -148,16 +143,16 @@ void c_InputFPPRemotePlayFile::Sync (String & FileName, float SecondsElapsed)
} // Sync

//-----------------------------------------------------------------------------
void c_InputFPPRemotePlayFile::Poll ()
bool c_InputFPPRemotePlayFile::Poll ()
{
// xDEBUG_START;

// TimerPoll ();
pCurrentFsmState->Poll ();

// Show that we have received a poll
PollDetectionCounter = 0;

// TimerPoll ();
return pCurrentFsmState->Poll ();

// xDEBUG_END;

} // Poll
Expand Down
2 changes: 1 addition & 1 deletion ESPixelStick/src/input/InputFPPRemotePlayFile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class c_InputFPPRemotePlayFile : public c_InputFPPRemotePlayItem
virtual void Start (String & FileName, float SecondsElapsed, uint32_t RemainingPlayCount);
virtual void Stop ();
virtual void Sync (String& FileName, float SecondsElapsed);
virtual void Poll ();
virtual bool Poll ();
virtual void GetStatus (JsonObject & jsonStatus);
virtual bool IsIdle () { return (pCurrentFsmState == &fsm_PlayFile_state_Idle_imp); }

Expand Down
Loading

0 comments on commit 973b06f

Please sign in to comment.