Skip to content

Commit

Permalink
Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sharadb-amazon committed Dec 13, 2023
1 parent 048671d commit a544fdc
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,28 @@ namespace matter {
namespace casting {
namespace clusters {

CHIP_ERROR ContentLauncherCluster::LaunchURL(const char * contentUrl, const char * contentDisplayStr,
chip::Optional<chip::app::Clusters::ContentLauncher::Structs::BrandingInformationStruct::Type> brandingInformation)
CHIP_ERROR ContentLauncherCluster::LaunchURL(chip::app::Clusters::ContentLauncher::Commands::LaunchURL::Type request)
{
memory::Strong<core::Endpoint> endpoint = this->GetEndpoint().lock();

if(endpoint)
memory::Strong<core::Endpoint> endpoint = this->GetEndpoint().lock();
if (endpoint)
{
LaunchURLContext * interactionContext = new LaunchURLContext();
interactionContext->endpoint = this->GetEndpoint();
interactionContext->request = request;
endpoint->GetCastingPlayer()->FindOrEstablishSession(
nullptr,
interactionContext,
[](void * context, chip::Messaging::ExchangeManager & exchangeMgr, const chip::SessionHandle & sessionHandle) {
//support::MediaClusterBase cluster(exchangeMgr, sessionHandle, endpoint->GetId());
LaunchURLContext * _interactionContext = static_cast<LaunchURLContext *>(context);

support::MediaClusterBase cluster(exchangeMgr, sessionHandle, _interactionContext->endpoint.lock()->GetId());
},
[](void * context, const chip::ScopedNodeId & peerId, CHIP_ERROR error) {
ChipLogError(AppServer, "ContentLauncherCluster::LaunchURL failed");
});

}
else
{

}

return CHIP_NO_ERROR;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,20 @@ namespace matter {
namespace casting {
namespace clusters {

struct LaunchURLContext
{
memory::Weak<core::Endpoint> endpoint;
chip::app::Clusters::ContentLauncher::Commands::LaunchURL::Type request;
};

class ContentLauncherCluster : public core::BaseCluster
{
private:
protected:
public:
ContentLauncherCluster(memory::Weak<core::Endpoint> endpoint) : core::BaseCluster(endpoint) {}

CHIP_ERROR LaunchURL(const char * contentUrl, const char * contentDisplayStr,
chip::Optional<chip::app::Clusters::ContentLauncher::Structs::BrandingInformationStruct::Type> brandingInformation);
CHIP_ERROR LaunchURL(chip::app::Clusters::ContentLauncher::Commands::LaunchURL::Type request);
};

}; // namespace clusters
Expand Down
39 changes: 17 additions & 22 deletions examples/tv-casting-app/tv-casting-common/core/CastingPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@

#include "Endpoint.h"
#include "Types.h"
#include "clusters/ContentLauncherCluster.h"
#include "core/Cluster.h"
#include "support/ChipDeviceEventHandler.h"
#include "support/EndpointListLoader.h"

Expand Down Expand Up @@ -86,7 +84,6 @@ enum ConnectionState
class ConnectionContext;
class CastingPlayer;
using ConnectCallback = std::function<void(CHIP_ERROR, CastingPlayer *)>;
class BaseCluster;

/**
* @brief CastingPlayer represents a Matter commissioner that is able to play media to a physical
Expand Down Expand Up @@ -133,6 +130,23 @@ class CastingPlayer : public std::enable_shared_from_this<CastingPlayer>
unsigned long long int commissioningWindowTimeoutSec = kCommissioningWindowTimeoutSec,
EndpointFilter desiredEndpointFilter = EndpointFilter());

/**
* @brief Find an existing session for this CastingPlayer, or trigger a new session
* request.
*
* The caller can optionally provide `onDeviceConnected` and `onDeviceConnectionFailure` callback
* objects. If provided, these will be used to inform the caller about
* successful or failed connection establishment.
*
* If the connection is already established, the `onDeviceConnected` callback
* will be immediately called, before FindOrEstablishSession returns.
*
* The `onDeviceConnectionFailure` callback may be called before the FindOrEstablishSession
* call returns, for error cases that are detected synchronously.
*/
void FindOrEstablishSession(void * clientContext, chip::OnDeviceConnected onDeviceConnected,
chip::OnDeviceConnectionFailure onDeviceConnectionFailure);

/**
* @brief Register an endpoint on this CastingPlayer. If the provided endpoint was already registered, its information will be
* updated in the registry.
Expand Down Expand Up @@ -194,23 +208,6 @@ class CastingPlayer : public std::enable_shared_from_this<CastingPlayer>
chip::Inet::IPAddress * GetIpAddressForUDCRequest();
#endif // CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONER_DISCOVERY_CLIENT

/**
* @brief Find an existing session for this CastingPlayer, or trigger a new session
* request.
*
* The caller can optionally provide `onDeviceConnected` and `onDeviceConnectionFailure` callback
* objects. If provided, these will be used to inform the caller about
* successful or failed connection establishment.
*
* If the connection is already established, the `onDeviceConnected` callback
* will be immediately called, before FindOrEstablishSession returns.
*
* The `onDeviceConnectionFailure` callback may be called before the FindOrEstablishSession
* call returns, for error cases that are detected synchronously.
*/
void FindOrEstablishSession(void * clientContext, chip::OnDeviceConnected onDeviceConnected,
chip::OnDeviceConnectionFailure onDeviceConnectionFailure);

/**
* @brief Checks if the cachedCastingPlayer contains an Endpoint that matches the description of the desiredEndpointFilter
*
Expand All @@ -225,8 +222,6 @@ class CastingPlayer : public std::enable_shared_from_this<CastingPlayer>

friend class ConnectionContext;
friend class support::EndpointListLoader;
friend class BaseCluster;
friend class clusters::ContentLauncherCluster;
};

class ConnectionContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

#pragma once

#include "support/MediaClusterBase.h"
#include "core/Endpoint.h"
#include "core/Types.h"
#include "support/MediaClusterBase.h"

#include <app-common/zap-generated/cluster-objects.h>
#include <app/server/Server.h>
Expand All @@ -30,7 +30,7 @@ namespace matter {
namespace casting {

namespace core {
class EndpointAttributes;
class EndpointAttributes;
};

namespace support {
Expand Down

0 comments on commit a544fdc

Please sign in to comment.