diff --git a/Android/APIExample-Audio/app/src/main/java/io/agora/api/example/common/model/StatisticsInfo.java b/Android/APIExample-Audio/app/src/main/java/io/agora/api/example/common/model/StatisticsInfo.java index 8396614b0..0b41aa1eb 100644 --- a/Android/APIExample-Audio/app/src/main/java/io/agora/api/example/common/model/StatisticsInfo.java +++ b/Android/APIExample-Audio/app/src/main/java/io/agora/api/example/common/model/StatisticsInfo.java @@ -1,24 +1,24 @@ package io.agora.api.example.common.model; +import io.agora.rtc2.IRtcEngineEventHandler; import io.agora.rtc2.IRtcEngineEventHandler.LocalVideoStats; import io.agora.rtc2.IRtcEngineEventHandler.RemoteAudioStats; import io.agora.rtc2.IRtcEngineEventHandler.RemoteVideoStats; -import io.agora.rtc2.IRtcEngineEventHandlerBase; public class StatisticsInfo { - private LocalVideoStats localVideoStats = new LocalVideoStats(new IRtcEngineEventHandlerBase.LocalVideoStatsBase()); - private IRtcEngineEventHandlerBase.LocalAudioStats localAudioStats = new IRtcEngineEventHandlerBase.LocalAudioStats(); - private RemoteVideoStats remoteVideoStats = new RemoteVideoStats(new IRtcEngineEventHandlerBase.RemoteVideoStatsBase()); - private RemoteAudioStats remoteAudioStats = new RemoteAudioStats(new IRtcEngineEventHandlerBase.RemoteAudioStatsBase()); - private IRtcEngineEventHandlerBase.RtcStats rtcStats = new IRtcEngineEventHandlerBase.RtcStats(); + private LocalVideoStats localVideoStats = new LocalVideoStats(); + private IRtcEngineEventHandler.LocalAudioStats localAudioStats = new IRtcEngineEventHandler.LocalAudioStats(); + private RemoteVideoStats remoteVideoStats = new RemoteVideoStats(); + private RemoteAudioStats remoteAudioStats = new RemoteAudioStats(); + private IRtcEngineEventHandler.RtcStats rtcStats = new IRtcEngineEventHandler.RtcStats(); private int quality; - private IRtcEngineEventHandlerBase.LastmileProbeResult lastMileProbeResult; + private IRtcEngineEventHandler.LastmileProbeResult lastMileProbeResult; public void setLocalVideoStats(LocalVideoStats localVideoStats) { this.localVideoStats = localVideoStats; } - public void setLocalAudioStats(IRtcEngineEventHandlerBase.LocalAudioStats localAudioStats) { + public void setLocalAudioStats(IRtcEngineEventHandler.LocalAudioStats localAudioStats) { this.localAudioStats = localAudioStats; } @@ -30,7 +30,7 @@ public void setRemoteAudioStats(RemoteAudioStats remoteAudioStats) { this.remoteAudioStats = remoteAudioStats; } - public void setRtcStats(IRtcEngineEventHandlerBase.RtcStats rtcStats) { + public void setRtcStats(IRtcEngineEventHandler.RtcStats rtcStats) { this.rtcStats = rtcStats; } @@ -160,7 +160,7 @@ public String getLastMileResult() { return stringBuilder.toString(); } - public void setLastMileProbeResult(IRtcEngineEventHandlerBase.LastmileProbeResult lastmileProbeResult) { + public void setLastMileProbeResult(IRtcEngineEventHandler.LastmileProbeResult lastmileProbeResult) { this.lastMileProbeResult = lastmileProbeResult; } diff --git a/Android/APIExample-Audio/app/src/main/java/io/agora/api/example/examples/advanced/SpatialSound.java b/Android/APIExample-Audio/app/src/main/java/io/agora/api/example/examples/advanced/SpatialSound.java index f3a63f32a..83bc7b8b1 100644 --- a/Android/APIExample-Audio/app/src/main/java/io/agora/api/example/examples/advanced/SpatialSound.java +++ b/Android/APIExample-Audio/app/src/main/java/io/agora/api/example/examples/advanced/SpatialSound.java @@ -399,8 +399,9 @@ private void unInitMediaPlayers() { private IMediaPlayer createLoopMediaPlayer() { IMediaPlayer mediaPlayer = engine.createMediaPlayer(); mediaPlayer.registerPlayerObserver(new IMediaPlayerObserver() { + @Override - public void onPlayerStateChanged(Constants.MediaPlayerState state, Constants.MediaPlayerError error) { + public void onPlayerStateChanged(Constants.MediaPlayerState state, Constants.MediaPlayerReason reason) { if (state.equals(PLAYER_STATE_OPEN_COMPLETED)) { mediaPlayer.setLoopCount(-1); mediaPlayer.play(); 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 81580b034..a3b4647a6 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 @@ -80,7 +80,7 @@ #endif #endif -#define INVALID_DISPLAY_ID 0xffff +#define INVALID_DISPLAY_ID (-2) namespace agora { namespace util { @@ -92,16 +92,16 @@ class AutoPtr { typedef T* pointer_type; public: - explicit AutoPtr(pointer_type p = NULL) : ptr_(p) {} + explicit AutoPtr(pointer_type p = OPTIONAL_NULLPTR) : ptr_(p) {} ~AutoPtr() { if (ptr_) { ptr_->release(); - ptr_ = NULL; + ptr_ = OPTIONAL_NULLPTR; } } - operator bool() const { return (ptr_ != NULL); } + operator bool() const { return (ptr_ != OPTIONAL_NULLPTR); } value_type& operator*() const { return *get(); } @@ -115,7 +115,7 @@ class AutoPtr { return ret; } - void reset(pointer_type ptr = NULL) { + void reset(pointer_type ptr = OPTIONAL_NULLPTR) { if (ptr != ptr_ && ptr_) { ptr_->release(); } @@ -125,12 +125,12 @@ class AutoPtr { template bool queryInterface(C1* c, C2 iid) { - pointer_type p = NULL; + pointer_type p = OPTIONAL_NULLPTR; if (c && !c->queryInterface(iid, reinterpret_cast(&p))) { reset(p); } - return (p != NULL); + return (p != OPTIONAL_NULLPTR); } private: @@ -153,7 +153,7 @@ class CopyableAutoPtr : public AutoPtr { return *this; } pointer_type clone() const { - if (!this->get()) return NULL; + if (!this->get()) return OPTIONAL_NULLPTR; return this->get()->clone(); } }; @@ -197,7 +197,7 @@ class AOutputIterator { typedef const value_type& const_reference; typedef value_type* pointer; typedef const value_type* const_pointer; - explicit AOutputIterator(IIterator* it = NULL) : p(it) {} + explicit AOutputIterator(IIterator* it = OPTIONAL_NULLPTR) : p(it) {} ~AOutputIterator() { if (p) p->release(); } @@ -215,7 +215,7 @@ class AOutputIterator { bool operator!=(const AOutputIterator& rhs) const { return !this->operator==(rhs); } reference operator*() { return *reinterpret_cast(p->current()); } const_reference operator*() const { return *reinterpret_cast(p->const_current()); } - bool valid() const { return p && p->current() != NULL; } + bool valid() const { return p && p->current() != OPTIONAL_NULLPTR; } }; template @@ -234,16 +234,16 @@ class AList { typedef const AOutputIterator const_iterator; public: - AList() : container(NULL), owner(false) {} + AList() : container(OPTIONAL_NULLPTR), owner(false) {} AList(IContainer* c, bool take_ownership) : container(c), owner(take_ownership) {} ~AList() { reset(); } - void reset(IContainer* c = NULL, bool take_ownership = false) { + void reset(IContainer* c = OPTIONAL_NULLPTR, bool take_ownership = false) { if (owner && container) container->release(); container = c; owner = take_ownership; } - iterator begin() { return container ? iterator(container->begin()) : iterator(NULL); } - iterator end() { return iterator(NULL); } + iterator begin() { return container ? iterator(container->begin()) : iterator(OPTIONAL_NULLPTR); } + iterator end() { return iterator(OPTIONAL_NULLPTR); } size_type size() const { return container ? container->size() : 0; } bool empty() const { return size() == 0; } }; @@ -731,10 +731,6 @@ enum ERROR_CODE_TYPE { * 1501: Video Device Module: The camera is not authorized. */ ERR_VDM_CAMERA_NOT_AUTHORIZED = 1501, - /** - * 2007: Audio Device Module: An error occurs in starting the application loopback. - */ - ERR_ADM_APPLICATION_LOOPBACK = 2007, }; enum LICENSE_ERROR_TYPE { @@ -857,9 +853,9 @@ enum INTERFACE_ID_TYPE { AGORA_IID_CLOUD_SPATIAL_AUDIO = 10, AGORA_IID_LOCAL_SPATIAL_AUDIO = 11, AGORA_IID_STATE_SYNC = 13, - AGORA_IID_METACHAT_SERVICE = 14, + AGORA_IID_META_SERVICE = 14, AGORA_IID_MUSIC_CONTENT_CENTER = 15, - AGORA_IID_H265_TRANSCODER = 16, + AGORA_IID_H265_TRANSCODER = 16, }; /** @@ -1267,7 +1263,7 @@ struct SenderOptions { SenderOptions() : ccMode(CC_ENABLED), - codecType(VIDEO_CODEC_H264), + codecType(VIDEO_CODEC_H265), targetBitrate(6500) {} }; @@ -1542,12 +1538,23 @@ struct VideoSubscriptionOptions { VideoSubscriptionOptions() {} }; + +/** The maximum length of the user account. + */ +enum MAX_USER_ACCOUNT_LENGTH_TYPE +{ + /** The maximum length of the user account is 256 bytes. + */ + MAX_USER_ACCOUNT_LENGTH = 256 +}; + /** * The definition of the EncodedVideoFrameInfo struct, which contains the information of the external encoded video frame. */ struct EncodedVideoFrameInfo { EncodedVideoFrameInfo() - : codecType(VIDEO_CODEC_H264), + : uid(0), + codecType(VIDEO_CODEC_H264), width(0), height(0), framesPerSecond(0), @@ -1556,11 +1563,11 @@ struct EncodedVideoFrameInfo { trackId(0), captureTimeMs(0), decodeTimeMs(0), - uid(0), streamType(VIDEO_STREAM_HIGH) {} EncodedVideoFrameInfo(const EncodedVideoFrameInfo& rhs) - : codecType(rhs.codecType), + : uid(rhs.uid), + codecType(rhs.codecType), width(rhs.width), height(rhs.height), framesPerSecond(rhs.framesPerSecond), @@ -1569,11 +1576,11 @@ struct EncodedVideoFrameInfo { trackId(rhs.trackId), captureTimeMs(rhs.captureTimeMs), decodeTimeMs(rhs.decodeTimeMs), - uid(rhs.uid), streamType(rhs.streamType) {} EncodedVideoFrameInfo& operator=(const EncodedVideoFrameInfo& rhs) { if (this == &rhs) return *this; + uid = rhs.uid; codecType = rhs.codecType; width = rhs.width; height = rhs.height; @@ -1583,12 +1590,16 @@ struct EncodedVideoFrameInfo { trackId = rhs.trackId; captureTimeMs = rhs.captureTimeMs; decodeTimeMs = rhs.decodeTimeMs; - uid = rhs.uid; streamType = rhs.streamType; return *this; } + + /** + * ID of the user that pushes the the external encoded video frame.. + */ + uid_t uid; /** - * The codec type of the local video stream. See #VIDEO_CODEC_TYPE. The default value is `VIDEO_CODEC_H264 (2)`. + * The codec type of the local video stream. See #VIDEO_CODEC_TYPE. The default value is `VIDEO_CODEC_H265 (3)`. */ VIDEO_CODEC_TYPE codecType; /** @@ -1626,16 +1637,13 @@ struct EncodedVideoFrameInfo { * The timestamp for decoding the video. */ int64_t decodeTimeMs; - /** - * ID of the user that pushes the the external encoded video frame.. - */ - uid_t uid; /** * The stream type of video frame. */ VIDEO_STREAM_TYPE streamType; }; + /** * Video compression preference. */ @@ -1750,6 +1758,8 @@ struct CodecCapInfo { int codecCapMask; /** The codec capability level, estimated based on the device hardware.*/ CodecCapLevels codecLevels; + + CodecCapInfo(): codecType(VIDEO_CODEC_NONE), codecCapMask(0) {} }; /** @@ -1863,7 +1873,7 @@ struct VideoEncoderConfiguration { AdvanceOptions advanceOptions; VideoEncoderConfiguration(const VideoDimensions& d, int f, int b, ORIENTATION_MODE m, VIDEO_MIRROR_MODE_TYPE mirror = VIDEO_MIRROR_MODE_DISABLED) - : codecType(VIDEO_CODEC_H264), + : codecType(VIDEO_CODEC_H265), dimensions(d), frameRate(f), bitrate(b), @@ -1873,7 +1883,7 @@ struct VideoEncoderConfiguration { mirrorMode(mirror), advanceOptions(PREFER_AUTO, PREFER_LOW_LATENCY) {} VideoEncoderConfiguration(int width, int height, int f, int b, ORIENTATION_MODE m, VIDEO_MIRROR_MODE_TYPE mirror = VIDEO_MIRROR_MODE_DISABLED) - : codecType(VIDEO_CODEC_H264), + : codecType(VIDEO_CODEC_H265), dimensions(width, height), frameRate(f), bitrate(b), @@ -1893,7 +1903,7 @@ struct VideoEncoderConfiguration { mirrorMode(config.mirrorMode), advanceOptions(config.advanceOptions) {} VideoEncoderConfiguration() - : codecType(VIDEO_CODEC_H264), + : codecType(VIDEO_CODEC_H265), dimensions(FRAME_WIDTH_960, FRAME_HEIGHT_540), frameRate(FRAME_RATE_FPS_15), bitrate(STANDARD_BITRATE), @@ -2583,6 +2593,29 @@ enum VIDEO_APPLICATION_SCENARIO_TYPE { APPLICATION_SCENARIO_MEETING = 1, }; +/** + * The video QoE preference type. + */ +enum VIDEO_QOE_PREFERENCE_TYPE { + /** + * 1: Default QoE type, balance the delay, picture quality and fluency. + */ + VIDEO_QOE_PREFERENCE_BALANCE = 1, + /** + * 2: lower the e2e delay. + */ + VIDEO_QOE_PREFERENCE_DELAY_FIRST = 2, + /** + * 3: picture quality. + */ + VIDEO_QOE_PREFERENCE_PICTURE_QUALITY_FIRST = 3, + /** + * 4: more fluency. + */ + VIDEO_QOE_PREFERENCE_FLUENCY_FIRST = 4, + +}; + /** * The brightness level of the video image captured by the local camera. */ @@ -2627,50 +2660,50 @@ enum LOCAL_AUDIO_STREAM_STATE { /** * Local audio state error codes. */ -enum LOCAL_AUDIO_STREAM_ERROR { +enum LOCAL_AUDIO_STREAM_REASON { /** * 0: The local audio is normal. */ - LOCAL_AUDIO_STREAM_ERROR_OK = 0, + LOCAL_AUDIO_STREAM_REASON_OK = 0, /** * 1: No specified reason for the local audio failure. Remind your users to try to rejoin the channel. */ - LOCAL_AUDIO_STREAM_ERROR_FAILURE = 1, + LOCAL_AUDIO_STREAM_REASON_FAILURE = 1, /** * 2: No permission to use the local audio device. Remind your users to grant permission. */ - LOCAL_AUDIO_STREAM_ERROR_DEVICE_NO_PERMISSION = 2, + LOCAL_AUDIO_STREAM_REASON_DEVICE_NO_PERMISSION = 2, /** * 3: (Android and iOS only) The local audio capture device is used. Remind your users to check * whether another application occupies the microphone. Local audio capture automatically resume * after the microphone is idle for about five seconds. You can also try to rejoin the channel * after the microphone is idle. */ - LOCAL_AUDIO_STREAM_ERROR_DEVICE_BUSY = 3, + LOCAL_AUDIO_STREAM_REASON_DEVICE_BUSY = 3, /** * 4: The local audio capture failed. */ - LOCAL_AUDIO_STREAM_ERROR_RECORD_FAILURE = 4, + LOCAL_AUDIO_STREAM_REASON_RECORD_FAILURE = 4, /** * 5: The local audio encoding failed. */ - LOCAL_AUDIO_STREAM_ERROR_ENCODE_FAILURE = 5, + LOCAL_AUDIO_STREAM_REASON_ENCODE_FAILURE = 5, /** 6: The SDK cannot find the local audio recording device. */ - LOCAL_AUDIO_STREAM_ERROR_NO_RECORDING_DEVICE = 6, + LOCAL_AUDIO_STREAM_REASON_NO_RECORDING_DEVICE = 6, /** 7: The SDK cannot find the local audio playback device. */ - LOCAL_AUDIO_STREAM_ERROR_NO_PLAYOUT_DEVICE = 7, + LOCAL_AUDIO_STREAM_REASON_NO_PLAYOUT_DEVICE = 7, /** * 8: The local audio capturing is interrupted by the system call. */ - LOCAL_AUDIO_STREAM_ERROR_INTERRUPTED = 8, + LOCAL_AUDIO_STREAM_REASON_INTERRUPTED = 8, /** 9: An invalid audio capture device ID. */ - LOCAL_AUDIO_STREAM_ERROR_RECORD_INVALID_ID = 9, + LOCAL_AUDIO_STREAM_REASON_RECORD_INVALID_ID = 9, /** 10: An invalid audio playback device ID. */ - LOCAL_AUDIO_STREAM_ERROR_PLAYOUT_INVALID_ID = 10, + LOCAL_AUDIO_STREAM_REASON_PLAYOUT_INVALID_ID = 10, }; /** Local video state types. @@ -2698,73 +2731,73 @@ enum LOCAL_VIDEO_STREAM_STATE { /** * Local video state error codes. */ -enum LOCAL_VIDEO_STREAM_ERROR { +enum LOCAL_VIDEO_STREAM_REASON { /** * 0: The local video is normal. */ - LOCAL_VIDEO_STREAM_ERROR_OK = 0, + LOCAL_VIDEO_STREAM_REASON_OK = 0, /** * 1: No specified reason for the local video failure. */ - LOCAL_VIDEO_STREAM_ERROR_FAILURE = 1, + LOCAL_VIDEO_STREAM_REASON_FAILURE = 1, /** * 2: No permission to use the local video capturing device. Remind the user to grant permission * and rejoin the channel. */ - LOCAL_VIDEO_STREAM_ERROR_DEVICE_NO_PERMISSION = 2, + LOCAL_VIDEO_STREAM_REASON_DEVICE_NO_PERMISSION = 2, /** * 3: The local video capturing device is in use. Remind the user to check whether another * application occupies the camera. */ - LOCAL_VIDEO_STREAM_ERROR_DEVICE_BUSY = 3, + LOCAL_VIDEO_STREAM_REASON_DEVICE_BUSY = 3, /** * 4: The local video capture fails. Remind the user to check whether the video capture device * is working properly or the camera is occupied by another application, and then to rejoin the * channel. */ - LOCAL_VIDEO_STREAM_ERROR_CAPTURE_FAILURE = 4, + LOCAL_VIDEO_STREAM_REASON_CAPTURE_FAILURE = 4, /** * 5: The local video encoder is not supported. */ - LOCAL_VIDEO_STREAM_ERROR_ENCODE_FAILURE = 5, + LOCAL_VIDEO_STREAM_REASON_CODEC_NOT_SUPPORT = 5, /** * 6: (iOS only) The app is in the background. Remind the user that video capture cannot be * performed normally when the app is in the background. */ - LOCAL_VIDEO_STREAM_ERROR_CAPTURE_INBACKGROUND = 6, + LOCAL_VIDEO_STREAM_REASON_CAPTURE_INBACKGROUND = 6, /** * 7: (iOS only) The current application window is running in Slide Over, Split View, or Picture * in Picture mode, and another app is occupying the camera. Remind the user that the application * cannot capture video properly when the app is running in Slide Over, Split View, or Picture in * Picture mode and another app is occupying the camera. */ - LOCAL_VIDEO_STREAM_ERROR_CAPTURE_MULTIPLE_FOREGROUND_APPS = 7, + LOCAL_VIDEO_STREAM_REASON_CAPTURE_MULTIPLE_FOREGROUND_APPS = 7, /** * 8: Fails to find a local video capture device. Remind the user to check whether the camera is * connected to the device properly or the camera is working properly, and then to rejoin the * channel. */ - LOCAL_VIDEO_STREAM_ERROR_DEVICE_NOT_FOUND = 8, + LOCAL_VIDEO_STREAM_REASON_DEVICE_NOT_FOUND = 8, /** * 9: (macOS only) The video capture device currently in use is disconnected (such as being * unplugged). */ - LOCAL_VIDEO_STREAM_ERROR_DEVICE_DISCONNECTED = 9, + LOCAL_VIDEO_STREAM_REASON_DEVICE_DISCONNECTED = 9, /** * 10: (macOS and Windows only) The SDK cannot find the video device in the video device list. * Check whether the ID of the video device is valid. */ - LOCAL_VIDEO_STREAM_ERROR_DEVICE_INVALID_ID = 10, + LOCAL_VIDEO_STREAM_REASON_DEVICE_INVALID_ID = 10, /** * 101: The current video capture device is unavailable due to excessive system pressure. */ - LOCAL_VIDEO_STREAM_ERROR_DEVICE_SYSTEM_PRESSURE = 101, + LOCAL_VIDEO_STREAM_REASON_DEVICE_SYSTEM_PRESSURE = 101, /** * 11: (macOS only) The shared window is minimized when you call `startScreenCaptureByWindowId` * to share a window. The SDK cannot share a minimized window. You can cancel the minimization * of this window at the application layer, for example by maximizing this window. */ - LOCAL_VIDEO_STREAM_ERROR_SCREEN_CAPTURE_WINDOW_MINIMIZED = 11, + LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_WINDOW_MINIMIZED = 11, /** * 12: (macOS and Windows only) The error code indicates that a window shared by the window ID * has been closed or a full-screen window shared by the window ID has exited full-screen mode. @@ -2779,31 +2812,38 @@ enum LOCAL_VIDEO_STREAM_ERROR { * then shares the window of the web video or document. After the user exits full-screen mode, * the SDK reports this error code. */ - LOCAL_VIDEO_STREAM_ERROR_SCREEN_CAPTURE_WINDOW_CLOSED = 12, + LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_WINDOW_CLOSED = 12, /** 13: The local screen capture window is occluded. */ - LOCAL_VIDEO_STREAM_ERROR_SCREEN_CAPTURE_WINDOW_OCCLUDED = 13, + LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_WINDOW_OCCLUDED = 13, /** 20: The local screen capture window is not supported. */ - LOCAL_VIDEO_STREAM_ERROR_SCREEN_CAPTURE_WINDOW_NOT_SUPPORTED = 20, + LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_WINDOW_NOT_SUPPORTED = 20, /** 21: The screen capture fails. */ - LOCAL_VIDEO_STREAM_ERROR_SCREEN_CAPTURE_FAILURE = 21, + LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_FAILURE = 21, /** 22: No permision to capture screen. */ - LOCAL_VIDEO_STREAM_ERROR_SCREEN_CAPTURE_NO_PERMISSION = 22, - /** - * 23: The screen capture paused. + LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_NO_PERMISSION = 22, + /** + * 24: (Windows Only) An unexpected error (possibly due to window block failure) occurs during the screen + * sharing process, resulting in performance degradation. However, the screen sharing process itself is + * functioning normally. + */ + LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_AUTO_FALLBACK = 24, + /** 25: (Windows only) The local screen capture window is currently hidden and not visible on the desktop. */ + LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_WINDOW_HIDDEN = 25, + /** 26: (Windows only) The local screen capture window is recovered from its hidden state. */ + LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_WINDOW_RECOVER_FROM_HIDDEN = 26, + /** 27:(Windows only) The window is recovered from miniminzed */ + LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_WINDOW_RECOVER_FROM_MINIMIZED = 27, + /** + * 28: The screen capture paused. * * Common scenarios for reporting this error code: * - When the desktop switch to the secure desktop such as UAC dialog or the Winlogon desktop on * Windows platform, the SDK reports this error code. */ - LOCAL_VIDEO_STREAM_ERROR_SCREEN_CAPTURE_PAUSED = 23, - /** 24: The screen capture is resumed. */ - LOCAL_VIDEO_STREAM_ERROR_SCREEN_CAPTURE_RESUMED = 24, - /** 25: (Windows only) The local screen capture window is currently hidden and not visible on the desktop. */ - LOCAL_VIDEO_STREAM_ERROR_SCREEN_CAPTURE_WINDOW_HIDDEN = 25, - /** 26: (Windows only) The local screen capture window is recovered from its hidden state. */ - LOCAL_VIDEO_STREAM_ERROR_SCREEN_CAPTURE_WINDOW_RECOVER_FROM_HIDDEN = 26, - /** 27:(Windows only) The window is recovered from miniminzed */ - LOCAL_VIDEO_STREAM_ERROR_SCREEN_CAPTURE_WINDOW_RECOVER_FROM_MINIMIZED = 27, + LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_PAUSED = 28, + /** 29: The screen capture is resumed. */ + LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_RESUMED = 29, + }; /** @@ -2991,7 +3031,6 @@ enum REMOTE_USER_STATE { * The remote user has enabled the local video capturing. */ USER_STATE_ENABLE_LOCAL_VIDEO = (1 << 8), - }; /** @@ -3001,7 +3040,7 @@ enum REMOTE_USER_STATE { struct VideoTrackInfo { VideoTrackInfo() : isLocal(false), ownerUid(0), trackId(0), channelId(OPTIONAL_NULLPTR) - , streamType(VIDEO_STREAM_HIGH), codecType(VIDEO_CODEC_H264) + , streamType(VIDEO_STREAM_HIGH), codecType(VIDEO_CODEC_H265) , encodedFrameOnly(false), sourceType(VIDEO_SOURCE_CAMERA_PRIMARY) , observationPosition(agora::media::base::POSITION_POST_CAPTURER) {} /** @@ -3014,7 +3053,6 @@ struct VideoTrackInfo { * ID of the user who publishes the video track. */ uid_t ownerUid; - /** * ID of the video track. */ @@ -3145,7 +3183,7 @@ class IPacketObserver { */ unsigned int size; - Packet() : buffer(NULL), size(0) {} + Packet() : buffer(OPTIONAL_NULLPTR), size(0) {} }; /** * Occurs when the SDK is ready to send the audio packet. @@ -3278,6 +3316,18 @@ struct LocalAudioStats * The audio delay of the device, contains record and playout delay */ int audioDeviceDelay; + /** + * The playout delay of the device + */ + int audioPlayoutDelay; + /** + * The signal delay estimated from audio in-ear monitoring (ms). + */ + int earMonitorDelay; + /** + * The signal delay estimated during the AEC process from nearin and farin (ms). + */ + int aecEstimatedDelay; }; @@ -3316,74 +3366,74 @@ enum RTMP_STREAM_PUBLISH_STATE { /** * Error codes of the RTMP or RTMPS streaming. */ -enum RTMP_STREAM_PUBLISH_ERROR_TYPE { +enum RTMP_STREAM_PUBLISH_REASON { /** * 0: The RTMP or RTMPS streaming publishes successfully. */ - RTMP_STREAM_PUBLISH_ERROR_OK = 0, + RTMP_STREAM_PUBLISH_REASON_OK = 0, /** * 1: Invalid argument used. If, for example, you do not call the `setLiveTranscoding` method to configure the LiveTranscoding parameters before calling the addPublishStreamUrl method, * the SDK returns this error. Check whether you set the parameters in the `setLiveTranscoding` method properly. */ - RTMP_STREAM_PUBLISH_ERROR_INVALID_ARGUMENT = 1, + RTMP_STREAM_PUBLISH_REASON_INVALID_ARGUMENT = 1, /** * 2: The RTMP or RTMPS streaming is encrypted and cannot be published. */ - RTMP_STREAM_PUBLISH_ERROR_ENCRYPTED_STREAM_NOT_ALLOWED = 2, + RTMP_STREAM_PUBLISH_REASON_ENCRYPTED_STREAM_NOT_ALLOWED = 2, /** * 3: Timeout for the RTMP or RTMPS streaming. Call the `addPublishStreamUrl` method to publish the streaming again. */ - RTMP_STREAM_PUBLISH_ERROR_CONNECTION_TIMEOUT = 3, + RTMP_STREAM_PUBLISH_REASON_CONNECTION_TIMEOUT = 3, /** * 4: An error occurs in Agora's streaming server. Call the `addPublishStreamUrl` method to publish the streaming again. */ - RTMP_STREAM_PUBLISH_ERROR_INTERNAL_SERVER_ERROR = 4, + RTMP_STREAM_PUBLISH_REASON_INTERNAL_SERVER_ERROR = 4, /** * 5: An error occurs in the CDN server. */ - RTMP_STREAM_PUBLISH_ERROR_RTMP_SERVER_ERROR = 5, + RTMP_STREAM_PUBLISH_REASON_RTMP_SERVER_ERROR = 5, /** * 6: The RTMP or RTMPS streaming publishes too frequently. */ - RTMP_STREAM_PUBLISH_ERROR_TOO_OFTEN = 6, + RTMP_STREAM_PUBLISH_REASON_TOO_OFTEN = 6, /** * 7: The host publishes more than 10 URLs. Delete the unnecessary URLs before adding new ones. */ - RTMP_STREAM_PUBLISH_ERROR_REACH_LIMIT = 7, + RTMP_STREAM_PUBLISH_REASON_REACH_LIMIT = 7, /** * 8: The host manipulates other hosts' URLs. Check your app logic. */ - RTMP_STREAM_PUBLISH_ERROR_NOT_AUTHORIZED = 8, + RTMP_STREAM_PUBLISH_REASON_NOT_AUTHORIZED = 8, /** * 9: Agora's server fails to find the RTMP or RTMPS streaming. */ - RTMP_STREAM_PUBLISH_ERROR_STREAM_NOT_FOUND = 9, + RTMP_STREAM_PUBLISH_REASON_STREAM_NOT_FOUND = 9, /** * 10: The format of the RTMP or RTMPS streaming URL is not supported. Check whether the URL format is correct. */ - RTMP_STREAM_PUBLISH_ERROR_FORMAT_NOT_SUPPORTED = 10, + RTMP_STREAM_PUBLISH_REASON_FORMAT_NOT_SUPPORTED = 10, /** * 11: The user role is not host, so the user cannot use the CDN live streaming function. Check your application code logic. */ - RTMP_STREAM_PUBLISH_ERROR_NOT_BROADCASTER = 11, // Note: match to ERR_PUBLISH_STREAM_NOT_BROADCASTER in AgoraBase.h + RTMP_STREAM_PUBLISH_REASON_NOT_BROADCASTER = 11, // Note: match to ERR_PUBLISH_STREAM_NOT_BROADCASTER in AgoraBase.h /** * 13: The `updateRtmpTranscoding` or `setLiveTranscoding` method is called to update the transcoding configuration in a scenario where there is streaming without transcoding. Check your application code logic. */ - RTMP_STREAM_PUBLISH_ERROR_TRANSCODING_NO_MIX_STREAM = 13, // Note: match to ERR_PUBLISH_STREAM_TRANSCODING_NO_MIX_STREAM in AgoraBase.h + RTMP_STREAM_PUBLISH_REASON_TRANSCODING_NO_MIX_STREAM = 13, // Note: match to ERR_PUBLISH_STREAM_TRANSCODING_NO_MIX_STREAM in AgoraBase.h /** * 14: Errors occurred in the host's network. */ - RTMP_STREAM_PUBLISH_ERROR_NET_DOWN = 14, // Note: match to ERR_NET_DOWN in AgoraBase.h + RTMP_STREAM_PUBLISH_REASON_NET_DOWN = 14, // Note: match to ERR_NET_DOWN in AgoraBase.h /** * 15: Your App ID does not have permission to use the CDN live streaming function. */ - RTMP_STREAM_PUBLISH_ERROR_INVALID_APPID = 15, // Note: match to ERR_PUBLISH_STREAM_APPID_INVALID in AgoraBase.h + RTMP_STREAM_PUBLISH_REASON_INVALID_APPID = 15, // Note: match to ERR_PUBLISH_STREAM_APPID_INVALID in AgoraBase.h /** invalid privilege. */ - RTMP_STREAM_PUBLISH_ERROR_INVALID_PRIVILEGE = 16, + RTMP_STREAM_PUBLISH_REASON_INVALID_PRIVILEGE = 16, /** * 100: The streaming has been stopped normally. After you call `removePublishStreamUrl` to stop streaming, the SDK returns this value. */ - RTMP_STREAM_UNPUBLISH_ERROR_OK = 100, + RTMP_STREAM_UNPUBLISH_REASON_OK = 100, }; /** Events during the RTMP or RTMPS streaming. */ @@ -3445,7 +3495,7 @@ typedef struct RtcImage { */ double alpha; - RtcImage() : url(NULL), x(0), y(0), width(0), height(0), zOrder(0), alpha(1.0) {} + RtcImage() : url(OPTIONAL_NULLPTR), x(0), y(0), width(0), height(0), zOrder(0), alpha(1.0) {} } RtcImage; /** * The configuration for advanced features of the RTMP or RTMPS streaming with transcoding. @@ -3453,7 +3503,7 @@ typedef struct RtcImage { * If you want to enable the advanced features of streaming with transcoding, contact support@agora.io. */ struct LiveStreamAdvancedFeature { - LiveStreamAdvancedFeature() : featureName(NULL), opened(false) {} + LiveStreamAdvancedFeature() : featureName(OPTIONAL_NULLPTR), opened(false) {} LiveStreamAdvancedFeature(const char* feat_name, bool open) : featureName(feat_name), opened(open) {} /** The advanced feature for high-quality video with a lower bitrate. */ // static const char* LBHQ = "lbhq"; @@ -3573,6 +3623,7 @@ struct TranscodingUser { * @note If the value is not `0`, a special player is required. */ int audioChannel; + TranscodingUser() : uid(0), x(0), @@ -3692,7 +3743,31 @@ struct LiveTranscoding { /** The number of enabled advanced features. The default value is 0. */ unsigned int advancedFeatureCount; - LiveTranscoding() : width(360), height(640), videoBitrate(400), videoFramerate(15), lowLatency(false), videoGop(30), videoCodecProfile(VIDEO_CODEC_PROFILE_HIGH), backgroundColor(0x000000), videoCodecType(VIDEO_CODEC_H264_FOR_STREAM), userCount(0), transcodingUsers(NULL), transcodingExtraInfo(NULL), metadata(NULL), watermark(NULL), watermarkCount(0), backgroundImage(NULL), backgroundImageCount(0), audioSampleRate(AUDIO_SAMPLE_RATE_48000), audioBitrate(48), audioChannels(1), audioCodecProfile(AUDIO_CODEC_PROFILE_LC_AAC), advancedFeatures(NULL), advancedFeatureCount(0) {} + + LiveTranscoding() + : width(360), + height(640), + videoBitrate(400), + videoFramerate(15), + lowLatency(false), + videoGop(30), + videoCodecProfile(VIDEO_CODEC_PROFILE_HIGH), + backgroundColor(0x000000), + videoCodecType(VIDEO_CODEC_H264_FOR_STREAM), + userCount(0), + transcodingUsers(OPTIONAL_NULLPTR), + transcodingExtraInfo(OPTIONAL_NULLPTR), + metadata(OPTIONAL_NULLPTR), + watermark(OPTIONAL_NULLPTR), + watermarkCount(0), + backgroundImage(OPTIONAL_NULLPTR), + backgroundImageCount(0), + audioSampleRate(AUDIO_SAMPLE_RATE_48000), + audioBitrate(48), + audioChannels(1), + audioCodecProfile(AUDIO_CODEC_PROFILE_LC_AAC), + advancedFeatures(OPTIONAL_NULLPTR), + advancedFeatureCount(0) {} }; /** @@ -3754,7 +3829,7 @@ struct TranscodingVideoStream { TranscodingVideoStream() : sourceType(VIDEO_SOURCE_CAMERA_PRIMARY), remoteUserUid(0), - imageUrl(NULL), + imageUrl(OPTIONAL_NULLPTR), x(0), y(0), width(0), @@ -3764,7 +3839,6 @@ struct TranscodingVideoStream { mirror(false) {} }; - /** * The configuration of the video mixing on the local client. */ @@ -3788,11 +3862,7 @@ struct LocalTranscoderConfiguration { */ bool syncWithPrimaryCamera; - LocalTranscoderConfiguration() - : streamCount(0), - videoInputStreams(NULL), - videoOutputConfiguration(), - syncWithPrimaryCamera(true) {} + LocalTranscoderConfiguration() : streamCount(0), videoInputStreams(OPTIONAL_NULLPTR), videoOutputConfiguration(), syncWithPrimaryCamera(true) {} }; enum VIDEO_TRANSCODER_ERROR { @@ -4014,10 +4084,18 @@ enum CONNECTION_CHANGED_REASON_TYPE * 21: The connection is failed due to license validation failure. */ CONNECTION_CHANGED_LICENSE_VALIDATION_FAILURE = 21, - /** + /* * 22: The connection is failed due to certification verify failure. */ CONNECTION_CHANGED_CERTIFICATION_VERYFY_FAILURE = 22, + /** + * 23: The connection is failed due to the lack of granting permission to the stream channel. + */ + CONNECTION_CHANGED_STREAM_CHANNEL_NOT_AVAILABLE = 23, + /** + * 24: The connection is failed due to join channel with an inconsistent appid. + */ + CONNECTION_CHANGED_INCONSISTENT_APPID = 24, }; /** @@ -4156,14 +4234,19 @@ enum VIDEO_VIEW_SETUP_MODE { * Attributes of video canvas object. */ struct VideoCanvas { - /** - * Video display window. - */ - view_t view; /** * The user id of local video. */ uid_t uid; + + /** + * The uid of video stream composing the video stream from transcoder which will be drawn on this video canvas. + */ + uid_t subviewUid; + /** + * Video display window. + */ + view_t view; /** * A RGBA value indicates background color of the render view. Defaults to 0x00000000. */ @@ -4205,28 +4288,37 @@ struct VideoCanvas { * The default value is empty(that is, if it has zero width or height), which means no cropping. */ Rectangle cropArea; - /** - * Whether to apply alpha mask to the video frame if exsit: - * true: Apply alpha mask to video frame. - * false: (Default) Do not apply alpha mask to video frame. - */ + * Whether to apply alpha mask to the video frame if exsit: + * true: Apply alpha mask to video frame. + * false: (Default) Do not apply alpha mask to video frame. + */ bool enableAlphaMask; - + /** + * The video frame position in pipeline. See \ref VIDEO_MODULE_POSITION "VIDEO_MODULE_POSITION". + * The default value is POSITION_POST_CAPTURER. + */ + media::base::VIDEO_MODULE_POSITION position; + VideoCanvas() - : view(NULL), uid(0), backgroundColor(0x00000000), renderMode(media::base::RENDER_MODE_HIDDEN), mirrorMode(VIDEO_MIRROR_MODE_AUTO), + : uid(0), subviewUid(0), view(NULL), backgroundColor(0x00000000), renderMode(media::base::RENDER_MODE_HIDDEN), mirrorMode(VIDEO_MIRROR_MODE_AUTO), setupMode(VIDEO_VIEW_SETUP_REPLACE), sourceType(VIDEO_SOURCE_CAMERA_PRIMARY), mediaPlayerId(-ERR_NOT_READY), - cropArea(0, 0, 0, 0), enableAlphaMask(false) {} + cropArea(0, 0, 0, 0), enableAlphaMask(false), position(media::base::POSITION_POST_CAPTURER) {} + + VideoCanvas(view_t v, media::base::RENDER_MODE_TYPE m, VIDEO_MIRROR_MODE_TYPE mt) + : uid(0), subviewUid(0), view(v), backgroundColor(0x00000000), renderMode(m), mirrorMode(mt), setupMode(VIDEO_VIEW_SETUP_REPLACE), + sourceType(VIDEO_SOURCE_CAMERA_PRIMARY), mediaPlayerId(-ERR_NOT_READY), + cropArea(0, 0, 0, 0), enableAlphaMask(false), position(media::base::POSITION_POST_CAPTURER) {} VideoCanvas(view_t v, media::base::RENDER_MODE_TYPE m, VIDEO_MIRROR_MODE_TYPE mt, uid_t u) - : view(v), uid(u), backgroundColor(0x00000000), renderMode(m), mirrorMode(mt), setupMode(VIDEO_VIEW_SETUP_REPLACE), + : uid(u), subviewUid(0), view(v), backgroundColor(0x00000000), renderMode(m), mirrorMode(mt), setupMode(VIDEO_VIEW_SETUP_REPLACE), sourceType(VIDEO_SOURCE_CAMERA_PRIMARY), mediaPlayerId(-ERR_NOT_READY), - cropArea(0, 0, 0, 0), enableAlphaMask(false) {} + cropArea(0, 0, 0, 0), enableAlphaMask(false), position(media::base::POSITION_POST_CAPTURER) {} - VideoCanvas(view_t v, media::base::RENDER_MODE_TYPE m, VIDEO_MIRROR_MODE_TYPE mt, user_id_t) - : view(v), uid(0), backgroundColor(0x00000000), renderMode(m), mirrorMode(mt), setupMode(VIDEO_VIEW_SETUP_REPLACE), + VideoCanvas(view_t v, media::base::RENDER_MODE_TYPE m, VIDEO_MIRROR_MODE_TYPE mt, uid_t u, uid_t subu) + : uid(u), subviewUid(subu), view(v), backgroundColor(0x00000000), renderMode(m), mirrorMode(mt), setupMode(VIDEO_VIEW_SETUP_REPLACE), sourceType(VIDEO_SOURCE_CAMERA_PRIMARY), mediaPlayerId(-ERR_NOT_READY), - cropArea(0, 0, 0, 0), enableAlphaMask(false) {} + cropArea(0, 0, 0, 0), enableAlphaMask(false), position(media::base::POSITION_POST_CAPTURER) {} }; /** Image enhancement options. @@ -4438,7 +4530,7 @@ struct VirtualBackgroundSource { */ BACKGROUND_BLUR_DEGREE blur_degree; - VirtualBackgroundSource() : background_source_type(BACKGROUND_COLOR), color(0xffffff), source(NULL), blur_degree(BLUR_DEGREE_HIGH) {} + VirtualBackgroundSource() : background_source_type(BACKGROUND_COLOR), color(0xffffff), source(OPTIONAL_NULLPTR), blur_degree(BLUR_DEGREE_HIGH) {} }; struct SegmentationProperty { @@ -4836,22 +4928,22 @@ struct ScreenCaptureParameters { */ int excludeWindowCount; - /** The width (px) of the border. Defaults to 0, and the value range is [0,50]. - * - */ - int highLightWidth; - /** The color of the border in RGBA format. The default value is 0xFF8CBF26. - * - */ - unsigned int highLightColor; - /** Whether to place a border around the shared window or screen: - * - true: Place a border. - * - false: (Default) Do not place a border. - * - * @note When you share a part of a window or screen, the SDK places a border around the entire window or screen if you set `enableHighLight` as true. - * - */ - bool enableHighLight; + /** The width (px) of the border. Defaults to 0, and the value range is [0,50]. + * + */ + int highLightWidth; + /** The color of the border in RGBA format. The default value is 0xFF8CBF26. + * + */ + unsigned int highLightColor; + /** Whether to place a border around the shared window or screen: + * - true: Place a border. + * - false: (Default) Do not place a border. + * + * @note When you share a part of a window or screen, the SDK places a border around the entire window or screen if you set `enableHighLight` as true. + * + */ + bool enableHighLight; ScreenCaptureParameters() : dimensions(1920, 1080), frameRate(5), bitrate(STANDARD_BITRATE), captureMouseCursor(true), windowFocus(false), excludeWindowList(OPTIONAL_NULLPTR), excludeWindowCount(0), highLightWidth(0), highLightColor(0), enableHighLight(false) {} @@ -4968,7 +5060,7 @@ struct AudioRecordingConfiguration { int recordingChannel; AudioRecordingConfiguration() - : filePath(NULL), + : filePath(OPTIONAL_NULLPTR), encode(false), sampleRate(32000), fileRecordingType(AUDIO_FILE_RECORDING_MIXED), @@ -5172,59 +5264,6 @@ enum CHANNEL_MEDIA_RELAY_ERROR { RELAY_ERROR_DEST_TOKEN_EXPIRED = 11, }; -/** - * The event code of channel media relay. - */ -enum CHANNEL_MEDIA_RELAY_EVENT { - /** 0: The user disconnects from the server due to poor network connections. - */ - RELAY_EVENT_NETWORK_DISCONNECTED = 0, - /** 1: The user is connected to the server. - */ - RELAY_EVENT_NETWORK_CONNECTED = 1, - /** 2: The user joins the source channel. - */ - RELAY_EVENT_PACKET_JOINED_SRC_CHANNEL = 2, - /** 3: The user joins the destination channel. - */ - RELAY_EVENT_PACKET_JOINED_DEST_CHANNEL = 3, - /** 4: The SDK starts relaying the media stream to the destination channel. - */ - RELAY_EVENT_PACKET_SENT_TO_DEST_CHANNEL = 4, - /** 5: The server receives the video stream from the source channel. - */ - RELAY_EVENT_PACKET_RECEIVED_VIDEO_FROM_SRC = 5, - /** 6: The server receives the audio stream from the source channel. - */ - RELAY_EVENT_PACKET_RECEIVED_AUDIO_FROM_SRC = 6, - /** 7: The destination channel is updated. - */ - RELAY_EVENT_PACKET_UPDATE_DEST_CHANNEL = 7, - /** 8: The destination channel update fails due to internal reasons. - */ - RELAY_EVENT_PACKET_UPDATE_DEST_CHANNEL_REFUSED = 8, - /** 9: The destination channel does not change, which means that the destination channel fails to be updated. - */ - RELAY_EVENT_PACKET_UPDATE_DEST_CHANNEL_NOT_CHANGE = 9, - /** 10: The destination channel name is NULL. - */ - RELAY_EVENT_PACKET_UPDATE_DEST_CHANNEL_IS_NULL = 10, - /** 11: The video profile is sent to the server. - */ - RELAY_EVENT_VIDEO_PROFILE_UPDATE = 11, - /** 12: The SDK successfully pauses relaying the media stream to destination channels. - */ - RELAY_EVENT_PAUSE_SEND_PACKET_TO_DEST_CHANNEL_SUCCESS = 12, - /** 13: The SDK fails to pause relaying the media stream to destination channels. - */ - RELAY_EVENT_PAUSE_SEND_PACKET_TO_DEST_CHANNEL_FAILED = 13, - /** 14: The SDK successfully resumes relaying the media stream to destination channels. - */ - RELAY_EVENT_RESUME_SEND_PACKET_TO_DEST_CHANNEL_SUCCESS = 14, - /** 15: The SDK fails to resume relaying the media stream to destination channels. - */ - RELAY_EVENT_RESUME_SEND_PACKET_TO_DEST_CHANNEL_FAILED = 15, -}; /** * The state code of the channel media relay. */ @@ -5247,17 +5286,20 @@ enum CHANNEL_MEDIA_RELAY_STATE { /** The definition of ChannelMediaInfo. */ struct ChannelMediaInfo { - /** The channel name. The default value is NULL, which means that the SDK - * applies the current channel name. + /** The user ID. */ + uid_t uid; + /** The channel name. The default value is NULL, which means that the SDK + * applies the current channel name. + */ const char* channelName; - /** The token that enables the user to join the channel. The default value - * is NULL, which means that the SDK applies the current token. - */ + /** The token that enables the user to join the channel. The default value + * is NULL, which means that the SDK applies the current token. + */ const char* token; - /** The user ID. - */ - uid_t uid; + + ChannelMediaInfo() : uid(0), channelName(NULL), token(NULL) {} + ChannelMediaInfo(const char* c, const char* t, uid_t u) : uid(u), channelName(c), token(t) {} }; /** The definition of ChannelMediaRelayConfiguration. @@ -5275,7 +5317,7 @@ struct ChannelMediaRelayConfiguration { * - If you have enabled the App Certificate, you must use the token generated with the `channelName` and `uid`, and * the `uid` must be set as 0. */ - ChannelMediaInfo *srcInfo; + ChannelMediaInfo* srcInfo; /** The information of the destination channel `ChannelMediaInfo`. It contains the following members: * - `channelName`: The name of the destination channel. * - `uid`: The unique ID to identify the relay stream in the destination channel. The value @@ -5290,18 +5332,14 @@ struct ChannelMediaRelayConfiguration { * If you have enabled the App Certificate, you must use the token generated with the `channelName` * and `uid`. */ - ChannelMediaInfo *destInfos; + ChannelMediaInfo* destInfos; /** The number of destination channels. The default value is 0, and the value range is from 0 to * 6. Ensure that the value of this parameter corresponds to the number of `ChannelMediaInfo` * structs you define in `destInfo`. */ int destCount; - ChannelMediaRelayConfiguration() - : srcInfo(NULL), - destInfos(NULL), - destCount(0) - {} + ChannelMediaRelayConfiguration() : srcInfo(OPTIONAL_NULLPTR), destInfos(OPTIONAL_NULLPTR), destCount(0) {} }; /** @@ -5320,15 +5358,12 @@ struct UplinkNetworkInfo { } }; -/** - * The collections of downlink network info. - */ struct DownlinkNetworkInfo { struct PeerDownlinkInfo { /** * The ID of the user who owns the remote video stream. */ - const char* uid; + const char* userId; /** * The remote video stream type: #VIDEO_STREAM_TYPE. */ @@ -5343,28 +5378,41 @@ struct DownlinkNetworkInfo { int expected_bitrate_bps; PeerDownlinkInfo() - : uid(OPTIONAL_NULLPTR), + : userId(OPTIONAL_NULLPTR), stream_type(VIDEO_STREAM_HIGH), current_downscale_level(REMOTE_VIDEO_DOWNSCALE_LEVEL_NONE), expected_bitrate_bps(-1) {} + PeerDownlinkInfo(const PeerDownlinkInfo& rhs) + : stream_type(rhs.stream_type), + current_downscale_level(rhs.current_downscale_level), + expected_bitrate_bps(rhs.expected_bitrate_bps) { + if (rhs.userId != OPTIONAL_NULLPTR) { + const int len = std::strlen(rhs.userId); + char* buf = new char[len + 1]; + std::memcpy(buf, rhs.userId, len); + buf[len] = '\0'; + userId = buf; + } + } + PeerDownlinkInfo& operator=(const PeerDownlinkInfo& rhs) { if (this == &rhs) return *this; - uid = OPTIONAL_NULLPTR; + userId = OPTIONAL_NULLPTR; stream_type = rhs.stream_type; current_downscale_level = rhs.current_downscale_level; expected_bitrate_bps = rhs.expected_bitrate_bps; - if (rhs.uid != OPTIONAL_NULLPTR) { - char* temp = new char[strlen(rhs.uid) + 1]; - strcpy(temp, rhs.uid); - uid = temp; + if (rhs.userId != OPTIONAL_NULLPTR) { + const int len = std::strlen(rhs.userId); + char* buf = new char[len + 1]; + std::memcpy(buf, rhs.userId, len); + buf[len] = '\0'; + userId = buf; } return *this; } - ~PeerDownlinkInfo() { - if (uid) { delete [] uid; } - } + ~PeerDownlinkInfo() { delete[] userId; } }; /** @@ -5422,9 +5470,7 @@ struct DownlinkNetworkInfo { return *this; } - ~DownlinkNetworkInfo() { - if (peer_downlink_info) delete [] peer_downlink_info; - } + ~DownlinkNetworkInfo() { delete[] peer_downlink_info; } }; /** @@ -5487,7 +5533,7 @@ struct EncryptionConfig { EncryptionConfig() : encryptionMode(AES_128_GCM2), - encryptionKey(NULL) + encryptionKey(OPTIONAL_NULLPTR) { memset(encryptionKdfSalt, 0, sizeof(encryptionKdfSalt)); } @@ -5558,15 +5604,6 @@ enum PERMISSION_TYPE { SCREEN_CAPTURE = 2, }; -/** The maximum length of the user account. - */ -enum MAX_USER_ACCOUNT_LENGTH_TYPE -{ - /** The maximum length of the user account is 256 bytes. - */ - MAX_USER_ACCOUNT_LENGTH = 256 -}; - /** * The subscribing state. */ @@ -5654,8 +5691,8 @@ struct UserInfo { * The user account. The maximum data length is `MAX_USER_ACCOUNT_LENGTH_TYPE`. */ char userAccount[MAX_USER_ACCOUNT_LENGTH]; - UserInfo() - : uid(0) { + + UserInfo() : uid(0) { userAccount[0] = '\0'; } }; @@ -5896,22 +5933,6 @@ enum CONFIG_FETCH_TYPE { }; -/** - * media recorder source stream information - */ -struct RecorderStreamInfo { - /** - * The channel ID of the video track. - */ - const char* channelId; - /** - * The user ID. - */ - uid_t uid; - RecorderStreamInfo() : channelId(NULL), uid(0) {} -}; - - /** The local proxy mode type. */ enum LOCAL_PROXY_MODE { /** 0: Connect local proxy with high priority, if not connected to local proxy, fallback to sdrtn. @@ -5975,7 +5996,21 @@ struct LocalAccessPointConfiguration { LocalAccessPointConfiguration() : ipList(NULL), ipListSize(0), domainList(NULL), domainListSize(0), verifyDomainName(NULL), mode(ConnectivityFirst) {} }; - +/** + * The information about recorded media streams. + */ +struct RecorderStreamInfo { + const char* channelId; + /** + * The user ID. + */ + uid_t uid; + /** + * The channel ID of the audio/video stream needs to be recorded. + */ + RecorderStreamInfo() : channelId(NULL), uid(0) {} + RecorderStreamInfo(const char* channelId, uid_t uid) : channelId(channelId), uid(uid) {} +}; } // namespace rtc namespace base { @@ -5994,9 +6029,9 @@ class AParameter : public agora::util::AutoPtr { private: bool initialize(IEngineBase* engine) { - IAgoraParameter* p = NULL; + IAgoraParameter* p = OPTIONAL_NULLPTR; if (engine && !engine->queryInterface(rtc::AGORA_IID_PARAMETER_ENGINE, (void**)&p)) reset(p); - return p != NULL; + return p != OPTIONAL_NULLPTR; } }; @@ -6048,7 +6083,47 @@ struct SpatialAudioParams { */ Optional enable_doppler; }; +/** + * Layout info of video stream which compose a transcoder video stream. +*/ +struct VideoLayout +{ + /** + * Channel Id from which this video stream come from. + */ + const char* channelId; + /** + * User id of video stream. + */ + rtc::uid_t uid; + /** + * User account of video stream. + */ + user_id_t strUid; + /** + * x coordinate of video stream on a transcoded video stream canvas. + */ + uint32_t x; + /** + * y coordinate of video stream on a transcoded video stream canvas. + */ + uint32_t y; + /** + * width of video stream on a transcoded video stream canvas. + */ + uint32_t width; + /** + * height of video stream on a transcoded video stream canvas. + */ + uint32_t height; + /** + * video state of video stream on a transcoded video stream canvas. + * 0 for normal video , 1 for placeholder image showed , 2 for black image. + */ + uint32_t videoState; + VideoLayout() : channelId(OPTIONAL_NULLPTR), uid(0), strUid(OPTIONAL_NULLPTR), x(0), y(0), width(0), height(0), videoState(0) {} +}; } // namespace agora /** diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/AgoraExtensionProviderEntry.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/AgoraExtensionProviderEntry.h index 66c43e71a..acae66ea4 100644 --- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/AgoraExtensionProviderEntry.h +++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/AgoraExtensionProviderEntry.h @@ -11,7 +11,7 @@ #include "NGIAgoraExtensionControl.h" AGORA_API agora::rtc::IExtensionControl* AGORA_CALL getAgoraExtensionControl(); AGORA_API void AGORA_CALL declareProviderVersion( - const char*, const agora::rtc::ExtensionVersion&); + const char*, const agora::rtc::ExtensionVersion&); typedef void(*agora_ext_entry_func_t)(void); AGORA_API void AGORA_CALL registerProviderEntry(const char*, agora_ext_entry_func_t); @@ -19,7 +19,7 @@ AGORA_API void AGORA_CALL registerProviderEntry(const char*, agora_ext_entry_fun static void register_##PROVIDER_NAME##_to_agora() { \ auto control = getAgoraExtensionControl(); \ agora::rtc::ExtensionVersion version = \ - agora::rtc::ExtensionInterfaceVersion::Version(); \ + agora::rtc::ExtensionInterfaceVersion::Version(); \ declareProviderVersion(#PROVIDER_NAME, version); \ if (#PROVIDER_NAME && control) { \ control->registerProvider(#PROVIDER_NAME, \ @@ -27,6 +27,18 @@ static void register_##PROVIDER_NAME##_to_agora() { } \ } \ +#define DECLARE_CREATE_AND_REGISTER_PROVIDER_PTR(PROVIDER_NAME, PROVIDER_INTERFACE_USED, PROVIDER_REF_PTR) \ +static void register_##PROVIDER_NAME##_to_agora() { \ + auto control = getAgoraExtensionControl(); \ + agora::rtc::ExtensionVersion version = \ + agora::rtc::ExtensionInterfaceVersion::Version(); \ + declareProviderVersion(#PROVIDER_NAME, version); \ + if (#PROVIDER_NAME && control) { \ + control->registerProvider(#PROVIDER_NAME, PROVIDER_REF_PTR); \ + } \ +} \ + + #if defined (__GNUC__) #define REGISTER_AGORA_EXTENSION_PROVIDER(PROVIDER_NAME, PROVIDER_CLASS, PROVIDER_INTERFACE_USED, ...) \ DECLARE_CREATE_AND_REGISTER_PROVIDER(PROVIDER_NAME, PROVIDER_CLASS, PROVIDER_INTERFACE_USED, __VA_ARGS__); \ @@ -35,6 +47,14 @@ static void _##PROVIDER_NAME##_provider_entry() { registerProviderEntry(#PROVIDER_NAME, register_##PROVIDER_NAME##_to_agora); \ } \ +#define REGISTER_AGORA_EXTENSION_PROVIDER_PTR(PROVIDER_NAME, PROVIDER_INTERFACE_USED, PROVIDER_REF_PTR) \ +DECLARE_CREATE_AND_REGISTER_PROVIDER_PTR(PROVIDER_NAME, PROVIDER_INTERFACE_USED, PROVIDER_REF_PTR); \ +__attribute__((constructor, used)) \ +static void _##PROVIDER_NAME##_provider_entry() { \ + registerProviderEntry(#PROVIDER_NAME, register_##PROVIDER_NAME##_to_agora); \ +} \ + + #elif defined (_MSC_VER) #define REGISTER_AGORA_EXTENSION_PROVIDER(PROVIDER_NAME, PROVIDER_CLASS, PROVIDER_INTERFACE_USED, ...) \ DECLARE_CREATE_AND_REGISTER_PROVIDER(PROVIDER_NAME, PROVIDER_CLASS, PROVIDER_INTERFACE_USED, __VA_ARGS__); \ @@ -44,6 +64,14 @@ static int _##PROVIDER_NAME##_provider_entry() { } \ const int DUMMY_AGORA_REGEXT_##PROVIDE_NAME##_VAR = _##PROVIDER_NAME##_provider_entry(); \ +#define REGISTER_AGORA_EXTENSION_PROVIDER_PTR(PROVIDER_NAME, PROVIDER_INTERFACE_USED, PROVIDER_REF_PTR) \ +DECLARE_CREATE_AND_REGISTER_PROVIDER_PTR(PROVIDER_NAME, PROVIDER_INTERFACE_USED, PROVIDER_REF_PTR); \ +static int _##PROVIDER_NAME##_provider_entry() { \ + registerProviderEntry(#PROVIDER_NAME, register_##PROVIDER_NAME##_to_agora); \ + return 0; \ +} \ +const int DUMMY_AGORA_REGEXT_##PROVIDE_NAME##_VAR = _##PROVIDER_NAME##_provider_entry(); \ + #else #error Unsupported Compilation Toolchain! #endif diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/AgoraMediaBase.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/AgoraMediaBase.h index bd0a7b881..15dfd4b38 100644 --- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/AgoraMediaBase.h +++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/AgoraMediaBase.h @@ -1,4 +1,3 @@ -// // Agora Engine SDK // // Created by Sting Feng in 2017-11. @@ -35,10 +34,8 @@ static const unsigned int INVALID_TRACK_ID = 0xffffffff; static const unsigned int DEFAULT_CONNECTION_ID = 0; static const unsigned int DUMMY_CONNECTION_ID = (std::numeric_limits::max)(); - struct EncodedVideoFrameInfo; - /** * Video source types definition. **/ @@ -105,45 +102,49 @@ enum AudioRoute */ ROUTE_DEFAULT = -1, /** - * The headset. + * The Headset. */ ROUTE_HEADSET = 0, /** - * The earpiece. + * The Earpiece. */ ROUTE_EARPIECE = 1, /** - * The headset with no microphone. + * The Headset with no microphone. */ ROUTE_HEADSETNOMIC = 2, /** - * The speakerphone. + * The Speakerphone. */ ROUTE_SPEAKERPHONE = 3, /** - * The loudspeaker. + * The Loudspeaker. */ ROUTE_LOUDSPEAKER = 4, /** - * The Bluetooth headset. + * The Bluetooth Headset via HFP. */ ROUTE_HEADSETBLUETOOTH = 5, /** - * The USB + * The USB. */ ROUTE_USB = 6, /** - * The HDMI + * The HDMI. */ ROUTE_HDMI = 7, /** - * The DISPLAYPORT + * The DisplayPort. */ ROUTE_DISPLAYPORT = 8, /** - * The AIRPLAY + * The AirPlay. */ ROUTE_AIRPLAY = 9, + /** + * The Bluetooth Speaker via A2DP. + */ + ROUTE_BLUETOOTH_SPEAKER = 10, }; /** @@ -551,6 +552,19 @@ enum CAMERA_VIDEO_SOURCE_TYPE { VIDEO_SOURCE_UNSPECIFIED = 2, }; +/** + * The IVideoFrameMetaInfo class. + * This interface provides access to metadata information. + */ +class IVideoFrameMetaInfo { + public: + enum META_INFO_KEY { + KEY_FACE_CAPTURE = 0, + }; + virtual ~IVideoFrameMetaInfo() {}; + virtual const char* getMetaInfoStr(META_INFO_KEY key) const = 0; +}; + /** * The definition of the ExternalVideoFrame struct. */ @@ -698,12 +712,12 @@ struct ExternalVideoFrame { uint8_t* alphaBuffer; /** - * [Windows Texture related parameter] The pointer of ID3D11Texture2D used by the video frame. + * [For Windows only] The pointer of ID3D11Texture2D used by the video frame. */ void *d3d11_texture_2d; /** - * [Windows Texture related parameter] The index of ID3D11Texture2D array used by the video frame. + * [For Windows only] The index of ID3D11Texture2D array used by the video frame. */ int texture_slice_index; }; @@ -731,7 +745,8 @@ struct VideoFrame { textureId(0), d3d11Texture2d(NULL), alphaBuffer(NULL), - pixelBuffer(NULL){ + pixelBuffer(NULL), + metaInfo(NULL){ memset(matrix, 0, sizeof(matrix)); } /** @@ -821,6 +836,10 @@ struct VideoFrame { *The type of CVPixelBufferRef, for iOS and macOS only. */ void* pixelBuffer; + /** + * The pointer to IVideoFrameMetaInfo, which is the interface to get metainfo contents from VideoFrame. + */ + IVideoFrameMetaInfo* metaInfo; }; /** @@ -865,6 +884,7 @@ enum VIDEO_MODULE_POSITION { POSITION_POST_CAPTURER = 1 << 0, POSITION_PRE_RENDERER = 1 << 1, POSITION_PRE_ENCODER = 1 << 2, + POSITION_POST_CAPTURER_ORIGIN = 1 << 3, }; } // namespace base @@ -942,10 +962,6 @@ class IAudioFrameObserverBase { * are used. */ int64_t renderTimeMs; - /** - * A reserved parameter. - */ - int avsync_type; /** * A reserved parameter. * @@ -953,7 +969,18 @@ class IAudioFrameObserverBase { * this will then filled into audio4 extension part, the remote side could use this pts in av * sync process with video frame. */ + int avsync_type; + /** + * The pts timestamp of this audio frame. + * + * This timestamp is used to indicate the origin pts time of the frame, and sync with video frame by + * the pts time stamp + */ int64_t presentationMs; + /** + * The number of the audio track. + */ + int audioTrackNumber; AudioFrame() : type(FRAME_TYPE_PCM16), samplesPerChannel(0), @@ -963,7 +990,8 @@ class IAudioFrameObserverBase { buffer(NULL), renderTimeMs(0), avsync_type(0), - presentationMs(0) {} + presentationMs(0), + audioTrackNumber(0) {} }; enum AUDIO_FRAME_POSITION { @@ -1180,9 +1208,9 @@ struct UserAudioSpectrumInfo { */ struct AudioSpectrumData spectrumData; - UserAudioSpectrumInfo () : uid(0), spectrumData() {} - UserAudioSpectrumInfo(agora::rtc::uid_t _uid, const float *data, int length) : - uid(_uid) { spectrumData.audioSpectrumData = data; spectrumData.dataLength = length; } + UserAudioSpectrumInfo() : uid(0) {} + + UserAudioSpectrumInfo(agora::rtc::uid_t uid, const float* data, int length) : uid(uid), spectrumData(data, length) {} }; /** @@ -1205,7 +1233,6 @@ class IAudioSpectrumObserver { * - false: Not processed. */ virtual bool onLocalAudioSpectrum(const AudioSpectrumData& data) = 0; - /** * Reports the audio spectrum of remote user. * @@ -1223,7 +1250,7 @@ class IAudioSpectrumObserver { * - true: Processed. * - false: Not processed. */ - virtual bool onRemoteAudioSpectrum(const UserAudioSpectrumInfo * spectrums, unsigned int spectrumNumber) = 0; + virtual bool onRemoteAudioSpectrum(const UserAudioSpectrumInfo* spectrums, unsigned int spectrumNumber) = 0; }; /** @@ -1505,7 +1532,7 @@ enum MediaRecorderStreamType { */ enum RecorderState { /** - * -1: An error occurs during the recording. See RecorderErrorCode for the reason. + * -1: An error occurs during the recording. See RecorderReasonCode for the reason. */ RECORDER_STATE_ERROR = -1, /** @@ -1522,27 +1549,27 @@ enum RecorderState { * * @since v3.5.2 */ -enum RecorderErrorCode { +enum RecorderReasonCode { /** * 0: No error occurs. */ - RECORDER_ERROR_NONE = 0, + RECORDER_REASON_NONE = 0, /** * 1: The SDK fails to write the recorded data to a file. */ - RECORDER_ERROR_WRITE_FAILED = 1, + RECORDER_REASON_WRITE_FAILED = 1, /** * 2: The SDK does not detect audio and video streams to be recorded, or audio and video streams are interrupted for more than five seconds during recording. */ - RECORDER_ERROR_NO_STREAM = 2, + RECORDER_REASON_NO_STREAM = 2, /** * 3: The recording duration exceeds the upper limit. */ - RECORDER_ERROR_OVER_MAX_DURATION = 3, + RECORDER_REASON_OVER_MAX_DURATION = 3, /** * 4: The recording configuration changes. */ - RECORDER_ERROR_CONFIG_CHANGED = 4, + RECORDER_REASON_CONFIG_CHANGED = 4, }; /** * Configurations for the local audio and video recording. @@ -1605,7 +1632,6 @@ struct RecorderInfo { RecorderInfo(const char* name, unsigned int dur, unsigned int size) : fileName(name), durationMs(dur), fileSize(size) {} }; - class IMediaRecorderObserver { public: /** @@ -1619,9 +1645,9 @@ class IMediaRecorderObserver { * @param channelId The channel name. * @param uid ID of the user. * @param state The current recording state. See \ref agora::media::RecorderState "RecorderState". - * @param error The reason for the state change. See \ref agora::media::RecorderErrorCode "RecorderErrorCode". + * @param reason The reason for the state change. See \ref agora::media::RecorderReasonCode "RecorderReasonCode". */ - virtual void onRecorderStateChanged(const char* channelId, rtc::uid_t uid, RecorderState state, RecorderErrorCode error) = 0; + virtual void onRecorderStateChanged(const char* channelId, rtc::uid_t uid, RecorderState state, RecorderReasonCode reason) = 0; /** * Occurs when the recording information is updated. * @@ -1637,7 +1663,9 @@ class IMediaRecorderObserver { * */ virtual void onRecorderInfoUpdated(const char* channelId, rtc::uid_t uid, const RecorderInfo& info) = 0; + virtual ~IMediaRecorderObserver() {} }; + } // namespace media } // namespace agora diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/AgoraMediaPlayerTypes.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/AgoraMediaPlayerTypes.h index d1bb17bb3..3beaba788 100644 --- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/AgoraMediaPlayerTypes.h +++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/AgoraMediaPlayerTypes.h @@ -105,61 +105,61 @@ enum MEDIA_PLAYER_STATE { * @brief Player error code * */ -enum MEDIA_PLAYER_ERROR { +enum MEDIA_PLAYER_REASON { /** No error. */ - PLAYER_ERROR_NONE = 0, + PLAYER_REASON_NONE = 0, /** The parameter is invalid. */ - PLAYER_ERROR_INVALID_ARGUMENTS = -1, + PLAYER_REASON_INVALID_ARGUMENTS = -1, /** Internel error. */ - PLAYER_ERROR_INTERNAL = -2, + PLAYER_REASON_INTERNAL = -2, /** No resource. */ - PLAYER_ERROR_NO_RESOURCE = -3, + PLAYER_REASON_NO_RESOURCE = -3, /** Invalid media source. */ - PLAYER_ERROR_INVALID_MEDIA_SOURCE = -4, + PLAYER_REASON_INVALID_MEDIA_SOURCE = -4, /** The type of the media stream is unknown. */ - PLAYER_ERROR_UNKNOWN_STREAM_TYPE = -5, + PLAYER_REASON_UNKNOWN_STREAM_TYPE = -5, /** The object is not initialized. */ - PLAYER_ERROR_OBJ_NOT_INITIALIZED = -6, + PLAYER_REASON_OBJ_NOT_INITIALIZED = -6, /** The codec is not supported. */ - PLAYER_ERROR_CODEC_NOT_SUPPORTED = -7, + PLAYER_REASON_CODEC_NOT_SUPPORTED = -7, /** Invalid renderer. */ - PLAYER_ERROR_VIDEO_RENDER_FAILED = -8, + PLAYER_REASON_VIDEO_RENDER_FAILED = -8, /** An error occurs in the internal state of the player. */ - PLAYER_ERROR_INVALID_STATE = -9, + PLAYER_REASON_INVALID_STATE = -9, /** The URL of the media file cannot be found. */ - PLAYER_ERROR_URL_NOT_FOUND = -10, + PLAYER_REASON_URL_NOT_FOUND = -10, /** Invalid connection between the player and the Agora server. */ - PLAYER_ERROR_INVALID_CONNECTION_STATE = -11, + PLAYER_REASON_INVALID_CONNECTION_STATE = -11, /** The playback buffer is insufficient. */ - PLAYER_ERROR_SRC_BUFFER_UNDERFLOW = -12, + PLAYER_REASON_SRC_BUFFER_UNDERFLOW = -12, /** The audio mixing file playback is interrupted. */ - PLAYER_ERROR_INTERRUPTED = -13, + PLAYER_REASON_INTERRUPTED = -13, /** The SDK does not support this function. */ - PLAYER_ERROR_NOT_SUPPORTED = -14, + PLAYER_REASON_NOT_SUPPORTED = -14, /** The token has expired. */ - PLAYER_ERROR_TOKEN_EXPIRED = -15, + PLAYER_REASON_TOKEN_EXPIRED = -15, /** The ip has expired. */ - PLAYER_ERROR_IP_EXPIRED = -16, + PLAYER_REASON_IP_EXPIRED = -16, /** An unknown error occurs. */ - PLAYER_ERROR_UNKNOWN = -17, + PLAYER_REASON_UNKNOWN = -17, }; /** @@ -357,18 +357,60 @@ struct CacheStatistics { int64_t downloadSize; }; -struct PlayerUpdatedInfo { - /** playerId has value when user trigger interface of opening +/** + * @brief The real time statistics of the media stream being played. + * + */ +struct PlayerPlaybackStats { + /** Video fps. */ - Optional playerId; - - /** deviceId has value when user trigger interface of opening + int videoFps; + /** Video bitrate (Kbps). + */ + int videoBitrateInKbps; + /** Audio bitrate (Kbps). */ - Optional deviceId; + int audioBitrateInKbps; + /** Total bitrate (Kbps). + */ + int totalBitrateInKbps; +}; - /** cacheStatistics exist if you enable cache, triggered 1s at a time after openning url +/** + * @brief The updated information of media player. + * + */ +struct PlayerUpdatedInfo { + /** @technical preview */ - Optional cacheStatistics; + const char* internalPlayerUuid; + /** The device ID of the playback device. + */ + const char* deviceId; + /** Video height. + */ + int videoHeight; + /** Video width. + */ + int videoWidth; + /** Audio sample rate. + */ + int audioSampleRate; + /** The audio channel number. + */ + int audioChannels; + /** The bit number of each audio sample. + */ + int audioBitsPerSample; + + PlayerUpdatedInfo() + : internalPlayerUuid(NULL), + deviceId(NULL), + videoHeight(0), + videoWidth(0), + audioSampleRate(0), + audioChannels(0), + audioBitsPerSample(0) {} }; /** @@ -436,6 +478,17 @@ struct MediaSource { * - false: (Default) Disable cache. */ bool enableCache; + /** + * Determines whether to enable multi-track audio stream decoding. + * Then you can select multi audio track of the media file for playback or publish to channel + * + * @note + * If you use the selectMultiAudioTrack API, you must set enableMultiAudioTrack to true. + * + * - true: Enable MultiAudioTrack;. + * - false: (Default) Disable MultiAudioTrack;. + */ + bool enableMultiAudioTrack; /** * Determines whether the opened media resource is a stream through the Agora Broadcast Streaming Network(CDN). * - true: It is a stream through the Agora Broadcast Streaming Network. @@ -454,7 +507,7 @@ struct MediaSource { IMediaPlayerCustomDataProvider* provider; MediaSource() : url(NULL), uri(NULL), startPos(0), autoPlay(true), enableCache(false), - provider(NULL){ + enableMultiAudioTrack(false), provider(NULL){ } }; diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/AgoraRefCountedObject.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/AgoraRefCountedObject.h index a457ef7db..93c970ed3 100644 --- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/AgoraRefCountedObject.h +++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/AgoraRefCountedObject.h @@ -7,6 +7,14 @@ // of Agora.io. #pragma once +#ifndef __AGORA_REF_COUNTED_OBJECT_H__ +#define __AGORA_REF_COUNTED_OBJECT_H__ +#endif + +#if defined(__AGORA_REF_COUNTED_OBJECT_INTERNAL_H__) +#error AgoraRefCountedObject is deprected now, its only purpose is for API compatiable. +#endif + #include "AgoraRefPtr.h" #include "AgoraAtomicOps.h" diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraFileUploader.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraFileUploader.h index 1ccd36718..f0611fe38 100644 --- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraFileUploader.h +++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraFileUploader.h @@ -9,6 +9,7 @@ #pragma once // NOLINT(build/header_guard) #include "AgoraRefPtr.h" +#include namespace agora { namespace rtc { @@ -37,8 +38,8 @@ struct ImagePayloadData { class IFileUploaderService : public RefCountInterface { public: virtual ~IFileUploaderService() {} - virtual int startImageUpload(const ImagePayloadData* imgData) = 0; - virtual int stopImageUpload() = 0; + virtual int startImageUpload(const ImagePayloadData* imgData, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; + virtual int stopImageUpload(ahpl_ref_t ares = AHPL_REF_INVALID) = 0; }; } // namespace rtc } // namespace agora diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraLog.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraLog.h index f3952163a..2fae3aa13 100644 --- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraLog.h +++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraLog.h @@ -75,7 +75,7 @@ const uint32_t MAX_LOG_SIZE = 20 * 1024 * 1024; // 20MB const uint32_t MIN_LOG_SIZE = 128 * 1024; // 128KB /** The default log size in kb */ -const uint32_t DEFAULT_LOG_SIZE_IN_KB = 1024; +const uint32_t DEFAULT_LOG_SIZE_IN_KB = 2048; /** Definition of LogConfiguration */ @@ -83,7 +83,7 @@ struct LogConfig { /**The log file path, default is NULL for default log path */ const char* filePath; - /** The log file size, KB , set 1024KB to use default log size + /** The log file size, KB , set 2048KB to use default log size */ uint32_t fileSizeInKB; /** The log level, set LOG_LEVEL_INFO to use default log level diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraMediaPlayerSource.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraMediaPlayerSource.h index 8d1a95be0..00be02233 100644 --- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraMediaPlayerSource.h +++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraMediaPlayerSource.h @@ -118,7 +118,7 @@ class IMediaPlayerSource : public RefCountInterface { * @param [out] pos A reference to the current playback position (ms). * @return * - 0: Success. - * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_ERROR MEDIA_PLAYER_ERROR}. + * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. */ virtual int getPlayPosition(int64_t& pos) = 0; @@ -127,7 +127,7 @@ class IMediaPlayerSource : public RefCountInterface { * @param [out] count The number of the media streams in the media source. * @return * - 0: Success. - * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_ERROR MEDIA_PLAYER_ERROR}. + * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. */ virtual int getStreamCount(int64_t& count) = 0; @@ -137,7 +137,7 @@ class IMediaPlayerSource : public RefCountInterface { * @param [out] info The detailed information of the media stream. See \ref media::base::PlayerStreamInfo "PlayerStreamInfo" for details. * @return * - 0: Success. - * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_ERROR MEDIA_PLAYER_ERROR}. + * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. */ virtual int getStreamInfo(int64_t index, media::base::PlayerStreamInfo* info) = 0; @@ -149,7 +149,7 @@ class IMediaPlayerSource : public RefCountInterface { * - -1: Play the media file in a loop indefinitely, until {@link stop} is called. * @return * - 0: Success. - * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_ERROR MEDIA_PLAYER_ERROR}. + * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. */ virtual int setLoopCount(int64_t loopCount) = 0; @@ -158,7 +158,7 @@ class IMediaPlayerSource : public RefCountInterface { * @param speed The playback speed ref [50-400]. * @return * - 0: Success. - * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_ERROR MEDIA_PLAYER_ERROR}. + * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. */ virtual int setPlaybackSpeed(int speed) = 0; @@ -167,17 +167,34 @@ class IMediaPlayerSource : public RefCountInterface { * @param index The index of the audio track in media file. * @return * - 0: Success. - * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_ERROR MEDIA_PLAYER_ERROR}. + * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. */ virtual int selectAudioTrack(int64_t index) = 0; + /** + * Selects multi audio track of the media file for playback or publish to channel. + * @param playoutTrackIndex The index of the audio track in media file for local playback. + * @param publishTrackIndex The index of the audio track in the media file published to the remote. + * + * @note + * You can obtain the streamIndex of the audio track by calling getStreamInfo.. + * If you want to use selectMultiAudioTrack, you need to open the media file with openWithMediaSource and set enableMultiAudioTrack to true. + * + * @return + * - 0: Success. + * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. + * - -2: Invalid argument. Argument must be greater than or equal to zero. + * - -8: Invalid State.You must open the media file with openWithMediaSource and set enableMultiAudioTrack to true + */ + virtual int selectMultiAudioTrack(int playoutTrackIndex, int publishTrackIndex) = 0; + /** * Changes the player option before playing a file. * @param key The key of the option paramemter. * @param value The value of option parameter. * @return * - 0: Success. - * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_ERROR MEDIA_PLAYER_ERROR}. + * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. */ virtual int setPlayerOption(const char* key, int64_t value) = 0; @@ -187,7 +204,7 @@ class IMediaPlayerSource : public RefCountInterface { * @param value The value of option parameter. * @return * - 0: Success. - * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_ERROR MEDIA_PLAYER_ERROR}. + * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. */ virtual int setPlayerOption(const char* key, const char* value) = 0; @@ -196,7 +213,7 @@ class IMediaPlayerSource : public RefCountInterface { * @param filename The filename of the screenshot file. * @return * - 0: Success. - * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_ERROR MEDIA_PLAYER_ERROR}. + * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. */ virtual int takeScreenshot(const char* filename) = 0; @@ -205,7 +222,7 @@ class IMediaPlayerSource : public RefCountInterface { * @param index The index of the internal subtitles. * @return * - 0: Success. - * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_ERROR MEDIA_PLAYER_ERROR}. + * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. */ virtual int selectInternalSubtitle(int64_t index) = 0; @@ -214,7 +231,7 @@ class IMediaPlayerSource : public RefCountInterface { * @param url The URL of the subtitle file. * @return * - 0: Success. - * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_ERROR MEDIA_PLAYER_ERROR}. + * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. */ virtual int setExternalSubtitle(const char* url) = 0; @@ -231,7 +248,7 @@ class IMediaPlayerSource : public RefCountInterface { * @param observer The pointer to the IMediaPlayerSourceObserver object. * @return * - 0: Success. - * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_ERROR MEDIA_PLAYER_ERROR}. + * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. */ virtual int registerPlayerSourceObserver(IMediaPlayerSourceObserver* observer) = 0; @@ -240,7 +257,7 @@ class IMediaPlayerSource : public RefCountInterface { * @param observer The pointer to the IMediaPlayerSourceObserver object. * @return * - 0: Success. - * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_ERROR MEDIA_PLAYER_ERROR}. + * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. */ virtual int unregisterPlayerSourceObserver(IMediaPlayerSourceObserver* observer) = 0; @@ -250,7 +267,7 @@ class IMediaPlayerSource : public RefCountInterface { * @param observer The pointer to the {@link media::IAudioPcmFrameSink observer} object. * @return * - 0: Success. - * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_ERROR MEDIA_PLAYER_ERROR}. + * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. */ virtual int registerAudioFrameObserver(media::IAudioPcmFrameSink* observer) = 0; @@ -259,7 +276,7 @@ class IMediaPlayerSource : public RefCountInterface { * @param observer The pointer to the {@link media::IAudioPcmFrameSink observer} object. * @return * - 0: Success. - * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_ERROR MEDIA_PLAYER_ERROR}. + * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. */ virtual int unregisterAudioFrameObserver(media::IAudioPcmFrameSink* observer) = 0; @@ -380,18 +397,19 @@ class IMediaPlayerSourceObserver { * * When the state of the playback changes, the SDK triggers this callback to report the new playback state and the reason or error for the change. * @param state The new playback state after change. See {@link media::base::MEDIA_PLAYER_STATE MEDIA_PLAYER_STATE}. - * @param ec The player's error code. See {@link media::base::MEDIA_PLAYER_ERROR MEDIA_PLAYER_ERROR}. + * @param reason The player's error code. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. */ virtual void onPlayerSourceStateChanged(media::base::MEDIA_PLAYER_STATE state, - media::base::MEDIA_PLAYER_ERROR ec) = 0; + media::base::MEDIA_PLAYER_REASON reason) = 0; /** * @brief Reports current playback progress. * * The callback occurs once every one second during the playback and reports the current playback progress. - * @param position Current playback progress (milisecond). + * @param positionMs Current playback progress (milisecond). + * @param timestampMs Current NTP(Network Time Protocol) time (milisecond). */ - virtual void onPositionChanged(int64_t position_ms) = 0; + virtual void onPositionChanged(int64_t positionMs, int64_t timestampMs) = 0; /** * @brief Reports the playback event. @@ -455,6 +473,24 @@ class IMediaPlayerSourceObserver { * @param info Include information of media player. */ virtual void onPlayerInfoUpdated(const media::base::PlayerUpdatedInfo& info) = 0; + + /** + * @brief Triggered every 1 second, reports the statistics of the files being cached. + * + * @param stats Cached file statistics. + */ + virtual void onPlayerCacheStats(const media::base::CacheStatistics& stats) { + (void)stats; + } + + /** + * @brief Triggered every 1 second, reports the statistics of the media stream being played. + * + * @param stats The statistics of the media stream. + */ + virtual void onPlayerPlaybackStats(const media::base::PlayerPlaybackStats& stats) { + (void)stats; + } /** * @brief Triggered every 200 millisecond ,update player current volume range [0,255] diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraParameter.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraParameter.h index 70ea5939e..b88969e1d 100644 --- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraParameter.h +++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraParameter.h @@ -15,6 +15,7 @@ */ #pragma once // NOLINT(build/header_guard) +#include "AgoraRefPtr.h" // external key /** @@ -115,6 +116,7 @@ * set the video codec type, such as "H264", "JPEG" */ #define KEY_RTC_VIDEO_CODEC_TYPE "engine.video.codec_type" +#define KEY_RTC_VIDEO_MINOR_STREAM_CODEC_TYPE "engine.video.minor_stream_codec_type" #define KEY_RTC_VIDEO_CODEC_INDEX "che.video.videoCodecIndex" /** * only use average QP for quality scaling @@ -144,7 +146,7 @@ typedef CopyableAutoPtr AString; namespace base { -class IAgoraParameter { +class IAgoraParameter : public RefCountInterface { public: /** * release the resource @@ -300,6 +302,7 @@ class IAgoraParameter { virtual int convertPath(const char* filePath, agora::util::AString& value) = 0; + protected: virtual ~IAgoraParameter() {} }; diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraRtmService.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraRtmService.h index 70dbbf1c1..1ce7c5f91 100644 --- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraRtmService.h +++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraRtmService.h @@ -7,6 +7,7 @@ #pragma once #include +#include namespace agora { @@ -519,7 +520,7 @@ class IChannel { * Sets an event handler for IChannel. * @param eventHandler The pointer to the event handler of IChannel: IChannelEventHandler. */ - virtual void setEventHandler(IChannelEventHandler *eventHandler) = 0; + virtual int setEventHandler(IChannelEventHandler *eventHandler, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Joins the current channel. * @@ -529,7 +530,7 @@ class IChannel { * - 0: Success. * - < 0: Failure. */ - virtual int join() = 0; + virtual int join(ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Leaves the current channel. * @@ -538,7 +539,7 @@ class IChannel { * - 0: Success. * - < 0: Failure. */ - virtual int leave() = 0; + virtual int leave(ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Sends a channel message. * @@ -549,7 +550,7 @@ class IChannel { * - 0: Success. * - < 0: Failure. */ - virtual int sendMessage(const IMessage *message) = 0; + virtual int sendMessage(const IMessage *message, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Updates the channel attributes. * @@ -560,7 +561,7 @@ class IChannel { * - 0: Success. * - < 0: Failure. */ - virtual int updateAttributes(IChannelAttributes *attributes, int64_t &requestId) = 0; + virtual int updateAttributes(IChannelAttributes *attributes, int64_t &requestId, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Removes the channel attributes. * @@ -571,7 +572,7 @@ class IChannel { * - 0: Success. * - < 0: Failure. */ - virtual int deleteAttributes(IChannelAttributes *attributes, int64_t &requestId) = 0; + virtual int deleteAttributes(IChannelAttributes *attributes, int64_t &requestId, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Gets the current request ID. * @return @@ -674,14 +675,14 @@ class IRtmService { * - 0: Success. * - < 0: Failure. */ - virtual int login(const char *token, const char *userId) = 0; + virtual int login(const char *token, const char *userId, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Logs out of the RTM service. * @return * - 0: Success. * - < 0: Failure. */ - virtual int logout() = 0; + virtual int logout(ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Sends a peer message to a specified remote user. * @@ -691,7 +692,7 @@ class IRtmService { * - 0: Success. * - < 0: Failure. */ - virtual int sendMessageToPeer(const char *peerId, const IMessage *message) = 0; + virtual int sendMessageToPeer(const char *peerId, const IMessage *message, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Creates an RTM channel. * diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraRtmpStreamingService.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraRtmpStreamingService.h index 59736d4ab..0f6a1eec8 100644 --- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraRtmpStreamingService.h +++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/IAgoraRtmpStreamingService.h @@ -12,6 +12,7 @@ #include "AgoraRefPtr.h" #include "IAgoraService.h" #include "NGIAgoraRtcConnection.h" +#include namespace agora { namespace rtc { @@ -51,13 +52,13 @@ class IRtmpStreamingObserver { * * @param url The RTMP URL address. * @param state The RTMP streaming state: #RTMP_STREAM_PUBLISH_STATE. - * @param errCode The detailed error information for streaming: #RTMP_STREAM_PUBLISH_ERROR_TYPE. + * @param reason The detailed error information for streaming: #RTMP_STREAM_PUBLISH_REASON. */ virtual void onRtmpStreamingStateChanged(const char* url, RTMP_STREAM_PUBLISH_STATE state, - RTMP_STREAM_PUBLISH_ERROR_TYPE errCode) { + RTMP_STREAM_PUBLISH_REASON reason) { (void)url; (void)state; - (void)errCode; + (void)reason; } /** Reports events during the RTMP or RTMPS streaming. @@ -109,7 +110,7 @@ class IRtmpStreamingService : public RefCountInterface { * - #ERR_NOT_INITIALIZED (7): You have not initialized the RTC engine when publishing the stream. * - #ERR_ALREADY_IN_USE (19): This streaming URL is already in use. Use a new streaming URL for CDN streaming. */ - virtual int startRtmpStreamWithoutTranscoding(const char* url) = 0; + virtual int startRtmpStreamWithoutTranscoding(const char* url, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** Publishes the local stream with transcoding to a specified CDN live RTMP address. (CDN live only.) @@ -132,7 +133,7 @@ class IRtmpStreamingService : public RefCountInterface { * - #ERR_NOT_INITIALIZED (7): You have not initialized the RTC engine when publishing the stream. * - #ERR_ALREADY_IN_USE (19): This streaming URL is already in use. Use a new streaming URL for CDN streaming. */ - virtual int startRtmpStreamWithTranscoding(const char* url, const LiveTranscoding& transcoding) = 0; + virtual int startRtmpStreamWithTranscoding(const char* url, const LiveTranscoding& transcoding, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** Update the video layout and audio settings for CDN live. (CDN live only.) * @note This method applies to Live Broadcast only. @@ -143,7 +144,7 @@ class IRtmpStreamingService : public RefCountInterface { * - 0: Success. * - < 0: Failure. */ - virtual int updateRtmpTranscoding(const LiveTranscoding& transcoding) = 0; + virtual int updateRtmpTranscoding(const LiveTranscoding& transcoding, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** Stop an RTMP stream with transcoding or without transcoding from the CDN. (CDN live only.) * This method removes the RTMP URL address (added by the \ref IRtcEngine::startRtmpStreamWithoutTranscoding "startRtmpStreamWithoutTranscoding" method @@ -162,7 +163,7 @@ class IRtmpStreamingService : public RefCountInterface { * - 0: Success. * - < 0: Failure. */ - virtual int stopRtmpStream(const char* url) = 0; + virtual int stopRtmpStream(const char* url, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Registers an RTMP streaming observer. @@ -171,7 +172,7 @@ class IRtmpStreamingService : public RefCountInterface { * - 0: Success. * - < 0: Failure. */ - virtual int registerObserver(IRtmpStreamingObserver* observer) = 0; + virtual int registerObserver(IRtmpStreamingObserver* observer, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Releases the RTMP streaming observer created by registerObserver(). * @param observer The pointer to the RTMP streaming observer that you want to release. See \ref agora::rtc::IRtmpStreamingObserver "IRtmpStreamingObserver". 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 8890b01d0..9feb0c914 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 @@ -8,6 +8,7 @@ #include "IAgoraLog.h" #include "AgoraBase.h" #include "AgoraOptional.h" +#include namespace agora { class ILocalDataChannel; @@ -392,7 +393,7 @@ class IAgoraService { /** * Flush log & cache before exit */ - virtual void atExit() = 0; + virtual int atExit(ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Releases the \ref agora::base::IAgoraService "AgoraService" object. @@ -412,7 +413,7 @@ class IAgoraService { * - 0: Success. * - < 0: Failure. */ - virtual int setAudioSessionPreset(agora::rtc::AUDIO_SCENARIO_TYPE scenario) = 0; + virtual int setAudioSessionPreset(agora::rtc::AUDIO_SCENARIO_TYPE scenario, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Customizes the audio session configuration. @@ -422,7 +423,7 @@ class IAgoraService { * - 0: Success. * - < 0: Failure. */ - virtual int setAudioSessionConfiguration(const AudioSessionConfiguration& config) = 0; + virtual int setAudioSessionConfiguration(const AudioSessionConfiguration& config, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Gets the audio session configuration. @@ -448,12 +449,12 @@ class IAgoraService { * \ref agora::base::IAgoraService::initialize "initialize". * * @param filePath The pointer to the log file. Ensure that the directory of the log file exists and is writable. - * @param fileSize The size of the SDK log file size (KB). + * @param fileSize The size of the SDK log file size (Byte), which means fileSize bytes per log file. * @return * - 0: Success. * - < 0: Failure. */ - virtual int setLogFile(const char* filePath, unsigned int fileSize) = 0; + virtual int setLogFile(const char* filePath, unsigned int fileSize, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Sets the SDK log output filter. * @@ -472,7 +473,7 @@ class IAgoraService { * - 0: Success. * - < 0: Failure. */ - virtual int setLogFilter(unsigned int filters) = 0; + virtual int setLogFilter(unsigned int filters, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Creates an \ref agora::rtc::IRtcConnection "RtcConnection" object and returns the pointer. @@ -501,6 +502,17 @@ class IAgoraService { */ virtual agora_refptr createLocalAudioTrack() = 0; + /** + * Creates a local mixed audio track object and returns the pointer. + * + * By default, the audio track is created from mix source, which could mixed target track. + * + * @return + * - The pointer to \ref rtc::ILocalAudioTrack "ILocalAudioTrack": Success. + * - A null pointer: Failure. + */ + virtual agora_refptr createLocalMixedAudioTrack() = 0; + /** * Creates a local audio track object with a PCM data sender and returns the pointer. * @@ -662,19 +674,6 @@ class IAgoraService { virtual agora_refptr createCameraVideoTrack( agora_refptr videoSource, const char* id = OPTIONAL_NULLPTR) = 0; - /** - * Creates a local video track object with a screen capturer and returns the pointer. - * - * Once created, this track can be used to send video data for screen sharing. - * - * @param videoSource The pointer to the screen capturer: \ref agora::rtc::IScreenCapturer "IScreenCapturer". - * @return - * - The pointer to \ref rtc::ILocalVideoTrack "ILocalVideoTrack": Success. - * - A null pointer: Failure. - */ - virtual agora_refptr createScreenVideoTrack( - agora_refptr videoSource, const char* id = OPTIONAL_NULLPTR) = 0; - /** * Creates a local video track object with a video mixer and returns the pointer. * @@ -867,9 +866,9 @@ class IAgoraService { */ virtual rtm::IRtmService* createRtmService() = 0; - virtual int addExtensionObserver(agora::agora_refptr observer) = 0; + virtual int addExtensionObserver(agora::agora_refptr observer, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; - virtual int removeExtensionObserver(agora::agora_refptr observer) = 0; + virtual int removeExtensionObserver(agora::agora_refptr observer, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Creates an audio device manager and returns the pointer. @@ -925,7 +924,7 @@ class IAgoraService { */ virtual int enableExtension( const char* provider_name, const char* extension_name, const char* track_id = NULL, - bool auto_enable_on_track = false) = 0; + bool auto_enable_on_track = false, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Disable extension. * @@ -938,7 +937,16 @@ class IAgoraService { * - < 0: Failure. */ virtual int disableExtension( - const char* provider_name, const char* extension_name, const char* track_id = NULL) = 0; + const char* provider_name, const char* extension_name, const char* track_id = NULL, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; + + /** + * Gets the IAgoraParameter object. + * @since 4.3.0 + * @return + * - The pointer to the \ref agora::base::IAgoraParameter "IAgoraParameter" object. + * - A null pointer: Failure. + */ + virtual agora_refptr getAgoraParameter() = 0; /** * Get the \ref agora::rtc::IConfigCenter "IConfigCenter" object and return the pointer. diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraAudioDeviceManager.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraAudioDeviceManager.h index c884a3951..6374ca11c 100644 --- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraAudioDeviceManager.h +++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraAudioDeviceManager.h @@ -10,6 +10,7 @@ #include "AgoraBase.h" #include "AgoraRefPtr.h" +#include namespace agora { namespace media { namespace base { @@ -146,7 +147,7 @@ class IRecordingDeviceSource : public RefCountInterface { * - 0: Success. * - < 0: Failure. */ - virtual int startRecording() = 0; + virtual int startRecording(ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Stop the recording device. @@ -154,7 +155,7 @@ class IRecordingDeviceSource : public RefCountInterface { * - 0: Success. * - < 0: Failure. */ - virtual int stopRecording() = 0; + virtual int stopRecording(ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Registers an audio frame observer. @@ -164,7 +165,7 @@ class IRecordingDeviceSource : public RefCountInterface { * - 0: Success. * - < 0: Failure. */ - virtual int registerAudioFrameObserver(media::IAudioPcmFrameSink* observer) = 0; + virtual int registerAudioFrameObserver(media::IAudioPcmFrameSink* observer, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Releases the registered IAudioFrameObserver object. @@ -182,7 +183,7 @@ class IRecordingDeviceSource : public RefCountInterface { * - 0: Success. * - < 0: Failure. */ - virtual int setLoopbackDeviceParameter(const LoopbackRecordingOption &option) = 0; + virtual int setLoopbackDeviceParameter(const LoopbackRecordingOption &option, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; virtual ~IRecordingDeviceSource() {} }; @@ -212,7 +213,7 @@ class INGAudioDeviceManager : public RefCountInterface { * - 0: Success. * - < 0: Failure. */ - virtual int setMicrophoneVolume(unsigned int volume) = 0; + virtual int setMicrophoneVolume(unsigned int volume, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Gets the volume of the microphone. * @param volume The volume of the microphone. @@ -228,7 +229,7 @@ class INGAudioDeviceManager : public RefCountInterface { * - 0: Success. * - < 0: Failure. */ - virtual int setSpeakerVolume(unsigned int volume) = 0; + virtual int setSpeakerVolume(unsigned int volume, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Gets the volume of the speaker. * @param volume The volume of the speaker. @@ -246,7 +247,7 @@ class INGAudioDeviceManager : public RefCountInterface { * - 0: Success. * - < 0: Failure. */ - virtual int setMicrophoneMute(bool mute) = 0; + virtual int setMicrophoneMute(bool mute, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Gets the mute state of the microphone. * @param mute The mute state of the microphone. @@ -264,7 +265,7 @@ class INGAudioDeviceManager : public RefCountInterface { * - 0: Success. * - < 0: Failure. */ - virtual int setSpeakerMute(bool mute) = 0; + virtual int setSpeakerMute(bool mute, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Gets the mute state of the speaker. * @param mute A reference to the mute state of the speaker. @@ -308,7 +309,7 @@ class INGAudioDeviceManager : public RefCountInterface { * - 0: Success. * - < 0: Failure. */ - virtual int setDefaultAudioRouting(AudioRoute route) = 0; + virtual int setDefaultAudioRouting(AudioRoute route, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Changes the current audio routing. * @@ -320,7 +321,7 @@ class INGAudioDeviceManager : public RefCountInterface { * - 0: Success. * - < 0: Failure. */ - virtual int changeAudioRouting(AudioRoute route) = 0; + virtual int changeAudioRouting(AudioRoute route, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Changes the speaker status on/off. * @@ -332,7 +333,7 @@ class INGAudioDeviceManager : public RefCountInterface { * - 0: Success. * - < 0: Failure. */ - virtual int setAudioRoutingSpeakerOn(bool enable) = 0; + virtual int setAudioRoutingSpeakerOn(bool enable, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Gets the current audio routing. * @@ -404,7 +405,7 @@ class INGAudioDeviceManager : public RefCountInterface { * - 0: Success. * - < 0: Failure. */ - virtual int setPlayoutDevice(int index) = 0; + virtual int setPlayoutDevice(int index, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Sets the recording device. * @@ -416,7 +417,7 @@ class INGAudioDeviceManager : public RefCountInterface { * - 0: Success. * - < 0: Failure. */ - virtual int setRecordingDevice(int index) = 0; + virtual int setRecordingDevice(int index, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** The status of following system default playback device. @note The status of following system default playback device. @@ -428,7 +429,7 @@ class INGAudioDeviceManager : public RefCountInterface { - 0: Success. - < 0: Failure. */ - virtual int followSystemPlaybackDevice(bool enable) = 0; + virtual int followSystemPlaybackDevice(bool enable, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** The status of following system default recording device. @@ -441,7 +442,7 @@ class INGAudioDeviceManager : public RefCountInterface { - 0: Success. - < 0: Failure. */ - virtual int followSystemRecordingDevice(bool enable) = 0; + virtual int followSystemRecordingDevice(bool enable, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; #endif // _WIN32 || (TARGET_OS_MAC && !TARGET_OS_IPHONE) #if defined(_WIN32) @@ -456,7 +457,7 @@ class INGAudioDeviceManager : public RefCountInterface { * - 0: Success. * - < 0: Failure. */ - virtual int setApplicationVolume(unsigned int volume) = 0; + virtual int setApplicationVolume(unsigned int volume, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Gets the volume of the app. * @@ -482,7 +483,7 @@ class INGAudioDeviceManager : public RefCountInterface { * - 0: Success. * - < 0: Failure. */ - virtual int setApplicationMuteState(bool mute) = 0; + virtual int setApplicationMuteState(bool mute, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Gets the mute state of the app. * @@ -517,7 +518,7 @@ class INGAudioDeviceManager : public RefCountInterface { * - 0: Success. * - < 0: Failure. */ - virtual int setLoopbackDevice(int index) = 0; + virtual int setLoopbackDevice(int index, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** The status of following system default loopback device. @note The status of following system default loopback device. @@ -529,7 +530,7 @@ class INGAudioDeviceManager : public RefCountInterface { - 0: Success. - < 0: Failure. */ - virtual int followSystemLoopbackDevice(bool enable) = 0; + virtual int followSystemLoopbackDevice(bool enable, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; #endif // _WIN32 /** @@ -543,7 +544,7 @@ class INGAudioDeviceManager : public RefCountInterface { * - 0: Success. * - < 0: Failure. */ - virtual int registerObserver(IAudioDeviceManagerObserver* observer, void(*safeDeleter)(IAudioDeviceManagerObserver*) = NULL) = 0; + virtual int registerObserver(IAudioDeviceManagerObserver* observer, void(*safeDeleter)(IAudioDeviceManagerObserver*) = NULL, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Releases the IAudioDeviceManagerObserver object. * @param observer The pointer to the IAudioDeviceManagerObserver class registered using #registerObserver. @@ -553,7 +554,7 @@ class INGAudioDeviceManager : public RefCountInterface { */ virtual int unregisterObserver(IAudioDeviceManagerObserver* observer) = 0; - virtual int setupAudioAttributeContext(void* audioAttr) = 0; + virtual int setupAudioAttributeContext(void* audioAttr, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; protected: ~INGAudioDeviceManager() {} 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 e6adb3e75..1d24933ed 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 @@ -9,6 +9,7 @@ #pragma once // NOLINT(build/header_guard) #include "AgoraBase.h" +#include // FIXME(Ender): use this class instead of AudioSendStream as local track namespace agora { @@ -36,6 +37,7 @@ struct AudioSinkWants { channels(0) {} AudioSinkWants(int sampleRate, size_t chs) : samplesPerSec(sampleRate), channels(chs) {} + AudioSinkWants(int sampleRate, size_t chs, int trackNum) : samplesPerSec(sampleRate), channels(chs) {} }; /** @@ -85,7 +87,7 @@ class IAudioTrack : public RefCountInterface { * - 0: Success. * - < 0: Failure. */ - virtual int adjustPlayoutVolume(int volume) = 0; + virtual int adjustPlayoutVolume(int volume, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Gets the current playback volume. @@ -106,7 +108,7 @@ class IAudioTrack : public RefCountInterface { * - `true`: Success. * - `false`: Failure. */ - virtual bool addAudioFilter(agora_refptr filter, AudioFilterPosition position) = 0; + virtual bool addAudioFilter(agora_refptr filter, AudioFilterPosition position, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Removes the audio filter added by callling `addAudioFilter`. * @@ -116,7 +118,7 @@ class IAudioTrack : public RefCountInterface { * - `true`: Success. * - `false`: Failure. */ - virtual bool removeAudioFilter(agora_refptr filter, AudioFilterPosition position) = 0; + virtual bool removeAudioFilter(agora_refptr filter, AudioFilterPosition position, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Enable / Disable specified audio filter @@ -127,7 +129,7 @@ class IAudioTrack : public RefCountInterface { * - 0: success * - <0: failure */ - virtual int enableAudioFilter(const char* id, bool enable, AudioFilterPosition position) { + virtual int enableAudioFilter(const char* id, bool enable, AudioFilterPosition position, ahpl_ref_t ares = AHPL_REF_INVALID) { (void)id; (void)enable; (void)position; @@ -144,7 +146,7 @@ class IAudioTrack : public RefCountInterface { * - 0: success * - <0: failure */ - virtual int setFilterProperty(const char* id, const char* key, const char* jsonValue, AudioFilterPosition position) { + virtual int setFilterProperty(const char* id, const char* key, const char* jsonValue, AudioFilterPosition position, ahpl_ref_t ares = AHPL_REF_INVALID) { (void)id; (void)key; (void)jsonValue; @@ -192,7 +194,7 @@ class IAudioTrack : public RefCountInterface { * - `true`: Success. * - `false`: Failure. */ - virtual bool addAudioSink(agora_refptr sink, const AudioSinkWants& wants) = 0; + virtual bool addAudioSink(agora_refptr sink, const AudioSinkWants& wants, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Removes an audio sink. @@ -202,7 +204,7 @@ class IAudioTrack : public RefCountInterface { * - `true`: Success. * - `false`: Failure. */ - virtual bool removeAudioSink(agora_refptr sink) = 0; + virtual bool removeAudioSink(agora_refptr sink, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; }; /** @@ -216,10 +218,10 @@ class ILocalAudioTrackObserver { * Occurs when the state of a local audio track changes. * * @param state The state of the local audio track. - * @param errorCode The error information for a state failure: \ref agora::rtc::LOCAL_AUDIO_STREAM_ERROR "LOCAL_AUDIO_STREAM_ERROR". + * @param reasonCode The error information for a state failure: \ref agora::rtc::LOCAL_AUDIO_STREAM_REASON "LOCAL_AUDIO_STREAM_REASON". */ virtual void onLocalAudioTrackStateChanged(LOCAL_AUDIO_STREAM_STATE state, - LOCAL_AUDIO_STREAM_ERROR errorCode) = 0; + LOCAL_AUDIO_STREAM_REASON reasonCode) = 0; }; /** @@ -313,7 +315,7 @@ class ILocalAudioTrack : public IAudioTrack { * - `true`: Enable the local audio track. * - `false`: Disable the local audio track. */ - virtual void setEnabled(bool enable) = 0; + virtual int setEnabled(bool enable, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Gets whether the local audio track is enabled. @@ -343,7 +345,7 @@ class ILocalAudioTrack : public IAudioTrack { * - 0: Success. * - < 0: Failure. */ - virtual int adjustPublishVolume(int volume) = 0; + virtual int adjustPublishVolume(int volume, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Gets the current volume for publishing. @@ -366,7 +368,7 @@ class ILocalAudioTrack : public IAudioTrack { * - 0: Success. * - < 0: Failure. */ - virtual int enableLocalPlayback(bool enable, bool sync = true) = 0; + virtual int enableLocalPlayback(bool enable, bool sync = true, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Enables in-ear monitoring (for Android and iOS only). @@ -379,7 +381,7 @@ class ILocalAudioTrack : public IAudioTrack { * - 0: Success. * - < 0: Failure. */ - virtual int enableEarMonitor(bool enable, int includeAudioFilters) = 0; + virtual int enableEarMonitor(bool enable, int includeAudioFilters, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** Register an local audio track observer * * @param observer A pointer to the local audio track observer: \ref agora::rtc::ILocalAudioTrackObserver @@ -388,7 +390,7 @@ class ILocalAudioTrack : public IAudioTrack { * - 0: Success. * - < 0: Failure. */ - virtual int registerTrackObserver(ILocalAudioTrackObserver* observer) = 0; + virtual int registerTrackObserver(ILocalAudioTrackObserver* observer, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** Releases the local audio track observer * * @param observer A pointer to the local audio track observer: \ref agora::rtc::ILocalAudioTrackObserver @@ -554,6 +556,10 @@ struct RemoteAudioTrackStats { * Duration of inbandfec */ int32_t fec_decode_ms; + /** + * The count of 10 ms frozen in 2 seconds + */ + uint16_t frozen_count_10_ms; /** * The total time (ms) when the remote user neither stops sending the audio * stream nor disables the audio module after joining the channel. @@ -616,6 +622,7 @@ struct RemoteAudioTrackStats { frozen_rate_by_custom_plc_count(0), plc_count(0), fec_decode_ms(-1), + frozen_count_10_ms(0), total_active_time(0), publish_duration(0), e2e_delay_ms(0), @@ -656,7 +663,7 @@ class IRemoteAudioTrack : public IAudioTrack { * - 0: Success. * - < 0: Failure. */ - virtual int registerMediaPacketReceiver(IMediaPacketReceiver* packetReceiver) = 0; + virtual int registerMediaPacketReceiver(IMediaPacketReceiver* packetReceiver, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Releases the `IMediaPacketReceiver` object. @@ -679,7 +686,7 @@ class IRemoteAudioTrack : public IAudioTrack { * - 0: Success. * - < 0: Failure. */ - virtual int registerAudioEncodedFrameReceiver(IAudioEncodedFrameReceiver* packetReceiver) = 0; + virtual int registerAudioEncodedFrameReceiver(IAudioEncodedFrameReceiver* packetReceiver, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Releases the `IAudioEncodedFrameReceiver` object. @@ -702,7 +709,7 @@ class IRemoteAudioTrack : public IAudioTrack { - 0: Success. - < 0: Failure. */ - virtual int setRemoteVoicePosition(float pan, float gain) = 0; + virtual int setRemoteVoicePosition(float pan, float gain, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** set percentage of audio acceleration during poor network @@ -717,7 +724,7 @@ class IRemoteAudioTrack : public IAudioTrack { - 0: Success. - < 0: Failure. */ - virtual int adjustAudioAcceleration(int percentage) = 0; + virtual int adjustAudioAcceleration(int percentage, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** set percentage of audio deceleration during poor network @@ -732,7 +739,7 @@ class IRemoteAudioTrack : public IAudioTrack { - 0: Success. - < 0: Failure. */ - virtual int adjustAudioDeceleration(int percentage) = 0; + virtual int adjustAudioDeceleration(int percentage, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** enable spatial audio @@ -743,7 +750,7 @@ class IRemoteAudioTrack : public IAudioTrack { - 0: Success. - < 0: Failure. */ - virtual int enableSpatialAudio(bool enabled) = 0; + virtual int enableSpatialAudio(bool enabled, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** Sets remote user parameters for spatial audio @@ -753,7 +760,7 @@ class IRemoteAudioTrack : public IAudioTrack { - 0: Success. - < 0: Failure. */ - virtual int setRemoteUserSpatialAudioParams(const agora::SpatialAudioParams& params) = 0; + virtual int setRemoteUserSpatialAudioParams(const agora::SpatialAudioParams& params, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; }; } // namespace rtc diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraCameraCapturer.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraCameraCapturer.h index 4101e9e07..09da1d422 100644 --- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraCameraCapturer.h +++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraCameraCapturer.h @@ -8,6 +8,7 @@ #include "AgoraBase.h" #include "AgoraRefPtr.h" +#include namespace agora { namespace rtc { @@ -120,7 +121,7 @@ class ICameraCapturer : public RefCountInterface { * - 0: Success. * - < 0: Failure. */ - virtual int setCameraSource(CAMERA_SOURCE source) = 0; + virtual int setCameraSource(CAMERA_SOURCE source, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Gets the camera source. * @@ -136,7 +137,7 @@ class ICameraCapturer : public RefCountInterface { * @note * This method applies to Android and iOS only. */ - virtual void switchCamera() = 0; + virtual int switchCamera(ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Returns whether zooming is supported by the current device. * @note @@ -160,7 +161,7 @@ class ICameraCapturer : public RefCountInterface { * - 0: Success. * - < 0: Failure. */ - virtual int32_t setCameraZoom(float zoomValue) = 0; + virtual int32_t setCameraZoom(float zoomValue, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Gets the max zooming factor of the device. * @@ -191,7 +192,7 @@ class ICameraCapturer : public RefCountInterface { * - 0: Success. * - < 0: Failure. */ - virtual int32_t setCameraFocus(float x, float y) = 0; + virtual int32_t setCameraFocus(float x, float y, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Returns whether auto face focus is supported by the current device. * @note @@ -213,7 +214,7 @@ class ICameraCapturer : public RefCountInterface { * - 0: Success. * - < 0: Failure. */ - virtual int32_t setCameraAutoFaceFocus(bool enable) = 0; + virtual int32_t setCameraAutoFaceFocus(bool enable, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Enables or disables auto face detection. * @note @@ -224,7 +225,7 @@ class ICameraCapturer : public RefCountInterface { * - 0: Success. * - < 0: Failure. */ - virtual int32_t enableFaceDetection(bool enable) = 0; + virtual int32_t enableFaceDetection(bool enable, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Checks whether the camera face detect is supported. @@ -273,7 +274,7 @@ class ICameraCapturer : public RefCountInterface { * - 0: Success * - < 0: Failure */ - virtual int setCameraTorchOn(bool isOn) = 0; + virtual int setCameraTorchOn(bool on, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** Checks whether the camera exposure function is supported. * @@ -303,7 +304,7 @@ class ICameraCapturer : public RefCountInterface { *
  • < 0: Failure.
  • * */ - virtual int setCameraExposurePosition(float positionXinView, float positionYinView) = 0; + virtual int setCameraExposurePosition(float positionXinView, float positionYinView, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Returns whether exposure value adjusting is supported by the current device. @@ -329,7 +330,7 @@ class ICameraCapturer : public RefCountInterface { * - 0: Success. * - < 0: Failure. */ - virtual int setCameraExposureFactor(float value) = 0; + virtual int setCameraExposureFactor(float value, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; #if (defined(__APPLE__) && TARGET_OS_IOS) /** @@ -343,7 +344,7 @@ class ICameraCapturer : public RefCountInterface { * - 0: Success. * - < 0: Failure. */ - virtual bool enableMultiCamera(bool enable) = 0; + virtual bool enableMultiCamera(bool enable, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Checks whether the camera auto exposure function is supported. * @@ -367,7 +368,7 @@ class ICameraCapturer : public RefCountInterface { *
  • < 0: Failure.
  • * */ - virtual int setCameraAutoExposureFaceModeEnabled(bool enabled) = 0; + virtual int setCameraAutoExposureFaceModeEnabled(bool enabled, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; #endif #elif defined(_WIN32) || (defined(__linux__) && !defined(__ANDROID__)) || \ @@ -413,7 +414,7 @@ class ICameraCapturer : public RefCountInterface { * Set the device orientation of the capture device * @param VIDEO_ORIENTATION orientaion of the device 0(by default), 90, 180, 270 */ - virtual void setDeviceOrientation(VIDEO_ORIENTATION orientation) = 0; + virtual int setDeviceOrientation(VIDEO_ORIENTATION orientation, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Sets the format of the video captured by the camera. @@ -422,7 +423,7 @@ class ICameraCapturer : public RefCountInterface { * * @param capture_format The reference to the video format: VideoFormat. */ - virtual void setCaptureFormat(const VideoFormat& capture_format) = 0; + virtual int setCaptureFormat(const VideoFormat& capture_format, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Gets the format of the video captured by the camera. * @return @@ -434,7 +435,7 @@ class ICameraCapturer : public RefCountInterface { * * @param observer Instance of the capture observer. */ - virtual int registerCameraObserver(ICameraCaptureObserver* observer) = 0; + virtual int registerCameraObserver(ICameraCaptureObserver* observer, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Unregisters the camera observer. * diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraDataChannel.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraDataChannel.h index 02b4983f8..a79b2c79e 100644 --- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraDataChannel.h +++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraDataChannel.h @@ -9,6 +9,7 @@ #include "AgoraRefPtr.h" #include "AgoraBase.h" +#include namespace agora { /** @@ -36,10 +37,16 @@ struct DataChannelConfig { int compressionLength; // optional Optional channelId; // 0~7 + + /** + * The priority + */ + int32_t priority; DataChannelConfig() : syncWithMedia(false), ordered(false), - compressionLength(0) {} + compressionLength(0), + priority(-1) {} }; /** @@ -85,7 +92,7 @@ class ILocalDataChannel : public RefCountInterface { * - 0: Success. * - < 0: Failure. */ - virtual int sendDataPacket(const char* packet, size_t length) = 0; + virtual int sendDataPacket(const char* packet, size_t length, uint64_t capture_time_ms, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Send meta data to this data channel before publishing. * @@ -95,7 +102,7 @@ class ILocalDataChannel : public RefCountInterface { * - 0: Success. * - < 0: Failure. */ - virtual int setMetaData(const char* metaData, size_t length) = 0; + virtual int setMetaData(const char* metaData, size_t length, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * return configured channel id diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraExtensionControl.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraExtensionControl.h index 5b27ffe99..da0c708df 100644 --- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraExtensionControl.h +++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraExtensionControl.h @@ -9,7 +9,6 @@ #pragma once // NOLINT(build/header_guard) #include "AgoraBase.h" #include "AgoraRefPtr.h" -#include "AgoraRefCountedObject.h" #include "IAgoraLog.h" #include "NGIAgoraVideoFrame.h" #include "NGIAgoraExtensionProvider.h" @@ -50,7 +49,7 @@ class IExtensionControl { * you can still call this method to perform an immediate memory recycle. * @param type Frame type to be recycled. */ - virtual void recycleVideoCache() = 0; + virtual int recycleVideoCache() = 0; /** * This method dumps the content of the video frame to the specified file. 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 3f6e1d2cc..8a9d885bb 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 @@ -11,6 +11,7 @@ #include #include "AgoraBase.h" #include "AgoraOptional.h" +#include namespace agora { namespace media { @@ -279,7 +280,7 @@ class ILocalUser { * as `role`, the connection fails with the \ref IRtcConnectionObserver::onConnectionFailure "onConnectionFailure" callback. * @param role The role of the user. See \ref rtc::CLIENT_ROLE_TYPE "CLIENT_ROLE_TYPE". */ - virtual void setUserRole(rtc::CLIENT_ROLE_TYPE role) = 0; + virtual int setUserRole(rtc::CLIENT_ROLE_TYPE role, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Gets the role of the user. @@ -288,8 +289,14 @@ class ILocalUser { */ virtual CLIENT_ROLE_TYPE getUserRole() = 0; - - virtual void setAudienceLatencyLevel(AUDIENCE_LATENCY_LEVEL_TYPE level) = 0; + /** + * Sets the latency level of an audience member. + * + * @note + * @param level The latency level of an audience member in interactive live streaming. See AUDIENCE_LATENCY_LEVEL_TYPE. + * @param role The user role determined by the config. If it's -1, it means there is no configured role. + */ + virtual int setAudienceLatencyLevel(AUDIENCE_LATENCY_LEVEL_TYPE level, int role, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; virtual AUDIENCE_LATENCY_LEVEL_TYPE getAudienceLatencyLevel() = 0; @@ -303,7 +310,7 @@ class ILocalUser { * - 0: Success. * - < 0: Failure. */ - virtual int setAudioEncoderConfiguration(const rtc::AudioEncoderConfiguration& config) = 0; + virtual int setAudioEncoderConfiguration(const rtc::AudioEncoderConfiguration& config, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Sets the audio parameters and application scenarios. @@ -314,7 +321,7 @@ class ILocalUser { * - 0: Success. * - < 0: Failure. */ - virtual int setAudioScenario(AUDIO_SCENARIO_TYPE scenario) = 0; + virtual int setAudioScenario(AUDIO_SCENARIO_TYPE scenario, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * You can call this method to set the expected video scenario. @@ -326,7 +333,22 @@ class ILocalUser { * - 0: Success. * - < 0: Failure. */ - virtual int setVideoScenario(VIDEO_APPLICATION_SCENARIO_TYPE scenarioType) = 0; + virtual int setVideoScenario(VIDEO_APPLICATION_SCENARIO_TYPE scenarioType, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; + + /** + * Sets the Video qoe preference. + * + * You can call this method to set the expected QoE Preference. + * The SDK will optimize the video experience for each preference you set. + * + * + * @param qoePreference The qoe preference type. See #VIDEO_QOE_PREFERENCE_TYPE. + * + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int setVideoQoEPreference(VIDEO_QOE_PREFERENCE_TYPE qoePreference, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Gets the detailed statistics of the local audio. @@ -349,7 +371,7 @@ class ILocalUser { * - < 0: Failure. * - -5(ERR_REFUSED), if the role of the local user is not broadcaster. */ - virtual int publishAudio(agora_refptr audioTrack) = 0; + virtual int publishAudio(agora_refptr audioTrack, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Stops publishing the local audio track to the channel. @@ -359,7 +381,7 @@ class ILocalUser { * - 0: Success. * - < 0: Failure. */ - virtual int unpublishAudio(agora_refptr audioTrack) = 0; + virtual int unpublishAudio(agora_refptr audioTrack, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Publishes a local video track to the channel. @@ -369,7 +391,7 @@ class ILocalUser { * - 0: Success. * - < 0: Failure. */ - virtual int publishVideo(agora_refptr videoTrack) = 0; + virtual int publishVideo(agora_refptr videoTrack, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Stops publishing the local video track to the channel. @@ -379,7 +401,7 @@ class ILocalUser { * - 0: Success. * - < 0: Failure. */ - virtual int unpublishVideo(agora_refptr videoTrack) = 0; + virtual int unpublishVideo(agora_refptr videoTrack, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Subscribes to the audio of a specified remote user in channel. @@ -390,7 +412,7 @@ class ILocalUser { * - < 0: Failure. * - -2(ERR_INVALID_ARGUMENT), if no such user exists or `userId` is invalid. */ - virtual int subscribeAudio(user_id_t userId) = 0; + virtual int subscribeAudio(user_id_t userId, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Subscribes to the audio of all remote users in the channel. @@ -401,7 +423,7 @@ class ILocalUser { * - 0: Success. * - < 0: Failure. */ - virtual int subscribeAllAudio() = 0; + virtual int subscribeAllAudio(ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Stops subscribing to the audio of a specified remote user in the channel. @@ -412,7 +434,7 @@ class ILocalUser { * - < 0: Failure. * - -2(ERR_INVALID_ARGUMENT), if no such user exists or `userId` is invalid. */ - virtual int unsubscribeAudio(user_id_t userId) = 0; + virtual int unsubscribeAudio(user_id_t userId, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Stops subscribing to the audio of all remote users in the channel. @@ -424,7 +446,7 @@ class ILocalUser { * - 0: Success. * - < 0: Failure. */ - virtual int unsubscribeAllAudio() = 0; + virtual int unsubscribeAllAudio(ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Adjusts the playback signal volume. @@ -436,7 +458,7 @@ class ILocalUser { * - 0: Success. * - < 0: Failure. */ - virtual int adjustPlaybackSignalVolume(int volume) = 0; + virtual int adjustPlaybackSignalVolume(int volume, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Gets the current playback signal volume. @@ -467,7 +489,7 @@ class ILocalUser { * - 0: Success. * - < 0: Failure. */ - virtual int adjustUserPlaybackSignalVolume(user_id_t userId, int volume) = 0; + virtual int adjustUserPlaybackSignalVolume(user_id_t userId, int volume, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Gets the current playback signal volume of specified user. @@ -491,7 +513,7 @@ class ILocalUser { - 0: Success. - < 0: Failure. */ - virtual int enableSoundPositionIndication(bool enabled) = 0; + virtual int enableSoundPositionIndication(bool enabled, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** Sets the sound position and gain of a remote user. @@ -513,7 +535,7 @@ class ILocalUser { - 0: Success. - < 0: Failure. */ - virtual int setRemoteVoicePosition(user_id_t userId, double pan, double gain) = 0; + virtual int setRemoteVoicePosition(user_id_t userId, double pan, double gain, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** enable spatial audio @@ -524,7 +546,7 @@ class ILocalUser { - 0: Success. - < 0: Failure. */ - virtual int enableSpatialAudio(bool enabled) = 0; + virtual int enableSpatialAudio(bool enabled, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** Sets remote user parameters for spatial audio @@ -535,7 +557,7 @@ class ILocalUser { - 0: Success. - < 0: Failure. */ - virtual int setRemoteUserSpatialAudioParams(user_id_t userId, const agora::SpatialAudioParams& param) = 0; + virtual int setRemoteUserSpatialAudioParams(user_id_t userId, const agora::SpatialAudioParams& param, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Sets the audio frame parameters for the \ref agora::media::IAudioFrameObserver::onPlaybackAudioFrame @@ -556,7 +578,7 @@ class ILocalUser { virtual int setPlaybackAudioFrameParameters(size_t numberOfChannels, uint32_t sampleRateHz, RAW_AUDIO_FRAME_OP_MODE_TYPE mode = RAW_AUDIO_FRAME_OP_MODE_READ_ONLY, - int samplesPerCall = 0) = 0; + int samplesPerCall = 0, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Sets the audio frame parameters for the \ref agora::media::IAudioFrameObserver::onRecordAudioFrame * "onRecordAudioFrame" callback. @@ -576,7 +598,7 @@ class ILocalUser { virtual int setRecordingAudioFrameParameters(size_t numberOfChannels, uint32_t sampleRateHz, RAW_AUDIO_FRAME_OP_MODE_TYPE mode = RAW_AUDIO_FRAME_OP_MODE_READ_ONLY, - int samplesPerCall = 0) = 0; + int samplesPerCall = 0, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Sets the audio frame parameters for the \ref agora::media::IAudioFrameObserver::onMixedAudioFrame * "onMixedAudioFrame" callback. @@ -593,7 +615,7 @@ class ILocalUser { */ virtual int setMixedAudioFrameParameters(size_t numberOfChannels, uint32_t sampleRateHz, - int samplesPerCall = 0) = 0; + int samplesPerCall = 0, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Sets the audio frame parameters for the \ref agora::media::IAudioFrameObserver::onEarMonitoringAudioFrame @@ -617,7 +639,7 @@ class ILocalUser { size_t numberOfChannels, uint32_t sampleRateHz, RAW_AUDIO_FRAME_OP_MODE_TYPE mode = RAW_AUDIO_FRAME_OP_MODE_READ_ONLY, - int samplesPerCall = 0) = 0; + int samplesPerCall = 0, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Sets the audio frame parameters for the \ref agora::media::IAudioFrameObserver::onPlaybackAudioFrameBeforeMixing @@ -634,7 +656,7 @@ class ILocalUser { * - < 0: Failure. */ virtual int setPlaybackAudioFrameBeforeMixingParameters(size_t numberOfChannels, - uint32_t sampleRateHz) = 0; + uint32_t sampleRateHz, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Registers an audio frame observer. @@ -652,7 +674,7 @@ class ILocalUser { * - 0: Success. * - < 0: Failure. */ - virtual int registerAudioFrameObserver(agora::media::IAudioFrameObserverBase * observer) = 0; + virtual int registerAudioFrameObserver(agora::media::IAudioFrameObserverBase* observer, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Releases the audio frame observer. * @@ -661,7 +683,7 @@ class ILocalUser { * - 0: Success. * - < 0: Failure. */ - virtual int unregisterAudioFrameObserver(agora::media::IAudioFrameObserverBase * observer) = 0; + virtual int unregisterAudioFrameObserver(agora::media::IAudioFrameObserverBase* observer) = 0; /** * Enable the audio spectrum monitor. @@ -673,7 +695,7 @@ class ILocalUser { * - 0: Success. * - < 0: Failure. */ - virtual int enableAudioSpectrumMonitor(int intervalInMS = 100) = 0; + virtual int enableAudioSpectrumMonitor(int intervalInMS = 100, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Disalbe the audio spectrum monitor. * @@ -681,7 +703,7 @@ class ILocalUser { * - 0: Success. * - < 0: Failure. */ - virtual int disableAudioSpectrumMonitor() = 0; + virtual int disableAudioSpectrumMonitor(ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Registers an audio spectrum observer. @@ -697,7 +719,7 @@ class ILocalUser { * - 0: Success. * - < 0: Failure. */ - virtual int registerAudioSpectrumObserver(agora::media::IAudioSpectrumObserver * observer, void (*safeDeleter)(agora::media::IAudioSpectrumObserver*)) = 0; + virtual int registerAudioSpectrumObserver(agora::media::IAudioSpectrumObserver * observer, void (*safeDeleter)(agora::media::IAudioSpectrumObserver*), ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Releases the audio spectrum observer. * @@ -721,7 +743,7 @@ class ILocalUser { * - 0: Success. * - < 0: Failure. */ - virtual int registerLocalVideoEncodedFrameObserver(agora::media::IVideoEncodedFrameObserver* observer) = 0; + virtual int registerLocalVideoEncodedFrameObserver(agora::media::IVideoEncodedFrameObserver* observer, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Releases the \ref agora::media::IVideoEncodedFrameObserver "IVideoEncodedFrameObserver" object. * @param observer The pointer to the `IVideoEncodedFrameObserver` object. @@ -737,7 +759,7 @@ class ILocalUser { * - 0: Success. * - < 0: Failure. */ - virtual int forceNextIntraFrame() = 0; + virtual int forceNextIntraFrame(ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Registers an \ref agora::media::IVideoEncodedFrameObserver "IVideoEncodedFrameObserver" object. * @@ -750,7 +772,7 @@ class ILocalUser { * - 0: Success. * - < 0: Failure. */ - virtual int registerVideoEncodedFrameObserver(agora::media::IVideoEncodedFrameObserver* observer) = 0; + virtual int registerVideoEncodedFrameObserver(agora::media::IVideoEncodedFrameObserver* observer, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Releases the \ref agora::media::IVideoEncodedFrameObserver "IVideoEncodedFrameObserver" object. * @param observer The pointer to the `IVideoEncodedFrameObserver` object. @@ -772,7 +794,7 @@ class ILocalUser { * - 0: Success. * - < 0: Failure. */ - virtual int registerVideoFrameObserver(IVideoFrameObserver2* observer) = 0; + virtual int registerVideoFrameObserver(IVideoFrameObserver2* observer, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Releases the \ref agora::rtc::IVideoFrameObserver2 "IVideoFrameObserver2" object. * @param observer The pointer to the `IVideoFrameObserver2` object. @@ -783,9 +805,9 @@ class ILocalUser { virtual int unregisterVideoFrameObserver(IVideoFrameObserver2* observer) = 0; virtual int setVideoSubscriptionOptions(user_id_t userId, - const VideoSubscriptionOptions& options) = 0; + const VideoSubscriptionOptions& options, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; - virtual int setHighPriorityUserList(uid_t* vipList, int uidNum, int option) = 0; + virtual int setHighPriorityUserList(uid_t* vipList, int uidNum, int option, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; virtual int getHighPriorityUserList(std::vector& vipList, int& option) = 0; @@ -803,7 +825,7 @@ class ILocalUser { * - 0: Success. * - < 0: Failure. */ - virtual int setSubscribeAudioBlocklist(user_id_t* userList, int userNumber) = 0; + virtual int setSubscribeAudioBlocklist(user_id_t* userList, int userNumber, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Sets the allowlist of subscribe remote stream audio. @@ -821,7 +843,7 @@ class ILocalUser { * - 0: Success. * - < 0: Failure. */ - virtual int setSubscribeAudioAllowlist(user_id_t* userList, int userNumber) = 0; + virtual int setSubscribeAudioAllowlist(user_id_t* userList, int userNumber, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Sets the blocklist of subscribe remote stream video. @@ -837,7 +859,7 @@ class ILocalUser { * - 0: Success. * - < 0: Failure. */ - virtual int setSubscribeVideoBlocklist(user_id_t* userList, int userNumber) = 0; + virtual int setSubscribeVideoBlocklist(user_id_t* userList, int userNumber, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Sets the allowlist of subscribe remote stream video. @@ -855,7 +877,7 @@ class ILocalUser { * - 0: Success. * - < 0: Failure. */ - virtual int setSubscribeVideoAllowlist(user_id_t* userList, int userNumber) = 0; + virtual int setSubscribeVideoAllowlist(user_id_t* userList, int userNumber, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Subscribes to the video of a specified remote user in the channel. @@ -870,7 +892,7 @@ class ILocalUser { * - -2(ERR_INVALID_ARGUMENT), if `userId` is invalid. */ virtual int subscribeVideo(user_id_t userId, - const VideoSubscriptionOptions &subscriptionOptions) = 0; + const VideoSubscriptionOptions &subscriptionOptions, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Subscribes to the video of all remote users in the channel. @@ -882,7 +904,7 @@ class ILocalUser { * - 0: Success. * - < 0: Failure. */ - virtual int subscribeAllVideo(const VideoSubscriptionOptions &subscriptionOptions) = 0; + virtual int subscribeAllVideo(const VideoSubscriptionOptions &subscriptionOptions, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Stops subscribing to the video of a specified remote user in the channel. @@ -893,7 +915,7 @@ class ILocalUser { * - < 0: Failure. * - -2(ERR_INVALID_ARGUMENT), if `userId` is invalid. */ - virtual int unsubscribeVideo(user_id_t userId) = 0; + virtual int unsubscribeVideo(user_id_t userId, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Stops subscribing to the video of all remote users in the channel. @@ -905,7 +927,7 @@ class ILocalUser { * - 0: Success. * - < 0: Failure. */ - virtual int unsubscribeAllVideo() = 0; + virtual int unsubscribeAllVideo(ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Sets the time interval and the volume smoothing factor of the \ref agora::rtc::ILocalUserObserver::onAudioVolumeIndication "onAudioVolumeIndication" callback. @@ -926,7 +948,7 @@ class ILocalUser { * - < 0: Failure. * - -2(ERR_INVALID_ARGUMENT), if `intervalInMS` or `smooth` is out of range. */ - virtual int setAudioVolumeIndicationParameters(int intervalInMS, int smooth, bool reportVad) = 0; + virtual int setAudioVolumeIndicationParameters(int intervalInMS, int smooth, bool reportVad, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Registers a local user observer object. @@ -941,7 +963,7 @@ class ILocalUser { */ virtual int registerLocalUserObserver( ILocalUserObserver* observer, - void(*safeDeleter)(ILocalUserObserver*) = NULL) = 0; + void(*safeDeleter)(ILocalUserObserver*) = NULL, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Releases the \ref agora::rtc::ILocalUserObserver "ILocalUserObserver" object. @@ -974,7 +996,7 @@ class ILocalUser { * - 0: Success. * - < 0: Failure. */ - virtual int registerMediaControlPacketReceiver(IMediaControlPacketReceiver* ctrlPacketReceiver) = 0; + virtual int registerMediaControlPacketReceiver(IMediaControlPacketReceiver* ctrlPacketReceiver, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Releases the media control packet receiver. @@ -995,7 +1017,7 @@ class ILocalUser { * - 0: Success. * - < 0: Failure. */ - virtual int sendIntraRequest(user_id_t userId) = 0; + virtual int sendIntraRequest(user_id_t userId, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Set local audio filterable by topn @@ -1008,7 +1030,7 @@ class ILocalUser { * - < 0: Failure. */ - virtual int setAudioFilterable(bool filterable) = 0; + virtual int setAudioFilterable(bool filterable, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Enable / Disable specified audio filter @@ -1019,7 +1041,7 @@ class ILocalUser { * - 0: success * - <0: failure */ - virtual int enableRemoteAudioTrackFilter(user_id_t userId, const char* id, bool enable) = 0; + virtual int enableRemoteAudioTrackFilter(user_id_t userId, const char* id, bool enable, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * set the properties of the specified audio filter @@ -1031,7 +1053,7 @@ class ILocalUser { * - 0: success * - <0: failure */ - virtual int setRemoteAudioTrackFilterProperty(user_id_t userId, const char* id, const char* key, const char* jsonValue) = 0; + virtual int setRemoteAudioTrackFilterProperty(user_id_t userId, const char* id, const char* key, const char* jsonValue, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * get the properties of the specified audio filter @@ -1053,7 +1075,7 @@ class ILocalUser { * - 0: Success. * - < 0: Failure. */ - virtual int publishDataChannel(agora_refptr channel) = 0; + virtual int publishDataChannel(agora_refptr channel, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Stops publishing the data channel to the channel. * @@ -1062,7 +1084,7 @@ class ILocalUser { * - 0: Success. * - < 0: Failure. */ - virtual int unpublishDataChannel(agora_refptr channel) = 0; + virtual int unpublishDataChannel(agora_refptr channel, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Subscribes to a specified data channel of a specified remote user in channel. * @@ -1072,7 +1094,7 @@ class ILocalUser { * - 0: Success. * - < 0: Failure. */ - virtual int subscribeDataChannel(user_id_t userId, int channelId) = 0; + virtual int subscribeDataChannel(user_id_t userId, int channelId, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Stops subscribing to the data channel of a specified remote user in the channel. * @@ -1083,8 +1105,7 @@ class ILocalUser { * - < 0: Failure. * - -2(ERR_INVALID_ARGUMENT), if no such user exists or `userId` is invalid. */ - - virtual int unsubscribeDataChannel(user_id_t userId, int channelId) = 0; + virtual int unsubscribeDataChannel(user_id_t userId, int channelId, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Registers an data channel observer. * @@ -1095,7 +1116,7 @@ class ILocalUser { * - 0: Success. * - < 0: Failure. */ - virtual int registerDataChannelObserver(IDataChannelObserver * observer) = 0; + virtual int registerDataChannelObserver(IDataChannelObserver * observer, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Releases the data channel observer. * @@ -1116,7 +1137,27 @@ class ILocalUser { * - 0: success * - <0: failure */ - virtual int SetAudioNsMode(bool NsEnable, NS_MODE NsMode, NS_LEVEL NsLevel, NS_DELAY NsDelay) = 0; + virtual int SetAudioNsMode(bool NsEnable, NS_MODE NsMode, NS_LEVEL NsLevel, NS_DELAY NsDelay, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; + /** + * enable the mix track that mix special track + * + * @param track The special mixed audio track. + * @param enalble Action of start mixing this user's audio. + * @param MixLocal Mix publish stream. + * @param MixRemote Mix remote stream. + * @return + * - 0: success + * - <0: failure + */ + virtual int EnableLocalMixedAudioTrack(agora_refptr& track, bool enable, bool MixLocal, bool MixRemote, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; + /** + * Trigger data channel update callback with all data channel infos. + * + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int takeDataChannelSnapshot(ahpl_ref_t ares = AHPL_REF_INVALID) = 0; }; /** @@ -1240,11 +1281,11 @@ class ILocalUserObserver { * * @param videoTrack The pointer to `ILocalVideoTrack`. * @param state The state of the local video track. - * @param errorCode The error information. + * @param reason The error information. */ virtual void onLocalVideoTrackStateChanged(agora_refptr videoTrack, LOCAL_VIDEO_STREAM_STATE state, - LOCAL_VIDEO_STREAM_ERROR errorCode) = 0; + LOCAL_VIDEO_STREAM_REASON reason) = 0; /** * Reports the statistics of a local video track. @@ -1265,7 +1306,7 @@ class ILocalUserObserver { * @param trackInfo The information of the remote video track. * @param videoTrack The pointer to `IRemoteVideoTrack`. */ - virtual void onUserVideoTrackSubscribed(user_id_t userId, VideoTrackInfo trackInfo, + virtual void onUserVideoTrackSubscribed(user_id_t userId, const VideoTrackInfo& trackInfo, agora_refptr videoTrack) = 0; /** diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraMediaNode.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraMediaNode.h index 2ac47728e..f74fb00ed 100644 --- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraMediaNode.h +++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraMediaNode.h @@ -4,6 +4,7 @@ #include "IAgoraLog.h" #include "NGIAgoraVideoFrame.h" #include "AgoraExtensionVersion.h" +#include #ifndef OPTIONAL_PROCESSRESULT_SPECIFIER #if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) @@ -299,16 +300,14 @@ class IExtensionVideoFilter : public IVideoFilter { }; /** - * @brief SDK will invoke this API first to get the filter's requested process mode @ref ProcessMode and threading model + * @brief SDK will invoke this API first to get the filter's requested process mode @ref ProcessMode * @param mode [out] filter assign its desired the process mode @ref ProcessMode - * @param independent_thread [out] filter assign its desired threading model. When this boolean is set "true", an - * indepent thread will be assigned to the current filter and all invocations from SDK afterwards are ensured to - * happen on that fixed thread. If this boolean flag is set "false", the filter will re-use the thread of the SDK's - * data path. All invocations from SDK afterwards are also ensured to be on the same thread, however that thread is shared. + * @param independent_thread deprecated. SDK will ignore this parameter. * @note If the filter implementation is not thread sensitive, we recommend to set the boolean to "false" to reduce thread context * switching. */ virtual void getProcessMode(ProcessMode& mode, bool& independent_thread) = 0; + /** * @brief SDK will invoke this API before feeding video frame data to the filter. Filter can perform its initialization/preparation job * in this step. @@ -466,7 +465,7 @@ class IAudioPcmDataSender : public RefCountInterface { const size_t samples_per_channel, // for 10ms Data, number_of_samples * 100 = sample_rate const agora::rtc::BYTES_PER_SAMPLE bytes_per_sample, // 2 const size_t number_of_channels, - const uint32_t sample_rate) = 0; // sample_rate > 8000) + const uint32_t sample_rate, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; // sample_rate > 8000) protected: ~IAudioPcmDataSender() {} @@ -494,7 +493,7 @@ class IAudioEncodedFrameSender : public RefCountInterface { * - `false`: Failure. */ virtual bool sendEncodedAudioFrame(const uint8_t* payload_data, size_t payload_size, - const EncodedAudioFrameInfo& audioFrameInfo) = 0; + const EncodedAudioFrameInfo& audioFrameInfo, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; protected: ~IAudioEncodedFrameSender() {} @@ -577,7 +576,7 @@ class IMediaPacketSender : public RefCountInterface { * - `false`: Failure. */ virtual int sendMediaPacket(const uint8_t *packet, size_t length, - const media::base::PacketOptions &options) = 0; + const media::base::PacketOptions &options, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; protected: ~IMediaPacketSender() {} }; @@ -605,7 +604,7 @@ class IMediaControlPacketSender { */ virtual int sendPeerMediaControlPacket(media::base::user_id_t userId, const uint8_t *packet, - size_t length) = 0; + size_t length, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Sends the media transport control packet to all users. @@ -617,7 +616,7 @@ class IMediaControlPacketSender { * - `true`: Success. * - `false`: Failure. */ - virtual int sendBroadcastMediaControlPacket(const uint8_t *packet, size_t length) = 0; + virtual int sendBroadcastMediaControlPacket(const uint8_t *packet, size_t length, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; virtual ~IMediaControlPacketSender() {} }; @@ -659,7 +658,7 @@ class IVideoFrameSender : public RefCountInterface { * - 0: Success. * - < 0: Failure. */ - virtual int sendVideoFrame(const media::base::ExternalVideoFrame& videoFrame) = 0; + virtual int sendVideoFrame(const media::base::ExternalVideoFrame& videoFrame, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; protected: ~IVideoFrameSender() {} @@ -686,7 +685,7 @@ class IVideoEncodedImageSender : public RefCountInterface { * - `false`: Failure. */ virtual bool sendEncodedVideoImage(const uint8_t* imageBuffer, size_t length, - const EncodedVideoFrameInfo& videoEncodedFrameInfo) = 0; + const EncodedVideoFrameInfo& videoEncodedFrameInfo, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; protected: ~IVideoEncodedImageSender() {} @@ -780,7 +779,7 @@ class IVideoRenderer : public IVideoSinkBase { * - 0: Success. * - < 0: Failure. */ - virtual int setRenderMode(media::base::RENDER_MODE_TYPE renderMode) = 0; + virtual int setRenderMode(media::base::RENDER_MODE_TYPE renderMode, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Sets the render mode of the view. * @param view the view to set render mode. @@ -789,7 +788,7 @@ class IVideoRenderer : public IVideoSinkBase { * - 0: Success. * - < 0: Failure. */ - virtual int setRenderMode(void* view, media::base::RENDER_MODE_TYPE renderMode) = 0; + virtual int setRenderMode(void* view, media::base::RENDER_MODE_TYPE renderMode, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Sets whether to mirror the video. * @param mirror Whether to mirror the video: @@ -799,7 +798,7 @@ class IVideoRenderer : public IVideoSinkBase { * - 0: Success. * - < 0: Failure. */ - virtual int setMirror(bool mirror) = 0; + virtual int setMirror(bool mirror, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Sets whether to mirror the video. * @param view the view to set mirror mode. @@ -810,7 +809,7 @@ class IVideoRenderer : public IVideoSinkBase { * - 0: Success. * - < 0: Failure. */ - virtual int setMirror(void* view, bool mirror) = 0; + virtual int setMirror(void* view, bool mirror, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Sets the video display window. * @param view The pointer to the video display window. @@ -818,7 +817,7 @@ class IVideoRenderer : public IVideoSinkBase { * - 0: Success. * - < 0: Failure. */ - virtual int setView(void* view) = 0; + virtual int setView(void* view, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Sets the video display window. * @param view The pointer to the video display window. @@ -827,14 +826,14 @@ class IVideoRenderer : public IVideoSinkBase { * - 0: Success. * - < 0: Failure. */ - virtual int addView(void* view, const Rectangle& cropArea) = 0; + virtual int addView(void* view, const Rectangle& cropArea, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Stops rendering the video view on the window. * @return * - 0: Success. * - < 0: Failure. */ - virtual int unsetView() = 0; + virtual int unsetView(ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * remove rendering the video view on the window. * @return @@ -853,8 +852,8 @@ class IVideoTrack; class IVideoFrameTransceiver : public RefCountInterface { public: virtual int getTranscodingDelayMs() = 0; - virtual int addVideoTrack(agora_refptr track) = 0; - virtual int removeVideoTrack(agora_refptr track) = 0; + virtual int addVideoTrack(agora_refptr track, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; + virtual int removeVideoTrack(agora_refptr track, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; }; } diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraMediaNodeFactory.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraMediaNodeFactory.h index 5a53ce562..fb57b852e 100644 --- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraMediaNodeFactory.h +++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraMediaNodeFactory.h @@ -7,6 +7,7 @@ #pragma once // NOLINT(build/header_guard) #include "AgoraBase.h" +#include namespace agora { namespace rtc { @@ -57,17 +58,6 @@ class IMediaNodeFactory : public RefCountInterface { */ virtual agora_refptr createAudioEncodedFrameSender() = 0; - /** - * Creates a remote audio mixer source object and returns the pointer. - * - * @param type The type of audio mixer source you want to create. - * - * @return - * - The pointer to \ref rtc::IRemoteAudioMixerSource "IRemoteAudioMixerSource", if the method call succeeds. - * - A null pointer, if the method call fails. - */ - virtual agora_refptr createRemoteAudioMixerSource() = 0; - /** * Creates a camera capturer. * @@ -80,6 +70,7 @@ class IMediaNodeFactory : public RefCountInterface { */ virtual agora_refptr createCameraCapturer() = 0; +#if !defined(__ANDROID__) && !(defined(__APPLE__) && TARGET_OS_IPHONE) /** * Creates a screen capturer. * @@ -91,6 +82,7 @@ class IMediaNodeFactory : public RefCountInterface { * - A null pointer: Failure. */ virtual agora_refptr createScreenCapturer() = 0; +#endif /** * Creates a video mixer. diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraRemoteAudioMixerSource.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraRemoteAudioMixerSource.h index e4710711f..12aa0d80d 100644 --- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraRemoteAudioMixerSource.h +++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraRemoteAudioMixerSource.h @@ -7,6 +7,7 @@ #pragma once #include "AgoraRefPtr.h" +#include namespace agora { namespace rtc { @@ -26,13 +27,13 @@ class IRemoteAudioMixerSource : public RefCountInterface { * Add a audio track for mixing. Automatically starts mixing if add audio track * @param track The instance of the audio track that you want mixer to receive its audio stream. */ - virtual int addAudioTrack(agora_refptr track) = 0; + virtual int addAudioTrack(agora_refptr track, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Remove a audio track for mixing. Automatically stops the mixed stream if all audio tracks are removed * @param track The instance of the audio track that you want to remove from the mixer. */ - virtual int removeAudioTrack(agora_refptr track) = 0; + virtual int removeAudioTrack(agora_refptr track, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Gets the delay time for mix. 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 886b2a257..4085bd1d6 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 @@ -9,6 +9,7 @@ #include "AgoraBase.h" #include "time_utils.h" +#include namespace agora { namespace rtc { @@ -148,6 +149,11 @@ struct RtcConnectionConfiguration { */ bool isInteractiveAudience; + /** + * Indicates data channel only. + */ + bool isDataChannelOnly; + RtcConnectionConfiguration() : autoSubscribeAudio(true), autoSubscribeVideo(true), @@ -160,7 +166,8 @@ struct RtcConnectionConfiguration { audioRecvEncodedFrame(false), audioRecvMediaPacket(false), videoRecvMediaPacket(false), - isInteractiveAudience(false) {} + isInteractiveAudience(false), + isDataChannelOnly(false) {} }; /** @@ -205,7 +212,7 @@ class IRtcConnection : public RefCountInterface { * - -2(ERR_INVALID_ARGUMENT): The argument that you pass is invalid. * - -8(ERR_INVALID_STATE): The current connection state is not CONNECTION_STATE_DISCONNECTED(1). */ - virtual int connect(const char* token, const char* channelId, user_id_t userId) = 0; + virtual int connect(const char* token, const char* channelId, user_id_t userId, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Connects to an Agora channel. @@ -218,7 +225,7 @@ class IRtcConnection : public RefCountInterface { * The SDK also triggers `onConnected` or `onDisconnected` to notify you of the state change. * @param settings The settings of connecting. */ - virtual int connect(const TConnectSettings& settings) = 0; + virtual int connect(const TConnectSettings& settings, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Disconnects from the Agora channel. @@ -231,7 +238,7 @@ class IRtcConnection : public RefCountInterface { * - 0: Success. * - < 0: Failure. */ - virtual int disconnect() = 0; + virtual int disconnect(ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Starts the last-mile network probe test. @@ -260,7 +267,7 @@ class IRtcConnection : public RefCountInterface { * - 0: Success. * - < 0: Failure. */ - virtual int startLastmileProbeTest(const LastmileProbeConfig& config) = 0; + virtual int startLastmileProbeTest(const LastmileProbeConfig& config, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Stops the last-mile network probe test. @@ -268,7 +275,7 @@ class IRtcConnection : public RefCountInterface { * - 0: Success. * - < 0: Failure. */ - virtual int stopLastmileProbeTest() = 0; + virtual int stopLastmileProbeTest(ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Renews the token. @@ -279,7 +286,7 @@ class IRtcConnection : public RefCountInterface { * * @param token The pointer to the new token. */ - virtual int renewToken(const char* token) = 0; + virtual int renewToken(const char* token, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Gets the connection information. @@ -333,7 +340,7 @@ class IRtcConnection : public RefCountInterface { * - 0: Success. * - < 0: Failure. */ - virtual int registerObserver(IRtcConnectionObserver* observer, void(*safeDeleter)(IRtcConnectionObserver*) = NULL) = 0; + virtual int registerObserver(IRtcConnectionObserver* observer, void(*safeDeleter)(IRtcConnectionObserver*) = NULL, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Releases the registered IRtcConnectionObserver object. @@ -354,7 +361,7 @@ class IRtcConnection : public RefCountInterface { * - 0: Success. * - < 0: Failure. */ - virtual int registerNetworkObserver(INetworkObserver* observer, void(*safeDeleter)(INetworkObserver*) = NULL) = 0; + virtual int registerNetworkObserver(INetworkObserver* observer, void(*safeDeleter)(INetworkObserver*) = NULL, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Releases the registered INetworkObserver object. @@ -430,7 +437,7 @@ class IRtcConnection : public RefCountInterface { * - 0: Success. * - < 0: Failure. */ - virtual int sendStreamMessage(int streamId, const char* data, size_t length) = 0; + virtual int sendStreamMessage(int streamId, const char* data, size_t length, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** Enables/Disables the built-in encryption. * @@ -450,7 +457,7 @@ class IRtcConnection : public RefCountInterface { * - 0: Success. * - < 0: Failure. */ - virtual int enableEncryption(bool enabled, const EncryptionConfig& config) = 0; + virtual int enableEncryption(bool enabled, const EncryptionConfig& config, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Reports a custom event to Agora. @@ -465,7 +472,7 @@ class IRtcConnection : public RefCountInterface { * - 0: Success. * - < 0: Failure. */ - virtual int sendCustomReportMessage(const char* id, const char* category, const char* event, const char* label, int value) = 0; + virtual int sendCustomReportMessage(const char* id, const char* category, const char* event, const char* label, int value, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** Gets the user information by user account, which is in string format. * * @param userAccount The user account of the user. @@ -685,8 +692,8 @@ class IRtcConnectionObserver { * @param height image height * @param errCode 0 is ok negative is error */ - virtual void onSnapshotTaken(uid_t uid, const char* filePath, int width, int height, int errCode) { - (void)uid; + virtual void onSnapshotTaken(user_id_t userId, const char* filePath, int width, int height, int errCode) { + (void)userId; (void)filePath; (void)width; (void)height; @@ -786,6 +793,15 @@ class IRtcConnectionObserver { (void)reason; } + /** + * Occurs when receive use rtm response. + * + * @param code The error code: + */ + virtual void onSetRtmFlagResult(int code) { + (void)code; + } + /** Occurs when the WIFI message need be sent to the user. * * @param reason The reason of notifying the user of a message. @@ -803,7 +819,7 @@ class IRtcConnectionObserver { * @param currentStats Instantaneous value of optimization effect. * @param averageStats Average value of cumulative optimization effect. */ - virtual void onWlAccStats(WlAccStats currentStats, WlAccStats averageStats) { + virtual void onWlAccStats(const WlAccStats& currentStats, const WlAccStats& averageStats) { (void)currentStats; (void)averageStats; } diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraRtmpConnection.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraRtmpConnection.h index 98bdfad9c..d0516cb6d 100644 --- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraRtmpConnection.h +++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraRtmpConnection.h @@ -9,6 +9,7 @@ #include "AgoraBase.h" #include "AgoraRefPtr.h" +#include namespace agora { namespace rtc { @@ -338,7 +339,7 @@ class IRtmpConnection : public RefCountInterface { * - ERR_INVALID_ARGUMENT: The passed in argument is invalid. * - ERR_INVALID_STATE: The current connection state is not STATE_DISCONNECTED(3). */ - virtual int connect(const char* url) = 0; + virtual int connect(const char* url, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Disconnects from the RTMP server. @@ -347,7 +348,7 @@ class IRtmpConnection : public RefCountInterface { * STATE_DISCONNECTED(4). You will be notified with the callback * \ref onDisconnected "onDisconnected". */ - virtual int disconnect() = 0; + virtual int disconnect(ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Gets the current connection information. @@ -375,7 +376,7 @@ class IRtmpConnection : public RefCountInterface { * - 0: Success. * - < 0: Failure. */ - virtual int registerObserver(IRtmpConnectionObserver* observer, void(*safeDeleter)(IRtmpConnectionObserver*) = NULL) = 0; + virtual int registerObserver(IRtmpConnectionObserver* observer, void(*safeDeleter)(IRtmpConnectionObserver*) = NULL, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Releases the registered IRtmpConnectionObserver object. diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraRtmpLocalUser.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraRtmpLocalUser.h index 22172b769..4b2531f47 100644 --- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraRtmpLocalUser.h +++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraRtmpLocalUser.h @@ -134,7 +134,7 @@ class IRtmpLocalUser { * - 0: Success. * - < 0: Failure. */ - virtual int setAudioStreamConfiguration(const RtmpStreamingAudioConfiguration& config) = 0; + virtual int setAudioStreamConfiguration(const RtmpStreamingAudioConfiguration& config, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Set the parameters of the video encoder when pushing the stream @@ -145,7 +145,7 @@ class IRtmpLocalUser { * - 0: Success. * - < 0: Failure. */ - virtual int setVideoStreamConfiguration(const RtmpStreamingVideoConfiguration& config) = 0; + virtual int setVideoStreamConfiguration(const RtmpStreamingVideoConfiguration& config, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Adjusts the audio volume for publishing. @@ -156,7 +156,7 @@ class IRtmpLocalUser { * - 0: Success. * - < 0: Failure. */ - virtual int adjustRecordingSignalVolume(int volume) = 0; + virtual int adjustRecordingSignalVolume(int volume, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Gets the current volume for publishing. @@ -168,18 +168,6 @@ class IRtmpLocalUser { */ virtual int getRecordingSignalVolume(int32_t* volume) = 0; - /** - * Set whether to enable local audio - * @param enabled Whether to enable local audio: - * - `true`: Enable local audio. - * - `false`: Disable local audio. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setAudioEnabled(bool enabled) = 0; - /** * Dynamically adjust the bit rate parameters of the video encoder in the push stream * @@ -194,7 +182,7 @@ class IRtmpLocalUser { * - 0: Success. * - < 0: Failure. */ - virtual void adjustVideoBitrate(VideoBitrateAdjustType type) = 0; + virtual int adjustVideoBitrate(VideoBitrateAdjustType type, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Set whether to enable local video @@ -207,7 +195,7 @@ class IRtmpLocalUser { * - 0: Success. * - < 0: Failure. */ - virtual int setVideoEnabled(bool enabled) = 0; + virtual int setVideoEnabled(bool enabled, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Publishes a local audio track to the RTMP connection. @@ -217,7 +205,7 @@ class IRtmpLocalUser { * - 0: Success. * - < 0: Failure. */ - virtual int publishAudio(agora_refptr audioTrack) = 0; + virtual int publishAudio(agora_refptr audioTrack, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Stops publishing the local audio track to the RTMP connection. @@ -227,29 +215,7 @@ class IRtmpLocalUser { * - 0: Success. * - < 0: Failure. */ - virtual int unpublishAudio(agora_refptr audioTrack) = 0; - - /** - * Publishes a media player local audio track to the RTMP connection. - * - * @param audioTrack The local audio track to be published: ILocalAudioTrack. - * @param playerId The player source ID. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int publishMediaPlayerAudio(agora_refptr audioTrack, int32_t playerId=0) = 0; - - /** - * Stops publishing the media player local audio track to the RTMP connection. - * - * @param audioTrack The local audio track that you want to stop publishing: ILocalAudioTrack. - * @param playerId The player source ID. - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int unpublishMediaPlayerAudio(agora_refptr audioTrack, int32_t playerId=0) = 0; + virtual int unpublishAudio(agora_refptr audioTrack, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Publishes a local video track to the RTMP connection. @@ -259,7 +225,7 @@ class IRtmpLocalUser { * - 0: Success. * - < 0: Failure. */ - virtual int publishVideo(agora_refptr videoTrack) = 0; + virtual int publishVideo(agora_refptr videoTrack, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Stops publishing the local video track to the RTMP connection. @@ -268,7 +234,7 @@ class IRtmpLocalUser { * - 0: Success. * - < 0: Failure. */ - virtual int unpublishVideo(agora_refptr videoTrack) = 0; + virtual int unpublishVideo(agora_refptr videoTrack, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Registers a RTMP user observer object. @@ -281,7 +247,7 @@ class IRtmpLocalUser { * - 0: Success. * - < 0: Failure. */ - virtual int registerRtmpUserObserver(IRtmpLocalUserObserver* observer, void(*safeDeleter)(IRtmpLocalUserObserver*) = NULL) = 0; + virtual int registerRtmpUserObserver(IRtmpLocalUserObserver* observer, void(*safeDeleter)(IRtmpLocalUserObserver*) = NULL, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Releases the IRtmpLocalUserObserver object previously registered using registerRtmpUserObserver(). @@ -291,7 +257,7 @@ class IRtmpLocalUser { * - 0: Success. * - < 0: Failure. */ - virtual int unregisteRtmpUserObserver(IRtmpLocalUserObserver* observer) = 0; + virtual int unregisterRtmpUserObserver(IRtmpLocalUserObserver* observer) = 0; /** * Registers an audio frame observer object. * @@ -301,7 +267,7 @@ class IRtmpLocalUser { * - 0: Success. * - < 0: Failure. */ - virtual int registerAudioFrameObserver(media::IAudioPcmFrameSink* observer) = 0; + virtual int registerAudioFrameObserver(media::IAudioPcmFrameSink* observer, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Unregisters an audio frame observer object. @@ -319,7 +285,7 @@ class IRtmpLocalUser { * - 0: Success. * - < 0: Failure. */ - virtual int registerVideoFrameObserver(media::base::IVideoFrameObserver* observer) = 0; + virtual int registerVideoFrameObserver(media::base::IVideoFrameObserver* observer, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Unregisters a video frame observer object. diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraScreenCapturer.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraScreenCapturer.h index a5e5e1693..ee1633fb6 100644 --- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraScreenCapturer.h +++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraScreenCapturer.h @@ -8,6 +8,7 @@ #include "AgoraBase.h" #include "AgoraRefPtr.h" +#include namespace agora { namespace rtc { @@ -90,7 +91,7 @@ class IScreenCapturer : public RefCountInterface { * - < 0: Failure. * - ERR_NOT_READY: No screen or window is being shared. */ - virtual int setContentHint(VIDEO_CONTENT_HINT contentHint) = 0; + virtual int setContentHint(VIDEO_CONTENT_HINT contentHint, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Updates the screen capture region. @@ -102,19 +103,19 @@ class IScreenCapturer : public RefCountInterface { * - < 0: Failure. * - No screen or window is being shared. */ - virtual int updateScreenCaptureRegion(const Rectangle& regionRect) = 0; + virtual int updateScreenCaptureRegion(const Rectangle& regionRect, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Set orientation of the captured screen image * @param VIDEO_ORIENTATION orientaion of the device 0(by default), 90, 180, 270 */ - virtual void setScreenOrientation(VIDEO_ORIENTATION orientation) = 0; + virtual int setScreenOrientation(VIDEO_ORIENTATION orientation, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Set frame rate of the screen capture source * @param rate frame rate (in fps) */ - virtual void setFrameRate(int rate) = 0; + virtual int setFrameRate(int rate, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; #if defined(__ANDROID__) /** @@ -141,7 +142,7 @@ class IScreenCapturer : public RefCountInterface { ~IScreenCapturer() {} }; -#if defined(__ANDROID__) || TARGET_OS_IPHONE +#if defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IPHONE) class IScreenCapturer2 : public RefCountInterface { public: /** @@ -154,7 +155,7 @@ class IScreenCapturer2 : public RefCountInterface { * - < 0: Failure. * - ERR_INVALID_ARGUMENT if data is null. */ - virtual int setScreenCaptureDimensions(const VideoDimensions& dimensions) = 0; + virtual int setScreenCaptureDimensions(const VideoDimensions& dimensions, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Updates the screen capture region. @@ -166,13 +167,13 @@ class IScreenCapturer2 : public RefCountInterface { * - < 0: Failure. * - No screen or window is being shared. */ - virtual int updateScreenCaptureRegion(const Rectangle& regionRect) = 0; + virtual int updateScreenCaptureRegion(const Rectangle& regionRect, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Set frame rate of the screen capture source * @param rate frame rate (in fps) */ - virtual int setFrameRate(int rate) = 0; + virtual int setFrameRate(int rate, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Set channels and sample rate of screen audio capturing @@ -182,7 +183,7 @@ class IScreenCapturer2 : public RefCountInterface { * - 0: Sucess. * - < 0: Failure */ - virtual int setAudioRecordConfig(int channels, int sampleRate) = 0; + virtual int setAudioRecordConfig(int channels, int sampleRate, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Set volume of screen audio capturing @@ -191,7 +192,7 @@ class IScreenCapturer2 : public RefCountInterface { * - 0: Sucess. * - < 0: Failure */ - virtual int setAudioVolume(uint32_t volume) = 0; + virtual int setAudioVolume(uint32_t volume, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; protected: virtual ~IScreenCapturer2() {} diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraVideoFrame.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraVideoFrame.h index d2f6945c6..9b114002f 100644 --- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraVideoFrame.h +++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraVideoFrame.h @@ -186,6 +186,7 @@ OPTIONAL_ENUM_CLASS VideoFrameMetaDataType { kScreenMetaInfo, kVideoSourceType, kFaceInfo, + kFaceCaptureInfo, // Add other types afterwards }; @@ -211,7 +212,7 @@ class IVideoFrame : public RefCountInterface { virtual int getVideoFrameData(VideoFrameData& data) const = 0; /** - * Fill the underlying buffer with source buffer info contained in VideoFrameInfo + * Fill the underlying buffer with source buffer info contained in VideoFrameData * For frames of type "Type::kMemPixels", This function first tries to fill in-place with no copy and reallocation. * When it fails, a copy or copy-plus-reallocation may happen * @param data [in] Data to be filled in. diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraVideoMixerSource.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraVideoMixerSource.h index f179cdac4..7cbe7183c 100644 --- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraVideoMixerSource.h +++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraVideoMixerSource.h @@ -51,7 +51,7 @@ class IVideoMixerSource : public RefCountInterface { * 0 - Success * <0 - Failure */ - virtual int addVideoTrack(const char* id, agora_refptr track) = 0; + virtual int addVideoTrack(const char* id, agora_refptr track, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Remove the video track. * @param id The unique id of the stream. @@ -60,7 +60,7 @@ class IVideoMixerSource : public RefCountInterface { * 0 - Success * <0 - Failure */ - virtual int removeVideoTrack(const char* id, agora_refptr track) = 0; + virtual int removeVideoTrack(const char* id, agora_refptr track, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Configures the layout of video frames comming from a specific track (indicated by uid) * on the mixer canvas. @@ -70,7 +70,7 @@ class IVideoMixerSource : public RefCountInterface { * 0 - Success * <0 - Failure */ - virtual int setStreamLayout(const char* id, const MixerLayoutConfig& config) = 0; + virtual int setStreamLayout(const char* id, const MixerLayoutConfig& config, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Remove the user layout on the mixer canvas * @param id The unique id of the stream. @@ -79,7 +79,7 @@ class IVideoMixerSource : public RefCountInterface { * 0 - Success * <0 - Failure */ - virtual int delStreamLayout(const char* id) = 0; + virtual int delStreamLayout(const char* id, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Add a image source to the mixer with its layout configuration on the mixer canvas. * @param id The unique id of the image. @@ -88,7 +88,7 @@ class IVideoMixerSource : public RefCountInterface { * 0 - Success * <0 - Failure */ - virtual int addImageSource(const char* id, const MixerLayoutConfig& config, ImageType type = kPng) = 0; + virtual int addImageSource(const char* id, const MixerLayoutConfig& config, ImageType type = kPng, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Delete a image source to the mixer. * @param id The unique id of the image. @@ -96,18 +96,18 @@ class IVideoMixerSource : public RefCountInterface { * 0 - Success * <0 - Failure */ - virtual int delImageSource(const char* id) = 0; + virtual int delImageSource(const char* id, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Clear all the layout settings set previously */ - virtual void clearLayout() = 0; + virtual int clearLayout(ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Refresh the user layout on the mixer canvas * @return * 0 - Success * <0 - Failure */ - virtual int refresh() = 0; + virtual int refresh(ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Set the mixer canvas background to override the default configuration * @param width width of the canvas @@ -118,7 +118,7 @@ class IVideoMixerSource : public RefCountInterface { * 0 - Success * <0 - Failure */ - virtual int setBackground(uint32_t width, uint32_t height, int fps, uint32_t color_argb = 0) = 0; + virtual int setBackground(uint32_t width, uint32_t height, int fps, uint32_t color_argb = 0, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Set the mixer canvas background to override the default configuration * @param width width of the canvas @@ -129,7 +129,7 @@ class IVideoMixerSource : public RefCountInterface { * 0 - Success * <0 - Failure */ - virtual int setBackground(uint32_t width, uint32_t height, int fps, const char* url) = 0; + virtual int setBackground(uint32_t width, uint32_t height, int fps, const char* url, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Set the rotation of the mixed video stream * @param rotation:0:none, 1:90°, 2:180°, 3:270° @@ -137,7 +137,7 @@ class IVideoMixerSource : public RefCountInterface { * 0 - Success * <0 - Failure */ - virtual int setRotation(uint8_t rotation) = 0; + virtual int setRotation(uint8_t rotation, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Get the average delay in ms introduced by the mixer module, which includes the average * mixing delay plus the encoder delay. @@ -152,7 +152,7 @@ class IVideoMixerSource : public RefCountInterface { * 0 - Success * <0 - Failure */ - virtual int setMasterClockSource(const char* id = NULL) = 0; + virtual int setMasterClockSource(const char* id = NULL, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; }; } //namespace rtc diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraVideoTrack.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraVideoTrack.h index cb927ae9f..a79cb5e45 100644 --- a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraVideoTrack.h +++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/NGIAgoraVideoTrack.h @@ -9,6 +9,7 @@ #pragma once // NOLINT(build/header_guard) #include "AgoraBase.h" +#include #ifndef OPTIONAL_OVERRIDE #if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) @@ -55,7 +56,7 @@ class IVideoTrack : public RefCountInterface { */ virtual bool addVideoFilter( agora_refptr filter, media::base::VIDEO_MODULE_POSITION position = media::base::POSITION_POST_CAPTURER, - const char* id = NULL) = 0; + const char* id = NULL, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Removes the video filter added by `addVideoFilter` from the video track. @@ -69,7 +70,7 @@ class IVideoTrack : public RefCountInterface { */ virtual bool removeVideoFilter( agora_refptr filter, media::base::VIDEO_MODULE_POSITION position = media::base::POSITION_POST_CAPTURER, - const char* id = NULL) = 0; + const char* id = NULL, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Whether a video filter exists @@ -94,7 +95,7 @@ class IVideoTrack : public RefCountInterface { * - `true`: The video renderer is added successfully. * - `false`: The video renderer fails to be added. */ - virtual bool addRenderer(agora_refptr videoRenderer, media::base::VIDEO_MODULE_POSITION position = media::base::POSITION_PRE_RENDERER) = 0; + virtual bool addRenderer(agora_refptr videoRenderer, media::base::VIDEO_MODULE_POSITION position, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Removes the video renderer added by `addRenderer` from the video track. * @@ -104,7 +105,7 @@ class IVideoTrack : public RefCountInterface { * - `true`: The video renderer is removed successfully. * - `false`: The video renderer fails to be removed. */ - virtual bool removeRenderer(agora_refptr videoRenderer, media::base::VIDEO_MODULE_POSITION position = media::base::POSITION_PRE_RENDERER) = 0; + virtual bool removeRenderer(agora_refptr videoRenderer, media::base::VIDEO_MODULE_POSITION position, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Get the track type of the video track * @return @@ -120,7 +121,7 @@ class IVideoTrack : public RefCountInterface { * - 0: success * - <0: failure */ - virtual int enableVideoFilter(const char* id, bool enable) { return -1; } + virtual int enableVideoFilter(const char* id, bool enable, ahpl_ref_t ares = AHPL_REF_INVALID) { return -1; } /** * set the properties of the specified video filter @@ -131,7 +132,7 @@ class IVideoTrack : public RefCountInterface { * - 0: success * - <0: failure */ - virtual int setFilterProperty(const char* id, const char* key, const char* json_value) { return -1; } + virtual int setFilterProperty(const char* id, const char* key, const char* json_value, ahpl_ref_t ares = AHPL_REF_INVALID) { return -1; } /** * get the properties of the specified video filter @@ -142,7 +143,7 @@ class IVideoTrack : public RefCountInterface { * - 0: success * - <0: failure */ - virtual int getFilterProperty(const char* id, const char* key, char* json_value, size_t buf_size) { return -1; } + virtual int getFilterProperty(const char* id, const char* key, char* json_value, size_t buf_size, ahpl_ref_t ares = AHPL_REF_INVALID) { return -1; } protected: ~IVideoTrack() {} @@ -234,6 +235,10 @@ struct LocalVideoTrackStats { int height; uint32_t encoder_type; uint32_t hw_encoder_accelerating; + /* + * encoder vender id, VideoCodecVenderId + */ + uint32_t encoder_vender_id; /** * The average time diff between frame captured and framed encoded. */ @@ -272,6 +277,8 @@ struct LocalVideoTrackStats { width(0), height(0), encoder_type(0), + hw_encoder_accelerating(0), + encoder_vender_id(0), uplink_cost_time_ms(0), quality_adapt_indication(ADAPT_NONE), txPacketLossRate(0), @@ -300,7 +307,7 @@ class ILocalVideoTrack : public IVideoTrack { * - `true`: Enable the local video track. * - `false`: Disable the local video track. */ - virtual void setEnabled(bool enable) = 0; + virtual int setEnabled(bool enable, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Sets the video encoder configuration. @@ -318,7 +325,7 @@ class ILocalVideoTrack : public IVideoTrack { * - 0: Success. * - < 0: Failure. */ - virtual int setVideoEncoderConfiguration(const VideoEncoderConfiguration& config) = 0; + virtual int setVideoEncoderConfiguration(const VideoEncoderConfiguration& config, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Set simulcast stream mode, enable, disable or auto enable @@ -329,7 +336,7 @@ class ILocalVideoTrack : public IVideoTrack { * - 0: Success. * - < 0: Failure. */ - virtual int setSimulcastStreamMode(SIMULCAST_STREAM_MODE mode, const SimulcastStreamConfig& config) = 0; + virtual int setSimulcastStreamMode(SIMULCAST_STREAM_MODE mode, const SimulcastStreamConfig& config, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Gets the state of the local video stream. @@ -446,13 +453,17 @@ struct RemoteVideoTrackStats { vqa avg cost ms */ int vqa_avg_cost_ms; + /** + decoder vender id, VideoCodecVenderId + */ + uint32_t decoder_vender_id; RemoteVideoTrackStats() : uid(0), delay(0), width(0), height(0), receivedBitrate(0), decoderOutputFrameRate(0), rendererOutputFrameRate(0), frameLossRate(0), packetLossRate(0), rxStreamType(VIDEO_STREAM_HIGH), totalFrozenTime(0), frozenRate(0), received_bytes(0), totalDecodedFrames(0), avSyncTimeMs(0), downlink_process_time_ms(0), frame_render_delay_ms(0), totalActiveTime(0), - publishDuration(0), vqa_mos(0), vqa_avg_cost_ms(0) {} + publishDuration(0), vqa_mos(0), vqa_avg_cost_ms(0), decoder_vender_id(0) {} }; /** @@ -493,7 +504,7 @@ class IRemoteVideoTrack : public IVideoTrack { * - 0: Success. * - < 0: Failure. */ - virtual int registerVideoEncodedFrameObserver(agora::media::IVideoEncodedFrameObserver* encodedObserver) = 0; + virtual int registerVideoEncodedFrameObserver(agora::media::IVideoEncodedFrameObserver* encodedObserver, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Releases the \ref agora::media::IVideoEncodedFrameObserver "IVideoEncodedFrameObserver" object. * @param encodedObserver The pointer to the `IVideoEncodedFrameObserver` object. @@ -515,7 +526,7 @@ class IRemoteVideoTrack : public IVideoTrack { * - 0: Success. * - < 0: Failure. */ - virtual int registerMediaPacketReceiver(IMediaPacketReceiver* videoReceiver) = 0; + virtual int registerMediaPacketReceiver(IMediaPacketReceiver* videoReceiver, ahpl_ref_t ares = AHPL_REF_INVALID) = 0; /** * Releases the \ref agora::rtc::IMediaPacketReceiver "IMediaPacketReceiver" object. * @param videoReceiver The pointer to the `IMediaPacketReceiver` object. diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/ahpl_ares.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/ahpl_ares.h new file mode 100644 index 000000000..92c409bb3 --- /dev/null +++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/ahpl_ares.h @@ -0,0 +1,77 @@ +/************************************************************* + * Author: Lionfore Hao (haolianfu@agora.io) + * Date : May 30th, 2023 + * Module: AHPL async result object header file + * + * + * This is a part of the Advanced High Performance Library. + * Copyright (C) 2018 ~ 2023 Agora IO + * All rights reserved. + * + *************************************************************/ + +#ifndef __AHPL_ARES_H__ +#define __AHPL_ARES_H__ + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +/** + * Create an async result object. + * Parameter: + * arg: the parameter attached with the async result object; + * Return value: + * the async result object ref id just created, AHPL_REF_INVALID when failed. + **/ +extern __ahpl_api__ ahpl_ref_t ahpl_ares_create (void *arg); + +/** + * Complete the specified async result object. + * Parameters: + * ref: the async result object ref id; + * result: a result value which can be retrieved by wait function; + * Return value: + * <0: error occured, and ahpl_errno indicates which error; + * >=0: successful; + **/ +extern __ahpl_api__ int ahpl_ares_complete (ahpl_ref_t ref, intptr_t result); + +/** + * Wait the specified async result object to complete. + * Parameters: + * ref: the async result object ref id; + * timeo: maximum waiting time in milliseconds; + * result: variable address for the value which was set by complete function, + * NOTE: the *result only will be set when the return value of wait + * function is AHPL_POLL_ST_SIGNALED and result != NULL, if you + * do not care the complete result, just passing NULL to it; + * Return value: + * <0: error occured, and ahpl_errno indicates which error; + * >=0: AHPL_POLL_ST_* macros value; + **/ +extern __ahpl_api__ int ahpl_ares_wait (ahpl_ref_t ref, intptr_t timeo, intptr_t *result); + +/** + * Reset the specified async result object to non signaled state. + * Parameters: + * ref: the async result object ref id + * Return value: + * <0: error occured, and ahpl_errno indicates which error; + * >=0: successful; + **/ +extern __ahpl_api__ int ahpl_ares_reset (ahpl_ref_t ref); + + + +#ifdef __cplusplus +} +#endif + +#endif /* __AHPL_ARES_H__ */ \ No newline at end of file diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/ahpl_defs.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/ahpl_defs.h new file mode 100644 index 000000000..3f1cb6a02 --- /dev/null +++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/ahpl_defs.h @@ -0,0 +1,171 @@ +/************************************************************* + * Author: Lionfore Hao (haolianfu@agora.io) + * Date : Jul 21st, 2018 + * Module: AHPL common definitions header file + * + * + * This is a part of the Advanced High Performance Library. + * Copyright (C) 2018 Agora IO + * All rights reserved. + * + *************************************************************/ + +#ifndef __AHPL_DEFS_H__ +#define __AHPL_DEFS_H__ + + +#define ahpl_stringify_1(x) #x +#define ahpl_stringify(x) ahpl_stringify_1(x) + + +#ifndef __MAKERCORE_ASSEMBLY__ + +#ifdef __cplusplus +extern "C" { +#endif + + +#ifdef _MSC_VER +#ifndef __inline__ +#define __inline__ __inline +#endif +#endif + + +#ifndef container_of +#if defined (__GNUC__) +#define container_of(ptr, type, member) ({ \ + const typeof( ((type *)0)->member ) *__mptr = (void *)(ptr); \ + (type *)( (char *)__mptr - offsetof(type,member) );}) +#else +#define container_of(ptr, type, member) ((type *)((char *)(ptr) - offsetof(type,member))) +#endif +#endif + +#define ahpl_rela_addr(type, field) (&((type *)0)->field) +#define ahpl_base_addr(ptr, type, field) \ + ((type *)((uintptr_t)(ptr) - (uintptr_t)(&((type *)0)->field))) + + +#define ahpl_min(x, y) ((x) < (y) ? (x) : (y)) +#define ahpl_max(x, y) ((x) > (y) ? (x) : (y)) + + +/* I think 64 args is big enough */ +#define AHPL_VAR_ARGS_MAX 64 + + +#ifdef BUILD_TARGET_SHARED +#if defined (__GNUC__) +#define __export_in_so__ __attribute__ ((visibility ("default"))) +#elif defined (_MSC_VER) +#define __export_in_so__ __declspec (dllexport) +#endif +#else +#define __export_in_so__ +#endif + + +#ifndef __ahpl_api__ +#if defined (_MSC_VER) && defined (BUILDING_API_IMPL_SOURCE) && defined (BUILD_TARGET_SHARED) +#define __ahpl_api__ __declspec (dllexport) +#elif defined (_MSC_VER) && !defined (BUILDING_API_IMPL_SOURCE) +#define __ahpl_api__ __declspec (dllimport) +#else +#define __ahpl_api__ +#endif +#endif + +#if defined (BUILDING_API_IMPL_SOURCE) || defined (STATIC_LINKING_AHPL) + +#if defined (__GNUC__) +#define __so_api__ __attribute__ ((visibility ("default"))) +#elif defined (_MSC_VER) +#define __so_api__ __declspec (dllexport) +#else +#define __so_api__ +#endif + +#else + +#if defined (_MSC_VER) +#define __so_api__ __declspec (dllimport) +#else +#define __so_api__ +#endif + +#endif + + +#ifdef __GNUC__ +#ifndef __MACH__ +#define AHPL_DEFINE_BIN(v, f) \ +__asm__ (".section .rodata\n\t" \ + ".globl "#v"_bin_begin\n\t" \ + ".hidden "#v"_bin_begin\n\t" \ + ".align 4\n\t" \ + #v"_bin_begin:\n\t" \ + ".incbin \"" ahpl_stringify(MAKERCORE_THIS_FILE_DIR/f)"\"\n\t" \ + ".globl "#v"_bin_end\n\t" \ + ".hidden "#v"_bin_end\n\t" \ + #v"_bin_end:\n\t" \ + ".previous\n\t") +#else +#define AHPL_DEFINE_BIN(v, f) \ +__asm__ (".section __TEXT,__const\n\t" \ + ".globl _"#v"_bin_begin\n\t" \ + ".private_extern _"#v"_bin_begin\n\t" \ + ".align 4\n\t" \ + "_"#v"_bin_begin:\n\t" \ + ".incbin \"" ahpl_stringify (MAKERCORE_THIS_FILE_DIR/f) "\"\n\t" \ + ".globl _"#v"_bin_end\n\t" \ + ".private_extern _"#v"_bin_end\n\t" \ + "_"#v"_bin_end:\n\t" \ + ".previous\n\t") +#endif + +#define AHPL_DECLARE_BIN(v) extern unsigned char v##_bin_begin, v##_bin_end +#define AHPL_BIN_ADDR(v) ((void *)&v##_bin_begin) +#define AHPL_BIN_SIZE(v) ((size_t)((unsigned char *)&v##_bin_end - (unsigned char *)&v##_bin_begin)) +#endif + + +#ifdef __cplusplus +} +#endif + +#else /* __MAKERCORE_ASSEMBLY__ */ + +#ifdef __GNUC__ +#ifndef __MACH__ +.macro AHPL_DEFINE_BIN_S v, f + .section .rodata + .globl \v\()_bin_begin + .hidden \v\()_bin_begin + .align 4 + \v\()_bin_begin: + .incbin ahpl_stringify (MAKERCORE_THIS_FILE_DIR/\f) + .globl \v\()_bin_end + .hidden \v\()_bin_end + \v\()_bin_end: + .previous +.endm +#else +.macro AHPL_DEFINE_BIN_S v, f + .section __TEXT,__const + .globl _\()\v\()_bin_begin + .private_extern _\()\v\()_bin_begin + .align 4 + _\()\v\()_bin_begin: + .incbin ahpl_stringify (MAKERCORE_THIS_FILE_DIR/\f) + .globl _\()\v\()_bin_end + .private_extern _\()\v\()_bin_end + _\()\v\()_bin_end: + .previous +.endm +#endif +#endif + +#endif /* __MAKERCORE_ASSEMBLY__ */ + +#endif /* __AHPL_DEFS_H__ */ \ No newline at end of file diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/ahpl_poll.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/ahpl_poll.h new file mode 100644 index 000000000..d8d1e7785 --- /dev/null +++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/ahpl_poll.h @@ -0,0 +1,51 @@ +/************************************************************* + * Author: Lionfore Hao (haolianfu@agora.io) + * Date : May 30th, 2023 + * Module: AHPL poll functionality definition header file + * + * + * This is a part of the Advanced High Performance Library. + * Copyright (C) 2018 ~ 2023 Agora IO + * All rights reserved. + * + *************************************************************/ + +#ifndef __AHPL_POLL_H__ +#define __AHPL_POLL_H__ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + + + +#define AHPL_POLL_ST_NONE 0 +#define AHPL_POLL_ST_SIGNALED 1 +#define AHPL_POLL_ST_DESTROY 2 + +/** + * Poll the objects specified in refs, return their states. + * Parameters: + * refs: the object refs array for input, and the signaled refs array for output; + * count: the number of items for input refs array; + * min: the minimum number of signaled refs for triggering waken up. + * NOTE: if any one of the refs encounters error or destroy, + * then wake up immediately regardless min parameter. + * timeo: maximum waiting time in milliseconds; + * Return value: + * <0: error occured, and ahpl_errno indicates which error; + * >=0: the signaled refs count before timeout; + **/ +extern __ahpl_api__ ssize_t ahpl_poll (ahpl_ref_t refs [], size_t count, size_t min, intptr_t timeo); + + + +#ifdef __cplusplus +} +#endif + +#endif /* __AHPL_POLL_H__ */ \ No newline at end of file diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/ahpl_ref.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/ahpl_ref.h new file mode 100644 index 000000000..b5264468b --- /dev/null +++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/ahpl_ref.h @@ -0,0 +1,230 @@ +/************************************************************* + * Author: Lionfore Hao (haolianfu@agora.io) + * Date : Nov 19th, 2018 + * Module: AHPL reference object definition file + * + * + * This is a part of the Advanced High Performance Library. + * Copyright (C) 2018 Agora IO + * All rights reserved. + * + *************************************************************/ + +#ifndef __AHPL_REF_H__ +#define __AHPL_REF_H__ + + +#include +#include + + +#ifdef __cplusplus +extern "C" { +#endif + + + +typedef struct _internal_ref_od_ *ahpl_ref_t; + +#define AHPL_REF_INVALID ((ahpl_ref_t)(intptr_t)-1) + +#define ahpl_ref_invalid(ref) (((int)(intptr_t)(ref)) < 0) + + +/** + * The reference object destructor function prototype, which invoked when application + * calling ahpl_ref_destroy functions to release resources. + * Parameter: + * arg: the parameter passed in when creating the reference object; + * Return value: + * none. + **/ +typedef void (*ahpl_ref_dtor_t) (void *arg); + +/** + * The reference object creating function prototype, which is used to create a ref object. + * Parameters: + * arg: the parameter attached with the reference object; + * dtor: the ref object destructor function, which will be invoked when + * the ref object is deleted; + * caller_free: + * none-0 guarantee the ref object relatives must be freed in the caller thread + * 0 the ref object relatives could be freed in any thread + * Return value: + * the ref object id, please use ahpl_ref_invalid macro to check whether failed. + **/ +extern __ahpl_api__ ahpl_ref_t ahpl_ref_create (void *arg, ahpl_ref_dtor_t dtor, int caller_free); + + +/** + * The ref object callback function prototype. + * Parameter: + * arg: the ref object argument which was passed in when creating; + * argc: specify the argv array elements count, the same as the argc + * when invoking ahpl_ref_[get|read|write] functions; + * argv: array for passing variable args, the same as the args + * when invoking ahpl_task_exec_* functions; + * Return value: + * none. + **/ +typedef void (*ahpl_ref_func_t) (void *arg, uintptr_t argc, uintptr_t argv []); + +/** + * Hold the ref object, and invoke the specified callback function. + * Parameter: + * ref: the ref object id; + * f: the callback function; + * argc: the args count + * ...: variable args + * Return value: + * 0: success + * <0: failure with ahpl_errno set + **/ +extern __ahpl_api__ int ahpl_ref_hold (ahpl_ref_t ref, ahpl_ref_func_t f, uintptr_t argc, ...); +extern __ahpl_api__ int ahpl_ref_hold_args (ahpl_ref_t ref, ahpl_ref_func_t f, uintptr_t argc, va_list args); +extern __ahpl_api__ int ahpl_ref_hold_argv (ahpl_ref_t ref, ahpl_ref_func_t f, uintptr_t argc, uintptr_t argv []); + +/** + * Hold the ref object and read lock it, then invoke the specified callback function. + * Parameter: + * ref: the ref object id; + * f: the callback function; + * argc: the args count + * ...: variable args + * Return value: + * 0: success + * <0: failure with ahpl_errno set + **/ +extern __ahpl_api__ int ahpl_ref_read (ahpl_ref_t ref, ahpl_ref_func_t f, uintptr_t argc, ...); +extern __ahpl_api__ int ahpl_ref_read_args (ahpl_ref_t ref, ahpl_ref_func_t f, uintptr_t argc, va_list args); +extern __ahpl_api__ int ahpl_ref_read_argv (ahpl_ref_t ref, ahpl_ref_func_t f, uintptr_t argc, uintptr_t argv []); + +/** + * Hold the ref object and write lock it, then invoke the specified callback function. + * Parameter: + * ref: the ref object id; + * f: the callback function; + * argc: the args count + * ...: variable args + * Return value: + * 0: success + * <0: failure with ahpl_errno set + **/ +extern __ahpl_api__ int ahpl_ref_write (ahpl_ref_t ref, ahpl_ref_func_t f, uintptr_t argc, ...); +extern __ahpl_api__ int ahpl_ref_write_args (ahpl_ref_t ref, ahpl_ref_func_t f, uintptr_t argc, va_list args); +extern __ahpl_api__ int ahpl_ref_write_argv (ahpl_ref_t ref, ahpl_ref_func_t f, uintptr_t argc, uintptr_t argv []); + +/** + * Hold the ref object and set it maystall, then invoke the specified callback function. + * Parameter: + * ref: the ref object id; + * f: the callback function; + * argc: the args count + * ...: variable args + * Return value: + * 0: success + * <0: failure with ahpl_errno set + **/ +extern __ahpl_api__ int ahpl_ref_maystall (ahpl_ref_t ref, ahpl_ref_func_t f, uintptr_t argc, ...); +extern __ahpl_api__ int ahpl_ref_maystall_args (ahpl_ref_t ref, ahpl_ref_func_t f, uintptr_t argc, va_list args); +extern __ahpl_api__ int ahpl_ref_maystall_argv (ahpl_ref_t ref, ahpl_ref_func_t f, uintptr_t argc, uintptr_t argv []); + + +typedef void *ahpl_refobj_t; + +#define AHPL_FREE_ONLY_OBJ ((ahpl_refobj_t)(uintptr_t)1) +#define ahpl_is_free_only(robj) ((int)((ahpl_refobj_t)(robj) == AHPL_FREE_ONLY_OBJ)) + +/** + * Retrieve the ref object arg. + * Parameters: + * robj: the reference object; + * Return value: + * the ref object arg; + **/ +extern __ahpl_api__ void *ahpl_refobj_arg (ahpl_refobj_t robj); + +/** + * Get the ref id of the specified ref object. + * Parameters: + * robj: the reference object; + * Return value: + * the ref id. + **/ +extern __ahpl_api__ ahpl_ref_t ahpl_refobj_id (ahpl_refobj_t robj); + +/** + * Make sure read lock the ref object specified by robj, then invoke the specified callback function. + * Parameter: + * robj: the ref object itself; + * f: the callback function; + * argc: the args count + * ...: variable args + * Return value: + * 0: success + * <0: failure with ahpl_errno set + **/ +extern __ahpl_api__ int ahpl_refobj_read (ahpl_refobj_t robj, ahpl_ref_func_t f, uintptr_t argc, ...); +extern __ahpl_api__ int ahpl_refobj_read_args (ahpl_refobj_t robj, ahpl_ref_func_t f, uintptr_t argc, va_list args); +extern __ahpl_api__ int ahpl_refobj_read_argv (ahpl_refobj_t robj, ahpl_ref_func_t f, uintptr_t argc, uintptr_t argv []); + +/** + * Make sure set the ref object specified by robj maystall, then invoke the specified callback function. + * Parameter: + * robj: the ref object itself; + * f: the callback function; + * argc: the args count + * ...: variable args + * Return value: + * 0: success + * <0: failure with ahpl_errno set + **/ +extern __ahpl_api__ int ahpl_refobj_maystall (ahpl_refobj_t robj, ahpl_ref_func_t f, uintptr_t argc, ...); +extern __ahpl_api__ int ahpl_refobj_maystall_args (ahpl_refobj_t robj, ahpl_ref_func_t f, uintptr_t argc, va_list args); +extern __ahpl_api__ int ahpl_refobj_maystall_argv (ahpl_refobj_t robj, ahpl_ref_func_t f, uintptr_t argc, uintptr_t argv []); + + +/** + * Detect whether the reference object specified by ref is read locked + * by the calling thread. + * Parameter: + * ref: the reference object id + * Return value: + * 0: not read locked + * none zero: read locked by calling thread + **/ +extern __ahpl_api__ int ahpl_ref_locked (ahpl_ref_t ref); + +/** + * Set the living scope ref object of the specified ref object. + * Parameters: + * ref: the ref object ref id; + * scope_ref: the living scope ref, the ref object will be destroyed + * when the object specified by scope_ref was destroyed; + * Return value: + * <0: error occured, and ahpl_errno indicates which error; + * >=0: successful; + **/ +extern __ahpl_api__ int ahpl_ref_set_scope (ahpl_ref_t ref, ahpl_ref_t scope_ref); + +/** + * Destroy the reference object specified by ref. + * Parameter: + * ref: the reference object id + * do_delete: 0 for just marking it destroyed + * non-0 value for deleting it + * Return value: + * 0: success + * <0: failed, and ahpl_errno indicates what error occurs + **/ +extern __ahpl_api__ int ahpl_ref_destroy (ahpl_ref_t ref, int do_delete); + + + +#ifdef __cplusplus +} +#endif + + + +#endif /* __AHPL_REF_H__ */ \ No newline at end of file diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/ahpl_types.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/ahpl_types.h new file mode 100644 index 000000000..0617d3326 --- /dev/null +++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/ahpl_types.h @@ -0,0 +1,96 @@ +/************************************************************* + * Author: Lionfore Hao (haolianfu@agora.io) + * Date : Jul 27th, 2020 + * Module: AHPL POSIX definitions header file + * + * + * This is a part of the Advanced High Performance Library. + * Copyright (C) 2020 Agora IO + * All rights reserved. + * + *************************************************************/ + +#ifndef __AHPL_TYPES_H__ +#define __AHPL_TYPES_H__ + +#include +#include +#include +#include +#if defined (__linux__) || defined (__MACH__) || defined (__kliteos2__) || defined (_WIN32) +#include +#endif + +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +#if !defined (__linux__) && !defined (__MACH__) +/** + * Worry about some guy would like to define a macro + * for this type, so confirm that it is not a macro. + * -- Lionfore Hao Nov 5th, 2018 + **/ +#ifndef __ssize_t_defined +typedef intptr_t ssize_t; +#define __ssize_t_defined +#endif +#endif + + +/* The AHPL timestamp type */ +typedef unsigned long long ahpl_ts_t; + +/* The proto for a general ahpl var args function with argc & argv. */ +typedef void (*ahpl_argv_f) (uintptr_t argc, uintptr_t argv []); + +/* The proto for a general ahpl object destructor function. */ +typedef ahpl_argv_f ahpl_obj_dtor_t; + + +#if !defined (_WIN32) && !defined (__kspreadtrum__) +typedef int ahpl_fd_t; +#define AHPL_INVALID_FD ((ahpl_fd_t)-1) + +static __inline__ int ahpl_fd_invalid (ahpl_fd_t fd) +{ + return (int)(fd < 0); +} +#else +#if defined (_WIN32) +/** + * We MUST include 'winsock2.h' before any occurrence + * of including 'windows.h', the fucking Windows has + * the fucking issue that many definitions would be + * complained redefinition if not so. + * -- Lionfore Hao Sep 25th, 2018 + **/ +#include +#include + +typedef HANDLE ahpl_fd_t; +#define AHPL_INVALID_FD ((ahpl_fd_t)INVALID_HANDLE_VALUE) +#elif defined (__kspreadtrum__) +#include +#include + +typedef TCPIP_SOCKET_T ahpl_fd_t; +#define AHPL_INVALID_FD ((ahpl_fd_t)-1) +#endif + +static __inline__ int ahpl_fd_invalid (ahpl_fd_t fd) +{ + return (int)(fd == AHPL_INVALID_FD); +} +#endif + + +#ifdef __cplusplus +} +#endif + + +#endif /* __AHPL_TYPES_H__ */ \ No newline at end of file diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/cpp/ahpl_ares_class.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/cpp/ahpl_ares_class.h new file mode 100644 index 000000000..8643c0b78 --- /dev/null +++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/cpp/ahpl_ares_class.h @@ -0,0 +1,91 @@ +/************************************************************* + * Author: Lionfore Hao (haolianfu@agora.io) + * Date : Jun 23rd, 2023 + * Module: AHPL async result object for C++ definition file + * + * + * This is a part of the Advanced High Performance Library. + * Copyright (C) 2018 ~ 2023 Agora IO + * All rights reserved. + * + *************************************************************/ + +#ifndef __AHPL_ARES_CLASS_H__ +#define __AHPL_ARES_CLASS_H__ + + +#include + +#include +#include +#include +#include +#include + + +class ahpl_ares_class: public ahpl_ref_class { +public: + ahpl_ares_class (): ahpl_ref_class (ahpl_ares_create (this)) + { + if (ahpl_ref_invalid (ref ())) + abort (); + } + + /** + * The destructor of this class is very different with + * base class and other derivatives, destroy the ref + * in the destructor and the destructor is public. + **/ + virtual ~ahpl_ares_class () + { + ahpl_ref_t refid = ref (); + if (!ahpl_ref_invalid (refid)) + ahpl_ref_destroy (refid, true); + } + + /* complete the async result */ + int complete (intptr_t result = 0) + { + return ahpl_ares_complete (ref (), result); + } + + /* wait the async result to be completed */ + int wait (intptr_t timeo, intptr_t *result = NULL) + { + return ahpl_ares_wait (ref (), timeo, result); + } + + /* reset the signaled state */ + int reset (void) + { + return ahpl_ares_reset (ref ()); + } + + operator ahpl_ref_t () const + { + return ref (); + } + +private: + /* we do not allow invoke the destroy function of base class */ + int destroy (bool do_delete = true) + { + abort (); + return 0; + } + +#if (__cplusplus >= 201103) || defined (_MSC_VER) +private: + ahpl_ares_class (const ahpl_ares_class &) = delete; + ahpl_ares_class (ahpl_ares_class &&) = delete; + ahpl_ares_class &operator = (const ahpl_ares_class &) = delete; + ahpl_ares_class &operator = (ahpl_ares_class &&) = delete; +#else +private: + ahpl_ares_class (const ahpl_ares_class &); + ahpl_ares_class &operator = (const ahpl_ares_class &); +#endif /* C++11 */ +}; + + +#endif /* __AHPL_ARES_CLASS_H__ */ \ No newline at end of file diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/cpp/ahpl_poll_class.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/cpp/ahpl_poll_class.h new file mode 100644 index 000000000..2253b5d34 --- /dev/null +++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/cpp/ahpl_poll_class.h @@ -0,0 +1,129 @@ +/************************************************************* + * Author: Lionfore Hao (haolianfu@agora.io) + * Date : Jun 23rd, 2023 + * Module: AHPL poll functionality for C++ definition file + * + * + * This is a part of the Advanced High Performance Library. + * Copyright (C) 2018 ~ 2023 Agora IO + * All rights reserved. + * + *************************************************************/ + +#ifndef __AHPL_POLL_CLASS_H__ +#define __AHPL_POLL_CLASS_H__ + + +#include +#include +#include +#include +#include + +#if (__cplusplus >= 201103) || defined (_MSC_VER) +#include +#include +#endif + +#include +#include + + +class ahpl_poll_class { +private: + std::map poll_refs; + std::vector signaled_refs; + +public: + int add (const ahpl_ares_class &tail) + { + poll_refs [tail.ref ()] = &tail; + return 0; + } + +#if (__cplusplus >= 201103) || defined (_MSC_VER) + template + int add (const T &head, const Targs&... rest) + { + poll_refs [head.ref ()] = &head; + return add (rest...); + } + + /* constructor with variable args */ + template + ahpl_poll_class (Targs&... args) + { + add (args...); + } +#endif /* C++11 */ + + /* poll the constructed async results */ + int poll (size_t min, intptr_t timeo) + { + ahpl_ref_t local_refs [32]; + ahpl_ref_t *refs = local_refs; + size_t count = poll_refs.size (); + std::map::iterator it; + int i; + int err; + + if (count > sizeof local_refs / sizeof local_refs [0]) { + refs = new ahpl_ref_t [count]; + if (refs == NULL) + return -1; + } + + i = 0; + for (it = poll_refs.begin (); it != poll_refs.end (); it++) + refs [i++] = it->first; + + err = ahpl_poll (refs, count, min, timeo); + signaled_refs.clear (); + for (i = 0; i < err; i++) { + it = poll_refs.find (refs [i]); + if (it != poll_refs.end ()) + signaled_refs.push_back (it->second); + } + + if (refs != local_refs) + delete [] refs; + + return err; + } + + /* total async results count */ + size_t total () + { + return poll_refs.size (); + } + + /* signaled async results count */ + size_t signaled () + { + return signaled_refs.size (); + } + + /* operator for accessing the signaled async results */ + const ahpl_ares_class *operator [] (size_t idx) + { + if (idx < signaled_refs.size ()) + return signaled_refs [idx]; + + return NULL; + } + +#if (__cplusplus >= 201103) || defined (_MSC_VER) +private: + ahpl_poll_class (const ahpl_poll_class &) = delete; + ahpl_poll_class (ahpl_poll_class &&) = delete; + ahpl_poll_class &operator = (const ahpl_poll_class &) = delete; + ahpl_poll_class &operator = (ahpl_poll_class &&) = delete; +#else +private: + ahpl_poll_class (const ahpl_poll_class &); + ahpl_poll_class &operator = (const ahpl_poll_class &); +#endif +}; + + +#endif /* __AHPL_POLL_CLASS_H__ */ \ No newline at end of file diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/cpp/ahpl_ref_class.h b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/cpp/ahpl_ref_class.h new file mode 100644 index 000000000..85958718e --- /dev/null +++ b/Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/api/cpp/ahpl_ref_class.h @@ -0,0 +1,1002 @@ +/************************************************************* + * Author: Lionfore Hao (haolianfu@agora.io) + * Date : Nov 19th, 2018 + * Module: AHPL reference object for C++ definition file + * + * + * This is a part of the Advanced High Performance Library. + * Copyright (C) 2018 Agora IO + * All rights reserved. + * + *************************************************************/ + +#ifndef __AHPL_REF_OBJ_CPP_H__ +#define __AHPL_REF_OBJ_CPP_H__ + + +#include + +#include +#include +#include + +#ifdef COMPILING_WITH_MPQ_H +#include +#ifdef COMPILING_WITH_MPQP_H +#include +#endif +#endif + +#ifdef COMPILING_WITH_ASYNC_H +#include +#endif + +#if (__cplusplus >= 201103) || defined (_MSC_VER) +#include +#include +#endif + +class ahpl_ref_class { +private: + ahpl_ref_t ref_id; + +public: + ahpl_ref_class (bool caller_free = true) + { + ref_id = ahpl_ref_create (this, __dtor, (int)caller_free); + if (ahpl_ref_invalid (ref_id)) + abort (); + } + + ahpl_ref_class (ahpl_ref_t ref) + { + ref_id = ref; + } + + ahpl_ref_t ref () const + { + return ref_id; + } + + int hold (ahpl_ref_func_t f, uintptr_t argc, ...) + { + va_list args; + int err; + + va_start (args, argc); + err = ahpl_ref_hold_args (ref (), f, argc, args); + va_end (args); + + return err; + } + + int hold_args (ahpl_ref_func_t f, uintptr_t argc, va_list args) + { + return ahpl_ref_hold_args (ref (), f, argc, args); + } + + int hold_argv (ahpl_ref_func_t f, uintptr_t argc, uintptr_t argv []) + { + return ahpl_ref_hold_argv (ref (), f, argc, argv); + } + + int read (ahpl_ref_func_t f, uintptr_t argc, ...) + { + va_list args; + int err; + + va_start (args, argc); + err = ahpl_ref_read_args (ref (), f, argc, args); + va_end (args); + + return err; + } + + int read_args (ahpl_ref_func_t f, uintptr_t argc, va_list args) + { + return ahpl_ref_read_args (ref (), f, argc, args); + } + + int read_argv (ahpl_ref_func_t f, uintptr_t argc, uintptr_t argv []) + { + return ahpl_ref_read_argv (ref (), f, argc, argv); + } + + int write (ahpl_ref_func_t f, uintptr_t argc, ...) + { + va_list args; + int err; + + va_start (args, argc); + err = ahpl_ref_write_args (ref (), f, argc, args); + va_end (args); + + return err; + } + + int write_args (ahpl_ref_func_t f, uintptr_t argc, va_list args) + { + return ahpl_ref_write_args (ref (), f, argc, args); + } + + int write_argv (ahpl_ref_func_t f, uintptr_t argc, uintptr_t argv []) + { + return ahpl_ref_write_argv (ref (), f, argc, argv); + } + + int maystall (ahpl_ref_func_t f, uintptr_t argc, ...) + { + va_list args; + int err; + + va_start (args, argc); + err = ahpl_ref_maystall_args (ref (), f, argc, args); + va_end (args); + + return err; + } + + int maystall_args (ahpl_ref_func_t f, uintptr_t argc, va_list args) + { + return ahpl_ref_maystall_args (ref (), f, argc, args); + } + + int maystall_argv (ahpl_ref_func_t f, uintptr_t argc, uintptr_t argv []) + { + return ahpl_ref_maystall_argv (ref (), f, argc, argv); + } + + /* The static version of member functions */ + static int hold (ahpl_ref_t ref, ahpl_ref_func_t f, uintptr_t argc, ...) + { + va_list args; + int err; + + va_start (args, argc); + err = ahpl_ref_hold_args (ref, f, argc, args); + va_end (args); + + return err; + } + + static int hold_args (ahpl_ref_t ref, ahpl_ref_func_t f, uintptr_t argc, va_list args) + { + return ahpl_ref_hold_args (ref, f, argc, args); + } + + static int hold_argv (ahpl_ref_t ref, ahpl_ref_func_t f, uintptr_t argc, uintptr_t argv []) + { + return ahpl_ref_hold_argv (ref, f, argc, argv); + } + + static int read (ahpl_ref_t ref, ahpl_ref_func_t f, uintptr_t argc, ...) + { + va_list args; + int err; + + va_start (args, argc); + err = ahpl_ref_read_args (ref, f, argc, args); + va_end (args); + + return err; + } + + static int read_args (ahpl_ref_t ref, ahpl_ref_func_t f, uintptr_t argc, va_list args) + { + return ahpl_ref_read_args (ref, f, argc, args); + } + + static int read_argv (ahpl_ref_t ref, ahpl_ref_func_t f, uintptr_t argc, uintptr_t argv []) + { + return ahpl_ref_read_argv (ref, f, argc, argv); + } + + static int write (ahpl_ref_t ref, ahpl_ref_func_t f, uintptr_t argc, ...) + { + va_list args; + int err; + + va_start (args, argc); + err = ahpl_ref_write_args (ref, f, argc, args); + va_end (args); + + return err; + } + + static int write_args (ahpl_ref_t ref, ahpl_ref_func_t f, uintptr_t argc, va_list args) + { + return ahpl_ref_write_args (ref, f, argc, args); + } + + static int write_argv (ahpl_ref_t ref, ahpl_ref_func_t f, uintptr_t argc, uintptr_t argv []) + { + return ahpl_ref_write_argv (ref, f, argc, argv); + } + + static int maystall (ahpl_ref_t ref, ahpl_ref_func_t f, uintptr_t argc, ...) + { + va_list args; + int err; + + va_start (args, argc); + err = ahpl_ref_maystall_args (ref, f, argc, args); + va_end (args); + + return err; + } + + static int maystall_args (ahpl_ref_t ref, ahpl_ref_func_t f, uintptr_t argc, va_list args) + { + return ahpl_ref_maystall_args (ref, f, argc, args); + } + + static int maystall_argv (ahpl_ref_t ref, ahpl_ref_func_t f, uintptr_t argc, uintptr_t argv []) + { + return ahpl_ref_maystall_argv (ref, f, argc, argv); + } + + static int read (ahpl_refobj_t robj, ahpl_ref_func_t f, uintptr_t argc, ...) + { + va_list args; + int err; + + va_start (args, argc); + err = ahpl_refobj_read_args (robj, f, argc, args); + va_end (args); + + return err; + } + + static int read_args (ahpl_refobj_t robj, ahpl_ref_func_t f, uintptr_t argc, va_list args) + { + return ahpl_refobj_read_args (robj, f, argc, args); + } + + static int read_argv (ahpl_refobj_t robj, ahpl_ref_func_t f, uintptr_t argc, uintptr_t argv []) + { + return ahpl_refobj_read_argv (robj, f, argc, argv); + } + + static int maystall (ahpl_refobj_t robj, ahpl_ref_func_t f, uintptr_t argc, ...) + { + va_list args; + int err; + + va_start (args, argc); + err = ahpl_refobj_maystall_args (robj, f, argc, args); + va_end (args); + + return err; + } + + static int maystall_args (ahpl_refobj_t robj, ahpl_ref_func_t f, uintptr_t argc, va_list args) + { + return ahpl_refobj_maystall_args (robj, f, argc, args); + } + + static int maystall_argv (ahpl_refobj_t robj, ahpl_ref_func_t f, uintptr_t argc, uintptr_t argv []) + { + return ahpl_refobj_maystall_argv (robj, f, argc, argv); + } + + static ahpl_ref_class *from_refobj (ahpl_refobj_t robj) + { + return (ahpl_ref_class *)ahpl_refobj_arg (robj); + } + + /* set the living scope ref object of this ref object */ + int set_scope (ahpl_ref_t scope_ref) + { + return ahpl_ref_set_scope (ref (), scope_ref); + } + + int destroy (bool do_delete = true) + { + if (!ahpl_ref_invalid (ref_id)) + return ahpl_ref_destroy (ref_id, (int)do_delete); + + if (do_delete) + delete this; + + return 0; + } + +public: + class deleter { + public: + void operator () (ahpl_ref_class *obj_ptr) const + { + if (obj_ptr != NULL) + obj_ptr->destroy (); + } + }; + +protected: + /* We do not allow delete this object directly. */ + virtual ~ahpl_ref_class () + { + } + +private: + static void __dtor (void *arg) + { + ahpl_ref_class *__this = (ahpl_ref_class *)arg; + ::delete __this; + } + +#ifdef __AHPL_MPQ_H__ + /* MPQ relative encapsulations */ +public: + int queue (ahpl_mpq_t tq, ahpl_mpq_t dq, const char *f_name, ahpl_mpq_func_argv_t f, uintptr_t argc, ...) + { + va_list args; + int err; + + va_start (args, argc); + err = ahpl_mpq_queue_args (tq, dq, ref (), f_name, f, argc, args); + va_end (args); + + return err; + } + + int queue_args (ahpl_mpq_t tq, ahpl_mpq_t dq, const char *f_name, ahpl_mpq_func_argv_t f, uintptr_t argc, va_list args) + { + return ahpl_mpq_queue_args (tq, dq, ref (), f_name, f, argc, args); + } + + int queue_argv (ahpl_mpq_t tq, ahpl_mpq_t dq, const char *f_name, ahpl_mpq_func_argv_t f, uintptr_t argc, uintptr_t *argv) + { + return ahpl_mpq_queue_argv (tq, dq, ref (), f_name, f, argc, argv); + } + + int queue_data (ahpl_mpq_t tq, ahpl_mpq_t dq, const char *f_name, ahpl_mpq_func_data_t f, size_t len, void *data) + { + return ahpl_mpq_queue_data (tq, dq, ref (), f_name, f, len, data); + } + + int call (ahpl_mpq_t q, const char *f_name, ahpl_mpq_func_argv_t f, uintptr_t argc, ...) + { + va_list args; + int err; + + va_start (args, argc); + err = ahpl_mpq_call_args (q, ref (), f_name, f, argc, args); + va_end (args); + + return err; + } + + int call_args (ahpl_mpq_t q, const char *f_name, ahpl_mpq_func_argv_t f, uintptr_t argc, va_list args) + { + return ahpl_mpq_call_args (q, ref (), f_name, f, argc, args); + } + + int call_argv (ahpl_mpq_t q, const char *f_name, ahpl_mpq_func_argv_t f, uintptr_t argc, uintptr_t *argv) + { + return ahpl_mpq_call_argv (q, ref (), f_name, f, argc, argv); + } + + int call_data (ahpl_mpq_t q, const char *f_name, ahpl_mpq_func_data_t f, size_t len, void *data) + { + return ahpl_mpq_call_data (q, ref (), f_name, f, len, data); + } + + int run (ahpl_mpq_t q, ahpl_mpq_t dq, const char *f_name, ahpl_mpq_func_argv_t f, uintptr_t argc, ...) + { + va_list args; + int err; + + va_start (args, argc); + err = ahpl_mpq_run_args (q, dq, ref (), f_name, f, argc, args); + va_end (args); + + return err; + } + + int run_args (ahpl_mpq_t q, ahpl_mpq_t dq, const char *f_name, ahpl_mpq_func_argv_t f, uintptr_t argc, va_list args) + { + return ahpl_mpq_run_args (q, dq, ref (), f_name, f, argc, args); + } + + int run_argv (ahpl_mpq_t q, ahpl_mpq_t dq, const char *f_name, ahpl_mpq_func_argv_t f, uintptr_t argc, uintptr_t *argv) + { + return ahpl_mpq_run_argv (q, dq, ref (), f_name, f, argc, argv); + } + + int run_data (ahpl_mpq_t q, ahpl_mpq_t dq, const char *f_name, ahpl_mpq_func_data_t f, size_t len, void *data) + { + return ahpl_mpq_run_data (q, dq, ref (), f_name, f, len, data); + } + +#ifdef __AHPL_MPQP_H__ + /* MPQP relative encapsulations */ + ahpl_mpq_t queue (ahpl_mpqp_t qp, ahpl_mpq_t dq, const char *f_name, ahpl_mpq_func_argv_t f, uintptr_t argc, ...) + { + va_list args; + ahpl_mpq_t qid; + + va_start (args, argc); + qid = ahpl_mpqp_queue_args (qp, dq, ref (), f_name, f, argc, args); + va_end (args); + + return qid; + } + + ahpl_mpq_t queue_args (ahpl_mpqp_t qp, ahpl_mpq_t dq, const char *f_name, ahpl_mpq_func_argv_t f, uintptr_t argc, va_list args) + { + return ahpl_mpqp_queue_args (qp, dq, ref (), f_name, f, argc, args); + } + + ahpl_mpq_t queue_argv (ahpl_mpqp_t qp, ahpl_mpq_t dq, const char *f_name, ahpl_mpq_func_argv_t f, uintptr_t argc, uintptr_t *argv) + { + return ahpl_mpqp_queue_argv (qp, dq, ref (), f_name, f, argc, argv); + } + + ahpl_mpq_t queue_data (ahpl_mpqp_t qp, ahpl_mpq_t dq, const char *f_name, ahpl_mpq_func_data_t f, size_t len, void *data) + { + return ahpl_mpqp_queue_data (qp, dq, ref (), f_name, f, len, data); + } + + ahpl_mpq_t call (ahpl_mpqp_t qp, const char *f_name, ahpl_mpq_func_argv_t f, uintptr_t argc, ...) + { + va_list args; + ahpl_mpq_t qid; + + va_start (args, argc); + qid = ahpl_mpqp_call_args (qp, ref (), f_name, f, argc, args); + va_end (args); + + return qid; + } + + ahpl_mpq_t call_args (ahpl_mpqp_t qp, const char *f_name, ahpl_mpq_func_argv_t f, uintptr_t argc, va_list args) + { + return ahpl_mpqp_call_args (qp, ref (), f_name, f, argc, args); + } + + ahpl_mpq_t call_argv (ahpl_mpqp_t qp, const char *f_name, ahpl_mpq_func_argv_t f, uintptr_t argc, uintptr_t *argv) + { + return ahpl_mpqp_call_argv (qp, ref (), f_name, f, argc, argv); + } + + ahpl_mpq_t call_data (ahpl_mpqp_t qp, const char *f_name, ahpl_mpq_func_data_t f, size_t len, void *data) + { + return ahpl_mpqp_call_data (qp, ref (), f_name, f, len, data); + } + + ahpl_mpq_t run (ahpl_mpqp_t qp, ahpl_mpq_t dq, const char *f_name, ahpl_mpq_func_argv_t f, uintptr_t argc, ...) + { + va_list args; + ahpl_mpq_t qid; + + va_start (args, argc); + qid = ahpl_mpqp_run_args (qp, dq, ref (), f_name, f, argc, args); + va_end (args); + + return qid; + } + + ahpl_mpq_t run_args (ahpl_mpqp_t qp, ahpl_mpq_t dq, const char *f_name, ahpl_mpq_func_argv_t f, uintptr_t argc, va_list args) + { + return ahpl_mpqp_run_args (qp, dq, ref (), f_name, f, argc, args); + } + + ahpl_mpq_t run_argv (ahpl_mpqp_t qp, ahpl_mpq_t dq, const char *f_name, ahpl_mpq_func_argv_t f, uintptr_t argc, uintptr_t *argv) + { + return ahpl_mpqp_run_argv (qp, dq, ref (), f_name, f, argc, argv); + } + + ahpl_mpq_t run_data (ahpl_mpqp_t qp, ahpl_mpq_t dq, const char *f_name, ahpl_mpq_func_data_t f, size_t len, void *data) + { + return ahpl_mpqp_run_data (qp, dq, ref (), f_name, f, len, data); + } + + int pool_tail_queue (ahpl_mpqp_t qp, ahpl_mpq_t dq, const char *f_name, ahpl_mpq_func_argv_t f, uintptr_t argc, ...) + { + va_list args; + int err; + + va_start (args, argc); + err = ahpl_mpqp_pool_tail_queue_args (qp, dq, ref (), f_name, f, argc, args); + va_end (args); + + return err; + } + + int pool_tail_queue_args (ahpl_mpqp_t qp, ahpl_mpq_t dq, const char *f_name, ahpl_mpq_func_argv_t f, uintptr_t argc, va_list args) + { + return ahpl_mpqp_pool_tail_queue_args (qp, dq, ref (), f_name, f, argc, args); + } + + int pool_tail_queue_argv (ahpl_mpqp_t qp, ahpl_mpq_t dq, const char *f_name, ahpl_mpq_func_argv_t f, uintptr_t argc, uintptr_t *argv) + { + return ahpl_mpqp_pool_tail_queue_argv (qp, dq, ref (), f_name, f, argc, argv); + } +#endif /* __AHPL_MPQP_H__ */ +#endif /* __AHPL_MPQ_H__ */ + + /* C++11 lambda encapsulations */ +#if (__cplusplus >= 201103) || defined (_MSC_VER) +public: + typedef std::function ahpl_ref_lambda_f; + + int hold (ahpl_ref_lambda_f &&lambda_f) + { + ahpl_ref_lambda_f lambda_obj (std::move (lambda_f)); + return ahpl_ref_class::hold (____ref_f, 1, &lambda_obj); + } + + int read (ahpl_ref_lambda_f &&lambda_f) + { + ahpl_ref_lambda_f lambda_obj (std::move (lambda_f)); + return ahpl_ref_class::read (____ref_f, 1, &lambda_obj); + } + + int write (ahpl_ref_lambda_f &&lambda_f) + { + ahpl_ref_lambda_f lambda_obj (std::move (lambda_f)); + return ahpl_ref_class::write (____ref_f, 1, &lambda_obj); + } + + int maystall (ahpl_ref_lambda_f &&lambda_f) + { + ahpl_ref_lambda_f lambda_obj (std::move (lambda_f)); + return ahpl_ref_class::maystall (____ref_f, 1, &lambda_obj); + } + + static int hold (ahpl_ref_t ref, ahpl_ref_lambda_f &&lambda_f) + { + ahpl_ref_lambda_f lambda_obj (std::move (lambda_f)); + return ahpl_ref_class::hold (ref, ____ref_f, 1, &lambda_obj); + } + + static int read (ahpl_ref_t ref, ahpl_ref_lambda_f &&lambda_f) + { + ahpl_ref_lambda_f lambda_obj (std::move (lambda_f)); + return ahpl_ref_class::read (ref, ____ref_f, 1, &lambda_obj); + } + + static int write (ahpl_ref_t ref, ahpl_ref_lambda_f &&lambda_f) + { + ahpl_ref_lambda_f lambda_obj (std::move (lambda_f)); + return ahpl_ref_class::write (ref, ____ref_f, 1, &lambda_obj); + } + + static int maystall (ahpl_ref_t ref, ahpl_ref_lambda_f &&lambda_f) + { + ahpl_ref_lambda_f lambda_obj (std::move (lambda_f)); + return ahpl_ref_class::maystall (ref, ____ref_f, 1, &lambda_obj); + } + + static int read (ahpl_refobj_t robj, ahpl_ref_lambda_f &&lambda_f) + { + ahpl_ref_lambda_f lambda_obj (std::move (lambda_f)); + return ahpl_ref_class::read (robj, ____ref_f, 1, &lambda_obj); + } + + static int maystall (ahpl_refobj_t robj, ahpl_ref_lambda_f &&lambda_f) + { + ahpl_ref_lambda_f lambda_obj (std::move (lambda_f)); + return ahpl_ref_class::maystall (robj, ____ref_f, 1, &lambda_obj); + } + +private: + static void ____ref_f (void *arg, uintptr_t argc, uintptr_t argv []) + { + ahpl_ref_lambda_f *lambda_obj = reinterpret_cast(argv [0]); + (*lambda_obj) ((ahpl_ref_class *)arg); + } + +#ifdef __AHPL_MPQ_H__ +public: + typedef std::function ahpl_ref_mpq_lambda_f; + + /* MPQ encapsulations */ + int queue (ahpl_mpq_t tq, ahpl_mpq_t dq, const char *f_name, ahpl_ref_mpq_lambda_f&& task) + { + ahpl_ref_mpq_lambda_f *task_obj = new ahpl_ref_mpq_lambda_f (std::move (task)); + int err = ahpl_ref_class::queue (tq, dq, f_name, ____mpq_f, 1, task_obj); + if (err < 0) + delete task_obj; + + return err; + } + + int call (ahpl_mpq_t q, const char *f_name, ahpl_ref_mpq_lambda_f&& task, void *task_result = NULL) + { + ahpl_ref_mpq_lambda_f *task_obj = new ahpl_ref_mpq_lambda_f (std::move (task)); + int err = ahpl_ref_class::call (q, f_name, ____mpq_f, 2, task_obj, task_result); + if (err < 0) + delete task_obj; + + return err; + } + + int run (ahpl_mpq_t q, const char *f_name, ahpl_ref_mpq_lambda_f&& task) + { + ahpl_ref_mpq_lambda_f *task_obj = new ahpl_ref_mpq_lambda_f (std::move (task)); + int err = ahpl_ref_class::run (q, AHPL_MPQ_INVALID, f_name, ____mpq_f, 1, task_obj); + if (err < 0) + delete task_obj; + + return err; + } + +#ifdef __AHPL_MPQP_H__ + /* MPQP encapsulations */ + ahpl_mpq_t queue (ahpl_mpqp_t qp, ahpl_mpq_t dq, const char *f_name, ahpl_ref_mpq_lambda_f&& task) + { + ahpl_ref_mpq_lambda_f *task_obj = new ahpl_ref_mpq_lambda_f (std::move (task)); + ahpl_mpq_t qid = ahpl_ref_class::queue (qp, dq, f_name, ____mpq_f, 1, task_obj); + if (ahpl_mpq_invalid (qid)) + delete task_obj; + + return qid; + } + + ahpl_mpq_t call (ahpl_mpqp_t qp, const char *f_name, ahpl_ref_mpq_lambda_f&& task, void *task_result = NULL) + { + ahpl_ref_mpq_lambda_f *task_obj = new ahpl_ref_mpq_lambda_f (std::move (task)); + ahpl_mpq_t qid = ahpl_ref_class::call (qp, f_name, ____mpq_f, 2, task_obj, task_result); + if (ahpl_mpq_invalid (qid)) + delete task_obj; + + return qid; + } + + ahpl_mpq_t run (ahpl_mpqp_t qp, const char *f_name, ahpl_ref_mpq_lambda_f&& task) + { + ahpl_ref_mpq_lambda_f *task_obj = new ahpl_ref_mpq_lambda_f (std::move (task)); + ahpl_mpq_t qid = ahpl_ref_class::run (qp, AHPL_MPQ_INVALID, f_name, ____mpq_f, 1, task_obj); + if (ahpl_mpq_invalid (qid)) + delete task_obj; + + return qid; + } + + int pool_tail_queue (ahpl_mpqp_t qp, ahpl_mpq_t dq, const char *f_name, ahpl_ref_mpq_lambda_f&& task) + { + ahpl_ref_mpq_lambda_f *task_obj = new ahpl_ref_mpq_lambda_f (std::move (task)); + int err = ahpl_ref_class::pool_tail_queue (qp, dq, f_name, ____mpq_f, 1, task_obj); + if (err < 0) + delete task_obj; + + return err; + } +#endif /* __AHPL_MPQP_H__ */ + + /* MPQ with specified ref encapsulations */ + static int queue (ahpl_mpq_t tq, ahpl_mpq_t dq, ahpl_ref_t ref, const char *f_name, ahpl_ref_mpq_lambda_f&& task) + { + ahpl_ref_mpq_lambda_f *task_obj = new ahpl_ref_mpq_lambda_f (std::move (task)); + int err = ahpl_mpq_queue (tq, dq, ref, f_name, ____mpq_f, 1, task_obj); + if (err < 0) + delete task_obj; + + return err; + } + + static int call (ahpl_mpq_t q, ahpl_ref_t ref, const char *f_name, ahpl_ref_mpq_lambda_f&& task, void *task_result = NULL) + { + ahpl_ref_mpq_lambda_f *task_obj = new ahpl_ref_mpq_lambda_f (std::move (task)); + int err = ahpl_mpq_call (q, ref, f_name, ____mpq_f, 2, task_obj, task_result); + if (err < 0) + delete task_obj; + + return err; + } + + static int run (ahpl_mpq_t q, ahpl_ref_t ref, const char *f_name, ahpl_ref_mpq_lambda_f&& task) + { + ahpl_ref_mpq_lambda_f *task_obj = new ahpl_ref_mpq_lambda_f (std::move (task)); + int err = ahpl_mpq_run (q, AHPL_MPQ_INVALID, ref, f_name, ____mpq_f, 1, task_obj); + if (err < 0) + delete task_obj; + + return err; + } + +#ifdef __AHPL_MPQP_H__ + /* MPQP with specified ref encapsulations */ + static ahpl_mpq_t queue (ahpl_mpqp_t qp, ahpl_mpq_t dq, ahpl_ref_t ref, const char *f_name, ahpl_ref_mpq_lambda_f&& task) + { + ahpl_ref_mpq_lambda_f *task_obj = new ahpl_ref_mpq_lambda_f (std::move (task)); + ahpl_mpq_t qid = ahpl_mpqp_queue (qp, dq, ref, f_name, ____mpq_f, 1, task_obj); + if (ahpl_mpq_invalid (qid)) + delete task_obj; + + return qid; + } + + static ahpl_mpq_t call (ahpl_mpqp_t qp, ahpl_ref_t ref, const char *f_name, ahpl_ref_mpq_lambda_f&& task, void *task_result = NULL) + { + ahpl_ref_mpq_lambda_f *task_obj = new ahpl_ref_mpq_lambda_f (std::move (task)); + ahpl_mpq_t qid = ahpl_mpqp_call (qp, ref, f_name, ____mpq_f, 2, task_obj, task_result); + if (ahpl_mpq_invalid (qid)) + delete task_obj; + + return qid; + } + + static ahpl_mpq_t run (ahpl_mpqp_t qp, ahpl_ref_t ref, const char *f_name, ahpl_ref_mpq_lambda_f&& task) + { + ahpl_ref_mpq_lambda_f *task_obj = new ahpl_ref_mpq_lambda_f (std::move (task)); + ahpl_mpq_t qid = ahpl_mpqp_run (qp, AHPL_MPQ_INVALID, ref, f_name, ____mpq_f, 1, task_obj); + if (ahpl_mpq_invalid (qid)) + delete task_obj; + + return qid; + } + + static int pool_tail_queue (ahpl_mpqp_t qp, ahpl_mpq_t dq, ahpl_ref_t ref, const char *f_name, ahpl_ref_mpq_lambda_f&& task) + { + ahpl_ref_mpq_lambda_f *task_obj = new ahpl_ref_mpq_lambda_f (std::move (task)); + int err = ahpl_mpqp_pool_tail_queue (qp, dq, ref, f_name, ____mpq_f, 1, task_obj); + if (err < 0) + delete task_obj; + + return err; + } +#endif /* __AHPL_MPQP_H__ */ + + static void *call_result_var_addr (void) + { + void *var_addr; + + if (ahpl_mpq_run_func_arg (1, (uintptr_t *)&var_addr) < 0) + return NULL; + + return var_addr; + } + +private: + static void ____mpq_f (const ahpl_ts_t *queued_ts_p, ahpl_refobj_t robj, uintptr_t argc, uintptr_t argv []) + { + ahpl_ref_mpq_lambda_f *task_obj = reinterpret_cast(argv [0]); + ahpl_mpq_t done_qid = ahpl_mpq_run_func_done_qid (); + (*task_obj) (*queued_ts_p, robj); + if (ahpl_mpq_invalid (done_qid) || ahpl_is_free_only (robj)) { + /** + * We only free the task object when the running function has no + * done mpq id, due to the task object would be still in use if + * the function has a done mpq id when queuing back to the done + * mpq. + * -- Lionfore Hao Nov 19th, 2018 + **/ + delete task_obj; + } + } +#endif /* __AHPL_MPQ_H__ */ + +#ifdef __AHPL_ASYNC_H__ + /** + * The stackless coroutine like implementation in AHPL. We could not + * support the real stackless coroutine except in the language level, + * so we just provide similar equivalent functionals here. + **/ +public: + typedef std::function ahpl_async_prepare_lambda_f; + + int prepare (ahpl_stack_id_t stack_id, const char *f_name, ahpl_async_prepare_lambda_f&& task) + { + ahpl_async_prepare_lambda_f *prepare_f = new ahpl_async_prepare_lambda_f (std::move (task)); + int err = ahpl_async_prepare (stack_id, ref (), f_name, ____async_prepare_f, 1, prepare_f); + if (err < 0) + delete prepare_f; + + return err; + } + + static int prepare (ahpl_stack_id_t stack_id, ahpl_ref_t ref, const char *f_name, ahpl_async_prepare_lambda_f&& task) + { + ahpl_async_prepare_lambda_f *prepare_f = new ahpl_async_prepare_lambda_f (std::move (task)); + int err = ahpl_async_prepare (stack_id, ref, f_name, ____async_prepare_f, 1, prepare_f); + if (err < 0) + delete prepare_f; + + return err; + } + +private: + static int ____async_prepare_f (int free_only, uintptr_t argc, uintptr_t argv []) + { + ahpl_async_prepare_lambda_f *prepare_f = reinterpret_cast(argv [0]); + int err; + err = (*prepare_f) (free_only); + delete prepare_f; + return err; + } + +public: + typedef std::function ahpl_async_resume_lambda_f; + + int resume (ahpl_stack_id_t stack_id, const char *f_name, ahpl_async_resume_lambda_f&& task) + { + ahpl_async_resume_lambda_f *resume_f = new ahpl_async_resume_lambda_f (std::move (task)); + int err = ahpl_async_resume (stack_id, ref (), f_name, ____async_resume_f, 1, resume_f); + if (err < 0) + delete resume_f; + + return err; + } + + static int resume (ahpl_stack_id_t stack_id, ahpl_ref_t ref, const char *f_name, ahpl_async_resume_lambda_f&& task) + { + ahpl_async_resume_lambda_f *resume_f = new ahpl_async_resume_lambda_f (std::move (task)); + int err = ahpl_async_resume (stack_id, ref, f_name, ____async_resume_f, 1, resume_f); + if (err < 0) + delete resume_f; + + return err; + } + +private: + static void ____async_resume_f (int free_only, uintptr_t argc, uintptr_t argv []) + { + ahpl_async_resume_lambda_f *resume_f = reinterpret_cast(argv [0]); + (*resume_f) (free_only); + delete resume_f; + } +#endif /* __AHPL_ASYNC_H__ */ +#endif /* C++11 */ + +#if (__cplusplus >= 201103) || defined (_MSC_VER) +private: + ahpl_ref_class (const ahpl_ref_class &) = delete; + ahpl_ref_class (ahpl_ref_class &&) = delete; + ahpl_ref_class &operator = (const ahpl_ref_class &) = delete; + ahpl_ref_class &operator = (ahpl_ref_class &&) = delete; +#else +private: + ahpl_ref_class (const ahpl_ref_class &); + ahpl_ref_class &operator = (const ahpl_ref_class &); +#endif /* C++11 */ +}; + + +/** + * The T_ref_cls argument of this template must be + * ahpl_ref_class or its derivatives. + **/ +template +class ahpl_ref_unique_ptr { +private: + T_ref_cls *_ptr; + +public: + ahpl_ref_unique_ptr (): _ptr (NULL) {} + ahpl_ref_unique_ptr (T_ref_cls *p): _ptr (p) {} + + ahpl_ref_unique_ptr &operator = (T_ref_cls *p) + { + reset (); + _ptr = p; + return *this; + } + + T_ref_cls *operator -> () const + { + return _ptr; + } + + T_ref_cls *get () const + { + return _ptr; + } + + operator bool () const + { + return _ptr != NULL; + } + + T_ref_cls *release () + { + T_ref_cls *p = _ptr; + _ptr = NULL; + return p; + } + + void reset (T_ref_cls *p = NULL) + { + T_ref_cls *old = _ptr; + + /** + * We do the destroy and not delete the object + * before we set the pointer to the new value, + * this is very important to make sure that no + * any async operation is executing. + **/ + if (old != NULL) + old->destroy (false/* not delete */); + + _ptr = p; + + /** + * The destroy with delete operation must be + * the last action, and don't touch any member + * of this object anymore after it. + **/ + if (old != NULL) + old->destroy (true/* do delete */); + } + + ~ahpl_ref_unique_ptr () + { + reset (); + } + +#if (__cplusplus >= 201103) || defined (_MSC_VER) +private: + ahpl_ref_unique_ptr (const ahpl_ref_unique_ptr &) = delete; + ahpl_ref_unique_ptr &operator = (const ahpl_ref_unique_ptr &) = delete; + +public: + ahpl_ref_unique_ptr (ahpl_ref_unique_ptr &&src): _ptr (src.release ()) {} + ahpl_ref_unique_ptr &operator = (ahpl_ref_unique_ptr &&ptr) + { + reset (ptr.release ()); + return *this; + } +#else +private: + ahpl_ref_unique_ptr (const ahpl_ref_unique_ptr &); + ahpl_ref_unique_ptr &operator = (const ahpl_ref_unique_ptr &); +#endif /* C++11 */ +}; + + +template +inline bool operator == (const ahpl_ref_unique_ptr &ptr, intptr_t _null) +{ + return ptr.get () == (T_ref_cls *)_null; +} + +template +inline bool operator != (const ahpl_ref_unique_ptr &ptr, intptr_t _null) +{ + return ptr.get () != (T_ref_cls *)_null; +} + +template +inline bool operator == (intptr_t _null, const ahpl_ref_unique_ptr &ptr) +{ + return (T_ref_cls *)_null == ptr.get (); +} + +template +inline bool operator != (intptr_t _null, const ahpl_ref_unique_ptr &ptr) +{ + return (T_ref_cls *)_null != ptr.get (); +} + +#if (__cplusplus >= 201103) || defined (_MSC_VER) +template +inline bool operator == (const ahpl_ref_unique_ptr &ptr, nullptr_t) +{ + return !ptr; +} + +template +inline bool operator != (const ahpl_ref_unique_ptr &ptr, nullptr_t) +{ + return ptr; +} + +template +inline bool operator == (nullptr_t, const ahpl_ref_unique_ptr &ptr) +{ + return !ptr; +} + +template +inline bool operator != (nullptr_t, const ahpl_ref_unique_ptr &ptr) +{ + return ptr; +} +#endif /* C++11 */ + + +typedef ahpl_ref_unique_ptr ahpl_ref_class_unique_ptr; + + +#endif /* __AHPL_REF_OBJ_CPP_H__ */ \ No newline at end of file diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/CMakeLists.txt b/Android/APIExample/agora-simple-filter/src/main/cpp/CMakeLists.txt index 2f2c24c33..977ea6581 100644 --- a/Android/APIExample/agora-simple-filter/src/main/cpp/CMakeLists.txt +++ b/Android/APIExample/agora-simple-filter/src/main/cpp/CMakeLists.txt @@ -70,6 +70,7 @@ find_library( # Sets the name of the path variable. # build script, prebuilt third-party libraries, or system libraries. target_include_directories(agora-simple-filter PRIVATE ${PROJECT_SOURCE_DIR}) +target_include_directories(agora-simple-filter PRIVATE ${PROJECT_SOURCE_DIR}/AgoraRtcKit) target_link_libraries( # Specifies the target library. agora-simple-filter 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 81580b034..a3b4647a6 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 @@ -80,7 +80,7 @@ #endif #endif -#define INVALID_DISPLAY_ID 0xffff +#define INVALID_DISPLAY_ID (-2) namespace agora { namespace util { @@ -92,16 +92,16 @@ class AutoPtr { typedef T* pointer_type; public: - explicit AutoPtr(pointer_type p = NULL) : ptr_(p) {} + explicit AutoPtr(pointer_type p = OPTIONAL_NULLPTR) : ptr_(p) {} ~AutoPtr() { if (ptr_) { ptr_->release(); - ptr_ = NULL; + ptr_ = OPTIONAL_NULLPTR; } } - operator bool() const { return (ptr_ != NULL); } + operator bool() const { return (ptr_ != OPTIONAL_NULLPTR); } value_type& operator*() const { return *get(); } @@ -115,7 +115,7 @@ class AutoPtr { return ret; } - void reset(pointer_type ptr = NULL) { + void reset(pointer_type ptr = OPTIONAL_NULLPTR) { if (ptr != ptr_ && ptr_) { ptr_->release(); } @@ -125,12 +125,12 @@ class AutoPtr { template bool queryInterface(C1* c, C2 iid) { - pointer_type p = NULL; + pointer_type p = OPTIONAL_NULLPTR; if (c && !c->queryInterface(iid, reinterpret_cast(&p))) { reset(p); } - return (p != NULL); + return (p != OPTIONAL_NULLPTR); } private: @@ -153,7 +153,7 @@ class CopyableAutoPtr : public AutoPtr { return *this; } pointer_type clone() const { - if (!this->get()) return NULL; + if (!this->get()) return OPTIONAL_NULLPTR; return this->get()->clone(); } }; @@ -197,7 +197,7 @@ class AOutputIterator { typedef const value_type& const_reference; typedef value_type* pointer; typedef const value_type* const_pointer; - explicit AOutputIterator(IIterator* it = NULL) : p(it) {} + explicit AOutputIterator(IIterator* it = OPTIONAL_NULLPTR) : p(it) {} ~AOutputIterator() { if (p) p->release(); } @@ -215,7 +215,7 @@ class AOutputIterator { bool operator!=(const AOutputIterator& rhs) const { return !this->operator==(rhs); } reference operator*() { return *reinterpret_cast(p->current()); } const_reference operator*() const { return *reinterpret_cast(p->const_current()); } - bool valid() const { return p && p->current() != NULL; } + bool valid() const { return p && p->current() != OPTIONAL_NULLPTR; } }; template @@ -234,16 +234,16 @@ class AList { typedef const AOutputIterator const_iterator; public: - AList() : container(NULL), owner(false) {} + AList() : container(OPTIONAL_NULLPTR), owner(false) {} AList(IContainer* c, bool take_ownership) : container(c), owner(take_ownership) {} ~AList() { reset(); } - void reset(IContainer* c = NULL, bool take_ownership = false) { + void reset(IContainer* c = OPTIONAL_NULLPTR, bool take_ownership = false) { if (owner && container) container->release(); container = c; owner = take_ownership; } - iterator begin() { return container ? iterator(container->begin()) : iterator(NULL); } - iterator end() { return iterator(NULL); } + iterator begin() { return container ? iterator(container->begin()) : iterator(OPTIONAL_NULLPTR); } + iterator end() { return iterator(OPTIONAL_NULLPTR); } size_type size() const { return container ? container->size() : 0; } bool empty() const { return size() == 0; } }; @@ -731,10 +731,6 @@ enum ERROR_CODE_TYPE { * 1501: Video Device Module: The camera is not authorized. */ ERR_VDM_CAMERA_NOT_AUTHORIZED = 1501, - /** - * 2007: Audio Device Module: An error occurs in starting the application loopback. - */ - ERR_ADM_APPLICATION_LOOPBACK = 2007, }; enum LICENSE_ERROR_TYPE { @@ -857,9 +853,9 @@ enum INTERFACE_ID_TYPE { AGORA_IID_CLOUD_SPATIAL_AUDIO = 10, AGORA_IID_LOCAL_SPATIAL_AUDIO = 11, AGORA_IID_STATE_SYNC = 13, - AGORA_IID_METACHAT_SERVICE = 14, + AGORA_IID_META_SERVICE = 14, AGORA_IID_MUSIC_CONTENT_CENTER = 15, - AGORA_IID_H265_TRANSCODER = 16, + AGORA_IID_H265_TRANSCODER = 16, }; /** @@ -1267,7 +1263,7 @@ struct SenderOptions { SenderOptions() : ccMode(CC_ENABLED), - codecType(VIDEO_CODEC_H264), + codecType(VIDEO_CODEC_H265), targetBitrate(6500) {} }; @@ -1542,12 +1538,23 @@ struct VideoSubscriptionOptions { VideoSubscriptionOptions() {} }; + +/** The maximum length of the user account. + */ +enum MAX_USER_ACCOUNT_LENGTH_TYPE +{ + /** The maximum length of the user account is 256 bytes. + */ + MAX_USER_ACCOUNT_LENGTH = 256 +}; + /** * The definition of the EncodedVideoFrameInfo struct, which contains the information of the external encoded video frame. */ struct EncodedVideoFrameInfo { EncodedVideoFrameInfo() - : codecType(VIDEO_CODEC_H264), + : uid(0), + codecType(VIDEO_CODEC_H264), width(0), height(0), framesPerSecond(0), @@ -1556,11 +1563,11 @@ struct EncodedVideoFrameInfo { trackId(0), captureTimeMs(0), decodeTimeMs(0), - uid(0), streamType(VIDEO_STREAM_HIGH) {} EncodedVideoFrameInfo(const EncodedVideoFrameInfo& rhs) - : codecType(rhs.codecType), + : uid(rhs.uid), + codecType(rhs.codecType), width(rhs.width), height(rhs.height), framesPerSecond(rhs.framesPerSecond), @@ -1569,11 +1576,11 @@ struct EncodedVideoFrameInfo { trackId(rhs.trackId), captureTimeMs(rhs.captureTimeMs), decodeTimeMs(rhs.decodeTimeMs), - uid(rhs.uid), streamType(rhs.streamType) {} EncodedVideoFrameInfo& operator=(const EncodedVideoFrameInfo& rhs) { if (this == &rhs) return *this; + uid = rhs.uid; codecType = rhs.codecType; width = rhs.width; height = rhs.height; @@ -1583,12 +1590,16 @@ struct EncodedVideoFrameInfo { trackId = rhs.trackId; captureTimeMs = rhs.captureTimeMs; decodeTimeMs = rhs.decodeTimeMs; - uid = rhs.uid; streamType = rhs.streamType; return *this; } + + /** + * ID of the user that pushes the the external encoded video frame.. + */ + uid_t uid; /** - * The codec type of the local video stream. See #VIDEO_CODEC_TYPE. The default value is `VIDEO_CODEC_H264 (2)`. + * The codec type of the local video stream. See #VIDEO_CODEC_TYPE. The default value is `VIDEO_CODEC_H265 (3)`. */ VIDEO_CODEC_TYPE codecType; /** @@ -1626,16 +1637,13 @@ struct EncodedVideoFrameInfo { * The timestamp for decoding the video. */ int64_t decodeTimeMs; - /** - * ID of the user that pushes the the external encoded video frame.. - */ - uid_t uid; /** * The stream type of video frame. */ VIDEO_STREAM_TYPE streamType; }; + /** * Video compression preference. */ @@ -1750,6 +1758,8 @@ struct CodecCapInfo { int codecCapMask; /** The codec capability level, estimated based on the device hardware.*/ CodecCapLevels codecLevels; + + CodecCapInfo(): codecType(VIDEO_CODEC_NONE), codecCapMask(0) {} }; /** @@ -1863,7 +1873,7 @@ struct VideoEncoderConfiguration { AdvanceOptions advanceOptions; VideoEncoderConfiguration(const VideoDimensions& d, int f, int b, ORIENTATION_MODE m, VIDEO_MIRROR_MODE_TYPE mirror = VIDEO_MIRROR_MODE_DISABLED) - : codecType(VIDEO_CODEC_H264), + : codecType(VIDEO_CODEC_H265), dimensions(d), frameRate(f), bitrate(b), @@ -1873,7 +1883,7 @@ struct VideoEncoderConfiguration { mirrorMode(mirror), advanceOptions(PREFER_AUTO, PREFER_LOW_LATENCY) {} VideoEncoderConfiguration(int width, int height, int f, int b, ORIENTATION_MODE m, VIDEO_MIRROR_MODE_TYPE mirror = VIDEO_MIRROR_MODE_DISABLED) - : codecType(VIDEO_CODEC_H264), + : codecType(VIDEO_CODEC_H265), dimensions(width, height), frameRate(f), bitrate(b), @@ -1893,7 +1903,7 @@ struct VideoEncoderConfiguration { mirrorMode(config.mirrorMode), advanceOptions(config.advanceOptions) {} VideoEncoderConfiguration() - : codecType(VIDEO_CODEC_H264), + : codecType(VIDEO_CODEC_H265), dimensions(FRAME_WIDTH_960, FRAME_HEIGHT_540), frameRate(FRAME_RATE_FPS_15), bitrate(STANDARD_BITRATE), @@ -2583,6 +2593,29 @@ enum VIDEO_APPLICATION_SCENARIO_TYPE { APPLICATION_SCENARIO_MEETING = 1, }; +/** + * The video QoE preference type. + */ +enum VIDEO_QOE_PREFERENCE_TYPE { + /** + * 1: Default QoE type, balance the delay, picture quality and fluency. + */ + VIDEO_QOE_PREFERENCE_BALANCE = 1, + /** + * 2: lower the e2e delay. + */ + VIDEO_QOE_PREFERENCE_DELAY_FIRST = 2, + /** + * 3: picture quality. + */ + VIDEO_QOE_PREFERENCE_PICTURE_QUALITY_FIRST = 3, + /** + * 4: more fluency. + */ + VIDEO_QOE_PREFERENCE_FLUENCY_FIRST = 4, + +}; + /** * The brightness level of the video image captured by the local camera. */ @@ -2627,50 +2660,50 @@ enum LOCAL_AUDIO_STREAM_STATE { /** * Local audio state error codes. */ -enum LOCAL_AUDIO_STREAM_ERROR { +enum LOCAL_AUDIO_STREAM_REASON { /** * 0: The local audio is normal. */ - LOCAL_AUDIO_STREAM_ERROR_OK = 0, + LOCAL_AUDIO_STREAM_REASON_OK = 0, /** * 1: No specified reason for the local audio failure. Remind your users to try to rejoin the channel. */ - LOCAL_AUDIO_STREAM_ERROR_FAILURE = 1, + LOCAL_AUDIO_STREAM_REASON_FAILURE = 1, /** * 2: No permission to use the local audio device. Remind your users to grant permission. */ - LOCAL_AUDIO_STREAM_ERROR_DEVICE_NO_PERMISSION = 2, + LOCAL_AUDIO_STREAM_REASON_DEVICE_NO_PERMISSION = 2, /** * 3: (Android and iOS only) The local audio capture device is used. Remind your users to check * whether another application occupies the microphone. Local audio capture automatically resume * after the microphone is idle for about five seconds. You can also try to rejoin the channel * after the microphone is idle. */ - LOCAL_AUDIO_STREAM_ERROR_DEVICE_BUSY = 3, + LOCAL_AUDIO_STREAM_REASON_DEVICE_BUSY = 3, /** * 4: The local audio capture failed. */ - LOCAL_AUDIO_STREAM_ERROR_RECORD_FAILURE = 4, + LOCAL_AUDIO_STREAM_REASON_RECORD_FAILURE = 4, /** * 5: The local audio encoding failed. */ - LOCAL_AUDIO_STREAM_ERROR_ENCODE_FAILURE = 5, + LOCAL_AUDIO_STREAM_REASON_ENCODE_FAILURE = 5, /** 6: The SDK cannot find the local audio recording device. */ - LOCAL_AUDIO_STREAM_ERROR_NO_RECORDING_DEVICE = 6, + LOCAL_AUDIO_STREAM_REASON_NO_RECORDING_DEVICE = 6, /** 7: The SDK cannot find the local audio playback device. */ - LOCAL_AUDIO_STREAM_ERROR_NO_PLAYOUT_DEVICE = 7, + LOCAL_AUDIO_STREAM_REASON_NO_PLAYOUT_DEVICE = 7, /** * 8: The local audio capturing is interrupted by the system call. */ - LOCAL_AUDIO_STREAM_ERROR_INTERRUPTED = 8, + LOCAL_AUDIO_STREAM_REASON_INTERRUPTED = 8, /** 9: An invalid audio capture device ID. */ - LOCAL_AUDIO_STREAM_ERROR_RECORD_INVALID_ID = 9, + LOCAL_AUDIO_STREAM_REASON_RECORD_INVALID_ID = 9, /** 10: An invalid audio playback device ID. */ - LOCAL_AUDIO_STREAM_ERROR_PLAYOUT_INVALID_ID = 10, + LOCAL_AUDIO_STREAM_REASON_PLAYOUT_INVALID_ID = 10, }; /** Local video state types. @@ -2698,73 +2731,73 @@ enum LOCAL_VIDEO_STREAM_STATE { /** * Local video state error codes. */ -enum LOCAL_VIDEO_STREAM_ERROR { +enum LOCAL_VIDEO_STREAM_REASON { /** * 0: The local video is normal. */ - LOCAL_VIDEO_STREAM_ERROR_OK = 0, + LOCAL_VIDEO_STREAM_REASON_OK = 0, /** * 1: No specified reason for the local video failure. */ - LOCAL_VIDEO_STREAM_ERROR_FAILURE = 1, + LOCAL_VIDEO_STREAM_REASON_FAILURE = 1, /** * 2: No permission to use the local video capturing device. Remind the user to grant permission * and rejoin the channel. */ - LOCAL_VIDEO_STREAM_ERROR_DEVICE_NO_PERMISSION = 2, + LOCAL_VIDEO_STREAM_REASON_DEVICE_NO_PERMISSION = 2, /** * 3: The local video capturing device is in use. Remind the user to check whether another * application occupies the camera. */ - LOCAL_VIDEO_STREAM_ERROR_DEVICE_BUSY = 3, + LOCAL_VIDEO_STREAM_REASON_DEVICE_BUSY = 3, /** * 4: The local video capture fails. Remind the user to check whether the video capture device * is working properly or the camera is occupied by another application, and then to rejoin the * channel. */ - LOCAL_VIDEO_STREAM_ERROR_CAPTURE_FAILURE = 4, + LOCAL_VIDEO_STREAM_REASON_CAPTURE_FAILURE = 4, /** * 5: The local video encoder is not supported. */ - LOCAL_VIDEO_STREAM_ERROR_ENCODE_FAILURE = 5, + LOCAL_VIDEO_STREAM_REASON_CODEC_NOT_SUPPORT = 5, /** * 6: (iOS only) The app is in the background. Remind the user that video capture cannot be * performed normally when the app is in the background. */ - LOCAL_VIDEO_STREAM_ERROR_CAPTURE_INBACKGROUND = 6, + LOCAL_VIDEO_STREAM_REASON_CAPTURE_INBACKGROUND = 6, /** * 7: (iOS only) The current application window is running in Slide Over, Split View, or Picture * in Picture mode, and another app is occupying the camera. Remind the user that the application * cannot capture video properly when the app is running in Slide Over, Split View, or Picture in * Picture mode and another app is occupying the camera. */ - LOCAL_VIDEO_STREAM_ERROR_CAPTURE_MULTIPLE_FOREGROUND_APPS = 7, + LOCAL_VIDEO_STREAM_REASON_CAPTURE_MULTIPLE_FOREGROUND_APPS = 7, /** * 8: Fails to find a local video capture device. Remind the user to check whether the camera is * connected to the device properly or the camera is working properly, and then to rejoin the * channel. */ - LOCAL_VIDEO_STREAM_ERROR_DEVICE_NOT_FOUND = 8, + LOCAL_VIDEO_STREAM_REASON_DEVICE_NOT_FOUND = 8, /** * 9: (macOS only) The video capture device currently in use is disconnected (such as being * unplugged). */ - LOCAL_VIDEO_STREAM_ERROR_DEVICE_DISCONNECTED = 9, + LOCAL_VIDEO_STREAM_REASON_DEVICE_DISCONNECTED = 9, /** * 10: (macOS and Windows only) The SDK cannot find the video device in the video device list. * Check whether the ID of the video device is valid. */ - LOCAL_VIDEO_STREAM_ERROR_DEVICE_INVALID_ID = 10, + LOCAL_VIDEO_STREAM_REASON_DEVICE_INVALID_ID = 10, /** * 101: The current video capture device is unavailable due to excessive system pressure. */ - LOCAL_VIDEO_STREAM_ERROR_DEVICE_SYSTEM_PRESSURE = 101, + LOCAL_VIDEO_STREAM_REASON_DEVICE_SYSTEM_PRESSURE = 101, /** * 11: (macOS only) The shared window is minimized when you call `startScreenCaptureByWindowId` * to share a window. The SDK cannot share a minimized window. You can cancel the minimization * of this window at the application layer, for example by maximizing this window. */ - LOCAL_VIDEO_STREAM_ERROR_SCREEN_CAPTURE_WINDOW_MINIMIZED = 11, + LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_WINDOW_MINIMIZED = 11, /** * 12: (macOS and Windows only) The error code indicates that a window shared by the window ID * has been closed or a full-screen window shared by the window ID has exited full-screen mode. @@ -2779,31 +2812,38 @@ enum LOCAL_VIDEO_STREAM_ERROR { * then shares the window of the web video or document. After the user exits full-screen mode, * the SDK reports this error code. */ - LOCAL_VIDEO_STREAM_ERROR_SCREEN_CAPTURE_WINDOW_CLOSED = 12, + LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_WINDOW_CLOSED = 12, /** 13: The local screen capture window is occluded. */ - LOCAL_VIDEO_STREAM_ERROR_SCREEN_CAPTURE_WINDOW_OCCLUDED = 13, + LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_WINDOW_OCCLUDED = 13, /** 20: The local screen capture window is not supported. */ - LOCAL_VIDEO_STREAM_ERROR_SCREEN_CAPTURE_WINDOW_NOT_SUPPORTED = 20, + LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_WINDOW_NOT_SUPPORTED = 20, /** 21: The screen capture fails. */ - LOCAL_VIDEO_STREAM_ERROR_SCREEN_CAPTURE_FAILURE = 21, + LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_FAILURE = 21, /** 22: No permision to capture screen. */ - LOCAL_VIDEO_STREAM_ERROR_SCREEN_CAPTURE_NO_PERMISSION = 22, - /** - * 23: The screen capture paused. + LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_NO_PERMISSION = 22, + /** + * 24: (Windows Only) An unexpected error (possibly due to window block failure) occurs during the screen + * sharing process, resulting in performance degradation. However, the screen sharing process itself is + * functioning normally. + */ + LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_AUTO_FALLBACK = 24, + /** 25: (Windows only) The local screen capture window is currently hidden and not visible on the desktop. */ + LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_WINDOW_HIDDEN = 25, + /** 26: (Windows only) The local screen capture window is recovered from its hidden state. */ + LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_WINDOW_RECOVER_FROM_HIDDEN = 26, + /** 27:(Windows only) The window is recovered from miniminzed */ + LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_WINDOW_RECOVER_FROM_MINIMIZED = 27, + /** + * 28: The screen capture paused. * * Common scenarios for reporting this error code: * - When the desktop switch to the secure desktop such as UAC dialog or the Winlogon desktop on * Windows platform, the SDK reports this error code. */ - LOCAL_VIDEO_STREAM_ERROR_SCREEN_CAPTURE_PAUSED = 23, - /** 24: The screen capture is resumed. */ - LOCAL_VIDEO_STREAM_ERROR_SCREEN_CAPTURE_RESUMED = 24, - /** 25: (Windows only) The local screen capture window is currently hidden and not visible on the desktop. */ - LOCAL_VIDEO_STREAM_ERROR_SCREEN_CAPTURE_WINDOW_HIDDEN = 25, - /** 26: (Windows only) The local screen capture window is recovered from its hidden state. */ - LOCAL_VIDEO_STREAM_ERROR_SCREEN_CAPTURE_WINDOW_RECOVER_FROM_HIDDEN = 26, - /** 27:(Windows only) The window is recovered from miniminzed */ - LOCAL_VIDEO_STREAM_ERROR_SCREEN_CAPTURE_WINDOW_RECOVER_FROM_MINIMIZED = 27, + LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_PAUSED = 28, + /** 29: The screen capture is resumed. */ + LOCAL_VIDEO_STREAM_REASON_SCREEN_CAPTURE_RESUMED = 29, + }; /** @@ -2991,7 +3031,6 @@ enum REMOTE_USER_STATE { * The remote user has enabled the local video capturing. */ USER_STATE_ENABLE_LOCAL_VIDEO = (1 << 8), - }; /** @@ -3001,7 +3040,7 @@ enum REMOTE_USER_STATE { struct VideoTrackInfo { VideoTrackInfo() : isLocal(false), ownerUid(0), trackId(0), channelId(OPTIONAL_NULLPTR) - , streamType(VIDEO_STREAM_HIGH), codecType(VIDEO_CODEC_H264) + , streamType(VIDEO_STREAM_HIGH), codecType(VIDEO_CODEC_H265) , encodedFrameOnly(false), sourceType(VIDEO_SOURCE_CAMERA_PRIMARY) , observationPosition(agora::media::base::POSITION_POST_CAPTURER) {} /** @@ -3014,7 +3053,6 @@ struct VideoTrackInfo { * ID of the user who publishes the video track. */ uid_t ownerUid; - /** * ID of the video track. */ @@ -3145,7 +3183,7 @@ class IPacketObserver { */ unsigned int size; - Packet() : buffer(NULL), size(0) {} + Packet() : buffer(OPTIONAL_NULLPTR), size(0) {} }; /** * Occurs when the SDK is ready to send the audio packet. @@ -3278,6 +3316,18 @@ struct LocalAudioStats * The audio delay of the device, contains record and playout delay */ int audioDeviceDelay; + /** + * The playout delay of the device + */ + int audioPlayoutDelay; + /** + * The signal delay estimated from audio in-ear monitoring (ms). + */ + int earMonitorDelay; + /** + * The signal delay estimated during the AEC process from nearin and farin (ms). + */ + int aecEstimatedDelay; }; @@ -3316,74 +3366,74 @@ enum RTMP_STREAM_PUBLISH_STATE { /** * Error codes of the RTMP or RTMPS streaming. */ -enum RTMP_STREAM_PUBLISH_ERROR_TYPE { +enum RTMP_STREAM_PUBLISH_REASON { /** * 0: The RTMP or RTMPS streaming publishes successfully. */ - RTMP_STREAM_PUBLISH_ERROR_OK = 0, + RTMP_STREAM_PUBLISH_REASON_OK = 0, /** * 1: Invalid argument used. If, for example, you do not call the `setLiveTranscoding` method to configure the LiveTranscoding parameters before calling the addPublishStreamUrl method, * the SDK returns this error. Check whether you set the parameters in the `setLiveTranscoding` method properly. */ - RTMP_STREAM_PUBLISH_ERROR_INVALID_ARGUMENT = 1, + RTMP_STREAM_PUBLISH_REASON_INVALID_ARGUMENT = 1, /** * 2: The RTMP or RTMPS streaming is encrypted and cannot be published. */ - RTMP_STREAM_PUBLISH_ERROR_ENCRYPTED_STREAM_NOT_ALLOWED = 2, + RTMP_STREAM_PUBLISH_REASON_ENCRYPTED_STREAM_NOT_ALLOWED = 2, /** * 3: Timeout for the RTMP or RTMPS streaming. Call the `addPublishStreamUrl` method to publish the streaming again. */ - RTMP_STREAM_PUBLISH_ERROR_CONNECTION_TIMEOUT = 3, + RTMP_STREAM_PUBLISH_REASON_CONNECTION_TIMEOUT = 3, /** * 4: An error occurs in Agora's streaming server. Call the `addPublishStreamUrl` method to publish the streaming again. */ - RTMP_STREAM_PUBLISH_ERROR_INTERNAL_SERVER_ERROR = 4, + RTMP_STREAM_PUBLISH_REASON_INTERNAL_SERVER_ERROR = 4, /** * 5: An error occurs in the CDN server. */ - RTMP_STREAM_PUBLISH_ERROR_RTMP_SERVER_ERROR = 5, + RTMP_STREAM_PUBLISH_REASON_RTMP_SERVER_ERROR = 5, /** * 6: The RTMP or RTMPS streaming publishes too frequently. */ - RTMP_STREAM_PUBLISH_ERROR_TOO_OFTEN = 6, + RTMP_STREAM_PUBLISH_REASON_TOO_OFTEN = 6, /** * 7: The host publishes more than 10 URLs. Delete the unnecessary URLs before adding new ones. */ - RTMP_STREAM_PUBLISH_ERROR_REACH_LIMIT = 7, + RTMP_STREAM_PUBLISH_REASON_REACH_LIMIT = 7, /** * 8: The host manipulates other hosts' URLs. Check your app logic. */ - RTMP_STREAM_PUBLISH_ERROR_NOT_AUTHORIZED = 8, + RTMP_STREAM_PUBLISH_REASON_NOT_AUTHORIZED = 8, /** * 9: Agora's server fails to find the RTMP or RTMPS streaming. */ - RTMP_STREAM_PUBLISH_ERROR_STREAM_NOT_FOUND = 9, + RTMP_STREAM_PUBLISH_REASON_STREAM_NOT_FOUND = 9, /** * 10: The format of the RTMP or RTMPS streaming URL is not supported. Check whether the URL format is correct. */ - RTMP_STREAM_PUBLISH_ERROR_FORMAT_NOT_SUPPORTED = 10, + RTMP_STREAM_PUBLISH_REASON_FORMAT_NOT_SUPPORTED = 10, /** * 11: The user role is not host, so the user cannot use the CDN live streaming function. Check your application code logic. */ - RTMP_STREAM_PUBLISH_ERROR_NOT_BROADCASTER = 11, // Note: match to ERR_PUBLISH_STREAM_NOT_BROADCASTER in AgoraBase.h + RTMP_STREAM_PUBLISH_REASON_NOT_BROADCASTER = 11, // Note: match to ERR_PUBLISH_STREAM_NOT_BROADCASTER in AgoraBase.h /** * 13: The `updateRtmpTranscoding` or `setLiveTranscoding` method is called to update the transcoding configuration in a scenario where there is streaming without transcoding. Check your application code logic. */ - RTMP_STREAM_PUBLISH_ERROR_TRANSCODING_NO_MIX_STREAM = 13, // Note: match to ERR_PUBLISH_STREAM_TRANSCODING_NO_MIX_STREAM in AgoraBase.h + RTMP_STREAM_PUBLISH_REASON_TRANSCODING_NO_MIX_STREAM = 13, // Note: match to ERR_PUBLISH_STREAM_TRANSCODING_NO_MIX_STREAM in AgoraBase.h /** * 14: Errors occurred in the host's network. */ - RTMP_STREAM_PUBLISH_ERROR_NET_DOWN = 14, // Note: match to ERR_NET_DOWN in AgoraBase.h + RTMP_STREAM_PUBLISH_REASON_NET_DOWN = 14, // Note: match to ERR_NET_DOWN in AgoraBase.h /** * 15: Your App ID does not have permission to use the CDN live streaming function. */ - RTMP_STREAM_PUBLISH_ERROR_INVALID_APPID = 15, // Note: match to ERR_PUBLISH_STREAM_APPID_INVALID in AgoraBase.h + RTMP_STREAM_PUBLISH_REASON_INVALID_APPID = 15, // Note: match to ERR_PUBLISH_STREAM_APPID_INVALID in AgoraBase.h /** invalid privilege. */ - RTMP_STREAM_PUBLISH_ERROR_INVALID_PRIVILEGE = 16, + RTMP_STREAM_PUBLISH_REASON_INVALID_PRIVILEGE = 16, /** * 100: The streaming has been stopped normally. After you call `removePublishStreamUrl` to stop streaming, the SDK returns this value. */ - RTMP_STREAM_UNPUBLISH_ERROR_OK = 100, + RTMP_STREAM_UNPUBLISH_REASON_OK = 100, }; /** Events during the RTMP or RTMPS streaming. */ @@ -3445,7 +3495,7 @@ typedef struct RtcImage { */ double alpha; - RtcImage() : url(NULL), x(0), y(0), width(0), height(0), zOrder(0), alpha(1.0) {} + RtcImage() : url(OPTIONAL_NULLPTR), x(0), y(0), width(0), height(0), zOrder(0), alpha(1.0) {} } RtcImage; /** * The configuration for advanced features of the RTMP or RTMPS streaming with transcoding. @@ -3453,7 +3503,7 @@ typedef struct RtcImage { * If you want to enable the advanced features of streaming with transcoding, contact support@agora.io. */ struct LiveStreamAdvancedFeature { - LiveStreamAdvancedFeature() : featureName(NULL), opened(false) {} + LiveStreamAdvancedFeature() : featureName(OPTIONAL_NULLPTR), opened(false) {} LiveStreamAdvancedFeature(const char* feat_name, bool open) : featureName(feat_name), opened(open) {} /** The advanced feature for high-quality video with a lower bitrate. */ // static const char* LBHQ = "lbhq"; @@ -3573,6 +3623,7 @@ struct TranscodingUser { * @note If the value is not `0`, a special player is required. */ int audioChannel; + TranscodingUser() : uid(0), x(0), @@ -3692,7 +3743,31 @@ struct LiveTranscoding { /** The number of enabled advanced features. The default value is 0. */ unsigned int advancedFeatureCount; - LiveTranscoding() : width(360), height(640), videoBitrate(400), videoFramerate(15), lowLatency(false), videoGop(30), videoCodecProfile(VIDEO_CODEC_PROFILE_HIGH), backgroundColor(0x000000), videoCodecType(VIDEO_CODEC_H264_FOR_STREAM), userCount(0), transcodingUsers(NULL), transcodingExtraInfo(NULL), metadata(NULL), watermark(NULL), watermarkCount(0), backgroundImage(NULL), backgroundImageCount(0), audioSampleRate(AUDIO_SAMPLE_RATE_48000), audioBitrate(48), audioChannels(1), audioCodecProfile(AUDIO_CODEC_PROFILE_LC_AAC), advancedFeatures(NULL), advancedFeatureCount(0) {} + + LiveTranscoding() + : width(360), + height(640), + videoBitrate(400), + videoFramerate(15), + lowLatency(false), + videoGop(30), + videoCodecProfile(VIDEO_CODEC_PROFILE_HIGH), + backgroundColor(0x000000), + videoCodecType(VIDEO_CODEC_H264_FOR_STREAM), + userCount(0), + transcodingUsers(OPTIONAL_NULLPTR), + transcodingExtraInfo(OPTIONAL_NULLPTR), + metadata(OPTIONAL_NULLPTR), + watermark(OPTIONAL_NULLPTR), + watermarkCount(0), + backgroundImage(OPTIONAL_NULLPTR), + backgroundImageCount(0), + audioSampleRate(AUDIO_SAMPLE_RATE_48000), + audioBitrate(48), + audioChannels(1), + audioCodecProfile(AUDIO_CODEC_PROFILE_LC_AAC), + advancedFeatures(OPTIONAL_NULLPTR), + advancedFeatureCount(0) {} }; /** @@ -3754,7 +3829,7 @@ struct TranscodingVideoStream { TranscodingVideoStream() : sourceType(VIDEO_SOURCE_CAMERA_PRIMARY), remoteUserUid(0), - imageUrl(NULL), + imageUrl(OPTIONAL_NULLPTR), x(0), y(0), width(0), @@ -3764,7 +3839,6 @@ struct TranscodingVideoStream { mirror(false) {} }; - /** * The configuration of the video mixing on the local client. */ @@ -3788,11 +3862,7 @@ struct LocalTranscoderConfiguration { */ bool syncWithPrimaryCamera; - LocalTranscoderConfiguration() - : streamCount(0), - videoInputStreams(NULL), - videoOutputConfiguration(), - syncWithPrimaryCamera(true) {} + LocalTranscoderConfiguration() : streamCount(0), videoInputStreams(OPTIONAL_NULLPTR), videoOutputConfiguration(), syncWithPrimaryCamera(true) {} }; enum VIDEO_TRANSCODER_ERROR { @@ -4014,10 +4084,18 @@ enum CONNECTION_CHANGED_REASON_TYPE * 21: The connection is failed due to license validation failure. */ CONNECTION_CHANGED_LICENSE_VALIDATION_FAILURE = 21, - /** + /* * 22: The connection is failed due to certification verify failure. */ CONNECTION_CHANGED_CERTIFICATION_VERYFY_FAILURE = 22, + /** + * 23: The connection is failed due to the lack of granting permission to the stream channel. + */ + CONNECTION_CHANGED_STREAM_CHANNEL_NOT_AVAILABLE = 23, + /** + * 24: The connection is failed due to join channel with an inconsistent appid. + */ + CONNECTION_CHANGED_INCONSISTENT_APPID = 24, }; /** @@ -4156,14 +4234,19 @@ enum VIDEO_VIEW_SETUP_MODE { * Attributes of video canvas object. */ struct VideoCanvas { - /** - * Video display window. - */ - view_t view; /** * The user id of local video. */ uid_t uid; + + /** + * The uid of video stream composing the video stream from transcoder which will be drawn on this video canvas. + */ + uid_t subviewUid; + /** + * Video display window. + */ + view_t view; /** * A RGBA value indicates background color of the render view. Defaults to 0x00000000. */ @@ -4205,28 +4288,37 @@ struct VideoCanvas { * The default value is empty(that is, if it has zero width or height), which means no cropping. */ Rectangle cropArea; - /** - * Whether to apply alpha mask to the video frame if exsit: - * true: Apply alpha mask to video frame. - * false: (Default) Do not apply alpha mask to video frame. - */ + * Whether to apply alpha mask to the video frame if exsit: + * true: Apply alpha mask to video frame. + * false: (Default) Do not apply alpha mask to video frame. + */ bool enableAlphaMask; - + /** + * The video frame position in pipeline. See \ref VIDEO_MODULE_POSITION "VIDEO_MODULE_POSITION". + * The default value is POSITION_POST_CAPTURER. + */ + media::base::VIDEO_MODULE_POSITION position; + VideoCanvas() - : view(NULL), uid(0), backgroundColor(0x00000000), renderMode(media::base::RENDER_MODE_HIDDEN), mirrorMode(VIDEO_MIRROR_MODE_AUTO), + : uid(0), subviewUid(0), view(NULL), backgroundColor(0x00000000), renderMode(media::base::RENDER_MODE_HIDDEN), mirrorMode(VIDEO_MIRROR_MODE_AUTO), setupMode(VIDEO_VIEW_SETUP_REPLACE), sourceType(VIDEO_SOURCE_CAMERA_PRIMARY), mediaPlayerId(-ERR_NOT_READY), - cropArea(0, 0, 0, 0), enableAlphaMask(false) {} + cropArea(0, 0, 0, 0), enableAlphaMask(false), position(media::base::POSITION_POST_CAPTURER) {} + + VideoCanvas(view_t v, media::base::RENDER_MODE_TYPE m, VIDEO_MIRROR_MODE_TYPE mt) + : uid(0), subviewUid(0), view(v), backgroundColor(0x00000000), renderMode(m), mirrorMode(mt), setupMode(VIDEO_VIEW_SETUP_REPLACE), + sourceType(VIDEO_SOURCE_CAMERA_PRIMARY), mediaPlayerId(-ERR_NOT_READY), + cropArea(0, 0, 0, 0), enableAlphaMask(false), position(media::base::POSITION_POST_CAPTURER) {} VideoCanvas(view_t v, media::base::RENDER_MODE_TYPE m, VIDEO_MIRROR_MODE_TYPE mt, uid_t u) - : view(v), uid(u), backgroundColor(0x00000000), renderMode(m), mirrorMode(mt), setupMode(VIDEO_VIEW_SETUP_REPLACE), + : uid(u), subviewUid(0), view(v), backgroundColor(0x00000000), renderMode(m), mirrorMode(mt), setupMode(VIDEO_VIEW_SETUP_REPLACE), sourceType(VIDEO_SOURCE_CAMERA_PRIMARY), mediaPlayerId(-ERR_NOT_READY), - cropArea(0, 0, 0, 0), enableAlphaMask(false) {} + cropArea(0, 0, 0, 0), enableAlphaMask(false), position(media::base::POSITION_POST_CAPTURER) {} - VideoCanvas(view_t v, media::base::RENDER_MODE_TYPE m, VIDEO_MIRROR_MODE_TYPE mt, user_id_t) - : view(v), uid(0), backgroundColor(0x00000000), renderMode(m), mirrorMode(mt), setupMode(VIDEO_VIEW_SETUP_REPLACE), + VideoCanvas(view_t v, media::base::RENDER_MODE_TYPE m, VIDEO_MIRROR_MODE_TYPE mt, uid_t u, uid_t subu) + : uid(u), subviewUid(subu), view(v), backgroundColor(0x00000000), renderMode(m), mirrorMode(mt), setupMode(VIDEO_VIEW_SETUP_REPLACE), sourceType(VIDEO_SOURCE_CAMERA_PRIMARY), mediaPlayerId(-ERR_NOT_READY), - cropArea(0, 0, 0, 0), enableAlphaMask(false) {} + cropArea(0, 0, 0, 0), enableAlphaMask(false), position(media::base::POSITION_POST_CAPTURER) {} }; /** Image enhancement options. @@ -4438,7 +4530,7 @@ struct VirtualBackgroundSource { */ BACKGROUND_BLUR_DEGREE blur_degree; - VirtualBackgroundSource() : background_source_type(BACKGROUND_COLOR), color(0xffffff), source(NULL), blur_degree(BLUR_DEGREE_HIGH) {} + VirtualBackgroundSource() : background_source_type(BACKGROUND_COLOR), color(0xffffff), source(OPTIONAL_NULLPTR), blur_degree(BLUR_DEGREE_HIGH) {} }; struct SegmentationProperty { @@ -4836,22 +4928,22 @@ struct ScreenCaptureParameters { */ int excludeWindowCount; - /** The width (px) of the border. Defaults to 0, and the value range is [0,50]. - * - */ - int highLightWidth; - /** The color of the border in RGBA format. The default value is 0xFF8CBF26. - * - */ - unsigned int highLightColor; - /** Whether to place a border around the shared window or screen: - * - true: Place a border. - * - false: (Default) Do not place a border. - * - * @note When you share a part of a window or screen, the SDK places a border around the entire window or screen if you set `enableHighLight` as true. - * - */ - bool enableHighLight; + /** The width (px) of the border. Defaults to 0, and the value range is [0,50]. + * + */ + int highLightWidth; + /** The color of the border in RGBA format. The default value is 0xFF8CBF26. + * + */ + unsigned int highLightColor; + /** Whether to place a border around the shared window or screen: + * - true: Place a border. + * - false: (Default) Do not place a border. + * + * @note When you share a part of a window or screen, the SDK places a border around the entire window or screen if you set `enableHighLight` as true. + * + */ + bool enableHighLight; ScreenCaptureParameters() : dimensions(1920, 1080), frameRate(5), bitrate(STANDARD_BITRATE), captureMouseCursor(true), windowFocus(false), excludeWindowList(OPTIONAL_NULLPTR), excludeWindowCount(0), highLightWidth(0), highLightColor(0), enableHighLight(false) {} @@ -4968,7 +5060,7 @@ struct AudioRecordingConfiguration { int recordingChannel; AudioRecordingConfiguration() - : filePath(NULL), + : filePath(OPTIONAL_NULLPTR), encode(false), sampleRate(32000), fileRecordingType(AUDIO_FILE_RECORDING_MIXED), @@ -5172,59 +5264,6 @@ enum CHANNEL_MEDIA_RELAY_ERROR { RELAY_ERROR_DEST_TOKEN_EXPIRED = 11, }; -/** - * The event code of channel media relay. - */ -enum CHANNEL_MEDIA_RELAY_EVENT { - /** 0: The user disconnects from the server due to poor network connections. - */ - RELAY_EVENT_NETWORK_DISCONNECTED = 0, - /** 1: The user is connected to the server. - */ - RELAY_EVENT_NETWORK_CONNECTED = 1, - /** 2: The user joins the source channel. - */ - RELAY_EVENT_PACKET_JOINED_SRC_CHANNEL = 2, - /** 3: The user joins the destination channel. - */ - RELAY_EVENT_PACKET_JOINED_DEST_CHANNEL = 3, - /** 4: The SDK starts relaying the media stream to the destination channel. - */ - RELAY_EVENT_PACKET_SENT_TO_DEST_CHANNEL = 4, - /** 5: The server receives the video stream from the source channel. - */ - RELAY_EVENT_PACKET_RECEIVED_VIDEO_FROM_SRC = 5, - /** 6: The server receives the audio stream from the source channel. - */ - RELAY_EVENT_PACKET_RECEIVED_AUDIO_FROM_SRC = 6, - /** 7: The destination channel is updated. - */ - RELAY_EVENT_PACKET_UPDATE_DEST_CHANNEL = 7, - /** 8: The destination channel update fails due to internal reasons. - */ - RELAY_EVENT_PACKET_UPDATE_DEST_CHANNEL_REFUSED = 8, - /** 9: The destination channel does not change, which means that the destination channel fails to be updated. - */ - RELAY_EVENT_PACKET_UPDATE_DEST_CHANNEL_NOT_CHANGE = 9, - /** 10: The destination channel name is NULL. - */ - RELAY_EVENT_PACKET_UPDATE_DEST_CHANNEL_IS_NULL = 10, - /** 11: The video profile is sent to the server. - */ - RELAY_EVENT_VIDEO_PROFILE_UPDATE = 11, - /** 12: The SDK successfully pauses relaying the media stream to destination channels. - */ - RELAY_EVENT_PAUSE_SEND_PACKET_TO_DEST_CHANNEL_SUCCESS = 12, - /** 13: The SDK fails to pause relaying the media stream to destination channels. - */ - RELAY_EVENT_PAUSE_SEND_PACKET_TO_DEST_CHANNEL_FAILED = 13, - /** 14: The SDK successfully resumes relaying the media stream to destination channels. - */ - RELAY_EVENT_RESUME_SEND_PACKET_TO_DEST_CHANNEL_SUCCESS = 14, - /** 15: The SDK fails to resume relaying the media stream to destination channels. - */ - RELAY_EVENT_RESUME_SEND_PACKET_TO_DEST_CHANNEL_FAILED = 15, -}; /** * The state code of the channel media relay. */ @@ -5247,17 +5286,20 @@ enum CHANNEL_MEDIA_RELAY_STATE { /** The definition of ChannelMediaInfo. */ struct ChannelMediaInfo { - /** The channel name. The default value is NULL, which means that the SDK - * applies the current channel name. + /** The user ID. */ + uid_t uid; + /** The channel name. The default value is NULL, which means that the SDK + * applies the current channel name. + */ const char* channelName; - /** The token that enables the user to join the channel. The default value - * is NULL, which means that the SDK applies the current token. - */ + /** The token that enables the user to join the channel. The default value + * is NULL, which means that the SDK applies the current token. + */ const char* token; - /** The user ID. - */ - uid_t uid; + + ChannelMediaInfo() : uid(0), channelName(NULL), token(NULL) {} + ChannelMediaInfo(const char* c, const char* t, uid_t u) : uid(u), channelName(c), token(t) {} }; /** The definition of ChannelMediaRelayConfiguration. @@ -5275,7 +5317,7 @@ struct ChannelMediaRelayConfiguration { * - If you have enabled the App Certificate, you must use the token generated with the `channelName` and `uid`, and * the `uid` must be set as 0. */ - ChannelMediaInfo *srcInfo; + ChannelMediaInfo* srcInfo; /** The information of the destination channel `ChannelMediaInfo`. It contains the following members: * - `channelName`: The name of the destination channel. * - `uid`: The unique ID to identify the relay stream in the destination channel. The value @@ -5290,18 +5332,14 @@ struct ChannelMediaRelayConfiguration { * If you have enabled the App Certificate, you must use the token generated with the `channelName` * and `uid`. */ - ChannelMediaInfo *destInfos; + ChannelMediaInfo* destInfos; /** The number of destination channels. The default value is 0, and the value range is from 0 to * 6. Ensure that the value of this parameter corresponds to the number of `ChannelMediaInfo` * structs you define in `destInfo`. */ int destCount; - ChannelMediaRelayConfiguration() - : srcInfo(NULL), - destInfos(NULL), - destCount(0) - {} + ChannelMediaRelayConfiguration() : srcInfo(OPTIONAL_NULLPTR), destInfos(OPTIONAL_NULLPTR), destCount(0) {} }; /** @@ -5320,15 +5358,12 @@ struct UplinkNetworkInfo { } }; -/** - * The collections of downlink network info. - */ struct DownlinkNetworkInfo { struct PeerDownlinkInfo { /** * The ID of the user who owns the remote video stream. */ - const char* uid; + const char* userId; /** * The remote video stream type: #VIDEO_STREAM_TYPE. */ @@ -5343,28 +5378,41 @@ struct DownlinkNetworkInfo { int expected_bitrate_bps; PeerDownlinkInfo() - : uid(OPTIONAL_NULLPTR), + : userId(OPTIONAL_NULLPTR), stream_type(VIDEO_STREAM_HIGH), current_downscale_level(REMOTE_VIDEO_DOWNSCALE_LEVEL_NONE), expected_bitrate_bps(-1) {} + PeerDownlinkInfo(const PeerDownlinkInfo& rhs) + : stream_type(rhs.stream_type), + current_downscale_level(rhs.current_downscale_level), + expected_bitrate_bps(rhs.expected_bitrate_bps) { + if (rhs.userId != OPTIONAL_NULLPTR) { + const int len = std::strlen(rhs.userId); + char* buf = new char[len + 1]; + std::memcpy(buf, rhs.userId, len); + buf[len] = '\0'; + userId = buf; + } + } + PeerDownlinkInfo& operator=(const PeerDownlinkInfo& rhs) { if (this == &rhs) return *this; - uid = OPTIONAL_NULLPTR; + userId = OPTIONAL_NULLPTR; stream_type = rhs.stream_type; current_downscale_level = rhs.current_downscale_level; expected_bitrate_bps = rhs.expected_bitrate_bps; - if (rhs.uid != OPTIONAL_NULLPTR) { - char* temp = new char[strlen(rhs.uid) + 1]; - strcpy(temp, rhs.uid); - uid = temp; + if (rhs.userId != OPTIONAL_NULLPTR) { + const int len = std::strlen(rhs.userId); + char* buf = new char[len + 1]; + std::memcpy(buf, rhs.userId, len); + buf[len] = '\0'; + userId = buf; } return *this; } - ~PeerDownlinkInfo() { - if (uid) { delete [] uid; } - } + ~PeerDownlinkInfo() { delete[] userId; } }; /** @@ -5422,9 +5470,7 @@ struct DownlinkNetworkInfo { return *this; } - ~DownlinkNetworkInfo() { - if (peer_downlink_info) delete [] peer_downlink_info; - } + ~DownlinkNetworkInfo() { delete[] peer_downlink_info; } }; /** @@ -5487,7 +5533,7 @@ struct EncryptionConfig { EncryptionConfig() : encryptionMode(AES_128_GCM2), - encryptionKey(NULL) + encryptionKey(OPTIONAL_NULLPTR) { memset(encryptionKdfSalt, 0, sizeof(encryptionKdfSalt)); } @@ -5558,15 +5604,6 @@ enum PERMISSION_TYPE { SCREEN_CAPTURE = 2, }; -/** The maximum length of the user account. - */ -enum MAX_USER_ACCOUNT_LENGTH_TYPE -{ - /** The maximum length of the user account is 256 bytes. - */ - MAX_USER_ACCOUNT_LENGTH = 256 -}; - /** * The subscribing state. */ @@ -5654,8 +5691,8 @@ struct UserInfo { * The user account. The maximum data length is `MAX_USER_ACCOUNT_LENGTH_TYPE`. */ char userAccount[MAX_USER_ACCOUNT_LENGTH]; - UserInfo() - : uid(0) { + + UserInfo() : uid(0) { userAccount[0] = '\0'; } }; @@ -5896,22 +5933,6 @@ enum CONFIG_FETCH_TYPE { }; -/** - * media recorder source stream information - */ -struct RecorderStreamInfo { - /** - * The channel ID of the video track. - */ - const char* channelId; - /** - * The user ID. - */ - uid_t uid; - RecorderStreamInfo() : channelId(NULL), uid(0) {} -}; - - /** The local proxy mode type. */ enum LOCAL_PROXY_MODE { /** 0: Connect local proxy with high priority, if not connected to local proxy, fallback to sdrtn. @@ -5975,7 +5996,21 @@ struct LocalAccessPointConfiguration { LocalAccessPointConfiguration() : ipList(NULL), ipListSize(0), domainList(NULL), domainListSize(0), verifyDomainName(NULL), mode(ConnectivityFirst) {} }; - +/** + * The information about recorded media streams. + */ +struct RecorderStreamInfo { + const char* channelId; + /** + * The user ID. + */ + uid_t uid; + /** + * The channel ID of the audio/video stream needs to be recorded. + */ + RecorderStreamInfo() : channelId(NULL), uid(0) {} + RecorderStreamInfo(const char* channelId, uid_t uid) : channelId(channelId), uid(uid) {} +}; } // namespace rtc namespace base { @@ -5994,9 +6029,9 @@ class AParameter : public agora::util::AutoPtr { private: bool initialize(IEngineBase* engine) { - IAgoraParameter* p = NULL; + IAgoraParameter* p = OPTIONAL_NULLPTR; if (engine && !engine->queryInterface(rtc::AGORA_IID_PARAMETER_ENGINE, (void**)&p)) reset(p); - return p != NULL; + return p != OPTIONAL_NULLPTR; } }; @@ -6048,7 +6083,47 @@ struct SpatialAudioParams { */ Optional enable_doppler; }; +/** + * Layout info of video stream which compose a transcoder video stream. +*/ +struct VideoLayout +{ + /** + * Channel Id from which this video stream come from. + */ + const char* channelId; + /** + * User id of video stream. + */ + rtc::uid_t uid; + /** + * User account of video stream. + */ + user_id_t strUid; + /** + * x coordinate of video stream on a transcoded video stream canvas. + */ + uint32_t x; + /** + * y coordinate of video stream on a transcoded video stream canvas. + */ + uint32_t y; + /** + * width of video stream on a transcoded video stream canvas. + */ + uint32_t width; + /** + * height of video stream on a transcoded video stream canvas. + */ + uint32_t height; + /** + * video state of video stream on a transcoded video stream canvas. + * 0 for normal video , 1 for placeholder image showed , 2 for black image. + */ + uint32_t videoState; + VideoLayout() : channelId(OPTIONAL_NULLPTR), uid(0), strUid(OPTIONAL_NULLPTR), x(0), y(0), width(0), height(0), videoState(0) {} +}; } // namespace agora /** diff --git a/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/AgoraMediaBase.h b/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/AgoraMediaBase.h index bd0a7b881..15dfd4b38 100644 --- a/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/AgoraMediaBase.h +++ b/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/AgoraMediaBase.h @@ -1,4 +1,3 @@ -// // Agora Engine SDK // // Created by Sting Feng in 2017-11. @@ -35,10 +34,8 @@ static const unsigned int INVALID_TRACK_ID = 0xffffffff; static const unsigned int DEFAULT_CONNECTION_ID = 0; static const unsigned int DUMMY_CONNECTION_ID = (std::numeric_limits::max)(); - struct EncodedVideoFrameInfo; - /** * Video source types definition. **/ @@ -105,45 +102,49 @@ enum AudioRoute */ ROUTE_DEFAULT = -1, /** - * The headset. + * The Headset. */ ROUTE_HEADSET = 0, /** - * The earpiece. + * The Earpiece. */ ROUTE_EARPIECE = 1, /** - * The headset with no microphone. + * The Headset with no microphone. */ ROUTE_HEADSETNOMIC = 2, /** - * The speakerphone. + * The Speakerphone. */ ROUTE_SPEAKERPHONE = 3, /** - * The loudspeaker. + * The Loudspeaker. */ ROUTE_LOUDSPEAKER = 4, /** - * The Bluetooth headset. + * The Bluetooth Headset via HFP. */ ROUTE_HEADSETBLUETOOTH = 5, /** - * The USB + * The USB. */ ROUTE_USB = 6, /** - * The HDMI + * The HDMI. */ ROUTE_HDMI = 7, /** - * The DISPLAYPORT + * The DisplayPort. */ ROUTE_DISPLAYPORT = 8, /** - * The AIRPLAY + * The AirPlay. */ ROUTE_AIRPLAY = 9, + /** + * The Bluetooth Speaker via A2DP. + */ + ROUTE_BLUETOOTH_SPEAKER = 10, }; /** @@ -551,6 +552,19 @@ enum CAMERA_VIDEO_SOURCE_TYPE { VIDEO_SOURCE_UNSPECIFIED = 2, }; +/** + * The IVideoFrameMetaInfo class. + * This interface provides access to metadata information. + */ +class IVideoFrameMetaInfo { + public: + enum META_INFO_KEY { + KEY_FACE_CAPTURE = 0, + }; + virtual ~IVideoFrameMetaInfo() {}; + virtual const char* getMetaInfoStr(META_INFO_KEY key) const = 0; +}; + /** * The definition of the ExternalVideoFrame struct. */ @@ -698,12 +712,12 @@ struct ExternalVideoFrame { uint8_t* alphaBuffer; /** - * [Windows Texture related parameter] The pointer of ID3D11Texture2D used by the video frame. + * [For Windows only] The pointer of ID3D11Texture2D used by the video frame. */ void *d3d11_texture_2d; /** - * [Windows Texture related parameter] The index of ID3D11Texture2D array used by the video frame. + * [For Windows only] The index of ID3D11Texture2D array used by the video frame. */ int texture_slice_index; }; @@ -731,7 +745,8 @@ struct VideoFrame { textureId(0), d3d11Texture2d(NULL), alphaBuffer(NULL), - pixelBuffer(NULL){ + pixelBuffer(NULL), + metaInfo(NULL){ memset(matrix, 0, sizeof(matrix)); } /** @@ -821,6 +836,10 @@ struct VideoFrame { *The type of CVPixelBufferRef, for iOS and macOS only. */ void* pixelBuffer; + /** + * The pointer to IVideoFrameMetaInfo, which is the interface to get metainfo contents from VideoFrame. + */ + IVideoFrameMetaInfo* metaInfo; }; /** @@ -865,6 +884,7 @@ enum VIDEO_MODULE_POSITION { POSITION_POST_CAPTURER = 1 << 0, POSITION_PRE_RENDERER = 1 << 1, POSITION_PRE_ENCODER = 1 << 2, + POSITION_POST_CAPTURER_ORIGIN = 1 << 3, }; } // namespace base @@ -942,10 +962,6 @@ class IAudioFrameObserverBase { * are used. */ int64_t renderTimeMs; - /** - * A reserved parameter. - */ - int avsync_type; /** * A reserved parameter. * @@ -953,7 +969,18 @@ class IAudioFrameObserverBase { * this will then filled into audio4 extension part, the remote side could use this pts in av * sync process with video frame. */ + int avsync_type; + /** + * The pts timestamp of this audio frame. + * + * This timestamp is used to indicate the origin pts time of the frame, and sync with video frame by + * the pts time stamp + */ int64_t presentationMs; + /** + * The number of the audio track. + */ + int audioTrackNumber; AudioFrame() : type(FRAME_TYPE_PCM16), samplesPerChannel(0), @@ -963,7 +990,8 @@ class IAudioFrameObserverBase { buffer(NULL), renderTimeMs(0), avsync_type(0), - presentationMs(0) {} + presentationMs(0), + audioTrackNumber(0) {} }; enum AUDIO_FRAME_POSITION { @@ -1180,9 +1208,9 @@ struct UserAudioSpectrumInfo { */ struct AudioSpectrumData spectrumData; - UserAudioSpectrumInfo () : uid(0), spectrumData() {} - UserAudioSpectrumInfo(agora::rtc::uid_t _uid, const float *data, int length) : - uid(_uid) { spectrumData.audioSpectrumData = data; spectrumData.dataLength = length; } + UserAudioSpectrumInfo() : uid(0) {} + + UserAudioSpectrumInfo(agora::rtc::uid_t uid, const float* data, int length) : uid(uid), spectrumData(data, length) {} }; /** @@ -1205,7 +1233,6 @@ class IAudioSpectrumObserver { * - false: Not processed. */ virtual bool onLocalAudioSpectrum(const AudioSpectrumData& data) = 0; - /** * Reports the audio spectrum of remote user. * @@ -1223,7 +1250,7 @@ class IAudioSpectrumObserver { * - true: Processed. * - false: Not processed. */ - virtual bool onRemoteAudioSpectrum(const UserAudioSpectrumInfo * spectrums, unsigned int spectrumNumber) = 0; + virtual bool onRemoteAudioSpectrum(const UserAudioSpectrumInfo* spectrums, unsigned int spectrumNumber) = 0; }; /** @@ -1505,7 +1532,7 @@ enum MediaRecorderStreamType { */ enum RecorderState { /** - * -1: An error occurs during the recording. See RecorderErrorCode for the reason. + * -1: An error occurs during the recording. See RecorderReasonCode for the reason. */ RECORDER_STATE_ERROR = -1, /** @@ -1522,27 +1549,27 @@ enum RecorderState { * * @since v3.5.2 */ -enum RecorderErrorCode { +enum RecorderReasonCode { /** * 0: No error occurs. */ - RECORDER_ERROR_NONE = 0, + RECORDER_REASON_NONE = 0, /** * 1: The SDK fails to write the recorded data to a file. */ - RECORDER_ERROR_WRITE_FAILED = 1, + RECORDER_REASON_WRITE_FAILED = 1, /** * 2: The SDK does not detect audio and video streams to be recorded, or audio and video streams are interrupted for more than five seconds during recording. */ - RECORDER_ERROR_NO_STREAM = 2, + RECORDER_REASON_NO_STREAM = 2, /** * 3: The recording duration exceeds the upper limit. */ - RECORDER_ERROR_OVER_MAX_DURATION = 3, + RECORDER_REASON_OVER_MAX_DURATION = 3, /** * 4: The recording configuration changes. */ - RECORDER_ERROR_CONFIG_CHANGED = 4, + RECORDER_REASON_CONFIG_CHANGED = 4, }; /** * Configurations for the local audio and video recording. @@ -1605,7 +1632,6 @@ struct RecorderInfo { RecorderInfo(const char* name, unsigned int dur, unsigned int size) : fileName(name), durationMs(dur), fileSize(size) {} }; - class IMediaRecorderObserver { public: /** @@ -1619,9 +1645,9 @@ class IMediaRecorderObserver { * @param channelId The channel name. * @param uid ID of the user. * @param state The current recording state. See \ref agora::media::RecorderState "RecorderState". - * @param error The reason for the state change. See \ref agora::media::RecorderErrorCode "RecorderErrorCode". + * @param reason The reason for the state change. See \ref agora::media::RecorderReasonCode "RecorderReasonCode". */ - virtual void onRecorderStateChanged(const char* channelId, rtc::uid_t uid, RecorderState state, RecorderErrorCode error) = 0; + virtual void onRecorderStateChanged(const char* channelId, rtc::uid_t uid, RecorderState state, RecorderReasonCode reason) = 0; /** * Occurs when the recording information is updated. * @@ -1637,7 +1663,9 @@ class IMediaRecorderObserver { * */ virtual void onRecorderInfoUpdated(const char* channelId, rtc::uid_t uid, const RecorderInfo& info) = 0; + virtual ~IMediaRecorderObserver() {} }; + } // namespace media } // namespace agora diff --git a/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/AgoraMediaPlayerTypes.h b/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/AgoraMediaPlayerTypes.h index d1bb17bb3..3beaba788 100644 --- a/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/AgoraMediaPlayerTypes.h +++ b/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/AgoraMediaPlayerTypes.h @@ -105,61 +105,61 @@ enum MEDIA_PLAYER_STATE { * @brief Player error code * */ -enum MEDIA_PLAYER_ERROR { +enum MEDIA_PLAYER_REASON { /** No error. */ - PLAYER_ERROR_NONE = 0, + PLAYER_REASON_NONE = 0, /** The parameter is invalid. */ - PLAYER_ERROR_INVALID_ARGUMENTS = -1, + PLAYER_REASON_INVALID_ARGUMENTS = -1, /** Internel error. */ - PLAYER_ERROR_INTERNAL = -2, + PLAYER_REASON_INTERNAL = -2, /** No resource. */ - PLAYER_ERROR_NO_RESOURCE = -3, + PLAYER_REASON_NO_RESOURCE = -3, /** Invalid media source. */ - PLAYER_ERROR_INVALID_MEDIA_SOURCE = -4, + PLAYER_REASON_INVALID_MEDIA_SOURCE = -4, /** The type of the media stream is unknown. */ - PLAYER_ERROR_UNKNOWN_STREAM_TYPE = -5, + PLAYER_REASON_UNKNOWN_STREAM_TYPE = -5, /** The object is not initialized. */ - PLAYER_ERROR_OBJ_NOT_INITIALIZED = -6, + PLAYER_REASON_OBJ_NOT_INITIALIZED = -6, /** The codec is not supported. */ - PLAYER_ERROR_CODEC_NOT_SUPPORTED = -7, + PLAYER_REASON_CODEC_NOT_SUPPORTED = -7, /** Invalid renderer. */ - PLAYER_ERROR_VIDEO_RENDER_FAILED = -8, + PLAYER_REASON_VIDEO_RENDER_FAILED = -8, /** An error occurs in the internal state of the player. */ - PLAYER_ERROR_INVALID_STATE = -9, + PLAYER_REASON_INVALID_STATE = -9, /** The URL of the media file cannot be found. */ - PLAYER_ERROR_URL_NOT_FOUND = -10, + PLAYER_REASON_URL_NOT_FOUND = -10, /** Invalid connection between the player and the Agora server. */ - PLAYER_ERROR_INVALID_CONNECTION_STATE = -11, + PLAYER_REASON_INVALID_CONNECTION_STATE = -11, /** The playback buffer is insufficient. */ - PLAYER_ERROR_SRC_BUFFER_UNDERFLOW = -12, + PLAYER_REASON_SRC_BUFFER_UNDERFLOW = -12, /** The audio mixing file playback is interrupted. */ - PLAYER_ERROR_INTERRUPTED = -13, + PLAYER_REASON_INTERRUPTED = -13, /** The SDK does not support this function. */ - PLAYER_ERROR_NOT_SUPPORTED = -14, + PLAYER_REASON_NOT_SUPPORTED = -14, /** The token has expired. */ - PLAYER_ERROR_TOKEN_EXPIRED = -15, + PLAYER_REASON_TOKEN_EXPIRED = -15, /** The ip has expired. */ - PLAYER_ERROR_IP_EXPIRED = -16, + PLAYER_REASON_IP_EXPIRED = -16, /** An unknown error occurs. */ - PLAYER_ERROR_UNKNOWN = -17, + PLAYER_REASON_UNKNOWN = -17, }; /** @@ -357,18 +357,60 @@ struct CacheStatistics { int64_t downloadSize; }; -struct PlayerUpdatedInfo { - /** playerId has value when user trigger interface of opening +/** + * @brief The real time statistics of the media stream being played. + * + */ +struct PlayerPlaybackStats { + /** Video fps. */ - Optional playerId; - - /** deviceId has value when user trigger interface of opening + int videoFps; + /** Video bitrate (Kbps). + */ + int videoBitrateInKbps; + /** Audio bitrate (Kbps). */ - Optional deviceId; + int audioBitrateInKbps; + /** Total bitrate (Kbps). + */ + int totalBitrateInKbps; +}; - /** cacheStatistics exist if you enable cache, triggered 1s at a time after openning url +/** + * @brief The updated information of media player. + * + */ +struct PlayerUpdatedInfo { + /** @technical preview */ - Optional cacheStatistics; + const char* internalPlayerUuid; + /** The device ID of the playback device. + */ + const char* deviceId; + /** Video height. + */ + int videoHeight; + /** Video width. + */ + int videoWidth; + /** Audio sample rate. + */ + int audioSampleRate; + /** The audio channel number. + */ + int audioChannels; + /** The bit number of each audio sample. + */ + int audioBitsPerSample; + + PlayerUpdatedInfo() + : internalPlayerUuid(NULL), + deviceId(NULL), + videoHeight(0), + videoWidth(0), + audioSampleRate(0), + audioChannels(0), + audioBitsPerSample(0) {} }; /** @@ -436,6 +478,17 @@ struct MediaSource { * - false: (Default) Disable cache. */ bool enableCache; + /** + * Determines whether to enable multi-track audio stream decoding. + * Then you can select multi audio track of the media file for playback or publish to channel + * + * @note + * If you use the selectMultiAudioTrack API, you must set enableMultiAudioTrack to true. + * + * - true: Enable MultiAudioTrack;. + * - false: (Default) Disable MultiAudioTrack;. + */ + bool enableMultiAudioTrack; /** * Determines whether the opened media resource is a stream through the Agora Broadcast Streaming Network(CDN). * - true: It is a stream through the Agora Broadcast Streaming Network. @@ -454,7 +507,7 @@ struct MediaSource { IMediaPlayerCustomDataProvider* provider; MediaSource() : url(NULL), uri(NULL), startPos(0), autoPlay(true), enableCache(false), - provider(NULL){ + enableMultiAudioTrack(false), provider(NULL){ } }; diff --git a/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/IAgoraH265Transcoder.h b/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/IAgoraH265Transcoder.h index 250d5ad82..b2f5c5b31 100644 --- a/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/IAgoraH265Transcoder.h +++ b/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/IAgoraH265Transcoder.h @@ -71,10 +71,8 @@ enum H265_TRANSCODE_RESULT { */ class IH265TranscoderObserver { public: - virtual ~IH265TranscoderObserver() {}; - /** * Use to notify the result of invoking enableTranscode interface. * @param result Result of invoking enableTranscode interface. There are some processing advice below of result. @@ -119,9 +117,8 @@ class IH265TranscoderObserver { /** * The IH265Transcoder class */ -class IH265Transcoder: public RefCountInterface { +class IH265Transcoder : public RefCountInterface { public: - /** * Enable transcoding for a channel. * @param token The token for authentication. @@ -154,7 +151,6 @@ class IH265Transcoder: public RefCountInterface { * - <0: Failure. */ virtual int triggerTranscode(const char* token, const char* channel, uid_t uid) = 0; - /** * Register a IH265TranscoderObserver object. * @param observer IH265TranscoderObserver. @@ -163,7 +159,6 @@ class IH265Transcoder: public RefCountInterface { * - <0: Failure. */ virtual int registerTranscoderObserver(IH265TranscoderObserver *observer) = 0; - /** * Unregister a IH265TranscoderObserver object. * @param observer IH265TranscoderObserver. @@ -178,5 +173,6 @@ class IH265Transcoder: public RefCountInterface { virtual ~IH265Transcoder() {}; }; + } // namespace rtc } // namespace agora \ No newline at end of file diff --git a/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/IAgoraLog.h b/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/IAgoraLog.h index f3952163a..2fae3aa13 100644 --- a/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/IAgoraLog.h +++ b/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/IAgoraLog.h @@ -75,7 +75,7 @@ const uint32_t MAX_LOG_SIZE = 20 * 1024 * 1024; // 20MB const uint32_t MIN_LOG_SIZE = 128 * 1024; // 128KB /** The default log size in kb */ -const uint32_t DEFAULT_LOG_SIZE_IN_KB = 1024; +const uint32_t DEFAULT_LOG_SIZE_IN_KB = 2048; /** Definition of LogConfiguration */ @@ -83,7 +83,7 @@ struct LogConfig { /**The log file path, default is NULL for default log path */ const char* filePath; - /** The log file size, KB , set 1024KB to use default log size + /** The log file size, KB , set 2048KB to use default log size */ uint32_t fileSizeInKB; /** The log level, set LOG_LEVEL_INFO to use default log level 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 e2f8e06a9..e57404a22 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 @@ -58,7 +58,6 @@ class IMediaEngine { * - < 0: Failure. */ virtual int registerVideoFrameObserver(IVideoFrameObserver* observer) = 0; - /** * Registers a receiver object for the encoded video image. * @@ -73,7 +72,6 @@ class IMediaEngine { * - < 0: Failure. */ virtual int registerVideoEncodedFrameObserver(IVideoEncodedFrameObserver* observer) = 0; - /** * Pushes the external audio data to the app. * @@ -83,7 +81,8 @@ class IMediaEngine { * - 0: Success. * - < 0: Failure. */ - virtual int pushAudioFrame(IAudioFrameObserver::AudioFrame* frame, rtc::track_id_t trackId = 0) = 0; + + virtual int pushAudioFrame(IAudioFrameObserverBase::AudioFrame* frame, rtc::track_id_t trackId = 0) = 0; /** * Pulls the remote audio data. @@ -101,7 +100,7 @@ class IMediaEngine { * - 0: Success. * - < 0: Failure. */ - virtual int pullAudioFrame(IAudioFrameObserver::AudioFrame* frame) = 0; + virtual int pullAudioFrame(IAudioFrameObserverBase::AudioFrame* frame) = 0; /** * Sets the external video source. @@ -237,7 +236,6 @@ class IMediaEngine { * - < 0: Failure. */ virtual int pushVideoFrame(base::ExternalVideoFrame* frame, unsigned int videoTrackId = 0) = 0; - /** * Pushes the encoded video image to the app. * @param imageBuffer A pointer to the video image. @@ -248,10 +246,9 @@ class IMediaEngine { * - 0: Success. * - < 0: Failure. */ - virtual int pushEncodedVideoImage(const uint8_t* imageBuffer, size_t length, + virtual int pushEncodedVideoImage(const unsigned char* imageBuffer, size_t length, const agora::rtc::EncodedVideoFrameInfo& videoEncodedFrameInfo, unsigned int videoTrackId = 0) = 0; - /** * @hide For internal usage only */ diff --git a/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/IAgoraMediaPlayer.h b/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/IAgoraMediaPlayer.h index cb5c8738e..bd3c7597c 100644 --- a/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/IAgoraMediaPlayer.h +++ b/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/IAgoraMediaPlayer.h @@ -158,13 +158,30 @@ class IMediaPlayer : public RefCountInterface { /** * Slect playback audio track of the media file - * @param speed the index of the audio track in meia file + * @param index the index of the audio track in media file * @return * - 0: Success. * - < 0: Failure. */ virtual int selectAudioTrack(int index) = 0; + /** + * Selects multi audio track of the media file for playback or publish to channel. + * @param playoutTrackIndex The index of the audio track in media file for local playback. + * @param publishTrackIndex The index of the audio track in the media file published to the remote. + * + * @note + * You can obtain the streamIndex of the audio track by calling getStreamInfo.. + * If you want to use selectMultiAudioTrack, you need to open the media file with openWithMediaSource and set enableMultiAudioTrack to true. + * + * @return + * - 0: Success. + * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. + * - -2: Invalid argument. Argument must be greater than or equal to zero. + * - -8: Invalid State.You must open the media file with openWithMediaSource and set enableMultiAudioTrack to true + */ + virtual int selectMultiAudioTrack(int playoutTrackIndex, int publishTrackIndex) = 0; + /** * change player option before play a file * @param key the key of the option param @@ -217,7 +234,7 @@ class IMediaPlayer : public RefCountInterface { * @brief Turn mute on or off * * @param muted Whether to mute on - * @return int < 0 on behalf of an error, the value corresponds to one of MEDIA_PLAYER_ERROR + * @return int < 0 on behalf of an error, the value corresponds to one of MEDIA_PLAYER_REASON */ virtual int mute(bool muted) = 0; @@ -225,7 +242,7 @@ class IMediaPlayer : public RefCountInterface { * @brief Get mute state * * @param[out] muted Whether is mute on - * @return int < 0 on behalf of an error, the value corresponds to one of MEDIA_PLAYER_ERROR + * @return int < 0 on behalf of an error, the value corresponds to one of MEDIA_PLAYER_REASON */ virtual int getMute(bool& muted) = 0; @@ -237,7 +254,7 @@ class IMediaPlayer : public RefCountInterface { * 0: mute; * 100: original volume; * 400: Up to 4 times the original volume (with built-in overflow protection). - * @return int < 0 on behalf of an error, the value corresponds to one of MEDIA_PLAYER_ERROR + * @return int < 0 on behalf of an error, the value corresponds to one of MEDIA_PLAYER_REASON */ virtual int adjustPlayoutVolume(int volume) = 0; @@ -245,21 +262,21 @@ class IMediaPlayer : public RefCountInterface { * @brief Get the current playback volume * * @param[out] volume - * @return int < 0 on behalf of an error, the value corresponds to one of MEDIA_PLAYER_ERROR + * @return int < 0 on behalf of an error, the value corresponds to one of MEDIA_PLAYER_REASON */ virtual int getPlayoutVolume(int& volume) = 0; /** * @brief adjust publish signal volume * - * @return int < 0 on behalf of an error, the value corresponds to one of MEDIA_PLAYER_ERROR + * @return int < 0 on behalf of an error, the value corresponds to one of MEDIA_PLAYER_REASON */ virtual int adjustPublishSignalVolume(int volume) = 0; /** * @brief get publish signal volume * - * @return int < 0 on behalf of an error, the value corresponds to one of MEDIA_PLAYER_ERROR + * @return int < 0 on behalf of an error, the value corresponds to one of MEDIA_PLAYER_REASON */ virtual int getPublishSignalVolume(int& volume) = 0; @@ -267,7 +284,7 @@ class IMediaPlayer : public RefCountInterface { * @brief Set video rendering view * * @param view view object, windows platform is HWND - * @return int < 0 on behalf of an error, the value corresponds to one of MEDIA_PLAYER_ERROR + * @return int < 0 on behalf of an error, the value corresponds to one of MEDIA_PLAYER_REASON */ virtual int setView(media::base::view_t view) = 0; @@ -275,7 +292,7 @@ class IMediaPlayer : public RefCountInterface { * @brief Set video display mode * * @param renderMode Video display mode - * @return int < 0 on behalf of an error, the value corresponds to one of MEDIA_PLAYER_ERROR + * @return int < 0 on behalf of an error, the value corresponds to one of MEDIA_PLAYER_REASON */ virtual int setRenderMode(media::base::RENDER_MODE_TYPE renderMode) = 0; @@ -337,7 +354,7 @@ class IMediaPlayer : public RefCountInterface { * @brief Register the player video observer * * @param observer observer object - * @return int < 0 on behalf of an error, the value corresponds to one of MEDIA_PLAYER_ERROR + * @return int < 0 on behalf of an error, the value corresponds to one of MEDIA_PLAYER_REASON */ virtual int registerVideoFrameObserver(media::base::IVideoFrameObserver* observer) = 0; @@ -345,7 +362,7 @@ class IMediaPlayer : public RefCountInterface { * @brief UnRegister the player video observer * * @param observer observer object - * @return int < 0 on behalf of an error, the value corresponds to one of MEDIA_PLAYER_ERROR + * @return int < 0 on behalf of an error, the value corresponds to one of MEDIA_PLAYER_REASON */ virtual int unregisterVideoFrameObserver(agora::media::base::IVideoFrameObserver* observer) = 0; diff --git a/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/IAgoraMediaPlayerSource.h b/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/IAgoraMediaPlayerSource.h index 8d1a95be0..00be02233 100644 --- a/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/IAgoraMediaPlayerSource.h +++ b/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/IAgoraMediaPlayerSource.h @@ -118,7 +118,7 @@ class IMediaPlayerSource : public RefCountInterface { * @param [out] pos A reference to the current playback position (ms). * @return * - 0: Success. - * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_ERROR MEDIA_PLAYER_ERROR}. + * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. */ virtual int getPlayPosition(int64_t& pos) = 0; @@ -127,7 +127,7 @@ class IMediaPlayerSource : public RefCountInterface { * @param [out] count The number of the media streams in the media source. * @return * - 0: Success. - * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_ERROR MEDIA_PLAYER_ERROR}. + * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. */ virtual int getStreamCount(int64_t& count) = 0; @@ -137,7 +137,7 @@ class IMediaPlayerSource : public RefCountInterface { * @param [out] info The detailed information of the media stream. See \ref media::base::PlayerStreamInfo "PlayerStreamInfo" for details. * @return * - 0: Success. - * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_ERROR MEDIA_PLAYER_ERROR}. + * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. */ virtual int getStreamInfo(int64_t index, media::base::PlayerStreamInfo* info) = 0; @@ -149,7 +149,7 @@ class IMediaPlayerSource : public RefCountInterface { * - -1: Play the media file in a loop indefinitely, until {@link stop} is called. * @return * - 0: Success. - * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_ERROR MEDIA_PLAYER_ERROR}. + * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. */ virtual int setLoopCount(int64_t loopCount) = 0; @@ -158,7 +158,7 @@ class IMediaPlayerSource : public RefCountInterface { * @param speed The playback speed ref [50-400]. * @return * - 0: Success. - * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_ERROR MEDIA_PLAYER_ERROR}. + * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. */ virtual int setPlaybackSpeed(int speed) = 0; @@ -167,17 +167,34 @@ class IMediaPlayerSource : public RefCountInterface { * @param index The index of the audio track in media file. * @return * - 0: Success. - * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_ERROR MEDIA_PLAYER_ERROR}. + * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. */ virtual int selectAudioTrack(int64_t index) = 0; + /** + * Selects multi audio track of the media file for playback or publish to channel. + * @param playoutTrackIndex The index of the audio track in media file for local playback. + * @param publishTrackIndex The index of the audio track in the media file published to the remote. + * + * @note + * You can obtain the streamIndex of the audio track by calling getStreamInfo.. + * If you want to use selectMultiAudioTrack, you need to open the media file with openWithMediaSource and set enableMultiAudioTrack to true. + * + * @return + * - 0: Success. + * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. + * - -2: Invalid argument. Argument must be greater than or equal to zero. + * - -8: Invalid State.You must open the media file with openWithMediaSource and set enableMultiAudioTrack to true + */ + virtual int selectMultiAudioTrack(int playoutTrackIndex, int publishTrackIndex) = 0; + /** * Changes the player option before playing a file. * @param key The key of the option paramemter. * @param value The value of option parameter. * @return * - 0: Success. - * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_ERROR MEDIA_PLAYER_ERROR}. + * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. */ virtual int setPlayerOption(const char* key, int64_t value) = 0; @@ -187,7 +204,7 @@ class IMediaPlayerSource : public RefCountInterface { * @param value The value of option parameter. * @return * - 0: Success. - * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_ERROR MEDIA_PLAYER_ERROR}. + * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. */ virtual int setPlayerOption(const char* key, const char* value) = 0; @@ -196,7 +213,7 @@ class IMediaPlayerSource : public RefCountInterface { * @param filename The filename of the screenshot file. * @return * - 0: Success. - * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_ERROR MEDIA_PLAYER_ERROR}. + * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. */ virtual int takeScreenshot(const char* filename) = 0; @@ -205,7 +222,7 @@ class IMediaPlayerSource : public RefCountInterface { * @param index The index of the internal subtitles. * @return * - 0: Success. - * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_ERROR MEDIA_PLAYER_ERROR}. + * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. */ virtual int selectInternalSubtitle(int64_t index) = 0; @@ -214,7 +231,7 @@ class IMediaPlayerSource : public RefCountInterface { * @param url The URL of the subtitle file. * @return * - 0: Success. - * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_ERROR MEDIA_PLAYER_ERROR}. + * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. */ virtual int setExternalSubtitle(const char* url) = 0; @@ -231,7 +248,7 @@ class IMediaPlayerSource : public RefCountInterface { * @param observer The pointer to the IMediaPlayerSourceObserver object. * @return * - 0: Success. - * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_ERROR MEDIA_PLAYER_ERROR}. + * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. */ virtual int registerPlayerSourceObserver(IMediaPlayerSourceObserver* observer) = 0; @@ -240,7 +257,7 @@ class IMediaPlayerSource : public RefCountInterface { * @param observer The pointer to the IMediaPlayerSourceObserver object. * @return * - 0: Success. - * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_ERROR MEDIA_PLAYER_ERROR}. + * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. */ virtual int unregisterPlayerSourceObserver(IMediaPlayerSourceObserver* observer) = 0; @@ -250,7 +267,7 @@ class IMediaPlayerSource : public RefCountInterface { * @param observer The pointer to the {@link media::IAudioPcmFrameSink observer} object. * @return * - 0: Success. - * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_ERROR MEDIA_PLAYER_ERROR}. + * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. */ virtual int registerAudioFrameObserver(media::IAudioPcmFrameSink* observer) = 0; @@ -259,7 +276,7 @@ class IMediaPlayerSource : public RefCountInterface { * @param observer The pointer to the {@link media::IAudioPcmFrameSink observer} object. * @return * - 0: Success. - * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_ERROR MEDIA_PLAYER_ERROR}. + * - < 0: Failure. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. */ virtual int unregisterAudioFrameObserver(media::IAudioPcmFrameSink* observer) = 0; @@ -380,18 +397,19 @@ class IMediaPlayerSourceObserver { * * When the state of the playback changes, the SDK triggers this callback to report the new playback state and the reason or error for the change. * @param state The new playback state after change. See {@link media::base::MEDIA_PLAYER_STATE MEDIA_PLAYER_STATE}. - * @param ec The player's error code. See {@link media::base::MEDIA_PLAYER_ERROR MEDIA_PLAYER_ERROR}. + * @param reason The player's error code. See {@link media::base::MEDIA_PLAYER_REASON MEDIA_PLAYER_REASON}. */ virtual void onPlayerSourceStateChanged(media::base::MEDIA_PLAYER_STATE state, - media::base::MEDIA_PLAYER_ERROR ec) = 0; + media::base::MEDIA_PLAYER_REASON reason) = 0; /** * @brief Reports current playback progress. * * The callback occurs once every one second during the playback and reports the current playback progress. - * @param position Current playback progress (milisecond). + * @param positionMs Current playback progress (milisecond). + * @param timestampMs Current NTP(Network Time Protocol) time (milisecond). */ - virtual void onPositionChanged(int64_t position_ms) = 0; + virtual void onPositionChanged(int64_t positionMs, int64_t timestampMs) = 0; /** * @brief Reports the playback event. @@ -455,6 +473,24 @@ class IMediaPlayerSourceObserver { * @param info Include information of media player. */ virtual void onPlayerInfoUpdated(const media::base::PlayerUpdatedInfo& info) = 0; + + /** + * @brief Triggered every 1 second, reports the statistics of the files being cached. + * + * @param stats Cached file statistics. + */ + virtual void onPlayerCacheStats(const media::base::CacheStatistics& stats) { + (void)stats; + } + + /** + * @brief Triggered every 1 second, reports the statistics of the media stream being played. + * + * @param stats The statistics of the media stream. + */ + virtual void onPlayerPlaybackStats(const media::base::PlayerPlaybackStats& stats) { + (void)stats; + } /** * @brief Triggered every 200 millisecond ,update player current volume range [0,255] diff --git a/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/IAgoraMediaRecorder.h b/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/IAgoraMediaRecorder.h index 6a4765f31..17375607c 100644 --- a/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/IAgoraMediaRecorder.h +++ b/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/IAgoraMediaRecorder.h @@ -15,6 +15,7 @@ namespace rtc { class IMediaRecorder : public RefCountInterface { protected: virtual ~IMediaRecorder() {} + public: /** * Registers the IMediaRecorderObserver object. @@ -62,8 +63,7 @@ class IMediaRecorder : public RefCountInterface { * - The specified path of the recording file exists and is writable. * - The specified format of the recording file is supported. * - The maximum recording duration is correctly set. - * - During remote recording, ensure the channel ID and user ID After calling \ref - * IRtcEngine::createMediaRecorder did join the channel. + * - During remote recording, ensure the user whose media streams you want record did join the channel. * - `-4(ERR_NOT_SUPPORTED)`: IRtcEngine does not support the request due to one of the following reasons: * - The recording is ongoing. * - The recording stops because an error occurs. diff --git a/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/IAgoraMusicContentCenter.h b/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/IAgoraMusicContentCenter.h index 1889bbdea..d5ed99ef8 100644 --- a/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/IAgoraMusicContentCenter.h +++ b/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/IAgoraMusicContentCenter.h @@ -44,36 +44,36 @@ typedef enum /** * 1: A general error occurs. */ - kMusicContentCenterStatusErr = 1, + kMusicContentCenterStatusError = 1, /** * 2: The gateway error. There are several possible reasons: * - Token is expired. Check if your token is expired. * - Token is invalid. Check the type of token you passed in. * - Network error. Check your network. */ - kMusicContentCenterStatusErrGateway = 2, + kMusicContentCenterStatusGateway = 2, /** * 3: Permission and resource error. There are several possible reasons: * - Your appid may not have the mcc permission. Please contact technical support * - The resource may not exist. Please contact technical support */ - kMusicContentCenterStatusErrPermissionAndResource = 3, + kMusicContentCenterStatusPermissionAndResource = 3, /** * 4: Internal data parse error. Please contact technical support */ - kMusicContentCenterStatusErrInternalDataParse = 4, + kMusicContentCenterStatusInternalDataParse = 4, /** * 5: Music loading error. Please contact technical support */ - kMusicContentCenterStatusErrMusicLoading = 5, + kMusicContentCenterStatusMusicLoading = 5, /** * 6: Music decryption error. Please contact technical support */ - kMusicContentCenterStatusErrMusicDecryption = 6, + kMusicContentCenterStatusMusicDecryption = 6, /** * 7: Http internal error. Please retry later. */ - kMusicContentCenterStatusErrHttpInternalError = 7, + kMusicContentCenterStatusHttpInternalError = 7, } MusicContentCenterStatusCode; typedef struct @@ -234,18 +234,18 @@ class IMusicContentCenterEventHandler { * * @param requestId The request id is same as that returned by getMusicCharts. * @param result The result of music chart collection - * @param errorCode The status of the request. See MusicContentCenterStatusCode + * @param status The status of the request. See MusicContentCenterStatusCode */ - virtual void onMusicChartsResult(const char* requestId, agora_refptr result, MusicContentCenterStatusCode errorCode) = 0; + virtual void onMusicChartsResult(const char* requestId, agora_refptr result, MusicContentCenterStatusCode status) = 0; /** * Music collection, occurs when getMusicCollectionByMusicChartId or searchMusic method is called. * * @param requestId The request id is same as that returned by getMusicCollectionByMusicChartId or searchMusic * @param result The result of music collection - * @param errorCode The status of the request. See MusicContentCenterStatusCode + * @param status The status of the request. See MusicContentCenterStatusCode */ - virtual void onMusicCollectionResult(const char* requestId, agora_refptr result, MusicContentCenterStatusCode errorCode) = 0; + virtual void onMusicCollectionResult(const char* requestId, agora_refptr result, MusicContentCenterStatusCode status) = 0; /** * Lyric url callback of getLyric, occurs when getLyric is called @@ -253,9 +253,9 @@ class IMusicContentCenterEventHandler { * @param requestId The request id is same as that returned by getLyric * @param songCode Song code * @param lyricUrl The lyric url of this music - * @param errorCode The status of the request. See MusicContentCenterStatusCode + * @param status The status of the request. See MusicContentCenterStatusCode */ - virtual void onLyricResult(const char* requestId, int64_t songCode, const char* lyricUrl, MusicContentCenterStatusCode errorCode) = 0; + virtual void onLyricResult(const char* requestId, int64_t songCode, const char* lyricUrl, MusicContentCenterStatusCode status) = 0; /** * Simple info callback of getSongSimpleInfo, occurs when getSongSimpleInfo is called @@ -263,9 +263,9 @@ class IMusicContentCenterEventHandler { * @param requestId The request id is same as that returned by getSongSimpleInfo. * @param songCode Song code * @param simpleInfo The metadata of the music. - * @param errorCode The status of the request. See MusicContentCenterStatusCode + * @param status The status of the request. See MusicContentCenterStatusCode */ - virtual void onSongSimpleInfoResult(const char* requestId, int64_t songCode, const char* simpleInfo, MusicContentCenterStatusCode errorCode) = 0; + virtual void onSongSimpleInfoResult(const char* requestId, int64_t songCode, const char* simpleInfo, MusicContentCenterStatusCode status) = 0; /** * Preload process callback, occurs when preload is called @@ -274,10 +274,10 @@ class IMusicContentCenterEventHandler { * @param songCode Song code * @param percent Preload progress (0 ~ 100) * @param lyricUrl The lyric url of this music - * @param status Preload status; see PreloadStatusCode. - * @param errorCode The status of the request. See MusicContentCenterStatusCode + * @param preloadStatus Preload status; see PreloadStatusCode. + * @param mccStatus The status of the request. See MusicContentCenterStatusCode */ - virtual void onPreLoadEvent(const char* requestId, int64_t songCode, int percent, const char* lyricUrl, PreloadStatusCode status, MusicContentCenterStatusCode errorCode) = 0; + virtual void onPreLoadEvent(const char* requestId, int64_t songCode, int percent, const char* lyricUrl, PreloadStatusCode preloadStatus, MusicContentCenterStatusCode mccStatus) = 0; virtual ~IMusicContentCenterEventHandler() {}; }; diff --git a/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/IAgoraParameter.h b/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/IAgoraParameter.h index 70ea5939e..b88969e1d 100644 --- a/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/IAgoraParameter.h +++ b/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/IAgoraParameter.h @@ -15,6 +15,7 @@ */ #pragma once // NOLINT(build/header_guard) +#include "AgoraRefPtr.h" // external key /** @@ -115,6 +116,7 @@ * set the video codec type, such as "H264", "JPEG" */ #define KEY_RTC_VIDEO_CODEC_TYPE "engine.video.codec_type" +#define KEY_RTC_VIDEO_MINOR_STREAM_CODEC_TYPE "engine.video.minor_stream_codec_type" #define KEY_RTC_VIDEO_CODEC_INDEX "che.video.videoCodecIndex" /** * only use average QP for quality scaling @@ -144,7 +146,7 @@ typedef CopyableAutoPtr AString; namespace base { -class IAgoraParameter { +class IAgoraParameter : public RefCountInterface { public: /** * release the resource @@ -300,6 +302,7 @@ class IAgoraParameter { virtual int convertPath(const char* filePath, agora::util::AString& value) = 0; + protected: virtual ~IAgoraParameter() {} }; diff --git a/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/IAgoraRhythmPlayer.h b/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/IAgoraRhythmPlayer.h index b39322a2d..e2e00ac70 100644 --- a/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/IAgoraRhythmPlayer.h +++ b/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/IAgoraRhythmPlayer.h @@ -35,19 +35,19 @@ enum RHYTHM_PLAYER_STATE_TYPE { }; /** - The error codes of the rhythm player. + The reason codes of the rhythm player. */ -enum RHYTHM_PLAYER_ERROR_TYPE { +enum RHYTHM_PLAYER_REASON { /** 0: The rhythm player works well. */ - RHYTHM_PLAYER_ERROR_OK = 0, + RHYTHM_PLAYER_REASON_OK = 0, /** 1: The rhythm player occurs a internal error. */ - RHYTHM_PLAYER_ERROR_FAILED = 1, + RHYTHM_PLAYER_REASON_FAILED = 1, /** 801: The rhythm player can not open the file. */ - RHYTHM_PLAYER_ERROR_CAN_NOT_OPEN = 801, + RHYTHM_PLAYER_REASON_CAN_NOT_OPEN = 801, /** 802: The rhythm player can not play the file. */ - RHYTHM_PLAYER_ERROR_CAN_NOT_PLAY, + RHYTHM_PLAYER_REASON_CAN_NOT_PLAY, /** 803: The file duration over the limit. The file duration limit is 1.2 seconds */ - RHYTHM_PLAYER_ERROR_FILE_OVER_DURATION_LIMIT, + RHYTHM_PLAYER_REASON_FILE_OVER_DURATION_LIMIT, }; /** 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 a54f24395..f7e8999b2 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 @@ -15,6 +15,9 @@ #include "IAgoraH265Transcoder.h" namespace agora { +namespace rtm { +class IStreamChannel; +} namespace rtc { template @@ -257,87 +260,87 @@ struct RtcConnection; */ struct LocalVideoStats { - /** - * ID of the local user. - */ - uid_t uid; - /** The actual bitrate (Kbps) while sending the local video stream. - * @note This value does not include the bitrate for resending the video after packet loss. - */ - int sentBitrate; - /** The actual frame rate (fps) while sending the local video stream. - * @note This value does not include the frame rate for resending the video after packet loss. - */ - int sentFrameRate; - /** The capture frame rate (fps) of the local video. - */ - int captureFrameRate; - /** The width of the capture frame (px). - */ - int captureFrameWidth; - /** The height of the capture frame (px). - */ - int captureFrameHeight; - /** - * The regulated frame rate of capture frame rate according to video encoder configuration. - */ - int regulatedCaptureFrameRate; - /** - * The regulated frame width (pixel) of capture frame width according to video encoder configuration. - */ - int regulatedCaptureFrameWidth; - /** - * The regulated frame height (pixel) of capture frame height according to video encoder configuration. - */ - int regulatedCaptureFrameHeight; - /** The output frame rate (fps) of the local video encoder. - */ - int encoderOutputFrameRate; - /** The width of the encoding frame (px). - */ - int encodedFrameWidth; - /** The height of the encoding frame (px). - */ - int encodedFrameHeight; - /** The output frame rate (fps) of the local video renderer. - */ - int rendererOutputFrameRate; - /** The target bitrate (Kbps) of the current encoder. This is an estimate made by the SDK based on the current network conditions. - */ - int targetBitrate; - /** The target frame rate (fps) of the current encoder. - */ - int targetFrameRate; - /** Quality adaption of the local video stream in the reported interval (based on the target frame - * rate and target bitrate). See #QUALITY_ADAPT_INDICATION. - */ - QUALITY_ADAPT_INDICATION qualityAdaptIndication; - /** The bitrate (Kbps) while encoding the local video stream. - * @note This value does not include the bitrate for resending the video after packet loss. - */ - int encodedBitrate; - /** The number of the sent video frames, represented by an aggregate value. - */ - int encodedFrameCount; - /** The codec type of the local video. See #VIDEO_CODEC_TYPE. - */ - VIDEO_CODEC_TYPE codecType; - /** - * The video packet loss rate (%) from the local client to the Agora server before applying the anti-packet loss strategies. - */ - unsigned short txPacketLossRate; - /** The brightness level of the video image captured by the local camera. See #CAPTURE_BRIGHTNESS_LEVEL_TYPE. - */ - CAPTURE_BRIGHTNESS_LEVEL_TYPE captureBrightnessLevel; - /** - * Whether we send dual stream now. - */ - bool dualStreamEnabled; - /** The hwEncoderAccelerating of the local video: - * - software = 0. - * - hardware = 1. - */ - int hwEncoderAccelerating; + /** + * ID of the local user. + */ + uid_t uid; + /** The actual bitrate (Kbps) while sending the local video stream. + * @note This value does not include the bitrate for resending the video after packet loss. + */ + int sentBitrate; + /** The actual frame rate (fps) while sending the local video stream. + * @note This value does not include the frame rate for resending the video after packet loss. + */ + int sentFrameRate; + /** The capture frame rate (fps) of the local video. + */ + int captureFrameRate; + /** The width of the capture frame (px). + */ + int captureFrameWidth; + /** The height of the capture frame (px). + */ + int captureFrameHeight; + /** + * The regulated frame rate of capture frame rate according to video encoder configuration. + */ + int regulatedCaptureFrameRate; + /** + * The regulated frame width (pixel) of capture frame width according to video encoder configuration. + */ + int regulatedCaptureFrameWidth; + /** + * The regulated frame height (pixel) of capture frame height according to video encoder configuration. + */ + int regulatedCaptureFrameHeight; + /** The output frame rate (fps) of the local video encoder. + */ + int encoderOutputFrameRate; + /** The width of the encoding frame (px). + */ + int encodedFrameWidth; + /** The height of the encoding frame (px). + */ + int encodedFrameHeight; + /** The output frame rate (fps) of the local video renderer. + */ + int rendererOutputFrameRate; + /** The target bitrate (Kbps) of the current encoder. This is an estimate made by the SDK based on the current network conditions. + */ + int targetBitrate; + /** The target frame rate (fps) of the current encoder. + */ + int targetFrameRate; + /** Quality adaption of the local video stream in the reported interval (based on the target frame + * rate and target bitrate). See #QUALITY_ADAPT_INDICATION. + */ + QUALITY_ADAPT_INDICATION qualityAdaptIndication; + /** The bitrate (Kbps) while encoding the local video stream. + * @note This value does not include the bitrate for resending the video after packet loss. + */ + int encodedBitrate; + /** The number of the sent video frames, represented by an aggregate value. + */ + int encodedFrameCount; + /** The codec type of the local video. See #VIDEO_CODEC_TYPE. + */ + VIDEO_CODEC_TYPE codecType; + /** + * The video packet loss rate (%) from the local client to the Agora server before applying the anti-packet loss strategies. + */ + unsigned short txPacketLossRate; + /** The brightness level of the video image captured by the local camera. See #CAPTURE_BRIGHTNESS_LEVEL_TYPE. + */ + CAPTURE_BRIGHTNESS_LEVEL_TYPE captureBrightnessLevel; + /** + * Whether we send dual stream now. + */ + bool dualStreamEnabled; + /** The hwEncoderAccelerating of the local video: + * - software = 0. + * - hardware = 1. + */ + int hwEncoderAccelerating; }; /** @@ -441,25 +444,25 @@ struct RemoteAudioStats */ unsigned int rxAudioBytes; - RemoteAudioStats() : - uid(0), - quality(0), - networkTransportDelay(0), - jitterBufferDelay(0), - audioLossRate(0), - numChannels(0), - receivedSampleRate(0), - receivedBitrate(0), - totalFrozenTime(0), - frozenRate(0), - mosValue(0), - frozenRateByCustomPlcCount(0), - plcCount(0), - totalActiveTime(0), - publishDuration(0), - qoeQuality(0), - qualityChangedReason(0), - rxAudioBytes(0) {} + RemoteAudioStats() + : uid(0), + quality(0), + networkTransportDelay(0), + jitterBufferDelay(0), + audioLossRate(0), + numChannels(0), + receivedSampleRate(0), + receivedBitrate(0), + totalFrozenTime(0), + frozenRate(0), + mosValue(0), + frozenRateByCustomPlcCount(0), + plcCount(0), + totalActiveTime(0), + publishDuration(0), + qoeQuality(0), + qualityChangedReason(0), + rxAudioBytes(0) {} }; /** @@ -575,8 +578,7 @@ struct VideoCompositingLayout { */ double alpha; - media::base::RENDER_MODE_TYPE - renderMode; // RENDER_MODE_HIDDEN: Crop, RENDER_MODE_FIT: Zoom to fit + media::base::RENDER_MODE_TYPE renderMode; // RENDER_MODE_HIDDEN: Crop, RENDER_MODE_FIT: Zoom to fit Region() : uid(0), @@ -619,10 +621,10 @@ struct VideoCompositingLayout { VideoCompositingLayout() : canvasWidth(0), canvasHeight(0), - backgroundColor(NULL), + backgroundColor(OPTIONAL_NULLPTR), regions(NULL), regionCount(0), - appData(NULL), + appData(OPTIONAL_NULLPTR), appDataLength(0) {} }; @@ -1033,7 +1035,7 @@ struct ChannelMediaOptions { * - `false`: (Default) Do not publish the video track of the secondary camera capturer. */ Optional publishSecondaryCameraTrack; - /** + /** * Whether to publish the video of the third camera track. * - `true`: Publish the video track of the third camera capturer. * - `false`: (Default) Do not publish the video track of the third camera capturer. @@ -1078,7 +1080,7 @@ struct ChannelMediaOptions { * - false: (Default) Do not publish the captured video from the secondary screen. */ Optional publishSecondaryScreenTrack; - /** + /** * Whether to publish the captured video from the third screen: * - true: Publish the captured video from the third screen. * - false: (Default) Do not publish the captured video from the third screen. @@ -1132,6 +1134,12 @@ struct ChannelMediaOptions { * - `false`: (Default) Do not publish the local transcoded video track. */ Optional publishTranscodedVideoTrack; + /** + * Whether to publish the local mixed track. + * - `true`: Publish the audio track of local mixed track. + * - `false`: (Default) Do not publish the local mixed track. + */ + Optional publishMixedAudioTrack; /** * Whether to automatically subscribe to all remote audio streams when the user joins a channel: * - `true`: (Default) Subscribe to all remote audio streams. @@ -1235,7 +1243,7 @@ struct ChannelMediaOptions { SET_FROM(publishCameraTrack); SET_FROM(publishSecondaryCameraTrack); SET_FROM(publishThirdCameraTrack); - SET_FROM(publishFourthCameraTrack); + SET_FROM(publishFourthCameraTrack); SET_FROM(publishMicrophoneTrack); #if defined(__ANDROID__) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) SET_FROM(publishScreenCaptureVideo); @@ -1247,6 +1255,7 @@ struct ChannelMediaOptions { SET_FROM(publishFourthScreenTrack); #endif SET_FROM(publishTranscodedVideoTrack); + SET_FROM(publishMixedAudioTrack); SET_FROM(publishCustomAudioTrack); SET_FROM(publishCustomAudioTrackId); SET_FROM(publishCustomVideoTrack); @@ -1293,6 +1302,7 @@ struct ChannelMediaOptions { ADD_COMPARE(publishFourthScreenTrack); #endif ADD_COMPARE(publishTranscodedVideoTrack); + ADD_COMPARE(publishMixedAudioTrack); ADD_COMPARE(publishCustomAudioTrack); ADD_COMPARE(publishCustomAudioTrackId); ADD_COMPARE(publishCustomVideoTrack); @@ -1342,6 +1352,7 @@ struct ChannelMediaOptions { REPLACE_BY(publishFourthScreenTrack); #endif REPLACE_BY(publishTranscodedVideoTrack); + REPLACE_BY(publishMixedAudioTrack); REPLACE_BY(publishCustomAudioTrack); REPLACE_BY(publishCustomAudioTrackId); REPLACE_BY(publishCustomVideoTrack); @@ -1512,8 +1523,7 @@ class IRtcEngineEventHandler { @param delay The network delay (ms) from the sender to the receiver, including the delay caused by audio sampling pre-processing, network transmission, and network jitter buffering. @param lost The audio packet loss rate (%) from the sender to the receiver. */ - virtual void onAudioQuality(uid_t uid, int quality, unsigned short delay, - unsigned short lost) __deprecated { + virtual void onAudioQuality(uid_t uid, int quality, unsigned short delay, unsigned short lost) __deprecated { (void)uid; (void)quality; (void)delay; @@ -1615,6 +1625,7 @@ class IRtcEngineEventHandler { If the startAudioMixing method call fails, the SDK returns the error code 701. */ virtual void onAudioMixingFinished() __deprecated {} + /** * Occurs when the playback of the local audio effect file finishes. * @@ -1782,7 +1793,7 @@ class IRtcEngineEventHandler { (void)width; (void)height; (void)rotation; - } + } /** Occurs when the local video stream state changes. * @@ -1792,13 +1803,13 @@ class IRtcEngineEventHandler { * you to troubleshoot issues when exceptions occur. * * The SDK triggers the onLocalVideoStateChanged callback with the state code of `LOCAL_VIDEO_STREAM_STATE_FAILED` - * and error code of `LOCAL_VIDEO_STREAM_ERROR_CAPTURE_FAILURE` in the following situations: + * and error code of `LOCAL_VIDEO_STREAM_REASON_CAPTURE_FAILURE` in the following situations: * - The app switches to the background, and the system gets the camera resource. * - The camera starts normally, but does not output video for four consecutive seconds. * * When the camera outputs the captured video frames, if the video frames are the same for 15 * consecutive frames, the SDK triggers the `onLocalVideoStateChanged` callback with the state code - * of `LOCAL_VIDEO_STREAM_STATE_CAPTURING` and error code of `LOCAL_VIDEO_STREAM_ERROR_CAPTURE_FAILURE`. + * of `LOCAL_VIDEO_STREAM_STATE_CAPTURING` and error code of `LOCAL_VIDEO_STREAM_REASON_CAPTURE_FAILURE`. * Note that the video frame duplication detection is only available for video frames with a resolution * greater than 200 × 200, a frame rate greater than or equal to 10 fps, and a bitrate less than 20 Kbps. * @@ -1808,12 +1819,12 @@ class IRtcEngineEventHandler { * * @param source The video source type: #VIDEO_SOURCE_TYPE. * @param state The state of the local video. See #LOCAL_VIDEO_STREAM_STATE. - * @param error The detailed error information. See #LOCAL_VIDEO_STREAM_ERROR. + * @param reason The detailed error information. See #LOCAL_VIDEO_STREAM_REASON. */ - virtual void onLocalVideoStateChanged(VIDEO_SOURCE_TYPE source, LOCAL_VIDEO_STREAM_STATE state, LOCAL_VIDEO_STREAM_ERROR error) { + virtual void onLocalVideoStateChanged(VIDEO_SOURCE_TYPE source, LOCAL_VIDEO_STREAM_STATE state, LOCAL_VIDEO_STREAM_REASON reason) { (void)source; (void)state; - (void)error; + (void)reason; } /** @@ -1836,13 +1847,13 @@ class IRtcEngineEventHandler { /** Occurs when the renderer receives the first frame of the remote video. * - * @param userId The user ID of the remote user sending the video stream. + * @param uid The user ID of the remote user sending the video stream. * @param width The width (px) of the video frame. * @param height The height (px) of the video stream. * @param elapsed The time elapsed (ms) from the local user calling `joinChannel` until the SDK triggers this callback. */ - virtual void onFirstRemoteVideoFrame(uid_t userId, int width, int height, int elapsed) { - (void)userId; + virtual void onFirstRemoteVideoFrame(uid_t uid, int width, int height, int elapsed) { + (void)uid; (void)width; (void)height; (void)elapsed; @@ -1922,8 +1933,8 @@ class IRtcEngineEventHandler { - true: The remote user has paused sending the video stream. - false: The remote user has resumed sending the video stream. */ - virtual void onUserMuteVideo(uid_t userId, bool muted) { - (void)userId; + virtual void onUserMuteVideo(uid_t uid, bool muted) { + (void)uid; (void)muted; } @@ -1945,11 +1956,11 @@ class IRtcEngineEventHandler { } /** - * Occurs when the remote user state is updated. + * Occurs when the remote user audio or video state is updated. * @param uid The uid of the remote user. - * @param state The remote user state: #REMOTE_USER_STATE. + * @param state The remote user's audio or video state: #REMOTE_USER_STATE. */ - virtual void onUserStateChanged(uid_t uid, uint32_t state) { + virtual void onUserStateChanged(uid_t uid, REMOTE_USER_STATE state) { (void)uid; (void)state; } @@ -1969,17 +1980,6 @@ class IRtcEngineEventHandler { (void)enabled; } - /** Reports the statistics of the local audio stream. - * - * The SDK triggers this callback once every two seconds. - * - * @param stats The statistics of the local audio stream. - * See LocalAudioStats. - */ - virtual void onLocalAudioStats(const LocalAudioStats& stats) { - (void)stats; - } - /** Reports the statistics of the audio stream from each remote user/host. The SDK triggers this callback once every two seconds for each remote user who is sending audio @@ -1991,6 +1991,17 @@ class IRtcEngineEventHandler { (void)stats; } + /** Reports the statistics of the local audio stream. + * + * The SDK triggers this callback once every two seconds. + * + * @param stats The statistics of the local audio stream. + * See LocalAudioStats. + */ + virtual void onLocalAudioStats(const LocalAudioStats& stats) { + (void)stats; + } + /** Reports the statistics of the local video stream. * * The SDK triggers this callback once every two seconds for each @@ -2020,12 +2031,14 @@ class IRtcEngineEventHandler { virtual void onRemoteVideoStats(const RemoteVideoStats& stats) { (void)stats; } + /** * Occurs when the camera turns on and is ready to capture the video. * @deprecated Use `LOCAL_VIDEO_STREAM_STATE_CAPTURING(1)` in onLocalVideoStateChanged instead. * This callback indicates that the camera has been successfully turned on and you can start to capture video. */ virtual void onCameraReady() __deprecated {} + /** * Occurs when the camera focus area changes. * @@ -2124,11 +2137,11 @@ class IRtcEngineEventHandler { callback. @param state The state code. See #RHYTHM_PLAYER_STATE_TYPE. - @param errorCode The error code. See #RHYTHM_PLAYER_ERROR_TYPE. + @param reason The error code. See #RHYTHM_PLAYER_REASON. */ - virtual void onRhythmPlayerStateChanged(RHYTHM_PLAYER_STATE_TYPE state, RHYTHM_PLAYER_ERROR_TYPE errorCode) { + virtual void onRhythmPlayerStateChanged(RHYTHM_PLAYER_STATE_TYPE state, RHYTHM_PLAYER_REASON reason) { (void)state; - (void)errorCode; + (void)reason; } /** @@ -2164,14 +2177,14 @@ class IRtcEngineEventHandler { * The SDK triggers this callback when the user receives the data stream that another user sends * by calling the \ref agora::rtc::IRtcEngine::sendStreamMessage "sendStreamMessage" method. * - * @param userId ID of the user who sends the data stream. + * @param uid ID of the user who sends the data stream. * @param streamId The ID of the stream data. * @param data The data stream. * @param length The length (byte) of the data stream. * @param sentTs The time when the data stream sent. */ - virtual void onStreamMessage(uid_t userId, int streamId, const char* data, size_t length, uint64_t sentTs) { - (void)userId; + virtual void onStreamMessage(uid_t uid, int streamId, const char* data, size_t length, uint64_t sentTs) { + (void)uid; (void)streamId; (void)data; (void)length; @@ -2183,15 +2196,15 @@ class IRtcEngineEventHandler { * The SDK triggers this callback when the user fails to receive the data stream that another user sends * by calling the \ref agora::rtc::IRtcEngine::sendStreamMessage "sendStreamMessage" method. * - * @param userId ID of the user who sends the data stream. + * @param uid ID of the user who sends the data stream. * @param streamId The ID of the stream data. * @param code The error code. * @param missed The number of lost messages. * @param cached The number of incoming cached messages when the data stream is * interrupted. */ - virtual void onStreamMessageError(uid_t userId, int streamId, int code, int missed, int cached) { - (void)userId; + virtual void onStreamMessageError(uid_t uid, int streamId, int code, int missed, int cached) { + (void)uid; (void)streamId; (void)code; (void)missed; @@ -2247,18 +2260,6 @@ class IRtcEngineEventHandler { (void)elapsed; } - /** Occurs when the SDK receives the first audio frame from a specific remote user. - * @deprecated Use `onRemoteAudioStateChanged` instead. - * - * @param uid ID of the remote user. - * @param elapsed The time elapsed (ms) from the loca user calling `joinChannel` - * until this callback is triggered. - */ - virtual void onFirstRemoteAudioFrame(uid_t uid, int elapsed) __deprecated { - (void)uid; - (void)elapsed; - } - /** * Occurs when the SDK decodes the first remote audio frame for playback. * @@ -2280,6 +2281,18 @@ class IRtcEngineEventHandler { (void)elapsed; } + /** Occurs when the SDK receives the first audio frame from a specific remote user. + * @deprecated Use `onRemoteAudioStateChanged` instead. + * + * @param uid ID of the remote user. + * @param elapsed The time elapsed (ms) from the loca user calling `joinChannel` + * until this callback is triggered. + */ + virtual void onFirstRemoteAudioFrame(uid_t uid, int elapsed) __deprecated { + (void)uid; + (void)elapsed; + } + /** Occurs when the local audio state changes. * * When the state of the local audio stream changes (including the state of the audio capture and encoding), the SDK @@ -2291,12 +2304,12 @@ class IRtcEngineEventHandler { * parameter for details. * * @param state State of the local audio. See #LOCAL_AUDIO_STREAM_STATE. - * @param error The error information of the local audio. - * See #LOCAL_AUDIO_STREAM_ERROR. + * @param reason The reason information of the local audio. + * See #LOCAL_AUDIO_STREAM_REASON. */ - virtual void onLocalAudioStateChanged(LOCAL_AUDIO_STREAM_STATE state, LOCAL_AUDIO_STREAM_ERROR error) { + virtual void onLocalAudioStateChanged(LOCAL_AUDIO_STREAM_STATE state, LOCAL_AUDIO_STREAM_REASON reason) { (void)state; - (void)error; + (void)reason; } /** Occurs when the remote audio state changes. @@ -2335,12 +2348,16 @@ class IRtcEngineEventHandler { * * @param userId The ID of the active speaker. A `uid` of 0 means the local user. */ - virtual void onActiveSpeaker(uid_t userId) { (void)userId; } + virtual void onActiveSpeaker(uid_t uid) { + (void)uid; + } + /** Reports result of content inspection. * * @param result The result of content inspection: #CONTENT_INSPECT_RESULT. */ virtual void onContentInspectResult(media::CONTENT_INSPECT_RESULT result) { (void)result; } + /** Reports the result of taking a video snapshot. * * After a successful `takeSnapshot` method call, the SDK triggers this callback to report whether the snapshot is @@ -2365,6 +2382,7 @@ class IRtcEngineEventHandler { (void)height; (void)errCode; } + /** * Occurs when the user role switches in the interactive live streaming. * @@ -2377,6 +2395,7 @@ class IRtcEngineEventHandler { (void)newRole; (void)newRoleOptions; } + /** * Occurs when the user role in a Live-Broadcast channel fails to switch, for example, from a broadcaster * to an audience or vice versa. @@ -2388,6 +2407,7 @@ class IRtcEngineEventHandler { (void)reason; (void)currentRole; } + /** Occurs when the audio device volume changes. @param deviceType The device type, see #MEDIA_DEVICE_TYPE @param volume The volume of the audio device. @@ -2410,13 +2430,13 @@ class IRtcEngineEventHandler { * * @param url The URL address where the state of the media push changes. * @param state The current state of the media push: #RTMP_STREAM_PUBLISH_STATE. - * @param errCode The detailed error information for the media push: #RTMP_STREAM_PUBLISH_ERROR_TYPE. + * @param reason The detailed error information for the media push: #RTMP_STREAM_PUBLISH_REASON. */ virtual void onRtmpStreamingStateChanged(const char* url, RTMP_STREAM_PUBLISH_STATE state, - RTMP_STREAM_PUBLISH_ERROR_TYPE errCode) { + RTMP_STREAM_PUBLISH_REASON reason) { (void)url; (void)state; - (void)errCode; + (void)reason; } /** Reports events during the media push. @@ -2456,7 +2476,6 @@ class IRtcEngineEventHandler { */ virtual void onAudioRoutingChanged(int routing) { (void)routing; } - /** * Occurs when the state of the media stream relay changes. * @@ -2493,32 +2512,6 @@ class IRtcEngineEventHandler { (void)code; } - /** - * Reports events during the media stream relay. - * @deprecated v4.2.0. This callback is not recommended and will be removed in future releases. - * @param code The event code for media stream relay: - * - `RELAY_EVENT_NETWORK_DISCONNECTED(0)`: The user disconnects from the server due to poor - * network connections. - * - `RELAY_EVENT_NETWORK_CONNECTED(1)`: The network reconnects. - * - `RELAY_EVENT_PACKET_JOINED_SRC_CHANNEL(2)`: The user joins the source channel. - * - `RELAY_EVENT_PACKET_JOINED_DEST_CHANNEL(3)`: The user joins the destination channel. - * - `RELAY_EVENT_PACKET_SENT_TO_DEST_CHANNEL(4)`: The SDK starts relaying the media stream to the - * destination channel. - * - `RELAY_EVENT_PACKET_RECEIVED_VIDEO_FROM_SRC(5)`: The server receives the video stream from - * the source channel. - * - `RELAY_EVENT_PACKET_RECEIVED_AUDIO_FROM_SRC(6)`: The server receives the audio stream from - * the source channel. - * - `RELAY_EVENT_PACKET_UPDATE_DEST_CHANNEL(7)`: The destination channel is updated. - * - `RELAY_EVENT_PACKET_UPDATE_DEST_CHANNEL_REFUSED(8)`: The destination channel update fails due - * to internal reasons. Deprecated from 4.1.0 - * - `RELAY_EVENT_PACKET_UPDATE_DEST_CHANNEL_NOT_CHANGE(9)`: The destination channel does not - * change, which means that the destination channel fails to be updated. - * - `RELAY_EVENT_PACKET_UPDATE_DEST_CHANNEL_IS_NULL(10)`: The destination channel name is NULL. - * - `RELAY_EVENT_VIDEO_PROFILE_UPDATE(11)`: The video profile is sent to the server. - */ - virtual void onChannelMediaRelayEvent(int code) __deprecated { - (void)code; - } /** * Occurs when the published media stream falls back to an audio-only stream due to poor network conditions or * switches back to video stream after the network conditions improve. @@ -2535,6 +2528,7 @@ class IRtcEngineEventHandler { virtual void onLocalPublishFallbackToAudioOnly(bool isFallbackOrRecover) { (void)isFallbackOrRecover; } + /** * Occurs when the remote media stream falls back to audio-only stream due to poor network conditions or * switches back to video stream after the network conditions improve. @@ -2571,8 +2565,7 @@ class IRtcEngineEventHandler { @param rxKBitRate Received bitrate (Kbps) of the audio packet sent from the remote user. */ - virtual void onRemoteAudioTransportStats(uid_t uid, unsigned short delay, unsigned short lost, - unsigned short rxKBitRate) __deprecated { + virtual void onRemoteAudioTransportStats(uid_t uid, unsigned short delay, unsigned short lost, unsigned short rxKBitRate) __deprecated { (void)uid; (void)delay; (void)lost; @@ -2596,8 +2589,7 @@ class IRtcEngineEventHandler { @param rxKBitRate The bitrate (Kbps) of the video packet sent from the remote user. */ - virtual void onRemoteVideoTransportStats(uid_t uid, unsigned short delay, unsigned short lost, - unsigned short rxKBitRate) __deprecated { + virtual void onRemoteVideoTransportStats(uid_t uid, unsigned short delay, unsigned short lost, unsigned short rxKBitRate) __deprecated { (void)uid; (void)delay; (void)lost; @@ -2635,7 +2627,7 @@ class IRtcEngineEventHandler { * @param currentStats Instantaneous value of optimization effect. * @param averageStats Average value of cumulative optimization effect. */ - virtual void onWlAccStats(WlAccStats currentStats, WlAccStats averageStats) { + virtual void onWlAccStats(const WlAccStats& currentStats, const WlAccStats& averageStats) { (void)currentStats; (void)averageStats; } @@ -2703,6 +2695,42 @@ class IRtcEngineEventHandler { (void)uid; (void)info; } + + /** + * Occurs when the user account is updated. + * + * @param uid The user ID. + * @param userAccount The user account. + */ + virtual void onUserAccountUpdated(uid_t uid, const char* userAccount){ + (void)uid; + (void)userAccount; + } + + /** + * Reports the tracing result of video rendering event of the user. + * + * @param uid The user ID. + * @param currentEvent The current event of the tracing result: #MEDIA_TRACE_EVENT. + * @param tracingInfo The tracing result: #VideoRenderingTracingInfo. + */ + virtual void onVideoRenderingTracingResult(uid_t uid, MEDIA_TRACE_EVENT currentEvent, VideoRenderingTracingInfo tracingInfo) { + (void)uid; + (void)currentEvent; + (void)tracingInfo; + } + + /** + * Occurs when local video transcoder stream has an error. + * + * @param stream Stream type of TranscodingVideoStream. + * @param error Error code of VIDEO_TRANSCODER_ERROR. + */ + virtual void onLocalVideoTranscoderError(const TranscodingVideoStream& stream, VIDEO_TRANSCODER_ERROR error){ + (void)stream; + (void)error; + } + /** * Reports the user log upload result * @param requestId RequestId of the upload @@ -2780,6 +2808,24 @@ class IRtcEngineEventHandler { (void)newState; (void)elapseSinceLastState; } + + /** + * Occurs when receive a video transcoder stream which has video layout info. + * + * @param uid user id of the transcoded stream. + * @param width width of the transcoded stream. + * @param height height of the transcoded stream. + * @param layoutCount count of layout info in the transcoded stream. + * @param layoutlist video layout info list of the transcoded stream. + */ + virtual void onTranscodedStreamLayoutInfo(uid_t uid, int width, int height, int layoutCount,const VideoLayout* layoutlist) { + (void)uid; + (void)width; + (void)height; + (void)layoutCount; + (void)layoutlist; + } + /** * The event callback of the extension. * @@ -2796,6 +2842,7 @@ class IRtcEngineEventHandler { (void)key; (void)value; } + /** * Occurs when the extension is enabled. * @@ -2808,6 +2855,7 @@ class IRtcEngineEventHandler { (void)provider; (void)extension; } + /** * Occurs when the extension is disabled. * @@ -2820,6 +2868,7 @@ class IRtcEngineEventHandler { (void)provider; (void)extension; } + /** * Occurs when the extension runs incorrectly. * @@ -2837,39 +2886,15 @@ class IRtcEngineEventHandler { (void)error; (void)message; } - /** - * Occurs when the user account is updated. - * - * @param uid The user ID. - * @param userAccount The user account. - */ - virtual void onUserAccountUpdated(uid_t uid, const char* userAccount){ - (void)uid; - (void)userAccount; - } - - /** - * Occurs when local video transcoder stream has an error. - * - * @param stream Stream type of TranscodingVideoStream. - * @param error Error code of VIDEO_TRANSCODER_ERROR. - */ - virtual void onLocalVideoTranscoderError(const TranscodingVideoStream& stream, VIDEO_TRANSCODER_ERROR error){ - (void)stream; - (void)error; - } /** - * Reports the tracing result of video rendering event of the user. - * - * @param uid The user ID. - * @param currentEvent The current event of the tracing result: #MEDIA_TRACE_EVENT. - * @param tracingInfo The tracing result: #VideoRenderingTracingInfo. + * Occurs when the SDK receives RTM setting change response. + * + * @technical preview + * @param code The error code. */ - virtual void onVideoRenderingTracingResult(uid_t uid, MEDIA_TRACE_EVENT currentEvent, VideoRenderingTracingInfo tracingInfo) { - (void)uid; - (void)currentEvent; - (void)tracingInfo; + virtual void onSetRtmFlagResult(int code) { + (void)code; } }; @@ -3027,8 +3052,6 @@ class IVideoDeviceManager { virtual void release() = 0; }; - -class IRtcEngineEventHandlerEx; /** * The context of IRtcEngine. */ @@ -3124,11 +3147,8 @@ struct RtcEngineContext { bool autoRegisterAgoraExtensions; RtcEngineContext() - : eventHandler(NULL), appId(NULL), context(NULL), - channelProfile(CHANNEL_PROFILE_LIVE_BROADCASTING), - license(NULL), - audioScenario(AUDIO_SCENARIO_DEFAULT), - areaCode(AREA_CODE_GLOB), + : eventHandler(NULL), appId(NULL), context(NULL), channelProfile(CHANNEL_PROFILE_LIVE_BROADCASTING), + license(NULL), audioScenario(AUDIO_SCENARIO_DEFAULT), areaCode(AREA_CODE_GLOB), logConfig(), useExternalEglContext(false), domainLimit(false), autoRegisterAgoraExtensions(true) {} }; @@ -3136,6 +3156,8 @@ struct RtcEngineContext { */ class IMetadataObserver { public: + virtual ~IMetadataObserver() {} + /** The metadata type. * * @note We only support video metadata for now. @@ -3163,25 +3185,25 @@ class IMetadataObserver { */ struct Metadata { - /** The User ID that sent the metadata. - * - For the receiver: The user ID of the user who sent the `metadata`. - * - For the sender: Ignore this value. - */ - unsigned int uid; - /** The buffer size of the sent or received `metadata`. - */ - unsigned int size; - /** The buffer address of the sent or received `metadata`. - */ - unsigned char *buffer; - /** The timestamp (ms) of the `metadata`. - * - */ - long long timeStampMs; + /** The User ID that sent the metadata. + * - For the receiver: The user ID of the user who sent the `metadata`. + * - For the sender: Ignore this value. + */ + unsigned int uid; + /** The buffer size of the sent or received `metadata`. + */ + unsigned int size; + /** The buffer address of the sent or received `metadata`. + */ + unsigned char* buffer; + /** The timestamp (ms) of the `metadata`. + * + */ + long long timeStampMs; + + Metadata() : uid(0), size(0), buffer(NULL), timeStampMs(0) {} }; - virtual ~IMetadataObserver() {} - /** Occurs when the SDK requests the maximum size of the metadata. * * @@ -3213,24 +3235,24 @@ class IMetadataObserver { * @note If the receiver is audience, the receiver cannot get the NTP timestamp (ms) * that the metadata sends. */ - virtual void onMetadataReceived(const Metadata &metadata) = 0; + virtual void onMetadataReceived(const Metadata& metadata) = 0; }; -// The error codes for media streaming +// The reason codes for media streaming // GENERATED_JAVA_ENUM_PACKAGE: io.agora.streaming -enum DIRECT_CDN_STREAMING_ERROR { +enum DIRECT_CDN_STREAMING_REASON { // No error occurs. - DIRECT_CDN_STREAMING_ERROR_OK = 0, + DIRECT_CDN_STREAMING_REASON_OK = 0, // A general error occurs (no specified reason). - DIRECT_CDN_STREAMING_ERROR_FAILED = 1, + DIRECT_CDN_STREAMING_REASON_FAILED = 1, // Audio publication error. - DIRECT_CDN_STREAMING_ERROR_AUDIO_PUBLICATION = 2, + DIRECT_CDN_STREAMING_REASON_AUDIO_PUBLICATION = 2, // Video publication error. - DIRECT_CDN_STREAMING_ERROR_VIDEO_PUBLICATION = 3, + DIRECT_CDN_STREAMING_REASON_VIDEO_PUBLICATION = 3, - DIRECT_CDN_STREAMING_ERROR_NET_CONNECT = 4, + DIRECT_CDN_STREAMING_REASON_NET_CONNECT = 4, // Already exist stream name. - DIRECT_CDN_STREAMING_ERROR_BAD_NAME = 5, + DIRECT_CDN_STREAMING_REASON_BAD_NAME = 5, }; // The connection state of media streaming @@ -3289,12 +3311,12 @@ class IDirectCdnStreamingEventHandler { /** * Event callback of direct cdn streaming * @param state Current status - * @param error Error Code + * @param reason Reason Code * @param message Message */ - virtual void onDirectCdnStreamingStateChanged(DIRECT_CDN_STREAMING_STATE state, DIRECT_CDN_STREAMING_ERROR error, const char* message) { + virtual void onDirectCdnStreamingStateChanged(DIRECT_CDN_STREAMING_STATE state, DIRECT_CDN_STREAMING_REASON reason, const char* message) { (void)state; - (void)error; + (void)reason; (void)message; }; @@ -3435,11 +3457,7 @@ struct ExtensionInfo { */ uid_t localUid; - ExtensionInfo() - : mediaSourceType(agora::media::UNKNOWN_MEDIA_SOURCE), - remoteUid(0), - channelId(NULL), - localUid(0) {} + ExtensionInfo() : mediaSourceType(agora::media::UNKNOWN_MEDIA_SOURCE), remoteUid(0), channelId(NULL), localUid(0) {} }; class IMediaPlayer; @@ -3450,7 +3468,6 @@ class IMediaRecorder; * * `IRtcEngine` provides the main methods that your app can call. * - * Before calling other APIs, you must call createAgoraRtcEngine to create an `IRtcEngine` object. */ class IRtcEngine : public agora::base::IEngineBase { public: @@ -3527,7 +3544,7 @@ class IRtcEngine : public agora::base::IEngineBase { /** * Queries the capacity of the current device codec. * - * @param codecInfo An array of the codec cap information: CodecCapInfo. + * @param codec_info An array of the codec cap information: CodecCapInfo. * @param size The array size. * @return * 0: Success. @@ -3535,6 +3552,17 @@ class IRtcEngine : public agora::base::IEngineBase { */ virtual int queryCodecCapability(CodecCapInfo* codecInfo, int& size) = 0; + /** + * Queries the score of the current device. + * + * @return + * > 0: If the value is greater than 0, it means that the device score has been retrieved and represents the score value. + * Most devices score between 60-100, with higher scores indicating better performance. + * + * < 0: Failure. + */ + virtual int queryDeviceScore() = 0; + /** * Preload a channel. * @@ -3542,8 +3570,7 @@ class IRtcEngine : public agora::base::IEngineBase { * * A successful call of this method will reduce the time of joining the same channel. * - * @since v4.2.2 - * @note + * Note: * 1. The SDK supports preloading up to 20 channels. Once the preloaded channels exceed the limit, the SDK will keep the latest 20 available. * 2. Renew the token of the preloaded channel by calling this method with the same 'channelId' and 'uid'. * @@ -3582,8 +3609,7 @@ class IRtcEngine : public agora::base::IEngineBase { * * A successful call of this method will reduce the time of joining the same channel. * - * @since v4.2.2 - * @note + * Note: * 1. The SDK supports preloading up to 20 channels. Once the preloaded channels exceed the limit, the SDK will keep the latest 20 available. * 2. Renew the token of the preloaded channel by calling this method with the same 'channelId' and 'userAccount'. * @@ -3615,15 +3641,13 @@ class IRtcEngine : public agora::base::IEngineBase { * - -102: The channel name is invalid. You need to pass in a valid channel name in channelId to * preload the channel again. */ - virtual int preloadChannel(const char* token, const char* channelId, const char* userAccount) = 0; + virtual int preloadChannelWithUserAccount(const char* token, const char* channelId, const char* userAccount) = 0; /** * Update token of the preloaded channels. * * An easy way to update all preloaded channels' tokens, if all preloaded channels use the same token. * - * @since v4.2.2 - * @note * If preloaded channels use different tokens, we need to call the 'preloadChannel' method with the same 'channelId' * and 'uid' or 'userAccount' to update the corresponding token. * @@ -3697,8 +3721,7 @@ class IRtcEngine : public agora::base::IEngineBase { * rejoin the channel. * - -121: The user ID is invalid. You need to pass in a valid user ID in uid to rejoin the channel. */ - virtual int joinChannel(const char* token, const char* channelId, const char* info, - uid_t uid) = 0; + virtual int joinChannel(const char* token, const char* channelId, const char* info, uid_t uid) = 0; /** * Joins a channel with media options. @@ -3767,8 +3790,7 @@ class IRtcEngine : public agora::base::IEngineBase { * rejoin the channel. * - -121: The user ID is invalid. You need to pass in a valid user ID in uid to rejoin the channel. */ - virtual int joinChannel(const char* token, const char* channelId, uid_t uid, - const ChannelMediaOptions& options) = 0; + virtual int joinChannel(const char* token, const char* channelId, uid_t uid, const ChannelMediaOptions& options) = 0; /** * Updates the channel media options after joining the channel. @@ -3947,7 +3969,7 @@ class IRtcEngine : public agora::base::IEngineBase { /** Starts a video call test. * - * @param config Configuration for video call test. + * @param config: configuration for video call test. * * @return * - 0: Success. @@ -4287,6 +4309,26 @@ class IRtcEngine : public agora::base::IEngineBase { */ virtual int setVideoScenario(VIDEO_APPLICATION_SCENARIO_TYPE scenarioType) = 0; + /** + * Sets the video qoe preference. + * + * @since v4.2.1 + * + * You can call this method to set the expected QoE Preference. + * The SDK will optimize the video experience for each preference you set. + * + * + * @param qoePreference The qoe preference type. See #VIDEO_QOE_PREFERENCE_TYPE. + * + * @return + * - 0: Success. + * - < 0: Failure. + * - ERR_FAILED (1): A general error occurs (no specified reason). + * - ERR_NOT_SUPPORTED (4): Unable to set video application scenario. + * - ERR_NOT_INITIALIZED (7): The SDK is not initialized. + */ + virtual int setVideoQoEPreference(VIDEO_QOE_PREFERENCE_TYPE qoePreference) = 0; + /** * Enables the audio. * @@ -4314,7 +4356,7 @@ class IRtcEngine : public agora::base::IEngineBase { * - < 0: Failure. */ virtual int disableAudio() = 0; - + /** * Sets the audio parameters and application scenarios. * @@ -4337,7 +4379,7 @@ class IRtcEngine : public agora::base::IEngineBase { * - < 0: Failure. */ virtual int setAudioProfile(AUDIO_PROFILE_TYPE profile, AUDIO_SCENARIO_TYPE scenario) __deprecated = 0; - + /** * Sets the audio profile. * @@ -4601,6 +4643,17 @@ class IRtcEngine : public agora::base::IEngineBase { */ virtual int setDefaultMuteAllRemoteVideoStreams(bool mute) __deprecated = 0; + /** + * Sets the default stream type of the remote video if the remote user has enabled dual-stream. + * + * @param streamType Sets the default video stream type: #VIDEO_STREAM_TYPE. + * + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int setRemoteDefaultVideoStreamType(VIDEO_STREAM_TYPE streamType) = 0; + /** * Stops or resumes receiving the video stream of a specified user. * @@ -4650,17 +4703,6 @@ class IRtcEngine : public agora::base::IEngineBase { */ virtual int setRemoteVideoSubscriptionOptions(uid_t uid, const VideoSubscriptionOptions &options) = 0; - /** - * Sets the default stream type of the remote video if the remote user has enabled dual-stream. - * - * @param streamType Sets the default video stream type: #VIDEO_STREAM_TYPE. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setRemoteDefaultVideoStreamType(VIDEO_STREAM_TYPE streamType) = 0; - /** * Sets the blocklist of subscribe remote stream audio. * @@ -4840,8 +4882,8 @@ class IRtcEngine : public agora::base::IEngineBase { - < 0: Failure. */ virtual int stopAudioRecording() = 0; - - /** + + /** * Creates a media player source object and return its pointer. If full featured * media player source is supported, it will create it, or it will create a simple * media player. @@ -4869,7 +4911,7 @@ class IRtcEngine : public agora::base::IEngineBase { /** * Creates a media recorder object and return its pointer. * - * @param info The RecorderStreamInfo object. It contains user ID and channel name of user. + * @param info The RecorderStreamInfo object. It contains the user ID and the channel name. * * @return * - The pointer to \ref rtc::IMediaRecorder "IMediaRecorder", @@ -5405,6 +5447,7 @@ class IRtcEngine : public agora::base::IEngineBase { - < 0: Failure. */ virtual int enableSoundPositionIndication(bool enabled) = 0; + /** Sets the sound position and gain of a remote user. When the local user calls this method to set the sound position of a remote user, the sound difference between the left and right channels allows the local user to track the real-time position of the remote user, creating a real sense of space. This method applies to massively multiplayer online games, such as Battle Royale games. @@ -5441,7 +5484,7 @@ class IRtcEngine : public agora::base::IEngineBase { /** Sets remote user parameters for spatial audio @param uid The ID of the remote user. - @param params Spatial audio parameters. see SpatialAudioParams. + @param param spatial audio parameters: SpatialAudioParams. @return int - 0: Success. @@ -5737,8 +5780,7 @@ class IRtcEngine : public agora::base::IEngineBase { - 0: Success. - -1: Failure. */ - virtual int setLocalVoiceEqualization(AUDIO_EQUALIZATION_BAND_FREQUENCY bandFrequency, - int bandGain) = 0; + virtual int setLocalVoiceEqualization(AUDIO_EQUALIZATION_BAND_FREQUENCY bandFrequency, int bandGain) = 0; /** Sets the local voice reverberation. @@ -5761,6 +5803,7 @@ class IRtcEngine : public agora::base::IEngineBase { - -1(ERR_FAILED): A general error occurs (no specified reason). */ virtual int setHeadphoneEQPreset(HEADPHONE_EQUALIZER_PRESET preset) = 0; + /** Sets the parameters of audio playback effect for remote headphones after remote audio is mixed. @param lowGain The higher the parameter value, the deeper the sound. The value range is [-10,10]. @@ -5876,6 +5919,7 @@ class IRtcEngine : public agora::base::IEngineBase { * - < 0: Failure. */ virtual int setLocalRenderMode(media::base::RENDER_MODE_TYPE renderMode, VIDEO_MIRROR_MODE_TYPE mirrorMode) = 0; + /** * Updates the display mode of the video view of a remote user. * @@ -5936,8 +5980,6 @@ class IRtcEngine : public agora::base::IEngineBase { /** * Enables or disables the dual video stream mode. * - * @deprecated v4.2.0. This method is deprecated. Use setDualStreamMode instead. - * * If dual-stream mode is enabled, the subscriber can choose to receive the high-stream * (high-resolution high-bitrate video stream) or low-stream (low-resolution low-bitrate video stream) * video using \ref setRemoteVideoStreamType "setRemoteVideoStreamType". @@ -5954,8 +5996,6 @@ class IRtcEngine : public agora::base::IEngineBase { /** * Enables or disables the dual video stream mode. * - * @deprecated v4.2.0. This method is deprecated. Use setDualStreamMode instead. - * * If dual-stream mode is enabled, the subscriber can choose to receive the high-stream * (high-resolution high-bitrate video stream) or low-stream (low-resolution low-bitrate video stream) * video using \ref setRemoteVideoStreamType "setRemoteVideoStreamType". @@ -6000,8 +6040,7 @@ class IRtcEngine : public agora::base::IEngineBase { * - 0: Success. * - < 0: Failure. */ - virtual int setDualStreamMode(SIMULCAST_STREAM_MODE mode, - const SimulcastStreamConfig& streamConfig) = 0; + virtual int setDualStreamMode(SIMULCAST_STREAM_MODE mode, const SimulcastStreamConfig& streamConfig) = 0; /** * Sets the external audio track. @@ -6230,7 +6269,7 @@ class IRtcEngine : public agora::base::IEngineBase { * - 0: Success. * - < 0: Failure. */ - virtual int adjustUserPlaybackSignalVolume(unsigned int uid, int volume) = 0; + virtual int adjustUserPlaybackSignalVolume(uid_t uid, int volume) = 0; /** Sets the fallback option for the published video stream based on the network conditions. @@ -6287,6 +6326,59 @@ class IRtcEngine : public agora::base::IEngineBase { */ virtual int setHighPriorityUserList(uid_t* uidList, int uidNum, STREAM_FALLBACK_OPTIONS option) = 0; + /** + * Enable/Disable an extension. + * By calling this function, you can dynamically enable/disable the extension without changing the pipeline. + * For example, enabling/disabling Extension_A means the data will be adapted/bypassed by Extension_A. + * + * NOTE: For compatibility reasons, if you haven't call registerExtension, + * enableExtension will automatically register the specified extension. + * We suggest you call registerExtension explicitly. + * + * @param provider The name of the extension provider, e.g. agora.io. + * @param extension The name of the extension, e.g. agora.beauty. + * @param extensionInfo The information for extension. + * @param enable Whether to enable the extension: + * - true: (Default) Enable the extension. + * - false: Disable the extension. + * + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int enableExtension(const char* provider, const char* extension, const ExtensionInfo& extensionInfo, bool enable = true) = 0; + + /** + * Sets the properties of an extension. + * + * @param provider The name of the extension provider, e.g. agora.io. + * @param extension The name of the extension, e.g. agora.beauty. + * @param extensionInfo The information for extension. + * @param key The key of the extension. + * @param value The JSON formatted value of the extension key. + * + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int setExtensionProperty(const char* provider, const char* extension, const ExtensionInfo& extensionInfo, const char* key, const char* value) = 0; + + /** + * Gets the properties of an extension. + * + * @param provider The name of the extension provider, e.g. agora.io. + * @param extension The name of the extension, e.g. agora.beauty. + * @param extensionInfo The information for extension. + * @param key The key of the extension. + * @param value The value of the extension key. + * @param buf_len Maximum length of the JSON string indicating the extension property. + * + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int getExtensionProperty(const char* provider, const char* extension, const ExtensionInfo& extensionInfo, const char* key, char* value, int buf_len) = 0; + /** Enables loopback recording. * * If you enable loopback recording, the output of the default sound card is mixed into @@ -6370,8 +6462,7 @@ class IRtcEngine : public agora::base::IEngineBase { * - 0: Success. * - < 0: Failure. */ - virtual int setExtensionProviderProperty( - const char* provider, const char* key, const char* value) = 0; + virtual int setExtensionProviderProperty(const char* provider, const char* key, const char* value) = 0; /** * Registers an extension. Normally you should call this function immediately after engine initialization. @@ -6385,8 +6476,7 @@ class IRtcEngine : public agora::base::IEngineBase { * - 0: Success. * - < 0: Failure. */ - virtual int registerExtension(const char* provider, const char* extension, - agora::media::MEDIA_SOURCE_TYPE type = agora::media::UNKNOWN_MEDIA_SOURCE) = 0; + virtual int registerExtension(const char* provider, const char* extension, agora::media::MEDIA_SOURCE_TYPE type = agora::media::UNKNOWN_MEDIA_SOURCE) = 0; /** * Enable/Disable an extension. @@ -6408,30 +6498,7 @@ class IRtcEngine : public agora::base::IEngineBase { * - 0: Success. * - < 0: Failure. */ - virtual int enableExtension( - const char* provider, const char* extension, bool enable=true, agora::media::MEDIA_SOURCE_TYPE type = agora::media::UNKNOWN_MEDIA_SOURCE) = 0; - - /** - * Enable/Disable an extension. - * By calling this function, you can dynamically enable/disable the extension without changing the pipeline. - * For example, enabling/disabling Extension_A means the data will be adapted/bypassed by Extension_A. - * - * NOTE: For compatibility reasons, if you haven't call registerExtension, - * enableExtension will automatically register the specified extension. - * We suggest you call registerExtension explicitly. - * - * @param provider The name of the extension provider, e.g. agora.io. - * @param extension The name of the extension, e.g. agora.beauty. - * @param extensionInfo The information for extension. - * @param enable Whether to enable the extension: - * - true: (Default) Enable the extension. - * - false: Disable the extension. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int enableExtension(const char* provider, const char* extension, const ExtensionInfo& extensionInfo, bool enable = true) = 0; + virtual int enableExtension(const char* provider, const char* extension, bool enable=true, agora::media::MEDIA_SOURCE_TYPE type = agora::media::UNKNOWN_MEDIA_SOURCE) = 0; /** * Sets the properties of an extension. @@ -6466,37 +6533,6 @@ class IRtcEngine : public agora::base::IEngineBase { const char* provider, const char* extension, const char* key, char* value, int buf_len, agora::media::MEDIA_SOURCE_TYPE type = agora::media::UNKNOWN_MEDIA_SOURCE) = 0; - /** - * Sets the properties of an extension. - * - * @param provider The name of the extension provider, e.g. agora.io. - * @param extension The name of the extension, e.g. agora.beauty. - * @param extensionInfo The information for extension. - * @param key The key of the extension. - * @param value The JSON formatted value of the extension key. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int setExtensionProperty(const char* provider, const char* extension, const ExtensionInfo& extensionInfo, const char* key, const char* value) = 0; - - /** - * Gets the properties of an extension. - * - * @param provider The name of the extension provider, e.g. agora.io. - * @param extension The name of the extension, e.g. agora.beauty. - * @param extensionInfo The information for extension. - * @param key The key of the extension. - * @param value The value of the extension key. - * @param buf_len Maximum length of the JSON string indicating the extension property. - * - * @return - * - 0: Success. - * - < 0: Failure. - */ - virtual int getExtensionProperty(const char* provider, const char* extension, const ExtensionInfo& extensionInfo, const char* key, char* value, int buf_len) = 0; - /** Sets the camera capture configuration. * @note Call this method before enabling the local camera. * That said, you can call this method before calling \ref IRtcEngine::joinChannel "joinChannel", @@ -6510,7 +6546,6 @@ class IRtcEngine : public agora::base::IEngineBase { */ virtual int setCameraCapturerConfiguration(const CameraCapturerConfiguration& config) = 0; - /** * Get an custom video track id created by internal,which could used to publish or preview * @@ -6549,9 +6584,7 @@ class IRtcEngine : public agora::base::IEngineBase { */ virtual int destroyCustomEncodedVideoTrack(video_track_id_t video_track_id) = 0; - #if defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IOS) - /** * Switches between front and rear cameras. * @@ -6693,7 +6726,7 @@ class IRtcEngine : public agora::base::IEngineBase { */ virtual int setCameraExposurePosition(float positionXinView, float positionYinView) = 0; - /** + /** * Returns whether exposure value adjusting is supported by the current device. * Exposure compensation is in auto exposure mode. * @since v4.2.2 @@ -6812,9 +6845,8 @@ class IRtcEngine : public agora::base::IEngineBase { */ virtual bool isSpeakerphoneEnabled() = 0; - /** Select preferred route for android communication mode + /** Select preferred route for android communication mode - @since v4.2.2 @param route The preferred route. For example, when a Bluetooth headset is connected, you can use this API to switch the route to a wired headset. @return meanless, route switch result is pass through CallbackOnRoutingChanged @@ -6892,7 +6924,6 @@ class IRtcEngine : public agora::base::IEngineBase { #endif // __APPLE__ && TARGET_OS_MAC && !TARGET_OS_IPHONE #if defined(_WIN32) - /** * Shares the whole or part of a screen by specifying the screen rect. * @@ -6919,8 +6950,7 @@ class IRtcEngine : public agora::base::IEngineBase { virtual int startScreenCaptureByScreenRect(const Rectangle& screenRect, const Rectangle& regionRect, const ScreenCaptureParameters& captureParams) __deprecated = 0; - -#endif // _WIN32 +#endif #if defined(__ANDROID__) /** @@ -7104,8 +7134,7 @@ class IRtcEngine : public agora::base::IEngineBase { * - 0: Success. * - < 0: Failure. */ - virtual int rate(const char* callId, int rating, - const char* description) = 0; // 0~10 + virtual int rate(const char* callId, int rating, const char* description) = 0; // 0~10 /** * Allows a user to complain about the call quality. @@ -7177,6 +7206,10 @@ class IRtcEngine : public agora::base::IEngineBase { * - < 0: Failure. */ virtual int updateRtmpTranscoding(const LiveTranscoding& transcoding) = 0; + + virtual int startLocalVideoTranscoder(const LocalTranscoderConfiguration& config) = 0; + virtual int updateLocalTranscoderConfiguration(const LocalTranscoderConfiguration& config) = 0; + /** Stop an RTMP stream with transcoding or without transcoding from the CDN. (CDN live only.) * This method removes the RTMP URL address (added by the \ref IRtcEngine::startRtmpStreamWithoutTranscoding "startRtmpStreamWithoutTranscoding" method @@ -7197,9 +7230,6 @@ class IRtcEngine : public agora::base::IEngineBase { */ virtual int stopRtmpStream(const char* url) = 0; - - virtual int startLocalVideoTranscoder(const LocalTranscoderConfiguration& config) = 0; - virtual int updateLocalTranscoderConfiguration(const LocalTranscoderConfiguration& config) = 0; virtual int stopLocalVideoTranscoder() = 0; /** * Starts video capture with a camera. @@ -7402,7 +7432,7 @@ class IRtcEngine : public agora::base::IEngineBase { * - Returns 0: Success. * - < 0: Failure. */ - virtual int createDataStream(int* streamId, DataStreamConfig& config) = 0; + virtual int createDataStream(int* streamId, const DataStreamConfig& config) = 0; /** Sends a data stream. * @@ -7457,7 +7487,7 @@ class IRtcEngine : public agora::base::IEngineBase { - 0: Success. - < 0: Failure. */ - virtual int addVideoWatermark(const RtcImage& watermark) = 0; + virtual int addVideoWatermark(const RtcImage& watermark) __deprecated = 0; /** Adds a watermark image to the local video. @@ -7544,8 +7574,7 @@ class IRtcEngine : public agora::base::IEngineBase { * To try out this function, contact [support@agora.io](mailto:support@agora.io) * and discuss the format of customized messages with us. */ - virtual int sendCustomReportMessage( - const char* id, const char* category, const char* event, const char* label, int value) = 0; + virtual int sendCustomReportMessage(const char* id, const char* category, const char* event, const char* label, int value) = 0; /** Registers the metadata observer. @@ -7588,13 +7617,12 @@ class IRtcEngine : public agora::base::IEngineBase { "pre_play_proc", "at_playout", "atw_playout" for audio receiving. */ + virtual int startAudioFrameDump(const char* channel_id, uid_t uid, const char* location, const char* uuid, const char* passwd, long duration_ms, bool auto_upload) = 0; - virtual int startAudioFrameDump(const char* channel_id, uid_t user_id, const char* location, - const char* uuid, const char* passwd, long duration_ms, bool auto_upload) = 0; /** * Stops the audio frame dump. */ - virtual int stopAudioFrameDump(const char* channel_id, uid_t user_id, const char* location) = 0; + virtual int stopAudioFrameDump(const char* channel_id, uid_t uid, const char* location) = 0; /** * Enables/Disables Agora AI Noise Suppression(AINS) with preset mode. @@ -7676,8 +7704,7 @@ class IRtcEngine : public agora::base::IEngineBase { * - 0: Success. * - < 0: Failure. */ - virtual int joinChannelWithUserAccount(const char* token, const char* channelId, - const char* userAccount) = 0; + virtual int joinChannelWithUserAccount(const char* token, const char* channelId, const char* userAccount) = 0; /** Joins the channel with a user account. * @@ -7710,8 +7737,7 @@ class IRtcEngine : public agora::base::IEngineBase { * - 0: Success. * - < 0: Failure. */ - virtual int joinChannelWithUserAccount(const char* token, const char* channelId, - const char* userAccount, const ChannelMediaOptions& options) = 0; + virtual int joinChannelWithUserAccount(const char* token, const char* channelId, const char* userAccount, const ChannelMediaOptions& options) = 0; /** Joins the channel with a user account. * @@ -7786,157 +7812,73 @@ class IRtcEngine : public agora::base::IEngineBase { * - < 0: Failure. */ virtual int getUserInfoByUid(uid_t uid, rtc::UserInfo* userInfo) = 0; - /** Starts relaying media streams across channels or updates the channels for media relay. - * - * After a successful method call, the SDK triggers the - * \ref agora::rtc::IRtcEngineEventHandler::onChannelMediaRelayStateChanged - * "onChannelMediaRelayStateChanged" and - * \ref agora::rtc::IRtcEngineEventHandler::onChannelMediaRelayEvent - * "onChannelMediaRelayEvent" callbacks, and these callbacks return the - * state and events of the media stream relay. - * - If the - * \ref agora::rtc::IRtcEngineEventHandler::onChannelMediaRelayStateChanged - * "onChannelMediaRelayStateChanged" callback returns - * #RELAY_STATE_RUNNING (2) and #RELAY_OK (0), and the - * \ref agora::rtc::IRtcEngineEventHandler::onChannelMediaRelayEvent - * "onChannelMediaRelayEvent" callback returns - * #RELAY_EVENT_PACKET_SENT_TO_DEST_CHANNEL (4), the host starts - * sending data to the destination channel. - * - If the - * \ref agora::rtc::IRtcEngineEventHandler::onChannelMediaRelayStateChanged - * "onChannelMediaRelayStateChanged" callback returns - * #RELAY_STATE_FAILURE (3), an exception occurs during the media stream - * relay. - * - * @note - * - Call this method after the \ref joinChannel() "joinChannel" method. - * - This method takes effect only when you are a host in a - * `LIVE_BROADCASTING` channel. - * - Contact sales-us@agora.io before implementing this function. - * - We do not support string user accounts in this API. - * - * @since v4.2.0 - * @param configuration The configuration of the media stream relay: - * ChannelMediaRelayConfiguration. - * - * @return - * - 0: Success. - * - < 0: Failure. - * - -1(ERR_FAILED): A general error occurs (no specified reason). - * - -2(ERR_INVALID_ARGUMENT): The argument is invalid. - * - -5(ERR_REFUSED): The request is rejected. - * - -8(ERR_INVALID_STATE): The current status is invalid, only allowed to be called when the role is the broadcaster. - */ - virtual int startOrUpdateChannelMediaRelay(const ChannelMediaRelayConfiguration &configuration) = 0; - /** Starts to relay media streams across channels. - * - * After a successful method call, the SDK triggers the - * \ref agora::rtc::IRtcEngineEventHandler::onChannelMediaRelayStateChanged - * "onChannelMediaRelayStateChanged" and - * \ref agora::rtc::IRtcEngineEventHandler::onChannelMediaRelayEvent - * "onChannelMediaRelayEvent" callbacks, and these callbacks return the - * state and events of the media stream relay. - * - If the - * \ref agora::rtc::IRtcEngineEventHandler::onChannelMediaRelayStateChanged - * "onChannelMediaRelayStateChanged" callback returns - * #RELAY_STATE_RUNNING (2) and #RELAY_OK (0), and the - * \ref agora::rtc::IRtcEngineEventHandler::onChannelMediaRelayEvent - * "onChannelMediaRelayEvent" callback returns - * #RELAY_EVENT_PACKET_SENT_TO_DEST_CHANNEL (4), the host starts - * sending data to the destination channel. - * - If the - * \ref agora::rtc::IRtcEngineEventHandler::onChannelMediaRelayStateChanged - * "onChannelMediaRelayStateChanged" callback returns - * #RELAY_STATE_FAILURE (3), an exception occurs during the media stream - * relay. - * - * @note - * - Call this method after the \ref joinChannel() "joinChannel" method. - * - This method takes effect only when you are a host in a - * `LIVE_BROADCASTING` channel. - * - After a successful method call, if you want to call this method - * again, ensure that you call the - * \ref stopChannelMediaRelay() "stopChannelMediaRelay" method to quit the - * current relay. - * - Contact sales-us@agora.io before implementing this function. - * - We do not support string user accounts in this API. - * - * @deprecated v4.2.0 Use `startOrUpdateChannelMediaRelay` instead. - * @param configuration The configuration of the media stream relay: - * ChannelMediaRelayConfiguration. - * - * @return - * - 0: Success. - * - < 0: Failure. - * - -1(ERR_FAILED): A general error occurs (no specified reason). - * - -2(ERR_INVALID_ARGUMENT): The argument is invalid. - * - -5(ERR_REFUSED): The request is rejected. - * - -8(ERR_INVALID_STATE): The current status is invalid, only allowed to be called when the role is the broadcaster. - */ - virtual int startChannelMediaRelay(const ChannelMediaRelayConfiguration &configuration) __deprecated = 0; - - /** Updates the channels for media stream relay. After a successful - * \ref startChannelMediaRelay() "startChannelMediaRelay" method call, if - * you want to relay the media stream to more channels, or leave the - * current relay channel, you can call the - * \ref updateChannelMediaRelay() "updateChannelMediaRelay" method. - * - * After a successful method call, the SDK triggers the - * \ref agora::rtc::IRtcEngineEventHandler::onChannelMediaRelayEvent - * "onChannelMediaRelayEvent" callback with the - * #RELAY_EVENT_PACKET_UPDATE_DEST_CHANNEL (7) state code. - * - * @note - * Call this method after the - * \ref startChannelMediaRelay() "startChannelMediaRelay" method to update - * the destination channel. - * - * @deprecated v4.2.0 Use `startOrUpdateChannelMediaRelay` instead. - * @param configuration The media stream relay configuration: - * ChannelMediaRelayConfiguration. - * - * @return - * - 0: Success. - * - < 0: Failure. - * - -1(ERR_FAILED): A general error occurs (no specified reason). - * - -2(ERR_INVALID_ARGUMENT): The argument is invalid. - * - -5(ERR_REFUSED): The request is rejected. - * - -7(ERR_NOT_INITIALIZED): cross channel media streams are not relayed. - */ - virtual int updateChannelMediaRelay(const ChannelMediaRelayConfiguration &configuration) __deprecated = 0; + /** Starts relaying media streams across channels or updates the channels for media relay. + * + * After a successful method call, the SDK triggers the + * \ref agora::rtc::IRtcEngineEventHandler::onChannelMediaRelayStateChanged + * "onChannelMediaRelayStateChanged" callback, and this callback return the state of the media stream relay. + * - If the + * \ref agora::rtc::IRtcEngineEventHandler::onChannelMediaRelayStateChanged + * "onChannelMediaRelayStateChanged" callback returns + * #RELAY_STATE_RUNNING (2) and #RELAY_OK (0), the host starts sending data to the destination channel. + * - If the + * \ref agora::rtc::IRtcEngineEventHandler::onChannelMediaRelayStateChanged + * "onChannelMediaRelayStateChanged" callback returns + * #RELAY_STATE_FAILURE (3), an exception occurs during the media stream + * relay. + * + * @note + * - Call this method after the \ref joinChannel() "joinChannel" method. + * - This method takes effect only when you are a host in a + * `LIVE_BROADCASTING` channel. + * - Contact sales-us@agora.io before implementing this function. + * - We do not support string user accounts in this API. + * + * @since v4.2.0 + * @param configuration The configuration of the media stream relay: + * ChannelMediaRelayConfiguration. + * + * @return + * - 0: Success. + * - < 0: Failure. + * - -1(ERR_FAILED): A general error occurs (no specified reason). + * - -2(ERR_INVALID_ARGUMENT): The argument is invalid. + * - -5(ERR_REFUSED): The request is rejected. + * - -8(ERR_INVALID_STATE): The current status is invalid, only allowed to be called when the role is the broadcaster. + **/ + virtual int startOrUpdateChannelMediaRelay(const ChannelMediaRelayConfiguration &configuration) = 0; - /** Stops the media stream relay. - * - * Once the relay stops, the host quits all the destination - * channels. - * - * After a successful method call, the SDK triggers the - * \ref agora::rtc::IRtcEngineEventHandler::onChannelMediaRelayStateChanged - * "onChannelMediaRelayStateChanged" callback. If the callback returns - * #RELAY_STATE_IDLE (0) and #RELAY_OK (0), the host successfully - * stops the relay. - * - * @note - * If the method call fails, the SDK triggers the - * \ref agora::rtc::IRtcEngineEventHandler::onChannelMediaRelayStateChanged - * "onChannelMediaRelayStateChanged" callback with the - * #RELAY_ERROR_SERVER_NO_RESPONSE (2) or - * #RELAY_ERROR_SERVER_CONNECTION_LOST (8) state code. You can leave the - * channel by calling the \ref leaveChannel() "leaveChannel" method, and - * the media stream relay automatically stops. - * - * @return - * - 0: Success. - * - < 0: Failure. - * - -1(ERR_FAILED): A general error occurs (no specified reason). - * - -2(ERR_INVALID_ARGUMENT): The argument is invalid. - * - -5(ERR_REFUSED): The request is rejected. - * - -7(ERR_NOT_INITIALIZED): cross channel media streams are not relayed. - */ + /** Stops the media stream relay. + * + * Once the relay stops, the host quits all the destination + * channels. + * + * After a successful method call, the SDK triggers the + * \ref agora::rtc::IRtcEngineEventHandler::onChannelMediaRelayStateChanged + * "onChannelMediaRelayStateChanged" callback. If the callback returns + * #RELAY_STATE_IDLE (0) and #RELAY_OK (0), the host successfully + * stops the relay. + * + * @note + * If the method call fails, the SDK triggers the + * \ref agora::rtc::IRtcEngineEventHandler::onChannelMediaRelayStateChanged + * "onChannelMediaRelayStateChanged" callback with the + * #RELAY_ERROR_SERVER_NO_RESPONSE (2) or + * #RELAY_ERROR_SERVER_CONNECTION_LOST (8) state code. You can leave the + * channel by calling the \ref leaveChannel() "leaveChannel" method, and + * the media stream relay automatically stops. + * + * @return + * - 0: Success. + * - < 0: Failure. + * - -1(ERR_FAILED): A general error occurs (no specified reason). + * - -2(ERR_INVALID_ARGUMENT): The argument is invalid. + * - -5(ERR_REFUSED): The request is rejected. + * - -7(ERR_NOT_INITIALIZED): cross channel media streams are not relayed. + */ virtual int stopChannelMediaRelay() = 0; - /** pause the channels for media stream relay. * @return * - 0: Success. @@ -8058,6 +8000,7 @@ class IRtcEngine : public agora::base::IEngineBase { * - < 0: Failure. */ virtual int configRhythmPlayer(const AgoraRhythmPlayerConfig& config) = 0; + /** * Takes a snapshot of a video stream. * @@ -8088,6 +8031,7 @@ class IRtcEngine : public agora::base::IEngineBase { * - < 0 : Failure. */ virtual int takeSnapshot(uid_t uid, const char* filePath) = 0; + /** Enables the content inspect. @param enabled Whether to enable content inspect: - `true`: Yes. @@ -8167,7 +8111,7 @@ class IRtcEngine : public agora::base::IEngineBase { - 0: Success - < 0: Failure */ - virtual int setAdvancedAudioOptions(AdvancedAudioOptions &options, int sourceType = 0) = 0; + virtual int setAdvancedAudioOptions(AdvancedAudioOptions& options, int sourceType = 0) = 0; /** Bind local user and a remote user as an audio&video sync group. The remote user is defined by cid and uid. * There’s a usage limit that local user must be a video stream sender. On the receiver side, media streams from same sync group will be time-synced @@ -8295,28 +8239,13 @@ class IRtcEngine : public agora::base::IEngineBase { /** * @brief Whether the target feature is available for the device. - * @since v4.2.0 + * @since v4.3.0 * @param type The feature type. See FeatureType. * @return * - true: available. * - false: not available. */ virtual bool isFeatureAvailableOnDevice(FeatureType type) = 0; - -}; - -class AAudioDeviceManager : public agora::util::AutoPtr { - public: - AAudioDeviceManager(IRtcEngine* engine) { - queryInterface(engine, AGORA_IID_AUDIO_DEVICE_MANAGER); - } -}; - -class AVideoDeviceManager : public agora::util::AutoPtr { - public: - AVideoDeviceManager(IRtcEngine* engine) { - queryInterface(engine, AGORA_IID_VIDEO_DEVICE_MANAGER); - } }; // The following types are either deprecated or not implmented yet. @@ -8493,6 +8422,20 @@ enum VIDEO_PROFILE_TYPE { VIDEO_PROFILE_DEFAULT = VIDEO_PROFILE_LANDSCAPE_360P, }; +class AAudioDeviceManager : public agora::util::AutoPtr { + public: + AAudioDeviceManager(IRtcEngine* engine) { + queryInterface(engine, AGORA_IID_AUDIO_DEVICE_MANAGER); + } +}; + +class AVideoDeviceManager : public agora::util::AutoPtr { + public: + AVideoDeviceManager(IRtcEngine* engine) { + queryInterface(engine, AGORA_IID_VIDEO_DEVICE_MANAGER); + } +}; + } // namespace rtc } // namespace agora 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 32690cffe..e9826d78f 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 @@ -91,6 +91,7 @@ class IRtcEngineEventHandlerEx : public IRtcEngineEventHandler { using IRtcEngineEventHandler::onNetworkTypeChanged; using IRtcEngineEventHandler::onEncryptionError; using IRtcEngineEventHandler::onUploadLogResult; + using IRtcEngineEventHandler::onUserInfoUpdated; using IRtcEngineEventHandler::onUserAccountUpdated; using IRtcEngineEventHandler::onAudioSubscribeStateChanged; using IRtcEngineEventHandler::onVideoSubscribeStateChanged; @@ -98,6 +99,8 @@ class IRtcEngineEventHandlerEx : public IRtcEngineEventHandler { using IRtcEngineEventHandler::onVideoPublishStateChanged; using IRtcEngineEventHandler::onSnapshotTaken; using IRtcEngineEventHandler::onVideoRenderingTracingResult; + using IRtcEngineEventHandler::onSetRtmFlagResult; + using IRtcEngineEventHandler::onTranscodedStreamLayoutInfo; virtual const char* eventHandlerType() const { return "event_handler_ex"; } @@ -322,13 +325,13 @@ class IRtcEngineEventHandlerEx : public IRtcEngineEventHandler { * you to troubleshoot issues when exceptions occur. * * The SDK triggers the onLocalVideoStateChanged callback with the state code of `LOCAL_VIDEO_STREAM_STATE_FAILED` - * and error code of `LOCAL_VIDEO_STREAM_ERROR_CAPTURE_FAILURE` in the following situations: + * and error code of `LOCAL_VIDEO_STREAM_REASON_CAPTURE_FAILURE` in the following situations: * - The app switches to the background, and the system gets the camera resource. * - The camera starts normally, but does not output video for four consecutive seconds. * * When the camera outputs the captured video frames, if the video frames are the same for 15 * consecutive frames, the SDK triggers the `onLocalVideoStateChanged` callback with the state code - * of `LOCAL_VIDEO_STREAM_STATE_CAPTURING` and error code of `LOCAL_VIDEO_STREAM_ERROR_CAPTURE_FAILURE`. + * of `LOCAL_VIDEO_STREAM_STATE_CAPTURING` and error code of `LOCAL_VIDEO_STREAM_REASON_CAPTURE_FAILURE`. * Note that the video frame duplication detection is only available for video frames with a resolution * greater than 200 × 200, a frame rate greater than or equal to 10 fps, and a bitrate less than 20 Kbps. * @@ -338,14 +341,14 @@ class IRtcEngineEventHandlerEx : public IRtcEngineEventHandler { * * @param connection The RtcConnection object. * @param state The state of the local video. See #LOCAL_VIDEO_STREAM_STATE. - * @param error The detailed error information. See #LOCAL_VIDEO_STREAM_ERROR. + * @param reason The detailed error information. See #LOCAL_VIDEO_STREAM_REASON. */ virtual void onLocalVideoStateChanged(const RtcConnection& connection, LOCAL_VIDEO_STREAM_STATE state, - LOCAL_VIDEO_STREAM_ERROR errorCode) { + LOCAL_VIDEO_STREAM_REASON reason) { (void)connection; (void)state; - (void)errorCode; + (void)reason; } /** @@ -762,13 +765,13 @@ class IRtcEngineEventHandlerEx : public IRtcEngineEventHandler { * * @param connection The RtcConnection object. * @param state State of the local audio. See #LOCAL_AUDIO_STREAM_STATE. - * @param error The error information of the local audio. - * See #LOCAL_AUDIO_STREAM_ERROR. + * @param reason The reason information of the local audio. + * See #LOCAL_AUDIO_STREAM_REASON. */ - virtual void onLocalAudioStateChanged(const RtcConnection& connection, LOCAL_AUDIO_STREAM_STATE state, LOCAL_AUDIO_STREAM_ERROR error) { + virtual void onLocalAudioStateChanged(const RtcConnection& connection, LOCAL_AUDIO_STREAM_STATE state, LOCAL_AUDIO_STREAM_REASON reason) { (void)connection; (void)state; - (void)error; + (void)reason; } /** Occurs when the remote audio state changes. @@ -976,6 +979,7 @@ class IRtcEngineEventHandlerEx : public IRtcEngineEventHandler { (void)success; (void)reason; } + /** * Occurs when the user account is updated. * @@ -983,10 +987,10 @@ class IRtcEngineEventHandlerEx : public IRtcEngineEventHandler { * @param remoteUid The user ID. * @param userAccount The user account. */ - virtual void onUserAccountUpdated(const RtcConnection& connection, uid_t remoteUid, const char* userAccount){ + virtual void onUserAccountUpdated(const RtcConnection& connection, uid_t remoteUid, const char* remoteUserAccount){ (void)connection; (void)remoteUid; - (void)userAccount; + (void)remoteUserAccount; } /** Reports the result of taking a video snapshot. @@ -1027,6 +1031,34 @@ class IRtcEngineEventHandlerEx : public IRtcEngineEventHandler { (void)currentEvent; (void)tracingInfo; } + + /** + * Occurs when receive use rtm response. + * + * @param connection The RtcConnection object. + * @param code The error code: + */ + virtual void onSetRtmFlagResult(const RtcConnection& connection, int code) { + (void)connection; + (void)code; + } + /** + * Occurs when receive a video transcoder stream which has video layout info. + * + * @param connection The RtcConnection object. + * @param uid user id of the transcoded stream. + * @param width width of the transcoded stream. + * @param height height of the transcoded stream. + * @param layoutCount count of layout info in the transcoded stream. + * @param layoutlist video layout info list of the transcoded stream. + */ + virtual void onTranscodedStreamLayoutInfo(const RtcConnection& connection, uid_t uid, int width, int height, int layoutCount,const VideoLayout* layoutlist) { + (void)uid; + (void)width; + (void)height; + (void)layoutCount; + (void)layoutlist; + } }; class IRtcEngineEx : public IRtcEngine { @@ -1488,7 +1520,7 @@ class IRtcEngineEx : public IRtcEngine { * - 0: Success. * - < 0: Failure. */ - virtual int adjustUserPlaybackSignalVolumeEx(unsigned int uid, int volume, const RtcConnection& connection) = 0; + virtual int adjustUserPlaybackSignalVolumeEx(uid_t uid, int volume, const RtcConnection& connection) = 0; /** Gets the current connection state of the SDK. @param connection The RtcConnection object. @@ -1561,7 +1593,7 @@ class IRtcEngineEx : public IRtcEngine { * - Returns 0: Success. * - < 0: Failure. */ - virtual int createDataStreamEx(int* streamId, DataStreamConfig& config, const RtcConnection& connection) = 0; + virtual int createDataStreamEx(int* streamId, const DataStreamConfig& config, const RtcConnection& connection) = 0; /** Sends a data stream. * * After calling \ref IRtcEngine::createDataStream "createDataStream", you can call @@ -1729,35 +1761,6 @@ class IRtcEngineEx : public IRtcEngine { */ virtual int startOrUpdateChannelMediaRelayEx(const ChannelMediaRelayConfiguration& configuration, const RtcConnection& connection) = 0; - /** Starts to relay media streams across channels. - * - * @deprecated v4.2.0 Use `startOrUpdateChannelMediaRelayEx` instead. - * @param configuration The configuration of the media stream relay:ChannelMediaRelayConfiguration. - * @param connection RtcConnection. - * @return - * - 0: Success. - * - < 0: Failure. - * - -1(ERR_FAILED): A general error occurs (no specified reason). - * - -2(ERR_INVALID_ARGUMENT): The argument is invalid. - * - -5(ERR_REFUSED): The request is rejected. - * - -8(ERR_INVALID_STATE): The current status is invalid, only allowed to be called when the role is the broadcaster. - */ - virtual int startChannelMediaRelayEx(const ChannelMediaRelayConfiguration& configuration, const RtcConnection& connection) __deprecated = 0; - - /** Updates the channels for media stream relay - * @deprecated v4.2.0 Use `startOrUpdateChannelMediaRelayEx` instead. - * @param configuration The media stream relay configuration: ChannelMediaRelayConfiguration. - * @param connection RtcConnection. - * @return - * - 0: Success. - * - < 0: Failure. - * - -1(ERR_FAILED): A general error occurs (no specified reason). - * - -2(ERR_INVALID_ARGUMENT): The argument is invalid. - * - -5(ERR_REFUSED): The request is rejected. - * - -7(ERR_NOT_INITIALIZED): cross channel media streams are not relayed. - */ - virtual int updateChannelMediaRelayEx(const ChannelMediaRelayConfiguration& configuration, const RtcConnection& connection) __deprecated = 0; - /** Stops the media stream relay. * * Once the relay stops, the host quits all the destination @@ -1942,6 +1945,16 @@ class IRtcEngineEx : public IRtcEngine { - -7(ERR_NOT_INITIALIZED): The SDK is not initialized. Initialize the `IRtcEngine` instance before calling this method. */ virtual int startMediaRenderingTracingEx(const RtcConnection& connection) = 0; + + /** Provides the technical preview functionalities or special customizations by configuring the SDK with JSON options. + @since v4.3.0 + @param connection The connection information. See RtcConnection. + @param parameters Pointer to the set parameters in a JSON string. + @return + - 0: Success. + - < 0: Failure. + */ + virtual int setParametersEx(const RtcConnection& connection, const char* parameters) = 0; }; } // namespace rtc diff --git a/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/IAgoraSpatialAudio.h b/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/IAgoraSpatialAudio.h index 51b382575..f4a3ba6a3 100644 --- a/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/IAgoraSpatialAudio.h +++ b/Android/APIExample/agora-stream-encrypt/src/main/cpp/include/agora/IAgoraSpatialAudio.h @@ -4,8 +4,7 @@ // Copyright (c) 2019 Agora.io. All rights reserved. // -#ifndef AGORA_SPATIAL_AUDIO_H -#define AGORA_SPATIAL_AUDIO_H +#pragma once #include #include "AgoraBase.h" @@ -22,7 +21,6 @@ struct RemoteVoicePositionInfo { float position[3]; // The forward vector of remote voice, (x, y, z). When it's not set, the vector is forward to listner. float forward[3]; - RemoteVoicePositionInfo() = default; }; struct SpatialAudioZone { @@ -44,7 +42,6 @@ struct SpatialAudioZone { float upLength; //the audio attenuation of zone float audioAttenuation; - SpatialAudioZone() = default; }; /** The definition of LocalSpatialAudioConfig @@ -60,15 +57,93 @@ struct LocalSpatialAudioConfig { /** The IBaseSpatialAudioEngine class provides the common methods of ICloudSpatialAudioEngine and ILocalSpatialAudioEngine. */ -class IBaseSpatialAudioEngine: public RefCountInterface { +class ILocalSpatialAudioEngine: public RefCountInterface { protected: - virtual ~IBaseSpatialAudioEngine() {} + virtual ~ILocalSpatialAudioEngine() {} public: /** * Releases all the resources occupied by spatial audio engine. */ virtual void release() = 0; + + /** + * Initializes the ILocalSpatialAudioEngine object and allocates the internal resources. + * + * @note Ensure that you call IRtcEngine::queryInterface and initialize before calling any other ILocalSpatialAudioEngine APIs. + * + * @param config The pointer to the LocalSpatialAudioConfig. See #LocalSpatialAudioConfig. + * + * @return + * - 0: Success. + * - <0: Failure. + */ + virtual int initialize(const LocalSpatialAudioConfig& config) = 0; + /** + * Updates the position information of remote user. You should call it when remote user whose role is broadcaster moves. + * + * @param uid The remote user ID. It should be the same as RTC channel remote user id. + * @param posInfo The position information of remote user. See #RemoteVoicePositionInfo. + * @return + * - 0: Success. + * - <0: Failure. + */ + virtual int updateRemotePosition(uid_t uid, const RemoteVoicePositionInfo &posInfo) = 0; + /** + * Updates the position of remote user. It's supposed to use with IRtcEngineEx::joinChannelEx. + * + * @param uid The remote user ID. It should be the same as RTC channel remote user id. + * @param posInfo The position information of remote user. See #RemoteVoicePositionInfo. + * @param connection The RTC connection whose spatial audio effect you want to update. See #RtcConnection. + * @return + * - 0: Success. + * - <0: Failure. + */ + virtual int updateRemotePositionEx(uid_t uid, const RemoteVoicePositionInfo &posInfo, const RtcConnection& connection) = 0; + /** + * Remove the position information of remote user. You should call it when remote user called IRtcEngine::leaveChannel. + * + * @param uid The remote user ID. It should be the same as RTC channel remote user id. + * @return + * - 0: Success. + * - <0: Failure. + */ + virtual int removeRemotePosition(uid_t uid) = 0; + /** + * Remove the position information of remote user. It's supposed to use with IRtcEngineEx::joinChannelEx. + * + * @param uid The remote user ID. It should be the same as RTC channel remote user id. + * @param connection The RTC connection whose spatial audio effect you want to update. See #RtcConnection. + * @return + * - 0: Success. + * - <0: Failure. + */ + virtual int removeRemotePositionEx(uid_t uid, const RtcConnection& connection) = 0; + /** + * Clear the position informations of remote users. It's supposed to use with IRtcEngineEx::joinChannelEx. + * + * @return + * - 0: Success. + * - <0: Failure. + */ + virtual int clearRemotePositionsEx(const RtcConnection& connection) = 0; + /** + * Updates the position of local user. This method is used in scene with multi RtcConnection. + * + * @note + * - This method is only effective in ILocalSpatialAudioEngine currently. + * + * @param position The sound position of the user. The coordinate order is forward, right, and up. + * @param axisForward The vector in the direction of the forward axis in the coordinate system. + * @param axisRight The vector in the direction of the right axis in the coordinate system. + * @param axisUp The vector in the direction of the up axis in the coordinate system. + * @param connection The RTC connection whose spatial audio effect you want to update. + * @return + * - 0: Success. + * - <0: Failure. + */ + virtual int updateSelfPositionEx(const float position[3], const float axisForward[3], const float axisRight[3], const float axisUp[3], const RtcConnection& connection) = 0; + /** * This method sets the maximum number of streams that a player can receive in a * specified audio reception range. @@ -136,24 +211,7 @@ class IBaseSpatialAudioEngine: public RefCountInterface { * - 0: Success. * - <0: Failure. */ - virtual int updateSelfPosition(float position[3], float axisForward[3], float axisRight[3], float axisUp[3]) = 0; - /** - * Updates the position of local user. This method is used in scene with multi RtcConnection. - * - * @note - * - This method is only effective in ILocalSpatialAudioEngine currently. - * - * @param position The sound position of the user. The coordinate order is forward, right, and up. - * @param axisForward The vector in the direction of the forward axis in the coordinate system. - * @param axisRight The vector in the direction of the right axis in the coordinate system. - * @param axisUp The vector in the direction of the up axis in the coordinate system. - * @param connection The RTC connection whose spatial audio effect you want to update. - * @return - * - 0: Success. - * - <0: Failure. - */ - virtual int updateSelfPositionEx(float position[3], float axisForward[3], float axisRight[3], float axisUp[3], const RtcConnection& connection) = 0; - + virtual int updateSelfPosition(const float position[3], const float axisForward[3], const float axisRight[3], const float axisUp[3]) = 0; /** * Updates the position of a media player in scene. This method has same behavior both in ICloudSpatialAudioEngine and ILocalSpatialAudioEngine. * @@ -196,28 +254,7 @@ class IBaseSpatialAudioEngine: public RefCountInterface { * - <0: Failure. */ virtual int muteAllRemoteAudioStreams(bool mute) = 0; - - - /** - * Setting up sound Space - * - * @param zones The Sound space array - * @param zoneCount the sound Space count of array - * @return - * - 0: Success. - * - <0: Failure. - */ - virtual int setZones(const SpatialAudioZone *zones, unsigned int zoneCount) = 0; - /** - * Set the audio attenuation coefficient of the player - * @param playerId The ID of the media player. You can get it by IMediaPlayer::getMediaPlayerId. - * @param attenuation The audio attenuation of the media player. - * @param forceSet Whether to force the setting of audio attenuation coefficient. - * @return - * - 0: Success. - * - <0: Failure. - */ - virtual int setPlayerAttenuation(int playerId, double attenuation, bool forceSet) = 0; + /** * Mute or unmute remote user audio stream. * @@ -228,65 +265,29 @@ class IBaseSpatialAudioEngine: public RefCountInterface { * - <0: Failure. */ virtual int muteRemoteAudioStream(uid_t uid, bool mute) = 0; -}; - -class ILocalSpatialAudioEngine : public IBaseSpatialAudioEngine { -protected: - virtual ~ILocalSpatialAudioEngine() {} -public: - /** - * Initializes the ILocalSpatialAudioEngine object and allocates the internal resources. - * - * @note Ensure that you call IRtcEngine::queryInterface and initialize before calling any other ILocalSpatialAudioEngine APIs. - * - * @param config The pointer to the LocalSpatialAudioConfig. See #LocalSpatialAudioConfig. - * - * @return - * - 0: Success. - * - <0: Failure. - */ - virtual int initialize(const LocalSpatialAudioConfig& config) = 0; - /** - * Updates the position information of remote user. You should call it when remote user whose role is broadcaster moves. - * - * @param uid The remote user ID. It should be the same as RTC channel remote user id. - * @param posInfo The position information of remote user. See #RemoteVoicePositionInfo. - * @return - * - 0: Success. - * - <0: Failure. - */ - virtual int updateRemotePosition(uid_t uid, const RemoteVoicePositionInfo &posInfo) = 0; - /** - * Updates the position of remote user. It's supposed to use with IRtcEngineEx::joinChannelEx. - * - * @param uid The remote user ID. It should be the same as RTC channel remote user id. - * @param posInfo The position information of remote user. See #RemoteVoicePositionInfo. - * @param connection The RTC connection whose spatial audio effect you want to update. See #RtcConnection. - * @return - * - 0: Success. - * - <0: Failure. - */ - virtual int updateRemotePositionEx(uid_t uid, const RemoteVoicePositionInfo &posInfo, const RtcConnection& connection) = 0; + virtual int setRemoteAudioAttenuation(uid_t uid, double attenuation, bool forceSet) = 0; + /** - * Remove the position information of remote user. You should call it when remote user called IRtcEngine::leaveChannel. + * Setting up sound Space * - * @param uid The remote user ID. It should be the same as RTC channel remote user id. + * @param zones The Sound space array + * @param zoneCount the sound Space count of array * @return * - 0: Success. * - <0: Failure. */ - virtual int removeRemotePosition(uid_t uid) = 0; + virtual int setZones(const SpatialAudioZone *zones, unsigned int zoneCount) = 0; /** - * Remove the position information of remote user. It's supposed to use with IRtcEngineEx::joinChannelEx. - * - * @param uid The remote user ID. It should be the same as RTC channel remote user id. - * @param connection The RTC connection whose spatial audio effect you want to update. See #RtcConnection. + * Set the audio attenuation coefficient of the player + * @param playerId The ID of the media player. You can get it by IMediaPlayer::getMediaPlayerId. + * @param attenuation The audio attenuation of the media player. + * @param forceSet Whether to force the setting of audio attenuation coefficient. * @return * - 0: Success. * - <0: Failure. */ - virtual int removeRemotePositionEx(uid_t uid, const RtcConnection& connection) = 0; + virtual int setPlayerAttenuation(int playerId, double attenuation, bool forceSet) = 0; /** * Clear the position informations of remote users. * @@ -294,21 +295,8 @@ class ILocalSpatialAudioEngine : public IBaseSpatialAudioEngine { * - 0: Success. * - <0: Failure. */ - virtual int clearRemotePositions() = 0; - /** - * Clear the position informations of remote users. It's supposed to use with IRtcEngineEx::joinChannelEx. - * - * @return - * - 0: Success. - * - <0: Failure. - */ - virtual int clearRemotePositionsEx(const RtcConnection& connection) = 0; - - - virtual int setRemoteAudioAttenuation(uid_t uid, double attenuation, bool forceSet) = 0; + virtual int clearRemotePositions() = 0; }; } // namespace rtc } // namespace agora - -#endif diff --git a/Android/APIExample/app/src/main/java/io/agora/api/example/common/model/StatisticsInfo.java b/Android/APIExample/app/src/main/java/io/agora/api/example/common/model/StatisticsInfo.java index 2d5615ba2..41498800a 100644 --- a/Android/APIExample/app/src/main/java/io/agora/api/example/common/model/StatisticsInfo.java +++ b/Android/APIExample/app/src/main/java/io/agora/api/example/common/model/StatisticsInfo.java @@ -2,16 +2,15 @@ import io.agora.rtc2.IRtcEngineEventHandler; -import io.agora.rtc2.IRtcEngineEventHandlerBase; /** * The type Statistics info. */ public class StatisticsInfo { - private IRtcEngineEventHandler.LocalVideoStats localVideoStats = new IRtcEngineEventHandler.LocalVideoStats(new IRtcEngineEventHandlerBase.LocalVideoStatsBase()); + private IRtcEngineEventHandler.LocalVideoStats localVideoStats = new IRtcEngineEventHandler.LocalVideoStats(); private IRtcEngineEventHandler.LocalAudioStats localAudioStats = new IRtcEngineEventHandler.LocalAudioStats(); - private IRtcEngineEventHandler.RemoteVideoStats remoteVideoStats = new IRtcEngineEventHandler.RemoteVideoStats(new IRtcEngineEventHandlerBase.RemoteVideoStatsBase()); - private IRtcEngineEventHandler.RemoteAudioStats remoteAudioStats = new IRtcEngineEventHandler.RemoteAudioStats(new IRtcEngineEventHandlerBase.RemoteAudioStatsBase()); + private IRtcEngineEventHandler.RemoteVideoStats remoteVideoStats = new IRtcEngineEventHandler.RemoteVideoStats(); + private IRtcEngineEventHandler.RemoteAudioStats remoteAudioStats = new IRtcEngineEventHandler.RemoteAudioStats(); private IRtcEngineEventHandler.RtcStats rtcStats = new IRtcEngineEventHandler.RtcStats(); private int quality; private IRtcEngineEventHandler.LastmileProbeResult lastMileProbeResult; diff --git a/Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/CDNStreaming/AudienceFragment.java b/Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/CDNStreaming/AudienceFragment.java index 87ecb6d49..ecffd3757 100644 --- a/Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/CDNStreaming/AudienceFragment.java +++ b/Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/CDNStreaming/AudienceFragment.java @@ -424,12 +424,12 @@ private String getUrl() { } @Override - public void onPlayerStateChanged(io.agora.mediaplayer.Constants.MediaPlayerState mediaPlayerState, io.agora.mediaplayer.Constants.MediaPlayerError mediaPlayerError) { - showShortToast("player state change to " + mediaPlayerState.name()); + public void onPlayerStateChanged(io.agora.mediaplayer.Constants.MediaPlayerState state, io.agora.mediaplayer.Constants.MediaPlayerReason reason) { + showShortToast("player state change to " + state.name()); handler.post(new Runnable() { @Override public void run() { - switch (mediaPlayerState) { + switch (state) { case PLAYER_STATE_FAILED: mediaPlayer.stop(); //showLongToast(String.format("media player error: %s", mediaPlayerError.name())); @@ -444,7 +444,7 @@ public void run() { .setPositiveButton(R.string.confirm, (dialog, which) -> openPlayerWithUrl()) .create(); } - mPlayerFailDialog.setMessage(getString(R.string.media_player_error, mediaPlayerError.name()) + "\n\n" + getString(R.string.reopen_url_again)); + mPlayerFailDialog.setMessage(getString(R.string.media_player_error, reason.name()) + "\n\n" + getString(R.string.reopen_url_again)); mPlayerFailDialog.show(); break; case PLAYER_STATE_OPEN_COMPLETED: diff --git a/Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/CDNStreaming/HostFragment.java b/Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/CDNStreaming/HostFragment.java index d18ee43db..90d6dee98 100644 --- a/Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/CDNStreaming/HostFragment.java +++ b/Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/CDNStreaming/HostFragment.java @@ -30,8 +30,8 @@ import io.agora.api.example.common.BaseFragment; import io.agora.rtc2.ChannelMediaOptions; import io.agora.rtc2.Constants; -import io.agora.rtc2.DirectCdnStreamingError; import io.agora.rtc2.DirectCdnStreamingMediaOptions; +import io.agora.rtc2.DirectCdnStreamingReason; import io.agora.rtc2.DirectCdnStreamingState; import io.agora.rtc2.DirectCdnStreamingStats; import io.agora.rtc2.IDirectCdnStreamingEventHandler; @@ -461,13 +461,14 @@ private void updateTranscodeLayout() { private final IDirectCdnStreamingEventHandler iDirectCdnStreamingEventHandler = new IDirectCdnStreamingEventHandler() { + @Override - public void onDirectCdnStreamingStateChanged(DirectCdnStreamingState directCdnStreamingState, DirectCdnStreamingError directCdnStreamingError, String s) { - showShortToast(String.format("onDirectCdnStreamingStateChanged state:%s, error:%s", directCdnStreamingState, directCdnStreamingError)); + public void onDirectCdnStreamingStateChanged(DirectCdnStreamingState state, DirectCdnStreamingReason reason, String message) { + showShortToast(String.format("onDirectCdnStreamingStateChanged state:%s, error:%s", state, reason)); runOnUIThread(new Runnable() { @Override public void run() { - switch (directCdnStreamingState) { + switch (state) { case RUNNING: streamingButton.setText(R.string.stop_streaming); cdnStreaming = true; @@ -491,7 +492,7 @@ public void run() { case FAILED: showLongToast(String.format("Start Streaming failed, please go back to previous page and check the settings.")); default: - Log.i(TAG, String.format("onDirectCdnStreamingStateChanged, state: %s error: %s message: %s", directCdnStreamingState.name(), directCdnStreamingError.name(), s)); + Log.i(TAG, String.format("onDirectCdnStreamingStateChanged, state: %s error: %s message: %s", state.name(), reason.name(), message)); } rtcSwitcher.setEnabled(true); } diff --git a/Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/MediaPlayer.java b/Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/MediaPlayer.java index a68c46c6e..b57a7f749 100644 --- a/Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/MediaPlayer.java +++ b/Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/MediaPlayer.java @@ -600,11 +600,11 @@ private void setMediaPlayerViewEnable(boolean enable) { } @Override - public void onPlayerStateChanged(io.agora.mediaplayer.Constants.MediaPlayerState mediaPlayerState, io.agora.mediaplayer.Constants.MediaPlayerError mediaPlayerError) { - Log.e(TAG, "onPlayerStateChanged mediaPlayerState " + mediaPlayerState + ", error=" + mediaPlayerError); - if (mediaPlayerState.equals(PLAYER_STATE_OPEN_COMPLETED)) { + public void onPlayerStateChanged(io.agora.mediaplayer.Constants.MediaPlayerState state, io.agora.mediaplayer.Constants.MediaPlayerReason reason) { + Log.e(TAG, "onPlayerStateChanged mediaPlayerState " + state + ", reason=" + reason); + if (state.equals(PLAYER_STATE_OPEN_COMPLETED)) { setMediaPlayerViewEnable(true); - } else if (mediaPlayerState.equals(PLAYER_STATE_IDLE) || mediaPlayerState.equals(PLAYER_STATE_STOPPED) || mediaPlayerState.equals(PLAYER_STATE_PLAYBACK_COMPLETED)) { + } else if (state.equals(PLAYER_STATE_IDLE) || state.equals(PLAYER_STATE_STOPPED) || state.equals(PLAYER_STATE_PLAYBACK_COMPLETED)) { setMediaPlayerViewEnable(false); options.publishMediaPlayerVideoTrack = false; options.publishMediaPlayerAudioTrack = false; diff --git a/Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/MediaRecorder.java b/Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/MediaRecorder.java index efc539bee..6f77922e1 100644 --- a/Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/MediaRecorder.java +++ b/Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/MediaRecorder.java @@ -334,7 +334,7 @@ public void onRecorderStateChanged(String channelId, int uid, int state, int err Log.d(TAG, "RemoteMediaRecorder -- onRecorderStateChanged channelId=" + channelId + ", uid=" + uid + ", state=" + state + ", error=" + error); if (state == AgoraMediaRecorder.RECORDER_STATE_STOP) { showRecordMediaPathDialog(storagePath); - } else if (state == AgoraMediaRecorder.RECORDER_STATE_ERROR && error == AgoraMediaRecorder.RECORDER_ERROR_CONFIG_CHANGED) { + } else if (state == AgoraMediaRecorder.RECORDER_STATE_ERROR && error == AgoraMediaRecorder.RECORDER_REASON_CONFIG_CHANGED) { // switch camera while recording runOnUIThread(() -> { VideoReportLayout userView = getUserView(uid); @@ -388,7 +388,7 @@ public void onRecorderStateChanged(String channelId, int uid, int state, int err Log.d(TAG, "LocalMediaRecorder -- onRecorderStateChanged channelId=" + channelId + ", uid=" + uid + ", state=" + state + ", error=" + error); if (state == AgoraMediaRecorder.RECORDER_STATE_STOP) { showRecordMediaPathDialog(storagePath); - } else if (state == AgoraMediaRecorder.RECORDER_STATE_ERROR && error == AgoraMediaRecorder.RECORDER_ERROR_CONFIG_CHANGED) { + } else if (state == AgoraMediaRecorder.RECORDER_STATE_ERROR && error == AgoraMediaRecorder.RECORDER_REASON_CONFIG_CHANGED) { // switch camera while recording runOnUIThread(() -> { VideoReportLayout userView = fl_local; diff --git a/Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/RTMPStreaming.java b/Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/RTMPStreaming.java index c37b5ad6f..8614555a7 100644 --- a/Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/RTMPStreaming.java +++ b/Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/RTMPStreaming.java @@ -150,8 +150,7 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) { // This api can only be used in the private media server scenario, otherwise some problems may occur. engine.setLocalAccessPoint(localAccessPointConfiguration); } - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); getActivity().onBackPressed(); } @@ -530,7 +529,7 @@ public void onRtmpStreamingStateChanged(String url, int state, int errCode) { } if (state == Constants.RTMP_STREAM_PUBLISH_STATE_RUNNING) { /*After confirming the successful push, make changes to the UI.*/ - if (errCode == Constants.RTMP_STREAM_PUBLISH_ERROR_OK) { + if (errCode == Constants.RTMP_STREAM_PUBLISH_REASON_OK) { publishing = true; retried = 0; retryTask.cancel(true); @@ -541,11 +540,11 @@ public void onRtmpStreamingStateChanged(String url, int state, int errCode) { } } else if (state == Constants.RTMP_STREAM_PUBLISH_STATE_FAILURE) { engine.stopRtmpStream(et_url.getText().toString()); - if (errCode == Constants.RTMP_STREAM_PUBLISH_ERROR_CONNECTION_TIMEOUT - || errCode == Constants.RTMP_STREAM_PUBLISH_ERROR_INTERNAL_SERVER_ERROR - || errCode == Constants.RTMP_STREAM_PUBLISH_ERROR_RTMP_SERVER_ERROR - || errCode == Constants.RTMP_STREAM_PUBLISH_ERROR_STREAM_NOT_FOUND - || errCode == Constants.RTMP_STREAM_PUBLISH_ERROR_NET_DOWN) { + if (errCode == Constants.RTMP_STREAM_PUBLISH_REASON_CONNECTION_TIMEOUT + || errCode == Constants.RTMP_STREAM_PUBLISH_REASON_INTERNAL_SERVER_ERROR + || errCode == Constants.RTMP_STREAM_PUBLISH_REASON_RTMP_SERVER_ERROR + || errCode == Constants.RTMP_STREAM_PUBLISH_REASON_STREAM_NOT_FOUND + || errCode == Constants.RTMP_STREAM_PUBLISH_REASON_NET_DOWN) { /*need republishing.*/ Log.w(TAG, "RTMP publish failure ->" + url + ", state->" + state + ", errorType->" + errCode); } else { diff --git a/Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/SpatialSound.java b/Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/SpatialSound.java index 3492482f8..51a790ad9 100644 --- a/Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/SpatialSound.java +++ b/Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/SpatialSound.java @@ -403,7 +403,7 @@ private IMediaPlayer createLoopMediaPlayer() { IMediaPlayer mediaPlayer = engine.createMediaPlayer(); mediaPlayer.registerPlayerObserver(new IMediaPlayerObserver() { @Override - public void onPlayerStateChanged(Constants.MediaPlayerState state, Constants.MediaPlayerError error) { + public void onPlayerStateChanged(Constants.MediaPlayerState state, Constants.MediaPlayerReason reason) { if (state.equals(PLAYER_STATE_OPEN_COMPLETED)) { mediaPlayer.setLoopCount(-1); mediaPlayer.play();