diff --git a/.github/ci/build/build_ios.sh b/.github/ci/build/build_ios.sh index 604a31e78..e818dac83 100644 --- a/.github/ci/build/build_ios.sh +++ b/.github/ci/build/build_ios.sh @@ -55,9 +55,6 @@ echo short_version: $short_version echo pwd: `pwd` echo sdk_url: $sdk_url -export https_proxy=10.10.114.55:1080 -export http_proxy=10.10.114.55:1080 -export all_proxy=10.10.114.55:1080 export LANG=en_US.UTF-8 unzip_name=Agora_Native_SDK_for_iOS_FULL diff --git a/.github/ci/build/build_mac.sh b/.github/ci/build/build_mac.sh index e9ef06451..5613531b6 100644 --- a/.github/ci/build/build_mac.sh +++ b/.github/ci/build/build_mac.sh @@ -52,9 +52,6 @@ echo short_version: $short_version echo pwd: `pwd` echo sdk_url: $sdk_url -export https_proxy=10.10.114.55:1080 -export http_proxy=10.10.114.55:1080 -export all_proxy=10.10.114.55:1080 export LANG=en_US.UTF-8 unzip_name=Agora_Native_SDK_for_iOS_FULL diff --git a/Android/APIExample-Audio/gradle.properties b/Android/APIExample-Audio/gradle.properties index 97f6f46d5..7806e177f 100644 --- a/Android/APIExample-Audio/gradle.properties +++ b/Android/APIExample-Audio/gradle.properties @@ -23,4 +23,4 @@ android.nonFinalResIds=false # read enable simple filter section on README first before set this flag to TRUE simpleFilter = false -rtc_sdk_version = 4.7.0 +rtc_sdk_version = 4.7.1 diff --git a/Android/APIExample-Compose/gradle.properties b/Android/APIExample-Compose/gradle.properties index fad88fe86..ce95e7a7c 100644 --- a/Android/APIExample-Compose/gradle.properties +++ b/Android/APIExample-Compose/gradle.properties @@ -22,4 +22,4 @@ kotlin.code.style=official # thereby reducing the size of the R class for that library android.nonTransitiveRClass=true -rtc_sdk_version = 4.7.0 +rtc_sdk_version = 4.7.1 diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/AgoraBase.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/AgoraBase.h index c8903c4f5..8e895c597 100644 --- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/AgoraBase.h +++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/AgoraBase.h @@ -92,6 +92,7 @@ #endif #define INVALID_DISPLAY_ID (-2) +#define MAX_AUDIO_CHANNELS (8) namespace agora { namespace util { @@ -294,6 +295,7 @@ enum CHANNEL_PROFILE_TYPE { /** * The channel types. + * @technical preview */ enum CHANNEL_TYPE { /** @@ -646,7 +648,8 @@ enum ERROR_CODE_TYPE { */ ERR_SIZE_TOO_LARGE = 114, /** - * 115: The data bitrate exceeds 6 KB/s when calling the `sendStreamMessage` method. + * 115: The data bitrate exceeds the data stream bitrate limit when calling the `sendStreamMessage` + * method. */ ERR_BITRATE_LIMIT = 115, /** @@ -845,31 +848,45 @@ enum ERROR_CODE_TYPE { ERR_VIDEOEFFECT_INVALID_BUNDLE_PATH = 1707, /** * 2007: Audio Device Module: An error occurs in starting the application loopback. + * + * @technical preview */ ERR_ADM_APPLICATION_LOOPBACK = 2007, /** * 2008: Audio Device Module: The application loopback was stopped unexpectedly, typically due to the application exiting or the user disabling loopback. + * + * @technical preview */ ERR_ADM_APPLICATION_LOOPBACK_STOPPED = 2008, /** * 2009: Audio Device Module: An error occurred while starting the system loopback. * This may be due to system restrictions, device conflicts, or other internal errors. + * + * @technical preview */ ERR_ADM_SYSTEM_LOOPBACK = 2009, /** * 2010: Audio Device Module: The system loopback was stopped unexpectedly, typically due to the user disabling loopback or a system error occurred. + * + * @technical preview */ ERR_ADM_SYSTEM_LOOPBACK_STOPPED = 2010, /** * 2011: Audio Device Module: No permission to start the loopback. + * + * @technical preview */ ERR_ADM_LOOPBACK_NO_PERMISSION = 2011, /** * 2012: Audio Device Module: Silent detected in loopback. + * + * @technical preview */ ERR_ADM_LOOPBACK_SILENT_DETECTED = 2012, /** * 2013: Audio Device Module: Silent recovered in loopback. + * + * @technical preview */ ERR_ADM_LOOPBACK_SILENT_RECOVERED = 2013, }; @@ -4561,13 +4578,16 @@ enum CONNECTION_STATE_TYPE { */ CONNECTION_STATE_RECONNECTING = 4, /** - * 5: The SDK fails to connect to the Agora edge server or join the channel. This state indicates - * that the SDK stops trying to rejoin the channel. You must call `leaveChannel()` to leave the - * channel. - * - You can call `joinChannel(const char* token, const char* channelId, uid_t uid, const - * ChannelMediaOptions& options)` to rejoin the channel. - * - If the SDK is banned from joining the channel by the Agora edge server through the RESTful API, - * the SDK triggers the `onConnectionStateChanged` callback. + * 5: The SDK fails to connect to the Agora edge server or join the channel and stops reconnecting. + * The reason reported by `onConnectionStateChanged` can vary when the user is kicked by the + * server, the token expires, or authentication fails, but the recovery flow is the same: + * - For `joinChannel`, call `leaveChannel()`, wait until CONNECTION_STATE_DISCONNECTED(1) is + * reported, and then call `joinChannel` with a valid new token. If you do not leave the channel + * first, `joinChannel` returns ERR_JOIN_CHANNEL_REJECTED(-17). + * - For `joinChannelEx`, call `leaveChannelEx` for the corresponding `RtcConnection`, wait until + * that connection enters CONNECTION_STATE_DISCONNECTED(1), and then call `joinChannelEx` with a + * valid new token. To clear only that connection, use `leaveChannelEx`; calling `leaveChannel` + * leaves all joined channels. */ CONNECTION_STATE_FAILED = 5, }; @@ -6204,28 +6224,68 @@ struct AudioTrackConfig { AudioTrackConfig() : enableLocalPlayback(true),enableAudioProcessing(false) {} }; -/** The type of loopback audio source mode -*/ +/** + * The type of loopback audio source mode + * + * @technical preview + */ enum LOOPBACK_AUDIO_TRACK_TYPE { - /** + /** * 0: loopback the whole system */ LOOPBACK_SYSTEM = 0, - /** + /** * 1: loopback the whole system exclude self */ LOOPBACK_SYSTEM_EXCLUDE_SELF = 1, - /** + /** * 2: loopback the specific application */ LOOPBACK_APPLICATION = 2, - /** + /** * 3: loopback the specific process */ LOOPBACK_PROCESS = 3, }; -/** Defines options for a custom loopback audio track. */ +/** The volume information of an audio track. */ +struct AudioTrackVolumeInfo { + /** The number of valid entries in levels. */ + int channelCount; + + /** + * The publish channel volumes in the range [0, 255]. Only the first channelCount entries are + * valid. + */ + int levels[MAX_AUDIO_CHANNELS]; +}; + +/** The per-track observer for audio tracks. */ +class IAudioTrackObserver { + public: + virtual ~IAudioTrackObserver() {} + + /** + * Occurs when the publish channel volumes of an audio track are available. + * + * The SDK invokes this callback at the interval configured by + * IMediaEngine::enableAudioTrackVolumeIndication(). + * + * @param trackId The audio track ID. + * @param volumeInfo The volume information. This pointer is valid only for the duration of the + * callback. + */ + virtual void onAudioTrackVolumeIndication(track_id_t trackId, const AudioTrackVolumeInfo* volumeInfo) { + (void)trackId; + (void)volumeInfo; + } +}; + +/** + * Defines options for a custom loopback audio track. + * + * @technical preview + */ struct LoopbackAudioTrackConfig { /** * Specifies the loopback source type. @@ -6235,7 +6295,7 @@ struct LoopbackAudioTrackConfig { LOOPBACK_AUDIO_TRACK_TYPE loopbackType; /** - * Initial playback volume for the loopback audio, valid in the range [0, 400]. + * Initial publish volume for the loopback audio, valid in the range [0, 400]. * 0: mute; 100: original volume; 400: maximum amplified volume. * Default is 100. */ diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraService.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraService.h index 49a555a37..c7928c580 100644 --- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraService.h +++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraService.h @@ -659,6 +659,8 @@ class IAgoraService { /** * Creates a local audio track object with the recording device source and returns the pointer. * + * @technical preview + * * Once created, this track can be used to send audio data got from a recording device. * @param audioSource The pointer to the recording device source. See \ref agora::rtc::IRecordingDeviceSource "IRecordingDeviceSource". * @param enableAec Whether enable audio echo cancellation for loopback recording. If loopback diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraAudioTrack.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraAudioTrack.h index fce4b4355..1edc03d87 100644 --- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraAudioTrack.h +++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraAudioTrack.h @@ -247,9 +247,25 @@ class ILocalAudioTrackObserver { /** * Occurs when the error of a local audio track occurs. * + * @technical preview + * * @param errorCode The error code of the local audio track. */ virtual void onLocalAudioTrackError(int errorCode) = 0; + + /** + * Occurs when the per-channel publish volume of a local audio track is available. + * + * @technical preview + * + * This callback is invoked only after volume indication is enabled for the track. The SDK owns + * info, and the pointer is valid only for the duration of this callback. + * + * @param info The volume information. See AudioTrackVolumeInfo. + */ + virtual void onLocalAudioTrackVolumeIndication(const AudioTrackVolumeInfo* info) { + (void)info; + } }; /** diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraLocalUser.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraLocalUser.h index 08e2b8896..6169237ce 100644 --- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraLocalUser.h +++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraLocalUser.h @@ -1214,6 +1214,10 @@ struct AudioVolumeInformation { */ class ILocalUserObserver { public: + /** + * The bitmask of streams published by a remote user. + * @technical preview + */ enum USER_STREAMS_BITMASK { USER_STREAMS_BITMASK_AUDIO = 1 << 0, USER_STREAMS_BITMASK_VIDEO_LOW = 1 << 1, @@ -1603,6 +1607,7 @@ class ILocalUserObserver { * @param uid The uid of the remote user. * @param streams The remote user published streams in bitmask. * See #USER_STREAMS_BITMASK. + * @technical preview */ virtual void onUserStreamsChanged(user_id_t userId, uint32_t streams) {} diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraRtcConnection.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraRtcConnection.h index 4d254974d..39021ccee 100644 --- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraRtcConnection.h +++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraRtcConnection.h @@ -157,6 +157,7 @@ struct RtcConnectionConfiguration { /** * Indicates the connection type. + * @technical preview */ CHANNEL_TYPE channelType; @@ -413,7 +414,7 @@ class IRtcConnection : public RefCountInterface { /** * Creates a data stream. * - * Each user can create up to five data streams during the lifecycle of an RTC connection. + * Each client can have up to five data streams simultaneously in a channel. * * @note Set both the `reliable` and `ordered` parameters as `true` or `false`. Do not set one as `true` and the other as `false`. * @@ -434,9 +435,10 @@ class IRtcConnection : public RefCountInterface { /** Sends data stream messages to all users in a channel. * * @note This method has the following restrictions: - * - Up to 30 packets can be sent per second in a channel with a maximum size of 1 kB for each packet. - * - Each client can send up to 6 kB of data per second. - * - Each user can have up to five data streams simultaneously. + * - Each client within the channel can have up to five data channels simultaneously, with a total + * shared packet bitrate limit of 30 KB/s for all data channels. + * - Each data channel can send up to 60 packets per second, with each packet being a maximum of 1 + * KB. * * @param streamId The ID of the sent data stream, returned in the \ref agora::rtc::IRtcConnection::createDataStream "createDataStream" method. * @param data The pointer to the sent data. diff --git a/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/AgoraBase.h b/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/AgoraBase.h index c8903c4f5..8e895c597 100644 --- a/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/AgoraBase.h +++ b/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/AgoraBase.h @@ -92,6 +92,7 @@ #endif #define INVALID_DISPLAY_ID (-2) +#define MAX_AUDIO_CHANNELS (8) namespace agora { namespace util { @@ -294,6 +295,7 @@ enum CHANNEL_PROFILE_TYPE { /** * The channel types. + * @technical preview */ enum CHANNEL_TYPE { /** @@ -646,7 +648,8 @@ enum ERROR_CODE_TYPE { */ ERR_SIZE_TOO_LARGE = 114, /** - * 115: The data bitrate exceeds 6 KB/s when calling the `sendStreamMessage` method. + * 115: The data bitrate exceeds the data stream bitrate limit when calling the `sendStreamMessage` + * method. */ ERR_BITRATE_LIMIT = 115, /** @@ -845,31 +848,45 @@ enum ERROR_CODE_TYPE { ERR_VIDEOEFFECT_INVALID_BUNDLE_PATH = 1707, /** * 2007: Audio Device Module: An error occurs in starting the application loopback. + * + * @technical preview */ ERR_ADM_APPLICATION_LOOPBACK = 2007, /** * 2008: Audio Device Module: The application loopback was stopped unexpectedly, typically due to the application exiting or the user disabling loopback. + * + * @technical preview */ ERR_ADM_APPLICATION_LOOPBACK_STOPPED = 2008, /** * 2009: Audio Device Module: An error occurred while starting the system loopback. * This may be due to system restrictions, device conflicts, or other internal errors. + * + * @technical preview */ ERR_ADM_SYSTEM_LOOPBACK = 2009, /** * 2010: Audio Device Module: The system loopback was stopped unexpectedly, typically due to the user disabling loopback or a system error occurred. + * + * @technical preview */ ERR_ADM_SYSTEM_LOOPBACK_STOPPED = 2010, /** * 2011: Audio Device Module: No permission to start the loopback. + * + * @technical preview */ ERR_ADM_LOOPBACK_NO_PERMISSION = 2011, /** * 2012: Audio Device Module: Silent detected in loopback. + * + * @technical preview */ ERR_ADM_LOOPBACK_SILENT_DETECTED = 2012, /** * 2013: Audio Device Module: Silent recovered in loopback. + * + * @technical preview */ ERR_ADM_LOOPBACK_SILENT_RECOVERED = 2013, }; @@ -4561,13 +4578,16 @@ enum CONNECTION_STATE_TYPE { */ CONNECTION_STATE_RECONNECTING = 4, /** - * 5: The SDK fails to connect to the Agora edge server or join the channel. This state indicates - * that the SDK stops trying to rejoin the channel. You must call `leaveChannel()` to leave the - * channel. - * - You can call `joinChannel(const char* token, const char* channelId, uid_t uid, const - * ChannelMediaOptions& options)` to rejoin the channel. - * - If the SDK is banned from joining the channel by the Agora edge server through the RESTful API, - * the SDK triggers the `onConnectionStateChanged` callback. + * 5: The SDK fails to connect to the Agora edge server or join the channel and stops reconnecting. + * The reason reported by `onConnectionStateChanged` can vary when the user is kicked by the + * server, the token expires, or authentication fails, but the recovery flow is the same: + * - For `joinChannel`, call `leaveChannel()`, wait until CONNECTION_STATE_DISCONNECTED(1) is + * reported, and then call `joinChannel` with a valid new token. If you do not leave the channel + * first, `joinChannel` returns ERR_JOIN_CHANNEL_REJECTED(-17). + * - For `joinChannelEx`, call `leaveChannelEx` for the corresponding `RtcConnection`, wait until + * that connection enters CONNECTION_STATE_DISCONNECTED(1), and then call `joinChannelEx` with a + * valid new token. To clear only that connection, use `leaveChannelEx`; calling `leaveChannel` + * leaves all joined channels. */ CONNECTION_STATE_FAILED = 5, }; @@ -6204,28 +6224,68 @@ struct AudioTrackConfig { AudioTrackConfig() : enableLocalPlayback(true),enableAudioProcessing(false) {} }; -/** The type of loopback audio source mode -*/ +/** + * The type of loopback audio source mode + * + * @technical preview + */ enum LOOPBACK_AUDIO_TRACK_TYPE { - /** + /** * 0: loopback the whole system */ LOOPBACK_SYSTEM = 0, - /** + /** * 1: loopback the whole system exclude self */ LOOPBACK_SYSTEM_EXCLUDE_SELF = 1, - /** + /** * 2: loopback the specific application */ LOOPBACK_APPLICATION = 2, - /** + /** * 3: loopback the specific process */ LOOPBACK_PROCESS = 3, }; -/** Defines options for a custom loopback audio track. */ +/** The volume information of an audio track. */ +struct AudioTrackVolumeInfo { + /** The number of valid entries in levels. */ + int channelCount; + + /** + * The publish channel volumes in the range [0, 255]. Only the first channelCount entries are + * valid. + */ + int levels[MAX_AUDIO_CHANNELS]; +}; + +/** The per-track observer for audio tracks. */ +class IAudioTrackObserver { + public: + virtual ~IAudioTrackObserver() {} + + /** + * Occurs when the publish channel volumes of an audio track are available. + * + * The SDK invokes this callback at the interval configured by + * IMediaEngine::enableAudioTrackVolumeIndication(). + * + * @param trackId The audio track ID. + * @param volumeInfo The volume information. This pointer is valid only for the duration of the + * callback. + */ + virtual void onAudioTrackVolumeIndication(track_id_t trackId, const AudioTrackVolumeInfo* volumeInfo) { + (void)trackId; + (void)volumeInfo; + } +}; + +/** + * Defines options for a custom loopback audio track. + * + * @technical preview + */ struct LoopbackAudioTrackConfig { /** * Specifies the loopback source type. @@ -6235,7 +6295,7 @@ struct LoopbackAudioTrackConfig { LOOPBACK_AUDIO_TRACK_TYPE loopbackType; /** - * Initial playback volume for the loopback audio, valid in the range [0, 400]. + * Initial publish volume for the loopback audio, valid in the range [0, 400]. * 0: mute; 100: original volume; 400: maximum amplified volume. * Default is 100. */ diff --git a/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/IAgoraMediaEngine.h b/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/IAgoraMediaEngine.h index 797047c65..3f0c48491 100644 --- a/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/IAgoraMediaEngine.h +++ b/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/IAgoraMediaEngine.h @@ -422,9 +422,32 @@ class IMediaEngine { */ virtual int removeVideoFrameRenderer(IVideoFrameObserver *renderer) = 0; + /** + * Enables, updates, or disables the volume indication interval for an audio track. + * + * @technical preview + * + * @param id The audio track ID. + * @param interval The callback interval in milliseconds. A value greater than 0 enables or + * updates the interval. Positive values that are not multiples of 50 are rounded up to the + * next multiple of 50. A value less than or equal to 0 disables volume indication. + * + * @note Currently, volume indication is supported only for loopback audio tracks created by + * createLoopbackAudioTrack(). Custom audio tracks are not supported. + * @return + * - 0: Success. + * - -ERR_FAILED: id does not identify an existing loopback audio track, including when it + * identifies a custom audio track. + * - -ERR_INVALID_ARGUMENT: interval is too large to round up safely. + * - -ERR_NOT_SUPPORTED: The current platform does not support loopback audio tracks. + */ + virtual int enableAudioTrackVolumeIndication(rtc::track_id_t id, int interval) = 0; + /** * Create a loopback audio track and get the audio track id. * + * @technical preview + * * @note This method is only supported on macOS and Windows for now. * * @param config The config of loopback audio track @@ -436,9 +459,27 @@ class IMediaEngine { */ virtual rtc::track_id_t createLoopbackAudioTrack(const rtc::LoopbackAudioTrackConfig& config) = 0; + /** + * Adjusts the publish volume of a loopback audio track. + * + * @technical preview + * + * @param trackId The loopback audio track ID. + * @param volume The publish volume in the range [0, 400]. + * + * @note This method replaces the deprecated `updateLoopbackAudioTrackConfig` method. + * @return + * - 0: Success. + * - -ERR_INVALID_ARGUMENT: volume is outside the range [0, 400]. + * - -ERR_FAILED: no loopback audio track matches trackId. + */ + virtual int adjustLoopbackAudioPublishVolume(rtc::track_id_t trackId, int volume) = 0; + /** * Destroy loopback audio track by trackId * + * @technical preview + * * @note This method is only supported on macOS and Windows for now. * * @param trackId The loopback audio track id. @@ -450,17 +491,50 @@ class IMediaEngine { virtual int destroyLoopbackAudioTrack(rtc::track_id_t trackId) = 0; /** - * Update the configuration of the loopback audio track + * Registers an observer for an audio track. * - * @note This method is only supported on macOS and Windows for now. + * @technical preview * - * @param trackId The loopback audio track id. - * @param config The configuration of the loopback audio track. + * The same observer can be registered for multiple tracks. Registering the same observer for + * the same track more than once fails. + * + * @note Currently, registration is supported only for loopback audio tracks created by + * createLoopbackAudioTrack(). A custom PCM track cannot be registered through this API, even + * though the PCM track implementation supports volume indication internally. + * The caller must keep the observer valid until unregisterAudioTrackObserver() returns. + * + * @param id The loopback audio track ID. + * @param observer The observer that receives publish volume indications. This pointer must not + * be null. * @return * - 0: Success. - * - < 0: Failure. + * - -ERR_INVALID_ARGUMENT: observer is null. + * - -ERR_FAILED: id does not identify an existing audio track, observer is already registered + * for id, or the observer cannot be registered. + * - -ERR_NOT_SUPPORTED: id identifies an existing custom audio track. + */ + virtual int registerAudioTrackObserver(rtc::track_id_t id, + rtc::IAudioTrackObserver* observer) = 0; + + /** + * Unregisters an observer from an audio track. + * + * @technical preview + * + * When this method returns, the observer no longer receives callbacks for the specified track. + * + * @note Currently, only observers registered for loopback audio tracks can be unregistered + * through this API. Custom audio tracks are not supported. + * @param id The loopback audio track ID. + * @param observer The observer previously registered for id. This pointer must not be null. + * @return + * - 0: Success. + * - -ERR_INVALID_ARGUMENT: observer is null. + * - -ERR_FAILED: id does not identify an existing loopback audio track (including a custom + * audio track ID), or observer is not registered for id. */ - virtual int updateLoopbackAudioTrackConfig(rtc::track_id_t trackId, const rtc::LoopbackAudioTrackConfig& config) = 0; + virtual int unregisterAudioTrackObserver(rtc::track_id_t id, + rtc::IAudioTrackObserver* observer) = 0; /** * Release the media engine diff --git a/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/IAgoraRtcEngine.h b/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/IAgoraRtcEngine.h index d32b28401..2384f839d 100644 --- a/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/IAgoraRtcEngine.h +++ b/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/IAgoraRtcEngine.h @@ -1237,6 +1237,11 @@ struct ImageTrackOptions { ImageTrackOptions() : imageUrl(NULL), fps(1), mirrorMode(VIDEO_MIRROR_MODE_DISABLED) {} }; +struct AudioTrackIdList { + const track_id_t* trackIds; + int trackCount; +}; + /** * @brief The channel media options. * @@ -1347,12 +1352,25 @@ struct ChannelMediaOptions { * Whether to publish the loopback audio from a specific source: * - true: Publish the loopback audio from a specific source. * - false: (Default) Do not publish the loopback audio from the specific source. + * + * @technical preview */ Optional publishLoopbackAudioTrack; /** - * The loopback audio track id. + * The loopback audio track IDs to publish or unpublish. + * + * When `publishLoopbackAudioTrack` is `true`, the SDK publishes every track in + * this list; when it is `false`, the SDK unpublishes every track in this + * list. If `publishLoopbackAudioTrack` is not set, this option does not + * trigger a publish operation. + * + * @note `trackIds` must remain valid until the method that receives + * `ChannelMediaOptions` returns. + * The removed `publishLoopbackAudioTrackId` option is replaced by this list-based option. + * + * @technical preview */ - Optional publishLoopbackAudioTrackId; + Optional publishLoopbackAudioTrackIds; /** * Whether to publish the video captured from a custom source: * - `true`: Publish the video captured from the custom source. @@ -1546,6 +1564,7 @@ struct ChannelMediaOptions { /** * The channel type. See `CHANNEL_TYPE`. * @note Valid only when calling channel joining methods (e.g. `joinChannel`, `joinChannelEx`); ignored by `updateChannelMediaOptions`. + * @technical preview * @since 4.6.3 */ Optional channelType; @@ -1578,7 +1597,7 @@ struct ChannelMediaOptions { SET_FROM(publishCustomAudioTrack); SET_FROM(publishCustomAudioTrackId); SET_FROM(publishLoopbackAudioTrack); - SET_FROM(publishLoopbackAudioTrackId); + SET_FROM(publishLoopbackAudioTrackIds); SET_FROM(publishCustomVideoTrack); SET_FROM(publishEncodedVideoTrack); SET_FROM(publishMediaPlayerAudioTrack); @@ -1636,7 +1655,6 @@ struct ChannelMediaOptions { ADD_COMPARE(publishCustomAudioTrack); ADD_COMPARE(publishCustomAudioTrackId); ADD_COMPARE(publishLoopbackAudioTrack); - ADD_COMPARE(publishLoopbackAudioTrackId); ADD_COMPARE(publishCustomVideoTrack); ADD_COMPARE(publishEncodedVideoTrack); ADD_COMPARE(publishMediaPlayerAudioTrack); @@ -1697,7 +1715,7 @@ struct ChannelMediaOptions { REPLACE_BY(publishCustomAudioTrack); REPLACE_BY(publishCustomAudioTrackId); REPLACE_BY(publishLoopbackAudioTrack); - REPLACE_BY(publishLoopbackAudioTrackId); + REPLACE_BY(publishLoopbackAudioTrackIds); REPLACE_BY(publishCustomVideoTrack); REPLACE_BY(publishEncodedVideoTrack); REPLACE_BY(publishMediaPlayerAudioTrack); @@ -4209,11 +4227,11 @@ struct RtcEngineContext { bool autoRegisterAgoraExtensions; - /* + /** + * @technical preview * Provides the technical preview functionalities or special customizations by configuring the SDK with JSON options. * Pointer to the set parameters in a JSON string. - * @technical preview - */ + */ const char* parameters; RtcEngineContext() @@ -8984,6 +9002,10 @@ class IRtcEngine : public agora::base::IEngineBase { * If you enable loopback audio capturing, the output of the sound card is mixed into the audio * stream sent to the other end. * + * @deprecated This method is deprecated. Use `IMediaEngine::createLoopbackAudioTrack` to + * create a loopback audio track, then use `ChannelMediaOptions::publishLoopbackAudioTrackIds` + * to publish it. Use `IMediaEngine::adjustLoopbackAudioPublishVolume` to adjust its volume. + * * @note * - This method applies to the macOS and Windows only. * - You can call this method either before or after joining a channel. @@ -9005,7 +9027,7 @@ class IRtcEngine : public agora::base::IEngineBase { * - 0: Success. * - < 0: Failure. */ - virtual int enableLoopbackRecording(bool enabled, const char* deviceName = NULL) = 0; + virtual int enableLoopbackRecording(bool enabled, const char* deviceName = NULL) __deprecated = 0; /** @@ -10939,9 +10961,8 @@ class IRtcEngine : public agora::base::IEngineBase { * code. * * @note - * Each user can create up to five data streams during the lifecycle of `IRtcEngine`. The data - * stream will be destroyed when leaving the channel, and the data stream needs to be recreated if - * needed. + * Each client can have up to five data streams simultaneously in a channel. The data stream is + * destroyed when leaving the channel, and the data stream needs to be recreated if needed. * If you need a more comprehensive solution for low-latency, high-concurrency, and scalable * real-time messaging and status synchronization, it is recommended to use [Signaling](https://docs.agora.io/en/signaling/overview/product-overview). * @@ -10976,9 +10997,8 @@ class IRtcEngine : public agora::base::IEngineBase { * Call timing: You can call this method either before or after joining a channel. * * @note - * Each user can create up to five data streams during the lifecycle of `IRtcEngine`. The data - * stream will be destroyed when leaving the channel, and the data stream needs to be recreated if - * needed. + * Each client can have up to five data streams simultaneously in a channel. The data stream is + * destroyed when leaving the channel, and the data stream needs to be recreated if needed. * If you need a more comprehensive solution for low-latency, high-concurrency, and scalable * real-time messaging and status synchronization, it is recommended to use [Signaling](https://docs.agora.io/en/signaling/overview/product-overview). * diff --git a/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/IAgoraRtcEngineEx.h b/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/IAgoraRtcEngineEx.h index 8611f7366..33d389e8d 100644 --- a/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/IAgoraRtcEngineEx.h +++ b/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/IAgoraRtcEngineEx.h @@ -1747,6 +1747,11 @@ class IRtcEngineEx : public IRtcEngine { /** * @brief Enables loopback audio capturing. * + * @deprecated This method is deprecated. Use `IMediaEngine::createLoopbackAudioTrack` to + * create a loopback audio track, then use the connection's channel media options and + * `publishLoopbackAudioTrackIds` to publish it. Use + * `IMediaEngine::adjustLoopbackAudioPublishVolume` to adjust its volume. + * * @details * If you enable loopback audio capturing, the output of the sound card is mixed into the audio * stream sent to the other end. @@ -1771,7 +1776,8 @@ class IRtcEngineEx : public IRtcEngine { * - 0: Success. * - < 0: Failure. */ - virtual int enableLoopbackRecordingEx(const RtcConnection& connection, bool enabled, const char* deviceName = NULL) = 0; + virtual int enableLoopbackRecordingEx(const RtcConnection& connection, bool enabled, + const char* deviceName = NULL) __deprecated = 0; /** * Adjusts the recording volume. @@ -1874,8 +1880,8 @@ class IRtcEngineEx : public IRtcEngine { * within five seconds, the SDK triggers the `onStreamMessageError` callback and returns an error * code. * - * @note Each user can create up to five data streams during the lifecycle of `IRtcEngine`. The data - * stream will be destroyed when leaving the channel, and the data stream needs to be recreated if + * @note Each client can have up to five data streams simultaneously in a channel. The data + * stream is destroyed when leaving the channel, and the data stream needs to be recreated if * needed. * * @param streamId An output parameter; the ID of the data stream created. @@ -1909,9 +1915,8 @@ class IRtcEngineEx : public IRtcEngine { * Call timing: Call this method after `joinChannelEx`. * * @note - * Each user can create up to five data streams during the lifecycle of `IRtcEngine`. The data - * stream will be destroyed when leaving the channel, and the data stream needs to be recreated if - * needed. + * Each client can have up to five data streams simultaneously in a channel. The data stream is + * destroyed when leaving the channel, and the data stream needs to be recreated if needed. * If you need a more comprehensive solution for low-latency, high-concurrency, and scalable * real-time messaging and status synchronization, it is recommended to use [Signaling](https://docs.agora.io/en/signaling/overview/product-overview). * diff --git a/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/rte_base/rte_cpp_player.h b/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/rte_base/rte_cpp_player.h index 920856e5d..68b42b778 100644 --- a/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/rte_base/rte_cpp_player.h +++ b/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/rte_base/rte_cpp_player.h @@ -613,6 +613,8 @@ class PlayerObserver { * play the mixed audio RTE URL, you can use this callback to get the volume information of each * audio stream before mixing. * + * @technical preview + * * @param stream_data The received stream data. * @return void */ diff --git a/Android/APIExample/gradle.properties b/Android/APIExample/gradle.properties index 384f9d744..ea6bc007e 100644 --- a/Android/APIExample/gradle.properties +++ b/Android/APIExample/gradle.properties @@ -25,4 +25,4 @@ simpleFilter = false # read enable stream encrypt section on README first before set this flag to TRUE streamEncrypt = false -rtc_sdk_version = 4.7.0 +rtc_sdk_version = 4.7.1 diff --git a/docs/ai/project-matrix.md b/docs/ai/project-matrix.md index e340e456b..035bfd87a 100644 --- a/docs/ai/project-matrix.md +++ b/docs/ai/project-matrix.md @@ -28,6 +28,22 @@ not inject an Aliyun Maven repository for RTC dependencies. Validate Maven resol without a local SDK and with a fresh dependency cache; compiling with a bundled SDK does not validate the public repository. +## Apple SDK source + +All four iOS projects declare +`https://download.agora.io/cocoapods/` before `https://cdn.cocoapods.org/` in their +Podfiles. The Agora source provides the overseas SDK specs; the public CocoaPods CDN +remains available for third-party pods. This overseas repository uses the Agora Maven +and CocoaPods endpoints, not the Shengwang domestic endpoints. + +The 4.7.1 update applies to Android and iOS. macOS and Windows retain SDK 4.7.0 +because SDK 4.7.1 was not released for those platforms. The macOS Podfile retains +its existing dependency source configuration. + +The iOS UIKit full project retains its local `sdk.podspec` release integration. +Its declared sources apply to published pods, including the SDK when compile CI switches +the local dependency to `AgoraRtcEngine_iOS`. + ## Scope Rules - SDK version, dependency, credential plumbing, CI, and packaging changes require review of diff --git a/iOS/APIExample-Audio/APIExample-Audio.xcodeproj/project.pbxproj b/iOS/APIExample-Audio/APIExample-Audio.xcodeproj/project.pbxproj index 06fbaebeb..7f387131d 100644 --- a/iOS/APIExample-Audio/APIExample-Audio.xcodeproj/project.pbxproj +++ b/iOS/APIExample-Audio/APIExample-Audio.xcodeproj/project.pbxproj @@ -979,7 +979,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 4.7.0; + MARKETING_VERSION = 4.7.1; OTHER_LDFLAGS = ( "$(inherited)", "-ObjC", @@ -1049,7 +1049,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 4.7.0; + MARKETING_VERSION = 4.7.1; OTHER_LDFLAGS = ( "$(inherited)", "-ObjC", diff --git a/iOS/APIExample-Audio/Podfile b/iOS/APIExample-Audio/Podfile index bd9c7d606..f79a9b00d 100644 --- a/iOS/APIExample-Audio/Podfile +++ b/iOS/APIExample-Audio/Podfile @@ -1,16 +1,18 @@ +source 'https://download.agora.io/cocoapods/' +source 'https://cdn.cocoapods.org/' + # Uncomment the next line to define a global platform for your project # platform :ios, '9.0' -#source 'https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git' target 'APIExample-Audio' do use_frameworks! pod 'Floaty', '~> 4.2.0' pod 'AGEVideoLayout', '~> 1.0.2' - pod 'AgoraAudio_iOS', '4.7.0' + pod 'AgoraAudio_iOS', '4.7.1' # pod 'sdk', :path => 'sdk.podspec' end pre_install do |installer| - # system("sh .download_script.sh 4.7.0 true") + # system("sh .download_script.sh 4.7.1 true") end diff --git a/iOS/APIExample-OC/APIExample-OC.xcodeproj/project.pbxproj b/iOS/APIExample-OC/APIExample-OC.xcodeproj/project.pbxproj index a358f4740..4725d4c44 100644 --- a/iOS/APIExample-OC/APIExample-OC.xcodeproj/project.pbxproj +++ b/iOS/APIExample-OC/APIExample-OC.xcodeproj/project.pbxproj @@ -1637,7 +1637,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 4.7.0; + MARKETING_VERSION = 4.7.1; PRODUCT_BUNDLE_IDENTIFIER = "io.agora.api.examples-oc"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -1678,7 +1678,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 4.7.0; + MARKETING_VERSION = 4.7.1; PRODUCT_BUNDLE_IDENTIFIER = "io.agora.api.examples-oc"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -1711,7 +1711,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 4.7.0; + MARKETING_VERSION = 4.7.1; PRODUCT_BUNDLE_IDENTIFIER = "io.agora.api.examples-oc.Agora-ScreenShare-Extension-OC"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -1740,7 +1740,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 4.7.0; + MARKETING_VERSION = 4.7.1; PRODUCT_BUNDLE_IDENTIFIER = "io.agora.api.examples-oc.Agora-ScreenShare-Extension-OC"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/iOS/APIExample-OC/Podfile b/iOS/APIExample-OC/Podfile index 43e0bc065..54f6731a5 100644 --- a/iOS/APIExample-OC/Podfile +++ b/iOS/APIExample-OC/Podfile @@ -1,8 +1,11 @@ +source 'https://download.agora.io/cocoapods/' +source 'https://cdn.cocoapods.org/' + # Uncomment the next line to define a global platform for your project # platform :ios, '9.0' def common_pods - pod 'AgoraRtcEngine_iOS', '4.7.0' + pod 'AgoraRtcEngine_iOS', '4.7.1' # pod 'sdk', :path => 'sdk.podspec' end @@ -26,5 +29,5 @@ target 'SimpleFilter' do end pre_install do |installer| - # system("sh .download_script.sh 4.7.0 true") + # system("sh .download_script.sh 4.7.1 true") end diff --git a/iOS/APIExample-SwiftUI/APIExample-SwiftUI.xcodeproj/project.pbxproj b/iOS/APIExample-SwiftUI/APIExample-SwiftUI.xcodeproj/project.pbxproj index 579dc01d6..24298d01e 100644 --- a/iOS/APIExample-SwiftUI/APIExample-SwiftUI.xcodeproj/project.pbxproj +++ b/iOS/APIExample-SwiftUI/APIExample-SwiftUI.xcodeproj/project.pbxproj @@ -1403,7 +1403,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 4.7.0; + MARKETING_VERSION = 4.7.1; PRODUCT_BUNDLE_IDENTIFIER = "io.agora.api.examples-swiftUI"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -1442,7 +1442,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 4.7.0; + MARKETING_VERSION = 4.7.1; PRODUCT_BUNDLE_IDENTIFIER = "io.agora.api.examples-swiftUI"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -1472,7 +1472,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 4.7.0; + MARKETING_VERSION = 4.7.1; PRODUCT_BUNDLE_IDENTIFIER = "io.agora.api.examples-swiftUI.Agora-ScreenShare-Extension"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -1503,7 +1503,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 4.7.0; + MARKETING_VERSION = 4.7.1; PRODUCT_BUNDLE_IDENTIFIER = "io.agora.api.examples-swiftUI.Agora-ScreenShare-Extension"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/iOS/APIExample-SwiftUI/Podfile b/iOS/APIExample-SwiftUI/Podfile index a59f9d423..ee2d7fa7a 100644 --- a/iOS/APIExample-SwiftUI/Podfile +++ b/iOS/APIExample-SwiftUI/Podfile @@ -1,8 +1,11 @@ +source 'https://download.agora.io/cocoapods/' +source 'https://cdn.cocoapods.org/' + # Uncomment the next line to define a global platform for your project # platform :ios, '9.0' def common_pods - pod 'AgoraRtcEngine_iOS', '4.7.0' + pod 'AgoraRtcEngine_iOS', '4.7.1' #pod 'sdk', :path => 'sdk.podspec' end @@ -32,5 +35,5 @@ end #end pre_install do |installer| -# system("sh .download_script.sh 4.7.0 true") +# system("sh .download_script.sh 4.7.1 true") end diff --git a/iOS/APIExample/APIExample.xcodeproj/project.pbxproj b/iOS/APIExample/APIExample.xcodeproj/project.pbxproj index 6410afadd..c9021396b 100644 --- a/iOS/APIExample/APIExample.xcodeproj/project.pbxproj +++ b/iOS/APIExample/APIExample.xcodeproj/project.pbxproj @@ -2399,7 +2399,7 @@ "$(inherited)", "$(PROJECT_DIR)/Agora-ScreenShare-Extension", ); - MARKETING_VERSION = 4.7.0; + MARKETING_VERSION = 4.7.1; PRODUCT_BUNDLE_IDENTIFIER = "io.agora.api.examples.Agora-ScreenShare-Extension"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -2435,7 +2435,7 @@ "$(inherited)", "$(PROJECT_DIR)/Agora-ScreenShare-Extension", ); - MARKETING_VERSION = 4.7.0; + MARKETING_VERSION = 4.7.1; PRODUCT_BUNDLE_IDENTIFIER = "io.agora.api.examples.Agora-ScreenShare-Extension"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -2592,7 +2592,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 4.7.0; + MARKETING_VERSION = 4.7.1; OTHER_LDFLAGS = ( "$(inherited)", "-ObjC", @@ -2665,7 +2665,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 4.7.0; + MARKETING_VERSION = 4.7.1; OTHER_LDFLAGS = ( "$(inherited)", "-ObjC", diff --git a/iOS/APIExample/APIExample/Examples/Advanced/StreamEncryption/StreamEncryption.swift b/iOS/APIExample/APIExample/Examples/Advanced/StreamEncryption/StreamEncryption.swift index 5968fb3fd..dd64be35c 100644 --- a/iOS/APIExample/APIExample/Examples/Advanced/StreamEncryption/StreamEncryption.swift +++ b/iOS/APIExample/APIExample/Examples/Advanced/StreamEncryption/StreamEncryption.swift @@ -79,6 +79,8 @@ class StreamEncryptionMain: BaseViewController { @IBOutlet weak var container: AGEVideoContainer! var agoraKit: AgoraRtcEngineKit! + private var joinRequestID = 0 + private var customEncryptionRegistered = false // indicate if current instance has joined channel var isJoined: Bool = false @@ -128,6 +130,7 @@ class StreamEncryptionMain: BaseViewController { } else { // your own custom algorithm encryption AgoraCustomEncryption.registerPacketProcessing(agoraKit) + customEncryptionRegistered = true } // enable video module and set up video encoding configs @@ -147,6 +150,9 @@ class StreamEncryptionMain: BaseViewController { } private func joinChannel(channelName: String) { + guard let engine = agoraKit else { return } + joinRequestID += 1 + let requestID = joinRequestID // set up local video to render your local camera preview let videoCanvas = AgoraRtcVideoCanvas() videoCanvas.uid = 0 @@ -166,21 +172,33 @@ class StreamEncryptionMain: BaseViewController { // 2. If app certificate is turned on at dashboard, token is needed // when joining channel. The channel name and uid used to calculate // the token has to match the ones used for channel join - NetworkManager.shared.generateToken(channelName: channelName, success: { token in - let result = self.agoraKit.joinChannel(byToken: token, - channelId: channelName, - info: nil, uid: 0) { [unowned self] (channel, uid, elapsed) -> Void in - self.isJoined = true - LogUtils.log(message: "Join \(channel) with uid \(uid) elapsed \(elapsed)ms", level: .info) - } - if result != 0 { - // Usually happens with invalid parameters - // Error code description can be found at: - // en: https://api-ref.agora.io/en/video-sdk/ios/4.x/documentation/agorartckit/agoraerrorcode - // cn: https://doc.shengwang.cn/api-ref/rtc/ios/error-code - self.showAlert(title: "Error", message: "joinChannel call failed: \(result), please check your params") + NetworkManager.shared.generateToken(channelName: channelName) { [weak self, weak engine] token in + DispatchQueue.main.async { [weak self, weak engine] in + guard let self = self, let engine = engine, + self.joinRequestID == requestID, self.agoraKit === engine else { return } + if !(KeyCenter.Certificate ?? "").isEmpty && (token ?? "").isEmpty { + self.showAlert(title: "Error", message: "Token request failed") + return + } + let result = engine.joinChannel(byToken: token, channelId: channelName, + info: nil, uid: 0) { [weak self, weak engine] channel, uid, elapsed in + DispatchQueue.main.async { [weak self, weak engine] in + guard let self = self, let engine = engine, + self.joinRequestID == requestID, self.agoraKit === engine, + channel == channelName else { return } + self.isJoined = true + LogUtils.log(message: "Join \(channel) with uid \(uid) elapsed \(elapsed)ms", level: .info) + } + } + if result != 0 { + // Usually happens with invalid parameters + // Error code description can be found at: + // en: https://api-ref.agora.io/en/video-sdk/ios/4.x/documentation/agorartckit/agoraerrorcode + // cn: https://doc.shengwang.cn/api-ref/rtc/ios/error-code + self.showAlert(title: "Error", message: "joinChannel call failed: \(result), please check your params") + } } - }) + } } func getEncryptionSaltFromServer() -> Data { @@ -192,22 +210,30 @@ class StreamEncryptionMain: BaseViewController { } override func willMove(toParent parent: UIViewController?) { + super.willMove(toParent: parent) if parent == nil { - // leave channel when exiting the view - - agoraKit.leaveChannel() - agoraKit.enableEncryption(false, encryptionConfig: AgoraEncryptionConfig()) - guard let useCustom = configs["useCustom"] as? Bool else { return } - if useCustom { - // deregister packet processing - AgoraCustomEncryption.deregisterPacketProcessing(agoraKit) - if isJoined { - agoraKit.leaveChannel { (stats) -> Void in - LogUtils.log(message: "left channel, duration: \(stats.duration)", level: .info) - } - } - } + destroyEngine() + } + } + + private func destroyEngine() { + // Invalidate pending Token and SDK callbacks before releasing this session. + joinRequestID += 1 + isJoined = false + guard let engine = agoraKit else { return } + agoraKit = nil + engine.delegate = nil + engine.stopPreview() + if customEncryptionRegistered { + AgoraCustomEncryption.deregisterPacketProcessing(engine) + customEncryptionRegistered = false } + engine.leaveChannel() + engine.enableEncryption(false, encryptionConfig: AgoraEncryptionConfig()) + let canvas = AgoraRtcVideoCanvas() + canvas.view = nil + engine.setupLocalVideo(canvas) + AgoraRtcEngineKit.destroy() } } @@ -237,17 +263,17 @@ extension StreamEncryptionMain: AgoraRtcEngineDelegate { /// @param uid uid of remote joined user /// @param elapsed time elapse since current sdk instance join the channel in ms func rtcEngine(_ engine: AgoraRtcEngineKit, didJoinedOfUid uid: UInt, elapsed: Int) { - LogUtils.log(message: "remote user join: \(uid) \(elapsed)ms", level: .info) - - // Only one remote video view is available for this - // tutorial. Here we check if there exists a surface - // view tagged as this uid. - let videoCanvas = AgoraRtcVideoCanvas() - videoCanvas.uid = uid - // the view to be binded - videoCanvas.view = remoteVideo.videoView - videoCanvas.renderMode = .hidden - agoraKit.setupRemoteVideo(videoCanvas) + DispatchQueue.main.async { [weak self, weak engine] in + guard let self = self, let engine = engine, self.agoraKit === engine else { return } + LogUtils.log(message: "remote user join: \(uid) \(elapsed)ms", level: .info) + + // Only one remote video view is available for this tutorial. + let videoCanvas = AgoraRtcVideoCanvas() + videoCanvas.uid = uid + videoCanvas.view = self.remoteVideo.videoView + videoCanvas.renderMode = .hidden + engine.setupRemoteVideo(videoCanvas) + } } /// callback when a remote user is leaving the channel, note audience in live broadcast mode will NOT trigger this event @@ -255,16 +281,16 @@ extension StreamEncryptionMain: AgoraRtcEngineDelegate { /// @param reason reason why this user left, note this event may be triggered when the remote user /// become an audience in live broadcasting profile func rtcEngine(_ engine: AgoraRtcEngineKit, didOfflineOfUid uid: UInt, reason: AgoraUserOfflineReason) { - LogUtils.log(message: "remote user left: \(uid) reason \(reason)", level: .info) - - // to unlink your view from sdk, so that your view reference will be released - // note the video will stay at its last frame, to completely remove it - // you will need to remove the EAGL sublayer from your binded view - let videoCanvas = AgoraRtcVideoCanvas() - videoCanvas.uid = uid - // the view to be binded - videoCanvas.view = nil - videoCanvas.renderMode = .hidden - agoraKit.setupRemoteVideo(videoCanvas) + DispatchQueue.main.async { [weak self, weak engine] in + guard let self = self, let engine = engine, self.agoraKit === engine else { return } + LogUtils.log(message: "remote user left: \(uid) reason \(reason)", level: .info) + + // Unlink the remote view so the SDK releases its reference. + let videoCanvas = AgoraRtcVideoCanvas() + videoCanvas.uid = uid + videoCanvas.view = nil + videoCanvas.renderMode = .hidden + engine.setupRemoteVideo(videoCanvas) + } } } diff --git a/iOS/APIExample/ARCHITECTURE.md b/iOS/APIExample/ARCHITECTURE.md index 511c72ccc..1375ff2f4 100644 --- a/iOS/APIExample/ARCHITECTURE.md +++ b/iOS/APIExample/ARCHITECTURE.md @@ -44,7 +44,7 @@ own view/window hierarchy; do not use `Floaty.global`, which creates a window wi | SimpleFilter | `Examples/Advanced/SimpleFilter/SimpleFilter.swift` | `enableExtension()`, `setExtensionPropertyWithVendor()` | Apply audio/video filter via Agora Extension API | | QuickSwitchChannel | `Examples/Advanced/QuickSwitchChannel/QuickSwitchChannel.swift` | `joinChannel()`, `leaveChannel()` | Quickly switch between channels as audience | | JoinMultiChannel | `Examples/Advanced/JoinMultiChannel/JoinMultiChannel.swift` | `joinChannelEx()`, `takeSnapshotEx()` | Join multiple channels simultaneously via ex connection | -| StreamEncryption | `Examples/Advanced/StreamEncryption/StreamEncryption.swift` | `enableEncryption()` | Built-in and custom stream encryption | +| StreamEncryption | `Examples/Advanced/StreamEncryption/StreamEncryption.swift` | `enableEncryption()` | Built-in and custom stream encryption with session-guarded callbacks and complete engine cleanup on exit | | AudioMixing | `Examples/Advanced/AudioMixing/AudioMixing.swift` | `startAudioMixing()`, `stopAudioMixing()`, `adjustAudioMixingVolume()`, `setEffectsVolume()` | Mix local audio file with microphone input | | PrecallTest | `Examples/Advanced/PrecallTest/PrecallTest.swift` | `startEchoTest()`, `stopEchoTest()`, `startLastmileProbeTest()`, `stopLastmileProbeTest()` | Pre-call echo test and last-mile network probe | | MediaPlayer | `Examples/Advanced/MediaPlayer/MediaPlayer.swift` | `createMediaPlayer()`, `updateChannelEx()` | Play media files and publish to channel via media player | diff --git a/iOS/APIExample/Podfile b/iOS/APIExample/Podfile index 225da67a9..2baf84f16 100644 --- a/iOS/APIExample/Podfile +++ b/iOS/APIExample/Podfile @@ -1,9 +1,11 @@ +source 'https://download.agora.io/cocoapods/' +source 'https://cdn.cocoapods.org/' + platform :ios, '12.0' -#source 'https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git' def common_pods - # pod 'AgoraRtcEngine_iOS', '4.7.0' + # pod 'AgoraRtcEngine_iOS', '4.7.1' pod 'sdk', :path => 'sdk.podspec' end @@ -37,7 +39,7 @@ target 'SimpleFilter' do end pre_install do |installer| -# system("sh .download_script.sh 4.7.0 true") +# system("sh .download_script.sh 4.7.1 true") end # Xcode 27 SDKs require iOS 15; retain each pod's default for older SDKs.