Skip to content

Commit

Permalink
updated docc, better inline docs
Browse files Browse the repository at this point in the history
  • Loading branch information
maxxfrazer committed Jul 19, 2023
1 parent 3529ef4 commit fe91c69
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 15 deletions.
10 changes: 5 additions & 5 deletions Example-App/Docs-Examples.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
F344ED9C2A45943400B3C313 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = "../../../../custom-video-and-audio/README.md"; sourceTree = "<group>"; };
F344ED9D2A494CE700B3C313 /* CustomCameraInputView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomCameraInputView.swift; sourceTree = "<group>"; };
F344ED9F2A496FF400B3C313 /* AgoraCustomVideoCanvasView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = AgoraCustomVideoCanvasView.swift; path = "../../../../custom-video-and-audio/AgoraCustomVideoCanvasView.swift"; sourceTree = "<group>"; };
F348B3962A4D7BDC00AF6B9B /* config.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = config.json; path = ../AgoraManager/config.json; sourceTree = SOURCE_ROOT; };
F348B3962A4D7BDC00AF6B9B /* config.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = config.json; path = ../agora-manager/config.json; sourceTree = SOURCE_ROOT; };
F372069829C8EE420029EEC8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
F3A88CCC2A1DE629000B2292 /* GettingStartedView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = GettingStartedView.swift; path = "../../../../get-started-sdk/GettingStartedView.swift"; sourceTree = "<group>"; };
F3A88CCD2A1DE629000B2292 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = "../../../../get-started-sdk/README.md"; sourceTree = "<group>"; };
Expand All @@ -94,10 +94,10 @@
F3A88CF82A1E05F1000B2292 /* Docs-Examples.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "Docs-Examples.entitlements"; sourceTree = "<group>"; };
F3A88CF92A1E0627000B2292 /* screenSharer.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = screenSharer.entitlements; sourceTree = "<group>"; };
F3A88CFC2A1E17E0000B2292 /* RPSystemBroadcastPickerWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = RPSystemBroadcastPickerWrapper.swift; path = "../../../../product-workflow/RPSystemBroadcastPickerWrapper.swift"; sourceTree = "<group>"; };
F3C06BB42A4D861200F59BC2 /* DocsAppConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = DocsAppConfig.swift; path = ../../../../AgoraManager/DocsAppConfig.swift; sourceTree = "<group>"; };
F3C06BB42A4D861200F59BC2 /* DocsAppConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = DocsAppConfig.swift; path = ../../../../agora-manager/DocsAppConfig.swift; sourceTree = "<group>"; };
F3CA2CDA29C97AF400561441 /* Documentation.docc */ = {isa = PBXFileReference; lastKnownFileType = folder.documentationcatalog; path = Documentation.docc; sourceTree = "<group>"; };
F3CA2CE329CB00F400561441 /* AgoraVideoCanvasView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = AgoraVideoCanvasView.swift; path = ../../../../AgoraManager/AgoraVideoCanvasView.swift; sourceTree = "<group>"; };
F3D7BD4629DB30680014DEC0 /* AgoraManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = AgoraManager.swift; path = ../../../../AgoraManager/AgoraManager.swift; sourceTree = "<group>"; };
F3CA2CE329CB00F400561441 /* AgoraVideoCanvasView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = AgoraVideoCanvasView.swift; path = ../../../../agora-manager/AgoraVideoCanvasView.swift; sourceTree = "<group>"; };
F3D7BD4629DB30680014DEC0 /* AgoraManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = AgoraManager.swift; path = ../../../../agora-manager/AgoraManager.swift; sourceTree = "<group>"; };
F3D7BD4E29DB42D00014DEC0 /* ChannelInputView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChannelInputView.swift; sourceTree = "<group>"; };
F3D7BD5029DB46BB0014DEC0 /* TokenAuthInputView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TokenAuthInputView.swift; sourceTree = "<group>"; };
F3E59CBA2A57257300EC2B2E /* View+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "View+Extensions.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -439,7 +439,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/zsh;
shellScript = "# Get the path of the JSON file\nJSON_FILE_PATH=\"${SRCROOT}/../AgoraManager/config.json\"\n\n# Check if jq is installed\nif ! [ -x \"$(command -v jq)\" ]; then\n echo \"warning: jq is not installed. json validation skipped.\" >&2\nelse\n\n # Check if the JSON file exists\n if [ -f \"${JSON_FILE_PATH}\" ]; then\n\n # Read the JSON file contents\n JSON_CONTENTS=$(cat \"${JSON_FILE_PATH}\")\n\n # Validate the JSON \n if ! (echo \"$JSON_CONTENTS\" | jq -e . >/dev/null 2>&1); then\n echo \"error: config.json is invalid JSON\"\n exit 1 \n fi\n\n # Extract the appId value\n APP_ID_VALUE=$(echo \"${JSON_CONTENTS}\" | jq -r '.appId')\n\n # Check if appId is empty\n if [ \"${APP_ID_VALUE}\" = \"\" ]; then\n echo \"warning: The 'appId' key should have a valid Agora App ID. See config.json and https://console.agora.io\"\n fi\n\n fi\n\nfi\n";
shellScript = "# Get the path of the JSON file\nJSON_FILE_PATH=\"${SRCROOT}/../agora-manager/config.json\"\n\n# Check if jq is installed\nif ! [ -x \"$(command -v jq)\" ]; then\n echo \"warning: jq is not installed. json validation skipped.\" >&2\nelse\n\n # Check if the JSON file exists\n if [ -f \"${JSON_FILE_PATH}\" ]; then\n\n # Read the JSON file contents\n JSON_CONTENTS=$(cat \"${JSON_FILE_PATH}\")\n\n # Validate the JSON \n if ! (echo \"$JSON_CONTENTS\" | jq -e . >/dev/null 2>&1); then\n echo \"error: config.json is invalid JSON\"\n exit 1 \n fi\n\n # Extract the appId value\n APP_ID_VALUE=$(echo \"${JSON_CONTENTS}\" | jq -r '.appId')\n\n # Check if appId is empty\n if [ \"${APP_ID_VALUE}\" = \"\" ]; then\n echo \"warning: The 'appId' key should have a valid Agora App ID. See config.json and https://console.agora.io\"\n fi\n\n fi\n\nfi\n";
};
/* End PBXShellScriptBuildPhase section */

Expand Down
9 changes: 9 additions & 0 deletions Example-App/Docs-Examples/Documentation.docc/Documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Take a look through each class to see how to implement all the features with Ago
### Getting Started

- ``GettingStartedView``
- ``AgoraManager``
- ``AgoraVideoCanvasView``

### Develop

Expand All @@ -28,3 +30,10 @@ Take a look through each class to see how to implement all the features with Ago
- ``EncryptionKeysInputView``
- ``CustomCameraInputView``
- ``ProxyInputView``

### AgoraManager Subclasses

- ``CallQualityManager``
- ``CloudProxyManager``
- ``ScreenShareVolumeManager``
- ``CustomAudioVideoManager``
9 changes: 8 additions & 1 deletion agora-manager/AgoraManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,14 @@ open class AgoraManager: NSObject, ObservableObject, AgoraRtcEngineDelegate {
}

@discardableResult
open func joinChannel(_ channel: String, uid: UInt? = nil) async -> Int32 {
/// This method is used by this app specifically. If there is a tokenURL, it will attempt to retrieve a token from there.
/// Otherwise it will simply apply the provided token in config.json or nil.
///
/// - Parameters:
/// - channel: Name of the channel to join.
/// - uid: User ID of the local user. This can be 0 to allow the engine to automatically assign an ID.
/// - Returns: Error code, 0 = success, &lt; 0 = failure.
internal func joinChannel(_ channel: String, uid: UInt? = nil) async -> Int32 {
let userId = uid ?? DocsAppConfig.shared.uid
var token = DocsAppConfig.shared.rtcToken
if !DocsAppConfig.shared.tokenUrl.isEmpty {
Expand Down
17 changes: 10 additions & 7 deletions authentication-workflow/TokenAuthenticationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,18 @@ public extension AgoraManager {
return tokenResponse.rtcToken
}

/// A Codable struct representing the token server response.
struct TokenResponse: Codable {
/// Value of the RTC Token.
public let rtcToken: String
}

/// Fetch a token from the token server, and then join the channel using Agora SDK.
/// - Returns: A boolean, for whether or not the token fetching was successful.
func fetchTokenThenJoin(tokenUrl: String, channel: String) async -> Bool {
/// - Parameters:
/// - tokenUrl: The URL of the token server.
/// - channel: The name of the channel for which the token will be used.
fileprivate func fetchTokenThenJoin(tokenUrl: String, channel: String) async -> Bool {
if let token = try? await self.fetchToken(
from: tokenUrl, channel: channel,
role: role, userId: 0
Expand All @@ -49,12 +58,6 @@ public extension AgoraManager {
}
}

/// A Codable struct representing the token server response.
public struct TokenResponse: Codable {
/// Value of the RTC Token.
public let rtcToken: String
}

/// A view that authenticates the user with a token and joins them to a channel using Agora SDK.
struct TokenAuthenticationView: View {
/// The Agora SDK manager.
Expand Down
5 changes: 3 additions & 2 deletions custom-video-and-audio/CustomAudioVideoView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ struct CustomAudioVideoView: View {
ScrollView {
VStack {
// The local custom camera view
AgoraCustomVideoCanvasView(canvas: customPreview, previewLayer: agoraManager.previewLayer)
.aspectRatio(contentMode: .fit).cornerRadius(10)
AgoraCustomVideoCanvasView(
canvas: customPreview, previewLayer: agoraManager.previewLayer
).aspectRatio(contentMode: .fit).cornerRadius(10)
// All remote camera views
ForEach(Array(agoraManager.allUsers), id: \.self) { uid in
AgoraVideoCanvasView(manager: agoraManager, uid: uid)
Expand Down

0 comments on commit fe91c69

Please sign in to comment.