Skip to content

Commit

Permalink
tv-casting-app: Disconnecting from previous video player before conne…
Browse files Browse the repository at this point in the history
…cting to the new one
  • Loading branch information
sharadb-amazon committed Jan 12, 2023
1 parent b4edebc commit e31ac73
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions examples/tv-casting-app/tv-casting-common/src/CastingServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,16 +289,17 @@ CHIP_ERROR CastingServer::VerifyOrEstablishConnection(TargetVideoPlayerInfo & ta
mOnConnectionFailureClientCallback = onConnectionFailure;
mOnNewOrUpdatedEndpoint = onNewOrUpdatedEndpoint;

chip::OperationalDeviceProxy * prevDeviceProxy =
CastingServer::GetInstance()->mActiveTargetVideoPlayerInfo.GetOperationalDeviceProxy();
if (prevDeviceProxy != nullptr)
{
ChipLogProgress(AppServer, "CastingServer::VerifyOrEstablishConnection Disconnecting previous deviceProxy");
prevDeviceProxy->Disconnect();
}

return targetVideoPlayerInfo.FindOrEstablishCASESession(
[](TargetVideoPlayerInfo * videoPlayer) {
ChipLogProgress(AppServer, "CastingServer::OnConnectionSuccess lambda called");
chip::OperationalDeviceProxy * prevDeviceProxy =
CastingServer::GetInstance()->mActiveTargetVideoPlayerInfo.GetOperationalDeviceProxy();
if (prevDeviceProxy != nullptr)
{
ChipLogProgress(AppServer, "CastingServer::OnConnectionSuccess lambda Disconnecting deviceProxy");
prevDeviceProxy->Disconnect();
}
CastingServer::GetInstance()->mActiveTargetVideoPlayerInfo = *videoPlayer;
CastingServer::GetInstance()->mOnConnectionSuccessClientCallback(videoPlayer);
},
Expand Down

0 comments on commit e31ac73

Please sign in to comment.