From ddc670fa99123365aabfb153cd8f22a0a23068f8 Mon Sep 17 00:00:00 2001 From: Sharad Binjola Date: Tue, 9 Jan 2024 15:54:03 -0800 Subject: [PATCH] examples iOS tv-casting-app: Changing file prefix to MC --- examples/tv-casting-app/APIs.md | 86 ++++---- .../project.pbxproj | 188 +++++++++--------- .../{MTRCastingApp.h => MCCastingApp.h} | 28 +-- .../{MTRCastingApp.mm => MCCastingApp.mm} | 72 +++---- .../{MTRCastingPlayer.h => MCCastingPlayer.h} | 20 +- ...MTRCastingPlayer.mm => MCCastingPlayer.mm} | 38 ++-- .../MCCastingPlayerDiscovery.h | 85 ++++++++ ...scovery.mm => MCCastingPlayerDiscovery.mm} | 68 +++---- ...ssionableData.h => MCCommissionableData.h} | 8 +- ...ionableData.mm => MCCommissionableData.mm} | 4 +- ...vider.h => MCCommissionableDataProvider.h} | 14 +- ...der.mm => MCCommissionableDataProvider.mm} | 32 +-- ...ommonCaseDeviceServerInitParamsProvider.h} | 8 +- .../{MTRCryptoUtils.h => MCCryptoUtils.h} | 8 +- .../{MTRCryptoUtils.mm => MCCryptoUtils.mm} | 8 +- .../{MTRDataSource.h => MCDataSource.h} | 22 +- ...als.h => MCDeviceAttestationCredentials.h} | 18 +- ...s.mm => MCDeviceAttestationCredentials.mm} | 4 +- ... MCDeviceAttestationCredentialsProvider.h} | 16 +- ...MCDeviceAttestationCredentialsProvider.mm} | 20 +- ...MTREndpointFilter.h => MCEndpointFilter.h} | 10 +- ...MTREndpointFilter.m => MCEndpointFilter.m} | 4 +- .../{MTRErrorUtils.h => MCErrorUtils.h} | 8 +- .../{MTRErrorUtils.mm => MCErrorUtils.mm} | 4 +- ...h => MCRotatingDeviceIdUniqueIdProvider.h} | 14 +- ... => MCRotatingDeviceIdUniqueIdProvider.mm} | 10 +- .../MTRCastingPlayerDiscovery.h | 85 -------- .../MatterTvCastingBridge.h | 16 +- .../TvCasting.xcodeproj/project.pbxproj | 40 ++-- .../TvCasting/TvCasting/ContentView.swift | 2 +- ...ew.swift => MCConnectionExampleView.swift} | 12 +- ...ift => MCConnectionExampleViewModel.swift} | 12 +- ...iew.swift => MCDiscoveryExampleView.swift} | 12 +- ...wift => MCDiscoveryExampleViewModel.swift} | 32 +-- ...le.swift => MCInitializationExample.swift} | 22 +- .../TvCasting/TvCasting/TvCastingApp.swift | 12 +- 36 files changed, 521 insertions(+), 521 deletions(-) rename examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/{MTRCastingApp.h => MCCastingApp.h} (64%) rename examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/{MTRCastingApp.mm => MCCastingApp.mm} (63%) rename examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/{MTRCastingPlayer.h => MCCastingPlayer.h} (87%) rename examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/{MTRCastingPlayer.mm => MCCastingPlayer.mm} (76%) create mode 100644 examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCastingPlayerDiscovery.h rename examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/{MTRCastingPlayerDiscovery.mm => MCCastingPlayerDiscovery.mm} (55%) rename examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/{MTRCommissionableData.h => MCCommissionableData.h} (90%) rename examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/{MTRCommissionableData.mm => MCCommissionableData.mm} (94%) rename examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/{MTRCommissionableDataProvider.h => MCCommissionableDataProvider.h} (85%) rename examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/{MTRCommissionableDataProvider.mm => MCCommissionableDataProvider.mm} (86%) rename examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/{MTRCommonCaseDeviceServerInitParamsProvider.h => MCCommonCaseDeviceServerInitParamsProvider.h} (82%) rename examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/{MTRCryptoUtils.h => MCCryptoUtils.h} (93%) rename examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/{MTRCryptoUtils.mm => MCCryptoUtils.mm} (94%) rename examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/{MTRDataSource.h => MCDataSource.h} (70%) rename examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/{MTRDeviceAttestationCredentials.h => MCDeviceAttestationCredentials.h} (59%) rename examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/{MTRDeviceAttestationCredentials.mm => MCDeviceAttestationCredentials.mm} (93%) rename examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/{MTRDeviceAttestationCredentialsProvider.h => MCDeviceAttestationCredentialsProvider.h} (77%) rename examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/{MTRDeviceAttestationCredentialsProvider.mm => MCDeviceAttestationCredentialsProvider.mm} (86%) rename examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/{MTREndpointFilter.h => MCEndpointFilter.h} (82%) rename examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/{MTREndpointFilter.m => MCEndpointFilter.m} (91%) rename examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/{MTRErrorUtils.h => MCErrorUtils.h} (90%) rename examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/{MTRErrorUtils.mm => MCErrorUtils.mm} (96%) rename examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/{MTRRotatingDeviceIdUniqueIdProvider.h => MCRotatingDeviceIdUniqueIdProvider.h} (73%) rename examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/{MTRRotatingDeviceIdUniqueIdProvider.mm => MCRotatingDeviceIdUniqueIdProvider.mm} (81%) delete mode 100644 examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRCastingPlayerDiscovery.h rename examples/tv-casting-app/darwin/TvCasting/TvCasting/{MTRConnectionExampleView.swift => MCConnectionExampleView.swift} (86%) rename examples/tv-casting-app/darwin/TvCasting/TvCasting/{MTRConnectionExampleViewModel.swift => MCConnectionExampleViewModel.swift} (75%) rename examples/tv-casting-app/darwin/TvCasting/TvCasting/{MTRDiscoveryExampleView.swift => MCDiscoveryExampleView.swift} (89%) rename examples/tv-casting-app/darwin/TvCasting/TvCasting/{MTRDiscoveryExampleViewModel.swift => MCDiscoveryExampleViewModel.swift} (83%) rename examples/tv-casting-app/darwin/TvCasting/TvCasting/{MTRInitializationExample.swift => MCInitializationExample.swift} (91%) diff --git a/examples/tv-casting-app/APIs.md b/examples/tv-casting-app/APIs.md index f0d1cfda70d2fa..4afb4f6556fe28 100644 --- a/examples/tv-casting-app/APIs.md +++ b/examples/tv-casting-app/APIs.md @@ -82,7 +82,7 @@ client's specific values for `CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID` and _{Complete Initialization examples: [Linux](linux/simple-app.cpp) | [Android](android/App/app/src/main/java/com/matter/casting/InitializationExample.java) -| [iOS](darwin/TvCasting/TvCasting/MTRInitializationExample.swift)}_ +| [iOS](darwin/TvCasting/TvCasting/MCInitializationExample.swift)}_ A Casting Client must first initialize the Matter SDK and define the following `DataProvider` objects for the the Matter Casting library to use throughout the @@ -135,10 +135,10 @@ client's lifecycle: On iOS, define the `func castingAppDidReceiveRequestForRotatingDeviceIdUniqueId` in a class, - `MTRAppParametersDataSource`, that implements the `MTRDataSource`: + `MCAppParametersDataSource`, that implements the `MCDataSource`: ```swift - class MTRAppParametersDataSource : NSObject, MTRDataSource + class MCAppParametersDataSource : NSObject, MCDataSource { func castingAppDidReceiveRequestForRotatingDeviceIdUniqueId(_ sender: Any) -> Data { // dummy value, with at least 16 bytes (ConfigurationManager::kMinRotatingDeviceIDUniqueIDLength), for demonstration only @@ -196,13 +196,13 @@ client's lifecycle: ``` On iOS, add a `func commissioningDataProvider` to the - `MTRAppParametersDataSource` class defined above, that can provide the - required values to the `MTRCastingApp`. + `MCAppParametersDataSource` class defined above, that can provide the + required values to the `MCCastingApp`. ```swift - func castingAppDidReceiveRequestForCommissionableData(_ sender: Any) -> MTRCommissionableData { + func castingAppDidReceiveRequestForCommissionableData(_ sender: Any) -> MCCommissionableData { // dummy values for demonstration only - return MTRCommissionableData( + return MCCommissionableData( passcode: 20202021, discriminator: 3874, spake2pIterationCount: 1000, @@ -272,8 +272,8 @@ client's lifecycle: On iOS, add functions `castingAppDidReceiveRequestForDeviceAttestationCredentials` and `didReceiveRequestToSignCertificateRequest` to the - `MTRAppParametersDataSource` class defined above, that can return - `MTRDeviceAttestationCredentials` and sign messages for the Casting Client, + `MCAppParametersDataSource` class defined above, that can return + `MCDeviceAttestationCredentials` and sign messages for the Casting Client, respectively. ```swift @@ -284,8 +284,8 @@ client's lifecycle: let KPAI_FFF1_8000_Cert_Array: Data = Data(base64Encoded: "MIIB4kQ==")!; let kCertificationDeclaration: Data = Data(base64Encoded: "MIIfA==")!; - func castingAppDidReceiveRequestForDeviceAttestationCredentials(_ sender: Any) -> MTRDeviceAttestationCredentials { - return MTRDeviceAttestationCredentials( + func castingAppDidReceiveRequestForDeviceAttestationCredentials(_ sender: Any) -> MCDeviceAttestationCredentials { + return MCDeviceAttestationCredentials( certificationDeclaration: kCertificationDeclaration, firmwareInformation: Data(), deviceAttestationCert: kDevelopmentDAC_Cert_FFF1_8001, @@ -321,7 +321,7 @@ client's lifecycle: } // convert ASN.1 DER signature to SEC1 raw format - return MTRCryptoUtils.ecdsaAsn1SignatureToRaw(withFeLengthBytes: 32, + return MCCryptoUtils.ecdsaAsn1SignatureToRaw(withFeLengthBytes: 32, asn1Signature: asn1SignatureData!, outRawSignature: &outRawSignature.pointee) } @@ -412,20 +412,20 @@ public static MatterError initAndStart(Context applicationContext) { } ``` -On iOS, call `MTRCastingApp.initialize` with an object of the -`MTRAppParametersDataSource`. +On iOS, call `MCCastingApp.initialize` with an object of the +`MCAppParametersDataSource`. ```swift func initialize() -> MatterError { - if let castingApp = MTRCastingApp.getSharedInstance() { - return castingApp.initialize(with: MTRAppParametersDataSource()) + if let castingApp = MCCastingApp.getSharedInstance() { + return castingApp.initialize(with: MCAppParametersDataSource()) } else { return MATTER_ERROR_INCORRECT_STATE } } ``` -After initialization, on iOS, call `start` and `stop` on the `MTRCastingApp` +After initialization, on iOS, call `start` and `stop` on the `MCCastingApp` shared instance when the App sends the `UIApplication.didBecomeActiveNotification` and `UIApplication.willResignActiveNotification` @@ -440,33 +440,33 @@ struct TvCastingApp: App { WindowGroup { ContentView() .onAppear(perform: { - let err: Error? = MTRInitializationExample().initialize() + let err: Error? = MCInitializationExample().initialize() if err != nil { - self.Log.error("MTRCastingApp initialization failed \(err)") + self.Log.error("MCCastingApp initialization failed \(err)") return } }) .onReceive(NotificationCenter.default.publisher(for: UIApplication.didBecomeActiveNotification)) { _ in self.Log.info("TvCastingApp: UIApplication.didBecomeActiveNotification") - if let castingApp = MTRCastingApp.getSharedInstance() + if let castingApp = MCCastingApp.getSharedInstance() { castingApp.start(completionBlock: { (err : Error?) -> () in if err != nil { - self.Log.error("MTRCastingApp start failed \(err)") + self.Log.error("MCCastingApp start failed \(err)") } }) } } .onReceive(NotificationCenter.default.publisher(for: UIApplication.willResignActiveNotification)) { _ in self.Log.info("TvCastingApp: UIApplication.willResignActiveNotification") - if let castingApp = MTRCastingApp.getSharedInstance() + if let castingApp = MCCastingApp.getSharedInstance() { castingApp.stop(completionBlock: { (err : Error?) -> () in if err != nil { - self.Log.error("MTRCastingApp stop failed \(err)") + self.Log.error("MCCastingApp stop failed \(err)") } }) } @@ -485,13 +485,13 @@ re-establishing the CASE session. This cache can be cleared by calling the `ClearCache` API on the `CastingApp`, say when the user signs out of the app. See API and its documentation for [Linux](tv-casting-common/core/CastingApp.h), Android and -[iOS](darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRCastingApp.h). +[iOS](darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCastingApp.h). ### Discover Casting Players _{Complete Discovery examples: [Linux](linux/simple-app-helper.cpp) | [Android](android/App/app/src/main/java/com/matter/casting/DiscoveryExampleFragment.java) -| [iOS](darwin/TvCasting/TvCasting/MTRDiscoveryExampleViewModel.swift)}_ +| [iOS](darwin/TvCasting/TvCasting/MCDiscoveryExampleViewModel.swift)}_ The Casting Client discovers `CastingPlayers` using Matter Commissioner discovery over DNS-SD by listening for `CastingPlayer` events as they are @@ -577,12 +577,12 @@ func didAddDiscoveredCastingPlayers(notification: Notification) { Log.info("didAddDiscoveredCastingPlayers() called") guard let userInfo = notification.userInfo, - let castingPlayer = userInfo["castingPlayer"] as? MTRCastingPlayer else { - self.Log.error("didAddDiscoveredCastingPlayers called with no MTRCastingPlayer") + let castingPlayer = userInfo["castingPlayer"] as? MCCastingPlayer else { + self.Log.error("didAddDiscoveredCastingPlayers called with no MCCastingPlayer") return } - self.Log.info("didAddDiscoveredCastingPlayers notified of a MTRCastingPlayer with ID: \(castingPlayer.identifier())") + self.Log.info("didAddDiscoveredCastingPlayers notified of a MCCastingPlayer with ID: \(castingPlayer.identifier())") DispatchQueue.main.async { self.displayedCastingPlayers.append(castingPlayer) @@ -594,12 +594,12 @@ func didRemoveDiscoveredCastingPlayers(notification: Notification) { Log.info("didRemoveDiscoveredCastingPlayers() called") guard let userInfo = notification.userInfo, - let castingPlayer = userInfo["castingPlayer"] as? MTRCastingPlayer else { - self.Log.error("didRemoveDiscoveredCastingPlayers called with no MTRCastingPlayer") + let castingPlayer = userInfo["castingPlayer"] as? MCCastingPlayer else { + self.Log.error("didRemoveDiscoveredCastingPlayers called with no MCCastingPlayer") return } - self.Log.info("didRemoveDiscoveredCastingPlayers notified of a MTRCastingPlayer with ID: \(castingPlayer.identifier())") + self.Log.info("didRemoveDiscoveredCastingPlayers notified of a MCCastingPlayer with ID: \(castingPlayer.identifier())") DispatchQueue.main.async { self.displayedCastingPlayers.removeAll(where: {$0 == castingPlayer}) @@ -611,12 +611,12 @@ func didUpdateDiscoveredCastingPlayers(notification: Notification) { Log.info("didUpdateDiscoveredCastingPlayers() called") guard let userInfo = notification.userInfo, - let castingPlayer = userInfo["castingPlayer"] as? MTRCastingPlayer else { - self.Log.error("didUpdateDiscoveredCastingPlayers called with no MTRCastingPlayer") + let castingPlayer = userInfo["castingPlayer"] as? MCCastingPlayer else { + self.Log.error("didUpdateDiscoveredCastingPlayers called with no MCCastingPlayer") return } - self.Log.info("didUpdateDiscoveredCastingPlayers notified of a MTRCastingPlayer with ID: \(castingPlayer.identifier())") + self.Log.info("didUpdateDiscoveredCastingPlayers notified of a MCCastingPlayer with ID: \(castingPlayer.identifier())") if let index = displayedCastingPlayers.firstIndex(where: { castingPlayer.identifier() == $0.identifier() }) { DispatchQueue.main.async @@ -672,7 +672,7 @@ if (err.hasError()) { On iOS, register the listeners by calling `addObserver` on the `NotificationCenter` with the appropriate selector, and then call start on the -`sharedInstance` of `MTRCastingPlayerDiscovery`. +`sharedInstance` of `MCCastingPlayerDiscovery`. ```swift func startDiscovery() { @@ -680,7 +680,7 @@ func startDiscovery() { NotificationCenter.default.addObserver(self, selector: #selector(self.didRemoveDiscoveredCastingPlayers), name: NSNotification.Name.didRemoveCastingPlayers, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(self.didUpdateDiscoveredCastingPlayers), name: NSNotification.Name.didUpdateCastingPlayers, object: nil) - MTRCastingPlayerDiscovery.sharedInstance().start() + MCCastingPlayerDiscovery.sharedInstance().start() ... } ``` @@ -693,7 +693,7 @@ discover available endpoints supported by a Casting Player. ### Connect to a Casting Player _{Complete Connection examples: [Linux](linux/simple-app-helper.cpp) | -[iOS](darwin/TvCasting/TvCasting/MTRConnectionExampleViewModel.swift)}_ +[iOS](darwin/TvCasting/TvCasting/MCConnectionExampleViewModel.swift)}_ Each `CastingPlayer` object created during [Discovery](#discover-casting-players) contains information such as @@ -741,22 +741,22 @@ targetCastingPlayer->VerifyOrEstablishConnection(ConnectionHandler, ``` On iOS, the Casting Client may call `verifyOrEstablishConnection` on the -`MTRCastingPlayer` object it wants to connect to and handle any `NSErrors` that +`MCCastingPlayer` object it wants to connect to and handle any `NSErrors` that may happen in the process. ```swift -// VendorId of the MTREndpoint on the MTRCastingPlayer that the MTRCastingApp desires to interact with after connection +// VendorId of the MCEndpoint on the MCCastingPlayer that the MCCastingApp desires to interact with after connection let kDesiredEndpointVendorId: UInt16 = 65521; @Published var connectionSuccess: Bool?; @Published var connectionStatus: String?; -func connect(selectedCastingPlayer: MTRCastingPlayer?) { - let desiredEndpointFilter: MTREndpointFilter = MTREndpointFilter() +func connect(selectedCastingPlayer: MCCastingPlayer?) { + let desiredEndpointFilter: MCEndpointFilter = MCEndpointFilter() desiredEndpointFilter.vendorId = kDesiredEndpointVendorId selectedCastingPlayer?.verifyOrEstablishConnection(completionBlock: { err in - self.Log.error("MTRConnectionExampleViewModel connect() completed with \(err)") + self.Log.error("MCConnectionExampleViewModel connect() completed with \(err)") if(err == nil) { self.connectionSuccess = true @@ -969,4 +969,4 @@ void SubscribeToMediaPlaybackCurrentState(matter::casting::memory::Strong _Nonnull)dataSource; +- (NSError * _Nullable)initializeWithDataSource:(id _Nonnull)dataSource; /** - * @brief (async) Starts the Matter server that the MTRCastingApp runs on and registers all the necessary delegates + * @brief (async) Starts the Matter server that the MCCastingApp runs on and registers all the necessary delegates */ - (void)startWithCompletionBlock:(void (^_Nonnull __strong)(NSError * _Nullable __strong))completion; /** - * @brief (async) Stops the Matter server that the MTRCastingApp runs on + * @brief (async) Stops the Matter server that the MCCastingApp runs on */ - (void)stopWithCompletionBlock:(void (^_Nonnull __strong)(NSError * _Nullable __strong))completion; /** - * @brief true, if MTRCastingApp is running. false otherwise + * @brief true, if MCCastingApp is running. false otherwise */ - (bool)isRunning; @@ -69,4 +69,4 @@ @end -#endif /* MTRCastingApp_h */ +#endif /* MCCastingApp_h */ diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRCastingApp.mm b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCastingApp.mm similarity index 63% rename from examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRCastingApp.mm rename to examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCastingApp.mm index ba7e72b6730fac..d124f7658fdca5 100644 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRCastingApp.mm +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCastingApp.mm @@ -15,13 +15,13 @@ * limitations under the License. */ -#import "MTRCastingApp.h" +#import "MCCastingApp.h" -#import "MTRCommissionableDataProvider.h" -#import "MTRCommonCaseDeviceServerInitParamsProvider.h" -#import "MTRDeviceAttestationCredentialsProvider.h" -#import "MTRErrorUtils.h" -#import "MTRRotatingDeviceIdUniqueIdProvider.h" +#import "MCCommissionableDataProvider.h" +#import "MCCommonCaseDeviceServerInitParamsProvider.h" +#import "MCDeviceAttestationCredentialsProvider.h" +#import "MCErrorUtils.h" +#import "MCRotatingDeviceIdUniqueIdProvider.h" #import "core/Types.h" #include @@ -29,13 +29,13 @@ #import -@interface MTRCastingApp () +@interface MCCastingApp () @property matter::casting::support::AppParameters appParameters; -@property matter::casting::support::MTRRotatingDeviceIdUniqueIdProvider uniqueIdProvider; -@property matter::casting::support::MTRCommissionableDataProvider * commissionableDataProvider; -@property matter::casting::support::MTRDeviceAttestationCredentialsProvider * dacProvider; -@property MTRCommonCaseDeviceServerInitParamsProvider * serverInitParamsProvider; +@property matter::casting::support::MCRotatingDeviceIdUniqueIdProvider uniqueIdProvider; +@property matter::casting::support::MCCommissionableDataProvider * commissionableDataProvider; +@property matter::casting::support::MCDeviceAttestationCredentialsProvider * dacProvider; +@property MCCommonCaseDeviceServerInitParamsProvider * serverInitParamsProvider; // queue used when calling the client code on completion blocks from any MatterTvCastingBridge API @property dispatch_queue_t _Nonnull clientQueue; @@ -45,11 +45,11 @@ @interface MTRCastingApp () @end -@implementation MTRCastingApp +@implementation MCCastingApp -+ (MTRCastingApp *)getSharedInstance ++ (MCCastingApp *)getSharedInstance { - static MTRCastingApp * instance = nil; + static MCCastingApp * instance = nil; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ instance = [[self alloc] init]; @@ -69,70 +69,70 @@ - (dispatch_queue_t)getClientQueue - (NSError *)initializeWithDataSource:(id)dataSource { - ChipLogProgress(AppServer, "MTRCastingApp.initializeWithDataSource called"); + ChipLogProgress(AppServer, "MCCastingApp.initializeWithDataSource called"); // get the clientQueue - VerifyOrReturnValue([dataSource clientQueue] != nil, [MTRErrorUtils NSErrorFromChipError:CHIP_ERROR_INVALID_ARGUMENT]); + VerifyOrReturnValue([dataSource clientQueue] != nil, [MCErrorUtils NSErrorFromChipError:CHIP_ERROR_INVALID_ARGUMENT]); _clientQueue = [dataSource clientQueue]; // Initialize cpp Providers - VerifyOrReturnValue(_uniqueIdProvider.Initialize(dataSource) == CHIP_NO_ERROR, [MTRErrorUtils NSErrorFromChipError:CHIP_ERROR_INVALID_ARGUMENT]); + VerifyOrReturnValue(_uniqueIdProvider.Initialize(dataSource) == CHIP_NO_ERROR, [MCErrorUtils NSErrorFromChipError:CHIP_ERROR_INVALID_ARGUMENT]); - _commissionableDataProvider = new matter::casting::support::MTRCommissionableDataProvider(); - VerifyOrReturnValue(_commissionableDataProvider->Initialize(dataSource) == CHIP_NO_ERROR, [MTRErrorUtils NSErrorFromChipError:CHIP_ERROR_INVALID_ARGUMENT]); + _commissionableDataProvider = new matter::casting::support::MCCommissionableDataProvider(); + VerifyOrReturnValue(_commissionableDataProvider->Initialize(dataSource) == CHIP_NO_ERROR, [MCErrorUtils NSErrorFromChipError:CHIP_ERROR_INVALID_ARGUMENT]); - _dacProvider = new matter::casting::support::MTRDeviceAttestationCredentialsProvider(); - VerifyOrReturnValue(_dacProvider->Initialize(dataSource) == CHIP_NO_ERROR, [MTRErrorUtils NSErrorFromChipError:CHIP_ERROR_INVALID_ARGUMENT]); + _dacProvider = new matter::casting::support::MCDeviceAttestationCredentialsProvider(); + VerifyOrReturnValue(_dacProvider->Initialize(dataSource) == CHIP_NO_ERROR, [MCErrorUtils NSErrorFromChipError:CHIP_ERROR_INVALID_ARGUMENT]); - _serverInitParamsProvider = new MTRCommonCaseDeviceServerInitParamsProvider(); + _serverInitParamsProvider = new MCCommonCaseDeviceServerInitParamsProvider(); // Create cpp AppParameters VerifyOrReturnValue(_appParameters.Create(&_uniqueIdProvider, _commissionableDataProvider, _dacProvider, GetDefaultDACVerifier(chip::Credentials::GetTestAttestationTrustStore()), _serverInitParamsProvider) == CHIP_NO_ERROR, - [MTRErrorUtils NSErrorFromChipError:CHIP_ERROR_INVALID_ARGUMENT]); + [MCErrorUtils NSErrorFromChipError:CHIP_ERROR_INVALID_ARGUMENT]); // Initialize cpp CastingApp VerifyOrReturnValue(matter::casting::core::CastingApp::GetInstance()->Initialize(_appParameters) == CHIP_NO_ERROR, - [MTRErrorUtils NSErrorFromChipError:CHIP_ERROR_INCORRECT_STATE]); + [MCErrorUtils NSErrorFromChipError:CHIP_ERROR_INCORRECT_STATE]); // Get and store the CHIP Work queue _workQueue = chip::DeviceLayer::PlatformMgrImpl().GetWorkQueue(); - return [MTRErrorUtils NSErrorFromChipError:CHIP_NO_ERROR]; + return [MCErrorUtils NSErrorFromChipError:CHIP_NO_ERROR]; } - (void)startWithCompletionBlock:(void (^)(NSError *))completion { - ChipLogProgress(AppServer, "MTRCastingApp.startWithCompletionBlock called"); + ChipLogProgress(AppServer, "MCCastingApp.startWithCompletionBlock called"); VerifyOrReturn(_workQueue != nil && _clientQueue != nil, dispatch_async(self->_clientQueue, ^{ - completion([MTRErrorUtils NSErrorFromChipError:CHIP_ERROR_INCORRECT_STATE]); + completion([MCErrorUtils NSErrorFromChipError:CHIP_ERROR_INCORRECT_STATE]); })); dispatch_async(_workQueue, ^{ __block CHIP_ERROR err = matter::casting::core::CastingApp::GetInstance()->Start(); dispatch_async(self->_clientQueue, ^{ - completion([MTRErrorUtils NSErrorFromChipError:err]); + completion([MCErrorUtils NSErrorFromChipError:err]); }); }); __block CHIP_ERROR err = chip::DeviceLayer::PlatformMgrImpl().StartEventLoopTask(); VerifyOrReturn(err == CHIP_NO_ERROR, dispatch_async(self->_clientQueue, ^{ - completion([MTRErrorUtils NSErrorFromChipError:err]); + completion([MCErrorUtils NSErrorFromChipError:err]); })); } - (void)stopWithCompletionBlock:(void (^)(NSError *))completion { - ChipLogProgress(AppServer, "MTRCastingApp.stopWithCompletionBlock called"); + ChipLogProgress(AppServer, "MCCastingApp.stopWithCompletionBlock called"); VerifyOrReturn(_workQueue != nil && _clientQueue != nil, dispatch_async(self->_clientQueue, ^{ - completion([MTRErrorUtils NSErrorFromChipError:CHIP_ERROR_INCORRECT_STATE]); + completion([MCErrorUtils NSErrorFromChipError:CHIP_ERROR_INCORRECT_STATE]); })); dispatch_async(_workQueue, ^{ __block CHIP_ERROR err = matter::casting::core::CastingApp::GetInstance()->Stop(); dispatch_async(self->_clientQueue, ^{ - completion([MTRErrorUtils NSErrorFromChipError:err]); + completion([MCErrorUtils NSErrorFromChipError:err]); }); }); } @@ -150,22 +150,22 @@ - (bool)isRunning - (NSError *)ShutdownAllSubscriptions { - ChipLogProgress(AppServer, "MTRCastingApp.ShutdownAllSubscriptions called"); + ChipLogProgress(AppServer, "MCCastingApp.ShutdownAllSubscriptions called"); __block CHIP_ERROR err = CHIP_NO_ERROR; dispatch_sync(_workQueue, ^{ err = matter::casting::core::CastingApp::GetInstance()->ShutdownAllSubscriptions(); }); - return [MTRErrorUtils NSErrorFromChipError:err]; + return [MCErrorUtils NSErrorFromChipError:err]; } - (NSError *)ClearCache { - ChipLogProgress(AppServer, "MTRCastingApp.ClearCache called"); + ChipLogProgress(AppServer, "MCCastingApp.ClearCache called"); __block CHIP_ERROR err = CHIP_NO_ERROR; dispatch_sync(_workQueue, ^{ err = matter::casting::core::CastingApp::GetInstance()->ClearCache(); }); - return [MTRErrorUtils NSErrorFromChipError:err]; + return [MCErrorUtils NSErrorFromChipError:err]; } @end diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRCastingPlayer.h b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCastingPlayer.h similarity index 87% rename from examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRCastingPlayer.h rename to examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCastingPlayer.h index 5827e652d6a60c..4259fe53cc7121 100644 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRCastingPlayer.h +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCastingPlayer.h @@ -15,20 +15,20 @@ * limitations under the License. */ -#import "MTREndpointFilter.h" +#import "MCEndpointFilter.h" #import -#ifndef MTRCastingPlayer_h -#define MTRCastingPlayer_h +#ifndef MCCastingPlayer_h +#define MCCastingPlayer_h -@class MTREndpoint; +@class MCEndpoint; /** - * @brief MTRCastingPlayer represents a Matter commissioner that is able to play media to a physical + * @brief MCCastingPlayer represents a Matter commissioner that is able to play media to a physical * output or to a display screen which is part of the device. */ -@interface MTRCastingPlayer : NSObject +@interface MCCastingPlayer : NSObject + (NSInteger)kMinCommissioningWindowTimeoutSec; @@ -45,7 +45,7 @@ * Commissioning, in case the desired Endpoint is not found in the on-device cached information about the CastingPlayer * (if any) */ -- (void)verifyOrEstablishConnectionWithCompletionBlock:(void (^_Nonnull)(NSError * _Nullable))completion timeout:(long long)timeout desiredEndpointFilter:(MTREndpointFilter * _Nullable)desiredEndpointFilter; +- (void)verifyOrEstablishConnectionWithCompletionBlock:(void (^_Nonnull)(NSError * _Nullable))completion timeout:(long long)timeout desiredEndpointFilter:(MCEndpointFilter * _Nullable)desiredEndpointFilter; /** * @brief (async) Verifies that a connection exists with this CastingPlayer, or triggers a new session request. If the @@ -58,7 +58,7 @@ * Commissioning, in case the desired Endpoint is not found in the on-device cached information about the CastingPlayer * (if any) */ -- (void)verifyOrEstablishConnectionWithCompletionBlock:(void (^_Nonnull)(NSError * _Nullable))completion desiredEndpointFilter:(MTREndpointFilter * _Nullable)desiredEndpointFilter; +- (void)verifyOrEstablishConnectionWithCompletionBlock:(void (^_Nonnull)(NSError * _Nullable))completion desiredEndpointFilter:(MCEndpointFilter * _Nullable)desiredEndpointFilter; /** * @brief Sets the internal connection state of this CastingPlayer to "disconnected" @@ -73,11 +73,11 @@ - (NSArray * _Nonnull)ipAddresses; // TODO -// - (NSArray * _Nonnull)endpoints; +// - (NSArray * _Nonnull)endpoints; - (nonnull instancetype)init UNAVAILABLE_ATTRIBUTE; + (nonnull instancetype)new UNAVAILABLE_ATTRIBUTE; @end -#endif /* MTRCastingPlayer_h */ +#endif /* MCCastingPlayer_h */ diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRCastingPlayer.mm b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCastingPlayer.mm similarity index 76% rename from examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRCastingPlayer.mm rename to examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCastingPlayer.mm index 04286426dde6c1..40ea160d5abc3b 100644 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRCastingPlayer.mm +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCastingPlayer.mm @@ -15,22 +15,22 @@ * limitations under the License. */ -#import "MTRCastingPlayer.h" +#import "MCCastingPlayer.h" -#import "MTRCastingApp.h" -#import "MTRErrorUtils.h" +#import "MCCastingApp.h" +#import "MCErrorUtils.h" #import "core/CastingPlayer.h" #import -@interface MTRCastingPlayer () +@interface MCCastingPlayer () @property (nonatomic, readwrite) matter::casting::memory::Strong cppCastingPlayer; @end -@implementation MTRCastingPlayer +@implementation MCCastingPlayer static const NSInteger kMinCommissioningWindowTimeoutSec = matter::casting::core::kCommissioningWindowTimeoutSec; @@ -39,17 +39,17 @@ + (NSInteger)kMinCommissioningWindowTimeoutSec return kMinCommissioningWindowTimeoutSec; } -- (void)verifyOrEstablishConnectionWithCompletionBlock:(void (^_Nonnull)(NSError * _Nullable))completion desiredEndpointFilter:(MTREndpointFilter * _Nullable)desiredEndpointFilter +- (void)verifyOrEstablishConnectionWithCompletionBlock:(void (^_Nonnull)(NSError * _Nullable))completion desiredEndpointFilter:(MCEndpointFilter * _Nullable)desiredEndpointFilter { [self verifyOrEstablishConnectionWithCompletionBlock:completion timeout:kMinCommissioningWindowTimeoutSec desiredEndpointFilter:desiredEndpointFilter]; } -- (void)verifyOrEstablishConnectionWithCompletionBlock:(void (^_Nonnull)(NSError * _Nullable))completion timeout:(long long)timeout desiredEndpointFilter:(MTREndpointFilter * _Nullable)desiredEndpointFilter +- (void)verifyOrEstablishConnectionWithCompletionBlock:(void (^_Nonnull)(NSError * _Nullable))completion timeout:(long long)timeout desiredEndpointFilter:(MCEndpointFilter * _Nullable)desiredEndpointFilter { - ChipLogProgress(AppServer, "MTRCastingPlayer.verifyOrEstablishConnectionWithCompletionBlock called"); - VerifyOrReturn([[MTRCastingApp getSharedInstance] isRunning], ChipLogError(AppServer, "MTRCastingApp NOT running")); + ChipLogProgress(AppServer, "MCCastingPlayer.verifyOrEstablishConnectionWithCompletionBlock called"); + VerifyOrReturn([[MCCastingApp getSharedInstance] isRunning], ChipLogError(AppServer, "MCCastingApp NOT running")); - dispatch_queue_t workQueue = [[MTRCastingApp getSharedInstance] getWorkQueue]; + dispatch_queue_t workQueue = [[MCCastingApp getSharedInstance] getWorkQueue]; dispatch_sync(workQueue, ^{ __block matter::casting::core::EndpointFilter cppDesiredEndpointFilter; if (desiredEndpointFilter != nil) { @@ -59,9 +59,9 @@ - (void)verifyOrEstablishConnectionWithCompletionBlock:(void (^_Nonnull)(NSError _cppCastingPlayer->VerifyOrEstablishConnection( [completion](CHIP_ERROR err, matter::casting::core::CastingPlayer * castingPlayer) { - dispatch_queue_t clientQueue = [[MTRCastingApp getSharedInstance] getClientQueue]; + dispatch_queue_t clientQueue = [[MCCastingApp getSharedInstance] getClientQueue]; dispatch_async(clientQueue, ^{ - completion(err == CHIP_NO_ERROR ? nil : [MTRErrorUtils NSErrorFromChipError:err]); + completion(err == CHIP_NO_ERROR ? nil : [MCErrorUtils NSErrorFromChipError:err]); }); }, timeout, cppDesiredEndpointFilter); }); @@ -69,10 +69,10 @@ - (void)verifyOrEstablishConnectionWithCompletionBlock:(void (^_Nonnull)(NSError - (void)disconnect { - ChipLogProgress(AppServer, "MTRCastingPlayer.disconnect called"); - VerifyOrReturn([[MTRCastingApp getSharedInstance] isRunning], ChipLogError(AppServer, "MTRCastingApp NOT running")); + ChipLogProgress(AppServer, "MCCastingPlayer.disconnect called"); + VerifyOrReturn([[MCCastingApp getSharedInstance] isRunning], ChipLogError(AppServer, "MCCastingApp NOT running")); - dispatch_queue_t workQueue = [[MTRCastingApp getSharedInstance] getWorkQueue]; + dispatch_queue_t workQueue = [[MCCastingApp getSharedInstance] getWorkQueue]; dispatch_sync(workQueue, ^{ _cppCastingPlayer->Disconnect(); }); @@ -129,12 +129,12 @@ - (NSArray * _Nonnull)ipAddresses } // TODO convert to Obj-C endpoints and return -/*- (NSArray * _Nonnull)endpoints +/*- (NSArray * _Nonnull)endpoints { return [NSMutableArray new]; }*/ -- (BOOL)isEqualToMTRCastingPlayer:(MTRCastingPlayer * _Nullable)other +- (BOOL)isEqualToMCCastingPlayer:(MCCastingPlayer * _Nullable)other { return [self.identifier isEqualToString:other.identifier]; } @@ -149,11 +149,11 @@ - (BOOL)isEqual:(id _Nullable)other return YES; } - if (![other isKindOfClass:[MTRCastingPlayer class]]) { + if (![other isKindOfClass:[MCCastingPlayer class]]) { return NO; } - return [self isEqualToMTRCastingPlayer:(MTRCastingPlayer *) other]; + return [self isEqualToMCCastingPlayer:(MCCastingPlayer *) other]; } - (NSUInteger)hash diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCastingPlayerDiscovery.h b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCastingPlayerDiscovery.h new file mode 100644 index 00000000000000..badb88591d0b8d --- /dev/null +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCastingPlayerDiscovery.h @@ -0,0 +1,85 @@ +/** + * + * Copyright (c) 2020-2023 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import "MCCastingPlayer.h" +#import "MatterError.h" + +#ifndef MCCastingPlayerDiscovery_h +#define MCCastingPlayerDiscovery_h + +/** + * MCCastingPlayerDiscovery sends notification with ADD_CASTING_PLAYER_NOTIFICATION_NAME + * through the NSNotificationCenter if a new MCCastingPlayer is added to the network + */ +extern NSString * _Nonnull const ADD_CASTING_PLAYER_NOTIFICATION_NAME; + +/** + * MCCastingPlayerDiscovery sends notification with REMOVE_CASTING_PLAYER_NOTIFICATION_NAME + * through the NSNotificationCenter if a MCCastingPlayer is removed from the network + */ +extern NSString * _Nonnull const REMOVE_CASTING_PLAYER_NOTIFICATION_NAME; + +/** + * MCCastingPlayerDiscovery sends notification with UPDATE_CASTING_PLAYER_NOTIFICATION_NAME + * through the NSNotificationCenter if a previously added MCCastingPlayer is updated + */ +extern NSString * _Nonnull const UPDATE_CASTING_PLAYER_NOTIFICATION_NAME; + +/** + * MCCastingPlayerDiscovery sends ADD / REMOVE / UPDATE notifications through the + * NSNotificationCenter with userInfo set to an NSDictionary that has CASTING_PLAYER_KEY as the + * key to a MCCastingPlayer object as value. + */ +extern NSString * _Nonnull const CASTING_PLAYER_KEY; + +/** + * @brief MCCastingPlayerDiscovery is a singleton utility class for discovering MCCastingPlayers. + */ +@interface MCCastingPlayerDiscovery : NSObject ++ (MCCastingPlayerDiscovery * _Nonnull)sharedInstance; + +- (nonnull instancetype)init UNAVAILABLE_ATTRIBUTE; ++ (nonnull instancetype)new UNAVAILABLE_ATTRIBUTE; + +@property (nonatomic, strong) NSArray * _Nonnull castingPlayers; + +/** + * @brief Starts the discovery for MCCastingPlayers + * + * @return Returns nil if discovery for CastingPlayers started successfully, NSError * describing the error otherwise. + */ +- (NSError * _Nullable)start; + +/** + * @brief Starts the discovery for MCCastingPlayers + * + * @param filterBydeviceType if passed as a non-zero value, MCCastingPlayerDiscovery will only discover + * MCCastingPlayers whose deviceType matches filterBydeviceType + * @return Returns nil if discovery for MCCastingPlayers started successfully, NSError * describing the error otherwise. + */ +- (NSError * _Nullable)start:(const uint32_t)filterBydeviceType; + +/** + * @brief Stop the discovery for MCCastingPlayers + * + * @return Returns nil if discovery for MCCastingPlayers stopped successfully, NSError * describing the error otherwise. + */ +- (NSError * _Nullable)stop; + +@end + +#endif /* MCCastingPlayerDiscovery_h */ diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRCastingPlayerDiscovery.mm b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCastingPlayerDiscovery.mm similarity index 55% rename from examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRCastingPlayerDiscovery.mm rename to examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCastingPlayerDiscovery.mm index d840f46495717f..b69817266c6edc 100644 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRCastingPlayerDiscovery.mm +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCastingPlayerDiscovery.mm @@ -15,12 +15,12 @@ * limitations under the License. */ -#import "MTRCastingPlayerDiscovery.h" +#import "MCCastingPlayerDiscovery.h" -#import "MTRCastingApp.h" +#import "MCCastingApp.h" -#import "MTRCastingPlayer.mm" -#import "MTRErrorUtils.h" +#import "MCCastingPlayer.mm" +#import "MCErrorUtils.h" #include "core/CastingPlayer.h" #include "core/CastingPlayerDiscovery.h" @@ -35,18 +35,18 @@ /** * @brief Singleton that reacts to CastingPlayer discovery results */ -class MTRDiscoveryDelegateImpl : public matter::casting::core::DiscoveryDelegate { +class MCDiscoveryDelegateImpl : public matter::casting::core::DiscoveryDelegate { private: - MTRDiscoveryDelegateImpl() {}; - static MTRDiscoveryDelegateImpl * _discoveryDelegateImpl; + MCDiscoveryDelegateImpl() {}; + static MCDiscoveryDelegateImpl * _discoveryDelegateImpl; public: - static MTRDiscoveryDelegateImpl * GetInstance(); + static MCDiscoveryDelegateImpl * GetInstance(); void HandleOnAdded(matter::casting::memory::Strong player) override; void HandleOnUpdated(matter::casting::memory::Strong player) override; }; -@implementation MTRCastingPlayerDiscovery +@implementation MCCastingPlayerDiscovery NSString * const ADD_CASTING_PLAYER_NOTIFICATION_NAME = @"didAddCastingPlayersNotification"; NSString * const REMOVE_CASTING_PLAYER_NOTIFICATION_NAME = @"didRemoveCastingPlayersNotification"; @@ -57,17 +57,17 @@ @implementation MTRCastingPlayerDiscovery { self = [super init]; if (self) { - dispatch_queue_t workQueue = [[MTRCastingApp getSharedInstance] getWorkQueue]; + dispatch_queue_t workQueue = [[MCCastingApp getSharedInstance] getWorkQueue]; dispatch_sync(workQueue, ^{ - core::CastingPlayerDiscovery::GetInstance()->SetDelegate(MTRDiscoveryDelegateImpl::GetInstance()); + core::CastingPlayerDiscovery::GetInstance()->SetDelegate(MCDiscoveryDelegateImpl::GetInstance()); }); } return self; } -+ (MTRCastingPlayerDiscovery *)sharedInstance ++ (MCCastingPlayerDiscovery *)sharedInstance { - static MTRCastingPlayerDiscovery * instance = nil; + static MCCastingPlayerDiscovery * instance = nil; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ instance = [[self alloc] init]; @@ -82,63 +82,63 @@ - (NSError *)start - (NSError *)start:(const uint32_t)filterBydeviceType { - ChipLogProgress(AppServer, "MTRCastingPlayerDiscovery.start called"); - VerifyOrReturnValue([[MTRCastingApp getSharedInstance] isRunning], [MTRErrorUtils NSErrorFromChipError:CHIP_ERROR_INCORRECT_STATE]); + ChipLogProgress(AppServer, "MCCastingPlayerDiscovery.start called"); + VerifyOrReturnValue([[MCCastingApp getSharedInstance] isRunning], [MCErrorUtils NSErrorFromChipError:CHIP_ERROR_INCORRECT_STATE]); - dispatch_queue_t workQueue = [[MTRCastingApp getSharedInstance] getWorkQueue]; + dispatch_queue_t workQueue = [[MCCastingApp getSharedInstance] getWorkQueue]; __block CHIP_ERROR err = CHIP_NO_ERROR; dispatch_sync(workQueue, ^{ err = core::CastingPlayerDiscovery::GetInstance()->StartDiscovery(filterBydeviceType); }); - return [MTRErrorUtils NSErrorFromChipError:err]; + return [MCErrorUtils NSErrorFromChipError:err]; } - (NSError *)stop { - ChipLogProgress(AppServer, "MTRCastingPlayerDiscovery.stop called"); - VerifyOrReturnValue([[MTRCastingApp getSharedInstance] isRunning], [MTRErrorUtils NSErrorFromChipError:CHIP_ERROR_INCORRECT_STATE]); + ChipLogProgress(AppServer, "MCCastingPlayerDiscovery.stop called"); + VerifyOrReturnValue([[MCCastingApp getSharedInstance] isRunning], [MCErrorUtils NSErrorFromChipError:CHIP_ERROR_INCORRECT_STATE]); - dispatch_queue_t workQueue = [[MTRCastingApp getSharedInstance] getWorkQueue]; + dispatch_queue_t workQueue = [[MCCastingApp getSharedInstance] getWorkQueue]; __block CHIP_ERROR err = CHIP_NO_ERROR; dispatch_sync(workQueue, ^{ err = core::CastingPlayerDiscovery::GetInstance()->StopDiscovery(); }); - return [MTRErrorUtils NSErrorFromChipError:err]; + return [MCErrorUtils NSErrorFromChipError:err]; } @end -MTRDiscoveryDelegateImpl * MTRDiscoveryDelegateImpl::_discoveryDelegateImpl = nullptr; +MCDiscoveryDelegateImpl * MCDiscoveryDelegateImpl::_discoveryDelegateImpl = nullptr; -MTRDiscoveryDelegateImpl * MTRDiscoveryDelegateImpl::GetInstance() +MCDiscoveryDelegateImpl * MCDiscoveryDelegateImpl::GetInstance() { if (_discoveryDelegateImpl == nullptr) { - _discoveryDelegateImpl = new MTRDiscoveryDelegateImpl(); + _discoveryDelegateImpl = new MCDiscoveryDelegateImpl(); } return _discoveryDelegateImpl; } -void MTRDiscoveryDelegateImpl::HandleOnAdded(matter::casting::memory::Strong castingPlayer) +void MCDiscoveryDelegateImpl::HandleOnAdded(matter::casting::memory::Strong castingPlayer) { - ChipLogProgress(AppServer, "MTRDiscoveryDelegateImpl::HandleOnAdded called with CastingPlayer ID: %s", castingPlayer->GetId()); - dispatch_queue_t clientQueue = [[MTRCastingApp getSharedInstance] getClientQueue]; - VerifyOrReturn(clientQueue != nil, ChipLogError(AppServer, "MTRDiscoveryDelegateImpl::HandleOnAdded ClientQueue was nil")); - VerifyOrReturn(castingPlayer != nil, ChipLogError(AppServer, "MTRDiscoveryDelegateImpl::HandleOnAdded Cpp CastingPlayer was nil")); + ChipLogProgress(AppServer, "MCDiscoveryDelegateImpl::HandleOnAdded called with CastingPlayer ID: %s", castingPlayer->GetId()); + dispatch_queue_t clientQueue = [[MCCastingApp getSharedInstance] getClientQueue]; + VerifyOrReturn(clientQueue != nil, ChipLogError(AppServer, "MCDiscoveryDelegateImpl::HandleOnAdded ClientQueue was nil")); + VerifyOrReturn(castingPlayer != nil, ChipLogError(AppServer, "MCDiscoveryDelegateImpl::HandleOnAdded Cpp CastingPlayer was nil")); dispatch_async(clientQueue, ^{ - NSDictionary * dictionary = @ { CASTING_PLAYER_KEY : [[MTRCastingPlayer alloc] initWithCppCastingPlayer:castingPlayer] }; + NSDictionary * dictionary = @ { CASTING_PLAYER_KEY : [[MCCastingPlayer alloc] initWithCppCastingPlayer:castingPlayer] }; [[NSNotificationCenter defaultCenter] postNotificationName:ADD_CASTING_PLAYER_NOTIFICATION_NAME object:nil userInfo:dictionary]; }); } -void MTRDiscoveryDelegateImpl::HandleOnUpdated(matter::casting::memory::Strong castingPlayer) +void MCDiscoveryDelegateImpl::HandleOnUpdated(matter::casting::memory::Strong castingPlayer) { - ChipLogProgress(AppServer, "MTRDiscoveryDelegateImpl::HandleOnUpdated called with CastingPlayer ID: %s", castingPlayer->GetId()); - dispatch_queue_t clientQueue = [[MTRCastingApp getSharedInstance] getClientQueue]; + ChipLogProgress(AppServer, "MCDiscoveryDelegateImpl::HandleOnUpdated called with CastingPlayer ID: %s", castingPlayer->GetId()); + dispatch_queue_t clientQueue = [[MCCastingApp getSharedInstance] getClientQueue]; VerifyOrReturn(clientQueue != nil); dispatch_async(clientQueue, ^{ - NSDictionary * dictionary = @ { CASTING_PLAYER_KEY : [[MTRCastingPlayer alloc] initWithCppCastingPlayer:castingPlayer] }; + NSDictionary * dictionary = @ { CASTING_PLAYER_KEY : [[MCCastingPlayer alloc] initWithCppCastingPlayer:castingPlayer] }; [[NSNotificationCenter defaultCenter] postNotificationName:UPDATE_CASTING_PLAYER_NOTIFICATION_NAME object:nil userInfo:dictionary]; }); } diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRCommissionableData.h b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCommissionableData.h similarity index 90% rename from examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRCommissionableData.h rename to examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCommissionableData.h index 59eb8acdb9eb53..5bbd1b05c54650 100644 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRCommissionableData.h +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCommissionableData.h @@ -17,10 +17,10 @@ #import -#ifndef MTRCommissionableData_h -#define MTRCommissionableData_h +#ifndef MCCommissionableData_h +#define MCCommissionableData_h -@interface MTRCommissionableData : NSObject +@interface MCCommissionableData : NSObject @property (nonatomic, readonly) uint32_t passcode; @@ -40,4 +40,4 @@ @end -#endif /* MTRCommissionableData_h */ +#endif /* MCCommissionableData_h */ diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRCommissionableData.mm b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCommissionableData.mm similarity index 94% rename from examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRCommissionableData.mm rename to examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCommissionableData.mm index 85858b36dffbd1..d4721c0c3844d7 100644 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRCommissionableData.mm +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCommissionableData.mm @@ -15,10 +15,10 @@ * limitations under the License. */ -#import "MTRCommissionableData.h" +#import "MCCommissionableData.h" #import -@implementation MTRCommissionableData +@implementation MCCommissionableData - (instancetype)initWithPasscode:(uint32_t)passcode discriminator:(uint16_t)discriminator diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRCommissionableDataProvider.h b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCommissionableDataProvider.h similarity index 85% rename from examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRCommissionableDataProvider.h rename to examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCommissionableDataProvider.h index 8112207a003028..96adcd5685f58e 100644 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRCommissionableDataProvider.h +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCommissionableDataProvider.h @@ -18,7 +18,7 @@ #pragma once -#import "MTRDataSource.h" +#import "MCDataSource.h" #include #include @@ -26,17 +26,17 @@ #include #include -#ifndef MTRCommissionableDataProvider_h -#define MTRCommissionableDataProvider_h +#ifndef MCCommissionableDataProvider_h +#define MCCommissionableDataProvider_h namespace matter { namespace casting { namespace support { -class MTRCommissionableDataProvider : public chip::DeviceLayer::CommissionableDataProvider +class MCCommissionableDataProvider : public chip::DeviceLayer::CommissionableDataProvider { public: - CHIP_ERROR Initialize(id dataSource); + CHIP_ERROR Initialize(id dataSource); CHIP_ERROR GetSetupDiscriminator(uint16_t & setupDiscriminator) override; CHIP_ERROR SetSetupDiscriminator(uint16_t setupDiscriminator) override { @@ -54,7 +54,7 @@ class MTRCommissionableDataProvider : public chip::DeviceLayer::CommissionableDa } private: - id mDataSource = nullptr; + id mDataSource = nullptr; bool mFirstUpdated = false; std::vector mSerializedPaseVerifier; @@ -68,4 +68,4 @@ class MTRCommissionableDataProvider : public chip::DeviceLayer::CommissionableDa }; // namespace casting }; // namespace matter -#endif /* MTRCommissionableDataProvider_h */ +#endif /* MCCommissionableDataProvider_h */ diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRCommissionableDataProvider.mm b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCommissionableDataProvider.mm similarity index 86% rename from examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRCommissionableDataProvider.mm rename to examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCommissionableDataProvider.mm index 6a6047984c1a8a..83159b2801f09a 100644 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRCommissionableDataProvider.mm +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCommissionableDataProvider.mm @@ -16,9 +16,9 @@ * limitations under the License. */ -#import "MTRCommissionableDataProvider.h" +#import "MCCommissionableDataProvider.h" -#import "MTRCommissionableData.h" +#import "MCCommissionableData.h" #include #include @@ -48,14 +48,14 @@ CHIP_ERROR GeneratePaseSalt(std::vector & spake2pSaltVector) return DRBG_get_bytes(spake2pSaltVector.data(), spake2pSaltVector.size()); } - CHIP_ERROR MTRCommissionableDataProvider::Initialize(id dataSource) + CHIP_ERROR MCCommissionableDataProvider::Initialize(id dataSource) { VerifyOrReturnLogError(dataSource != nil, CHIP_ERROR_INVALID_ARGUMENT); VerifyOrReturnLogError(mDataSource == nullptr, CHIP_ERROR_INCORRECT_STATE); mDataSource = dataSource; - MTRCommissionableData * commissionableData = - [mDataSource castingAppDidReceiveRequestForCommissionableData:@"MTRCommissionableDataProvider.Initialize()"]; + MCCommissionableData * commissionableData = + [mDataSource castingAppDidReceiveRequestForCommissionableData:@"MCCommissionableDataProvider.Initialize()"]; VerifyOrReturnLogError(commissionableData.discriminator <= chip::kMaxDiscriminatorValue, CHIP_ERROR_INVALID_ARGUMENT); @@ -96,7 +96,7 @@ CHIP_ERROR GeneratePaseSalt(std::vector & spake2pSaltVector) // read salt from paramter if provided or generate one std::vector spake2pSalt(chip::Crypto::kSpake2p_Max_PBKDF_Salt_Length); if (!havePaseSalt) { - ChipLogProgress(Support, "MTRCommissionableDataProvider didn't get a PASE salt, generating one."); + ChipLogProgress(Support, "MCCommissionableDataProvider didn't get a PASE salt, generating one."); err = GeneratePaseSalt(spake2pSalt); VerifyOrReturnLogError(err == CHIP_NO_ERROR, err); } else { @@ -162,24 +162,24 @@ CHIP_ERROR GeneratePaseSalt(std::vector & spake2pSaltVector) return CHIP_NO_ERROR; } - CHIP_ERROR MTRCommissionableDataProvider::GetSetupDiscriminator(uint16_t & setupDiscriminator) + CHIP_ERROR MCCommissionableDataProvider::GetSetupDiscriminator(uint16_t & setupDiscriminator) { VerifyOrReturnError(mFirstUpdated, CHIP_ERROR_INCORRECT_STATE); setupDiscriminator = mDiscriminator; return CHIP_NO_ERROR; } - CHIP_ERROR MTRCommissionableDataProvider::GetSpake2pIterationCount(uint32_t & iterationCount) + CHIP_ERROR MCCommissionableDataProvider::GetSpake2pIterationCount(uint32_t & iterationCount) { - ChipLogProgress(AppServer, "MTRCommissionableDataProvider::GetSpake2pIterationCount called"); + ChipLogProgress(AppServer, "MCCommissionableDataProvider::GetSpake2pIterationCount called"); VerifyOrReturnLogError(mFirstUpdated, CHIP_ERROR_INCORRECT_STATE); iterationCount = mPaseIterationCount; return CHIP_NO_ERROR; } - CHIP_ERROR MTRCommissionableDataProvider::GetSpake2pSalt(chip::MutableByteSpan & saltBuf) + CHIP_ERROR MCCommissionableDataProvider::GetSpake2pSalt(chip::MutableByteSpan & saltBuf) { - ChipLogProgress(AppServer, "MTRCommissionableDataProvider::GetSpake2pSalt called"); + ChipLogProgress(AppServer, "MCCommissionableDataProvider::GetSpake2pSalt called"); VerifyOrReturnError(mFirstUpdated, CHIP_ERROR_INCORRECT_STATE); VerifyOrReturnError(saltBuf.size() >= kSpake2p_Max_PBKDF_Salt_Length, CHIP_ERROR_BUFFER_TOO_SMALL); @@ -189,9 +189,9 @@ CHIP_ERROR GeneratePaseSalt(std::vector & spake2pSaltVector) return CHIP_NO_ERROR; } - CHIP_ERROR MTRCommissionableDataProvider::GetSpake2pVerifier(chip::MutableByteSpan & verifierBuf, size_t & outVerifierLen) + CHIP_ERROR MCCommissionableDataProvider::GetSpake2pVerifier(chip::MutableByteSpan & verifierBuf, size_t & outVerifierLen) { - ChipLogProgress(AppServer, "MTRCommissionableDataProvider::GetSpake2pVerifier called"); + ChipLogProgress(AppServer, "MCCommissionableDataProvider::GetSpake2pVerifier called"); VerifyOrReturnError(mFirstUpdated, CHIP_ERROR_INCORRECT_STATE); // By now, serialized verifier from Init should be correct size @@ -205,9 +205,9 @@ CHIP_ERROR GeneratePaseSalt(std::vector & spake2pSaltVector) return CHIP_NO_ERROR; } - CHIP_ERROR MTRCommissionableDataProvider::GetSetupPasscode(uint32_t & setupPasscode) + CHIP_ERROR MCCommissionableDataProvider::GetSetupPasscode(uint32_t & setupPasscode) { - ChipLogProgress(AppServer, "MTRCommissionableDataProvider::GetSetupPasscode called"); + ChipLogProgress(AppServer, "MCCommissionableDataProvider::GetSetupPasscode called"); VerifyOrReturnError(mFirstUpdated, CHIP_ERROR_INCORRECT_STATE); // Pretend not implemented if we don't have a passcode value externally set @@ -216,7 +216,7 @@ CHIP_ERROR GeneratePaseSalt(std::vector & spake2pSaltVector) } setupPasscode = mSetupPasscode.Value(); - ChipLogProgress(AppServer, "MTRCommissionableDataProvider::GetSetupPasscode returning value %d", setupPasscode); + ChipLogProgress(AppServer, "MCCommissionableDataProvider::GetSetupPasscode returning value %d", setupPasscode); return CHIP_NO_ERROR; } diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRCommonCaseDeviceServerInitParamsProvider.h b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCommonCaseDeviceServerInitParamsProvider.h similarity index 82% rename from examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRCommonCaseDeviceServerInitParamsProvider.h rename to examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCommonCaseDeviceServerInitParamsProvider.h index a22113074e31f1..d510a0ec48db2b 100644 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRCommonCaseDeviceServerInitParamsProvider.h +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCommonCaseDeviceServerInitParamsProvider.h @@ -17,13 +17,13 @@ #include "core/Types.h" -#ifndef MTRCommonCaseDeviceServerInitParamsProvider_h -#define MTRCommonCaseDeviceServerInitParamsProvider_h +#ifndef MCCommonCaseDeviceServerInitParamsProvider_h +#define MCCommonCaseDeviceServerInitParamsProvider_h /** * @brief Provides the ServerInitParams required to start the CastingApp, which in turn starts the Matter server */ -class MTRCommonCaseDeviceServerInitParamsProvider : public matter::casting::support::ServerInitParamsProvider +class MCCommonCaseDeviceServerInitParamsProvider : public matter::casting::support::ServerInitParamsProvider { private: // For this example, we'll use CommonCaseDeviceServerInitParams @@ -39,4 +39,4 @@ class MTRCommonCaseDeviceServerInitParamsProvider : public matter::casting::supp } }; -#endif /* MTRCommonCaseDeviceServerInitParamsProvider_h */ +#endif /* MCCommonCaseDeviceServerInitParamsProvider_h */ diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRCryptoUtils.h b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCryptoUtils.h similarity index 93% rename from examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRCryptoUtils.h rename to examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCryptoUtils.h index e624d04ffaa848..bab8330e790d73 100644 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRCryptoUtils.h +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCryptoUtils.h @@ -19,10 +19,10 @@ #import -#ifndef MTRCryptoUtils_h -#define MTRCryptoUtils_h +#ifndef MCCryptoUtils_h +#define MCCryptoUtils_h -@interface MTRCryptoUtils : NSObject +@interface MCCryptoUtils : NSObject /** * @brief Convert an ASN.1 DER signature (per X9.62) as used by TLS libraries to SEC1 raw format @@ -44,4 +44,4 @@ @end -#endif /* MTRCryptoUtils_h */ +#endif /* MCCryptoUtils_h */ diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRCryptoUtils.mm b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCryptoUtils.mm similarity index 94% rename from examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRCryptoUtils.mm rename to examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCryptoUtils.mm index 562388d7d9dc73..101a725ce6cccd 100644 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRCryptoUtils.mm +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCCryptoUtils.mm @@ -15,8 +15,8 @@ * limitations under the License. */ -#import "MTRCryptoUtils.h" -#import "MTRErrorUtils.h" +#import "MCCryptoUtils.h" +#import "MCErrorUtils.h" #include #include @@ -25,7 +25,7 @@ #include -@implementation MTRCryptoUtils +@implementation MCCryptoUtils + (MatterError *)ecdsaAsn1SignatureToRawWithFeLengthBytes:(NSUInteger)feLengthBytes asn1Signature:(CFDataRef)asn1Signature outRawSignature:(NSData **)outRawSignature { @@ -44,7 +44,7 @@ + (MatterError *)ecdsaAsn1SignatureToRawWithFeLengthBytes:(NSUInteger)feLengthBy CHIP_ERROR err = chip::Crypto::EcdsaAsn1SignatureToRaw(feLengthBytes, chip::ByteSpan(asn1SignatureByteSpan.data(), asn1SignatureByteSpan.size()), rawSignatureMutableByteSpan); if (err != CHIP_NO_ERROR) { ChipLogError(AppServer, "chip::Crypto::EcdsaAsn1SignatureToRaw() failed"); - return [MTRErrorUtils MatterErrorFromChipError:err]; + return [MCErrorUtils MatterErrorFromChipError:err]; } // copy from rawSignatureMutableByteSpan into *outRawSignature diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRDataSource.h b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCDataSource.h similarity index 70% rename from examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRDataSource.h rename to examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCDataSource.h index 86156efb7462e0..6339de82bc2695 100644 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRDataSource.h +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCDataSource.h @@ -15,14 +15,14 @@ * limitations under the License. */ -#import "MTRCommissionableData.h" -#import "MTRDeviceAttestationCredentials.h" +#import "MCCommissionableData.h" +#import "MCDeviceAttestationCredentials.h" #import "MatterError.h" -#ifndef MTRDataSource_h -#define MTRDataSource_h +#ifndef MCDataSource_h +#define MCDataSource_h -@protocol MTRDataSource +@protocol MCDataSource /** * @brief Queue used when calling the client code on completion blocks from any MatterTvCastingBridge API @@ -30,20 +30,20 @@ - (dispatch_queue_t _Nonnull)clientQueue; /** - * @brief Provide UniqueId used to generate the RotatingDeviceId advertised during commissioning by the MTRCastingApp + * @brief Provide UniqueId used to generate the RotatingDeviceId advertised during commissioning by the MCCastingApp * Must be at least 16 bytes (i.e. ConfigurationManager::kMinRotatingDeviceIDUniqueIDLength) */ - (NSData * _Nonnull)castingAppDidReceiveRequestForRotatingDeviceIdUniqueId:(id _Nonnull)sender; /** - * @brief Provides MTRCommissionableData (such as setupPasscode, discriminator, etc) used to get the MTRCastingApp commissioned + * @brief Provides MCCommissionableData (such as setupPasscode, discriminator, etc) used to get the MCCastingApp commissioned */ -- (MTRCommissionableData * _Nonnull)castingAppDidReceiveRequestForCommissionableData:(id _Nonnull)sender; +- (MCCommissionableData * _Nonnull)castingAppDidReceiveRequestForCommissionableData:(id _Nonnull)sender; /** - * @brief Provides MTRDeviceAttestationCredentials of the MTRCastingApp used during commissioning + * @brief Provides MCDeviceAttestationCredentials of the MCCastingApp used during commissioning */ -- (MTRDeviceAttestationCredentials * _Nonnull)castingAppDidReceiveRequestForDeviceAttestationCredentials:(id _Nonnull)sender; +- (MCDeviceAttestationCredentials * _Nonnull)castingAppDidReceiveRequestForDeviceAttestationCredentials:(id _Nonnull)sender; /** * @brief Request to signs a message using the device attestation private key @@ -56,4 +56,4 @@ @end -#endif /* MTRDataSource_h */ +#endif /* MCDataSource_h */ diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRDeviceAttestationCredentials.h b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCDeviceAttestationCredentials.h similarity index 59% rename from examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRDeviceAttestationCredentials.h rename to examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCDeviceAttestationCredentials.h index aed7eceedbacdd..12e895fc31b532 100644 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRDeviceAttestationCredentials.h +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCDeviceAttestationCredentials.h @@ -18,10 +18,10 @@ #import #import -#ifndef MTRDeviceAttestationCredentials_h -#define MTRDeviceAttestationCredentials_h +#ifndef MCDeviceAttestationCredentials_h +#define MCDeviceAttestationCredentials_h -@interface MTRDeviceAttestationCredentials : NSObject +@interface MCDeviceAttestationCredentials : NSObject @property (nonatomic, strong, readonly) NSData * _Nonnull certificationDeclaration; @@ -31,12 +31,12 @@ @property (nonatomic, strong, readonly) NSData * _Nonnull productAttestationIntermediateCert; -- (MTRDeviceAttestationCredentials * _Nonnull)initWithCertificationDeclaration:(NSData * _Nonnull)certificationDeclaration - firmwareInformation:(NSData * _Nonnull)firmwareInformation - deviceAttestationCert:(NSData * _Nonnull)deviceAttestationCert - productAttestationIntermediateCert: - (NSData * _Nonnull)productAttestationIntermediateCert; +- (MCDeviceAttestationCredentials * _Nonnull)initWithCertificationDeclaration:(NSData * _Nonnull)certificationDeclaration + firmwareInformation:(NSData * _Nonnull)firmwareInformation + deviceAttestationCert:(NSData * _Nonnull)deviceAttestationCert + productAttestationIntermediateCert: + (NSData * _Nonnull)productAttestationIntermediateCert; @end -#endif /* MTRDeviceAttestationCredentials_h */ +#endif /* MCDeviceAttestationCredentials_h */ diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRDeviceAttestationCredentials.mm b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCDeviceAttestationCredentials.mm similarity index 93% rename from examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRDeviceAttestationCredentials.mm rename to examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCDeviceAttestationCredentials.mm index 1daa18a681c93c..5cf45b8a9ac69c 100644 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRDeviceAttestationCredentials.mm +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCDeviceAttestationCredentials.mm @@ -15,10 +15,10 @@ * limitations under the License. */ -#import "MTRDeviceAttestationCredentials.h" +#import "MCDeviceAttestationCredentials.h" #import -@implementation MTRDeviceAttestationCredentials +@implementation MCDeviceAttestationCredentials - (instancetype)initWithCertificationDeclaration:(NSData * _Nonnull)certificationDeclaration firmwareInformation:(NSData * _Nonnull)firmwareInformation diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRDeviceAttestationCredentialsProvider.h b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCDeviceAttestationCredentialsProvider.h similarity index 77% rename from examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRDeviceAttestationCredentialsProvider.h rename to examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCDeviceAttestationCredentialsProvider.h index e955ac9ee7eb33..00cbf0628ab9f8 100644 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRDeviceAttestationCredentialsProvider.h +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCDeviceAttestationCredentialsProvider.h @@ -15,7 +15,7 @@ * limitations under the License. */ -#import "MTRDataSource.h" +#import "MCDataSource.h" #include #include @@ -24,17 +24,17 @@ #import #include -#ifndef MTRDeviceAttestationCredentialsProvider_h -#define MTRDeviceAttestationCredentialsProvider_h +#ifndef MCDeviceAttestationCredentialsProvider_h +#define MCDeviceAttestationCredentialsProvider_h namespace matter { namespace casting { namespace support { -class MTRDeviceAttestationCredentialsProvider : public chip::Credentials::DeviceAttestationCredentialsProvider +class MCDeviceAttestationCredentialsProvider : public chip::Credentials::DeviceAttestationCredentialsProvider { public: - CHIP_ERROR Initialize(id dataSource); + CHIP_ERROR Initialize(id dataSource); CHIP_ERROR GetCertificationDeclaration(chip::MutableByteSpan & outCertificationDeclaration) override; CHIP_ERROR GetFirmwareInformation(chip::MutableByteSpan & outFirmwareInformation) override; @@ -44,12 +44,12 @@ class MTRDeviceAttestationCredentialsProvider : public chip::Credentials::Device chip::MutableByteSpan & outSignatureBuffer) override; private: - id mDataSource = nullptr; - MTRDeviceAttestationCredentials * mDac = nullptr; + id mDataSource = nullptr; + MCDeviceAttestationCredentials * mDac = nullptr; }; }; // namespace support }; // namespace casting }; // namespace matter -#endif /* MTRDeviceAttestationCredentialsProvider_h */ +#endif /* MCDeviceAttestationCredentialsProvider_h */ diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRDeviceAttestationCredentialsProvider.mm b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCDeviceAttestationCredentialsProvider.mm similarity index 86% rename from examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRDeviceAttestationCredentialsProvider.mm rename to examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCDeviceAttestationCredentialsProvider.mm index 00c4d4102baeac..16a49c76363792 100644 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRDeviceAttestationCredentialsProvider.mm +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCDeviceAttestationCredentialsProvider.mm @@ -15,9 +15,9 @@ * limitations under the License. */ -#import "MTRDeviceAttestationCredentialsProvider.h" +#import "MCDeviceAttestationCredentialsProvider.h" -#import "MTRDeviceAttestationCredentials.h" +#import "MCDeviceAttestationCredentials.h" #include "lib/support/logging/CHIPLogging.h" #include @@ -29,19 +29,19 @@ namespace casting { namespace support { - CHIP_ERROR MTRDeviceAttestationCredentialsProvider::Initialize(id dataSource) + CHIP_ERROR MCDeviceAttestationCredentialsProvider::Initialize(id dataSource) { VerifyOrReturnError(dataSource != nullptr, CHIP_ERROR_INVALID_ARGUMENT); VerifyOrReturnError(mDataSource == nullptr, CHIP_ERROR_INCORRECT_STATE); mDataSource = dataSource; mDac = [mDataSource - castingAppDidReceiveRequestForDeviceAttestationCredentials:@"MTRDeviceAttestationCredentialsProvider.Initialize()"]; + castingAppDidReceiveRequestForDeviceAttestationCredentials:@"MCDeviceAttestationCredentialsProvider.Initialize()"]; return CHIP_NO_ERROR; } - CHIP_ERROR MTRDeviceAttestationCredentialsProvider::GetCertificationDeclaration( + CHIP_ERROR MCDeviceAttestationCredentialsProvider::GetCertificationDeclaration( chip::MutableByteSpan & outCertificationDeclaration) { VerifyOrReturnError(mDac != nullptr, CHIP_ERROR_INCORRECT_STATE); @@ -58,7 +58,7 @@ return CHIP_NO_ERROR; } - CHIP_ERROR MTRDeviceAttestationCredentialsProvider::GetFirmwareInformation(chip::MutableByteSpan & outFirmwareInformation) + CHIP_ERROR MCDeviceAttestationCredentialsProvider::GetFirmwareInformation(chip::MutableByteSpan & outFirmwareInformation) { VerifyOrReturnError(mDac != nullptr, CHIP_ERROR_INCORRECT_STATE); @@ -73,7 +73,7 @@ return CHIP_NO_ERROR; } - CHIP_ERROR MTRDeviceAttestationCredentialsProvider::GetDeviceAttestationCert( + CHIP_ERROR MCDeviceAttestationCredentialsProvider::GetDeviceAttestationCert( chip::MutableByteSpan & outDeviceAttestationCert) { VerifyOrReturnError(mDac != nullptr, CHIP_ERROR_INCORRECT_STATE); @@ -89,7 +89,7 @@ return CHIP_NO_ERROR; } - CHIP_ERROR MTRDeviceAttestationCredentialsProvider::GetProductAttestationIntermediateCert( + CHIP_ERROR MCDeviceAttestationCredentialsProvider::GetProductAttestationIntermediateCert( chip::MutableByteSpan & outProductAttestationIntermediateCert) { VerifyOrReturnError(mDac != nullptr, CHIP_ERROR_INCORRECT_STATE); @@ -106,7 +106,7 @@ return CHIP_NO_ERROR; } - CHIP_ERROR MTRDeviceAttestationCredentialsProvider::SignWithDeviceAttestationKey( + CHIP_ERROR MCDeviceAttestationCredentialsProvider::SignWithDeviceAttestationKey( const chip::ByteSpan & messageToSign, chip::MutableByteSpan & outSignatureBuffer) { VerifyOrReturnError(mDataSource != nullptr, CHIP_ERROR_INCORRECT_STATE); @@ -115,7 +115,7 @@ __block NSData * signedData = [NSData dataWithBytes:outSignatureBuffer.data() length:outSignatureBuffer.size()]; __block MatterError * err = nil; dispatch_sync(mDataSource.clientQueue, ^{ - err = [mDataSource castingApp:@"MTRDeviceAttestationCredentialsProvider.SignWithDeviceAttestationKey()" + err = [mDataSource castingApp:@"MCDeviceAttestationCredentialsProvider.SignWithDeviceAttestationKey()" didReceiveRequestToSignCertificateRequest:csrData outRawSignature:&signedData]; }); diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTREndpointFilter.h b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCEndpointFilter.h similarity index 82% rename from examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTREndpointFilter.h rename to examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCEndpointFilter.h index 821a7ec834f66f..7f6d7e7103b6f6 100644 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTREndpointFilter.h +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCEndpointFilter.h @@ -17,17 +17,17 @@ #import -#ifndef MTREndpointFilter_h -#define MTREndpointFilter_h +#ifndef MCEndpointFilter_h +#define MCEndpointFilter_h /** - * @brief Describes a MTREndpoint that the client wants to connect to + * @brief Describes a MCEndpoint that the client wants to connect to */ -@interface MTREndpointFilter : NSObject +@interface MCEndpointFilter : NSObject // value of 0 means unspecified @property (nonatomic) uint16_t vendorId; @property (nonatomic) uint16_t productId; // std::vector requiredDeviceTypes; @end -#endif /* MTREndpointFilter_h */ +#endif /* MCEndpointFilter_h */ diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTREndpointFilter.m b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCEndpointFilter.m similarity index 91% rename from examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTREndpointFilter.m rename to examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCEndpointFilter.m index b060a5deeba3cf..9c25048a3966fe 100644 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTREndpointFilter.m +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCEndpointFilter.m @@ -15,8 +15,8 @@ * limitations under the License. */ -#import "MTREndpointFilter.h" +#import "MCEndpointFilter.h" -@implementation MTREndpointFilter +@implementation MCEndpointFilter @end diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRErrorUtils.h b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCErrorUtils.h similarity index 90% rename from examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRErrorUtils.h rename to examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCErrorUtils.h index 18a06478425004..56606e96b7a7d9 100644 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRErrorUtils.h +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCErrorUtils.h @@ -20,13 +20,13 @@ #import -#ifndef MTRErrorUtils_h -#define MTRErrorUtils_h +#ifndef MCErrorUtils_h +#define MCErrorUtils_h /** * @brief - Conversion utilities to/from CHIP_ERROR (C++) / MatterError (Objective C) / NSError */ -@interface MTRErrorUtils : NSObject +@interface MCErrorUtils : NSObject + (MatterError * _Nonnull)MatterErrorFromChipError:(CHIP_ERROR)chipError; @@ -36,4 +36,4 @@ @end -#endif /* MTRErrorUtils_h */ +#endif /* MCErrorUtils_h */ diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRErrorUtils.mm b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCErrorUtils.mm similarity index 96% rename from examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRErrorUtils.mm rename to examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCErrorUtils.mm index 1f6b896e681ca0..66fc7544aad226 100644 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRErrorUtils.mm +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCErrorUtils.mm @@ -17,11 +17,11 @@ #import -#import "MTRErrorUtils.h" +#import "MCErrorUtils.h" #include -@implementation MTRErrorUtils +@implementation MCErrorUtils + (MatterError * _Nonnull)MatterErrorFromChipError:(CHIP_ERROR)chipError { diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRRotatingDeviceIdUniqueIdProvider.h b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCRotatingDeviceIdUniqueIdProvider.h similarity index 73% rename from examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRRotatingDeviceIdUniqueIdProvider.h rename to examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCRotatingDeviceIdUniqueIdProvider.h index 5f0b32a21b58e2..8dad8db2a60091 100644 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRRotatingDeviceIdUniqueIdProvider.h +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCRotatingDeviceIdUniqueIdProvider.h @@ -15,25 +15,25 @@ * limitations under the License. */ -#import "MTRDataSource.h" +#import "MCDataSource.h" #include "core/Types.h" -#ifndef MTRRotatingDeviceIdUniqueIdProvider_h -#define MTRRotatingDeviceIdUniqueIdProvider_h +#ifndef MCRotatingDeviceIdUniqueIdProvider_h +#define MCRotatingDeviceIdUniqueIdProvider_h namespace matter { namespace casting { namespace support { -class MTRRotatingDeviceIdUniqueIdProvider : public matter::casting::support::MutableByteSpanDataProvider +class MCRotatingDeviceIdUniqueIdProvider : public matter::casting::support::MutableByteSpanDataProvider { public: - CHIP_ERROR Initialize(id dataSource); + CHIP_ERROR Initialize(id dataSource); chip::MutableByteSpan * Get(); private: - id mDataSource = nullptr; + id mDataSource = nullptr; chip::MutableByteSpan mRotatingDeviceIdUniqueIdSpan; uint8_t mRotatingDeviceIdUniqueId[chip::DeviceLayer::ConfigurationManager::kRotatingDeviceIDUniqueIDLength]; @@ -43,4 +43,4 @@ class MTRRotatingDeviceIdUniqueIdProvider : public matter::casting::support::Mut }; // namespace casting }; // namespace matter -#endif /* MTRRotatingDeviceIdUniqueIdProvider_h */ +#endif /* MCRotatingDeviceIdUniqueIdProvider_h */ diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRRotatingDeviceIdUniqueIdProvider.mm b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCRotatingDeviceIdUniqueIdProvider.mm similarity index 81% rename from examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRRotatingDeviceIdUniqueIdProvider.mm rename to examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCRotatingDeviceIdUniqueIdProvider.mm index 7db4ce55c91e7b..40d07984dda11b 100644 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRRotatingDeviceIdUniqueIdProvider.mm +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MCRotatingDeviceIdUniqueIdProvider.mm @@ -15,7 +15,7 @@ * limitations under the License. */ -#include "MTRRotatingDeviceIdUniqueIdProvider.h" +#include "MCRotatingDeviceIdUniqueIdProvider.h" #include "lib/support/logging/CHIPLogging.h" #include @@ -27,7 +27,7 @@ namespace casting { namespace support { - CHIP_ERROR MTRRotatingDeviceIdUniqueIdProvider::Initialize(id dataSource) + CHIP_ERROR MCRotatingDeviceIdUniqueIdProvider::Initialize(id dataSource) { VerifyOrReturnError(dataSource != nullptr, CHIP_ERROR_INVALID_ARGUMENT); VerifyOrReturnError(mDataSource == nullptr, CHIP_ERROR_INCORRECT_STATE); @@ -35,13 +35,13 @@ return CHIP_NO_ERROR; } - chip::MutableByteSpan * MTRRotatingDeviceIdUniqueIdProvider::Get() + chip::MutableByteSpan * MCRotatingDeviceIdUniqueIdProvider::Get() { - ChipLogProgress(AppServer, "MTRRotatingDeviceIdUniqueIdProvider.Get() called"); + ChipLogProgress(AppServer, "MCRotatingDeviceIdUniqueIdProvider.Get() called"); VerifyOrReturnValue(mDataSource != nil, nullptr, ChipLogError(AppServer, "mDataSource found nil!")); NSData * uniqueIdData = - [mDataSource castingAppDidReceiveRequestForRotatingDeviceIdUniqueId:@"MTRRotatingDeviceIdUniqueIdProvider.Get()"]; + [mDataSource castingAppDidReceiveRequestForRotatingDeviceIdUniqueId:@"MCRotatingDeviceIdUniqueIdProvider.Get()"]; if (uniqueIdData != nil) { mRotatingDeviceIdUniqueIdSpan = chip::MutableByteSpan( const_cast(reinterpret_cast(uniqueIdData.bytes)), uniqueIdData.length); diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRCastingPlayerDiscovery.h b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRCastingPlayerDiscovery.h deleted file mode 100644 index 3fd0ca84700157..00000000000000 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MTRCastingPlayerDiscovery.h +++ /dev/null @@ -1,85 +0,0 @@ -/** - * - * Copyright (c) 2020-2023 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#import "MTRCastingPlayer.h" -#import "MatterError.h" - -#ifndef MTRCastingPlayerDiscovery_h -#define MTRCastingPlayerDiscovery_h - -/** - * MTRCastingPlayerDiscovery sends notification with ADD_CASTING_PLAYER_NOTIFICATION_NAME - * through the NSNotificationCenter if a new MTRCastingPlayer is added to the network - */ -extern NSString * _Nonnull const ADD_CASTING_PLAYER_NOTIFICATION_NAME; - -/** - * MTRCastingPlayerDiscovery sends notification with REMOVE_CASTING_PLAYER_NOTIFICATION_NAME - * through the NSNotificationCenter if a MTRCastingPlayer is removed from the network - */ -extern NSString * _Nonnull const REMOVE_CASTING_PLAYER_NOTIFICATION_NAME; - -/** - * MTRCastingPlayerDiscovery sends notification with UPDATE_CASTING_PLAYER_NOTIFICATION_NAME - * through the NSNotificationCenter if a previously added MTRCastingPlayer is updated - */ -extern NSString * _Nonnull const UPDATE_CASTING_PLAYER_NOTIFICATION_NAME; - -/** - * MTRCastingPlayerDiscovery sends ADD / REMOVE / UPDATE notifications through the - * NSNotificationCenter with userInfo set to an NSDictionary that has CASTING_PLAYER_KEY as the - * key to a MTRCastingPlayer object as value. - */ -extern NSString * _Nonnull const CASTING_PLAYER_KEY; - -/** - * @brief MTRCastingPlayerDiscovery is a singleton utility class for discovering MTRCastingPlayers. - */ -@interface MTRCastingPlayerDiscovery : NSObject -+ (MTRCastingPlayerDiscovery * _Nonnull)sharedInstance; - -- (nonnull instancetype)init UNAVAILABLE_ATTRIBUTE; -+ (nonnull instancetype)new UNAVAILABLE_ATTRIBUTE; - -@property (nonatomic, strong) NSArray * _Nonnull castingPlayers; - -/** - * @brief Starts the discovery for MTRCastingPlayers - * - * @return Returns nil if discovery for CastingPlayers started successfully, NSError * describing the error otherwise. - */ -- (NSError * _Nullable)start; - -/** - * @brief Starts the discovery for MTRCastingPlayers - * - * @param filterBydeviceType if passed as a non-zero value, MTRCastingPlayerDiscovery will only discover - * MTRCastingPlayers whose deviceType matches filterBydeviceType - * @return Returns nil if discovery for MTRCastingPlayers started successfully, NSError * describing the error otherwise. - */ -- (NSError * _Nullable)start:(const uint32_t)filterBydeviceType; - -/** - * @brief Stop the discovery for MTRCastingPlayers - * - * @return Returns nil if discovery for MTRCastingPlayers stopped successfully, NSError * describing the error otherwise. - */ -- (NSError * _Nullable)stop; - -@end - -#endif /* MTRCastingPlayerDiscovery_h */ diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MatterTvCastingBridge.h b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MatterTvCastingBridge.h index b83ce9cccf99be..9329bc657b9c32 100644 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MatterTvCastingBridge.h +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/MatterTvCastingBridge.h @@ -26,11 +26,11 @@ FOUNDATION_EXPORT const unsigned char MatterTvCastingBridgeVersionString[]; #import "CastingServerBridge.h" // Add simplified casting API headers here -#import "MTRCastingApp.h" -#import "MTRCastingPlayer.h" -#import "MTRCastingPlayerDiscovery.h" -#import "MTRCommissionableData.h" -#import "MTRCryptoUtils.h" -#import "MTRDataSource.h" -#import "MTRDeviceAttestationCredentials.h" -#import "MTREndpointFilter.h" +#import "MCCastingApp.h" +#import "MCCastingPlayer.h" +#import "MCCastingPlayerDiscovery.h" +#import "MCCommissionableData.h" +#import "MCCryptoUtils.h" +#import "MCDataSource.h" +#import "MCDeviceAttestationCredentials.h" +#import "MCEndpointFilter.h" diff --git a/examples/tv-casting-app/darwin/TvCasting/TvCasting.xcodeproj/project.pbxproj b/examples/tv-casting-app/darwin/TvCasting/TvCasting.xcodeproj/project.pbxproj index c208d6b24901a2..1fd70f6b3f48fb 100644 --- a/examples/tv-casting-app/darwin/TvCasting/TvCasting.xcodeproj/project.pbxproj +++ b/examples/tv-casting-app/darwin/TvCasting/TvCasting.xcodeproj/project.pbxproj @@ -7,15 +7,15 @@ objects = { /* Begin PBXBuildFile section */ - 3C69204A2AA1368F00D0F613 /* MTRInitializationExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C6920492AA1368F00D0F613 /* MTRInitializationExample.swift */; }; + 3C69204A2AA1368F00D0F613 /* MCInitializationExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C6920492AA1368F00D0F613 /* MCInitializationExample.swift */; }; 3C81C75328F8C79E001CB9D1 /* StartFromCacheView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C81C75228F8C79E001CB9D1 /* StartFromCacheView.swift */; }; 3C81C75528F8C7B6001CB9D1 /* StartFromCacheViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C81C75428F8C7B6001CB9D1 /* StartFromCacheViewModel.swift */; }; 3C81C75728F8E418001CB9D1 /* ConnectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C81C75628F8E418001CB9D1 /* ConnectionView.swift */; }; 3C81C75928F8E42D001CB9D1 /* ConnectionViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C81C75828F8E42D001CB9D1 /* ConnectionViewModel.swift */; }; - 3C94377D2B364D380096E5F4 /* MTRDiscoveryExampleViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C94377C2B364D380096E5F4 /* MTRDiscoveryExampleViewModel.swift */; }; - 3C94377F2B364D510096E5F4 /* MTRConnectionExampleViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C94377E2B364D510096E5F4 /* MTRConnectionExampleViewModel.swift */; }; - 3C94378E2B3B3CB00096E5F4 /* MTRDiscoveryExampleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C94378D2B3B3CB00096E5F4 /* MTRDiscoveryExampleView.swift */; }; - 3C9437902B3B3FF90096E5F4 /* MTRConnectionExampleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C94378F2B3B3FF90096E5F4 /* MTRConnectionExampleView.swift */; }; + 3C94377D2B364D380096E5F4 /* MCDiscoveryExampleViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C94377C2B364D380096E5F4 /* MCDiscoveryExampleViewModel.swift */; }; + 3C94377F2B364D510096E5F4 /* MCConnectionExampleViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C94377E2B364D510096E5F4 /* MCConnectionExampleViewModel.swift */; }; + 3C94378E2B3B3CB00096E5F4 /* MCDiscoveryExampleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C94378D2B3B3CB00096E5F4 /* MCDiscoveryExampleView.swift */; }; + 3C9437902B3B3FF90096E5F4 /* MCConnectionExampleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C94378F2B3B3FF90096E5F4 /* MCConnectionExampleView.swift */; }; 3CA1CA7A28E281080023ED44 /* ClusterSelectorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CA1CA7928E281080023ED44 /* ClusterSelectorView.swift */; }; 3CA1CA7C28E282150023ED44 /* MediaPlaybackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CA1CA7B28E282150023ED44 /* MediaPlaybackView.swift */; }; 3CA1CA7E28E284950023ED44 /* MediaPlaybackViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CA1CA7D28E284950023ED44 /* MediaPlaybackViewModel.swift */; }; @@ -51,7 +51,7 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ - 3C6920492AA1368F00D0F613 /* MTRInitializationExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MTRInitializationExample.swift; sourceTree = ""; }; + 3C6920492AA1368F00D0F613 /* MCInitializationExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MCInitializationExample.swift; sourceTree = ""; }; 3C75075E284C1DF800D7DB3A /* TvCasting.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = TvCasting.entitlements; sourceTree = ""; }; 3C7507AC285299DF00D7DB3A /* CommissionerDiscoveryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommissionerDiscoveryView.swift; sourceTree = ""; }; 3C7507AE28529A5F00D7DB3A /* CommissioningView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommissioningView.swift; sourceTree = ""; }; @@ -61,10 +61,10 @@ 3C81C75428F8C7B6001CB9D1 /* StartFromCacheViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StartFromCacheViewModel.swift; sourceTree = ""; }; 3C81C75628F8E418001CB9D1 /* ConnectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConnectionView.swift; sourceTree = ""; }; 3C81C75828F8E42D001CB9D1 /* ConnectionViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConnectionViewModel.swift; sourceTree = ""; }; - 3C94377C2B364D380096E5F4 /* MTRDiscoveryExampleViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MTRDiscoveryExampleViewModel.swift; sourceTree = ""; }; - 3C94377E2B364D510096E5F4 /* MTRConnectionExampleViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MTRConnectionExampleViewModel.swift; sourceTree = ""; }; - 3C94378D2B3B3CB00096E5F4 /* MTRDiscoveryExampleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MTRDiscoveryExampleView.swift; sourceTree = ""; }; - 3C94378F2B3B3FF90096E5F4 /* MTRConnectionExampleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MTRConnectionExampleView.swift; sourceTree = ""; }; + 3C94377C2B364D380096E5F4 /* MCDiscoveryExampleViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MCDiscoveryExampleViewModel.swift; sourceTree = ""; }; + 3C94377E2B364D510096E5F4 /* MCConnectionExampleViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MCConnectionExampleViewModel.swift; sourceTree = ""; }; + 3C94378D2B3B3CB00096E5F4 /* MCDiscoveryExampleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MCDiscoveryExampleView.swift; sourceTree = ""; }; + 3C94378F2B3B3FF90096E5F4 /* MCConnectionExampleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MCConnectionExampleView.swift; sourceTree = ""; }; 3CA19434285BA780004768D5 /* ContentLauncherView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentLauncherView.swift; sourceTree = ""; }; 3CA19436285BA877004768D5 /* ContentLauncherViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentLauncherViewModel.swift; sourceTree = ""; }; 3CA1CA7928E281080023ED44 /* ClusterSelectorView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClusterSelectorView.swift; sourceTree = ""; }; @@ -126,11 +126,11 @@ 3CC0E8FD2841DD3500EC6A18 /* Assets.xcassets */, 3C75075E284C1DF800D7DB3A /* TvCasting.entitlements */, 3CC0E8F92841DD3400EC6A18 /* TvCastingApp.swift */, - 3C6920492AA1368F00D0F613 /* MTRInitializationExample.swift */, - 3C94378D2B3B3CB00096E5F4 /* MTRDiscoveryExampleView.swift */, - 3C94377C2B364D380096E5F4 /* MTRDiscoveryExampleViewModel.swift */, - 3C94378F2B3B3FF90096E5F4 /* MTRConnectionExampleView.swift */, - 3C94377E2B364D510096E5F4 /* MTRConnectionExampleViewModel.swift */, + 3C6920492AA1368F00D0F613 /* MCInitializationExample.swift */, + 3C94378D2B3B3CB00096E5F4 /* MCDiscoveryExampleView.swift */, + 3C94377C2B364D380096E5F4 /* MCDiscoveryExampleViewModel.swift */, + 3C94378F2B3B3FF90096E5F4 /* MCConnectionExampleView.swift */, + 3C94377E2B364D510096E5F4 /* MCConnectionExampleViewModel.swift */, EAF14298296D561900E17793 /* CertTestView.swift */, EAF1429A296D57DF00E17793 /* CertTestViewModel.swift */, 3CC0E8FB2841DD3400EC6A18 /* ContentView.swift */, @@ -247,16 +247,16 @@ buildActionMask = 2147483647; files = ( 3C81C75328F8C79E001CB9D1 /* StartFromCacheView.swift in Sources */, - 3C94377F2B364D510096E5F4 /* MTRConnectionExampleViewModel.swift in Sources */, + 3C94377F2B364D510096E5F4 /* MCConnectionExampleViewModel.swift in Sources */, 3C81C75528F8C7B6001CB9D1 /* StartFromCacheViewModel.swift in Sources */, 3CCB8745286A5D0F00771BAD /* CommissionerDiscoveryView.swift in Sources */, 3CCB8746286A5D0F00771BAD /* CommissionerDiscoveryViewModel.swift in Sources */, 3C81C75928F8E42D001CB9D1 /* ConnectionViewModel.swift in Sources */, 3CA1CA7A28E281080023ED44 /* ClusterSelectorView.swift in Sources */, - 3C94378E2B3B3CB00096E5F4 /* MTRDiscoveryExampleView.swift in Sources */, + 3C94378E2B3B3CB00096E5F4 /* MCDiscoveryExampleView.swift in Sources */, EAF14299296D561900E17793 /* CertTestView.swift in Sources */, - 3C69204A2AA1368F00D0F613 /* MTRInitializationExample.swift in Sources */, - 3C94377D2B364D380096E5F4 /* MTRDiscoveryExampleViewModel.swift in Sources */, + 3C69204A2AA1368F00D0F613 /* MCInitializationExample.swift in Sources */, + 3C94377D2B364D380096E5F4 /* MCDiscoveryExampleViewModel.swift in Sources */, 3CCB8747286A5D0F00771BAD /* CommissioningView.swift in Sources */, 3CCB8748286A5D0F00771BAD /* CommissioningViewModel.swift in Sources */, 3CAC955B29BA948700BEA5C3 /* ExampleDAC.swift in Sources */, @@ -268,7 +268,7 @@ 3CC0E8FC2841DD3400EC6A18 /* ContentView.swift in Sources */, 3CA1CA7C28E282150023ED44 /* MediaPlaybackView.swift in Sources */, 3CC0E8FA2841DD3400EC6A18 /* TvCastingApp.swift in Sources */, - 3C9437902B3B3FF90096E5F4 /* MTRConnectionExampleView.swift in Sources */, + 3C9437902B3B3FF90096E5F4 /* MCConnectionExampleView.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/examples/tv-casting-app/darwin/TvCasting/TvCasting/ContentView.swift b/examples/tv-casting-app/darwin/TvCasting/TvCasting/ContentView.swift index 4f66f03db398bd..701fada1fe62d9 100644 --- a/examples/tv-casting-app/darwin/TvCasting/TvCasting/ContentView.swift +++ b/examples/tv-casting-app/darwin/TvCasting/TvCasting/ContentView.swift @@ -22,7 +22,7 @@ struct ContentView: View { NavigationView { if ProcessInfo.processInfo.environment["CHIP_CASTING_SIMPLIFIED"] == "1" { - MTRDiscoveryExampleView() + MCDiscoveryExampleView() } else { diff --git a/examples/tv-casting-app/darwin/TvCasting/TvCasting/MTRConnectionExampleView.swift b/examples/tv-casting-app/darwin/TvCasting/TvCasting/MCConnectionExampleView.swift similarity index 86% rename from examples/tv-casting-app/darwin/TvCasting/TvCasting/MTRConnectionExampleView.swift rename to examples/tv-casting-app/darwin/TvCasting/TvCasting/MCConnectionExampleView.swift index f56e7efef64481..0dd6d302f7b968 100644 --- a/examples/tv-casting-app/darwin/TvCasting/TvCasting/MTRConnectionExampleView.swift +++ b/examples/tv-casting-app/darwin/TvCasting/TvCasting/MCConnectionExampleView.swift @@ -18,12 +18,12 @@ import SwiftUI -struct MTRConnectionExampleView: View { - var selectedCastingPlayer: MTRCastingPlayer? +struct MCConnectionExampleView: View { + var selectedCastingPlayer: MCCastingPlayer? - @StateObject var viewModel = MTRConnectionExampleViewModel(); + @StateObject var viewModel = MCConnectionExampleViewModel(); - init(_selectedCastingPlayer: MTRCastingPlayer?) { + init(_selectedCastingPlayer: MCCastingPlayer?) { self.selectedCastingPlayer = _selectedCastingPlayer } @@ -62,8 +62,8 @@ struct MTRConnectionExampleView: View { } } -struct MTRConnectionExampleView_Previews: PreviewProvider { +struct MCConnectionExampleView_Previews: PreviewProvider { static var previews: some View { - MTRConnectionExampleView(_selectedCastingPlayer: nil) + MCConnectionExampleView(_selectedCastingPlayer: nil) } } diff --git a/examples/tv-casting-app/darwin/TvCasting/TvCasting/MTRConnectionExampleViewModel.swift b/examples/tv-casting-app/darwin/TvCasting/TvCasting/MCConnectionExampleViewModel.swift similarity index 75% rename from examples/tv-casting-app/darwin/TvCasting/TvCasting/MTRConnectionExampleViewModel.swift rename to examples/tv-casting-app/darwin/TvCasting/TvCasting/MCConnectionExampleViewModel.swift index da237e47cc4d6e..9d130b5e7737ee 100644 --- a/examples/tv-casting-app/darwin/TvCasting/TvCasting/MTRConnectionExampleViewModel.swift +++ b/examples/tv-casting-app/darwin/TvCasting/TvCasting/MCConnectionExampleViewModel.swift @@ -19,22 +19,22 @@ import Foundation import os.log -class MTRConnectionExampleViewModel: ObservableObject { +class MCConnectionExampleViewModel: ObservableObject { let Log = Logger(subsystem: "com.matter.casting", - category: "MTRConnectionExampleViewModel") + category: "MCConnectionExampleViewModel") - // VendorId of the MTREndpoint on the MTRCastingPlayer that the MTRCastingApp desires to interact with after connection + // VendorId of the MCEndpoint on the MCCastingPlayer that the MCCastingApp desires to interact with after connection let kDesiredEndpointVendorId: UInt16 = 65521; @Published var connectionSuccess: Bool?; @Published var connectionStatus: String?; - func connect(selectedCastingPlayer: MTRCastingPlayer?) { - let desiredEndpointFilter: MTREndpointFilter = MTREndpointFilter() + func connect(selectedCastingPlayer: MCCastingPlayer?) { + let desiredEndpointFilter: MCEndpointFilter = MCEndpointFilter() desiredEndpointFilter.vendorId = kDesiredEndpointVendorId selectedCastingPlayer?.verifyOrEstablishConnection(completionBlock: { err in - self.Log.error("MTRConnectionExampleViewModel connect() completed with \(err)") + self.Log.error("MCConnectionExampleViewModel connect() completed with \(err)") if(err == nil) { self.connectionSuccess = true diff --git a/examples/tv-casting-app/darwin/TvCasting/TvCasting/MTRDiscoveryExampleView.swift b/examples/tv-casting-app/darwin/TvCasting/TvCasting/MCDiscoveryExampleView.swift similarity index 89% rename from examples/tv-casting-app/darwin/TvCasting/TvCasting/MTRDiscoveryExampleView.swift rename to examples/tv-casting-app/darwin/TvCasting/TvCasting/MCDiscoveryExampleView.swift index 79b8c911e1a27c..ef0e32f6770b88 100644 --- a/examples/tv-casting-app/darwin/TvCasting/TvCasting/MTRDiscoveryExampleView.swift +++ b/examples/tv-casting-app/darwin/TvCasting/TvCasting/MCDiscoveryExampleView.swift @@ -17,14 +17,14 @@ import SwiftUI -extension MTRCastingPlayer : Identifiable { +extension MCCastingPlayer : Identifiable { public var id: String { identifier() } } -struct MTRDiscoveryExampleView: View { - @StateObject var viewModel = MTRDiscoveryExampleViewModel() +struct MCDiscoveryExampleView: View { + @StateObject var viewModel = MCDiscoveryExampleViewModel() var body: some View { VStack(alignment: .leading) { @@ -59,7 +59,7 @@ struct MTRDiscoveryExampleView: View { ForEach(viewModel.displayedCastingPlayers) { castingPlayer in NavigationLink( destination: { - MTRConnectionExampleView(_selectedCastingPlayer: castingPlayer) + MCConnectionExampleView(_selectedCastingPlayer: castingPlayer) }, label: { Text(castingPlayer.description) @@ -78,8 +78,8 @@ struct MTRDiscoveryExampleView: View { } } -struct MTRDiscoveryExampleView_Previews: PreviewProvider { +struct MCDiscoveryExampleView_Previews: PreviewProvider { static var previews: some View { - MTRDiscoveryExampleView() + MCDiscoveryExampleView() } } diff --git a/examples/tv-casting-app/darwin/TvCasting/TvCasting/MTRDiscoveryExampleViewModel.swift b/examples/tv-casting-app/darwin/TvCasting/TvCasting/MCDiscoveryExampleViewModel.swift similarity index 83% rename from examples/tv-casting-app/darwin/TvCasting/TvCasting/MTRDiscoveryExampleViewModel.swift rename to examples/tv-casting-app/darwin/TvCasting/TvCasting/MCDiscoveryExampleViewModel.swift index 16f86457d44e7b..315dca021231a8 100644 --- a/examples/tv-casting-app/darwin/TvCasting/TvCasting/MTRDiscoveryExampleViewModel.swift +++ b/examples/tv-casting-app/darwin/TvCasting/TvCasting/MCDiscoveryExampleViewModel.swift @@ -18,12 +18,12 @@ import Foundation import os.log -class MTRDiscoveryExampleViewModel: ObservableObject { +class MCDiscoveryExampleViewModel: ObservableObject { let Log = Logger(subsystem: "com.matter.casting", - category: "MTRDiscoveryExampleViewModel") + category: "MCDiscoveryExampleViewModel") let kTargetPlayerDeviceType: UInt64 = 35 - @Published var displayedCastingPlayers: [MTRCastingPlayer] = [] + @Published var displayedCastingPlayers: [MCCastingPlayer] = [] @Published var discoveryHasError: Bool = false; @@ -36,9 +36,9 @@ class MTRDiscoveryExampleViewModel: ObservableObject { NotificationCenter.default.addObserver(self, selector: #selector(self.didRemoveDiscoveredCastingPlayers), name: NSNotification.Name(REMOVE_CASTING_PLAYER_NOTIFICATION_NAME), object: nil) NotificationCenter.default.addObserver(self, selector: #selector(self.didUpdateDiscoveredCastingPlayers), name: NSNotification.Name(UPDATE_CASTING_PLAYER_NOTIFICATION_NAME), object: nil) - if let err:Error = MTRCastingPlayerDiscovery.sharedInstance().start(UInt32(kTargetPlayerDeviceType)) + if let err:Error = MCCastingPlayerDiscovery.sharedInstance().start(UInt32(kTargetPlayerDeviceType)) { - Log.error("MTRCastingPlayerDiscovery.start failed with \(err)") + Log.error("MCCastingPlayerDiscovery.start failed with \(err)") self.discoveryHasError = true } self.discoveryHasError = false @@ -46,9 +46,9 @@ class MTRDiscoveryExampleViewModel: ObservableObject { func stopDiscovery() { Log.info("stopDiscovery() called") - if let err:Error = MTRCastingPlayerDiscovery.sharedInstance().stop() + if let err:Error = MCCastingPlayerDiscovery.sharedInstance().stop() { - Log.error("MTRCastingPlayerDiscovery.stop failed with \(err)") + Log.error("MCCastingPlayerDiscovery.stop failed with \(err)") self.discoveryHasError = true } else @@ -74,12 +74,12 @@ class MTRDiscoveryExampleViewModel: ObservableObject { { Log.info("didAddDiscoveredCastingPlayers() called") guard let userInfo = notification.userInfo, - let castingPlayer = userInfo["castingPlayer"] as? MTRCastingPlayer else { - self.Log.error("didAddDiscoveredCastingPlayers called with no MTRCastingPlayer") + let castingPlayer = userInfo["castingPlayer"] as? MCCastingPlayer else { + self.Log.error("didAddDiscoveredCastingPlayers called with no MCCastingPlayer") return } - self.Log.info("didAddDiscoveredCastingPlayers notified of a MTRCastingPlayer with ID: \(castingPlayer.identifier())") + self.Log.info("didAddDiscoveredCastingPlayers notified of a MCCastingPlayer with ID: \(castingPlayer.identifier())") DispatchQueue.main.async { @@ -92,12 +92,12 @@ class MTRDiscoveryExampleViewModel: ObservableObject { { Log.info("didRemoveDiscoveredCastingPlayers() called") guard let userInfo = notification.userInfo, - let castingPlayer = userInfo["castingPlayer"] as? MTRCastingPlayer else { - self.Log.error("didRemoveDiscoveredCastingPlayers called with no MTRCastingPlayer") + let castingPlayer = userInfo["castingPlayer"] as? MCCastingPlayer else { + self.Log.error("didRemoveDiscoveredCastingPlayers called with no MCCastingPlayer") return } - self.Log.info("didRemoveDiscoveredCastingPlayers notified of a MTRCastingPlayer with ID: \(castingPlayer.identifier())") + self.Log.info("didRemoveDiscoveredCastingPlayers notified of a MCCastingPlayer with ID: \(castingPlayer.identifier())") DispatchQueue.main.async { self.displayedCastingPlayers.removeAll(where: {$0 == castingPlayer}) @@ -109,12 +109,12 @@ class MTRDiscoveryExampleViewModel: ObservableObject { { Log.info("didUpdateDiscoveredCastingPlayers() called") guard let userInfo = notification.userInfo, - let castingPlayer = userInfo["castingPlayer"] as? MTRCastingPlayer else { - self.Log.error("didUpdateDiscoveredCastingPlayers called with no MTRCastingPlayer") + let castingPlayer = userInfo["castingPlayer"] as? MCCastingPlayer else { + self.Log.error("didUpdateDiscoveredCastingPlayers called with no MCCastingPlayer") return } - self.Log.info("didUpdateDiscoveredCastingPlayers notified of a MTRCastingPlayer with ID: \(castingPlayer.identifier())") + self.Log.info("didUpdateDiscoveredCastingPlayers notified of a MCCastingPlayer with ID: \(castingPlayer.identifier())") if let index = displayedCastingPlayers.firstIndex(where: { castingPlayer.identifier() == $0.identifier() }) { DispatchQueue.main.async diff --git a/examples/tv-casting-app/darwin/TvCasting/TvCasting/MTRInitializationExample.swift b/examples/tv-casting-app/darwin/TvCasting/TvCasting/MCInitializationExample.swift similarity index 91% rename from examples/tv-casting-app/darwin/TvCasting/TvCasting/MTRInitializationExample.swift rename to examples/tv-casting-app/darwin/TvCasting/TvCasting/MCInitializationExample.swift index 534094a8cec060..daae3ab449418f 100644 --- a/examples/tv-casting-app/darwin/TvCasting/TvCasting/MTRInitializationExample.swift +++ b/examples/tv-casting-app/darwin/TvCasting/TvCasting/MCInitializationExample.swift @@ -19,10 +19,10 @@ import Foundation import Security import os.log -class MTRAppParametersDataSource : NSObject, MTRDataSource +class MCAppParametersDataSource : NSObject, MCDataSource { let Log = Logger(subsystem: "com.matter.casting", - category: "MTRAppParametersDataSource") + category: "MCAppParametersDataSource") func clientQueue() -> DispatchQueue { return DispatchQueue.main; @@ -33,9 +33,9 @@ class MTRAppParametersDataSource : NSObject, MTRDataSource return "0123456789ABCDEF".data(using: .utf8)! } - func castingAppDidReceiveRequestForCommissionableData(_ sender: Any) -> MTRCommissionableData { + func castingAppDidReceiveRequestForCommissionableData(_ sender: Any) -> MCCommissionableData { // dummy values for demonstration only - return MTRCommissionableData( + return MCCommissionableData( passcode: 20202021, discriminator: 3874, spake2pIterationCount: 1000, @@ -53,8 +53,8 @@ class MTRAppParametersDataSource : NSObject, MTRDataSource let KPAI_FFF1_8000_Cert_Array: Data = Data(base64Encoded: "MIIByzCCAXGgAwIBAgIIVq2CIq2UW2QwCgYIKoZIzj0EAwIwMDEYMBYGA1UEAwwPTWF0dGVyIFRlc3QgUEFBMRQwEgYKKwYBBAGConwCAQwERkZGMTAgFw0yMjAyMDUwMDAwMDBaGA85OTk5MTIzMTIzNTk1OVowPTElMCMGA1UEAwwcTWF0dGVyIERldiBQQUkgMHhGRkYxIG5vIFBJRDEUMBIGCisGAQQBgqJ8AgEMBEZGRjEwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAARBmpMVwhc+DIyHbQPM/JRIUmR/f+xeUIL0BZko7KiUxZQVEwmsYx5MsDOSr2hLC6+35ls7gWLC9Sv5MbjneqqCo2YwZDASBgNVHRMBAf8ECDAGAQH/AgEAMA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUY1QOR/ZLHDjROISkYtFsGV2P+zwwHwYDVR0jBBgwFoAUav0idx9RH+y/FkGXZxDc3DGhcX4wCgYIKoZIzj0EAwIDSAAwRQIhALLvJ/Sa6bUPuR7qyUxNC9u415KcbLiPrOUpNo0SBUwMAiBlXckrhr2QmIKmxiF3uCXX0F7b58Ivn+pxIg5+pwP4kQ==")!; let kCertificationDeclaration: Data = Data(base64Encoded: "MIICGQYJKoZIhvcNAQcCoIICCjCCAgYCAQMxDTALBglghkgBZQMEAgEwggFxBgkqhkiG9w0BBwGgggFiBIIBXhUkAAElAfH/NgIFAIAFAYAFAoAFA4AFBIAFBYAFBoAFB4AFCIAFCYAFCoAFC4AFDIAFDYAFDoAFD4AFEIAFEYAFEoAFE4AFFIAFFYAFFoAFF4AFGIAFGYAFGoAFG4AFHIAFHYAFHoAFH4AFIIAFIYAFIoAFI4AFJIAFJYAFJoAFJ4AFKIAFKYAFKoAFK4AFLIAFLYAFLoAFL4AFMIAFMYAFMoAFM4AFNIAFNYAFNoAFN4AFOIAFOYAFOoAFO4AFPIAFPYAFPoAFP4AFQIAFQYAFQoAFQ4AFRIAFRYAFRoAFR4AFSIAFSYAFSoAFS4AFTIAFTYAFToAFT4AFUIAFUYAFUoAFU4AFVIAFVYAFVoAFV4AFWIAFWYAFWoAFW4AFXIAFXYAFXoAFX4AFYIAFYYAFYoAFY4AYJAMWLAQTWklHMjAxNDJaQjMzMDAwMy0yNCQFACQGACUHlCYkCAAYMX0wewIBA4AUYvqCM1ms+qmWPhz6FArd9QTzcWAwCwYJYIZIAWUDBAIBMAoGCCqGSM49BAMCBEcwRQIgJOXR9Hp9ew0gaibvaZt8l1e3LUaQid4xkuZ4x0Xn9gwCIQD4qi+nEfy3m5fjl87aZnuuRk4r0//fw8zteqjKX0wafA==")!; - func castingAppDidReceiveRequestForDeviceAttestationCredentials(_ sender: Any) -> MTRDeviceAttestationCredentials { - return MTRDeviceAttestationCredentials( + func castingAppDidReceiveRequestForDeviceAttestationCredentials(_ sender: Any) -> MCDeviceAttestationCredentials { + return MCDeviceAttestationCredentials( certificationDeclaration: kCertificationDeclaration, firmwareInformation: Data(), deviceAttestationCert: kDevelopmentDAC_Cert_FFF1_8001, @@ -90,20 +90,20 @@ class MTRAppParametersDataSource : NSObject, MTRDataSource } // convert ASN.1 DER signature to SEC1 raw format - return MTRCryptoUtils.ecdsaAsn1SignatureToRaw(withFeLengthBytes: 32, + return MCCryptoUtils.ecdsaAsn1SignatureToRaw(withFeLengthBytes: 32, asn1Signature: asn1SignatureData!, outRawSignature: &outRawSignature.pointee) } } -class MTRInitializationExample { +class MCInitializationExample { let Log = Logger(subsystem: "com.matter.casting", - category: "MTRInitializationExample") + category: "MCInitializationExample") func initialize() -> Error? { - if let castingApp = MTRCastingApp.getSharedInstance() + if let castingApp = MCCastingApp.getSharedInstance() { - return castingApp.initialize(with: MTRAppParametersDataSource()) + return castingApp.initialize(with: MCAppParametersDataSource()) } else { diff --git a/examples/tv-casting-app/darwin/TvCasting/TvCasting/TvCastingApp.swift b/examples/tv-casting-app/darwin/TvCasting/TvCasting/TvCastingApp.swift index 1fc28dce6ddf8c..d6949900f43202 100644 --- a/examples/tv-casting-app/darwin/TvCasting/TvCasting/TvCastingApp.swift +++ b/examples/tv-casting-app/darwin/TvCasting/TvCasting/TvCastingApp.swift @@ -33,10 +33,10 @@ struct TvCastingApp: App { { self.Log.info("CHIP_CASTING_SIMPLIFIED = 1") - let err: Error? = MTRInitializationExample().initialize() + let err: Error? = MCInitializationExample().initialize() if err != nil { - self.Log.error("MTRCastingApp initialization failed \(err)") + self.Log.error("MCCastingApp initialization failed \(err)") return } } @@ -72,12 +72,12 @@ struct TvCastingApp: App { self.Log.info("TvCastingApp: UIApplication.willResignActiveNotification") if ProcessInfo.processInfo.environment["CHIP_CASTING_SIMPLIFIED"] == "1" { - if let castingApp = MTRCastingApp.getSharedInstance() + if let castingApp = MCCastingApp.getSharedInstance() { castingApp.stop(completionBlock: { (err : Error?) -> () in if err != nil { - self.Log.error("MTRCastingApp stop failed \(err)") + self.Log.error("MCCastingApp stop failed \(err)") } }) } @@ -91,12 +91,12 @@ struct TvCastingApp: App { self.Log.info("TvCastingApp: UIApplication.didBecomeActiveNotification") if ProcessInfo.processInfo.environment["CHIP_CASTING_SIMPLIFIED"] == "1" { - if let castingApp = MTRCastingApp.getSharedInstance() + if let castingApp = MCCastingApp.getSharedInstance() { castingApp.start(completionBlock: { (err : Error?) -> () in if err != nil { - self.Log.error("MTRCastingApp start failed \(err)") + self.Log.error("MCCastingApp start failed \(err)") } }) }