Skip to content

Commit 188fa99

Browse files
authored
Merge pull request #350 from AgoraIO/dev/4.2.1-hotfix
Dev/4.2.1 hotfix
2 parents a31d1d2 + 458d6f8 commit 188fa99

File tree

30 files changed

+1040
-483
lines changed

30 files changed

+1040
-483
lines changed

Android/APIExample-Audio/app/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ dependencies {
4848
implementation fileTree(dir: "${localSdkPath}", include: ['*.jar', '*.aar'])
4949
}
5050
else{
51-
def agora_sdk_version = "4.2.0"
51+
def agora_sdk_version = "4.2.1"
5252
// case 1: full single lib with voice only
5353
implementation "io.agora.rtc:voice-sdk:${agora_sdk_version}"
5454
// case 2: partial libs with voice only

Android/APIExample-Audio/gradle/wrapper/gradle-wrapper.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
# distributionUrl=https://services.gradle.org/distributions/gradle-7.3.3-bin.zip
7-
distributionUrl=https://mirrors.cloud.tencent.com/gradle/gradle-7.3.3-bin.zip
6+
distributionUrl=https://services.gradle.org/distributions/gradle-7.3.3-bin.zip
7+
# distributionUrl=https://mirrors.cloud.tencent.com/gradle/gradle-7.3.3-bin.zip

Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/AgoraBase.h

+377-263
Large diffs are not rendered by default.

Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/AgoraMediaBase.h

+114-122
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,70 @@ typedef unsigned int track_id_t;
3131
typedef unsigned int conn_id_t;
3232
typedef unsigned int video_track_id_t;
3333

34+
static const unsigned int INVALID_TRACK_ID = 0xffffffff;
3435
static const unsigned int DEFAULT_CONNECTION_ID = 0;
3536
static const unsigned int DUMMY_CONNECTION_ID = (std::numeric_limits<unsigned int>::max)();
3637

3738

3839
struct EncodedVideoFrameInfo;
3940

41+
42+
/**
43+
* Video source types definition.
44+
**/
45+
enum VIDEO_SOURCE_TYPE {
46+
/** Video captured by the camera.
47+
*/
48+
VIDEO_SOURCE_CAMERA_PRIMARY = 0,
49+
VIDEO_SOURCE_CAMERA = VIDEO_SOURCE_CAMERA_PRIMARY,
50+
/** Video captured by the secondary camera.
51+
*/
52+
VIDEO_SOURCE_CAMERA_SECONDARY = 1,
53+
/** Video for screen sharing.
54+
*/
55+
VIDEO_SOURCE_SCREEN_PRIMARY = 2,
56+
VIDEO_SOURCE_SCREEN = VIDEO_SOURCE_SCREEN_PRIMARY,
57+
/** Video for secondary screen sharing.
58+
*/
59+
VIDEO_SOURCE_SCREEN_SECONDARY = 3,
60+
/** Not define.
61+
*/
62+
VIDEO_SOURCE_CUSTOM = 4,
63+
/** Video for media player sharing.
64+
*/
65+
VIDEO_SOURCE_MEDIA_PLAYER = 5,
66+
/** Video for png image.
67+
*/
68+
VIDEO_SOURCE_RTC_IMAGE_PNG = 6,
69+
/** Video for png image.
70+
*/
71+
VIDEO_SOURCE_RTC_IMAGE_JPEG = 7,
72+
/** Video for png image.
73+
*/
74+
VIDEO_SOURCE_RTC_IMAGE_GIF = 8,
75+
/** Remote video received from network.
76+
*/
77+
VIDEO_SOURCE_REMOTE = 9,
78+
/** Video for transcoded.
79+
*/
80+
VIDEO_SOURCE_TRANSCODED = 10,
81+
82+
/** Video captured by the third camera.
83+
*/
84+
VIDEO_SOURCE_CAMERA_THIRD = 11,
85+
/** Video captured by the fourth camera.
86+
*/
87+
VIDEO_SOURCE_CAMERA_FOURTH = 12,
88+
/** Video for third screen sharing.
89+
*/
90+
VIDEO_SOURCE_SCREEN_THIRD = 13,
91+
/** Video for fourth screen sharing.
92+
*/
93+
VIDEO_SOURCE_SCREEN_FOURTH = 14,
94+
95+
VIDEO_SOURCE_UNKNOWN = 100
96+
};
97+
4098
/**
4199
* Audio routes.
42100
*/
@@ -385,22 +443,6 @@ enum AUDIO_DUAL_MONO_MODE {
385443
/**< ChanLout=ChanRout=(ChanLin+ChanRin)/2 */
386444
AUDIO_DUAL_MONO_MIX = 3
387445
};
388-
/**
389-
* The audio frame observer.
390-
*/
391-
class IAudioFrameObserver {
392-
public:
393-
/**
394-
* Occurs when each time the player receives an audio frame.
395-
*
396-
* After registering the audio frame observer,
397-
* the callback occurs when each time the player receives an audio frame,
398-
* reporting the detailed information of the audio frame.
399-
* @param frame The detailed information of the audio frame. See {@link AudioPcmFrame}.
400-
*/
401-
virtual void onFrame(AudioPcmFrame* frame) = 0;
402-
virtual ~IAudioFrameObserver() {}
403-
};
404446

405447
/**
406448
* Video pixel formats.
@@ -479,9 +521,9 @@ enum RENDER_MODE_TYPE {
479521
};
480522

481523
/**
482-
* The video source type
524+
* The camera video source type
483525
*/
484-
enum VIDEO_SOURCE_TYPE {
526+
enum CAMERA_VIDEO_SOURCE_TYPE {
485527
/**
486528
* 0: the video frame comes from the front camera
487529
*/
@@ -516,7 +558,8 @@ struct ExternalVideoFrame {
516558
eglType(EGL_CONTEXT10),
517559
textureId(0),
518560
metadata_buffer(NULL),
519-
metadata_size(0){}
561+
metadata_size(0),
562+
alphaBuffer(NULL){}
520563

521564
/**
522565
* The EGL context type.
@@ -632,6 +675,12 @@ struct ExternalVideoFrame {
632675
* The default value is 0
633676
*/
634677
int metadata_size;
678+
/**
679+
* Indicates the output data of the portrait segmentation algorithm, which is consistent with the size of the video frame.
680+
* The value range of each pixel is [0,255], where 0 represents the background; 255 represents the foreground (portrait).
681+
* The default value is NULL
682+
*/
683+
uint8_t* alphaBuffer;
635684
};
636685

637686
/**
@@ -655,8 +704,10 @@ struct VideoFrame {
655704
metadata_size(0),
656705
sharedContext(0),
657706
textureId(0),
658-
alphaBuffer(NULL){}
659-
707+
alphaBuffer(NULL),
708+
pixelBuffer(NULL){
709+
memset(matrix, 0, sizeof(matrix));
710+
}
660711
/**
661712
* The video pixel format: #VIDEO_PIXEL_FORMAT.
662713
*/
@@ -731,11 +782,15 @@ struct VideoFrame {
731782
*/
732783
float matrix[16];
733784
/**
734-
* Portrait Segmentation meta buffer, dimension of which is the same as VideoFrame.
735-
* Pixl value is between 0-255, 0 represents totally background, 255 represents totally foreground.
785+
* Indicates the output data of the portrait segmentation algorithm, which is consistent with the size of the video frame.
786+
* The value range of each pixel is [0,255], where 0 represents the background; 255 represents the foreground (portrait).
736787
* The default value is NULL
737788
*/
738789
uint8_t* alphaBuffer;
790+
/**
791+
*The type of CVPixelBufferRef, for iOS and macOS only.
792+
*/
793+
void* pixelBuffer;
739794
};
740795

741796
/**
@@ -784,6 +839,23 @@ enum VIDEO_MODULE_POSITION {
784839

785840
} // namespace base
786841

842+
/**
843+
* The audio frame observer.
844+
*/
845+
class IAudioPcmFrameSink {
846+
public:
847+
/**
848+
* Occurs when each time the player receives an audio frame.
849+
*
850+
* After registering the audio frame observer,
851+
* the callback occurs when each time the player receives an audio frame,
852+
* reporting the detailed information of the audio frame.
853+
* @param frame The detailed information of the audio frame. See {@link AudioPcmFrame}.
854+
*/
855+
virtual void onFrame(agora::media::base::AudioPcmFrame* frame) = 0;
856+
virtual ~IAudioPcmFrameSink() {}
857+
};
858+
787859
/**
788860
* The IAudioFrameObserverBase class.
789861
*/
@@ -1178,11 +1250,12 @@ class IVideoFrameObserver {
11781250
* - The video data that this callback gets has not been pre-processed, such as watermarking, cropping content, rotating, or image enhancement.
11791251
*
11801252
* @param videoFrame A pointer to the video frame: VideoFrame
1253+
* @param sourceType source type of video frame. See #VIDEO_SOURCE_TYPE.
11811254
* @return Determines whether to ignore the current video frame if the pre-processing fails:
11821255
* - true: Do not ignore.
11831256
* - false: Ignore, in which case this method does not sent the current video frame to the SDK.
11841257
*/
1185-
virtual bool onCaptureVideoFrame(VideoFrame& videoFrame) = 0;
1258+
virtual bool onCaptureVideoFrame(agora::rtc::VIDEO_SOURCE_TYPE sourceType, VideoFrame& videoFrame) = 0;
11861259

11871260
/**
11881261
* Occurs each time the SDK receives a video frame before encoding.
@@ -1200,78 +1273,13 @@ class IVideoFrameObserver {
12001273
* - This callback does not support sending processed RGBA video data back to the SDK.
12011274
*
12021275
* @param videoFrame A pointer to the video frame: VideoFrame
1276+
* @param sourceType source type of video frame. See #VIDEO_SOURCE_TYPE.
12031277
* @return Determines whether to ignore the current video frame if the pre-processing fails:
12041278
* - true: Do not ignore.
12051279
* - false: Ignore, in which case this method does not sent the current video frame to the SDK.
12061280
*/
1207-
virtual bool onPreEncodeVideoFrame(VideoFrame& videoFrame) = 0;
1208-
1209-
virtual bool onSecondaryCameraCaptureVideoFrame(VideoFrame& videoFrame) = 0;
1210-
1211-
/**
1212-
* Gets the video data captured from the second camera before encoding.
1213-
*
1214-
* After you successfully register the video frame observer, the SDK triggers this callback each time
1215-
* when it receives a video frame. In this callback, you can get the video data before encoding. You can then
1216-
* process the data according to your particular scenarios.
1217-
*
1218-
* After processing, you can send the processed video data back to the SDK by setting the
1219-
* `videoFrame` parameter in this callback.
1220-
*
1221-
* @note
1222-
* - This callback is for Windows.
1223-
* - You need to set (1 << 2) as a frame position by `getObservedFramePosition` before you can use this callback to get the video data captured from the second screen and before encoding.
1224-
* - The video data that this callback gets has been pre-processed, such as watermarking, cropping content, rotating, or image enhancement.
1225-
* - This callback does not support sending processed RGBA video data back to the SDK.
1226-
*
1227-
* @param videoFrame A pointer to the video frame: VideoFrame
1228-
* @return Determines whether to ignore the current video frame if the pre-processing fails:
1229-
* - true: Do not ignore.
1230-
* - false: Ignore, in which case this method does not sent the current video frame to the SDK.
1231-
*/
1232-
virtual bool onSecondaryPreEncodeCameraVideoFrame(VideoFrame& videoFrame) = 0;
1281+
virtual bool onPreEncodeVideoFrame(agora::rtc::VIDEO_SOURCE_TYPE sourceType, VideoFrame& videoFrame) = 0;
12331282

1234-
/**
1235-
* Occurs each time the SDK receives a video frame captured by the screen.
1236-
*
1237-
* After you successfully register the video frame observer, the SDK triggers this callback each time
1238-
* a video frame is received. In this callback, you can get the video data captured by the screen.
1239-
* You can then pre-process the data according to your scenarios.
1240-
*
1241-
* After pre-processing, you can send the processed video data back to the SDK by setting the
1242-
* `videoFrame` parameter in this callback.
1243-
*
1244-
* @note
1245-
* - If you get the video data in RGBA color encoding format, Agora does not support using this callback to send the processed data in RGBA color encoding format back to the SDK.
1246-
* - The video data obtained through this callback has not undergone preprocessing, such as watermarking, cropping content, rotating, or image enhancement.
1247-
*
1248-
* @param videoFrame A pointer to the video frame: VideoFrame
1249-
* @return Determines whether to ignore the current video frame if the pre-processing fails:
1250-
* - true: Do not ignore.
1251-
* - false: Ignore, in which case this method does not sent the current video frame to the SDK.
1252-
*/
1253-
virtual bool onScreenCaptureVideoFrame(VideoFrame& videoFrame) = 0;
1254-
/**
1255-
* Gets the video data captured from the screen before encoding.
1256-
*
1257-
* After you successfully register the video frame observer, the SDK triggers this callback each
1258-
* time it receives a video frame. In this callback, you can get the video data captured from the
1259-
* screen before encoding and then process the data according to your particular scenarios.
1260-
*
1261-
* After processing, you can send the processed video data back to the SDK in this callback.
1262-
*
1263-
* @note
1264-
* - To get the video data captured from the second screen before encoding, you need to set
1265-
* (1 << 2) as a frame position through `getObservedFramePosition`.
1266-
* - The video data that this callback gets has been preprocessed, such as watermarking, cropping content, rotating, or image enhancement.
1267-
* - This callback does not support sending processed RGBA video data back to the SDK.
1268-
*
1269-
* @param videoFrame A pointer to the video frame: VideoFrame
1270-
* @return Determines whether to ignore the current video frame if the pre-processing fails:
1271-
* - true: Do not ignore.
1272-
* - false: Ignore, in which case this method does not sent the current video frame to the SDK.
1273-
*/
1274-
virtual bool onPreEncodeScreenVideoFrame(VideoFrame& videoFrame) = 0;
12751283
/**
12761284
* Occurs each time the SDK receives a video frame decoded by the MediaPlayer.
12771285
*
@@ -1281,38 +1289,18 @@ class IVideoFrameObserver {
12811289
*
12821290
* After pre-processing, you can send the processed video data back to the SDK by setting the
12831291
* `videoFrame` parameter in this callback.
1284-
*
1285-
* @param videoFrame A pointer to the video frame: VideoFrame
1286-
* @param mediaPlayerId ID of the mediaPlayer.
1287-
* @return Determines whether to ignore the current video frame if the pre-processing fails:
1288-
* - true: Do not ignore.
1289-
* - false: Ignore, in which case this method does not sent the current video frame to the SDK.
1290-
*/
1291-
virtual bool onMediaPlayerVideoFrame(VideoFrame& videoFrame, int mediaPlayerId) = 0;
1292-
1293-
virtual bool onSecondaryScreenCaptureVideoFrame(VideoFrame& videoFrame) = 0;
1294-
/**
1295-
* Gets the video data captured from the second camera before encoding.
1296-
*
1297-
* After you successfully register the video frame observer, the SDK triggers this callback each
1298-
* time it receives a video frame. In this callback, you can get the video data captured from the
1299-
* second camera before encoding and then process the data according to your particular scenarios.
1300-
*
1301-
* After processing, you can send the processed video data back to the SDK in this callback.
13021292
*
13031293
* @note
1304-
* - This callback is for Windows.
1305-
* - You need to set (1 << 2) as a frame position by `getObservedFramePosition` before you can
1306-
* use this callback to get the video data captured from the second screen and before encoding.
1307-
* - The video data that this callback gets has been preprocessed, such as watermarking, cropping content, rotating, or image enhancement.
1308-
* - This callback does not support sending processed RGBA video data back to the SDK.
1294+
* - This callback will not be affected by the return values of \ref getVideoFrameProcessMode "getVideoFrameProcessMode", \ref getRotationApplied "getRotationApplied", \ref getMirrorApplied "getMirrorApplied", \ref getObservedFramePosition "getObservedFramePosition".
1295+
* - On Android, this callback is not affected by the return value of \ref getVideoFormatPreference "getVideoFormatPreference"
13091296
*
13101297
* @param videoFrame A pointer to the video frame: VideoFrame
1298+
* @param mediaPlayerId ID of the mediaPlayer.
13111299
* @return Determines whether to ignore the current video frame if the pre-processing fails:
13121300
* - true: Do not ignore.
13131301
* - false: Ignore, in which case this method does not sent the current video frame to the SDK.
13141302
*/
1315-
virtual bool onSecondaryPreEncodeScreenVideoFrame(VideoFrame& videoFrame) = 0;
1303+
virtual bool onMediaPlayerVideoFrame(VideoFrame& videoFrame, int mediaPlayerId) = 0;
13161304

13171305
/**
13181306
* Occurs each time the SDK receives a video frame sent by the remote user.
@@ -1584,28 +1572,32 @@ class IMediaRecorderObserver {
15841572
/**
15851573
* Occurs when the recording state changes.
15861574
*
1587-
* @since v3.5.2
1575+
* @since v4.0.0
15881576
*
15891577
* When the local audio and video recording state changes, the SDK triggers this callback to report the current
15901578
* recording state and the reason for the change.
15911579
*
1592-
* @param state The current recording state. See \ref agora::rtc::RecorderState "RecorderState".
1593-
* @param error The reason for the state change. See \ref agora::rtc::RecorderErrorCode "RecorderErrorCode".
1580+
* @param channelId The channel name.
1581+
* @param uid ID of the user.
1582+
* @param state The current recording state. See \ref agora::media::RecorderState "RecorderState".
1583+
* @param error The reason for the state change. See \ref agora::media::RecorderErrorCode "RecorderErrorCode".
15941584
*/
1595-
virtual void onRecorderStateChanged(RecorderState state, RecorderErrorCode error) = 0;
1585+
virtual void onRecorderStateChanged(const char* channelId, rtc::uid_t uid, RecorderState state, RecorderErrorCode error) = 0;
15961586
/**
15971587
* Occurs when the recording information is updated.
15981588
*
1599-
* @since v3.5.2
1589+
* @since v4.0.0
16001590
*
16011591
* After you successfully register this callback and enable the local audio and video recording, the SDK periodically triggers
16021592
* the `onRecorderInfoUpdated` callback based on the set value of `recorderInfoUpdateInterval`. This callback reports the
16031593
* filename, duration, and size of the current recording file.
16041594
*
1605-
* @param info Information for the recording file. See RecorderInfo.
1595+
* @param channelId The channel name.
1596+
* @param uid ID of the user.
1597+
* @param info Information about the recording file. See \ref agora::media::RecorderInfo "RecorderInfo".
16061598
*
16071599
*/
1608-
virtual void onRecorderInfoUpdated(const RecorderInfo& info) = 0;
1600+
virtual void onRecorderInfoUpdated(const char* channelId, rtc::uid_t uid, const RecorderInfo& info) = 0;
16091601
virtual ~IMediaRecorderObserver() {}
16101602
};
16111603
} // namespace media

Android/APIExample/agora-simple-filter/src/main/cpp/AgoraRtcKit/AgoraMediaPlayerTypes.h

+5
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,11 @@ struct MediaSource {
427427
/**
428428
* Determines whether to enable cache streaming to local files. If enable cached, the media player will
429429
* use the url or uri as the cache index.
430+
*
431+
* @note
432+
* The local cache function only supports on-demand video/audio streams and does not support live streams.
433+
* Caching video and audio files based on the HLS protocol (m3u8) to your local device is not supported.
434+
*
430435
* - true: Enable cache.
431436
* - false: (Default) Disable cache.
432437
*/

0 commit comments

Comments
 (0)