Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extending Media attribute subscriptions to iOS tv-casting-app/framework #22964

Merged
merged 1 commit into from
Oct 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*/
package com.chip.casting;

import java.util.ArrayList;

public class TvCastingApp {
private static final String TAG = TvCastingApp.class.getSimpleName();

Expand Down Expand Up @@ -178,7 +180,7 @@ public native boolean targetNavigator_subscribeToCurrentTarget(
SubscriptionEstablishedCallback subscriptionEstablishedHandler);

public native boolean targetNavigator_subscribeToTargetList(
SuccessCallback<TargetNavigatorTypes.TargetInfo> readSuccessHandler,
SuccessCallback<ArrayList<TargetNavigatorTypes.TargetInfo>> readSuccessHandler,
FailureCallback readFailureHandler,
int minInterval,
int maxInterval,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,8 @@ jobject TargetListSuccessHandlerJNI::ConvertToJObject(
}

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

chip::JniReferences::GetInstance().AddToList(jArrayList, jTargetInfo);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <lib/core/CHIPError.h>
#include <lib/core/Optional.h>
#include <lib/support/CHIPJNIError.h>
#include <lib/support/CHIPListUtils.h>
#include <lib/support/JniReferences.h>
#include <lib/support/JniTypeWrappers.h>

Expand Down Expand Up @@ -173,7 +174,7 @@ CHIP_ERROR CreateParameter(JNIEnv * env, jobject jParameter,
}

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

chip::app::Clusters::ContentLauncher::Structs::Parameter::Type * parameterList =
new chip::app::Clusters::ContentLauncher::Structs::Parameter::Type[parameterListSize];
auto * parameterListHolder = new ListHolder<chip::app::Clusters::ContentLauncher::Structs::Parameter::Type>(parameterListSize);
listFreer.add(parameterListHolder);
int parameterIndex = 0;
while (env->CallBooleanMethod(jIterator, jHasNextMid))
{
jobject jParameter = env->CallObjectMethod(jIterator, jNextMid);
chip::app::Clusters::ContentLauncher::Structs::Parameter::Type parameter;
ReturnErrorOnFailure(CreateParameter(env, jParameter, parameter));
parameterList[parameterIndex++] = parameter;
parameterListHolder->mList[parameterIndex].type = parameter.type;
parameterListHolder->mList[parameterIndex].value = parameter.value;
parameterListHolder->mList[parameterIndex].externalIDList = parameter.externalIDList;
parameterIndex++;
}
search.parameterList = chip::app::DataModel::List<chip::app::Clusters::ContentLauncher::Structs::Parameter::Type>(
parameterList, parameterListSize);
parameterListHolder->mList, parameterListSize);

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

ListFreer listFreer;
chip::app::Clusters::ContentLauncher::Structs::ContentSearch::Type search;
CHIP_ERROR err = CreateContentSearch(env, jSearch, search);
CHIP_ERROR err = CreateContentSearch(env, jSearch, search, listFreer);
VerifyOrExit(CHIP_NO_ERROR == err,
ChipLogError(AppServer,
"contentLauncher_1launchContent::Could not create ContentSearch object %" CHIP_ERROR_FORMAT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

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

/* Begin PBXFileReference section */
3C4AE64E286A7D40005B52A4 /* OnboardingPayload.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OnboardingPayload.h; sourceTree = "<group>"; };
3C4AE64F286A7D4D005B52A4 /* OnboardingPayload.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OnboardingPayload.m; sourceTree = "<group>"; };
3C4E53AF28E4F28100F293E8 /* MediaPlaybackTypes.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MediaPlaybackTypes.mm; sourceTree = "<group>"; };
3C4E53B128E5184C00F293E8 /* TargetNavigatorTypes.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = TargetNavigatorTypes.mm; sourceTree = "<group>"; };
3C4E53B328E5185F00F293E8 /* TargetNavigatorTypes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TargetNavigatorTypes.h; sourceTree = "<group>"; };
3C4E53B428E5593700F293E8 /* ContentLauncherTypes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ContentLauncherTypes.h; sourceTree = "<group>"; };
3C4E53B528E5595A00F293E8 /* ContentLauncherTypes.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ContentLauncherTypes.mm; sourceTree = "<group>"; };
3CA1CA7728E243750023ED44 /* MediaPlaybackTypes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MediaPlaybackTypes.h; sourceTree = "<group>"; };
3CCB871D2869085400771BAD /* MatterTvCastingBridge.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MatterTvCastingBridge.framework; sourceTree = BUILT_PRODUCTS_DIR; };
3CCB87202869085400771BAD /* MatterTvCastingBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MatterTvCastingBridge.h; sourceTree = "<group>"; };
3CCB8735286A555500771BAD /* libTvCastingCommon.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libTvCastingCommon.a; path = lib/libTvCastingCommon.a; sourceTree = BUILT_PRODUCTS_DIR; };
Expand All @@ -32,6 +42,8 @@
3CCB873C286A593700771BAD /* DiscoveredNodeDataConverter.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = DiscoveredNodeDataConverter.hpp; sourceTree = "<group>"; };
3CCB873D286A593700771BAD /* CastingServerBridge.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CastingServerBridge.mm; sourceTree = "<group>"; };
3CCB873E286A593700771BAD /* DiscoveredNodeDataConverter.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DiscoveredNodeDataConverter.mm; sourceTree = "<group>"; };
3CF8532528E37ED800F07B9F /* MatterError.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MatterError.h; sourceTree = "<group>"; };
3CF8532628E37F1000F07B9F /* MatterError.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MatterError.mm; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -77,6 +89,14 @@
3CCB873C286A593700771BAD /* DiscoveredNodeDataConverter.hpp */,
3C4AE64E286A7D40005B52A4 /* OnboardingPayload.h */,
3C4AE64F286A7D4D005B52A4 /* OnboardingPayload.m */,
3CF8532528E37ED800F07B9F /* MatterError.h */,
3CF8532628E37F1000F07B9F /* MatterError.mm */,
3C4E53B428E5593700F293E8 /* ContentLauncherTypes.h */,
3C4E53B528E5595A00F293E8 /* ContentLauncherTypes.mm */,
3CA1CA7728E243750023ED44 /* MediaPlaybackTypes.h */,
3C4E53AF28E4F28100F293E8 /* MediaPlaybackTypes.mm */,
3C4E53B328E5185F00F293E8 /* TargetNavigatorTypes.h */,
3C4E53B128E5184C00F293E8 /* TargetNavigatorTypes.mm */,
);
path = MatterTvCastingBridge;
sourceTree = "<group>";
Expand Down Expand Up @@ -185,7 +205,11 @@
buildActionMask = 2147483647;
files = (
3CCB8743286A593700771BAD /* CastingServerBridge.mm in Sources */,
3C4E53B228E5184C00F293E8 /* TargetNavigatorTypes.mm in Sources */,
3CF8532728E37F1000F07B9F /* MatterError.mm in Sources */,
3C4E53B628E5595A00F293E8 /* ContentLauncherTypes.mm in Sources */,
3CCB8744286A593700771BAD /* DiscoveredNodeDataConverter.mm in Sources */,
3C4E53B028E4F28100F293E8 /* MediaPlaybackTypes.mm in Sources */,
3CCB873F286A593700771BAD /* DiscoveredNodeData.mm in Sources */,
3C4AE650286A7D4D005B52A4 /* OnboardingPayload.m in Sources */,
);
Expand Down
Loading