Skip to content

Commit 1534176

Browse files
sharadb-amazonpull[bot]
authored andcommitted
Extending Media attribute subscriptions to iOS tv-casting-app/framework (#22964)
1 parent cee9408 commit 1534176

20 files changed

+2035
-63
lines changed

examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/TvCastingApp.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
*/
1818
package com.chip.casting;
1919

20+
import java.util.ArrayList;
21+
2022
public class TvCastingApp {
2123
private static final String TAG = TvCastingApp.class.getSimpleName();
2224

@@ -178,7 +180,7 @@ public native boolean targetNavigator_subscribeToCurrentTarget(
178180
SubscriptionEstablishedCallback subscriptionEstablishedHandler);
179181

180182
public native boolean targetNavigator_subscribeToTargetList(
181-
SuccessCallback<TargetNavigatorTypes.TargetInfo> readSuccessHandler,
183+
SuccessCallback<ArrayList<TargetNavigatorTypes.TargetInfo>> readSuccessHandler,
182184
FailureCallback readFailureHandler,
183185
int minInterval,
184186
int maxInterval,

examples/tv-casting-app/android/App/app/src/main/jni/cpp/MatterCallbackHandler-JNI.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,8 @@ jobject TargetListSuccessHandlerJNI::ConvertToJObject(
307307
}
308308

309309
jmethodID constructor = env->GetMethodID(responseTypeClass, "<init>", "(Ljava/lang/Integer;java/lang/String;)V");
310-
jobject jTargetInfo = env->NewObject(responseTypeClass, constructor, targetInfo.identifier, targetInfo.name);
310+
chip::UtfString targetInfoName(env, targetInfo.name);
311+
jobject jTargetInfo = env->NewObject(responseTypeClass, constructor, targetInfo.identifier, targetInfoName.jniValue());
311312

312313
chip::JniReferences::GetInstance().AddToList(jArrayList, jTargetInfo);
313314
}

examples/tv-casting-app/android/App/app/src/main/jni/cpp/TvCastingApp-JNI.cpp

+11-6
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <lib/core/CHIPError.h>
3131
#include <lib/core/Optional.h>
3232
#include <lib/support/CHIPJNIError.h>
33+
#include <lib/support/CHIPListUtils.h>
3334
#include <lib/support/JniReferences.h>
3435
#include <lib/support/JniTypeWrappers.h>
3536

@@ -173,7 +174,7 @@ CHIP_ERROR CreateParameter(JNIEnv * env, jobject jParameter,
173174
}
174175

175176
CHIP_ERROR CreateContentSearch(JNIEnv * env, jobject jSearch,
176-
chip::app::Clusters::ContentLauncher::Structs::ContentSearch::Type & search)
177+
chip::app::Clusters::ContentLauncher::Structs::ContentSearch::Type & search, ListFreer & listFreer)
177178
{
178179
jclass jContentSearchClass;
179180
ReturnErrorOnFailure(
@@ -192,18 +193,21 @@ CHIP_ERROR CreateContentSearch(JNIEnv * env, jobject jSearch,
192193
jmethodID jNextMid = env->GetMethodID(env->GetObjectClass(jIterator), "next", "()Ljava/lang/Object;");
193194
jmethodID jHasNextMid = env->GetMethodID(env->GetObjectClass(jIterator), "hasNext", "()Z");
194195

195-
chip::app::Clusters::ContentLauncher::Structs::Parameter::Type * parameterList =
196-
new chip::app::Clusters::ContentLauncher::Structs::Parameter::Type[parameterListSize];
196+
auto * parameterListHolder = new ListHolder<chip::app::Clusters::ContentLauncher::Structs::Parameter::Type>(parameterListSize);
197+
listFreer.add(parameterListHolder);
197198
int parameterIndex = 0;
198199
while (env->CallBooleanMethod(jIterator, jHasNextMid))
199200
{
200201
jobject jParameter = env->CallObjectMethod(jIterator, jNextMid);
201202
chip::app::Clusters::ContentLauncher::Structs::Parameter::Type parameter;
202203
ReturnErrorOnFailure(CreateParameter(env, jParameter, parameter));
203-
parameterList[parameterIndex++] = parameter;
204+
parameterListHolder->mList[parameterIndex].type = parameter.type;
205+
parameterListHolder->mList[parameterIndex].value = parameter.value;
206+
parameterListHolder->mList[parameterIndex].externalIDList = parameter.externalIDList;
207+
parameterIndex++;
204208
}
205209
search.parameterList = chip::app::DataModel::List<chip::app::Clusters::ContentLauncher::Structs::Parameter::Type>(
206-
parameterList, parameterListSize);
210+
parameterListHolder->mList, parameterListSize);
207211

208212
return CHIP_NO_ERROR;
209213
}
@@ -221,8 +225,9 @@ JNI_METHOD(jboolean, contentLauncher_1launchContent)
221225
const char * nativeData = env->GetStringUTFChars(jData, 0);
222226
chip::Optional<chip::CharSpan> data = MakeOptional(CharSpan::fromCharString(nativeData));
223227

228+
ListFreer listFreer;
224229
chip::app::Clusters::ContentLauncher::Structs::ContentSearch::Type search;
225-
CHIP_ERROR err = CreateContentSearch(env, jSearch, search);
230+
CHIP_ERROR err = CreateContentSearch(env, jSearch, search, listFreer);
226231
VerifyOrExit(CHIP_NO_ERROR == err,
227232
ChipLogError(AppServer,
228233
"contentLauncher_1launchContent::Could not create ContentSearch object %" CHIP_ERROR_FORMAT,

examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge.xcodeproj/project.pbxproj

+24
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
/* Begin PBXBuildFile section */
1010
3C4AE650286A7D4D005B52A4 /* OnboardingPayload.m in Sources */ = {isa = PBXBuildFile; fileRef = 3C4AE64F286A7D4D005B52A4 /* OnboardingPayload.m */; };
11+
3C4E53B028E4F28100F293E8 /* MediaPlaybackTypes.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3C4E53AF28E4F28100F293E8 /* MediaPlaybackTypes.mm */; };
12+
3C4E53B228E5184C00F293E8 /* TargetNavigatorTypes.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3C4E53B128E5184C00F293E8 /* TargetNavigatorTypes.mm */; };
13+
3C4E53B628E5595A00F293E8 /* ContentLauncherTypes.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3C4E53B528E5595A00F293E8 /* ContentLauncherTypes.mm */; };
1114
3CCB87212869085400771BAD /* MatterTvCastingBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 3CCB87202869085400771BAD /* MatterTvCastingBridge.h */; settings = {ATTRIBUTES = (Public, ); }; };
1215
3CCB8737286A555500771BAD /* libTvCastingCommon.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3CCB8735286A555500771BAD /* libTvCastingCommon.a */; };
1316
3CCB8738286A555500771BAD /* libmbedtls.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3CCB8736286A555500771BAD /* libmbedtls.a */; settings = {ATTRIBUTES = (Required, ); }; };
@@ -17,11 +20,18 @@
1720
3CCB8742286A593700771BAD /* DiscoveredNodeDataConverter.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 3CCB873C286A593700771BAD /* DiscoveredNodeDataConverter.hpp */; };
1821
3CCB8743286A593700771BAD /* CastingServerBridge.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3CCB873D286A593700771BAD /* CastingServerBridge.mm */; };
1922
3CCB8744286A593700771BAD /* DiscoveredNodeDataConverter.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3CCB873E286A593700771BAD /* DiscoveredNodeDataConverter.mm */; };
23+
3CF8532728E37F1000F07B9F /* MatterError.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3CF8532628E37F1000F07B9F /* MatterError.mm */; };
2024
/* End PBXBuildFile section */
2125

2226
/* Begin PBXFileReference section */
2327
3C4AE64E286A7D40005B52A4 /* OnboardingPayload.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OnboardingPayload.h; sourceTree = "<group>"; };
2428
3C4AE64F286A7D4D005B52A4 /* OnboardingPayload.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OnboardingPayload.m; sourceTree = "<group>"; };
29+
3C4E53AF28E4F28100F293E8 /* MediaPlaybackTypes.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MediaPlaybackTypes.mm; sourceTree = "<group>"; };
30+
3C4E53B128E5184C00F293E8 /* TargetNavigatorTypes.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = TargetNavigatorTypes.mm; sourceTree = "<group>"; };
31+
3C4E53B328E5185F00F293E8 /* TargetNavigatorTypes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TargetNavigatorTypes.h; sourceTree = "<group>"; };
32+
3C4E53B428E5593700F293E8 /* ContentLauncherTypes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ContentLauncherTypes.h; sourceTree = "<group>"; };
33+
3C4E53B528E5595A00F293E8 /* ContentLauncherTypes.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ContentLauncherTypes.mm; sourceTree = "<group>"; };
34+
3CA1CA7728E243750023ED44 /* MediaPlaybackTypes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MediaPlaybackTypes.h; sourceTree = "<group>"; };
2535
3CCB871D2869085400771BAD /* MatterTvCastingBridge.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MatterTvCastingBridge.framework; sourceTree = BUILT_PRODUCTS_DIR; };
2636
3CCB87202869085400771BAD /* MatterTvCastingBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MatterTvCastingBridge.h; sourceTree = "<group>"; };
2737
3CCB8735286A555500771BAD /* libTvCastingCommon.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libTvCastingCommon.a; path = lib/libTvCastingCommon.a; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -32,6 +42,8 @@
3242
3CCB873C286A593700771BAD /* DiscoveredNodeDataConverter.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = DiscoveredNodeDataConverter.hpp; sourceTree = "<group>"; };
3343
3CCB873D286A593700771BAD /* CastingServerBridge.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CastingServerBridge.mm; sourceTree = "<group>"; };
3444
3CCB873E286A593700771BAD /* DiscoveredNodeDataConverter.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DiscoveredNodeDataConverter.mm; sourceTree = "<group>"; };
45+
3CF8532528E37ED800F07B9F /* MatterError.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MatterError.h; sourceTree = "<group>"; };
46+
3CF8532628E37F1000F07B9F /* MatterError.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MatterError.mm; sourceTree = "<group>"; };
3547
/* End PBXFileReference section */
3648

3749
/* Begin PBXFrameworksBuildPhase section */
@@ -77,6 +89,14 @@
7789
3CCB873C286A593700771BAD /* DiscoveredNodeDataConverter.hpp */,
7890
3C4AE64E286A7D40005B52A4 /* OnboardingPayload.h */,
7991
3C4AE64F286A7D4D005B52A4 /* OnboardingPayload.m */,
92+
3CF8532528E37ED800F07B9F /* MatterError.h */,
93+
3CF8532628E37F1000F07B9F /* MatterError.mm */,
94+
3C4E53B428E5593700F293E8 /* ContentLauncherTypes.h */,
95+
3C4E53B528E5595A00F293E8 /* ContentLauncherTypes.mm */,
96+
3CA1CA7728E243750023ED44 /* MediaPlaybackTypes.h */,
97+
3C4E53AF28E4F28100F293E8 /* MediaPlaybackTypes.mm */,
98+
3C4E53B328E5185F00F293E8 /* TargetNavigatorTypes.h */,
99+
3C4E53B128E5184C00F293E8 /* TargetNavigatorTypes.mm */,
80100
);
81101
path = MatterTvCastingBridge;
82102
sourceTree = "<group>";
@@ -185,7 +205,11 @@
185205
buildActionMask = 2147483647;
186206
files = (
187207
3CCB8743286A593700771BAD /* CastingServerBridge.mm in Sources */,
208+
3C4E53B228E5184C00F293E8 /* TargetNavigatorTypes.mm in Sources */,
209+
3CF8532728E37F1000F07B9F /* MatterError.mm in Sources */,
210+
3C4E53B628E5595A00F293E8 /* ContentLauncherTypes.mm in Sources */,
188211
3CCB8744286A593700771BAD /* DiscoveredNodeDataConverter.mm in Sources */,
212+
3C4E53B028E4F28100F293E8 /* MediaPlaybackTypes.mm in Sources */,
189213
3CCB873F286A593700771BAD /* DiscoveredNodeData.mm in Sources */,
190214
3C4AE650286A7D4D005B52A4 /* OnboardingPayload.m in Sources */,
191215
);

0 commit comments

Comments
 (0)