Skip to content

Commit

Permalink
tv-casting-app: fix TargetVideoPlayerInfo mem corruption
Browse files Browse the repository at this point in the history
  • Loading branch information
sharadb-amazon committed Feb 2, 2024
1 parent 9483084 commit 0dbeb36
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,20 @@ public void discoverVideoPlayerCommissioners(
}

List<VideoPlayer> preCommissionedVideoPlayers = readCachedVideoPlayers();

if (preCommissionedVideoPlayers != null) {
for (VideoPlayer videoPlayer : preCommissionedVideoPlayers) {
Log.d(
TAG,
"preCommissionedVideoPlayer hostName: "
+ videoPlayer.getHostName()
+ " MACAddress: "
+ videoPlayer.getMACAddress()
+ " numIPs: "
+ videoPlayer.getNumIPs()
+ " IP Addresses: "
+ videoPlayer.getIpAddresses());
}
}
WifiManager wifiManager =
(WifiManager) applicationContext.getSystemService(Context.WIFI_SERVICE);
multicastLock = wifiManager.createMulticastLock("multicastLock");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ class CastingServer : public AppDelegate

static void VerifyOrEstablishConnectionTask(chip::System::Layer * aSystemLayer, void * context);
CHIP_ERROR ReadMACAddress(TargetEndpointInfo * endpoint);
int GetVideoPlayerIndex(TargetVideoPlayerInfo * targetVideoPlayerInfo);

/**
* @brief Retrieve the IP Address to use for the UDC request.
Expand Down
18 changes: 17 additions & 1 deletion examples/tv-casting-app/tv-casting-common/src/CastingServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,8 @@ CHIP_ERROR CastingServer::VerifyOrEstablishConnection(TargetVideoPlayerInfo & ta
prevDeviceProxy->Disconnect();
}

CastingServer::GetInstance()->mActiveTargetVideoPlayerInfo = targetVideoPlayerInfo;
int cacheIndex = GetVideoPlayerIndex(&targetVideoPlayerInfo);
CastingServer::GetInstance()->mActiveTargetVideoPlayerInfo = mCachedTargetVideoPlayerInfo[cacheIndex];
uint32_t delay = 0;
if (targetVideoPlayerInfo.IsAsleep())
{
Expand All @@ -511,6 +512,21 @@ CHIP_ERROR CastingServer::VerifyOrEstablishConnection(TargetVideoPlayerInfo & ta
nullptr);
}

int CastingServer::GetVideoPlayerIndex(TargetVideoPlayerInfo * targetVideoPlayerInfo)
{
if (targetVideoPlayerInfo != nullptr)
{
for (size_t i = 0; i < kMaxCachedVideoPlayers && mCachedTargetVideoPlayerInfo[i].IsInitialized(); i++)
{
if (mCachedTargetVideoPlayerInfo[i] == *targetVideoPlayerInfo)
{
return static_cast<int>(i);
}
}
}
return -1;
}

void CastingServer::VerifyOrEstablishConnectionTask(chip::System::Layer * aSystemLayer, void * context)
{
ChipLogProgress(AppServer, "CastingServer::VerifyOrEstablishConnectionTask called");
Expand Down

0 comments on commit 0dbeb36

Please sign in to comment.