Skip to content

Commit aad708c

Browse files
Build fixes
1 parent 70be782 commit aad708c

File tree

9 files changed

+165
-28
lines changed

9 files changed

+165
-28
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright (c) 2022 Project CHIP Authors
3+
* All rights reserved.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
package com.chip.casting;
19+
20+
public class ContentApp
21+
{
22+
private short endpointId;
23+
private List<Integer> clusterIds;
24+
25+
private boolean isInitialized = false;
26+
27+
public ContentApp(short endpointId, List<Integer> clusterIds) {
28+
this.endpointId = endpointId;
29+
this.clusterIds = clusterIds;
30+
this.isInitialized = true;
31+
}
32+
33+
public short getEndpointId() {
34+
return endpointId;
35+
}
36+
37+
public List<Integer> getClusterIds() {
38+
return clusterIds;
39+
}
40+
41+
public boolean isInitialized() {
42+
return isInitialized;
43+
}
44+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/*
2+
* Copyright (c) 2022 Project CHIP Authors
3+
* All rights reserved.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
package com.chip.casting;
19+
20+
public class VideoPlayer
21+
{
22+
private long nodeId;
23+
private byte fabricIndex;
24+
private String deviceName;
25+
private short vendorId;
26+
private short productId;
27+
private short deviceType;
28+
private List<ContentApp> contentApps;
29+
private boolean isConnected = false;
30+
31+
private boolean isInitialized = false;
32+
33+
public VideoPlayer(long nodeId, byte fabricIndex, String deviceName, short vendorId, short productId, short deviceType, List<ContentApp> contentApps, boolean isConnected) {
34+
this.nodeId = nodeId;
35+
this.fabricIndex = fabricIndex;
36+
this.deviceName = deviceName;
37+
this.vendorId = vendorId;
38+
this.productId = productId;
39+
this.deviceType = deviceType;
40+
this.contentApps = contentApps;
41+
this.isConnected = isConnected;
42+
this.isInitialized = true;
43+
}
44+
45+
public boolean equals(Object object) {
46+
if (this == object) return true;
47+
if (object == null || getClass() != object.getClass()) return false;
48+
if (!super.equals(object)) return false;
49+
VideoPlayer that = (VideoPlayer) object;
50+
return nodeId == that.nodeId && fabricIndex == that.fabricIndex;
51+
}
52+
53+
public int hashCode() {
54+
return Objects.hash(super.hashCode(), nodeId, fabricIndex);
55+
}
56+
57+
public long getNodeId() {
58+
return nodeId;
59+
}
60+
61+
public byte getFabricIndex() {
62+
return fabricIndex;
63+
}
64+
65+
public boolean isConnected() {
66+
return isConnected;
67+
}
68+
69+
public List<ContentApp> getContentApps() {
70+
return contentApps;
71+
}
72+
73+
public String getDeviceName() {
74+
return deviceName;
75+
}
76+
77+
public short getVendorId() {
78+
return vendorId;
79+
}
80+
81+
public short getProductId() {
82+
return productId;
83+
}
84+
85+
public short getDeviceType() {
86+
return deviceType;
87+
}
88+
89+
public boolean isInitialized() {
90+
return isInitialized;
91+
}
92+
}

examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/CastingServerBridge.mm

+3-2
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,9 @@ - (void)readCachedVideoPlayers:(dispatch_queue_t _Nonnull)clientQueue
317317
videoPlayers = [NSMutableArray new];
318318
for (size_t i = 0; cppTargetVideoPlayerInfos[i].IsInitialized(); i++) {
319319
ChipLogProgress(AppServer,
320-
"CastingServerBridge().readCachedVideoPlayers() with nodeId: %lu fabricIndex: %d deviceName: %s vendorId: %d",
321-
cppTargetVideoPlayerInfos[i].GetNodeId(), cppTargetVideoPlayerInfos[i].GetFabricIndex(),
320+
"CastingServerBridge().readCachedVideoPlayers() with nodeId: 0x" ChipLogFormatX64
321+
" fabricIndex: %d deviceName: %s vendorId: %d",
322+
ChipLogValueX64(cppTargetVideoPlayerInfos[i].GetNodeId()), cppTargetVideoPlayerInfos[i].GetFabricIndex(),
322323
cppTargetVideoPlayerInfos[i].GetDeviceName(), cppTargetVideoPlayerInfos[i].GetVendorId());
323324
videoPlayers[i] = [ConversionUtils convertToObjCVideoPlayerFrom:&cppTargetVideoPlayerInfos[i]];
324325
}

examples/tv-casting-app/linux/CastingUtils.cpp

+9-8
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,10 @@ void doCastingDemoActions(TargetEndpointInfo * endpoint)
210210
void OnConnectionSuccess(TargetVideoPlayerInfo * videoPlayer)
211211
{
212212
ChipLogProgress(AppServer,
213-
"OnConnectionSuccess with Video Player(nodeId: %lu, fabricIndex: %d, deviceName: %s, vendorId: %d, productId: "
213+
"OnConnectionSuccess with Video Player(nodeId: 0x" ChipLogFormatX64
214+
", fabricIndex: %d, deviceName: %s, vendorId: %d, productId: "
214215
"%d, deviceType: %d)",
215-
videoPlayer->GetNodeId(), videoPlayer->GetFabricIndex(), videoPlayer->GetDeviceName(),
216+
ChipLogValueX64(videoPlayer->GetNodeId()), videoPlayer->GetFabricIndex(), videoPlayer->GetDeviceName(),
216217
videoPlayer->GetVendorId(), videoPlayer->GetProductId(), videoPlayer->GetDeviceType());
217218

218219
TargetEndpointInfo * endpoints = videoPlayer->GetEndpoints();
@@ -245,15 +246,15 @@ CHIP_ERROR ConnectToCachedVideoPlayer()
245246
{
246247
if (cachedVideoPlayers[i].IsInitialized())
247248
{
248-
ChipLogProgress(AppServer, "Found a Cached video player with nodeId: %lu, fabricIndex: %d",
249-
cachedVideoPlayers[i].GetNodeId(), cachedVideoPlayers[i].GetFabricIndex());
249+
ChipLogProgress(AppServer, "Found a Cached video player with nodeId: 0x" ChipLogFormatX64 ", fabricIndex: %d",
250+
ChipLogValueX64(cachedVideoPlayers[i].GetNodeId()), cachedVideoPlayers[i].GetFabricIndex());
250251
if (CastingServer::GetInstance()->VerifyOrEstablishConnection(
251252
cachedVideoPlayers[i], OnConnectionSuccess, OnConnectionFailure, OnNewOrUpdatedEndpoint) == CHIP_NO_ERROR)
252253
{
253-
ChipLogProgress(
254-
AppServer,
255-
"FindOrEstablish CASESession attempted for cached video player with nodeId: %lu, fabricIndex: %d",
256-
cachedVideoPlayers[i].GetNodeId(), cachedVideoPlayers[i].GetFabricIndex());
254+
ChipLogProgress(AppServer,
255+
"FindOrEstablish CASESession attempted for cached video player with nodeId: 0x" ChipLogFormatX64
256+
", fabricIndex: %d",
257+
ChipLogValueX64(cachedVideoPlayers[i].GetNodeId()), cachedVideoPlayers[i].GetFabricIndex());
257258
return CHIP_NO_ERROR;
258259
}
259260
}

examples/tv-casting-app/tv-casting-common/include/CastingServer.h

+2-6
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,8 @@ class CastingServer
6565
CHIP_ERROR SendUserDirectedCommissioningRequest(chip::Dnssd::DiscoveredNodeData * selectedCommissioner);
6666
#endif // CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONER_DISCOVERY_CLIENT
6767

68-
TargetVideoPlayerInfo * GetActiveTargetVideoPlayer()
69-
{
70-
return mActiveTargetVideoPlayerInfo.IsInitialized() && mActiveTargetVideoPlayerInfo.GetOperationalDeviceProxy() != nullptr
71-
? &mActiveTargetVideoPlayerInfo
72-
: nullptr;
73-
}
68+
TargetVideoPlayerInfo * GetActiveTargetVideoPlayer() { return &mActiveTargetVideoPlayerInfo; }
69+
7470
CHIP_ERROR TargetVideoPlayerInfoInit(chip::NodeId nodeId, chip::FabricIndex fabricIndex,
7571
std::function<void(TargetVideoPlayerInfo *)> onConnectionSuccess,
7672
std::function<void(CHIP_ERROR)> onConnectionFailure,

examples/tv-casting-app/tv-casting-common/include/MediaBase.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ class MediaBase
3131
auto deviceProxy = targetVideoPlayerInfo.GetOperationalDeviceProxy();
3232
if (deviceProxy == nullptr)
3333
{
34-
ChipLogError(AppServer, "Failed in getting an instance of OperationalDeviceProxy for nodeId: %lu, fabricIndex: %d",
35-
targetVideoPlayerInfo.GetNodeId(), targetVideoPlayerInfo.GetFabricIndex());
34+
ChipLogError(AppServer,
35+
"Failed in getting an instance of OperationalDeviceProxy for nodeId: 0x" ChipLogFormatX64
36+
", fabricIndex: %d",
37+
ChipLogValueX64(targetVideoPlayerInfo.GetNodeId()), targetVideoPlayerInfo.GetFabricIndex());
3638
return CHIP_ERROR_PEER_NODE_NOT_FOUND;
3739
}
3840
mTargetVideoPlayerInfo = &targetVideoPlayerInfo;

examples/tv-casting-app/tv-casting-common/include/TargetVideoPlayerInfo.h

+7-6
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,9 @@ class TargetVideoPlayerInfo
7373
_this->mDeviceProxy = chip::OperationalDeviceProxy(&exchangeMgr, sessionHandle);
7474
_this->mInitialized = true;
7575
ChipLogProgress(AppServer,
76-
"HandleDeviceConnected created an instance of OperationalDeviceProxy for nodeId: %lu, fabricIndex: %d",
77-
_this->GetNodeId(), _this->GetFabricIndex());
76+
"HandleDeviceConnected created an instance of OperationalDeviceProxy for nodeId: 0x" ChipLogFormatX64
77+
", fabricIndex: %d",
78+
ChipLogValueX64(_this->GetNodeId()), _this->GetFabricIndex());
7879

7980
if (_this->mOnConnectionSuccessClientCallback)
8081
{
@@ -85,10 +86,10 @@ class TargetVideoPlayerInfo
8586

8687
static void HandleDeviceConnectionFailure(void * context, const chip::ScopedNodeId & peerId, CHIP_ERROR error)
8788
{
88-
ChipLogError(
89-
AppServer,
90-
"HandleDeviceConnectionFailure called for peerId.nodeId: %lu, peer.fabricIndex: %d with error: %" CHIP_ERROR_FORMAT,
91-
peerId.GetNodeId(), peerId.GetFabricIndex(), error.AsString());
89+
ChipLogError(AppServer,
90+
"HandleDeviceConnectionFailure called for peerId.nodeId: 0x" ChipLogFormatX64
91+
", peer.fabricIndex: %d with error: %" CHIP_ERROR_FORMAT,
92+
ChipLogValueX64(peerId.GetNodeId()), peerId.GetFabricIndex(), error.AsString());
9293
TargetVideoPlayerInfo * _this = static_cast<TargetVideoPlayerInfo *>(context);
9394
_this->mDeviceProxy = chip::OperationalDeviceProxy();
9495
if (_this->mOnConnectionFailureClientCallback)

examples/tv-casting-app/tv-casting-common/src/CastingServer.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ CHIP_ERROR CastingServer::VerifyOrEstablishConnection(TargetVideoPlayerInfo & ta
255255
mOnNewOrUpdatedEndpoint = onNewOrUpdatedEndpoint;
256256

257257
return targetVideoPlayerInfo.FindOrEstablishCASESession(
258-
[](TargetVideoPlayerInfo * targetVideoPlayerInfo) {
258+
[](TargetVideoPlayerInfo * videoPlayer) {
259259
ChipLogProgress(AppServer, "CastingServer::OnConnectionSuccess lambda called");
260260
chip::OperationalDeviceProxy * prevDeviceProxy =
261261
CastingServer::GetInstance()->mActiveTargetVideoPlayerInfo.GetOperationalDeviceProxy();
@@ -264,8 +264,8 @@ CHIP_ERROR CastingServer::VerifyOrEstablishConnection(TargetVideoPlayerInfo & ta
264264
ChipLogProgress(AppServer, "CastingServer::OnConnectionSuccess lambda Disconnecting deviceProxy");
265265
prevDeviceProxy->Disconnect();
266266
}
267-
CastingServer::GetInstance()->mActiveTargetVideoPlayerInfo = *targetVideoPlayerInfo;
268-
CastingServer::GetInstance()->mOnConnectionSuccessClientCallback(targetVideoPlayerInfo);
267+
CastingServer::GetInstance()->mActiveTargetVideoPlayerInfo = *videoPlayer;
268+
CastingServer::GetInstance()->mOnConnectionSuccessClientCallback(videoPlayer);
269269
},
270270
onConnectionFailure);
271271
}

examples/tv-casting-app/tv-casting-common/src/PersistenceManager.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ CHIP_ERROR PersistenceManager::ReadAllVideoPlayers(TargetVideoPlayerInfo outVide
149149
size_t castingDataSize = 0;
150150
ReturnErrorOnFailure(chip::DeviceLayer::PersistedStorage::KeyValueStoreMgr().Get(kCastingDataKey, castingData,
151151
kCastingDataMaxBytes, &castingDataSize));
152-
ChipLogProgress(AppServer, "PersistenceManager::ReadAllVideoPlayers Read TLV(CastingData) from KVS store with size: %zu bytes",
152+
ChipLogProgress(AppServer, "PersistenceManager::ReadAllVideoPlayers Read TLV(CastingData) from KVS store with size: %lu bytes",
153153
castingDataSize);
154154

155155
TLV::TLVReader reader;

0 commit comments

Comments
 (0)