AgoraSDK-4.1.1.33
This commit is contained in:
parent
b9144b69c0
commit
8440d6d0d4
|
@ -0,0 +1,58 @@
|
||||||
|
// swift-tools-version: 5.10
|
||||||
|
// The swift-tools-version declares the minimum version of Swift required to build this package.
|
||||||
|
|
||||||
|
import PackageDescription
|
||||||
|
|
||||||
|
let package = Package(
|
||||||
|
name: "AgoraSDK-4.1.1.33",
|
||||||
|
products: [
|
||||||
|
// Products define the executables and libraries a package produces, making them visible to other packages.
|
||||||
|
.library(
|
||||||
|
name: "AgoraSDK-4.1.1.33",
|
||||||
|
targets: [
|
||||||
|
"AgoraAiEchoCancellationExtension",
|
||||||
|
"AgoraAiNoiseSuppressionExtension",
|
||||||
|
"AgoraAudioBeautyExtension",
|
||||||
|
"AgoraClearVisionExtension",
|
||||||
|
"AgoraContentInspectExtension",
|
||||||
|
"AgoraDav1d",
|
||||||
|
"AgoraFaceDetectionExtension",
|
||||||
|
"Agorafdkaac",
|
||||||
|
"Agoraffmpeg",
|
||||||
|
"AgoraReplayKitExtension",
|
||||||
|
"AgoraRtcKit",
|
||||||
|
"AgoraSoundTouch",
|
||||||
|
"AgoraSpatialAudioExtension",
|
||||||
|
"AgoraVideoDecoderExtension",
|
||||||
|
"AgoraVideoEncoderExtension",
|
||||||
|
"AgoraVideoQualityAnalyzerExtension",
|
||||||
|
"AgoraVideoSegmentationExtension",
|
||||||
|
"video_dec",
|
||||||
|
"video_enc",
|
||||||
|
]
|
||||||
|
),
|
||||||
|
],
|
||||||
|
targets: [
|
||||||
|
// Targets are the basic building blocks of a package, defining a module or a test suite.
|
||||||
|
// Targets can depend on other targets in this package and products from dependencies.
|
||||||
|
.binaryTarget(name: "AgoraAiEchoCancellationExtension", path: "Sources/AgoraAiEchoCancellationExtension.xcframework"),
|
||||||
|
.binaryTarget(name: "AgoraAiNoiseSuppressionExtension", path: "Sources/AgoraAiNoiseSuppressionExtension.xcframework"),
|
||||||
|
.binaryTarget(name: "AgoraAudioBeautyExtension", path: "Sources/AgoraAudioBeautyExtension.xcframework"),
|
||||||
|
.binaryTarget(name: "AgoraClearVisionExtension", path: "Sources/AgoraClearVisionExtension.xcframework"),
|
||||||
|
.binaryTarget(name: "AgoraContentInspectExtension", path: "Sources/AgoraContentInspectExtension.xcframework"),
|
||||||
|
.binaryTarget(name: "AgoraDav1d", path: "Sources/AgoraDav1d.xcframework"),
|
||||||
|
.binaryTarget(name: "AgoraFaceDetectionExtension", path: "Sources/AgoraFaceDetectionExtension.xcframework"),
|
||||||
|
.binaryTarget(name: "Agorafdkaac", path: "Sources/Agorafdkaac.xcframework"),
|
||||||
|
.binaryTarget(name: "Agoraffmpeg", path: "Sources/Agoraffmpeg.xcframework"),
|
||||||
|
.binaryTarget(name: "AgoraReplayKitExtension", path: "Sources/AgoraReplayKitExtension.xcframework"),
|
||||||
|
.binaryTarget(name: "AgoraRtcKit", path: "Sources/AgoraRtcKit.xcframework"),
|
||||||
|
.binaryTarget(name: "AgoraSoundTouch", path: "Sources/AgoraSoundTouch.xcframework"),
|
||||||
|
.binaryTarget(name: "AgoraSpatialAudioExtension", path: "Sources/AgoraSpatialAudioExtension.xcframework"),
|
||||||
|
.binaryTarget(name: "AgoraVideoDecoderExtension", path: "Sources/AgoraVideoDecoderExtension.xcframework"),
|
||||||
|
.binaryTarget(name: "AgoraVideoEncoderExtension", path: "Sources/AgoraVideoEncoderExtension.xcframework"),
|
||||||
|
.binaryTarget(name: "AgoraVideoQualityAnalyzerExtension", path: "Sources/AgoraVideoQualityAnalyzerExtension.xcframework"),
|
||||||
|
.binaryTarget(name: "AgoraVideoSegmentationExtension", path: "Sources/AgoraVideoSegmentationExtension.xcframework"),
|
||||||
|
.binaryTarget(name: "video_dec", path: "Sources/video_dec.xcframework"),
|
||||||
|
.binaryTarget(name: "video_enc", path: "Sources/video_enc.xcframework"),
|
||||||
|
]
|
||||||
|
)
|
|
@ -0,0 +1,41 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>AvailableLibraries</key>
|
||||||
|
<array>
|
||||||
|
<dict>
|
||||||
|
<key>LibraryIdentifier</key>
|
||||||
|
<string>ios-arm64_x86_64-simulator</string>
|
||||||
|
<key>LibraryPath</key>
|
||||||
|
<string>AgoraAiEchoCancellationExtension.framework</string>
|
||||||
|
<key>SupportedArchitectures</key>
|
||||||
|
<array>
|
||||||
|
<string>arm64</string>
|
||||||
|
<string>x86_64</string>
|
||||||
|
</array>
|
||||||
|
<key>SupportedPlatform</key>
|
||||||
|
<string>ios</string>
|
||||||
|
<key>SupportedPlatformVariant</key>
|
||||||
|
<string>simulator</string>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>LibraryIdentifier</key>
|
||||||
|
<string>ios-arm64_armv7</string>
|
||||||
|
<key>LibraryPath</key>
|
||||||
|
<string>AgoraAiEchoCancellationExtension.framework</string>
|
||||||
|
<key>SupportedArchitectures</key>
|
||||||
|
<array>
|
||||||
|
<string>arm64</string>
|
||||||
|
<string>armv7</string>
|
||||||
|
</array>
|
||||||
|
<key>SupportedPlatform</key>
|
||||||
|
<string>ios</string>
|
||||||
|
</dict>
|
||||||
|
</array>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>XFWK</string>
|
||||||
|
<key>XCFrameworkFormatVersion</key>
|
||||||
|
<string>1.0</string>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,41 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>AvailableLibraries</key>
|
||||||
|
<array>
|
||||||
|
<dict>
|
||||||
|
<key>LibraryIdentifier</key>
|
||||||
|
<string>ios-arm64_armv7</string>
|
||||||
|
<key>LibraryPath</key>
|
||||||
|
<string>AgoraAiNoiseSuppressionExtension.framework</string>
|
||||||
|
<key>SupportedArchitectures</key>
|
||||||
|
<array>
|
||||||
|
<string>arm64</string>
|
||||||
|
<string>armv7</string>
|
||||||
|
</array>
|
||||||
|
<key>SupportedPlatform</key>
|
||||||
|
<string>ios</string>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>LibraryIdentifier</key>
|
||||||
|
<string>ios-arm64_x86_64-simulator</string>
|
||||||
|
<key>LibraryPath</key>
|
||||||
|
<string>AgoraAiNoiseSuppressionExtension.framework</string>
|
||||||
|
<key>SupportedArchitectures</key>
|
||||||
|
<array>
|
||||||
|
<string>arm64</string>
|
||||||
|
<string>x86_64</string>
|
||||||
|
</array>
|
||||||
|
<key>SupportedPlatform</key>
|
||||||
|
<string>ios</string>
|
||||||
|
<key>SupportedPlatformVariant</key>
|
||||||
|
<string>simulator</string>
|
||||||
|
</dict>
|
||||||
|
</array>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>XFWK</string>
|
||||||
|
<key>XCFrameworkFormatVersion</key>
|
||||||
|
<string>1.0</string>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,41 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>AvailableLibraries</key>
|
||||||
|
<array>
|
||||||
|
<dict>
|
||||||
|
<key>LibraryIdentifier</key>
|
||||||
|
<string>ios-arm64_armv7</string>
|
||||||
|
<key>LibraryPath</key>
|
||||||
|
<string>AgoraAudioBeautyExtension.framework</string>
|
||||||
|
<key>SupportedArchitectures</key>
|
||||||
|
<array>
|
||||||
|
<string>arm64</string>
|
||||||
|
<string>armv7</string>
|
||||||
|
</array>
|
||||||
|
<key>SupportedPlatform</key>
|
||||||
|
<string>ios</string>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>LibraryIdentifier</key>
|
||||||
|
<string>ios-arm64_x86_64-simulator</string>
|
||||||
|
<key>LibraryPath</key>
|
||||||
|
<string>AgoraAudioBeautyExtension.framework</string>
|
||||||
|
<key>SupportedArchitectures</key>
|
||||||
|
<array>
|
||||||
|
<string>arm64</string>
|
||||||
|
<string>x86_64</string>
|
||||||
|
</array>
|
||||||
|
<key>SupportedPlatform</key>
|
||||||
|
<string>ios</string>
|
||||||
|
<key>SupportedPlatformVariant</key>
|
||||||
|
<string>simulator</string>
|
||||||
|
</dict>
|
||||||
|
</array>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>XFWK</string>
|
||||||
|
<key>XCFrameworkFormatVersion</key>
|
||||||
|
<string>1.0</string>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,41 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>AvailableLibraries</key>
|
||||||
|
<array>
|
||||||
|
<dict>
|
||||||
|
<key>LibraryIdentifier</key>
|
||||||
|
<string>ios-arm64_armv7</string>
|
||||||
|
<key>LibraryPath</key>
|
||||||
|
<string>AgoraClearVisionExtension.framework</string>
|
||||||
|
<key>SupportedArchitectures</key>
|
||||||
|
<array>
|
||||||
|
<string>arm64</string>
|
||||||
|
<string>armv7</string>
|
||||||
|
</array>
|
||||||
|
<key>SupportedPlatform</key>
|
||||||
|
<string>ios</string>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>LibraryIdentifier</key>
|
||||||
|
<string>ios-arm64_x86_64-simulator</string>
|
||||||
|
<key>LibraryPath</key>
|
||||||
|
<string>AgoraClearVisionExtension.framework</string>
|
||||||
|
<key>SupportedArchitectures</key>
|
||||||
|
<array>
|
||||||
|
<string>arm64</string>
|
||||||
|
<string>x86_64</string>
|
||||||
|
</array>
|
||||||
|
<key>SupportedPlatform</key>
|
||||||
|
<string>ios</string>
|
||||||
|
<key>SupportedPlatformVariant</key>
|
||||||
|
<string>simulator</string>
|
||||||
|
</dict>
|
||||||
|
</array>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>XFWK</string>
|
||||||
|
<key>XCFrameworkFormatVersion</key>
|
||||||
|
<string>1.0</string>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,41 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>AvailableLibraries</key>
|
||||||
|
<array>
|
||||||
|
<dict>
|
||||||
|
<key>LibraryIdentifier</key>
|
||||||
|
<string>ios-arm64_armv7</string>
|
||||||
|
<key>LibraryPath</key>
|
||||||
|
<string>AgoraContentInspectExtension.framework</string>
|
||||||
|
<key>SupportedArchitectures</key>
|
||||||
|
<array>
|
||||||
|
<string>arm64</string>
|
||||||
|
<string>armv7</string>
|
||||||
|
</array>
|
||||||
|
<key>SupportedPlatform</key>
|
||||||
|
<string>ios</string>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>LibraryIdentifier</key>
|
||||||
|
<string>ios-arm64_x86_64-simulator</string>
|
||||||
|
<key>LibraryPath</key>
|
||||||
|
<string>AgoraContentInspectExtension.framework</string>
|
||||||
|
<key>SupportedArchitectures</key>
|
||||||
|
<array>
|
||||||
|
<string>arm64</string>
|
||||||
|
<string>x86_64</string>
|
||||||
|
</array>
|
||||||
|
<key>SupportedPlatform</key>
|
||||||
|
<string>ios</string>
|
||||||
|
<key>SupportedPlatformVariant</key>
|
||||||
|
<string>simulator</string>
|
||||||
|
</dict>
|
||||||
|
</array>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>XFWK</string>
|
||||||
|
<key>XCFrameworkFormatVersion</key>
|
||||||
|
<string>1.0</string>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,41 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>AvailableLibraries</key>
|
||||||
|
<array>
|
||||||
|
<dict>
|
||||||
|
<key>LibraryIdentifier</key>
|
||||||
|
<string>ios-arm64_armv7</string>
|
||||||
|
<key>LibraryPath</key>
|
||||||
|
<string>AgoraDav1d.framework</string>
|
||||||
|
<key>SupportedArchitectures</key>
|
||||||
|
<array>
|
||||||
|
<string>arm64</string>
|
||||||
|
<string>armv7</string>
|
||||||
|
</array>
|
||||||
|
<key>SupportedPlatform</key>
|
||||||
|
<string>ios</string>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>LibraryIdentifier</key>
|
||||||
|
<string>ios-arm64_x86_64-simulator</string>
|
||||||
|
<key>LibraryPath</key>
|
||||||
|
<string>AgoraDav1d.framework</string>
|
||||||
|
<key>SupportedArchitectures</key>
|
||||||
|
<array>
|
||||||
|
<string>arm64</string>
|
||||||
|
<string>x86_64</string>
|
||||||
|
</array>
|
||||||
|
<key>SupportedPlatform</key>
|
||||||
|
<string>ios</string>
|
||||||
|
<key>SupportedPlatformVariant</key>
|
||||||
|
<string>simulator</string>
|
||||||
|
</dict>
|
||||||
|
</array>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>XFWK</string>
|
||||||
|
<key>XCFrameworkFormatVersion</key>
|
||||||
|
<string>1.0</string>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,41 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>AvailableLibraries</key>
|
||||||
|
<array>
|
||||||
|
<dict>
|
||||||
|
<key>LibraryIdentifier</key>
|
||||||
|
<string>ios-arm64_x86_64-simulator</string>
|
||||||
|
<key>LibraryPath</key>
|
||||||
|
<string>AgoraFaceDetectionExtension.framework</string>
|
||||||
|
<key>SupportedArchitectures</key>
|
||||||
|
<array>
|
||||||
|
<string>arm64</string>
|
||||||
|
<string>x86_64</string>
|
||||||
|
</array>
|
||||||
|
<key>SupportedPlatform</key>
|
||||||
|
<string>ios</string>
|
||||||
|
<key>SupportedPlatformVariant</key>
|
||||||
|
<string>simulator</string>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>LibraryIdentifier</key>
|
||||||
|
<string>ios-arm64_armv7</string>
|
||||||
|
<key>LibraryPath</key>
|
||||||
|
<string>AgoraFaceDetectionExtension.framework</string>
|
||||||
|
<key>SupportedArchitectures</key>
|
||||||
|
<array>
|
||||||
|
<string>arm64</string>
|
||||||
|
<string>armv7</string>
|
||||||
|
</array>
|
||||||
|
<key>SupportedPlatform</key>
|
||||||
|
<string>ios</string>
|
||||||
|
</dict>
|
||||||
|
</array>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>XFWK</string>
|
||||||
|
<key>XCFrameworkFormatVersion</key>
|
||||||
|
<string>1.0</string>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,41 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>AvailableLibraries</key>
|
||||||
|
<array>
|
||||||
|
<dict>
|
||||||
|
<key>LibraryIdentifier</key>
|
||||||
|
<string>ios-arm64_armv7</string>
|
||||||
|
<key>LibraryPath</key>
|
||||||
|
<string>AgoraReplayKitExtension.framework</string>
|
||||||
|
<key>SupportedArchitectures</key>
|
||||||
|
<array>
|
||||||
|
<string>arm64</string>
|
||||||
|
<string>armv7</string>
|
||||||
|
</array>
|
||||||
|
<key>SupportedPlatform</key>
|
||||||
|
<string>ios</string>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>LibraryIdentifier</key>
|
||||||
|
<string>ios-arm64_x86_64-simulator</string>
|
||||||
|
<key>LibraryPath</key>
|
||||||
|
<string>AgoraReplayKitExtension.framework</string>
|
||||||
|
<key>SupportedArchitectures</key>
|
||||||
|
<array>
|
||||||
|
<string>arm64</string>
|
||||||
|
<string>x86_64</string>
|
||||||
|
</array>
|
||||||
|
<key>SupportedPlatform</key>
|
||||||
|
<string>ios</string>
|
||||||
|
<key>SupportedPlatformVariant</key>
|
||||||
|
<string>simulator</string>
|
||||||
|
</dict>
|
||||||
|
</array>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>XFWK</string>
|
||||||
|
<key>XCFrameworkFormatVersion</key>
|
||||||
|
<string>1.0</string>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
Binary file not shown.
|
@ -0,0 +1,44 @@
|
||||||
|
//
|
||||||
|
// AgoraSampleHander.h
|
||||||
|
// BroadCastUI
|
||||||
|
//
|
||||||
|
// Created by Agora on 2022/1/25.
|
||||||
|
// Copyright (c) 2022 Agora IO. All rights reserved.
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import <ReplayKit/ReplayKit.h>
|
||||||
|
typedef enum {
|
||||||
|
// Failed to connect to the app process, Please call startScreenCapture in the app process.
|
||||||
|
AgoraReplayKitExtReasonConnectFail = 1,
|
||||||
|
// Disconnected from the app process. Please Check the APP process exits or not.
|
||||||
|
AgoraReplayKitExtReasonDisconnect = 2,
|
||||||
|
// Stopped by the user or the app process.
|
||||||
|
AgoraReplayKitExtReasonInitiativeStop = 3,
|
||||||
|
} AgoraReplayKitExtReason;
|
||||||
|
|
||||||
|
@class AgoraReplayKitExt;
|
||||||
|
|
||||||
|
@protocol AgoraReplayKitExtDelegate <NSObject>
|
||||||
|
|
||||||
|
- (void)broadcastFinished:(AgoraReplayKitExt* _Nonnull)broadcast
|
||||||
|
reason:(AgoraReplayKitExtReason)reason;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
API_AVAILABLE(ios(11.0))
|
||||||
|
NS_SWIFT_NAME(AgoraReplayKitExt)
|
||||||
|
__attribute__((visibility("default")))
|
||||||
|
@interface AgoraReplayKitExt : NSObject
|
||||||
|
|
||||||
|
+ (instancetype)shareInstance;
|
||||||
|
|
||||||
|
- (void)start:(id<AgoraReplayKitExtDelegate>)delegate;
|
||||||
|
- (void)stop;
|
||||||
|
- (void)resume;
|
||||||
|
- (void)pause;
|
||||||
|
- (void)pushSampleBuffer:(CMSampleBufferRef)sampleBuffer
|
||||||
|
withType:(RPSampleBufferType)sampleBufferType;
|
||||||
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
|
@ -0,0 +1,15 @@
|
||||||
|
//
|
||||||
|
// AgoraReplayKitExtension.h
|
||||||
|
// AgoraScreenShare
|
||||||
|
//
|
||||||
|
// Created by Agora on 2022/1/25.
|
||||||
|
// Copyright (c) 2022 Agora IO. All rights reserved.
|
||||||
|
|
||||||
|
#ifndef AgoraReplayKitExtension_h
|
||||||
|
#define AgoraReplayKitExtension_h
|
||||||
|
|
||||||
|
#import <AgoraReplayKitExtension/AgoraReplayKitExt.h>
|
||||||
|
#import <AgoraReplayKitExtension/AgoraReplayKitHandler.h>
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* AgoraReplayKitExtension_h */
|
|
@ -0,0 +1,14 @@
|
||||||
|
//
|
||||||
|
// SampleHandler.h
|
||||||
|
// BroadCastUI
|
||||||
|
//
|
||||||
|
// Created by Agora on 2022/1/25.
|
||||||
|
// Copyright (c) 2022 Agora IO. All rights reserved.
|
||||||
|
|
||||||
|
#import <ReplayKit/ReplayKit.h>
|
||||||
|
|
||||||
|
API_AVAILABLE(ios(11.0))
|
||||||
|
__attribute__((visibility("default")))
|
||||||
|
@interface AgoraReplayKitHandler : RPBroadcastSampleHandler
|
||||||
|
|
||||||
|
@end
|
Binary file not shown.
|
@ -0,0 +1,6 @@
|
||||||
|
framework module AgoraReplayKitExtension {
|
||||||
|
header "AgoraReplayKitExtension.h"
|
||||||
|
header "AgoraReplayKitExt.h"
|
||||||
|
header "AgoraReplayKitHandler.h"
|
||||||
|
export *
|
||||||
|
}
|
Binary file not shown.
|
@ -0,0 +1,44 @@
|
||||||
|
//
|
||||||
|
// AgoraSampleHander.h
|
||||||
|
// BroadCastUI
|
||||||
|
//
|
||||||
|
// Created by Agora on 2022/1/25.
|
||||||
|
// Copyright (c) 2022 Agora IO. All rights reserved.
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import <ReplayKit/ReplayKit.h>
|
||||||
|
typedef enum {
|
||||||
|
// Failed to connect to the app process, Please call startScreenCapture in the app process.
|
||||||
|
AgoraReplayKitExtReasonConnectFail = 1,
|
||||||
|
// Disconnected from the app process. Please Check the APP process exits or not.
|
||||||
|
AgoraReplayKitExtReasonDisconnect = 2,
|
||||||
|
// Stopped by the user or the app process.
|
||||||
|
AgoraReplayKitExtReasonInitiativeStop = 3,
|
||||||
|
} AgoraReplayKitExtReason;
|
||||||
|
|
||||||
|
@class AgoraReplayKitExt;
|
||||||
|
|
||||||
|
@protocol AgoraReplayKitExtDelegate <NSObject>
|
||||||
|
|
||||||
|
- (void)broadcastFinished:(AgoraReplayKitExt* _Nonnull)broadcast
|
||||||
|
reason:(AgoraReplayKitExtReason)reason;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
API_AVAILABLE(ios(11.0))
|
||||||
|
NS_SWIFT_NAME(AgoraReplayKitExt)
|
||||||
|
__attribute__((visibility("default")))
|
||||||
|
@interface AgoraReplayKitExt : NSObject
|
||||||
|
|
||||||
|
+ (instancetype)shareInstance;
|
||||||
|
|
||||||
|
- (void)start:(id<AgoraReplayKitExtDelegate>)delegate;
|
||||||
|
- (void)stop;
|
||||||
|
- (void)resume;
|
||||||
|
- (void)pause;
|
||||||
|
- (void)pushSampleBuffer:(CMSampleBufferRef)sampleBuffer
|
||||||
|
withType:(RPSampleBufferType)sampleBufferType;
|
||||||
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
|
@ -0,0 +1,15 @@
|
||||||
|
//
|
||||||
|
// AgoraReplayKitExtension.h
|
||||||
|
// AgoraScreenShare
|
||||||
|
//
|
||||||
|
// Created by Agora on 2022/1/25.
|
||||||
|
// Copyright (c) 2022 Agora IO. All rights reserved.
|
||||||
|
|
||||||
|
#ifndef AgoraReplayKitExtension_h
|
||||||
|
#define AgoraReplayKitExtension_h
|
||||||
|
|
||||||
|
#import <AgoraReplayKitExtension/AgoraReplayKitExt.h>
|
||||||
|
#import <AgoraReplayKitExtension/AgoraReplayKitHandler.h>
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* AgoraReplayKitExtension_h */
|
|
@ -0,0 +1,14 @@
|
||||||
|
//
|
||||||
|
// SampleHandler.h
|
||||||
|
// BroadCastUI
|
||||||
|
//
|
||||||
|
// Created by Agora on 2022/1/25.
|
||||||
|
// Copyright (c) 2022 Agora IO. All rights reserved.
|
||||||
|
|
||||||
|
#import <ReplayKit/ReplayKit.h>
|
||||||
|
|
||||||
|
API_AVAILABLE(ios(11.0))
|
||||||
|
__attribute__((visibility("default")))
|
||||||
|
@interface AgoraReplayKitHandler : RPBroadcastSampleHandler
|
||||||
|
|
||||||
|
@end
|
Binary file not shown.
|
@ -0,0 +1,6 @@
|
||||||
|
framework module AgoraReplayKitExtension {
|
||||||
|
header "AgoraReplayKitExtension.h"
|
||||||
|
header "AgoraReplayKitExt.h"
|
||||||
|
header "AgoraReplayKitHandler.h"
|
||||||
|
export *
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>AvailableLibraries</key>
|
||||||
|
<array>
|
||||||
|
<dict>
|
||||||
|
<key>LibraryIdentifier</key>
|
||||||
|
<string>ios-arm64_armv7</string>
|
||||||
|
<key>LibraryPath</key>
|
||||||
|
<string>AgoraRtcKit.framework</string>
|
||||||
|
<key>SupportedArchitectures</key>
|
||||||
|
<array>
|
||||||
|
<string>arm64</string>
|
||||||
|
<string>armv7</string>
|
||||||
|
</array>
|
||||||
|
<key>SupportedPlatform</key>
|
||||||
|
<string>ios</string>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>LibraryIdentifier</key>
|
||||||
|
<string>ios-arm64_x86_64-simulator</string>
|
||||||
|
<key>LibraryPath</key>
|
||||||
|
<string>AgoraRtcKit.framework</string>
|
||||||
|
<key>SupportedArchitectures</key>
|
||||||
|
<array>
|
||||||
|
<string>arm64</string>
|
||||||
|
<string>x86_64</string>
|
||||||
|
</array>
|
||||||
|
<key>SupportedPlatform</key>
|
||||||
|
<string>ios</string>
|
||||||
|
<key>SupportedPlatformVariant</key>
|
||||||
|
<string>simulator</string>
|
||||||
|
</dict>
|
||||||
|
</array>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>XFWK</string>
|
||||||
|
<key>XCFrameworkFormatVersion</key>
|
||||||
|
<string>1.0</string>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
Binary file not shown.
|
@ -0,0 +1,73 @@
|
||||||
|
// Copyright (c) 2020 Agora.io. All rights reserved
|
||||||
|
|
||||||
|
// This program is confidential and proprietary to Agora.io.
|
||||||
|
// And may not be copied, reproduced, modified, disclosed to others, published
|
||||||
|
// or used, in whole or in part, without the express prior written permission
|
||||||
|
// of Agora.io.
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
// clang-format off
|
||||||
|
// clang formating would change include order.
|
||||||
|
|
||||||
|
// Include WinSock2.h before including <Windows.h> to maintain consistency with
|
||||||
|
// win32.h. To include win32.h directly, it must be broken out into its own
|
||||||
|
// build target.
|
||||||
|
#include <WinSock2.h>
|
||||||
|
#include <Windows.h>
|
||||||
|
// clang-format on
|
||||||
|
#endif // _WIN32
|
||||||
|
|
||||||
|
namespace agora {
|
||||||
|
|
||||||
|
class AtomicOps {
|
||||||
|
public:
|
||||||
|
#if defined(_WIN32)
|
||||||
|
// Assumes sizeof(int) == sizeof(LONG), which it is on Win32 and Win64.
|
||||||
|
static int Increment(volatile int* i) {
|
||||||
|
return ::InterlockedIncrement(reinterpret_cast<volatile LONG*>(i));
|
||||||
|
}
|
||||||
|
static int Decrement(volatile int* i) {
|
||||||
|
return ::InterlockedDecrement(reinterpret_cast<volatile LONG*>(i));
|
||||||
|
}
|
||||||
|
static int AcquireLoad(volatile const int* i) { return *i; }
|
||||||
|
static void ReleaseStore(volatile int* i, int value) { *i = value; }
|
||||||
|
static int CompareAndSwap(volatile int* i, int old_value, int new_value) {
|
||||||
|
return ::InterlockedCompareExchange(reinterpret_cast<volatile LONG*>(i),
|
||||||
|
new_value, old_value);
|
||||||
|
}
|
||||||
|
// Pointer variants.
|
||||||
|
template <typename T>
|
||||||
|
static T* AcquireLoadPtr(T* volatile* ptr) {
|
||||||
|
return *ptr;
|
||||||
|
}
|
||||||
|
template <typename T>
|
||||||
|
static T* CompareAndSwapPtr(T* volatile* ptr, T* old_value, T* new_value) {
|
||||||
|
return static_cast<T*>(::InterlockedCompareExchangePointer(
|
||||||
|
reinterpret_cast<PVOID volatile*>(ptr), new_value, old_value));
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
static int Increment(volatile int* i) { return __sync_add_and_fetch(i, 1); }
|
||||||
|
static int Decrement(volatile int* i) { return __sync_sub_and_fetch(i, 1); }
|
||||||
|
static int AcquireLoad(volatile const int* i) {
|
||||||
|
return __atomic_load_n(i, __ATOMIC_ACQUIRE);
|
||||||
|
}
|
||||||
|
static void ReleaseStore(volatile int* i, int value) {
|
||||||
|
__atomic_store_n(i, value, __ATOMIC_RELEASE);
|
||||||
|
}
|
||||||
|
static int CompareAndSwap(volatile int* i, int old_value, int new_value) {
|
||||||
|
return __sync_val_compare_and_swap(i, old_value, new_value);
|
||||||
|
}
|
||||||
|
// Pointer variants.
|
||||||
|
template <typename T>
|
||||||
|
static T* AcquireLoadPtr(T* volatile* ptr) {
|
||||||
|
return __atomic_load_n(ptr, __ATOMIC_ACQUIRE);
|
||||||
|
}
|
||||||
|
template <typename T>
|
||||||
|
static T* CompareAndSwapPtr(T* volatile* ptr, T* old_value, T* new_value) {
|
||||||
|
return __sync_val_compare_and_swap(ptr, old_value, new_value);
|
||||||
|
}
|
||||||
|
#endif // _WIN32
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace agora
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,420 @@
|
||||||
|
//
|
||||||
|
// AgoraRtcEngineKit.h
|
||||||
|
// AgoraRtcEngineKit
|
||||||
|
//
|
||||||
|
// Created by Sting Feng on 2015-8-11.
|
||||||
|
// Copyright (c) 2015 Agora. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
@class AgoraRtcEngineKit;
|
||||||
|
#import "AgoraObjects.h"
|
||||||
|
|
||||||
|
@protocol AgoraBaseDelegate <NSObject>
|
||||||
|
@optional
|
||||||
|
#pragma mark SDK common delegates
|
||||||
|
|
||||||
|
#pragma mark String UID
|
||||||
|
|
||||||
|
/** Occurs when the local user successfully registers a user account by calling the
|
||||||
|
* This callback reports the user ID and user account of the local user.
|
||||||
|
* @param uid The ID of the local user.
|
||||||
|
* @param userAccount The user account of the local user.
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine didLocalUserRegisteredWithUserId:(NSUInteger)uid userAccount:(NSString * _Nonnull)userAccount NS_SWIFT_NAME(rtcEngine(_:didLocalUserRegisteredWithUserId:userAccount:));
|
||||||
|
|
||||||
|
/** Occurs when the SDK gets the user ID and user account of the remote user.
|
||||||
|
|
||||||
|
* After a remote user joins the channel, the SDK gets the UID and user account of the remote user,
|
||||||
|
* caches them in a mapping table object (`userInfo`), and triggers this callback on the local client.
|
||||||
|
|
||||||
|
* @param uid The ID of the remote user.
|
||||||
|
* @param userInfo The `AgoraUserInfo` object that contains the user ID and user account of the remote user.
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine didUserInfoUpdatedWithUserId:(NSUInteger)uid userInfo:(AgoraUserInfo* _Nonnull)userInfo NS_SWIFT_NAME(rtcEngine(_:didUserInfoUpdatedWithUserId:userInfo:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The warning occurred in SDK. The APP could igonre the warning, and the SDK could try to resume automically.
|
||||||
|
*
|
||||||
|
* @param engine The engine kit
|
||||||
|
* @param warningCode The warning code
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine didOccurWarning:(AgoraWarningCode)warningCode NS_SWIFT_NAME(rtcEngine(_:didOccurWarning:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The error occurred in SDK. The SDK couldn't resume to normal state, and the app need to handle it.
|
||||||
|
*
|
||||||
|
* @param engine The engine kit
|
||||||
|
* @param errorCode The error code
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine didOccurError:(AgoraErrorCode)errorCode NS_SWIFT_NAME(rtcEngine(_:didOccurError:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event of load media engine success
|
||||||
|
*
|
||||||
|
* @param engine The engine kit
|
||||||
|
*/
|
||||||
|
- (void)rtcEngineMediaEngineDidLoaded:(AgoraRtcEngineKit * _Nonnull)engine NS_SWIFT_NAME(rtcEngineMediaEngineDidLoaded(_:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event of media engine start call success
|
||||||
|
*
|
||||||
|
* @param engine The engine kit
|
||||||
|
*/
|
||||||
|
- (void)rtcEngineMediaEngineDidStartCall:(AgoraRtcEngineKit * _Nonnull)engine NS_SWIFT_NAME(rtcEngineMediaEngineDidStartCall(_:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* when token is enabled, and specified token is invalid or expired, this function will be called.
|
||||||
|
* APP should generate a new token and call renewToken() to refresh the token.
|
||||||
|
* NOTE: to be compatible with previous version, ERR_TOKEN_EXPIRED and ERR_INVALID_TOKEN are also reported via onError() callback.
|
||||||
|
* You should move renew of token logic into this callback.
|
||||||
|
* @param engine The engine kit
|
||||||
|
*/
|
||||||
|
- (void)rtcEngineRequestToken:(AgoraRtcEngineKit * _Nonnull)engine NS_SWIFT_NAME(rtcEngineRequestToken(_:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event of disconnected with server. This event is reported at the moment SDK loses connection with server.
|
||||||
|
* In the mean time SDK automatically tries to reconnect with the server until APP calls leaveChannel.
|
||||||
|
*
|
||||||
|
* @param engine The engine kit
|
||||||
|
*/
|
||||||
|
- (void)rtcEngineConnectionDidInterrupted:(AgoraRtcEngineKit * _Nonnull)engine NS_SWIFT_NAME(rtcEngineConnectionDidInterrupted(_:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event of loss connection with server. This event is reported after the connection is interrupted and exceed the retry period (10 seconds by default).
|
||||||
|
* In the mean time SDK automatically tries to reconnect with the server until APP calls leaveChannel.
|
||||||
|
*
|
||||||
|
* @param engine The engine kit
|
||||||
|
*/
|
||||||
|
- (void)rtcEngineConnectionDidLost:(AgoraRtcEngineKit * _Nonnull)engine NS_SWIFT_NAME(rtcEngineConnectionDidLost(_:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event of connection banned by server. This event is reported after the connection is banned by server.
|
||||||
|
* In the mean time SDK will not try to reconnect the server.
|
||||||
|
*/
|
||||||
|
- (void)rtcEngineConnectionDidBanned:(AgoraRtcEngineKit * _Nonnull)engine NS_SWIFT_NAME(rtcEngineConnectionDidBanned(_:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Statistics of rtc engine status. Updated every two seconds.
|
||||||
|
*
|
||||||
|
* @param engine The engine kit
|
||||||
|
* @param stats The statistics of rtc status, including duration, sent bytes and received bytes
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine reportRtcStats:(AgoraChannelStats * _Nonnull)stats NS_SWIFT_NAME(rtcEngine(_:reportRtcStats:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The network quality of lastmile test.
|
||||||
|
*
|
||||||
|
* @param engine The engine kit
|
||||||
|
* @param quality The network quality
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine lastmileQuality:(AgoraNetworkQuality)quality NS_SWIFT_NAME(rtcEngine(_:lastmileQuality:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reports the last-mile network probe result.
|
||||||
|
*
|
||||||
|
* The SDK triggers this callback within 30 seconds after the app calls the [startLastmileProbeTest]([AgoraRtcEngineKit startLastmileProbeTest:]) method.
|
||||||
|
*
|
||||||
|
* @param engine AgoraRtcEngineKit object.
|
||||||
|
* @param result The uplink and downlink last-mile network probe test result, see [AgoraLastmileProbeResult](AgoraLastmileProbeResult).
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine lastmileProbeTestResult:(AgoraLastmileProbeResult * _Nonnull)result NS_SWIFT_NAME(rtcEngine(_:lastmileProbeTest:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event of API call executed
|
||||||
|
* @deprecated This callback is deprecated. Use other specific event callbacks instead.
|
||||||
|
*
|
||||||
|
* @param engine The engine kit
|
||||||
|
* @param api The API description
|
||||||
|
* @param error The error code
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine didApiCallExecute:(NSInteger)error api:(NSString * _Nonnull)api result:(NSString * _Nonnull)result NS_SWIFT_NAME(rtcEngine(_:didApiCallExecute:api:result:)) __deprecated;
|
||||||
|
|
||||||
|
|
||||||
|
#if (!(TARGET_OS_IPHONE) && (TARGET_OS_MAC))
|
||||||
|
/**
|
||||||
|
* the notificaitoin of device added removed
|
||||||
|
*
|
||||||
|
* @param engine The engine kit
|
||||||
|
* @param deviceId the identification of device
|
||||||
|
* @param deviceType type of device: -1: audio unknown; 0: audio recording ; 1: audio playout ; 2: render; 4: capture
|
||||||
|
* @param state state of device: 0: added; 1: removed
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine device:(NSString * _Nonnull)deviceId type:(AgoraMediaDeviceType)deviceType stateChanged:(NSInteger)state NS_SWIFT_NAME(rtcEngine(_:device:type:stateChanged:));
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An error of encryption occurred during SDK runtime.
|
||||||
|
*
|
||||||
|
* @param errorType AgoraEncryptionErrorType
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine didOccurEncryptionError:(AgoraEncryptionErrorType)errorType NS_SWIFT_NAME(rtcEngine(_:didOccur:));
|
||||||
|
/**
|
||||||
|
* Reports the user log upload result
|
||||||
|
* @param requestId RequestId of the upload
|
||||||
|
* @param success Is upload success
|
||||||
|
* @param reason Reason of the upload, 0: OK, 1 Network Error, 2 Server Error.
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine uploadLogResultRequestId:(NSString * _Nonnull)requestId success:(BOOL)success reason:(AgoraUploadErrorReason)reason NS_SWIFT_NAME(rtcEngine(_:uploadLogResultRequestId:success:reason:));
|
||||||
|
|
||||||
|
#pragma mark Local user common delegates
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event of cient role change. only take effect under broadcasting mode
|
||||||
|
*
|
||||||
|
* @param engine The engine kit
|
||||||
|
* @param oldRole The previous role of the local user
|
||||||
|
* @param newRole The new role of the local user
|
||||||
|
* @param newRoleOptions The client role options of the current role of the local user
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine didClientRoleChanged:(AgoraClientRole)oldRole newRole:(AgoraClientRole)newRole newRoleOptions:(AgoraClientRoleOptions * _Nullable)newRoleOptions NS_SWIFT_NAME(rtcEngine(_:didClientRoleChanged:newRole:newRoleOptions:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event of cient role change. only take effect under broadcasting mode
|
||||||
|
*
|
||||||
|
* @param engine The engine kit
|
||||||
|
* @param reason The reason of the failure of the local user role switches
|
||||||
|
* @param currentRole The current role of the user
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine didClientRoleChangeFailed:(AgoraClientRoleChangeFailedReason)reason currentRole:(AgoraClientRole)currentRole NS_SWIFT_NAME(rtcEngine(_:didClientRoleChangeFailed:currentRole:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The statistics of the call when leave channel
|
||||||
|
*
|
||||||
|
* @param engine The engine kit
|
||||||
|
* @param stats The statistics of the call, including duration, sent bytes and received bytes
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine didLeaveChannelWithStats:(AgoraChannelStats * _Nonnull)stats NS_SWIFT_NAME(rtcEngine(_:didLeaveChannelWith:));
|
||||||
|
|
||||||
|
#pragma mark Local user audio delegates
|
||||||
|
/**
|
||||||
|
* Event of the first audio frame is sent.
|
||||||
|
*
|
||||||
|
* @param engine The engine kit
|
||||||
|
* @param elapsed The elapsed time(ms) from the beginning of the session.
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine firstLocalAudioFramePublished:(NSInteger)elapsed NS_SWIFT_NAME(rtcEngine(_:firstLocalAudioFramePublished:));
|
||||||
|
|
||||||
|
/** The statistics of the local audio stream.
|
||||||
|
|
||||||
|
Same as [localAudioStatBlock]([AgoraRtcEngineKit localAudioStatBlock:]). The SDK updates the application on the statistics of the local audio stream once every two seconds.
|
||||||
|
|
||||||
|
* @param engine The AgoraRtcEngineKit object.
|
||||||
|
* @param stats AgoraRtcLocalAudioStats
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine localAudioStats:(AgoraRtcLocalAudioStats * _Nonnull)stats NS_SWIFT_NAME(rtcEngine(_:localAudioStats:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event of local audio route changed
|
||||||
|
*
|
||||||
|
* @param engine The engine kit
|
||||||
|
* @param routing the current audio output routing
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine didAudioRouteChanged:(AgoraAudioOutputRouting)routing NS_SWIFT_NAME(rtcEngine(_:didAudioRouteChanged:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event of finish audio mixing.
|
||||||
|
*
|
||||||
|
* @param engine The engine kit
|
||||||
|
*/
|
||||||
|
- (void)rtcEngineLocalAudioMixingDidFinish:(AgoraRtcEngineKit * _Nonnull)engine NS_SWIFT_NAME(rtcEngineLocalAudioMixingDidFinish(_:));
|
||||||
|
|
||||||
|
/** Audio mixing state changed.
|
||||||
|
|
||||||
|
* @param engine The AgoraRtcEngineKit object.
|
||||||
|
* @param state AgoraAudioMixingStateType
|
||||||
|
* @param reasonCode AgoraAudioMixingReasonType
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine audioMixingStateChanged:(AgoraAudioMixingStateType)state
|
||||||
|
reasonCode:(AgoraAudioMixingReasonCode)reasonCode NS_SWIFT_NAME(rtcEngine(_:audioMixingStateChanged:reasonCode:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Reports current AudioMixing progress.
|
||||||
|
*
|
||||||
|
* The callback occurs once every one second during the playback and reports the current playback progress.
|
||||||
|
* @param position Current AudioMixing progress (millisecond).
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine audioMixingPositionChanged:(NSInteger)position NS_SWIFT_NAME(rtcEngine(_:audioMixingPositionChanged:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event of finish audio effect.
|
||||||
|
*
|
||||||
|
* @param engine The engine kit
|
||||||
|
*/
|
||||||
|
- (void)rtcEngineDidAudioEffectFinish:(AgoraRtcEngineKit * _Nonnull)engine soundId:(int)soundId NS_SWIFT_NAME(rtcEngineDidAudioEffectFinish(_:soundId:));
|
||||||
|
|
||||||
|
|
||||||
|
#pragma mark Local user video delegates
|
||||||
|
/**
|
||||||
|
* Event of camera opened
|
||||||
|
*
|
||||||
|
* @param engine The engine kit
|
||||||
|
*/
|
||||||
|
- (void)rtcEngineCameraDidReady:(AgoraRtcEngineKit * _Nonnull)engine NS_SWIFT_NAME(rtcEngineCameraDidReady(_:));
|
||||||
|
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
|
/**
|
||||||
|
* Event of camera focus position changed
|
||||||
|
*
|
||||||
|
* @param engine The engine kit
|
||||||
|
* @param rect The focus rect in local preview
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine cameraFocusDidChangedToRect:(CGRect)rect NS_SWIFT_NAME(rtcEngine(_:cameraFocusDidChangedTo:));
|
||||||
|
|
||||||
|
/** A camera exposure position changed.
|
||||||
|
|
||||||
|
@param engine AgoraRtcEngineKit object
|
||||||
|
@param rect Exposure rectangle in the local preview
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit* _Nonnull)engine cameraExposureDidChangedToRect:(CGRect)rect NS_SWIFT_NAME(rtcEngine(_:cameraExposureDidChangedTo:));
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event of camera stopped
|
||||||
|
*
|
||||||
|
* @param engine The engine kit
|
||||||
|
*/
|
||||||
|
- (void)rtcEngineVideoDidStop:(AgoraRtcEngineKit * _Nonnull)engine NS_SWIFT_NAME(rtcEngineVideoDidStop(_:));
|
||||||
|
|
||||||
|
/** Event of the first local video frame is published.
|
||||||
|
* @param engine The engine kit
|
||||||
|
* @param elapsed The elapsed time(ms) from the beginning of the session.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine firstLocalVideoFramePublishedWithElapsed:(NSInteger)elapsed
|
||||||
|
sourceType:(AgoraVideoSourceType)source NS_SWIFT_NAME(rtcEngine(_:firstLocalVideoFramePublishedWithElapsed:sourceType:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event of the first local frame starts rendering on the screen.
|
||||||
|
*
|
||||||
|
* @param engine The engine kit
|
||||||
|
* @param size The size of local video stream
|
||||||
|
* @param elapsed The elapsed time(ms) from the beginning of the session.
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine firstLocalVideoFrameWithSize:(CGSize)size elapsed:(NSInteger)elapsed sourceType:(AgoraVideoSourceType)source NS_SWIFT_NAME(rtcEngine(_:firstLocalVideoFrameWith:elapsed:sourceType:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The statistics of local video stream. Update every two seconds.
|
||||||
|
*
|
||||||
|
* @param engine The engine kit
|
||||||
|
* @param stats The statistics of local video, including sent bitrate, sent framerate
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine localVideoStats:(AgoraRtcLocalVideoStats * _Nonnull)stats
|
||||||
|
sourceType:(AgoraVideoSourceType)source NS_SWIFT_NAME(rtcEngine(_:localVideoStats:sourceType:));
|
||||||
|
|
||||||
|
#pragma mark Remote user audio delegates
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The sdk reports the volume of a speaker. The interface is disable by default, and it could be enable by API "enableAudioVolumeIndication"
|
||||||
|
*
|
||||||
|
* @param engine The engine kit
|
||||||
|
* @param speakers AgoraRtcAudioVolumeInfo array
|
||||||
|
* @param totalVolume The total volume of speakers
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine reportAudioVolumeIndicationOfSpeakers:(NSArray<AgoraRtcAudioVolumeInfo *> * _Nonnull)speakers totalVolume:(NSInteger)totalVolume NS_SWIFT_NAME(rtcEngine(_:reportAudioVolumeIndicationOfSpeakers:totalVolume:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event of remote start audio mixing.
|
||||||
|
*
|
||||||
|
* @param engine The engine kit
|
||||||
|
*/
|
||||||
|
- (void)rtcEngineRemoteAudioMixingDidStart:(AgoraRtcEngineKit * _Nonnull)engine NS_SWIFT_NAME(rtcEngineRemoteAudioMixingDidStart(_:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event of remote finish audio mixing.
|
||||||
|
*
|
||||||
|
* @param engine The engine kit
|
||||||
|
*/
|
||||||
|
- (void)rtcEngineRemoteAudioMixingDidFinish:(AgoraRtcEngineKit * _Nonnull)engine NS_SWIFT_NAME(rtcEngineRemoteAudioMixingDidFinish(_:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The statistics of remote audio stream. Update every two seconds.
|
||||||
|
*
|
||||||
|
* @param engine The engine kit
|
||||||
|
* @param stats The statistics of audio video, including user id, delay, resolution, received bitrate, received framerate, audio stream type
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine remoteAudioStats:(AgoraRtcRemoteAudioStats * _Nonnull)stats NS_SWIFT_NAME(rtcEngine(_:remoteAudioStats:));
|
||||||
|
|
||||||
|
#pragma mark Remote user video delegates
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The statistics of remote video stream. Update every two seconds.
|
||||||
|
*
|
||||||
|
* @param engine The engine kit
|
||||||
|
* @param stats The statistics of remote video, including user id, delay, resolution, received bitrate, received framerate, video stream type
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine remoteVideoStats:(AgoraRtcRemoteVideoStats * _Nonnull)stats NS_SWIFT_NAME(rtcEngine(_:remoteVideoStats:));
|
||||||
|
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine rtmpStreamingChangedToState:(NSString * _Nonnull)url
|
||||||
|
state:(AgoraRtmpStreamingState)state
|
||||||
|
errCode:(AgoraRtmpStreamingErrorCode)errCode NS_SWIFT_NAME(rtcEngine(_:rtmpStreamingChangedToState:state:errCode:));
|
||||||
|
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine rtmpStreamingEventWithUrl:(NSString* _Nonnull)url eventCode:(AgoraRtmpStreamingEvent)eventCode NS_SWIFT_NAME(rtcEngine(_:rtmpStreamingEventWithUrl:eventCode:));
|
||||||
|
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine streamPublishedWithUrl:(NSString * _Nonnull)url errorCode:(AgoraErrorCode)errorCode NS_SWIFT_NAME(rtcEngine(_:streamPublishedWithUrl:errorCode:));
|
||||||
|
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine streamUnpublishedWithUrl:(NSString * _Nonnull)url NS_SWIFT_NAME(rtcEngine(_:streamUnpublishedWithUrl:));
|
||||||
|
|
||||||
|
- (void)rtcEngineTranscodingUpdated:(AgoraRtcEngineKit * _Nonnull)engine NS_SWIFT_NAME(rtcEngineTranscodingUpdated(_:));
|
||||||
|
|
||||||
|
#pragma mark Face Detection Delegate Methods
|
||||||
|
/**-----------------------------------------------------------------------------
|
||||||
|
* @name Face Detection Delegate Methods
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** Reports the face detection result of the local user. (iOS only)
|
||||||
|
|
||||||
|
**Since:** v3.0.1.
|
||||||
|
|
||||||
|
Once you enable face detection by calling [enableFaceDetection]([AgoraRtcEngineKit enableFaceDetection:]), you can get the following information on the local user in real-time:
|
||||||
|
|
||||||
|
- The width and height of the local video.
|
||||||
|
- The position of the human face in the local video.
|
||||||
|
- The distance between the human face and the device screen. This value is based on the fitting calculation of the local video size and the position of the human face.
|
||||||
|
|
||||||
|
**Note**
|
||||||
|
|
||||||
|
- If the SDK does not detect a face, it reduces the frequency of this callback to reduce power consumption on the local device.
|
||||||
|
- The SDK stops triggering this callback when a human face is in close proximity to the screen.
|
||||||
|
|
||||||
|
@param engine AgoraRtcEngineKit object.
|
||||||
|
@param width The width (px) of the local video.
|
||||||
|
@param height The height (px) of the local video.
|
||||||
|
@param faces An AgoraFacePositionInfo array, which contains the information of the detected human face.
|
||||||
|
|
||||||
|
The number of the AgoraFacePositionInfo array depends on the number of human faces detected. If the array length is 0, it means that no human face is detected.
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit* _Nonnull)engine facePositionDidChangeWidth:(int)width previewHeight:(int)height faces:(NSArray<AgoraFacePositionInfo*>* _Nullable)faces NS_SWIFT_NAME(rtcEngine(_:facePositionDidChangeWidth:previewHeight:faces:));
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
- (int)joinChannelByToken:(NSString * _Nullable)token
|
||||||
|
channelId:(NSString * _Nonnull)channelId
|
||||||
|
info:(NSString * _Nullable)info
|
||||||
|
userId:(NSString * _Nullable)userId NS_SWIFT_NAME(joinChannel(byToken:channelId:info:userId:));
|
||||||
|
|
||||||
|
- (int)setRemoteRenderModeWithUid:(NSString * _Nonnull)userId
|
||||||
|
mode:(AgoraVideoRenderMode)mode NS_SWIFT_NAME(setRemoteRenderModeWithUid(_:mode:));
|
||||||
|
|
||||||
|
- (int)switchView:(NSString * _Nonnull)userId1
|
||||||
|
andAnother:(NSString * _Nonnull)userId2 NS_SWIFT_NAME(switchView(_:andAnother:)) __deprecated;
|
||||||
|
|
||||||
|
- (int)muteRemoteAudioStream:(NSString * _Nonnull)userId mute:(BOOL)mute NS_SWIFT_NAME(muteRemoteAudioStream(_:mute:));
|
||||||
|
|
||||||
|
- (int)setRemoteVideoStream:(NSString * _Nonnull)userId
|
||||||
|
type:(AgoraVideoStreamType)streamType NS_SWIFT_NAME(setRemoteVideoStream(_:type:));
|
||||||
|
- (int)muteRemoteVideoStream:(NSString * _Nonnull)userId
|
||||||
|
mute:(BOOL)mute NS_SWIFT_NAME(muteRemoteVideoStream(_:mute:));
|
||||||
|
|
||||||
|
- (void)setRemoteVideoRenderer:(id<AgoraVideoSinkProtocol> _Nullable)videoRenderer withUserId:(NSString * _Nonnull)userId NS_SWIFT_NAME(setRemoteVideoRenderer(_:withUserId:));
|
||||||
|
|
||||||
|
- (int)sendPublishingRequestToOwner:(NSString * _Nonnull)userId NS_SWIFT_NAME(sendPublishingRequestToOwner(_:));
|
||||||
|
- (int)answerPublishingRequestOfUid:(NSString * _Nonnull)userId accepted:(bool)accepted NS_SWIFT_NAME(answerPublishingRequestOfUid(_:accepted:));
|
||||||
|
- (int)sendUnpublishingRequestToUid:(NSString * _Nonnull)userId NS_SWIFT_NAME(sendUnpublishingRequestToUid(_:));
|
||||||
|
|
||||||
|
- (id<AgoraVideoSinkProtocol> _Nullable)remoteVideoRendererOfUserId:(NSString * _Nonnull)userId NS_SWIFT_NAME(remoteVideoRendererOfUserId(_:));
|
||||||
|
*/
|
|
@ -0,0 +1,122 @@
|
||||||
|
//
|
||||||
|
// AgoraConstants.h
|
||||||
|
// AgoraRtcEngineKit
|
||||||
|
//
|
||||||
|
// Copyright (c) 2018 Agora. All rights reserved.
|
||||||
|
//
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
#elif TARGET_OS_MAC
|
||||||
|
#import <AppKit/AppKit.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** The standard bitrate in [setVideoEncoderConfiguration]([AgoraRtcEngineKit setVideoEncoderConfiguration:]).
|
||||||
|
|
||||||
|
(Recommended) In a live broadcast, Agora recommends setting a larger bitrate to improve the video quality. When you choose AgoraVideoBitrateStandard, the bitrate value doubles in a live broadcast mode, and remains the same as in AgoraVideoProfile in a communication mode.
|
||||||
|
*/
|
||||||
|
extern NSInteger const AgoraVideoBitrateStandard;
|
||||||
|
|
||||||
|
/** The compatible bitrate in [setVideoEncoderConfiguration]([AgoraRtcEngineKit setVideoEncoderConfiguration:]).
|
||||||
|
|
||||||
|
The bitrate in both the live broadcast and communication modes remain the same as in AgoraVideoProfile.
|
||||||
|
*/
|
||||||
|
extern NSInteger const AgoraVideoBitrateCompatible;
|
||||||
|
|
||||||
|
|
||||||
|
/** The min bitrate in [setVideoEncoderConfiguration]([AgoraRtcEngineKit setVideoEncoderConfiguration:]).
|
||||||
|
|
||||||
|
The min bitrate set to default value
|
||||||
|
*/
|
||||||
|
extern NSInteger const AgoraVideoDefaultMinBitrate;
|
||||||
|
|
||||||
|
/** The min bitrate in [setVideoEncoderConfiguration]([AgoraRtcEngineKit setVideoEncoderConfiguration:]).
|
||||||
|
|
||||||
|
The min bitrate will be equal to bitrate
|
||||||
|
*/
|
||||||
|
extern NSInteger const AgoraVideoMinBitrateEqualToBitrate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set analyze duration for real time stream
|
||||||
|
* @example "setPlayerOption(AgoraRtcMediaPlayerRealTimeStreamAnalyzeDuration,1000000)"
|
||||||
|
*/
|
||||||
|
extern NSString* const AgoraRtcMediaPlayerRealTimeStreamAnalyzeDuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* make the player to enable audio or not
|
||||||
|
* @example "setPlayerOption(AgoraRtcMediaPlayerEnableAudio,0)"
|
||||||
|
*/
|
||||||
|
extern NSString* const AgoraRtcMediaPlayerEnableAudio;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* make the player to enable video or not
|
||||||
|
* @example "setPlayerOption(AgoraRtcMediaPlayerEnableVideo,0)"
|
||||||
|
*/
|
||||||
|
extern NSString* const AgoraRtcMediaPlayerEnableVideo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set the player enable to search metadata
|
||||||
|
* @example "setPlayerOption(AgoraRtcMediaPlayerEnableSearchMetadata,0)"
|
||||||
|
*/
|
||||||
|
extern NSString* const AgoraRtcMediaPlayerEnableSearchMetadata;
|
||||||
|
|
||||||
|
/** 120 x 120
|
||||||
|
*/
|
||||||
|
extern CGSize const AgoraVideoDimension120x120;
|
||||||
|
/** 160 x 120
|
||||||
|
*/
|
||||||
|
extern CGSize const AgoraVideoDimension160x120;
|
||||||
|
/** 180 x 180
|
||||||
|
*/
|
||||||
|
extern CGSize const AgoraVideoDimension180x180;
|
||||||
|
/** 240 x 180
|
||||||
|
*/
|
||||||
|
extern CGSize const AgoraVideoDimension240x180;
|
||||||
|
/** 320 x 180
|
||||||
|
*/
|
||||||
|
extern CGSize const AgoraVideoDimension320x180;
|
||||||
|
/** 240 x 240
|
||||||
|
*/
|
||||||
|
extern CGSize const AgoraVideoDimension240x240;
|
||||||
|
/** 320 x 240
|
||||||
|
*/
|
||||||
|
extern CGSize const AgoraVideoDimension320x240;
|
||||||
|
/** 424 x 240
|
||||||
|
*/
|
||||||
|
extern CGSize const AgoraVideoDimension424x240;
|
||||||
|
/** 360 x 360
|
||||||
|
*/
|
||||||
|
extern CGSize const AgoraVideoDimension360x360;
|
||||||
|
/** 480 x 360
|
||||||
|
*/
|
||||||
|
extern CGSize const AgoraVideoDimension480x360;
|
||||||
|
/** 640 x 360
|
||||||
|
*/
|
||||||
|
extern CGSize const AgoraVideoDimension640x360;
|
||||||
|
/** 480 x 480
|
||||||
|
*/
|
||||||
|
extern CGSize const AgoraVideoDimension480x480;
|
||||||
|
/** 640 x 480
|
||||||
|
*/
|
||||||
|
extern CGSize const AgoraVideoDimension640x480;
|
||||||
|
/** 840 x 480
|
||||||
|
*/
|
||||||
|
extern CGSize const AgoraVideoDimension840x480;
|
||||||
|
/** 960 x 540
|
||||||
|
*/
|
||||||
|
extern CGSize const AgoraVideoDimension960x540;
|
||||||
|
/** 960 x 720 (Depends on the hardware)
|
||||||
|
*/
|
||||||
|
extern CGSize const AgoraVideoDimension960x720;
|
||||||
|
/** 1280 x 720 (Depends on the hardware)
|
||||||
|
*/
|
||||||
|
extern CGSize const AgoraVideoDimension1280x720;
|
||||||
|
/** 1920 x 1080 (Depends on the hardware)
|
||||||
|
*/
|
||||||
|
extern CGSize const AgoraVideoDimension1920x1080;
|
||||||
|
/** 25400 x 1440 (Depends on the hardware)
|
||||||
|
*/
|
||||||
|
extern CGSize const AgoraVideoDimension2540x1440;
|
||||||
|
/** 3840 x 2160 (Depends on the hardware)
|
||||||
|
*/
|
||||||
|
extern CGSize const AgoraVideoDimension3840x2160;
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,49 @@
|
||||||
|
//
|
||||||
|
// Copyright (c) 2020 Agora.io. All rights reserved
|
||||||
|
|
||||||
|
// This program is confidential and proprietary to Agora.io.
|
||||||
|
// And may not be copied, reproduced, modified, disclosed to others, published
|
||||||
|
// or used, in whole or in part, without the express prior written permission
|
||||||
|
// of Agora.io.
|
||||||
|
|
||||||
|
#pragma once // NOLINT(build/header_guard)
|
||||||
|
|
||||||
|
#include "NGIAgoraExtensionControl.h"
|
||||||
|
AGORA_API agora::rtc::IExtensionControl* AGORA_CALL getAgoraExtensionControl();
|
||||||
|
AGORA_API void AGORA_CALL declareProviderVersion(
|
||||||
|
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);
|
||||||
|
|
||||||
|
#define DECLARE_CREATE_AND_REGISTER_PROVIDER(PROVIDER_NAME, PROVIDER_CLASS, PROVIDER_INTERFACE_USED, ...) \
|
||||||
|
static void register_##PROVIDER_NAME##_to_agora() { \
|
||||||
|
auto control = getAgoraExtensionControl(); \
|
||||||
|
agora::rtc::ExtensionVersion version = \
|
||||||
|
agora::rtc::ExtensionInterfaceVersion<PROVIDER_INTERFACE_USED>::Version(); \
|
||||||
|
declareProviderVersion(#PROVIDER_NAME, version); \
|
||||||
|
if (#PROVIDER_NAME && control) { \
|
||||||
|
control->registerProvider(#PROVIDER_NAME, \
|
||||||
|
new agora::RefCountedObject<PROVIDER_CLASS>(__VA_ARGS__)); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
|
||||||
|
#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__); \
|
||||||
|
__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__); \
|
||||||
|
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
|
|
@ -0,0 +1,111 @@
|
||||||
|
//
|
||||||
|
// Copyright (c) 2021 Agora.io. All rights reserved
|
||||||
|
|
||||||
|
// This program is confidential and proprietary to Agora.io.
|
||||||
|
// And may not be copied, reproduced, modified, disclosed to others, published
|
||||||
|
// or used, in whole or in part, without the express prior written permission
|
||||||
|
// of Agora.io.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace agora {
|
||||||
|
namespace rtc {
|
||||||
|
|
||||||
|
struct ExtensionVersion {
|
||||||
|
// Extension Framework Version : major.minor.micro
|
||||||
|
int major_v;
|
||||||
|
int minor_v;
|
||||||
|
int micro_v;
|
||||||
|
|
||||||
|
ExtensionVersion()
|
||||||
|
: major_v(0), minor_v(0), micro_v(0) {}
|
||||||
|
ExtensionVersion(int majorV, int minorV = 0, int microV = 0)
|
||||||
|
: major_v(majorV), minor_v(minorV), micro_v(microV) {}
|
||||||
|
|
||||||
|
bool operator==(const ExtensionVersion& other) const {
|
||||||
|
return major_v == other.major_v && minor_v == other.minor_v && micro_v == other.micro_v;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator>(const ExtensionVersion& other) const {
|
||||||
|
return major_v > other.major_v || (major_v == other.major_v && minor_v > other.minor_v)
|
||||||
|
|| (major_v == other.major_v && minor_v == other.minor_v && micro_v > other.micro_v);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator<(const ExtensionVersion& other) const {
|
||||||
|
return major_v < other.major_v || (major_v == other.major_v && minor_v < other.minor_v)
|
||||||
|
|| (major_v == other.major_v && minor_v == other.minor_v && micro_v < other.micro_v);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator<=(const ExtensionVersion& other) const {
|
||||||
|
return !operator>(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator>=(const ExtensionVersion& other) const {
|
||||||
|
return !operator<(other);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#define BUMP_MAJOR_VERSION(VERSION) \
|
||||||
|
ExtensionVersion(VERSION.major_v + 1, 0, 0); \
|
||||||
|
|
||||||
|
#define BUMP_MINOR_VERSION(VERSION) \
|
||||||
|
ExtensionVersion(VERSION.major_v, VERSION.minor_v + 1, 0); \
|
||||||
|
|
||||||
|
#define BUMP_MICRO_VERSION(VERSION) \
|
||||||
|
ExtensionVersion(VERSION.major_v, VERSION.minor_v, VERSION.micro_v + 1); \
|
||||||
|
|
||||||
|
class IExtensionProvider;
|
||||||
|
class IExtensionProviderV2;
|
||||||
|
class IExtensionProviderV3;
|
||||||
|
class IAudioFilter;
|
||||||
|
class IAudioFilterV2;
|
||||||
|
class IExtensionVideoFilter;
|
||||||
|
class IScreenCaptureSource;
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
struct ExtensionInterfaceVersion;
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct ExtensionInterfaceVersion<IExtensionProvider> {
|
||||||
|
static ExtensionVersion Version() {
|
||||||
|
return ExtensionVersion(1, 0, 0);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct ExtensionInterfaceVersion<IExtensionProviderV2> {
|
||||||
|
static ExtensionVersion Version() {
|
||||||
|
return BUMP_MAJOR_VERSION(ExtensionInterfaceVersion<IExtensionProvider>::Version());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct ExtensionInterfaceVersion<IAudioFilter> {
|
||||||
|
static ExtensionVersion Version() {
|
||||||
|
return ExtensionVersion(1, 0, 0);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct ExtensionInterfaceVersion<IAudioFilterV2> {
|
||||||
|
static ExtensionVersion Version() {
|
||||||
|
return BUMP_MAJOR_VERSION(ExtensionInterfaceVersion<IAudioFilter>::Version());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct ExtensionInterfaceVersion<IExtensionVideoFilter> {
|
||||||
|
static ExtensionVersion Version() {
|
||||||
|
return ExtensionVersion(1, 0, 0);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct ExtensionInterfaceVersion<IScreenCaptureSource> {
|
||||||
|
static ExtensionVersion Version() {
|
||||||
|
return ExtensionVersion(1, 0, 0);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace rtc
|
||||||
|
} // namespace agora
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,67 @@
|
||||||
|
//
|
||||||
|
// AgoraMediaFilterEventDelegate.h
|
||||||
|
// Agora SDK
|
||||||
|
//
|
||||||
|
// Created by LLF on 2020-9-21.
|
||||||
|
// Copyright (c) 2020 Agora. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
@interface AgoraExtensionContext : NSObject
|
||||||
|
/** Whether uid is valid.
|
||||||
|
*/
|
||||||
|
@property (assign, nonatomic) BOOL isValid;
|
||||||
|
/** Default 0 when "isValid is NO
|
||||||
|
* Local user is 0 and remote user great than 0 when "isValid" is YES
|
||||||
|
*/
|
||||||
|
@property (assign, nonatomic) NSUInteger uid;
|
||||||
|
@property (copy, nonatomic) NSString * _Nullable providerName;
|
||||||
|
@property (copy, nonatomic) NSString * _Nullable extensionName;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@protocol AgoraMediaFilterEventDelegate <NSObject>
|
||||||
|
@optional
|
||||||
|
/* Meida filter(audio filter or video filter) event callback
|
||||||
|
*/
|
||||||
|
- (void)onEvent:(NSString * __nullable)provider
|
||||||
|
extension:(NSString * __nullable)extension
|
||||||
|
key:(NSString * __nullable)key
|
||||||
|
value:(NSString * __nullable)value NS_SWIFT_NAME(onEvent(_:extension:key:value:)) __deprecated_msg("override needExtensionContext, use onEventWithContext instead");
|
||||||
|
|
||||||
|
- (void)onExtensionStopped:(NSString * __nullable)provider
|
||||||
|
extension:(NSString * __nullable)extension NS_SWIFT_NAME(onExtensionStopped(_:extension:))
|
||||||
|
__deprecated_msg("override needExtensionContext, use onExtensionStoppedWithContext instead");
|
||||||
|
|
||||||
|
- (void)onExtensionStarted:(NSString * __nullable)provider
|
||||||
|
extension:(NSString * __nullable)extension NS_SWIFT_NAME(onExtensionStarted(_:extension:))
|
||||||
|
__deprecated_msg("override needExtensionContext, use onExtensionStartedWithContext instead");
|
||||||
|
|
||||||
|
- (void)onExtensionError:(NSString * __nullable)provider
|
||||||
|
extension:(NSString * __nullable)extension
|
||||||
|
error:(int)error
|
||||||
|
message:(NSString * __nullable)message NS_SWIFT_NAME(onExtensionError(_:extension:error:message:))
|
||||||
|
__deprecated_msg("override needExtensionContext, use onExtensionErrorWithContext instead");
|
||||||
|
|
||||||
|
/** Whether need ExtensionContext, default NO if doesn't impl
|
||||||
|
*
|
||||||
|
* recommend override for YES
|
||||||
|
* return NO, then callback interface with onEvent、onExtensionStarted、onExtensionStopped、onExtensionError
|
||||||
|
* return YES, then callback interface conterpart with *WithContext interface
|
||||||
|
*/
|
||||||
|
- (BOOL)needExtensionContext NS_SWIFT_NAME(needExtensionContext());//
|
||||||
|
|
||||||
|
- (void)onEventWithContext:(AgoraExtensionContext * __nonnull)context
|
||||||
|
key:(NSString * __nullable)key
|
||||||
|
value:(NSString * __nullable)value NS_SWIFT_NAME(onEventWithContext(_:key:value:));
|
||||||
|
|
||||||
|
- (void)onExtensionStartedWithContext:(AgoraExtensionContext * __nonnull)context NS_SWIFT_NAME(onExtensionStartedWithContext(_:));
|
||||||
|
|
||||||
|
- (void)onExtensionStoppedWithContext:(AgoraExtensionContext * __nonnull)context NS_SWIFT_NAME(onExtensionStoppedWithContext(_:));
|
||||||
|
|
||||||
|
- (void)onExtensionErrorWithContext:(AgoraExtensionContext * __nonnull)context
|
||||||
|
error:(int)error
|
||||||
|
message:(NSString * __nullable)message NS_SWIFT_NAME(onExtensionErrorWithContext(_:error:message:));
|
||||||
|
|
||||||
|
@end
|
|
@ -0,0 +1,474 @@
|
||||||
|
//
|
||||||
|
// Agora Engine SDK
|
||||||
|
//
|
||||||
|
// Created by Sting Feng in 2020-05.
|
||||||
|
// Copyright (c) 2017 Agora.io. All rights reserved.
|
||||||
|
|
||||||
|
#pragma once // NOLINT(build/header_guard)
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "AgoraOptional.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set analyze duration for real time stream
|
||||||
|
* @example "setPlayerOption(KEY_PLAYER_REAL_TIME_STREAM_ANALYZE_DURATION,1000000)"
|
||||||
|
*/
|
||||||
|
#define KEY_PLAYER_REAL_TIME_STREAM_ANALYZE_DURATION "analyze_duration"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* make the player to enable audio or not
|
||||||
|
* @example "setPlayerOption(KEY_PLAYER_ENABLE_AUDIO,0)"
|
||||||
|
*/
|
||||||
|
#define KEY_PLAYER_ENABLE_AUDIO "enable_audio"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* make the player to enable video or not
|
||||||
|
* @example "setPlayerOption(KEY_PLAYER_ENABLE_VIDEO,0)"
|
||||||
|
*/
|
||||||
|
#define KEY_PLAYER_ENABLE_VIDEO "enable_video"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set the player enable to search metadata
|
||||||
|
* @example "setPlayerOption(KEY_PLAYER_DISABLE_SEARCH_METADATA,0)"
|
||||||
|
*/
|
||||||
|
#define KEY_PLAYER_ENABLE_SEARCH_METADATA "enable_search_metadata"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set the player sei filter type
|
||||||
|
* @example "setPlayerOption(KEY_PLAYER_SEI_FILTER_TYPE,"5")"
|
||||||
|
*/
|
||||||
|
#define KEY_PLAYER_SEI_FILTER_TYPE "set_sei_filter_type"
|
||||||
|
|
||||||
|
namespace agora {
|
||||||
|
|
||||||
|
namespace media {
|
||||||
|
|
||||||
|
namespace base {
|
||||||
|
static const uint8_t kMaxCharBufferLength = 50;
|
||||||
|
/**
|
||||||
|
* @brief The playback state.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
enum MEDIA_PLAYER_STATE {
|
||||||
|
/** Default state.
|
||||||
|
*/
|
||||||
|
PLAYER_STATE_IDLE = 0,
|
||||||
|
/** Opening the media file.
|
||||||
|
*/
|
||||||
|
PLAYER_STATE_OPENING,
|
||||||
|
/** The media file is opened successfully.
|
||||||
|
*/
|
||||||
|
PLAYER_STATE_OPEN_COMPLETED,
|
||||||
|
/** Playing the media file.
|
||||||
|
*/
|
||||||
|
PLAYER_STATE_PLAYING,
|
||||||
|
/** The playback is paused.
|
||||||
|
*/
|
||||||
|
PLAYER_STATE_PAUSED,
|
||||||
|
/** The playback is completed.
|
||||||
|
*/
|
||||||
|
PLAYER_STATE_PLAYBACK_COMPLETED,
|
||||||
|
/** All loops are completed.
|
||||||
|
*/
|
||||||
|
PLAYER_STATE_PLAYBACK_ALL_LOOPS_COMPLETED,
|
||||||
|
/** The playback is stopped.
|
||||||
|
*/
|
||||||
|
PLAYER_STATE_STOPPED,
|
||||||
|
/** Player pausing (internal)
|
||||||
|
*/
|
||||||
|
PLAYER_STATE_PAUSING_INTERNAL = 50,
|
||||||
|
/** Player stopping (internal)
|
||||||
|
*/
|
||||||
|
PLAYER_STATE_STOPPING_INTERNAL,
|
||||||
|
/** Player seeking state (internal)
|
||||||
|
*/
|
||||||
|
PLAYER_STATE_SEEKING_INTERNAL,
|
||||||
|
/** Player getting state (internal)
|
||||||
|
*/
|
||||||
|
PLAYER_STATE_GETTING_INTERNAL,
|
||||||
|
/** None state for state machine (internal)
|
||||||
|
*/
|
||||||
|
PLAYER_STATE_NONE_INTERNAL,
|
||||||
|
/** Do nothing state for state machine (internal)
|
||||||
|
*/
|
||||||
|
PLAYER_STATE_DO_NOTHING_INTERNAL,
|
||||||
|
/** Player set track state (internal)
|
||||||
|
*/
|
||||||
|
PLAYER_STATE_SET_TRACK_INTERNAL,
|
||||||
|
/** The playback fails.
|
||||||
|
*/
|
||||||
|
PLAYER_STATE_FAILED = 100,
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* @brief Player error code
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
enum MEDIA_PLAYER_ERROR {
|
||||||
|
/** No error.
|
||||||
|
*/
|
||||||
|
PLAYER_ERROR_NONE = 0,
|
||||||
|
/** The parameter is invalid.
|
||||||
|
*/
|
||||||
|
PLAYER_ERROR_INVALID_ARGUMENTS = -1,
|
||||||
|
/** Internel error.
|
||||||
|
*/
|
||||||
|
PLAYER_ERROR_INTERNAL = -2,
|
||||||
|
/** No resource.
|
||||||
|
*/
|
||||||
|
PLAYER_ERROR_NO_RESOURCE = -3,
|
||||||
|
/** Invalid media source.
|
||||||
|
*/
|
||||||
|
PLAYER_ERROR_INVALID_MEDIA_SOURCE = -4,
|
||||||
|
/** The type of the media stream is unknown.
|
||||||
|
*/
|
||||||
|
PLAYER_ERROR_UNKNOWN_STREAM_TYPE = -5,
|
||||||
|
/** The object is not initialized.
|
||||||
|
*/
|
||||||
|
PLAYER_ERROR_OBJ_NOT_INITIALIZED = -6,
|
||||||
|
/** The codec is not supported.
|
||||||
|
*/
|
||||||
|
PLAYER_ERROR_CODEC_NOT_SUPPORTED = -7,
|
||||||
|
/** Invalid renderer.
|
||||||
|
*/
|
||||||
|
PLAYER_ERROR_VIDEO_RENDER_FAILED = -8,
|
||||||
|
/** An error occurs in the internal state of the player.
|
||||||
|
*/
|
||||||
|
PLAYER_ERROR_INVALID_STATE = -9,
|
||||||
|
/** The URL of the media file cannot be found.
|
||||||
|
*/
|
||||||
|
PLAYER_ERROR_URL_NOT_FOUND = -10,
|
||||||
|
/** Invalid connection between the player and the Agora server.
|
||||||
|
*/
|
||||||
|
PLAYER_ERROR_INVALID_CONNECTION_STATE = -11,
|
||||||
|
/** The playback buffer is insufficient.
|
||||||
|
*/
|
||||||
|
PLAYER_ERROR_SRC_BUFFER_UNDERFLOW = -12,
|
||||||
|
/** The audio mixing file playback is interrupted.
|
||||||
|
*/
|
||||||
|
PLAYER_ERROR_INTERRUPTED = -13,
|
||||||
|
/** The SDK does not support this function.
|
||||||
|
*/
|
||||||
|
PLAYER_ERROR_NOT_SUPPORTED = -14,
|
||||||
|
/** The token has expired.
|
||||||
|
*/
|
||||||
|
PLAYER_ERROR_TOKEN_EXPIRED = -15,
|
||||||
|
/** The ip has expired.
|
||||||
|
*/
|
||||||
|
PLAYER_ERROR_IP_EXPIRED = -16,
|
||||||
|
/** An unknown error occurs.
|
||||||
|
*/
|
||||||
|
PLAYER_ERROR_UNKNOWN = -17,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The type of the media stream.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
enum MEDIA_STREAM_TYPE {
|
||||||
|
/** The type is unknown.
|
||||||
|
*/
|
||||||
|
STREAM_TYPE_UNKNOWN = 0,
|
||||||
|
/** The video stream.
|
||||||
|
*/
|
||||||
|
STREAM_TYPE_VIDEO = 1,
|
||||||
|
/** The audio stream.
|
||||||
|
*/
|
||||||
|
STREAM_TYPE_AUDIO = 2,
|
||||||
|
/** The subtitle stream.
|
||||||
|
*/
|
||||||
|
STREAM_TYPE_SUBTITLE = 3,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The playback event.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
enum MEDIA_PLAYER_EVENT {
|
||||||
|
/** The player begins to seek to the new playback position.
|
||||||
|
*/
|
||||||
|
PLAYER_EVENT_SEEK_BEGIN = 0,
|
||||||
|
/** The seek operation completes.
|
||||||
|
*/
|
||||||
|
PLAYER_EVENT_SEEK_COMPLETE = 1,
|
||||||
|
/** An error occurs during the seek operation.
|
||||||
|
*/
|
||||||
|
PLAYER_EVENT_SEEK_ERROR = 2,
|
||||||
|
/** The player changes the audio track for playback.
|
||||||
|
*/
|
||||||
|
PLAYER_EVENT_AUDIO_TRACK_CHANGED = 5,
|
||||||
|
/** player buffer low
|
||||||
|
*/
|
||||||
|
PLAYER_EVENT_BUFFER_LOW = 6,
|
||||||
|
/** player buffer recover
|
||||||
|
*/
|
||||||
|
PLAYER_EVENT_BUFFER_RECOVER = 7,
|
||||||
|
/** The video or audio is interrupted
|
||||||
|
*/
|
||||||
|
PLAYER_EVENT_FREEZE_START = 8,
|
||||||
|
/** Interrupt at the end of the video or audio
|
||||||
|
*/
|
||||||
|
PLAYER_EVENT_FREEZE_STOP = 9,
|
||||||
|
/** switch source begin
|
||||||
|
*/
|
||||||
|
PLAYER_EVENT_SWITCH_BEGIN = 10,
|
||||||
|
/** switch source complete
|
||||||
|
*/
|
||||||
|
PLAYER_EVENT_SWITCH_COMPLETE = 11,
|
||||||
|
/** switch source error
|
||||||
|
*/
|
||||||
|
PLAYER_EVENT_SWITCH_ERROR = 12,
|
||||||
|
/** An application can render the video to less than a second
|
||||||
|
*/
|
||||||
|
PLAYER_EVENT_FIRST_DISPLAYED = 13,
|
||||||
|
/** cache resources exceed the maximum file count
|
||||||
|
*/
|
||||||
|
PLAYER_EVENT_REACH_CACHE_FILE_MAX_COUNT = 14,
|
||||||
|
/** cache resources exceed the maximum file size
|
||||||
|
*/
|
||||||
|
PLAYER_EVENT_REACH_CACHE_FILE_MAX_SIZE = 15,
|
||||||
|
/** Triggered when a retry is required to open the media
|
||||||
|
*/
|
||||||
|
PLAYER_EVENT_TRY_OPEN_START = 16,
|
||||||
|
/** Triggered when the retry to open the media is successful
|
||||||
|
*/
|
||||||
|
PLAYER_EVENT_TRY_OPEN_SUCCEED = 17,
|
||||||
|
/** Triggered when retrying to open media fails
|
||||||
|
*/
|
||||||
|
PLAYER_EVENT_TRY_OPEN_FAILED = 18,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The play preload another source event.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
enum PLAYER_PRELOAD_EVENT {
|
||||||
|
/** preload source begin
|
||||||
|
*/
|
||||||
|
PLAYER_PRELOAD_EVENT_BEGIN = 0,
|
||||||
|
/** preload source complete
|
||||||
|
*/
|
||||||
|
PLAYER_PRELOAD_EVENT_COMPLETE = 1,
|
||||||
|
/** preload source error
|
||||||
|
*/
|
||||||
|
PLAYER_PRELOAD_EVENT_ERROR = 2,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The information of the media stream object.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
struct PlayerStreamInfo {
|
||||||
|
/** The index of the media stream. */
|
||||||
|
int streamIndex;
|
||||||
|
|
||||||
|
/** The type of the media stream. See {@link MEDIA_STREAM_TYPE}. */
|
||||||
|
MEDIA_STREAM_TYPE streamType;
|
||||||
|
|
||||||
|
/** The codec of the media stream. */
|
||||||
|
char codecName[kMaxCharBufferLength];
|
||||||
|
|
||||||
|
/** The language of the media stream. */
|
||||||
|
char language[kMaxCharBufferLength];
|
||||||
|
|
||||||
|
/** The frame rate (fps) if the stream is video. */
|
||||||
|
int videoFrameRate;
|
||||||
|
|
||||||
|
/** The video bitrate (bps) if the stream is video. */
|
||||||
|
int videoBitRate;
|
||||||
|
|
||||||
|
/** The video width (pixel) if the stream is video. */
|
||||||
|
int videoWidth;
|
||||||
|
|
||||||
|
/** The video height (pixel) if the stream is video. */
|
||||||
|
int videoHeight;
|
||||||
|
|
||||||
|
/** The rotation angle if the steam is video. */
|
||||||
|
int videoRotation;
|
||||||
|
|
||||||
|
/** The sample rate if the stream is audio. */
|
||||||
|
int audioSampleRate;
|
||||||
|
|
||||||
|
/** The number of audio channels if the stream is audio. */
|
||||||
|
int audioChannels;
|
||||||
|
|
||||||
|
/** The number of bits per sample if the stream is audio. */
|
||||||
|
int audioBitsPerSample;
|
||||||
|
|
||||||
|
/** The total duration (millisecond) of the media stream. */
|
||||||
|
int64_t duration;
|
||||||
|
|
||||||
|
PlayerStreamInfo() : streamIndex(0),
|
||||||
|
streamType(STREAM_TYPE_UNKNOWN),
|
||||||
|
videoFrameRate(0),
|
||||||
|
videoBitRate(0),
|
||||||
|
videoWidth(0),
|
||||||
|
videoHeight(0),
|
||||||
|
videoRotation(0),
|
||||||
|
audioSampleRate(0),
|
||||||
|
audioChannels(0),
|
||||||
|
audioBitsPerSample(0),
|
||||||
|
duration(0) {
|
||||||
|
memset(codecName, 0, sizeof(codecName));
|
||||||
|
memset(language, 0, sizeof(language));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The information of the media stream object.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
struct SrcInfo {
|
||||||
|
/** The bitrate of the media stream. The unit of the number is kbps.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
int bitrateInKbps;
|
||||||
|
|
||||||
|
/** The name of the media stream.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
const char* name;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The type of the media metadata.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
enum MEDIA_PLAYER_METADATA_TYPE {
|
||||||
|
/** The type is unknown.
|
||||||
|
*/
|
||||||
|
PLAYER_METADATA_TYPE_UNKNOWN = 0,
|
||||||
|
/** The type is SEI.
|
||||||
|
*/
|
||||||
|
PLAYER_METADATA_TYPE_SEI = 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct CacheStatistics {
|
||||||
|
/** total data size of uri
|
||||||
|
*/
|
||||||
|
int64_t fileSize;
|
||||||
|
/** data of uri has cached
|
||||||
|
*/
|
||||||
|
int64_t cacheSize;
|
||||||
|
/** data of uri has downloaded
|
||||||
|
*/
|
||||||
|
int64_t downloadSize;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct PlayerUpdatedInfo {
|
||||||
|
/** playerId has value when user trigger interface of opening
|
||||||
|
*/
|
||||||
|
Optional<const char*> playerId;
|
||||||
|
|
||||||
|
/** deviceId has value when user trigger interface of opening
|
||||||
|
*/
|
||||||
|
Optional<const char*> deviceId;
|
||||||
|
|
||||||
|
/** cacheStatistics exist if you enable cache, triggered 1s at a time after openning url
|
||||||
|
*/
|
||||||
|
Optional<CacheStatistics> cacheStatistics;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The custom data source provides a data stream input callback, and the player will continue to call back this interface, requesting the user to fill in the data that needs to be played.
|
||||||
|
*/
|
||||||
|
class IMediaPlayerCustomDataProvider {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The player requests to read the data callback, you need to fill the specified length of data into the buffer
|
||||||
|
* @param buffer the buffer pointer that you need to fill data.
|
||||||
|
* @param bufferSize the bufferSize need to fill of the buffer pointer.
|
||||||
|
* @return you need return offset value if succeed. return 0 if failed.
|
||||||
|
*/
|
||||||
|
virtual int onReadData(unsigned char *buffer, int bufferSize) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The Player seek event callback, you need to operate the corresponding stream seek operation, You can refer to the definition of lseek() at https://man7.org/linux/man-pages/man2/lseek.2.html
|
||||||
|
* @param offset the value of seek offset.
|
||||||
|
* @param whence the postion of start seeking, the directive whence as follows:
|
||||||
|
* 0 - SEEK_SET : The file offset is set to offset bytes.
|
||||||
|
* 1 - SEEK_CUR : The file offset is set to its current location plus offset bytes.
|
||||||
|
* 2 - SEEK_END : The file offset is set to the size of the file plus offset bytes.
|
||||||
|
* 65536 - AVSEEK_SIZE : Optional. Passing this as the "whence" parameter to a seek function causes it to return the filesize without seeking anywhere.
|
||||||
|
* @return
|
||||||
|
* whence == 65536, return filesize if you need.
|
||||||
|
* whence >= 0 && whence < 3 , return offset value if succeed. return -1 if failed.
|
||||||
|
*/
|
||||||
|
virtual int64_t onSeek(int64_t offset, int whence) = 0;
|
||||||
|
|
||||||
|
virtual ~IMediaPlayerCustomDataProvider() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct MediaSource {
|
||||||
|
/**
|
||||||
|
* The URL of the media file that you want to play.
|
||||||
|
*/
|
||||||
|
const char* url;
|
||||||
|
/**
|
||||||
|
* The URI of the media file
|
||||||
|
*
|
||||||
|
* When caching is enabled, if the url cannot distinguish the cache file name,
|
||||||
|
* the uri must be able to ensure that the cache file name corresponding to the url is unique.
|
||||||
|
*/
|
||||||
|
const char* uri;
|
||||||
|
/**
|
||||||
|
* Set the starting position for playback, in ms.
|
||||||
|
*/
|
||||||
|
int64_t startPos;
|
||||||
|
/**
|
||||||
|
* Determines whether to autoplay after opening a media resource.
|
||||||
|
* - true: (Default) Autoplay after opening a media resource.
|
||||||
|
* - false: Do not autoplay after opening a media resource.
|
||||||
|
*/
|
||||||
|
bool autoPlay;
|
||||||
|
/**
|
||||||
|
* Determines whether to enable cache streaming to local files. If enable cached, the media player will
|
||||||
|
* use the url or uri as the cache index.
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* The local cache function only supports on-demand video/audio streams and does not support live streams.
|
||||||
|
* Caching video and audio files based on the HLS protocol (m3u8) to your local device is not supported.
|
||||||
|
*
|
||||||
|
* - true: Enable cache.
|
||||||
|
* - 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.
|
||||||
|
* - false: (Default) It is not a stream through the Agora Broadcast Streaming Network.
|
||||||
|
*/
|
||||||
|
Optional<bool> isAgoraSource;
|
||||||
|
/**
|
||||||
|
* Determines whether the opened media resource is a live stream. If is a live stream, it can speed up the opening of media resources.
|
||||||
|
* - true: It is a live stream.
|
||||||
|
* - false: (Default) It is not is a live stream.
|
||||||
|
*/
|
||||||
|
Optional<bool> isLiveSource;
|
||||||
|
/**
|
||||||
|
* External custom data source object
|
||||||
|
*/
|
||||||
|
IMediaPlayerCustomDataProvider* provider;
|
||||||
|
|
||||||
|
MediaSource() : url(NULL), uri(NULL), startPos(0), autoPlay(true), enableCache(false),
|
||||||
|
enableMultiAudioTrack(false), provider(NULL){
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace base
|
||||||
|
} // namespace media
|
||||||
|
} // namespace agora
|
|
@ -0,0 +1,485 @@
|
||||||
|
//
|
||||||
|
// AgoraMusicContentCenter.h
|
||||||
|
// AgoraMusicContentCenter
|
||||||
|
//
|
||||||
|
// Created by dingyusong on 2022/6/1.
|
||||||
|
// Copyright © 2022 Agora. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import "AgoraRtcEngineKit.h"
|
||||||
|
/**
|
||||||
|
* The status of preload request
|
||||||
|
*/
|
||||||
|
typedef NS_ENUM(NSUInteger, AgoraMusicContentCenterPreloadStatus) {
|
||||||
|
/**
|
||||||
|
* 0: No error occurs and preload succeeds.
|
||||||
|
*/
|
||||||
|
AgoraMusicContentCenterPreloadStatusOK = 0,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 1: A general error occurs.
|
||||||
|
*/
|
||||||
|
AgoraMusicContentCenterPreloadStatusError = 1,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 2: The media file is preloading.
|
||||||
|
*/
|
||||||
|
AgoraMusicContentCenterPreloadStatusPreloading = 2,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 3: The media file is removed.
|
||||||
|
*/
|
||||||
|
AgoraMusicContentCenterPreloadStatusRemoveCache = 3,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the status of search or get top list request
|
||||||
|
*/
|
||||||
|
typedef NS_ENUM(NSUInteger, AgoraMusicContentCenterStatusCode) {
|
||||||
|
/**
|
||||||
|
* 0: No error occurs and request succeeds.
|
||||||
|
*/
|
||||||
|
AgoraMusicContentCenterStatusCodeOK = 0,
|
||||||
|
/**
|
||||||
|
* 1: A general error occurs.
|
||||||
|
*/
|
||||||
|
AgoraMusicContentCenterStatusCodeError = 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.
|
||||||
|
*/
|
||||||
|
AgoraMusicContentCenterStatusCodeErrorGateway = 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
|
||||||
|
*/
|
||||||
|
AgoraMusicContentCenterStatusCodeErrorPermissionAndResource = 3,
|
||||||
|
/**
|
||||||
|
* 4: Internal data parse error. Please contact technical support
|
||||||
|
*/
|
||||||
|
AgoraMusicContentCenterStatusCodeErrorInternalDataParse = 4,
|
||||||
|
/**
|
||||||
|
* 5: Music loading error. Please contact technical support
|
||||||
|
*/
|
||||||
|
AgoraMusicContentCenterStatusCodeErrorMusicLoading = 5,
|
||||||
|
/**
|
||||||
|
* 6: Music decryption error. Please contact technical support
|
||||||
|
*/
|
||||||
|
AgoraMusicContentCenterStatusCodeErrorMusicDecryption = 6,
|
||||||
|
/**
|
||||||
|
* 7: Http internal error. suggest retry later.
|
||||||
|
*/
|
||||||
|
AgoraMusicContentCenterStatusCodeErrorHttpInternalError = 7,
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef NS_ENUM(NSUInteger, AgoraMusicCacheStatusType) {
|
||||||
|
/**
|
||||||
|
* 0: The media file is already cached.
|
||||||
|
*/
|
||||||
|
AgoraMusicCacheStatusTypeCached = 0,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 1: The media file is being cached.
|
||||||
|
*/
|
||||||
|
AgoraMusicCacheStatusTypeCaching = 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
__attribute__((visibility("default"))) @interface AgoraMusicCacheInfo : NSObject
|
||||||
|
/**
|
||||||
|
* The songCode of the music
|
||||||
|
*/
|
||||||
|
@property(nonatomic, assign) NSInteger songCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The cache status of the music
|
||||||
|
*/
|
||||||
|
@property(nonatomic, assign) AgoraMusicCacheStatusType statusType;
|
||||||
|
@end
|
||||||
|
|
||||||
|
__attribute__((visibility("default"))) @interface AgoraMusicChartInfo : NSObject
|
||||||
|
/**
|
||||||
|
* Name of the music chart
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy) NSString *chartName;
|
||||||
|
/**
|
||||||
|
* Id of the music chart, which is used to get music list
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign) NSInteger identify;
|
||||||
|
@end
|
||||||
|
|
||||||
|
__attribute__((visibility("default"))) @interface AgoraMvProperty : NSObject
|
||||||
|
/**
|
||||||
|
* The resolution of the mv
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy) NSString *resolution;
|
||||||
|
/**
|
||||||
|
* The bandwidth of the mv
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy) NSString *bandwidth;
|
||||||
|
@end
|
||||||
|
|
||||||
|
__attribute__((visibility("default"))) @interface AgoraClimaxSegment : NSObject
|
||||||
|
/**
|
||||||
|
* The start time of climax segment
|
||||||
|
*/
|
||||||
|
@property(nonatomic, assign) NSInteger startTimeMs;
|
||||||
|
/**
|
||||||
|
* The end time of climax segment
|
||||||
|
*/
|
||||||
|
@property(nonatomic, assign) NSInteger endTimeMs;
|
||||||
|
@end
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The music info
|
||||||
|
*/
|
||||||
|
__attribute__((visibility("default"))) @interface AgoraMusic : NSObject
|
||||||
|
/**
|
||||||
|
* The songCode of music
|
||||||
|
*/
|
||||||
|
@property(nonatomic, assign) NSInteger songCode;
|
||||||
|
/**
|
||||||
|
* The type of music
|
||||||
|
* 1, mp3 with instrumental accompaniment and original
|
||||||
|
* 2, mp3 only with instrumental accompaniment
|
||||||
|
* 3, mp3 only with original
|
||||||
|
* 4, mp4 with instrumental accompaniment and original
|
||||||
|
* 5, mv only
|
||||||
|
* 6, new type mp4 with instrumental accompaniment and original
|
||||||
|
* detail at document of music media center
|
||||||
|
*/
|
||||||
|
@property(nonatomic, assign) NSInteger type;
|
||||||
|
/**
|
||||||
|
* The pitch type of music.
|
||||||
|
* 1, xml lyric has pitch
|
||||||
|
* 2, lyric has no pitch
|
||||||
|
*/
|
||||||
|
@property(nonatomic, assign) NSInteger pitchType;
|
||||||
|
/**
|
||||||
|
* The name of music
|
||||||
|
*/
|
||||||
|
@property(nonatomic, copy) NSString* name;
|
||||||
|
/**
|
||||||
|
* The singer of music
|
||||||
|
*/
|
||||||
|
@property(nonatomic, copy) NSString* singer;
|
||||||
|
/**
|
||||||
|
* The poster url of music
|
||||||
|
*/
|
||||||
|
@property(nonatomic, copy) NSString* poster;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The release time of music
|
||||||
|
*/
|
||||||
|
@property(nonatomic, copy) NSString* releaseTime;
|
||||||
|
/**
|
||||||
|
* The duration (in seconds) of music
|
||||||
|
*/
|
||||||
|
@property(nonatomic, assign) NSInteger durationS;
|
||||||
|
/**
|
||||||
|
* The lyric list of music
|
||||||
|
* 0, xml
|
||||||
|
* 1, lrc
|
||||||
|
*/
|
||||||
|
@property(nonatomic, strong) NSArray<NSNumber *>* lyricList;
|
||||||
|
/**
|
||||||
|
* The mv property list of music
|
||||||
|
*/
|
||||||
|
@property(nonatomic, strong) NSArray<AgoraMvProperty *>* mvPropertyList;
|
||||||
|
/**
|
||||||
|
* The climax segment list of music
|
||||||
|
*/
|
||||||
|
@property(nonatomic, strong) NSArray<AgoraClimaxSegment *>* climaxSegmentList;
|
||||||
|
@end
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The music collection info
|
||||||
|
*/
|
||||||
|
__attribute__((visibility("default"))) @interface AgoraMusicCollection : NSObject
|
||||||
|
/**
|
||||||
|
* This page contains how many AgoraMusic object
|
||||||
|
*/
|
||||||
|
@property(nonatomic, assign) NSInteger count;
|
||||||
|
/**
|
||||||
|
* Total number of this search result or total number of the type music sources
|
||||||
|
*/
|
||||||
|
@property(nonatomic, assign) NSInteger total;
|
||||||
|
/**
|
||||||
|
* This current page number
|
||||||
|
*/
|
||||||
|
@property(nonatomic, assign) NSInteger page;
|
||||||
|
/**
|
||||||
|
* This request page size
|
||||||
|
*/
|
||||||
|
@property(nonatomic, assign) NSInteger pageSize;
|
||||||
|
/**
|
||||||
|
* This music list of the request result
|
||||||
|
*/
|
||||||
|
@property(nonatomic, strong) NSArray<AgoraMusic *>* musicList;
|
||||||
|
@end
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The request event delegate callback
|
||||||
|
*/
|
||||||
|
@protocol AgoraMusicContentCenterEventDelegate <NSObject>
|
||||||
|
/**
|
||||||
|
* The music chart result callback; occurs when getMusicCharts method is called.
|
||||||
|
*
|
||||||
|
* @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
|
||||||
|
*/
|
||||||
|
- (void)onMusicChartsResult:(NSString *)requestId result:(NSArray<AgoraMusicChartInfo*> *)result errorCode:(AgoraMusicContentCenterStatusCode)errorCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Music collection, occurs when getMusicCollectionByMusicChartId or searchMusic method is called.
|
||||||
|
*
|
||||||
|
* @param requestId The request id is the same with that returned by getMusicCollectionByMusicChartId or searchMusic
|
||||||
|
* @param result The result of music collection
|
||||||
|
* @param errorCode The status of the request. See MusicContentCenterStatusCode
|
||||||
|
*/
|
||||||
|
- (void)onMusicCollectionResult:(NSString *)requestId result:(AgoraMusicCollection *)result errorCode:(AgoraMusicContentCenterStatusCode)errorCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lyric url callback of getLyric, occurs when getLyric is called
|
||||||
|
*
|
||||||
|
* @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
|
||||||
|
*/
|
||||||
|
- (void)onLyricResult:(NSString*)requestId songCode:(NSInteger)songCode lyricUrl:(NSString* _Nullable)lyricUrl errorCode:(AgoraMusicContentCenterStatusCode)errorCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simple info callback of getSongSimpleInfo, occurs when getSongSimpleInfo is called
|
||||||
|
*
|
||||||
|
* @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
|
||||||
|
*/
|
||||||
|
- (void)onSongSimpleInfoResult:(NSString*)requestId songCode:(NSInteger)songCode simpleInfo:(NSString* _Nullable)simpleInfo errorCode:(AgoraMusicContentCenterStatusCode)errorCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Preload process callback, occurs when preload is called
|
||||||
|
*
|
||||||
|
* @param requestId The request id is same as that returned by preload.
|
||||||
|
* @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
|
||||||
|
*/
|
||||||
|
- (void)onPreLoadEvent:(NSString*)requestId songCode:(NSInteger)songCode percent:(NSInteger)percent lyricUrl:(NSString * _Nullable)lyricUrl status:(AgoraMusicContentCenterPreloadStatus)status errorCode:(AgoraMusicContentCenterStatusCode)errorCode;
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
@class AgoraRtcEngineKit;
|
||||||
|
__attribute__((visibility("default"))) @interface AgoraMusicContentCenterConfig : NSObject
|
||||||
|
@property(assign, nonatomic) AgoraRtcEngineKit* _Nullable rtcEngine;
|
||||||
|
/**
|
||||||
|
* The app ID of the project that has enabled the music content center
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy) NSString *appId;
|
||||||
|
/**
|
||||||
|
* music content center need token to connect with server
|
||||||
|
*/
|
||||||
|
@property (nonatomic, copy) NSString *token;
|
||||||
|
/**
|
||||||
|
* The user ID when using music content center. It can be different from that of the rtc product.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign) NSInteger mccUid;
|
||||||
|
/**
|
||||||
|
* The max number which the music content center caches cannot exceed 50.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign) NSUInteger maxCacheSize;
|
||||||
|
/**
|
||||||
|
* The mccdomain, used to control the domain name of music contenter center,usually developer do not need to set it.Only under Tech supporter's help, can set the value
|
||||||
|
*/
|
||||||
|
@property(nonatomic, copy) NSString* mccDomain;
|
||||||
|
/**
|
||||||
|
* Event handler to get callback result.
|
||||||
|
*/
|
||||||
|
@property(nonatomic, weak) id<AgoraMusicContentCenterEventDelegate> eventDelegate;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@protocol AgoraMusicPlayerProtocol <AgoraRtcMediaPlayerProtocol>
|
||||||
|
/**
|
||||||
|
* Open a media file with specified parameters.
|
||||||
|
*
|
||||||
|
* @param songCode The identifier of the media file that you want to play.
|
||||||
|
* @param startPos The playback position (ms) of the music file.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (NSInteger)openMediaWithSongCode:(NSInteger)songCode startPos:(NSInteger)startPos NS_SWIFT_NAME(openMedia(songCode:startPos:));
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
__attribute__((visibility("default"))) @interface AgoraMusicContentCenter : NSObject
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an AgoraMusicContentCenter instance.
|
||||||
|
*
|
||||||
|
* @param config Configurations for the AgoraMusicContentCenter instance. For details, see AgoraMusicContentCenterConfig.
|
||||||
|
* @return An shared instance of AgoraMusicContentCenter
|
||||||
|
*/
|
||||||
|
+ (instancetype _Nullable)sharedContentCenterWithConfig:(AgoraMusicContentCenterConfig *)config NS_SWIFT_NAME(sharedContentCenter(config:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renew token of music content center
|
||||||
|
* @param token The new token.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (NSInteger)renewToken:(NSString * _Nonnull)token;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register an event delegate, only the last delegate is working.
|
||||||
|
*
|
||||||
|
* @param eventDelegate the object who need AgoraRtcMediaPlayerDelegate method to get the player information ,
|
||||||
|
* if you want remove the delegate, just pass nil
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (NSInteger)registerEventDelegate:(id<AgoraMusicContentCenterEventDelegate> _Nullable)eventDelegate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a music player source object and return its pointer.
|
||||||
|
*
|
||||||
|
* @param delegate The object who need AgoraRtcMediaPlayerDelegate method to get the player information
|
||||||
|
* @return
|
||||||
|
* - The pointer to an object who realize the AgoraMusicPlayerProtocol, if the method call succeeds.
|
||||||
|
* - The empty pointer NULL, if the method call fails.
|
||||||
|
*/
|
||||||
|
- (id<AgoraMusicPlayerProtocol> _Nullable)createMusicPlayerWithDelegate:(id<AgoraRtcMediaPlayerDelegate> _Nullable)delegate NS_SWIFT_NAME(createMusicPlayer(delegate:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get music chart collection of music.If the method call success, get result from the AgoraMusicContentCenterEventDelegate - (void)onMusicChartsResult:(NSString *)requestId status:(AgoraMusicContentCenterStatusCode)status result:(NSArray<AgoraMusicChartInfo*> *)result; match the callback "requestId" parameter to get the request result.
|
||||||
|
*
|
||||||
|
* @return The request identification
|
||||||
|
*/
|
||||||
|
- (NSString *)getMusicCharts;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get hot music list by hotType and page info.If the method call success, get result from the AgoraMusicContentCenterEventDelegate - (void)onMusicCollectionResult:(NSString *)requestId status:(AgoraMusicContentCenterStatusCode)status result:(AgoraMusicCollection *)result; match the callback "requestId" parameter to get the request result.
|
||||||
|
*
|
||||||
|
* @param musicChartId The music chart id obtained from getMusicCharts.
|
||||||
|
* @param page The page of the music chart, starting from 1
|
||||||
|
* @param pageSize The page size, max is 50.
|
||||||
|
* @param jsonOption The ext param, default is null.
|
||||||
|
* @return The request identification
|
||||||
|
*/
|
||||||
|
- (NSString *)getMusicCollectionWithMusicChartId:(NSInteger)musicChartId page:(NSInteger)page pageSize:(NSInteger)pageSize jsonOption:(NSString * _Nullable)jsonOption NS_SWIFT_NAME(getMusicCollection(musicChartId:page:pageSize:jsonOption:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search music by keyword and page info. get result from the AgoraMusicContentCenterEventDelegate - (void)onMusicCollectionResult:(NSString *)requestId status:(AgoraMusicContentCenterStatusCode)status result:(AgoraMusicCollection *)result; match the callback "requestId" parameter to get the request result.
|
||||||
|
*
|
||||||
|
* @param keyWord The key word to search.
|
||||||
|
* @param page The page of the music search result, starting from 1
|
||||||
|
* @param pageSize The page size, max is 50.
|
||||||
|
* @param jsonOption The ext param, default is null.
|
||||||
|
* @return The request identification
|
||||||
|
*/
|
||||||
|
- (NSString *)searchMusicWithKeyWord:(NSString *)keyWord page:(NSInteger)page pageSize:(NSInteger)pageSize jsonOption:(NSString * _Nullable)jsonOption NS_SWIFT_NAME(searchMusic(keyWord:page:pageSize:jsonOption:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Preload a media file with specified parameters.
|
||||||
|
*
|
||||||
|
* @deprecated This method is deprecated. Use preload(songCode:) instead.
|
||||||
|
* @param songCode The identify of the media file that you want to play.
|
||||||
|
* @param jsonOption The ext param, default is null.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (NSInteger)preloadWithSongCode:(NSInteger)songCode jsonOption:(NSString* _Nullable)jsonOption NS_SWIFT_NAME(preload(songCode:jsonOption:)) __attribute__((deprecated("Use preload(songCode:) instead.")));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Preload a media file with specified parameters.
|
||||||
|
*
|
||||||
|
* @param songCode The identify of the media file that you want to play.
|
||||||
|
* @return The request identification
|
||||||
|
*/
|
||||||
|
- (NSString *)preloadWithSongCode:(NSInteger)songCode NS_SWIFT_NAME(preload(songCode:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Preload a media file with specified parameters.
|
||||||
|
*
|
||||||
|
* @param songCode The identify of the media file that you want to play.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (NSInteger)isPreloadedWithSongCode:(NSInteger)songCode NS_SWIFT_NAME(isPreloaded(songCode:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a media file cache
|
||||||
|
*
|
||||||
|
* @param songCode The identifier of the media file that you want to play.
|
||||||
|
* @return
|
||||||
|
* - 0: Success; the cached media file is removed.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (NSInteger)removeCacheWithSongCode:(NSInteger)songCode NS_SWIFT_NAME(removeCache(songCode:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get media cache files.
|
||||||
|
*
|
||||||
|
* @return The caches Array contains songCode and status of the music.
|
||||||
|
*/
|
||||||
|
- (NSArray *)getCaches NS_SWIFT_NAME(getCaches());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get internal songCodeKey from songCode and jsonOption
|
||||||
|
*
|
||||||
|
* @param songCode The identifier of the media file.
|
||||||
|
* @param jsonOption An extention parameter. The default value is null. it’s a json-format string and the `key` and `value` can be customized according to your scenarios.
|
||||||
|
* @return
|
||||||
|
* - Internal songCode key, if the method call succeeds.
|
||||||
|
* - The number less than zero, if the method call fails.
|
||||||
|
*/
|
||||||
|
- (NSInteger)getInternalSongCode:(NSInteger)songCode jsonOption:(NSString * _Nullable)jsonOption NS_SWIFT_NAME(getInternalSongCode(songCode:jsonOption:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get lyric of the song. get result from the AgoraMusicContentCenterEventDelegate - (void)onLyricResult:(NSString*)requestId lyricUrl:(NSString*)lyricUrl; match the callback "requestId" parameter to get the request result.
|
||||||
|
*
|
||||||
|
* @param songCode The identify of the media file that you want to play.
|
||||||
|
* @param lyricType The type of the lyric file. may be 0:xml or 1:lrc.
|
||||||
|
* @return The request identification
|
||||||
|
*/
|
||||||
|
- (NSString *)getLyricWithSongCode:(NSInteger)songCode lyricType:(NSInteger)lyricType NS_SWIFT_NAME(getLyric(songCode:lyricType:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the metadata of a specific music. Once this method is called, the SDK triggers the onSongSimpleInfoResult callback to report the metadata of the music.
|
||||||
|
*
|
||||||
|
* @param songCode The identify of the media file that you want to play.
|
||||||
|
* @return The request identification
|
||||||
|
*/
|
||||||
|
- (NSString *)getSongSimpleInfoWithSongCode:(NSInteger)songCode NS_SWIFT_NAME(getSongSimpleInfo(songCode:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If you want AgoraMusicContentCenterEventDelegate methods callback in the mainThread ,you should set enable YES. Default the delegate callback in subthread.
|
||||||
|
* - `NO`: (Default)Send the delegate callback in subthread.
|
||||||
|
* - `YES`: Send the delegate callback in mainthread.
|
||||||
|
*/
|
||||||
|
- (void)enableMainQueueDispatch:(BOOL)enabled;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destroy the shared instance of AgoraMusicContentCenter
|
||||||
|
*
|
||||||
|
* @note If you call the method, you should call it brefore AgoraRtcEngineKit destroy
|
||||||
|
*/
|
||||||
|
+ (void)destroy;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,891 @@
|
||||||
|
// Copyright (c) 2019 Agora.io. All rights reserved
|
||||||
|
|
||||||
|
// This program is confidential and proprietary to Agora.io.
|
||||||
|
// And may not be copied, reproduced, modified, disclosed to others, published
|
||||||
|
// or used, in whole or in part, without the express prior written permission
|
||||||
|
// of Agora.io.
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
|
||||||
|
#include <type_traits>
|
||||||
|
#endif
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
#ifndef CONSTEXPR
|
||||||
|
#if __cplusplus >= 201103L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201103L)
|
||||||
|
#define CONSTEXPR constexpr
|
||||||
|
#else
|
||||||
|
#define CONSTEXPR
|
||||||
|
#endif
|
||||||
|
#endif // !CONSTEXPR
|
||||||
|
|
||||||
|
#ifndef NOEXCEPT
|
||||||
|
#if __cplusplus >= 201103L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201103L)
|
||||||
|
#define NOEXCEPT(Expr) noexcept(Expr)
|
||||||
|
#else
|
||||||
|
#define NOEXCEPT(Expr)
|
||||||
|
#endif
|
||||||
|
#endif // !NOEXCEPT
|
||||||
|
|
||||||
|
namespace agora {
|
||||||
|
|
||||||
|
// Specification:
|
||||||
|
// http://en.cppreference.com/w/cpp/utility/optional/in_place_t
|
||||||
|
struct in_place_t {};
|
||||||
|
|
||||||
|
// Specification:
|
||||||
|
// http://en.cppreference.com/w/cpp/utility/optional/nullopt_t
|
||||||
|
struct nullopt_t {
|
||||||
|
CONSTEXPR explicit nullopt_t(int) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Specification:
|
||||||
|
// http://en.cppreference.com/w/cpp/utility/optional/in_place
|
||||||
|
/*CONSTEXPR*/ const in_place_t in_place = {};
|
||||||
|
|
||||||
|
// Specification:
|
||||||
|
// http://en.cppreference.com/w/cpp/utility/optional/nullopt
|
||||||
|
/*CONSTEXPR*/ const nullopt_t nullopt(0);
|
||||||
|
|
||||||
|
// Forward declaration, which is refered by following helpers.
|
||||||
|
template <typename T>
|
||||||
|
class Optional;
|
||||||
|
|
||||||
|
namespace internal {
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct OptionalStorageBase {
|
||||||
|
// Initializing |empty_| here instead of using default member initializing
|
||||||
|
// to avoid errors in g++ 4.8.
|
||||||
|
CONSTEXPR OptionalStorageBase() : is_populated_(false), empty_('\0') {}
|
||||||
|
|
||||||
|
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
|
||||||
|
template <class... Args>
|
||||||
|
CONSTEXPR explicit OptionalStorageBase(in_place_t, Args&&... args)
|
||||||
|
: is_populated_(true), value_(std::forward<Args>(args)...) {}
|
||||||
|
#else
|
||||||
|
CONSTEXPR explicit OptionalStorageBase(in_place_t, const T& _value)
|
||||||
|
: is_populated_(true), value_(_value) {}
|
||||||
|
#endif
|
||||||
|
// When T is not trivially destructible we must call its
|
||||||
|
// destructor before deallocating its memory.
|
||||||
|
// Note that this hides the (implicitly declared) move constructor, which
|
||||||
|
// would be used for constexpr move constructor in OptionalStorage<T>.
|
||||||
|
// It is needed iff T is trivially move constructible. However, the current
|
||||||
|
// is_trivially_{copy,move}_constructible implementation requires
|
||||||
|
// is_trivially_destructible (which looks a bug, cf:
|
||||||
|
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51452 and
|
||||||
|
// http://cplusplus.github.io/LWG/lwg-active.html#2116), so it is not
|
||||||
|
// necessary for this case at the moment. Please see also the destructor
|
||||||
|
// comment in "is_trivially_destructible = true" specialization below.
|
||||||
|
~OptionalStorageBase() {
|
||||||
|
if (is_populated_)
|
||||||
|
value_.~T();
|
||||||
|
}
|
||||||
|
|
||||||
|
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
|
||||||
|
template <class... Args>
|
||||||
|
void Init(Args&&... args) {
|
||||||
|
::new (&value_) T(std::forward<Args>(args)...);
|
||||||
|
is_populated_ = true;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
void Init(const T& _value) {
|
||||||
|
::new (&value_) T(_value);
|
||||||
|
is_populated_ = true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
bool is_populated_;
|
||||||
|
|
||||||
|
union {
|
||||||
|
// |empty_| exists so that the union will always be initialized, even when
|
||||||
|
// it doesn't contain a value. Union members must be initialized for the
|
||||||
|
// constructor to be 'constexpr'.
|
||||||
|
char empty_;
|
||||||
|
T value_;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
// Implement conditional constexpr copy and move constructors. These are
|
||||||
|
// constexpr if is_trivially_{copy,move}_constructible<T>::value is true
|
||||||
|
// respectively. If each is true, the corresponding constructor is defined as
|
||||||
|
// "= default;", which generates a constexpr constructor (In this case,
|
||||||
|
// the condition of constexpr-ness is satisfied because the base class also has
|
||||||
|
// compiler generated constexpr {copy,move} constructors). Note that
|
||||||
|
// placement-new is prohibited in constexpr.
|
||||||
|
template <typename T>
|
||||||
|
struct OptionalStorage : OptionalStorageBase<T> {
|
||||||
|
// This is no trivially {copy,move} constructible case. Other cases are
|
||||||
|
// defined below as specializations.
|
||||||
|
|
||||||
|
// Accessing the members of template base class requires explicit
|
||||||
|
// declaration.
|
||||||
|
using OptionalStorageBase<T>::is_populated_;
|
||||||
|
using OptionalStorageBase<T>::value_;
|
||||||
|
using OptionalStorageBase<T>::Init;
|
||||||
|
|
||||||
|
// Inherit constructors (specifically, the in_place constructor).
|
||||||
|
//using OptionalStorageBase<T>::OptionalStorageBase;
|
||||||
|
|
||||||
|
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
|
||||||
|
template <class... Args>
|
||||||
|
CONSTEXPR explicit OptionalStorage(in_place_t in_place, Args&&... args)
|
||||||
|
: OptionalStorageBase<T>(in_place, std::forward<Args>(args)...) {}
|
||||||
|
#else
|
||||||
|
CONSTEXPR explicit OptionalStorage(in_place_t in_place, const T& _value)
|
||||||
|
: OptionalStorageBase<T>(in_place, _value) {}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// User defined constructor deletes the default constructor.
|
||||||
|
// Define it explicitly.
|
||||||
|
OptionalStorage() {}
|
||||||
|
|
||||||
|
OptionalStorage(const OptionalStorage& other) {
|
||||||
|
if (other.is_populated_)
|
||||||
|
Init(other.value_);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
|
||||||
|
OptionalStorage(OptionalStorage&& other) NOEXCEPT(std::is_nothrow_move_constructible<T>::value) {
|
||||||
|
if (other.is_populated_)
|
||||||
|
Init(std::move(other.value_));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
// Base class to support conditionally usable copy-/move- constructors
|
||||||
|
// and assign operators.
|
||||||
|
template <typename T>
|
||||||
|
class OptionalBase {
|
||||||
|
// This class provides implementation rather than public API, so everything
|
||||||
|
// should be hidden. Often we use composition, but we cannot in this case
|
||||||
|
// because of C++ language restriction.
|
||||||
|
protected:
|
||||||
|
CONSTEXPR OptionalBase() {}
|
||||||
|
CONSTEXPR OptionalBase(const OptionalBase& other) : storage_(other.storage_) {}
|
||||||
|
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
|
||||||
|
CONSTEXPR OptionalBase(OptionalBase&& other) : storage_(std::move(other.storage_)) {}
|
||||||
|
|
||||||
|
template <class... Args>
|
||||||
|
CONSTEXPR explicit OptionalBase(in_place_t, Args&&... args)
|
||||||
|
: storage_(in_place, std::forward<Args>(args)...) {}
|
||||||
|
#else
|
||||||
|
CONSTEXPR explicit OptionalBase(in_place_t, const T& _value)
|
||||||
|
: storage_(in_place, _value) {}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Implementation of converting constructors.
|
||||||
|
template <typename U>
|
||||||
|
explicit OptionalBase(const OptionalBase<U>& other) {
|
||||||
|
if (other.storage_.is_populated_)
|
||||||
|
storage_.Init(other.storage_.value_);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
|
||||||
|
template <typename U>
|
||||||
|
explicit OptionalBase(OptionalBase<U>&& other) {
|
||||||
|
if (other.storage_.is_populated_)
|
||||||
|
storage_.Init(std::move(other.storage_.value_));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
~OptionalBase() {}
|
||||||
|
|
||||||
|
OptionalBase& operator=(const OptionalBase& other) {
|
||||||
|
CopyAssign(other);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
|
||||||
|
OptionalBase& operator=(OptionalBase&& other) NOEXCEPT(
|
||||||
|
std::is_nothrow_move_assignable<T>::value &&
|
||||||
|
std::is_nothrow_move_constructible<T>::value) {
|
||||||
|
MoveAssign(std::move(other));
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
template <typename U>
|
||||||
|
void CopyAssign(const OptionalBase<U>& other) {
|
||||||
|
if (other.storage_.is_populated_)
|
||||||
|
InitOrAssign(other.storage_.value_);
|
||||||
|
else
|
||||||
|
FreeIfNeeded();
|
||||||
|
}
|
||||||
|
|
||||||
|
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
|
||||||
|
template <typename U>
|
||||||
|
void MoveAssign(OptionalBase<U>&& other) {
|
||||||
|
if (other.storage_.is_populated_)
|
||||||
|
InitOrAssign(std::move(other.storage_.value_));
|
||||||
|
else
|
||||||
|
FreeIfNeeded();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
template <typename U>
|
||||||
|
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
|
||||||
|
void InitOrAssign(U&& value) {
|
||||||
|
if (storage_.is_populated_)
|
||||||
|
storage_.value_ = std::forward<U>(value);
|
||||||
|
else
|
||||||
|
storage_.Init(std::forward<U>(value));
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
void InitOrAssign(const U& value) {
|
||||||
|
if (storage_.is_populated_)
|
||||||
|
storage_.value_ = value;
|
||||||
|
else
|
||||||
|
storage_.Init(value);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
void FreeIfNeeded() {
|
||||||
|
if (!storage_.is_populated_)
|
||||||
|
return;
|
||||||
|
storage_.value_.~T();
|
||||||
|
storage_.is_populated_ = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// For implementing conversion, allow access to other typed OptionalBase
|
||||||
|
// class.
|
||||||
|
template <typename U>
|
||||||
|
friend class OptionalBase;
|
||||||
|
|
||||||
|
OptionalStorage<T> storage_;
|
||||||
|
};
|
||||||
|
|
||||||
|
// The following {Copy,Move}{Constructible,Assignable} structs are helpers to
|
||||||
|
// implement constructor/assign-operator overloading. Specifically, if T is
|
||||||
|
// is not movable but copyable, Optional<T>'s move constructor should not
|
||||||
|
// participate in overload resolution. This inheritance trick implements that.
|
||||||
|
template <bool is_copy_constructible>
|
||||||
|
struct CopyConstructible {};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct CopyConstructible<false> {
|
||||||
|
CONSTEXPR CopyConstructible() {}
|
||||||
|
CopyConstructible& operator=(const CopyConstructible&) { return *this; }
|
||||||
|
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
|
||||||
|
CONSTEXPR CopyConstructible(CopyConstructible&&) {}
|
||||||
|
CopyConstructible& operator=(CopyConstructible&&) { return *this; }
|
||||||
|
#endif
|
||||||
|
private:
|
||||||
|
CONSTEXPR CopyConstructible(const CopyConstructible&);
|
||||||
|
};
|
||||||
|
|
||||||
|
template <bool is_move_constructible>
|
||||||
|
struct MoveConstructible {};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct MoveConstructible<false> {
|
||||||
|
CONSTEXPR MoveConstructible() {}
|
||||||
|
CONSTEXPR MoveConstructible(const MoveConstructible&) {}
|
||||||
|
MoveConstructible& operator=(const MoveConstructible&) { return *this; }
|
||||||
|
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
|
||||||
|
MoveConstructible& operator=(MoveConstructible&&) { return *this; }
|
||||||
|
private:
|
||||||
|
CONSTEXPR MoveConstructible(MoveConstructible&&);
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
template <bool is_copy_assignable>
|
||||||
|
struct CopyAssignable {};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct CopyAssignable<false> {
|
||||||
|
CONSTEXPR CopyAssignable() {}
|
||||||
|
CONSTEXPR CopyAssignable(const CopyAssignable&) {}
|
||||||
|
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
|
||||||
|
CONSTEXPR CopyAssignable(CopyAssignable&&) {}
|
||||||
|
CopyAssignable& operator=(CopyAssignable&&) { return *this; }
|
||||||
|
#endif
|
||||||
|
private:
|
||||||
|
CopyAssignable& operator=(const CopyAssignable&);
|
||||||
|
};
|
||||||
|
|
||||||
|
template <bool is_move_assignable>
|
||||||
|
struct MoveAssignable {};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct MoveAssignable<false> {
|
||||||
|
CONSTEXPR MoveAssignable() {}
|
||||||
|
CONSTEXPR MoveAssignable(const MoveAssignable&) {}
|
||||||
|
MoveAssignable& operator=(const MoveAssignable&) { return *this; }
|
||||||
|
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
|
||||||
|
CONSTEXPR MoveAssignable(MoveAssignable&&) {}
|
||||||
|
|
||||||
|
private:
|
||||||
|
MoveAssignable& operator=(MoveAssignable&&);
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
|
||||||
|
// Helper to conditionally enable converting constructors and assign operators.
|
||||||
|
template <typename T, typename U>
|
||||||
|
struct IsConvertibleFromOptional
|
||||||
|
: std::integral_constant<
|
||||||
|
bool,
|
||||||
|
std::is_constructible<T, Optional<U>&>::value ||
|
||||||
|
std::is_constructible<T, const Optional<U>&>::value ||
|
||||||
|
std::is_constructible<T, Optional<U>&&>::value ||
|
||||||
|
std::is_constructible<T, const Optional<U>&&>::value ||
|
||||||
|
std::is_convertible<Optional<U>&, T>::value ||
|
||||||
|
std::is_convertible<const Optional<U>&, T>::value ||
|
||||||
|
std::is_convertible<Optional<U>&&, T>::value ||
|
||||||
|
std::is_convertible<const Optional<U>&&, T>::value> {};
|
||||||
|
|
||||||
|
template <typename T, typename U>
|
||||||
|
struct IsAssignableFromOptional
|
||||||
|
: std::integral_constant<
|
||||||
|
bool,
|
||||||
|
IsConvertibleFromOptional<T, U>::value ||
|
||||||
|
std::is_assignable<T&, Optional<U>&>::value ||
|
||||||
|
std::is_assignable<T&, const Optional<U>&>::value ||
|
||||||
|
std::is_assignable<T&, Optional<U>&&>::value ||
|
||||||
|
std::is_assignable<T&, const Optional<U>&&>::value> {};
|
||||||
|
|
||||||
|
// Forward compatibility for C++17.
|
||||||
|
// Introduce one more deeper nested namespace to avoid leaking using std::swap.
|
||||||
|
namespace swappable_impl {
|
||||||
|
using std::swap;
|
||||||
|
|
||||||
|
struct IsSwappableImpl {
|
||||||
|
// Tests if swap can be called. Check<T&>(0) returns true_type iff swap
|
||||||
|
// is available for T. Otherwise, Check's overload resolution falls back
|
||||||
|
// to Check(...) declared below thanks to SFINAE, so returns false_type.
|
||||||
|
template <typename T>
|
||||||
|
static auto Check(int)
|
||||||
|
-> decltype(swap(std::declval<T>(), std::declval<T>()), std::true_type());
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
static std::false_type Check(...);
|
||||||
|
};
|
||||||
|
} // namespace swappable_impl
|
||||||
|
template <typename T>
|
||||||
|
struct IsSwappable : decltype(swappable_impl::IsSwappableImpl::Check<T&>(0)) {};
|
||||||
|
#endif
|
||||||
|
} // namespace internal
|
||||||
|
|
||||||
|
// On Windows, by default, empty-base class optimization does not work,
|
||||||
|
// which means even if the base class is empty struct, it still consumes one
|
||||||
|
// byte for its body. __declspec(empty_bases) enables the optimization.
|
||||||
|
// cf)
|
||||||
|
// https://blogs.msdn.microsoft.com/vcblog/2016/03/30/optimizing-the-layout-of-empty-base-classes-in-vs2015-update-2-3/
|
||||||
|
#if defined(_WIN32)
|
||||||
|
#define OPTIONAL_DECLSPEC_EMPTY_BASES __declspec(empty_bases)
|
||||||
|
#else
|
||||||
|
#define OPTIONAL_DECLSPEC_EMPTY_BASES
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Optional is a Chromium version of the C++17 optional class:
|
||||||
|
// std::optional documentation:
|
||||||
|
// http://en.cppreference.com/w/cpp/utility/optional
|
||||||
|
// Chromium documentation:
|
||||||
|
// https://chromium.googlesource.com/chromium/src/+/master/docs/optional.md
|
||||||
|
//
|
||||||
|
// These are the differences between the specification and the implementation:
|
||||||
|
// - Constructors do not use 'constexpr' as it is a C++14 extension.
|
||||||
|
// - 'constexpr' might be missing in some places for reasons specified locally.
|
||||||
|
// - No exceptions are thrown, because they are banned from Chromium.
|
||||||
|
// Marked noexcept for only move constructor and move assign operators.
|
||||||
|
// - All the non-members are in the 'base' namespace instead of 'std'.
|
||||||
|
//
|
||||||
|
// Note that T cannot have a constructor T(Optional<T>) etc. Optional<T> checks
|
||||||
|
// T's constructor (specifically via IsConvertibleFromOptional), and in the
|
||||||
|
// check whether T can be constructible from Optional<T>, which is recursive
|
||||||
|
// so it does not work. As of Feb 2018, std::optional C++17 implementation in
|
||||||
|
// both clang and gcc has same limitation. MSVC SFINAE looks to have different
|
||||||
|
// behavior, but anyway it reports an error, too.
|
||||||
|
template <typename T>
|
||||||
|
class OPTIONAL_DECLSPEC_EMPTY_BASES Optional
|
||||||
|
: public internal::OptionalBase<T>
|
||||||
|
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
|
||||||
|
, public internal::CopyConstructible<std::is_copy_constructible<T>::value>,
|
||||||
|
public internal::MoveConstructible<std::is_move_constructible<T>::value>,
|
||||||
|
public internal::CopyAssignable<std::is_copy_constructible<T>::value &&
|
||||||
|
std::is_copy_assignable<T>::value>,
|
||||||
|
public internal::MoveAssignable<std::is_move_constructible<T>::value &&
|
||||||
|
std::is_move_assignable<T>::value>
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
#undef OPTIONAL_DECLSPEC_EMPTY_BASES
|
||||||
|
|
||||||
|
typedef T value_type;
|
||||||
|
|
||||||
|
// Defer default/copy/move constructor implementation to OptionalBase.
|
||||||
|
CONSTEXPR Optional() {}
|
||||||
|
CONSTEXPR Optional(const Optional& other) : internal::OptionalBase<T>(other) {}
|
||||||
|
|
||||||
|
CONSTEXPR Optional(nullopt_t) {} // NOLINT(runtime/explicit)
|
||||||
|
|
||||||
|
// Converting copy constructor. "explicit" only if
|
||||||
|
// std::is_convertible<const U&, T>::value is false. It is implemented by
|
||||||
|
// declaring two almost same constructors, but that condition in enable_if_t
|
||||||
|
// is different, so that either one is chosen, thanks to SFINAE.
|
||||||
|
template <typename U>
|
||||||
|
Optional(const Optional<U>& other) : internal::OptionalBase<T>(other) {}
|
||||||
|
|
||||||
|
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
|
||||||
|
// Converting move constructor. Similar to converting copy constructor,
|
||||||
|
// declaring two (explicit and non-explicit) constructors.
|
||||||
|
template <typename U>
|
||||||
|
Optional(Optional<U>&& other) : internal::OptionalBase<T>(std::move(other)) {}
|
||||||
|
|
||||||
|
template <class... Args>
|
||||||
|
CONSTEXPR explicit Optional(in_place_t, Args&&... args)
|
||||||
|
: internal::OptionalBase<T>(in_place, std::forward<Args>(args)...) {}
|
||||||
|
|
||||||
|
template <class U, class... Args>
|
||||||
|
CONSTEXPR explicit Optional(in_place_t,
|
||||||
|
std::initializer_list<U> il,
|
||||||
|
Args&&... args)
|
||||||
|
: internal::OptionalBase<T>(in_place, il, std::forward<Args>(args)...) {}
|
||||||
|
#else
|
||||||
|
CONSTEXPR explicit Optional(in_place_t, const T& _value)
|
||||||
|
: internal::OptionalBase<T>(in_place, _value) {}
|
||||||
|
template <class U>
|
||||||
|
CONSTEXPR explicit Optional(in_place_t,
|
||||||
|
const U il[],
|
||||||
|
const T& _value)
|
||||||
|
: internal::OptionalBase<T>(in_place, il, _value) {}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Forward value constructor. Similar to converting constructors,
|
||||||
|
// conditionally explicit.
|
||||||
|
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
|
||||||
|
template <typename U = value_type>
|
||||||
|
CONSTEXPR Optional(U&& value)
|
||||||
|
: internal::OptionalBase<T>(in_place, std::forward<U>(value)) {}
|
||||||
|
#else
|
||||||
|
template <typename U>
|
||||||
|
CONSTEXPR Optional(const U& value)
|
||||||
|
: internal::OptionalBase<T>(in_place, value) {}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
~Optional() {}
|
||||||
|
|
||||||
|
// Defer copy-/move- assign operator implementation to OptionalBase.
|
||||||
|
Optional& operator=(const Optional& other) {
|
||||||
|
if (&other == this) {
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal::OptionalBase<T>::operator=(other);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Optional& operator=(nullopt_t) {
|
||||||
|
FreeIfNeeded();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Perfect-forwarded assignment.
|
||||||
|
template <typename U>
|
||||||
|
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
|
||||||
|
Optional& operator=(U&& value) {
|
||||||
|
InitOrAssign(std::forward<U>(value));
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
Optional& operator=(const U& value) {
|
||||||
|
InitOrAssign(value);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Copy assign the state of other.
|
||||||
|
template <typename U>
|
||||||
|
Optional& operator=(const Optional<U>& other) {
|
||||||
|
CopyAssign(other);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
|
||||||
|
// Move assign the state of other.
|
||||||
|
template <typename U>
|
||||||
|
Optional& operator=(Optional<U>&& other) {
|
||||||
|
MoveAssign(std::move(other));
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const T* operator->() const {
|
||||||
|
return &storage_.value_;
|
||||||
|
}
|
||||||
|
|
||||||
|
T* operator->() {
|
||||||
|
return &storage_.value_;
|
||||||
|
}
|
||||||
|
|
||||||
|
const T& operator*() const {
|
||||||
|
return storage_.value_;
|
||||||
|
}
|
||||||
|
|
||||||
|
T& operator*() {
|
||||||
|
return storage_.value_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
|
||||||
|
CONSTEXPR explicit operator bool() const { return storage_.is_populated_; }
|
||||||
|
#else
|
||||||
|
CONSTEXPR operator bool() const { return storage_.is_populated_; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
CONSTEXPR bool has_value() const { return storage_.is_populated_; }
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
const T& value() const {
|
||||||
|
return storage_.value_;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class U>
|
||||||
|
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
|
||||||
|
CONSTEXPR T value_or(U&& default_value) const {
|
||||||
|
// TODO(mlamouri): add the following assert when possible:
|
||||||
|
// static_assert(std::is_copy_constructible<T>::value,
|
||||||
|
// "T must be copy constructible");
|
||||||
|
static_assert(std::is_convertible<U, T>::value,
|
||||||
|
"U must be convertible to T");
|
||||||
|
return storage_.is_populated_
|
||||||
|
? value()
|
||||||
|
: static_cast<T>(std::forward<U>(default_value));
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
CONSTEXPR T value_or(const U& default_value) const {
|
||||||
|
return storage_.is_populated_
|
||||||
|
? value()
|
||||||
|
: static_cast<T>(default_value);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
const T& value() const & {
|
||||||
|
return storage_.value_;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
|
||||||
|
const T&& value() const && {
|
||||||
|
return std::move(storage_.value_);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
template <class U>
|
||||||
|
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
|
||||||
|
CONSTEXPR T value_or(U&& default_value) const & {
|
||||||
|
// TODO(mlamouri): add the following assert when possible:
|
||||||
|
// static_assert(std::is_copy_constructible<T>::value,
|
||||||
|
// "T must be copy constructible");
|
||||||
|
static_assert(std::is_convertible<U, T>::value,
|
||||||
|
"U must be convertible to T");
|
||||||
|
return storage_.is_populated_
|
||||||
|
? value()
|
||||||
|
: static_cast<T>(std::forward<U>(default_value));
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
CONSTEXPR T value_or(const U& default_value) const & {
|
||||||
|
// TODO(mlamouri): add the following assert when possible:
|
||||||
|
// static_assert(std::is_copy_constructible<T>::value,
|
||||||
|
// "T must be copy constructible");
|
||||||
|
static_assert(std::is_convertible<U, T>::value,
|
||||||
|
"U must be convertible to T");
|
||||||
|
return storage_.is_populated_
|
||||||
|
? value()
|
||||||
|
: static_cast<T>(default_value);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
template <class U>
|
||||||
|
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
|
||||||
|
CONSTEXPR T value_or(U&& default_value) const && {
|
||||||
|
// TODO(mlamouri): add the following assert when possible:
|
||||||
|
// static_assert(std::is_move_constructible<T>::value,
|
||||||
|
// "T must be move constructible");
|
||||||
|
static_assert(std::is_convertible<U, T>::value,
|
||||||
|
"U must be convertible to T");
|
||||||
|
return storage_.is_populated_
|
||||||
|
? std::move(value())
|
||||||
|
: static_cast<T>(std::forward<U>(default_value));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif // 1
|
||||||
|
|
||||||
|
void swap(Optional& other) {
|
||||||
|
if (!storage_.is_populated_ && !other.storage_.is_populated_)
|
||||||
|
return;
|
||||||
|
|
||||||
|
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
|
||||||
|
if (storage_.is_populated_ != other.storage_.is_populated_) {
|
||||||
|
if (storage_.is_populated_) {
|
||||||
|
other.storage_.Init(std::move(storage_.value_));
|
||||||
|
FreeIfNeeded();
|
||||||
|
} else {
|
||||||
|
storage_.Init(std::move(other.storage_.value_));
|
||||||
|
other.FreeIfNeeded();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
using std::swap;
|
||||||
|
swap(**this, *other);
|
||||||
|
}
|
||||||
|
|
||||||
|
void reset() { FreeIfNeeded(); }
|
||||||
|
|
||||||
|
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
|
||||||
|
template <class... Args>
|
||||||
|
T& emplace(Args&&... args) {
|
||||||
|
FreeIfNeeded();
|
||||||
|
storage_.Init(std::forward<Args>(args)...);
|
||||||
|
return storage_.value_;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class U, class... Args>
|
||||||
|
T& emplace(std::initializer_list<U> il, Args&&... args) {
|
||||||
|
FreeIfNeeded();
|
||||||
|
storage_.Init(il, std::forward<Args>(args)...);
|
||||||
|
return storage_.value_;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
T& emplace(const T& _value) {
|
||||||
|
FreeIfNeeded();
|
||||||
|
storage_.Init(_value);
|
||||||
|
return storage_.value_;
|
||||||
|
}
|
||||||
|
template <class U>
|
||||||
|
T& emplace(const U il[], const T& _value) {
|
||||||
|
FreeIfNeeded();
|
||||||
|
storage_.Init(il, _value);
|
||||||
|
return storage_.value_;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Accessing template base class's protected member needs explicit
|
||||||
|
// declaration to do so.
|
||||||
|
using internal::OptionalBase<T>::CopyAssign;
|
||||||
|
using internal::OptionalBase<T>::FreeIfNeeded;
|
||||||
|
using internal::OptionalBase<T>::InitOrAssign;
|
||||||
|
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
|
||||||
|
using internal::OptionalBase<T>::MoveAssign;
|
||||||
|
#endif
|
||||||
|
using internal::OptionalBase<T>::storage_;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Here after defines comparation operators. The definition follows
|
||||||
|
// http://en.cppreference.com/w/cpp/utility/optional/operator_cmp
|
||||||
|
// while bool() casting is replaced by has_value() to meet the chromium
|
||||||
|
// style guide.
|
||||||
|
template <class T, class U>
|
||||||
|
bool operator==(const Optional<T>& lhs, const Optional<U>& rhs) {
|
||||||
|
if (lhs.has_value() != rhs.has_value())
|
||||||
|
return false;
|
||||||
|
if (!lhs.has_value())
|
||||||
|
return true;
|
||||||
|
return *lhs == *rhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T, class U>
|
||||||
|
bool operator!=(const Optional<T>& lhs, const Optional<U>& rhs) {
|
||||||
|
if (lhs.has_value() != rhs.has_value())
|
||||||
|
return true;
|
||||||
|
if (!lhs.has_value())
|
||||||
|
return false;
|
||||||
|
return *lhs != *rhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T, class U>
|
||||||
|
bool operator<(const Optional<T>& lhs, const Optional<U>& rhs) {
|
||||||
|
if (!rhs.has_value())
|
||||||
|
return false;
|
||||||
|
if (!lhs.has_value())
|
||||||
|
return true;
|
||||||
|
return *lhs < *rhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T, class U>
|
||||||
|
bool operator<=(const Optional<T>& lhs, const Optional<U>& rhs) {
|
||||||
|
if (!lhs.has_value())
|
||||||
|
return true;
|
||||||
|
if (!rhs.has_value())
|
||||||
|
return false;
|
||||||
|
return *lhs <= *rhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T, class U>
|
||||||
|
bool operator>(const Optional<T>& lhs, const Optional<U>& rhs) {
|
||||||
|
if (!lhs.has_value())
|
||||||
|
return false;
|
||||||
|
if (!rhs.has_value())
|
||||||
|
return true;
|
||||||
|
return *lhs > *rhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T, class U>
|
||||||
|
bool operator>=(const Optional<T>& lhs, const Optional<U>& rhs) {
|
||||||
|
if (!rhs.has_value())
|
||||||
|
return true;
|
||||||
|
if (!lhs.has_value())
|
||||||
|
return false;
|
||||||
|
return *lhs >= *rhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
CONSTEXPR bool operator==(const Optional<T>& opt, nullopt_t) {
|
||||||
|
return !opt;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
CONSTEXPR bool operator==(nullopt_t, const Optional<T>& opt) {
|
||||||
|
return !opt;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
CONSTEXPR bool operator!=(const Optional<T>& opt, nullopt_t) {
|
||||||
|
return opt.has_value();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
CONSTEXPR bool operator!=(nullopt_t, const Optional<T>& opt) {
|
||||||
|
return opt.has_value();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
CONSTEXPR bool operator<(const Optional<T>& , nullopt_t) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
CONSTEXPR bool operator<(nullopt_t, const Optional<T>& opt) {
|
||||||
|
return opt.has_value();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
CONSTEXPR bool operator<=(const Optional<T>& opt, nullopt_t) {
|
||||||
|
return !opt;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
CONSTEXPR bool operator<=(nullopt_t, const Optional<T>& ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
CONSTEXPR bool operator>(const Optional<T>& opt, nullopt_t) {
|
||||||
|
return opt.has_value();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
CONSTEXPR bool operator>(nullopt_t, const Optional<T>& ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
CONSTEXPR bool operator>=(const Optional<T>& , nullopt_t) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
CONSTEXPR bool operator>=(nullopt_t, const Optional<T>& opt) {
|
||||||
|
return !opt;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T, class U>
|
||||||
|
CONSTEXPR bool operator==(const Optional<T>& opt, const U& value) {
|
||||||
|
return opt.has_value() ? *opt == value : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T, class U>
|
||||||
|
CONSTEXPR bool operator==(const U& value, const Optional<T>& opt) {
|
||||||
|
return opt.has_value() ? value == *opt : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T, class U>
|
||||||
|
CONSTEXPR bool operator!=(const Optional<T>& opt, const U& value) {
|
||||||
|
return opt.has_value() ? *opt != value : true;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T, class U>
|
||||||
|
CONSTEXPR bool operator!=(const U& value, const Optional<T>& opt) {
|
||||||
|
return opt.has_value() ? value != *opt : true;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T, class U>
|
||||||
|
CONSTEXPR bool operator<(const Optional<T>& opt, const U& value) {
|
||||||
|
return opt.has_value() ? *opt < value : true;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T, class U>
|
||||||
|
CONSTEXPR bool operator<(const U& value, const Optional<T>& opt) {
|
||||||
|
return opt.has_value() ? value < *opt : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T, class U>
|
||||||
|
CONSTEXPR bool operator<=(const Optional<T>& opt, const U& value) {
|
||||||
|
return opt.has_value() ? *opt <= value : true;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T, class U>
|
||||||
|
CONSTEXPR bool operator<=(const U& value, const Optional<T>& opt) {
|
||||||
|
return opt.has_value() ? value <= *opt : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T, class U>
|
||||||
|
CONSTEXPR bool operator>(const Optional<T>& opt, const U& value) {
|
||||||
|
return opt.has_value() ? *opt > value : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T, class U>
|
||||||
|
CONSTEXPR bool operator>(const U& value, const Optional<T>& opt) {
|
||||||
|
return opt.has_value() ? value > *opt : true;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T, class U>
|
||||||
|
CONSTEXPR bool operator>=(const Optional<T>& opt, const U& value) {
|
||||||
|
return opt.has_value() ? *opt >= value : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T, class U>
|
||||||
|
CONSTEXPR bool operator>=(const U& value, const Optional<T>& opt) {
|
||||||
|
return opt.has_value() ? value >= *opt : true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
|
||||||
|
template <class T, class... Args>
|
||||||
|
CONSTEXPR Optional<T> make_optional(Args&&... args) {
|
||||||
|
return Optional<T>(in_place, std::forward<Args>(args)...);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T, class U, class... Args>
|
||||||
|
CONSTEXPR Optional<T> make_optional(std::initializer_list<U> il,
|
||||||
|
Args&&... args) {
|
||||||
|
return Optional<T>(in_place, il, std::forward<Args>(args)...);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Partial specialization for a function template is not allowed. Also, it is
|
||||||
|
// not allowed to add overload function to std namespace, while it is allowed
|
||||||
|
// to specialize the template in std. Thus, swap() (kind of) overloading is
|
||||||
|
// defined in base namespace, instead.
|
||||||
|
template <class T>
|
||||||
|
void swap(Optional<T>& lhs, Optional<T>& rhs) {
|
||||||
|
lhs.swap(rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace agora
|
||||||
|
|
||||||
|
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
|
||||||
|
namespace std {
|
||||||
|
template <class T>
|
||||||
|
struct hash<agora::Optional<T> > {
|
||||||
|
size_t operator()(const agora::Optional<T>& opt) const {
|
||||||
|
return opt == agora::nullopt ? 0 : std::hash<T>()(*opt);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace std
|
||||||
|
#endif
|
||||||
|
#undef CONSTEXPR
|
||||||
|
#undef NOEXCEPT
|
|
@ -0,0 +1,129 @@
|
||||||
|
|
||||||
|
// Copyright (c) 2020 Agora.io. All rights reserved
|
||||||
|
|
||||||
|
// This program is confidential and proprietary to Agora.io.
|
||||||
|
// And may not be copied, reproduced, modified, disclosed to others, published
|
||||||
|
// or used, in whole or in part, without the express prior written permission
|
||||||
|
// of Agora.io.
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "AgoraRefPtr.h"
|
||||||
|
#include "AgoraAtomicOps.h"
|
||||||
|
|
||||||
|
#ifndef OPTIONAL_REFCOUNTRELEASESTATUS_SPECIFIER
|
||||||
|
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
|
||||||
|
#define OPTIONAL_REFCOUNTRELEASESTATUS_SPECIFIER agora::RefCountReleaseStatus::
|
||||||
|
#else
|
||||||
|
#define OPTIONAL_REFCOUNTRELEASESTATUS_SPECIFIER
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
namespace agora {
|
||||||
|
|
||||||
|
class RefCounter {
|
||||||
|
public:
|
||||||
|
explicit RefCounter(int ref_count) : ref_count_(ref_count) {}
|
||||||
|
|
||||||
|
void IncRef() { AtomicOps::Increment(&ref_count_); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if this was the last reference, and the resource protected by
|
||||||
|
* the reference counter can be deleted.
|
||||||
|
*/
|
||||||
|
agora::RefCountReleaseStatus DecRef() {
|
||||||
|
return (AtomicOps::Decrement(&ref_count_) == 0
|
||||||
|
? OPTIONAL_REFCOUNTRELEASESTATUS_SPECIFIER kDroppedLastRef
|
||||||
|
: OPTIONAL_REFCOUNTRELEASESTATUS_SPECIFIER kOtherRefsRemained);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return whether the reference count is one. If the reference count is used
|
||||||
|
* in the conventional way, a reference count of 1 implies that the current
|
||||||
|
* thread owns the reference and no other thread shares it. This call performs
|
||||||
|
* the test for a reference count of one, and performs the memory barrier
|
||||||
|
* needed for the owning thread to act on the resource protected by the
|
||||||
|
* reference counter, knowing that it has exclusive access.
|
||||||
|
*/
|
||||||
|
bool HasOneRef() const { return (AtomicOps::AcquireLoad(&ref_count_) == 1); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
RefCounter();
|
||||||
|
|
||||||
|
private:
|
||||||
|
volatile int ref_count_;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Agora sample code for wrapping a class that needs to inherit from RefCountInterface in order
|
||||||
|
* to be held by agora::agora_refptr
|
||||||
|
* Usage:
|
||||||
|
* agora::agora_refptr<TypeName> ptr = new RefCountedObject<TypeName>(Arg1, Arg2, ...);
|
||||||
|
*/
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
class RefCountedObject : public T {
|
||||||
|
public:
|
||||||
|
RefCountedObject(): ref_count_(0) {}
|
||||||
|
|
||||||
|
template <class P0>
|
||||||
|
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
|
||||||
|
explicit RefCountedObject(P0&& p0) : T(std::forward<P0>(p0)), ref_count_(0) {}
|
||||||
|
#else
|
||||||
|
explicit RefCountedObject(const P0& p0) : T(p0), ref_count_(0) {}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
|
||||||
|
template <class P0, class P1, class... Args>
|
||||||
|
RefCountedObject(P0&& p0, P1&& p1, Args&&... args)
|
||||||
|
: T(std::forward<P0>(p0),
|
||||||
|
std::forward<P1>(p1),
|
||||||
|
std::forward<Args>(args)...),
|
||||||
|
ref_count_(0) {}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
virtual void AddRef() const { ref_count_.IncRef(); }
|
||||||
|
|
||||||
|
virtual agora::RefCountReleaseStatus Release() const {
|
||||||
|
const agora::RefCountReleaseStatus status = ref_count_.DecRef();
|
||||||
|
if (status == OPTIONAL_REFCOUNTRELEASESTATUS_SPECIFIER kDroppedLastRef) {
|
||||||
|
delete this;
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return whether the reference count is one. If the reference count is used
|
||||||
|
* in the conventional way, a reference count of 1 implies that the current
|
||||||
|
* thread owns the reference and no other thread shares it. This call
|
||||||
|
* performs the test for a reference count of one, and performs the memory
|
||||||
|
* barrier needed for the owning thread to act on the object, knowing that it
|
||||||
|
* has exclusive access to the object.
|
||||||
|
*/
|
||||||
|
virtual bool HasOneRef() const { return ref_count_.HasOneRef(); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual ~RefCountedObject() {}
|
||||||
|
|
||||||
|
private:
|
||||||
|
RefCountedObject(const RefCountedObject&);
|
||||||
|
RefCountedObject& operator=(const RefCountedObject&);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
mutable agora::RefCounter ref_count_;
|
||||||
|
};
|
||||||
|
|
||||||
|
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
|
||||||
|
template <typename T, typename... types>
|
||||||
|
inline agora_refptr<T> make_refptr(types&&... args) {
|
||||||
|
return agora_refptr<T>(new RefCountedObject<T>(std::forward<types>(args)...));
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
template <typename T>
|
||||||
|
inline agora_refptr<T> make_refptr() {
|
||||||
|
return agora_refptr<T>(new RefCountedObject<T>());
|
||||||
|
}
|
||||||
|
template <typename T, typename P0>
|
||||||
|
inline agora_refptr<T> make_refptr(const P0& p0) {
|
||||||
|
return agora_refptr<T>(new RefCountedObject<T>(p0));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
} // namespace agora
|
|
@ -0,0 +1,156 @@
|
||||||
|
|
||||||
|
// Copyright (c) 2019 Agora.io. All rights reserved
|
||||||
|
|
||||||
|
// This program is confidential and proprietary to Agora.io.
|
||||||
|
// And may not be copied, reproduced, modified, disclosed to others, published
|
||||||
|
// or used, in whole or in part, without the express prior written permission
|
||||||
|
// of Agora.io.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#if !(__cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800))
|
||||||
|
#include <cstddef>
|
||||||
|
#endif
|
||||||
|
#ifndef OPTIONAL_ENUM_CLASS
|
||||||
|
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
|
||||||
|
#define OPTIONAL_ENUM_CLASS enum class
|
||||||
|
#else
|
||||||
|
#define OPTIONAL_ENUM_CLASS enum
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace agora {
|
||||||
|
|
||||||
|
OPTIONAL_ENUM_CLASS RefCountReleaseStatus { kDroppedLastRef, kOtherRefsRemained };
|
||||||
|
|
||||||
|
// Interfaces where refcounting is part of the public api should
|
||||||
|
// inherit this abstract interface. The implementation of these
|
||||||
|
// methods is usually provided by the RefCountedObject template class,
|
||||||
|
// applied as a leaf in the inheritance tree.
|
||||||
|
class RefCountInterface {
|
||||||
|
public:
|
||||||
|
virtual void AddRef() const = 0;
|
||||||
|
virtual RefCountReleaseStatus Release() const = 0;
|
||||||
|
virtual bool HasOneRef() const = 0;
|
||||||
|
|
||||||
|
// Non-public destructor, because Release() has exclusive responsibility for
|
||||||
|
// destroying the object.
|
||||||
|
protected:
|
||||||
|
virtual ~RefCountInterface() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
class agora_refptr {
|
||||||
|
public:
|
||||||
|
agora_refptr() : ptr_(NULL) {}
|
||||||
|
|
||||||
|
agora_refptr(T* p) : ptr_(p) {
|
||||||
|
if (ptr_) ptr_->AddRef();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename U>
|
||||||
|
agora_refptr(U* p) : ptr_(p) {
|
||||||
|
if (ptr_) ptr_->AddRef();
|
||||||
|
}
|
||||||
|
|
||||||
|
agora_refptr(const agora_refptr<T>& r) : ptr_(r.get()) {
|
||||||
|
if (ptr_) ptr_->AddRef();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename U>
|
||||||
|
agora_refptr(const agora_refptr<U>& r) : ptr_(r.get()) {
|
||||||
|
if (ptr_) ptr_->AddRef();
|
||||||
|
}
|
||||||
|
|
||||||
|
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
|
||||||
|
agora_refptr(agora_refptr<T>&& r) : ptr_(r.move()) {}
|
||||||
|
|
||||||
|
template <typename U>
|
||||||
|
agora_refptr(agora_refptr<U>&& r) : ptr_(r.move()) {}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
~agora_refptr() {
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
T* get() const { return ptr_; }
|
||||||
|
operator bool() const { return (ptr_ != NULL); }
|
||||||
|
|
||||||
|
T* operator->() const { return ptr_; }
|
||||||
|
T& operator*() const { return *ptr_; }
|
||||||
|
|
||||||
|
// Returns the (possibly null) raw pointer, and makes the agora_refptr hold a
|
||||||
|
// null pointer, all without touching the reference count of the underlying
|
||||||
|
// pointed-to object. The object is still reference counted, and the caller of
|
||||||
|
// move() is now the proud owner of one reference, so it is responsible for
|
||||||
|
// calling Release() once on the object when no longer using it.
|
||||||
|
T* move() {
|
||||||
|
T* retVal = ptr_;
|
||||||
|
ptr_ = NULL;
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
agora_refptr<T>& operator=(T* p) {
|
||||||
|
if (ptr_ == p) return *this;
|
||||||
|
|
||||||
|
if (p) p->AddRef();
|
||||||
|
if (ptr_) ptr_->Release();
|
||||||
|
ptr_ = p;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
agora_refptr<T>& operator=(const agora_refptr<T>& r) {
|
||||||
|
return *this = r.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
|
||||||
|
agora_refptr<T>& operator=(agora_refptr<T>&& r) {
|
||||||
|
agora_refptr<T>(std::move(r)).swap(*this);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename U>
|
||||||
|
agora_refptr<T>& operator=(agora_refptr<U>&& r) {
|
||||||
|
agora_refptr<T>(std::move(r)).swap(*this);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// For working with std::find()
|
||||||
|
bool operator==(const agora_refptr<T>& r) const { return ptr_ == r.ptr_; }
|
||||||
|
|
||||||
|
// For working with std::set
|
||||||
|
bool operator<(const agora_refptr<T>& r) const { return ptr_ < r.ptr_; }
|
||||||
|
|
||||||
|
void swap(T** pp) {
|
||||||
|
T* p = ptr_;
|
||||||
|
ptr_ = *pp;
|
||||||
|
*pp = p;
|
||||||
|
}
|
||||||
|
|
||||||
|
void swap(agora_refptr<T>& r) { swap(&r.ptr_); }
|
||||||
|
|
||||||
|
void reset() {
|
||||||
|
if (ptr_) {
|
||||||
|
ptr_->Release();
|
||||||
|
ptr_ = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
T* ptr_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace agora
|
||||||
|
|
||||||
|
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
|
||||||
|
namespace std {
|
||||||
|
template <typename T>
|
||||||
|
struct hash<agora::agora_refptr<T>> {
|
||||||
|
std::size_t operator()(const agora::agora_refptr<T>& k) const {
|
||||||
|
return reinterpret_cast<size_t>(k.get());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace std
|
||||||
|
#endif
|
|
@ -0,0 +1,48 @@
|
||||||
|
//
|
||||||
|
// AgoraRtcMediaPlayerProtocol.h
|
||||||
|
// AgoraRtcMediaPlayerProtocol
|
||||||
|
//
|
||||||
|
// Copyright (c) 2020 Agora. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import "AgoraObjects.h"
|
||||||
|
|
||||||
|
|
||||||
|
@protocol AgoraAudioSpectrumDelegate <NSObject>
|
||||||
|
|
||||||
|
@optional
|
||||||
|
/**
|
||||||
|
* Reports the audio spectrum of audio recording.
|
||||||
|
*
|
||||||
|
* This callback reports the audio spectrum data of the audio recording at the moment
|
||||||
|
* in the channel.
|
||||||
|
*
|
||||||
|
* You can set the time interval of this callback using "enableAudioSpectrumMonitor".
|
||||||
|
*
|
||||||
|
* @param audioSpectrumData The audio spectrum data of audio recording.
|
||||||
|
* - true: Processed.
|
||||||
|
* - false: Not processed.
|
||||||
|
*/
|
||||||
|
- (BOOL)onLocalAudioSpectrum:(NSArray<NSNumber *> * _Nullable)audioSpectrumData NS_SWIFT_NAME(onLocalAudioSpectrum(_:));
|
||||||
|
/**
|
||||||
|
* Reports the audio spectrum of remote user.
|
||||||
|
*
|
||||||
|
* This callback reports the IDs and audio spectrum data of the loudest speakers at the moment
|
||||||
|
* in the channel.
|
||||||
|
*
|
||||||
|
* You can set the time interval of this callback using "enableAudioSpectrumMonitor".
|
||||||
|
*
|
||||||
|
* @param AudioSpectrumInfo The pointer to AudioSpectrumInfo, which is an array containing
|
||||||
|
* the user ID and audio spectrum data for each speaker.
|
||||||
|
* - This array contains the following members:
|
||||||
|
* - `uid`, which is the UID of each remote speaker
|
||||||
|
* - `audioSpectrumData`, which reports the audio spectrum of each remote speaker.
|
||||||
|
* - `spectrumDataLength`, the length of audio spectrum data.
|
||||||
|
* - true: Processed.
|
||||||
|
* - false: Not processed.
|
||||||
|
*/
|
||||||
|
- (BOOL)onRemoteAudioSpectrum:(NSArray<AgoraAudioSpectrumInfo *> * _Nullable)AudioSpectrumInfo NS_SWIFT_NAME(onRemoteAudioSpectrum(_:));
|
||||||
|
|
||||||
|
|
||||||
|
@end
|
|
@ -0,0 +1,467 @@
|
||||||
|
//
|
||||||
|
// AgoraRtcEngineKit2.h
|
||||||
|
// AgoraRtcEngineKit
|
||||||
|
//
|
||||||
|
// Created by Sting Feng on 2015-8-11.
|
||||||
|
// Copyright (c) 2015 Agora. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "AgoraBaseDelegate.h"
|
||||||
|
#import "AgoraEnumerates.h"
|
||||||
|
|
||||||
|
@class AgoraRtcEngineKit;
|
||||||
|
|
||||||
|
@protocol AgoraRtcEngineDelegate2 <NSObject, AgoraBaseDelegate>
|
||||||
|
@optional
|
||||||
|
|
||||||
|
#pragma mark Local user common delegates
|
||||||
|
/**
|
||||||
|
* Event of the user joined the channel.
|
||||||
|
*
|
||||||
|
* @param engine The engine kit
|
||||||
|
* @param channelId The channel name
|
||||||
|
* @param userId The remote user id
|
||||||
|
* @param elapsed The elapsed time (ms) from session beginning
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine didJoinChannel:(NSString * _Nonnull)channelId withUid:(NSString * _Nonnull)userId elapsed:(NSInteger)elapsed NS_SWIFT_NAME(rtcEngine(_:didJoinChannel:withUid:elapsed:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event of the user rejoined the channel
|
||||||
|
*
|
||||||
|
* @param engine The engine kit
|
||||||
|
* @param channelId The channel name
|
||||||
|
* @param userId The user id
|
||||||
|
* @param elapsed The elapsed time (ms) from session beginning
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine didRejoinChannel:(NSString * _Nonnull)channelId withUid:(NSString * _Nonnull)userId elapsed:(NSInteger)elapsed NS_SWIFT_NAME(rtcEngine(_:didRejoinChannel:withUid:elapsed:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The network quality of local user.
|
||||||
|
*
|
||||||
|
* @param engine The engine kit
|
||||||
|
* @param userId The id of user
|
||||||
|
* @param txQuality The sending network quality
|
||||||
|
* @param rxQuality The receiving network quality
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine networkQuality:(NSString * _Nonnull)userId txQuality:(AgoraNetworkQuality)txQuality rxQuality:(AgoraNetworkQuality)rxQuality NS_SWIFT_NAME(rtcEngine(_:networkQuality:txQuality:rxQuality:));
|
||||||
|
|
||||||
|
#pragma mark Remote user common delegates
|
||||||
|
/**
|
||||||
|
* Event of remote user joined
|
||||||
|
*
|
||||||
|
* @param engine The engine kit
|
||||||
|
* @param userId The remote user id
|
||||||
|
* @param elapsed The elapsed time(ms) from the beginning of the session.
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine didJoinedOfUid:(NSString * _Nonnull)userId elapsed:(NSInteger)elapsed NS_SWIFT_NAME(rtcEngine(_:didJoinedOfUid:elapsed:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event of remote user offlined
|
||||||
|
*
|
||||||
|
* @param engine The engine kit
|
||||||
|
* @param userId The remote user id
|
||||||
|
* @param reason Reason of user offline, quit, drop or became audience
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine didOfflineOfUid:(NSString * _Nonnull)userId reason:(AgoraUserOfflineReason)reason NS_SWIFT_NAME(rtcEngine(_:didOfflineOfUid:reason:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* receive custom data from remote user
|
||||||
|
*
|
||||||
|
* @param engine The engine kit
|
||||||
|
* @param userId The remote user id
|
||||||
|
* @param streamId The stream id
|
||||||
|
* @param data The user defined data
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine receiveStreamMessageFromUid:(NSString * _Nonnull)userId streamId:(NSInteger)streamId data:(NSData * _Nonnull)data NS_SWIFT_NAME(rtcEngine(_:receiveStreamMessageFromUid:streamId:data:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the local user has not received the data stream from the other user within 5 seconds.
|
||||||
|
*
|
||||||
|
* @param engine The engine kit
|
||||||
|
* @param userId The remote user id
|
||||||
|
* @param streamId The stream id
|
||||||
|
* @param error The error code
|
||||||
|
* @param missed The number of lost messages
|
||||||
|
* @param cached The number of incoming cached messages when the data stream is interrupted
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine didOccurStreamMessageErrorFromUid:(NSString * _Nonnull)userId streamId:(NSInteger)streamId error:(NSInteger)error missed:(NSInteger)missed cached:(NSInteger)cached NS_SWIFT_NAME(rtcEngine(_:didOccurStreamMessageErrorFromUid:streamId:error:missed:cached:));
|
||||||
|
|
||||||
|
#pragma mark Local user audio delegates
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This callback indicates local audio stream state has changed.
|
||||||
|
*
|
||||||
|
* @param engine The engine kit
|
||||||
|
* @param state Stopped: The initial state
|
||||||
|
* Recording: The capturer starts successfully
|
||||||
|
* Encoding: The first video frame is successfully encoded
|
||||||
|
* Failed: The local video fails to start
|
||||||
|
* @param error OK: The local audio is normal
|
||||||
|
* Failure: No specified reason for the local audio failure.
|
||||||
|
* DeviceNoPermission: No permission to use the local audio device
|
||||||
|
* DeviceBusy: The microphone is in use
|
||||||
|
* RecordFailure: The local audio recording fails. Check whether the recording device is working properly
|
||||||
|
* EncodeFailure: The local audio encoding fails
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine localAudioStateChanged:(AgoraAudioLocalState)state error:(AgoraAudioLocalError)error NS_SWIFT_NAME(rtcEngine(_:localAudioStateChanged:error:));
|
||||||
|
|
||||||
|
#pragma mark Remote user audio delegates
|
||||||
|
|
||||||
|
/** The first audio frame received and decoded from the remote user.
|
||||||
|
|
||||||
|
@param engine The AgoraRtcEngineKit object.
|
||||||
|
@param userId Remote user ID.
|
||||||
|
@param elapsed Time elapsed (ms) from calling `joinChannelByToken` until this callback is triggered.
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine firstRemoteAudioFrameOfUid:(NSString * _Nonnull)userId elapsed:(NSInteger)elapsed NS_SWIFT_NAME(rtcEngine(_:firstRemoteAudioFrameOfUid:elapsed:));
|
||||||
|
|
||||||
|
/** Occurs when the SDK decodes the first remote audio frame for playback.
|
||||||
|
|
||||||
|
**Deprecated** . Use `AgoraAudioRemoteStateDecoding(2)` in the [remoteAudioStateChangedOfUid]([AgoraRtcEngineDelegate rtcEngine:remoteAudioStateChangedOfUid:state:reason:elapsed:]) callback instead.
|
||||||
|
|
||||||
|
This callback is triggered in either of the following scenarios:
|
||||||
|
|
||||||
|
- The remote user joins the channel and sends the audio stream.
|
||||||
|
- The remote user stops sending the audio stream and re-sends it after 15 seconds. Reasons for such an interruption include:
|
||||||
|
|
||||||
|
- The remote user leaves channel.
|
||||||
|
- The remote user drops offline.
|
||||||
|
- The remote user calls the [muteLocalAudioStream]([AgoraRtcEngineKit muteLocalAudioStream:]) method to stop sending the local audio stream.
|
||||||
|
- The remote user calls the [disableAudio]([AgoraRtcEngineKit disableAudio]) method to disable audio.
|
||||||
|
|
||||||
|
@param engine AgoraRtcEngineKit object.
|
||||||
|
@param uid User ID of the remote user sending the audio stream.
|
||||||
|
@param elapsed The time elapsed (ms) from the local user calling the joinChannel method until the SDK triggers this callback.
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit* _Nonnull)engine firstRemoteAudioFrameDecodedOfUid:(NSString * _Nonnull)uid elapsed:(NSInteger)elapsed NS_SWIFT_NAME(rtcEngine(_:firstRemoteAudioFrameDecodedOfUid:elapsed:));
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This callback indicates remote audio stream state has changed.
|
||||||
|
*
|
||||||
|
* @param engine The engine kit
|
||||||
|
* @param userId The user id
|
||||||
|
* @param state Stopped // The remote audio stopped, default state, audio is started or remote user disabled/muted audio stream.
|
||||||
|
* Starting // The first remote audio packet is received.
|
||||||
|
* Decoding // The remote audio stream is decoded and plays normally.
|
||||||
|
* Frozen // The remote audio is frozen.
|
||||||
|
* Failed // The remote audio fails to start.
|
||||||
|
* @param reason Interal // Internal reasons.
|
||||||
|
* NetworkCongestion // Network congestion.
|
||||||
|
* NetworkRecovery // Network recovery.
|
||||||
|
* LocalMuted // The local user stops receiving the remote audio stream or disables the audio module.
|
||||||
|
* LocalUnmuted // The local user resumes receiving the remote audio stream or enables the audio module.
|
||||||
|
* RemoteMuted // The remote user stops sending the audio stream or disables the audio module.
|
||||||
|
* RemoteUnmuted // The remote user resumes sending the audio stream or enables the audio module.
|
||||||
|
* Offline // The remote user leaves the channel.
|
||||||
|
* @param elapsed The elapsed time(ms) from the beginning of the session.
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine remoteAudioStateChangedOfUid:(NSString * _Nonnull)userId state:(AgoraAudioRemoteState)state reason:(AgoraAudioRemoteReason)reason elapsed:(NSInteger)elapsed NS_SWIFT_NAME(rtcEngine(_:remoteAudioStateChangedOfUid:state:reason:elapsed:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The sdk reports who is active speaker in the channel
|
||||||
|
*
|
||||||
|
* @param engine The engine kit
|
||||||
|
* @param speakerUid The speaker who is talking
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine activeSpeaker:(NSString * _Nonnull)speakerUid NS_SWIFT_NAME(rtcEngine(_:activeSpeaker:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The audio quality of the user. updated every two seconds.
|
||||||
|
*
|
||||||
|
* @param engine The engine kit
|
||||||
|
* @param userId The id of user
|
||||||
|
* @param quality The audio quality
|
||||||
|
* @param delay The delay from the remote user
|
||||||
|
* @param lost The percentage of lost packets
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine audioQualityOfUid:(NSString * _Nonnull)userId quality:(AgoraNetworkQuality)quality delay:(NSUInteger)delay lost:(NSUInteger)lost NS_SWIFT_NAME(rtcEngine(_:audioQualityOfUid:quality:delay:lost:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Occurs when the audio subscribe state changed.
|
||||||
|
*
|
||||||
|
* @param channelId The channel name of user joined.
|
||||||
|
* @param uid The remote user ID that is subscribed to.
|
||||||
|
* @param oldState The old state of the audio stream subscribe : #AgoraStreamSubscribeState.
|
||||||
|
* @param newState The new state of the audio stream subscribe : #AgoraStreamSubscribeState.
|
||||||
|
* @param elapseSinceLastState The time elapsed (ms) from the old state to the new state.
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didAudioSubscribeStateChange:(NSString * _Nonnull)channelId
|
||||||
|
uid:(unsigned int)uid
|
||||||
|
oldState:(AgoraStreamSubscribeState)oldState
|
||||||
|
newState:(AgoraStreamSubscribeState)newState
|
||||||
|
elapseSinceLastState:(int)elapseSinceLastState NS_SWIFT_NAME(rtcEngine(_:didAudioSubscribeStateChange:uid:oldState:newState:elapseSinceLastState:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Occurs when the audio publish state changed.
|
||||||
|
*
|
||||||
|
* @param channelId The channel name of user joined.
|
||||||
|
* @param oldState The old state of the audio stream publish : #AgoraStreamPublishState.
|
||||||
|
* @param newState The new state of the audio stream publish : #AgoraStreamPublishState.
|
||||||
|
* @param elapseSinceLastState The time elapsed (ms) from the old state to the new state.
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didAudioPublishStateChange:(NSString * _Nonnull)channelId
|
||||||
|
oldState:(AgoraStreamPublishState)oldState
|
||||||
|
newState:(AgoraStreamPublishState)newState
|
||||||
|
elapseSinceLastState:(int)elapseSinceLastState NS_SWIFT_NAME(rtcEngine(_:didAudioPublishStateChange:oldState:newState:elapseSinceLastState:));
|
||||||
|
|
||||||
|
#pragma mark Remote user video delegates
|
||||||
|
/**
|
||||||
|
* Event of the first frame of remote user is decoded successfully.
|
||||||
|
*
|
||||||
|
* @param engine The engine kit
|
||||||
|
* @param userId The remote user id
|
||||||
|
* @param size The size of video stream
|
||||||
|
* @param elapsed The elapsed time(ms) from the beginning of the session.
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine firstRemoteVideoDecodedOfUid:(NSString * _Nonnull)userId size:(CGSize)size elapsed:(NSInteger)elapsed NS_SWIFT_NAME(rtcEngine(_:firstRemoteVideoDecodedOfUid:size:elapsed:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event of the first frame of remote user is rendering on the screen.
|
||||||
|
*
|
||||||
|
* @param engine The engine kit
|
||||||
|
* @param userId The remote user id
|
||||||
|
* @param size The size of video stream
|
||||||
|
* @param elapsed The elapsed time(ms) from the beginning of the session.
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine firstRemoteVideoFrameOfUid:(NSString * _Nonnull)userId size:(CGSize)size elapsed:(NSInteger)elapsed NS_SWIFT_NAME(rtcEngine(_:firstRemoteVideoFrameOfUid:size:elapsed:));
|
||||||
|
|
||||||
|
/** Occurs when the local or remote video size or rotation has changed.
|
||||||
|
*
|
||||||
|
* @param engine AgoraRtcEngineKit object.
|
||||||
|
* @param sourceType The video source type.
|
||||||
|
* @param uid The user ID. 0 indicates the local user.
|
||||||
|
* @param size Size of the video (width and height) in pixels.
|
||||||
|
* @param rotation The rotation information of the video.
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine videoSizeChangedOfSourceType:(AgoraVideoSourceType)sourceType uid:(NSString * _Nonnull)uid size:(CGSize)size rotation:(NSInteger)rotation NS_SWIFT_NAME(rtcEngine(_:videoSizeChangedOf:uid:size:rotation:));
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit* _Nonnull)engine contentInspectResult:(AgoraContentInspectResult)result NS_SWIFT_NAME(rtcEngine(_:contentInspectResult:));
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit* _Nonnull)engine snapshotTaken:(NSUInteger)uid filePath:(NSString* _Nonnull)filePath width:(NSInteger)width height:(NSInteger)height errCode:(NSInteger)errCode NS_SWIFT_NAME(rtcEngine(_:snapshotTaken:filePath:width:height:errCode:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @technical preview
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit* _Nonnull)engine audioMetadataReceived:(NSString * _Nonnull)userId metadata:(NSData * _Nonnull)metadata NS_SWIFT_NAME(rtcEngine(_:audioMetadataReceived:metadata:));
|
||||||
|
/** Occurs when the local video stream state changes
|
||||||
|
*
|
||||||
|
* This callback indicates the state of the local video stream, including camera capturing and video encoding,
|
||||||
|
* and allows you to troubleshoot issues when exceptions occur.
|
||||||
|
*
|
||||||
|
* @note For some device models, the SDK will not trigger this callback when the state of the local video changes
|
||||||
|
* while the local video capturing device is in use, so you have to make your own timeout judgment.
|
||||||
|
* @param engine AgoraRtcEngineKit object
|
||||||
|
* @param state State type #AgoraVideoLocalState. When the state is AgoraVideoLocalStateFailed (3), see the `error` parameter for details.
|
||||||
|
* @param error The detailed error information: #AgoraLocalVideoStreamError.
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine localVideoStateChangedOfState:(AgoraVideoLocalState)state
|
||||||
|
error:(AgoraLocalVideoStreamError)error
|
||||||
|
sourceType:(AgoraVideoSourceType)source NS_SWIFT_NAME(rtcEngine(_:localVideoStateChangedOf:error:sourceType:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This callback indicates remote video stream state has changed.
|
||||||
|
*
|
||||||
|
* @param engine The engine kit
|
||||||
|
* @param userId The user id
|
||||||
|
* @param state Stopped // Default state, video is started or remote user disabled/muted video stream
|
||||||
|
Running // Running state, remote video can be displayed normally
|
||||||
|
Frozen // Remote video is frozen, probably due to network issue.
|
||||||
|
* @param reason Interal // Internal reasons.
|
||||||
|
* NetworkCongestion // Network congestion.
|
||||||
|
* NetworkRecovery // Network recovery.
|
||||||
|
* LocalMuted // The local user stops receiving the remote audio stream or disables the audio module.
|
||||||
|
* LocalUnmuted // The local user resumes receiving the remote audio stream or enables the audio module.
|
||||||
|
* RemoteMuted // The remote user stops sending the audio stream or disables the audio module.
|
||||||
|
* RemoteUnmuted // The remote user resumes sending the audio stream or enables the audio module.
|
||||||
|
* Offline // The remote user leaves the channel.
|
||||||
|
* AudioFallback //The remote media stream falls back to the audio-only stream due to poor network conditions.
|
||||||
|
* AudioFallbackRecovery // The remote media stream switches back to the video stream after the network conditions improve.
|
||||||
|
* @param elapsed The time elapsed (ms) from the local user calling `joinChannel` until this callback is triggered.
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine remoteVideoStateChangedOfUid:(NSString * _Nonnull)userId state:(AgoraVideoRemoteState)state reason:(AgoraVideoRemoteReason)reason elapsed:(NSInteger)elapsed NS_SWIFT_NAME(rtcEngine(_:remoteVideoStateChangedOfUid:state:reason:elapsed:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event of remote user audio muted or unmuted
|
||||||
|
*
|
||||||
|
* @param engine The engine kit
|
||||||
|
* @param muted Muted or unmuted
|
||||||
|
* @param userId The remote user id
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine didAudioMuted:(BOOL)muted byUid:(NSString * _Nonnull)userId NS_SWIFT_NAME(rtcEngine(_:didAudioMuted:byUid:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event of remote user video muted or unmuted
|
||||||
|
*
|
||||||
|
* @param engine The engine kit
|
||||||
|
* @param muted Muted or unmuted
|
||||||
|
* @param userId The remote user id
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine didVideoMuted:(BOOL)muted byUid:(NSString * _Nonnull)userId NS_SWIFT_NAME(rtcEngine(_:didVideoMuted:byUid:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event of remote user video enabled or disabled
|
||||||
|
*
|
||||||
|
* @param engine The engine kit
|
||||||
|
* @param enabled Enabled or disabled
|
||||||
|
* @param userId The remote user id
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine didVideoEnabled:(BOOL)enabled byUid:(NSString * _Nonnull)userId NS_SWIFT_NAME(rtcEngine(_:didVideoEnabled:byUid:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event of remote user local video enabled or disabled
|
||||||
|
*
|
||||||
|
* @param engine The engine kit
|
||||||
|
* @param enabled Enabled or disabled
|
||||||
|
* @param userId The remote user id
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine didLocalVideoEnabled:(BOOL)enabled byUid:(NSString * _Nonnull)userId NS_SWIFT_NAME(rtcEngine(_:didLocalVideoEnabled:byUid:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Occurs when the remote user state is updated.
|
||||||
|
*
|
||||||
|
* @param engine The engine kit
|
||||||
|
* @param userId The remote user id
|
||||||
|
* @param state The remote user state
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine remoteUserStateChangedOfUid:(NSString * _Nonnull)userId state:(NSUInteger)state NS_SWIFT_NAME(rtcEngine(_:remoteUserStateChangedOfUid:state:));
|
||||||
|
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine publishingRequestReceivedFromUid:(NSString * _Nonnull)userId NS_SWIFT_NAME(rtcEngine(_:publishingRequestReceivedFromUid:));
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine publishingRequestAnsweredByOwner:(NSString * _Nonnull)userId accepted:(BOOL)accepted error:(AgoraErrorCode)error NS_SWIFT_NAME(rtcEngine(_:publishingRequestAnsweredByOwner:accepted:error:));
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine unpublishingRequestReceivedFromOwner:(NSString * _Nonnull)userId NS_SWIFT_NAME(rtcEngine(_:unpublishingRequestReceivedFromOwner:));
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine streamInjectedStatusOfUrl:(NSString * _Nonnull)url uid:(NSString * _Nonnull)userId status:(AgoraInjectStreamStatus)status NS_SWIFT_NAME(rtcEngine(_:streamInjectedStatusOfUrl:uid:status:));
|
||||||
|
|
||||||
|
/** Intra request received.
|
||||||
|
* @param engine The AgoraRtcEngineKit object.
|
||||||
|
*/
|
||||||
|
- (void)rtcEngineIntraRequestReceived:(AgoraRtcEngineKit *_Nonnull)engine NS_SWIFT_NAME(rtcEngineIntraRequestReceived(_:));
|
||||||
|
|
||||||
|
/** Target bitrate updated.
|
||||||
|
* @param engine The AgoraRtcEngineKit object.
|
||||||
|
* @param bweInfo The uplink network info, including target bitrate bps.
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine uplinkNetworkInfoUpdate:(AgoraUplinkNetworkInfo *_Nonnull)bweInfo NS_SWIFT_NAME(rtcEngine(_:uplinkNetworkInfoUpdate:));
|
||||||
|
|
||||||
|
/** Downlink network info updated.
|
||||||
|
* @param engine The AgoraRtcEngineKit object.
|
||||||
|
* @param networkInfo The downlink network info.
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine downlinkNetworkInfoUpdate:(AgoraDownlinkNetworkInfo *_Nonnull)networkInfo NS_SWIFT_NAME(rtcEngine(_:downlinkNetworkInfoUpdate:));
|
||||||
|
|
||||||
|
#pragma mark Connection state delegates
|
||||||
|
|
||||||
|
/** Occurs when the connection state of the SDK to the server is changed.
|
||||||
|
*
|
||||||
|
* @param state See #AgoraConnectionState.
|
||||||
|
* @param reason See #AgoraConnectionChangedReason.
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit* _Nonnull)engine connectionChangedToState:(AgoraConnectionState)state reason:(AgoraConnectionChangedReason)reason NS_SWIFT_NAME(rtcEngine(_:connectionChangedTo:reason:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reports WIFI user message.
|
||||||
|
* When the user needs to be prompted to approach the AP or switch the frequency band connected to the AP, the SDK will trigger this callback to notify the APP.
|
||||||
|
* @param engine AgoraRtcEngineKit object.
|
||||||
|
* @param reason The reason of notifying the user of a message.
|
||||||
|
* @param action Suggest an action for the user.
|
||||||
|
* @param wlAccMsg The message content of notifying the user.
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine wlAccMessage:(AgoraWlAccReason)reason action:(AgoraWlAccAction)action wlAccMsg:(NSString * _Nonnull)wlAccMsg NS_SWIFT_NAME(rtcEngine(_:wlAccMessage:action:wlAccMsg:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reports WIFI accelerate status.
|
||||||
|
* When the optimized end-to-end delay, frozen ratio and packet loss rate need to be displayed to the user, the SDK will trigger this callback to notify the APP.
|
||||||
|
* @param engine AgoraRtcEngineKit object.
|
||||||
|
* @param currentStats Instantaneous value of optimization effect.
|
||||||
|
* @param averageStats Average value of cumulative optimization effect.
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine wlAccStats:(AgoraWlAccStats * _Nonnull)currentStats averageStats:(AgoraWlAccStats * _Nonnull)averageStats NS_SWIFT_NAME(rtcEngine(_:wlAccStats:averageStats:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Occurs when the connection state of the SDK to the server is changed.
|
||||||
|
*
|
||||||
|
* @param engine The AgoraRtcEngineKit object.
|
||||||
|
* @param type See \ref AgoraNetworkType.
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine networkTypeChanged:(AgoraNetworkType)type NS_SWIFT_NAME(rtcEngine(_:networkTypeChanged:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Occurs when permission error
|
||||||
|
*
|
||||||
|
* @param engine The AgoraRtcEngineKit object.
|
||||||
|
* @param type See \ref AgoraPermissionType.
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine permissionError:(AgoraPermissionType)type NS_SWIFT_NAME(rtcEngine(_:permissionError:));
|
||||||
|
|
||||||
|
/** Occurs when the state of the media stream relay changes.
|
||||||
|
|
||||||
|
The SDK reports the state of the current media relay and possible error messages in this callback.
|
||||||
|
|
||||||
|
@param engine AgoraRtcEngineKit object.
|
||||||
|
@param state The state code in [AgoraChannelMediaRelayState](AgoraChannelMediaRelayState).
|
||||||
|
@param error The error code in [AgoraChannelMediaRelayError](AgoraChannelMediaRelayError).
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine
|
||||||
|
channelMediaRelayStateDidChange:(AgoraChannelMediaRelayState)state
|
||||||
|
error:(AgoraChannelMediaRelayError)error NS_SWIFT_NAME(rtcEngine(_:channelMediaRelayStateDidChange:error:));
|
||||||
|
|
||||||
|
/** Reports events during the media stream relay.
|
||||||
|
|
||||||
|
@param engine AgoraRtcEngineKit object.
|
||||||
|
@param event The event code in [AgoraChannelMediaRelayEvent](AgoraChannelMediaRelayEvent).
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine
|
||||||
|
didReceiveChannelMediaRelayEvent:(AgoraChannelMediaRelayEvent)event NS_SWIFT_NAME(rtcEngine(_:didReceive:));
|
||||||
|
|
||||||
|
/** Occurs when the video subscribe state changed.
|
||||||
|
*
|
||||||
|
* @param engine AgoraRtcEngineKit object.
|
||||||
|
* @param channelId The channel name of user joined.
|
||||||
|
* @param uid The remote user ID that is subscribed to.
|
||||||
|
* @param oldState The old state of the video stream subscribe : #AgoraStreamSubscribeState.
|
||||||
|
* @param newState The new state of the video stream subscribe : #AgoraStreamSubscribeState.
|
||||||
|
* @param elapseSinceLastState The time elapsed (ms) from the old state to the new state.
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didVideoSubscribeStateChange:(NSString * _Nonnull)channelId
|
||||||
|
uid:(unsigned int)uid
|
||||||
|
oldState:(AgoraStreamSubscribeState)oldState
|
||||||
|
newState:(AgoraStreamSubscribeState)newState
|
||||||
|
elapseSinceLastState:(int)elapseSinceLastState NS_SWIFT_NAME(rtcEngine(_:didVideoSubscribeStateChange:uid:oldState:newState:elapseSinceLastState:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Occurs when the video publish state changed.
|
||||||
|
*
|
||||||
|
* @param engine AgoraRtcEngineKit object.
|
||||||
|
* @param channelId The channel name of user joined.
|
||||||
|
* @param oldState The old state of the video stream publish : #AgoraStreamPublishState.
|
||||||
|
* @param newState The new state of the video stream publish : #AgoraStreamPublishState.
|
||||||
|
* @param elapseSinceLastState The time elapsed (ms) from the old state to the new state.
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didVideoPublishStateChange:(NSString * _Nonnull)channelId
|
||||||
|
sourceType:(AgoraVideoSourceType)source
|
||||||
|
oldState:(AgoraStreamPublishState)oldState
|
||||||
|
newState:(AgoraStreamPublishState)newState
|
||||||
|
elapseSinceLastState:(int)elapseSinceLastState NS_SWIFT_NAME(rtcEngine(_:didVideoPublishStateChange:sourceType:oldState:newState:elapseSinceLastState:));
|
||||||
|
|
||||||
|
#pragma mark Rhythm Player Delegates Methods
|
||||||
|
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine didRhythmPlayerStateChanged:(AgoraRhythmPlayerState)state
|
||||||
|
errorCode:(AgoraRhythmPlayerError)errorCode NS_SWIFT_NAME(rtcEngine(_:didRhythmPlayerStateChanged:errorCode:));
|
||||||
|
|
||||||
|
#pragma mark Local Video Transcoder Delegates Methods
|
||||||
|
/**
|
||||||
|
* Occurs when local video transcoder stream has error.
|
||||||
|
*
|
||||||
|
* @param stream Stream type of AgoraTranscodingVideoStream.
|
||||||
|
* @param error Error code of AgoraVideoTranscoderError.
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine didLocalVideoTranscoderErrorWithStream:(AgoraTranscodingVideoStream * _Nonnull )stream
|
||||||
|
errorCode:(AgoraVideoTranscoderError)errorCode NS_SWIFT_NAME(rtcEngine(_:didLocalVideoTranscoderErrorWithStream:errorCode:));
|
||||||
|
|
||||||
|
#pragma mark Remote Video Layout Info Delegates Methods
|
||||||
|
/**
|
||||||
|
* Occurs when local video transcoder stream has error.
|
||||||
|
*
|
||||||
|
* @param uid The ID of the remote user.
|
||||||
|
* @param videoLayoutInfo The `AgoraVideoLayoutInfo` object that contains video layout info of the remote user..
|
||||||
|
*/
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine didTranscodedStreamLayoutInfoUpdatedWithUserId:(NSUInteger)uid videoLayoutInfo:(AgoraVideoLayoutInfo* _Nonnull)videoLayoutInfo NS_SWIFT_NAME(rtcEngine(_:didTranscodedStreamLayoutInfoUpdatedWithUserId:videoLayoutInfo:));
|
||||||
|
|
||||||
|
@end
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,940 @@
|
||||||
|
//
|
||||||
|
// AgoraRtcEngineKitEx.h
|
||||||
|
// AgoraRtcEngineKit
|
||||||
|
//
|
||||||
|
// Copyright (c) 2020 Agora. All rights reserved.
|
||||||
|
// Created by LLF on 2020/3/9.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "AgoraRtcEngineKit.h"
|
||||||
|
#import "AgoraObjects.h"
|
||||||
|
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
#elif TARGET_OS_MAC
|
||||||
|
#import <AppKit/AppKit.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
@interface AgoraRtcEngineKit(Ex)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Joins a channel.
|
||||||
|
*
|
||||||
|
* You can call this method multiple times to join multiple channels.
|
||||||
|
*
|
||||||
|
* @param token The token for authentication.
|
||||||
|
* - In situations not requiring high security: You can use the temporary token
|
||||||
|
* generated at Console. For details, see [Get a temporary token](https://docs.agora.io/en/Agora%20Platform/token?platform=All%20Platforms#get-a-temporary-token).
|
||||||
|
* - In situations requiring high security: Set it as the token generated at
|
||||||
|
* you server. For details, see [Generate a token](https://docs.agora.io/en/Agora%20Platform/token?platform=All%20Platforms#get-a-token).
|
||||||
|
* @param connection \ref AgoraRtcConnection by channelId and uid combine
|
||||||
|
* @param delegate AgoraRtcEngineDelegate protocol.(Need a new object when called)
|
||||||
|
* @param mediaOptions AgoraRtcChannelMediaOptions Object.
|
||||||
|
* @param joinSuccessBlock Same as \ref AgoraRtcEngineDelegate.rtcEngine:didJoinChannel:withUid:elapsed: didJoinChannel. We recommend you set this parameter as `nil` to use `didJoinChannel`.
|
||||||
|
* - If `joinSuccessBlock` is nil, the SDK triggers the `didJoinChannel` callback.
|
||||||
|
* - If you implement both `joinSuccessBlock` and `didJoinChannel`, `joinSuccessBlock` takes higher priority than `didJoinChannel`.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)joinChannelExByToken:(NSString* _Nullable)token
|
||||||
|
connection:(AgoraRtcConnection * _Nonnull)connection
|
||||||
|
delegate:(id<AgoraRtcEngineDelegate> _Nullable)delegate
|
||||||
|
mediaOptions:(AgoraRtcChannelMediaOptions* _Nonnull)mediaOptions
|
||||||
|
joinSuccess:(void(^ _Nullable)(NSString* _Nonnull channel, NSUInteger uid, NSInteger elapsed))joinSuccessBlock NS_SWIFT_NAME(joinChannelEx(byToken:connection:delegate:mediaOptions:joinSuccess:));
|
||||||
|
|
||||||
|
/** Joins the channel with a user account.
|
||||||
|
*
|
||||||
|
* After the user successfully joins the channel, the SDK triggers the following callbacks:
|
||||||
|
*
|
||||||
|
* - The local client: \ref agora::rtc::IRtcEngineEventHandler::onLocalUserRegistered "onLocalUserRegistered" and \ref agora::rtc::IRtcEngineEventHandler::onJoinChannelSuccess "onJoinChannelSuccess" .
|
||||||
|
* The remote client: \ref agora::rtc::IRtcEngineEventHandler::onUserJoined "onUserJoined" and \ref agora::rtc::IRtcEngineEventHandler::onUserInfoUpdated "onUserInfoUpdated" , if the user joining the channel is in the `COMMUNICATION` profile, or is a host in the `LIVE_BROADCASTING` profile.
|
||||||
|
*
|
||||||
|
* @note To ensure smooth communication, use the same parameter type to identify the user. For example, if a user joins the channel with a user ID, then ensure all the other users use the user ID too. The same applies to the user account.
|
||||||
|
* If a user joins the channel with the Agora Web SDK, ensure that the uid of the user is set to the same parameter type.
|
||||||
|
*
|
||||||
|
* @param token The token generated at your server:
|
||||||
|
* - For low-security requirements: You can use the temporary token generated at Console. For details, see [Get a temporary toke](https://docs.agora.io/en/Voice/token?platform=All%20Platforms#get-a-temporary-token).
|
||||||
|
* - For high-security requirements: Set it as the token generated at your server. For details, see [Get a token](https://docs.agora.io/en/Voice/token?platform=All%20Platforms#get-a-token).
|
||||||
|
* @param channelId The channel name. The maximum length of this parameter is 64 bytes. Supported character scopes are:
|
||||||
|
* - All lowercase English letters: a to z.
|
||||||
|
* - All uppercase English letters: A to Z.
|
||||||
|
* - All numeric characters: 0 to 9.
|
||||||
|
* - The space character.
|
||||||
|
* - Punctuation characters and other symbols, including: "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", ",".
|
||||||
|
* @param userAccount The user account. The maximum length of this parameter is 255 bytes. Ensure that you set this parameter and do not set it as null. Supported character scopes are:
|
||||||
|
* - All lowercase English letters: a to z.
|
||||||
|
* - All uppercase English letters: A to Z.
|
||||||
|
* - All numeric characters: 0 to 9.
|
||||||
|
* - The space character.
|
||||||
|
* - Punctuation characters and other symbols, including: "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", ",".
|
||||||
|
* @param delegate AgoraRtcEngineDelegate protocol.
|
||||||
|
* @param mediaOptions The channel media options: \ref agora::rtc::ChannelMediaOptions::ChannelMediaOptions "ChannelMediaOptions"
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
* - #ERR_INVALID_ARGUMENT (-2)
|
||||||
|
* - #ERR_NOT_READY (-3)
|
||||||
|
* - #ERR_REFUSED (-5)
|
||||||
|
*/
|
||||||
|
- (int)joinChannelExByToken:(NSString* _Nullable)token
|
||||||
|
channelId:(NSString* _Nonnull)channelId
|
||||||
|
userAccount:(NSString* _Nonnull)userAccount
|
||||||
|
delegate:(id<AgoraRtcEngineDelegate> _Nullable)delegate
|
||||||
|
mediaOptions:(AgoraRtcChannelMediaOptions* _Nonnull)mediaOptions
|
||||||
|
joinSuccess:(void(^ _Nullable)(NSString* _Nonnull channel, NSUInteger uid, NSInteger elapsed))joinSuccessBlock NS_SWIFT_NAME(joinChannelEx(byToken:channelId:userAccount:delegate:mediaOptions:joinSuccess:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the channel media options after joining the channel.
|
||||||
|
*
|
||||||
|
* @param mediaOptions The channel media options: ChannelMediaOptions.
|
||||||
|
* @param connection \ref AgoraRtcConnection by channelId and uid combine
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)updateChannelExWithMediaOptions:(AgoraRtcChannelMediaOptions* _Nonnull)mediaOptions
|
||||||
|
connection:(AgoraRtcConnection * _Nonnull)connection NS_SWIFT_NAME(updateChannelEx(with:connection:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Leaves the channel by connection.
|
||||||
|
*
|
||||||
|
* @param connection \ref AgoraRtcConnection by channelId and uid combine
|
||||||
|
* @param leaveChannelBlock This callback indicates that a user leaves a channel, and provides the statistics of the call in #AgoraChannelStats.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)leaveChannelEx:(AgoraRtcConnection * _Nonnull)connection
|
||||||
|
leaveChannelBlock:(void(^ _Nullable)(AgoraChannelStats* _Nonnull stat))leaveChannelBlock NS_SWIFT_NAME(leaveChannelEx(_:leaveChannelBlock:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets the SDK delegate.
|
||||||
|
*
|
||||||
|
* The SDK uses the delegate to inform the app on engine runtime events. All methods defined in the
|
||||||
|
* delegate are optional implementation methods.
|
||||||
|
*
|
||||||
|
* @param delegate The AgoraRtcEngineDelegate protocol.
|
||||||
|
* @param connection The AgoraRtcConnection object.
|
||||||
|
*/
|
||||||
|
- (int)setDelegateEx:(id<AgoraRtcEngineDelegate> _Nullable)delegate connection:(AgoraRtcConnection * _Nonnull)connection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*Stops or resumes sending the local audio stream with connection.
|
||||||
|
*
|
||||||
|
*@param mute Determines whether to send or stop sending the local audio stream:
|
||||||
|
*- `YES`: Stop sending the local audio stream.
|
||||||
|
*- `NO`: Send the local audio stream.
|
||||||
|
*
|
||||||
|
*@param connection \ref AgoraRtcConnection by channelId and uid combine
|
||||||
|
*
|
||||||
|
*@return
|
||||||
|
*- 0: Success.
|
||||||
|
*- < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)muteLocalAudioStreamEx:(BOOL)mute connection:(AgoraRtcConnection * _Nonnull)connection NS_SWIFT_NAME(muteLocalAudioStreamEx(_:connection:));
|
||||||
|
/**
|
||||||
|
*Stops or resumes sending the local video stream with connection.
|
||||||
|
*
|
||||||
|
*@param mute Determines whether to send or stop sending the local video stream:
|
||||||
|
*- `YES`: Stop sending the local video stream.
|
||||||
|
*- `NO`: Send the local video stream.
|
||||||
|
*
|
||||||
|
*@param connection \ref AgoraRtcConnection by channelId and uid combine
|
||||||
|
*
|
||||||
|
*@return
|
||||||
|
*- 0: Success.
|
||||||
|
*- < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)muteLocalVideoStreamEx:(BOOL)mute connection:(AgoraRtcConnection * _Nonnull)connection NS_SWIFT_NAME(muteLocalVideoStreamEx(_:connection:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Leaves the channel by connection.
|
||||||
|
*
|
||||||
|
* @param connection {@link AgoraRtcConnection} by channelId and uid combine
|
||||||
|
* @param options The options for leaving the channel. See {@link LeaveChannelOptions}.
|
||||||
|
* @param leaveChannelBlock This callback indicates that a user leaves a channel, and provides the statistics of the call in #AgoraChannelStats.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)leaveChannelEx:(AgoraRtcConnection * _Nonnull)connection
|
||||||
|
options:(AgoraLeaveChannelOptions * _Nonnull)options
|
||||||
|
leaveChannelBlock:(void(^ _Nullable)(AgoraChannelStats* _Nonnull stat))leaveChannelBlock;
|
||||||
|
|
||||||
|
/** Mutes a specified remote user's audio stream.
|
||||||
|
|
||||||
|
@note When setting to YES, this method stops playing audio streams without affecting the audio stream receiving process.
|
||||||
|
|
||||||
|
@param uid User ID whose audio streams the user intends to mute.
|
||||||
|
@param mute * YES: Stops playing a specified user’s audio streams.
|
||||||
|
* NO: Resumes playing a specified user’s audio streams.
|
||||||
|
@param connection \ref AgoraRtcConnection by channelId and uid combine
|
||||||
|
|
||||||
|
@return * 0: Success.
|
||||||
|
* <0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)muteRemoteAudioStreamEx:(NSUInteger)uid
|
||||||
|
mute:(BOOL)mute
|
||||||
|
connection:(AgoraRtcConnection * _Nonnull)connection NS_SWIFT_NAME(muteRemoteAudioStreamEx(_:mute:connection:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
*Stops or resumes receiving all remote audio stream with connection.
|
||||||
|
*
|
||||||
|
*@param mute Whether to stop receiving remote audio streams:
|
||||||
|
*- `YES`: Stop receiving any remote audio stream.
|
||||||
|
*- `NO`: Resume receiving all remote audio streams.
|
||||||
|
*
|
||||||
|
*@param connection \ref AgoraRtcConnection by channelId and uid combine
|
||||||
|
*
|
||||||
|
*@return
|
||||||
|
*- 0: Success.
|
||||||
|
*- < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)muteAllRemoteAudioStreamsEx:(BOOL)mute
|
||||||
|
connection:(AgoraRtcConnection * _Nonnull)connection NS_SWIFT_NAME(muteAllRemoteAudioStreamsEx(_:connection:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the video encoder configuration.
|
||||||
|
*
|
||||||
|
* Each configuration profile corresponds to a set of video parameters,
|
||||||
|
* including the resolution, frame rate, and bitrate.
|
||||||
|
*
|
||||||
|
* The parameters specified in this method are the maximum values under ideal network conditions.
|
||||||
|
* If the video engine cannot render the video using the specified parameters
|
||||||
|
* due to poor network conditions, the parameters further down the list are
|
||||||
|
* considered until a successful configuration is found.
|
||||||
|
*
|
||||||
|
* @param config The local video encoder configuration, see #AgoraVideoEncoderConfiguration.
|
||||||
|
* @param connection \ref AgoraRtcConnection by channelId and uid combine
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)setVideoEncoderConfigurationEx:(AgoraVideoEncoderConfiguration* _Nonnull)config
|
||||||
|
connection:(AgoraRtcConnection * _Nonnull)connection NS_SWIFT_NAME(setVideoEncoderConfigurationEx(_:connection:));
|
||||||
|
|
||||||
|
/** Binds the remote user to the video display window, that is, sets the view for the user of the specified uid.
|
||||||
|
*
|
||||||
|
* Usually, the application should specify the uid of the remote video in the method call before the user enters a channel. If the remote uid is unknown to the application, you can set the uid after receiving the \ref AgoraRtcEngineDelegate.rtcEngine:didJoinedOfUid:elapsed: didJoinedOfUid event.
|
||||||
|
*
|
||||||
|
* @param remote \ref AgoraRtcVideoCanvas
|
||||||
|
* @param connection \ref AgoraRtcConnection by channelId and uid combine
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - <0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)setupRemoteVideoEx:(AgoraRtcVideoCanvas* _Nonnull)remote
|
||||||
|
connection:(AgoraRtcConnection * _Nonnull)connection NS_SWIFT_NAME(setupRemoteVideoEx(_:connection:));
|
||||||
|
|
||||||
|
/** Configures the remote video display mode. The application can call this method multiple times to change the display mode.
|
||||||
|
*
|
||||||
|
* @param uid User id of the user whose video streams are received.
|
||||||
|
* @param mode AgoraVideoRenderMode
|
||||||
|
* @param mirror AgoraVideoMirrorMode
|
||||||
|
* @param connection \ref AgoraRtcConnection by channelId and uid combine
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - <0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)setRemoteRenderModeEx:(NSUInteger)uid
|
||||||
|
mode:(AgoraVideoRenderMode)mode
|
||||||
|
mirror:(AgoraVideoMirrorMode)mirror
|
||||||
|
connection:(AgoraRtcConnection * _Nonnull)connection NS_SWIFT_NAME(setRemoteRenderModeEx(_:mode:mirror:connection:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stops or resumes receiving the video stream of a specified user.
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* Once you leave the channel, the settings in this method becomes invalid.
|
||||||
|
*
|
||||||
|
* @param uid ID of the specified remote user.
|
||||||
|
* @param mute Determines whether to receive or stop receiving a specified video stream:
|
||||||
|
* - `YES`: Stop receiving the specified video stream.
|
||||||
|
* - `NO`: (Default) Receive the specified video stream.
|
||||||
|
* @param connection \ref AgoraRtcConnection by channelId and uid combine
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)muteRemoteVideoStreamEx:(NSUInteger)uid
|
||||||
|
mute:(BOOL)mute
|
||||||
|
connection:(AgoraRtcConnection * _Nonnull)connection NS_SWIFT_NAME(muteRemoteVideoStreamEx(_:mute:connection:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
*Stops or resumes receiving all remote video stream with connection.
|
||||||
|
*
|
||||||
|
*@param mute Whether to stop receiving remote video streams:
|
||||||
|
*- `YES`: Stop receiving any remote video stream.
|
||||||
|
*- `NO`: Resume receiving all remote video streams.
|
||||||
|
*
|
||||||
|
*@param connection \ref AgoraRtcConnection by channelId and uid combine
|
||||||
|
*
|
||||||
|
*@return
|
||||||
|
*- 0: Success.
|
||||||
|
*- < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)muteAllRemoteVideoStreamsEx:(BOOL)mute
|
||||||
|
connection:(AgoraRtcConnection * _Nonnull)connection NS_SWIFT_NAME(muteAllRemoteVideoStreamsEx(_:connection:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables or disables the dual video stream mode.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* @param enabled
|
||||||
|
* - true: Enable the dual-stream mode.
|
||||||
|
* - false: (default) Disable the dual-stream mode.
|
||||||
|
* @param streamConfig The minor stream config
|
||||||
|
* @param connection An output parameter which is used to control different connection instances.
|
||||||
|
*/
|
||||||
|
- (int)enableDualStreamModeEx:(BOOL)enabled
|
||||||
|
streamConfig:(AgoraSimulcastStreamConfig*)streamConfig
|
||||||
|
connection:(AgoraRtcConnection* _Nonnull)connection NS_SWIFT_NAME(enableDualStreamModeEx(_:streamConfig:connection:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables or disables the dual video stream mode.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* @param mode The dual-stream mode.
|
||||||
|
* @param streamConfig The minor stream config
|
||||||
|
* @param connection An output parameter which is used to control different connection instances.
|
||||||
|
*/
|
||||||
|
- (int)setDualStreamModeEx:(AgoraSimulcastStreamMode)mode
|
||||||
|
streamConfig:(AgoraSimulcastStreamConfig*)streamConfig
|
||||||
|
connection:(AgoraRtcConnection* _Nonnull)connection NS_SWIFT_NAME(setDualStreamModeEx(_:streamConfig:connection:));
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the remote video stream type.
|
||||||
|
*
|
||||||
|
* If the remote user has enabled the dual-stream mode, by default the SDK
|
||||||
|
* receives the high-stream video. Call this method to switch to the low-stream
|
||||||
|
* video.
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* This method applies to scenarios where the remote user has enabled the
|
||||||
|
* dual-stream mode by \ref enableDualStreamMode: enableDualStreamMode
|
||||||
|
* before joining the channel.
|
||||||
|
*
|
||||||
|
* @param uid ID of the remote user sending the video stream.
|
||||||
|
* @param streamType The video stream type: #AgoraVideoStreamType.
|
||||||
|
* @param connection \ref AgoraRtcConnection by channelId and uid combine
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)setRemoteVideoStreamEx:(NSUInteger)uid
|
||||||
|
type:(AgoraVideoStreamType)streamType
|
||||||
|
connection:(AgoraRtcConnection * _Nonnull)connection NS_SWIFT_NAME(setRemoteVideoStreamEx(_:type:connection:));
|
||||||
|
/**
|
||||||
|
* Sets the remote video subscription options
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param uid ID of the remote user sending the video stream.
|
||||||
|
* @param options Sets the video subscription options.
|
||||||
|
* @param connection \ref AgoraRtcConnection by channelId and uid combine
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)setRemoteVideoSubscriptionOptionsEx:(NSUInteger)uid
|
||||||
|
options:(AgoraVideoSubscriptionOptions* _Nonnull)options
|
||||||
|
connection:(AgoraRtcConnection* _Nonnull)connection NS_SWIFT_NAME(setRemoteVideoSubscriptionOptionsEx(_:options:connection:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pushes the encoded external video frame to specified connection in Agora SDK.
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* Ensure that you have configured encoded video source before calling this method.
|
||||||
|
*
|
||||||
|
* @param data The encoded external video data, which must be the direct buffer.
|
||||||
|
* @param frameInfo The encoded external video frame info: AgoraEncodedVideoFrameInfo.
|
||||||
|
* @param connection \ref AgoraRtcConnection by channelId and uid combine
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0: Success, which means that the encoded external video frame is pushed successfully.
|
||||||
|
* - < 0: Failure, which means that the encoded external video frame fails to be pushed.
|
||||||
|
*/
|
||||||
|
- (int)pushExternalEncodedVideoFrameEx:(NSData* _Nonnull)frame
|
||||||
|
info:(AgoraEncodedVideoFrameInfo * _Nonnull)info
|
||||||
|
videoTrackId:(NSUInteger)videoTrackId NS_SWIFT_NAME(pushExternalEncodedVideoFrameEx(_:info:videoTrackId:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pushes the external video frame.
|
||||||
|
*
|
||||||
|
* This method pushes the video frame using the AgoraVideoFrame class and
|
||||||
|
* passes it to the Agora SDK with the `format` parameter in AgoraVideoFormat.
|
||||||
|
*
|
||||||
|
* Call \ref setExternalVideoSource:useTexture:pushMode: setExternalVideoSource
|
||||||
|
* and set the `pushMode` parameter as `YES` before calling this method.
|
||||||
|
* @note
|
||||||
|
* In the Communication profile, this method does not support pushing textured
|
||||||
|
* video frames.
|
||||||
|
* @param frame Video frame containing the SDK's encoded video data to be
|
||||||
|
* pushed: #AgoraVideoFrame.
|
||||||
|
* @param videoTrackId The id of the video track.
|
||||||
|
* @return
|
||||||
|
* - `YES`: Success.
|
||||||
|
* - `NO`: Failure.
|
||||||
|
*/
|
||||||
|
- (BOOL)pushExternalVideoFrame:(AgoraVideoFrame * _Nonnull)frame videoTrackId:(NSUInteger)videoTrackId NS_SWIFT_NAME(pushExternalVideoFrame(_:videoTrackId:));
|
||||||
|
|
||||||
|
/** Gets the user information by passing in the user account.
|
||||||
|
|
||||||
|
* After a remote user joins the channel, the SDK gets the user ID and user account of the remote user, caches them in a mapping table object (`AgoraUserInfo`), and triggers the [didUpdatedUserInfo]([AgoraRtcEngineDelegate rtcEngine:didUpdatedUserInfo:withUid:]) callback on the local client.
|
||||||
|
|
||||||
|
* After receiving the [didUpdatedUserInfo]([AgoraRtcEngineDelegate rtcEngine:didUpdatedUserInfo:withUid:]) callback, you can call this method to get the user ID of the remote user from the `userInfo` object by passing in the user account.
|
||||||
|
|
||||||
|
* @param userAccount The user account of the user. Ensure that you set this parameter.
|
||||||
|
* @param connection \ref AgoraRtcConnection by channelId and uid combine
|
||||||
|
* @return An [AgoraUserInfo](AgoraUserInfo) object that contains the user account and user ID of the user.
|
||||||
|
*/
|
||||||
|
- (AgoraUserInfo* _Nullable)getUserInfoByUserAccountEx:(NSString* _Nonnull)userAccount
|
||||||
|
connection:(AgoraRtcConnection * _Nonnull)connection
|
||||||
|
withError:(AgoraErrorCode* _Nullable)error NS_SWIFT_NAME(getUserInfo(byUserAccountEx:connection:withError:));
|
||||||
|
|
||||||
|
/** Gets the user information by passing in the user ID.
|
||||||
|
*
|
||||||
|
* After a remote user joins the channel, the SDK gets the user ID and user account of the remote user,
|
||||||
|
* caches them in a mapping table object (`userInfo`), and triggers the \ref agora::rtc::IRtcEngineEventHandler::onUserInfoUpdated "onUserInfoUpdated" callback on the local client.
|
||||||
|
*
|
||||||
|
* After receiving the \ref agora::rtc::IRtcEngineEventHandler::onUserInfoUpdated "onUserInfoUpdated" callback, you can call this method to get the user account of the remote user
|
||||||
|
* from the `userInfo` object by passing in the user ID.
|
||||||
|
*
|
||||||
|
* @param uid The user ID of the remote user. Ensure that you set this parameter.
|
||||||
|
* @param connection \ref AgoraRtcConnection by channelId and uid combine
|
||||||
|
* @return An [AgoraUserInfo](AgoraUserInfo) object that contains the user account and user ID of the user.
|
||||||
|
*/
|
||||||
|
- (AgoraUserInfo* _Nullable)getUserInfoByUidEx:(NSUInteger)uid
|
||||||
|
connection:(AgoraRtcConnection * _Nonnull)connection
|
||||||
|
withError:(AgoraErrorCode* _Nullable)error NS_SWIFT_NAME(getUserInfo(byUidEx:connection:withError:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the connection state of the SDK.
|
||||||
|
*
|
||||||
|
* @param connection \ref AgoraRtcConnection by channelId and uid combine
|
||||||
|
*
|
||||||
|
* @return The connection state. See \ref AgoraConnectionState.
|
||||||
|
*/
|
||||||
|
- (AgoraConnectionState)getConnectionStateEx:(AgoraRtcConnection * _Nonnull)connection NS_SWIFT_NAME(getConnectionStateEx(_:));
|
||||||
|
|
||||||
|
#if (!(TARGET_OS_IPHONE) && (TARGET_OS_MAC))
|
||||||
|
/** Enables loopback sampling. (macOS only)
|
||||||
|
* If you enable loopback sampling, the output of the sound card is mixed into the audio stream sent to the other end.
|
||||||
|
* You can call this method either before or after joining a channel.
|
||||||
|
|
||||||
|
* *Note:**
|
||||||
|
* macOS does not support loopback sampling of the default sound card. If you need to use this method,
|
||||||
|
* please use a virtual sound card and pass its name to the `deviceName` parameter. Agora has tested and recommends using soundflower.
|
||||||
|
|
||||||
|
* @param enabled Sets whether to enable/disable loopback sampling.
|
||||||
|
* YES: Enable loopback sampling.
|
||||||
|
* NO: (Default) Disable loopback sampling.
|
||||||
|
|
||||||
|
* @param deviceName Pointer to the device name of the sound card. The default value is nil (default sound card).
|
||||||
|
* If you use a virtual sound card like "Soundflower", set this parameter as the name of the sound card, "Soundflower",
|
||||||
|
* and the SDK will find the corresponding sound card and start capturing.
|
||||||
|
* @param connection \ref AgoraRtcConnection by channelId and uid combine
|
||||||
|
* @return
|
||||||
|
* 0: Success.
|
||||||
|
* < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)enableLoopbackRecordingEx:(BOOL)enabled
|
||||||
|
deviceName:(NSString* _Nullable)deviceName
|
||||||
|
connection:(AgoraRtcConnection * _Nonnull)connection NS_SWIFT_NAME(enableLoopbackRecordingEx(_:deviceName:connection:));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adjusts the recording volume.
|
||||||
|
*
|
||||||
|
* @param volume The recording volume, which ranges from 0 to 400:
|
||||||
|
* - 0 : Mute the recording volume.
|
||||||
|
* - 100: The original volume.
|
||||||
|
* - 400: (Maximum) Four times the original volume with signal clipping protection.
|
||||||
|
*
|
||||||
|
* @param connection \ref AgoraRtcConnection by channelId and uid combine
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0 : Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)adjustRecordingSignalVolumeEx:(NSInteger)volume
|
||||||
|
connection:(AgoraRtcConnection* _Nonnull)connection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mute or resume recording signal volume.
|
||||||
|
*
|
||||||
|
* @param mute Determines whether to mute or resume the recording signal volume.
|
||||||
|
* - YES: Mute the recording signal volume.
|
||||||
|
* - NO: (Default) Resume the recording signal volume.
|
||||||
|
*
|
||||||
|
* @param connection \ref AgoraRtcConnection by channelId and uid combine
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0 : Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)muteRecordingSignalEx:(BOOL)mute
|
||||||
|
connection:(AgoraRtcConnection* _Nonnull)connection;
|
||||||
|
|
||||||
|
/** Adjust the playback signal volume of a specified remote user.
|
||||||
|
|
||||||
|
You can call this method as many times as necessary to adjust the playback volume of different remote users, or to repeatedly adjust the playback volume of the same remote user.
|
||||||
|
|
||||||
|
**Note**
|
||||||
|
|
||||||
|
- The playback volume here refers to the mixed volume of a specified remote user.
|
||||||
|
- This method can only adjust the playback volume of one specified remote user at a time. To adjust the playback volume of different remote users, call the method as many times, once for each remote user.
|
||||||
|
|
||||||
|
@param uid The ID of the remote user.
|
||||||
|
@param volume The playback volume of the specified remote user. The value
|
||||||
|
ranges between 0 and 400, including the following:
|
||||||
|
|
||||||
|
- 0: Mute.
|
||||||
|
- 100: (Default) Original volume.
|
||||||
|
@param connection \ref AgoraRtcConnection by channelId and uid combine
|
||||||
|
|
||||||
|
@return
|
||||||
|
- 0: Success.
|
||||||
|
- < 0: Failure.
|
||||||
|
*/
|
||||||
|
|
||||||
|
- (int)adjustUserPlaybackSignalVolumeEx:(NSUInteger)uid
|
||||||
|
volume:(NSInteger)volume
|
||||||
|
connection:(AgoraRtcConnection* _Nonnull)connection;
|
||||||
|
|
||||||
|
- (int)sendCustomReportMessageEx:(NSString * _Nullable)messageId
|
||||||
|
category:(NSString * _Nullable)category
|
||||||
|
event:(NSString * _Nullable)event
|
||||||
|
label:(NSString * _Nullable)label
|
||||||
|
value:(NSInteger)value
|
||||||
|
connection:(AgoraRtcConnection * _Nonnull)connection NS_SWIFT_NAME(sendCustomReportMessageEx(_:category:event:label:value:connection:));
|
||||||
|
|
||||||
|
- (int)enableAudioVolumeIndicationEx:(NSInteger)interval
|
||||||
|
smooth:(NSInteger)smooth
|
||||||
|
reportVad:(BOOL)reportVad
|
||||||
|
connection:(AgoraRtcConnection* _Nonnull)connection NS_SWIFT_NAME(enableAudioVolumeIndicationEx(_:smooth:reportVad:connection:));
|
||||||
|
|
||||||
|
/** 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.
|
||||||
|
|
||||||
|
**Note:**
|
||||||
|
|
||||||
|
- Ensure that you call this method after joining a channel. For this method to work, enable stereo panning for remote users by calling [enableSoundPositionIndication]([AgoraRtcEngineKit enableSoundPositionIndication:]) before joining a channel.
|
||||||
|
This method requires hardware support.
|
||||||
|
- For the best effect, we recommend using the following audio output devices:
|
||||||
|
- (iOS) A stereo headset.
|
||||||
|
- (macOS) A stereo loudspeaker.
|
||||||
|
@param uid The ID of the remote user.
|
||||||
|
@param pan The sound position of the remote user. The value ranges from -1.0 to 1.0:
|
||||||
|
|
||||||
|
* 0.0: (default) the remote sound comes from the front.
|
||||||
|
* -1.0: the remote sound comes from the left.
|
||||||
|
* 1.0: the remote sound comes from the right.
|
||||||
|
|
||||||
|
@param gain Gain of the remote user. The value ranges from 0.0 to 100.0. The default value is 100.0 (the original gain of the remote user). The smaller the value, the less the gain.
|
||||||
|
@param connection \ref AgoraRtcConnection by channelId and uid combine
|
||||||
|
|
||||||
|
@return * 0: Success.
|
||||||
|
* < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)setRemoteVoicePositionEx:(NSUInteger)uid
|
||||||
|
pan:(double)pan
|
||||||
|
gain:(double)gain
|
||||||
|
connection:(AgoraRtcConnection * _Nonnull)connection NS_SWIFT_NAME(setRemoteVoicePositionEx(_:pan:gain:connection:));
|
||||||
|
|
||||||
|
/** Sets spatial audio parameters of a remote user.
|
||||||
|
|
||||||
|
When the local user calls this method to set the spatial audio parameters 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 spatial.
|
||||||
|
|
||||||
|
**Note:**
|
||||||
|
|
||||||
|
- For the best effect, we recommend using the following audio output devices:
|
||||||
|
- (iOS) A stereo headset.
|
||||||
|
- (macOS) A stereo loudspeaker.
|
||||||
|
@param uid The ID of the remote user.
|
||||||
|
@param params The spatial audio parameters of the remote user.
|
||||||
|
@param connection \ref AgoraRtcConnection by channelId and uid combine
|
||||||
|
|
||||||
|
@return * 0: Success.
|
||||||
|
* < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)setRemoteUserSpatialAudioParamsEx:(NSUInteger)uid
|
||||||
|
params:(AgoraSpatialAudioParams* _Nonnull)params
|
||||||
|
connection:(AgoraRtcConnection* _Nonnull)connection NS_SWIFT_NAME(setRemoteUserSpatialAudioParamsEx(_:params:connection:));
|
||||||
|
|
||||||
|
/** Adds a watermark image to the local video.
|
||||||
|
|
||||||
|
This method adds a PNG watermark image to the local video in the interactive live streaming. Once the watermark image is added, all the audience in the channel (CDN audience included), and the capturing device can see and capture it. Agora supports adding only one watermark image onto the local video, and the newly watermark image replaces the previous one.
|
||||||
|
|
||||||
|
The watermark position depends on the settings in the [setVideoEncoderConfiguration]([AgoraRtcEngineKit setVideoEncoderConfiguration:]) method:
|
||||||
|
|
||||||
|
- If the orientation mode of the encoding video is AgoraVideoOutputOrientationModeFixedLandscape, or the landscape mode in AgoraVideoOutputOrientationModeAdaptative, the watermark uses the landscape orientation.
|
||||||
|
- If the orientation mode of the encoding video is AgoraVideoOutputOrientationModeFixedPortrait, or the portrait mode in AgoraVideoOutputOrientationModeAdaptative, the watermark uses the portrait orientation.
|
||||||
|
- When setting the watermark position, the region must be less than the dimensions set in the [setVideoEncoderConfiguration]([AgoraRtcEngineKit setVideoEncoderConfiguration:]) method. Otherwise, the watermark image will be cropped.
|
||||||
|
|
||||||
|
**Note**
|
||||||
|
|
||||||
|
- Ensure that you have called the [enableVideo]([AgoraRtcEngineKit enableVideo]) method to enable the video module before calling this method.
|
||||||
|
- If you only want to add a watermark image to the local video for the audience in the CDN live streaming channel to see and capture, you can call this method or the [setLiveTranscoding]([AgoraRtcEngineKit setLiveTranscoding:]) method.
|
||||||
|
- This method supports adding a watermark image in the PNG file format only. Supported pixel formats of the PNG image are RGBA, RGB, Palette, Gray, and Alpha_gray.
|
||||||
|
- If the dimensions of the PNG image differ from your settings in this method, the image will be cropped or zoomed to conform to your settings.
|
||||||
|
- If you have enabled the local video preview by calling the [startPreview]([AgoraRtcEngineKit startPreview]) method, you can use the `visibleInPreview` member in the WatermarkOptions class to set whether or not the watermark is visible in preview.
|
||||||
|
- If you have enabled the mirror mode for the local video, the watermark on the local video is also mirrored. To avoid mirroring the watermark, Agora recommends that you do not use the mirror and watermark functions for the local video at the same time. You can implement the watermark function in your application layer.
|
||||||
|
|
||||||
|
@param url The local file path of the watermark image to be added. This method supports adding a watermark image from the local file path. If the watermark image to be added is in the project file, you need to change the image's Type from PNG image to Data in the Xcode property, otherwise, the Agora Native SDK cannot recognize the image.
|
||||||
|
@param options The options of the watermark image to be added. See WatermarkOptions.
|
||||||
|
@param connection \ref AgoraRtcConnection by channelId and uid combine
|
||||||
|
|
||||||
|
@return * 0: Success.
|
||||||
|
* < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)addVideoWatermarkEx:(NSURL* _Nonnull)url options:(WatermarkOptions* _Nonnull)options connection:(AgoraRtcConnection * _Nonnull)connection NS_SWIFT_NAME(addVideoWatermarkEx(_:options:connection:));
|
||||||
|
|
||||||
|
/** Clears the watermark image on the video stream.
|
||||||
|
@param connection \ref AgoraRtcConnection by channelId and uid combine
|
||||||
|
|
||||||
|
@return * 0: Success.
|
||||||
|
* < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)clearVideoWatermarkEx:(AgoraRtcConnection * _Nonnull)connection NS_SWIFT_NAME(clearVideoWatermarkEx(_:));
|
||||||
|
|
||||||
|
/**-----------------------------------------------------------------------------
|
||||||
|
* @name Data Steam
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
/** Creates a data stream.
|
||||||
|
*
|
||||||
|
* Each user can create up to five data streams during the lifecycle of the `AgoraRtcEngineKit`.
|
||||||
|
*
|
||||||
|
* @note Set both the `reliable` and `ordered` parameters to `YES` or `NO`. Do not set one as `YES` and the other as `NO`.
|
||||||
|
*
|
||||||
|
* @param streamId ID of the created data stream.
|
||||||
|
* @param reliable Sets whether or not the recipients are guaranteed to receive the data stream from the sender within five seconds:
|
||||||
|
* - YES: The recipients receive the data stream from the sender within five seconds. If the recipient does not receive the data stream within five seconds, an error is reported to the app.
|
||||||
|
* - NO: There is no guarantee that the recipients receive the data stream within five seconds and no error message is reported for any delay or missing data stream.
|
||||||
|
*
|
||||||
|
* @param ordered Sets whether or not the recipients receive the data stream in the sent order:
|
||||||
|
* - YES: The recipients receive the data stream in the sent order.
|
||||||
|
* - NO: The recipients do not receive the data stream in the sent order.
|
||||||
|
* @param connection \ref AgoraRtcConnection by channelId and uid combine.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)createDataStreamEx:(NSInteger * _Nonnull)streamId
|
||||||
|
reliable:(BOOL)reliable
|
||||||
|
ordered:(BOOL)ordered
|
||||||
|
connection:(AgoraRtcConnection * _Nonnull)connection NS_SWIFT_NAME(createDataStreamEx(_:reliable:ordered:connection:));
|
||||||
|
/** Creates a data stream.
|
||||||
|
|
||||||
|
Each user can create up to five data streams during the lifecycle of the [AgoraRtcChannel](AgoraRtcChannel).
|
||||||
|
|
||||||
|
@param streamId ID of the created data stream.
|
||||||
|
@param config the config of data stream.
|
||||||
|
@param connection \ref AgoraRtcConnection by channelId and uid combine.
|
||||||
|
@return * 0: Success.
|
||||||
|
* < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)createDataStreamEx:(NSInteger * _Nonnull)streamId
|
||||||
|
config:(AgoraDataStreamConfig * _Nonnull)config
|
||||||
|
connection:(AgoraRtcConnection * _Nonnull)connection NS_SWIFT_NAME(createDataStreamEx(_:config:connection:));
|
||||||
|
|
||||||
|
/** Sends data stream messages to all users in a channel.
|
||||||
|
|
||||||
|
The SDK has the following restrictions on this method:
|
||||||
|
|
||||||
|
- Up to 60 packets can be sent per second in a channel with each packet having a maximum size of 1 KB.
|
||||||
|
- Each client can send up to 30 KB of data per second.
|
||||||
|
- Each user can have up to five data streams simultaneously.
|
||||||
|
|
||||||
|
If the remote user receives the data stream within five seconds, the SDK triggers the \ref AgoraRtcEngineDelegate.rtcEngine:receiveStreamMessageFromUid:streamId:data: receiveStreamMessageFromUid callback on the remote client, from which the remote user gets the stream message.
|
||||||
|
|
||||||
|
If the remote user does not receive the data stream within five seconds, the SDK triggers the \ref AgoraRtcEngineDelegate.rtcEngine:didOccurStreamMessageErrorFromUid:streamId:error:missed:cached: didOccurStreamMessageErrorFromUid callback on the remote client.
|
||||||
|
|
||||||
|
@note
|
||||||
|
- This method applies only to the Communication profile or to the hosts in the live interactive streaming profile. If an audience in the live interactive streaming profile calls this method, the audience role may be changed to a host.
|
||||||
|
- Ensure that you have created the data stream using \ref createDataStream:reliable:ordered: createDataStream before calling this method.
|
||||||
|
|
||||||
|
@param streamId ID of the sent data stream returned in the `createDataStream` method.
|
||||||
|
@param data Sent data.
|
||||||
|
@param connection \ref AgoraRtcConnection by channelId and uid combine.
|
||||||
|
|
||||||
|
@return
|
||||||
|
- 0: Success.
|
||||||
|
- < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)sendStreamMessageEx:(NSInteger)streamId
|
||||||
|
data:(NSData * _Nonnull)data
|
||||||
|
connection:(AgoraRtcConnection * _Nonnull)connection NS_SWIFT_NAME(sendStreamMessageEx(_:data:connection:));
|
||||||
|
|
||||||
|
/**-----------------------------------------------------------------------------
|
||||||
|
* @name Stream Publish
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the blocklist of subscribe remote stream audio.
|
||||||
|
*
|
||||||
|
* @param blocklist The uid list of users who do not subscribe to audio.
|
||||||
|
* @param connection \ref AgoraRtcConnection by channelId and uid combine.
|
||||||
|
* @note
|
||||||
|
* If uid is in blocklist, the remote user's audio will not be subscribed,
|
||||||
|
* even if muteRemoteAudioStream(uid, false) and muteAllRemoteAudioStreams(false) are operated.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)setSubscribeAudioBlocklistEx:(NSArray <NSNumber *> *_Nonnull)blocklist connection:(AgoraRtcConnection * _Nonnull)connection NS_SWIFT_NAME(setSubscribeAudioBlocklistEx(_:connection:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the allowlist of subscribe remote stream audio.
|
||||||
|
*
|
||||||
|
* @param allowlist The uid list of users who do subscribe to audio.
|
||||||
|
* @param connection \ref AgoraRtcConnection by channelId and uid combine.
|
||||||
|
* @note
|
||||||
|
* If uid is in allowlist, the remote user's audio will be subscribed,
|
||||||
|
* even if muteRemoteAudioStream(uid, true) and muteAllRemoteAudioStreams(true) are operated.
|
||||||
|
*
|
||||||
|
* If a user is in the blocklist and allowlist at the same time, the user will not subscribe to audio.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)setSubscribeAudioAllowlistEx:(NSArray <NSNumber *> *_Nonnull)allowlist connection:(AgoraRtcConnection * _Nonnull)connection NS_SWIFT_NAME(setSubscribeAudioAllowlistEx(_:connection:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the blocklist of subscribe remote stream video.
|
||||||
|
*
|
||||||
|
* @param blocklist The uid list of users who do not subscribe to video.
|
||||||
|
* @param connection \ref AgoraRtcConnection by channelId and uid combine.
|
||||||
|
* @note
|
||||||
|
* If uid is in blocklist, the remote user's video will not be subscribed,
|
||||||
|
* even if muteRemoteVideoStream(uid, false) and muteAllRemoteVideoStreams(false) are operated.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)setSubscribeVideoBlocklistEx:(NSArray <NSNumber *> *_Nonnull)blocklist connection:(AgoraRtcConnection * _Nonnull)connection NS_SWIFT_NAME(setSubscribeVideoBlocklistEx(_:connection:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the allowlist of subscribe remote stream video.
|
||||||
|
*
|
||||||
|
* @param allowlist The uid list of users who do subscribe to video.
|
||||||
|
* @param connection \ref AgoraRtcConnection by channelId and uid combine.
|
||||||
|
* @note
|
||||||
|
* If uid is in whitelist, the remote user's video will be subscribed,
|
||||||
|
* even if muteRemoteVideoStream(uid, true) and muteAllRemoteVideoStreams(true) are operated.
|
||||||
|
*
|
||||||
|
* If a user is in the blocklist and allowlist at the same time, the user will not subscribe to video.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)setSubscribeVideoAllowlistEx:(NSArray <NSNumber *> *_Nonnull)allowlist connection:(AgoraRtcConnection * _Nonnull)connection NS_SWIFT_NAME(setSubscribeVideoAllowlistEx(_:connection:));
|
||||||
|
|
||||||
|
- (NSInteger)takeSnapshotEx:(AgoraRtcConnection * _Nonnull)connection uid:(NSInteger)uid filePath:(NSString* _Nonnull)filePath NS_SWIFT_NAME(takeSnapshotEx(_:uid:filePath:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @technical preview
|
||||||
|
*/
|
||||||
|
- (int)sendAudioMetadataEx:(AgoraRtcConnection * _Nonnull)connection metadata:(NSData * _Nonnull)metadata NS_SWIFT_NAME(sendAudioMetadataEx(_:metadata:));
|
||||||
|
|
||||||
|
- (int)enableContentInspectEx:(BOOL)enabled config:(AgoraContentInspectConfig* _Nonnull)config connection:(AgoraRtcConnection * _Nonnull)connection NS_SWIFT_NAME(enableContentInspectEx(_:config:connection:));
|
||||||
|
|
||||||
|
/** Publishes the local stream without transcoding to a specified CDN live RTMP address. (CDN live only.)
|
||||||
|
*
|
||||||
|
* @param url The CDN streaming URL in the RTMP format. The maximum length of this parameter is 1024 bytes.
|
||||||
|
* @param connection AgoraRtcConnection.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)startRtmpStreamWithoutTranscodingEx:(NSString* _Nonnull)url
|
||||||
|
connection:(AgoraRtcConnection * _Nonnull)connection NS_SWIFT_NAME(startRtmpStreamWithoutTranscodingEx(_:connection:));
|
||||||
|
|
||||||
|
/** Publishes the local stream with transcoding to a specified CDN live RTMP address. (CDN live only.)
|
||||||
|
*
|
||||||
|
* @param url The CDN streaming URL in the RTMP format. The maximum length of this parameter is 1024 bytes.
|
||||||
|
* @param transcoding Sets the CDN live audio/video transcoding settings. See LiveTranscoding.
|
||||||
|
* @param connection AgoraRtcConnection.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)startRtmpStreamWithTranscodingEx:(NSString* _Nonnull)url
|
||||||
|
transcoding:(AgoraLiveTranscoding* _Nullable)transcoding
|
||||||
|
connection:(AgoraRtcConnection * _Nonnull)connection NS_SWIFT_NAME(startRtmpStreamWithTranscodingEx(_:transcoding:connection:));
|
||||||
|
|
||||||
|
/** Update the video layout and audio settings for CDN live. (CDN live only.)
|
||||||
|
* @note This method applies to Live Broadcast only.
|
||||||
|
*
|
||||||
|
* @param transcoding Sets the CDN live audio/video transcoding settings. See LiveTranscoding.
|
||||||
|
* @param connection AgoraRtcConnection.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)updateRtmpTranscodingEx:(AgoraLiveTranscoding* _Nullable)transcoding
|
||||||
|
connection:(AgoraRtcConnection * _Nonnull)connection NS_SWIFT_NAME(updateRtmpTranscodingEx(_:connection:));
|
||||||
|
|
||||||
|
/** Stop an RTMP stream with transcoding or without transcoding from the CDN. (CDN live only.)
|
||||||
|
* @param url The RTMP URL address to be removed. The maximum length of this parameter is 1024 bytes.
|
||||||
|
* @param connection AgoraRtcConnection.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)stopRtmpStreamEx:(NSString* _Nonnull)url
|
||||||
|
connection:(AgoraRtcConnection * _Nonnull)connection NS_SWIFT_NAME(stopRtmpStreamEx(_:connection:));
|
||||||
|
|
||||||
|
/** Starts to relay media streams across channels.
|
||||||
|
*
|
||||||
|
* @param configuration The configuration of the media stream relay:AgoraChannelMediaRelayConfiguration.
|
||||||
|
* @param connection AgoraRtcConnection.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)startChannelMediaRelayEx:(AgoraChannelMediaRelayConfiguration * _Nonnull)config connection:(AgoraRtcConnection * _Nonnull)connection NS_SWIFT_NAME(startChannelMediaRelayEx(_:connection:));
|
||||||
|
|
||||||
|
/** Updates the channels for media stream relay
|
||||||
|
* @param configuration The media stream relay configuration: AgoraChannelMediaRelayConfiguration.
|
||||||
|
* @param connection AgoraRtcConnection.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)updateChannelMediaRelayEx:(AgoraChannelMediaRelayConfiguration * _Nonnull)config connection:(AgoraRtcConnection * _Nonnull)connection NS_SWIFT_NAME(updateChannelMediaRelayEx(_:connection:));
|
||||||
|
|
||||||
|
/** Stops the media stream relay.
|
||||||
|
*
|
||||||
|
* Once the relay stops, the host quits all the destination
|
||||||
|
* channels.
|
||||||
|
*
|
||||||
|
* @param connection AgoraRtcConnection.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)stopChannelMediaRelayEx:(AgoraRtcConnection * _Nonnull)connection NS_SWIFT_NAME(stopChannelMediaRelayEx(_:));
|
||||||
|
|
||||||
|
/** pause the channels for media stream relay.
|
||||||
|
*
|
||||||
|
* @param connection AgoraRtcConnection.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)pauseAllChannelMediaRelayEx:(AgoraRtcConnection * _Nonnull)connection NS_SWIFT_NAME(pauseAllChannelMediaRelayEx(_:));
|
||||||
|
|
||||||
|
/** resume the channels for media stream relay.
|
||||||
|
*
|
||||||
|
* @param connection AgoraRtcConnection.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)resumeAllChannelMediaRelayEx:(AgoraRtcConnection * _Nonnull)connection NS_SWIFT_NAME(resumeAllChannelMediaRelayEx(_:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Start tracing media rendering events.
|
||||||
|
@since v4.1.1
|
||||||
|
@discussion
|
||||||
|
- SDK will trace media rendering events when this API is called.
|
||||||
|
- The tracing result can be obtained through callback `[AgoraRtcEngineDelegate rtcEngine:videoRenderingTracingResultOfUid:currentEvent:tracingInfo:]`
|
||||||
|
@param connection AgoraRtcConnection.
|
||||||
|
@note
|
||||||
|
- By default, SDK will trace media rendering events when join channel.
|
||||||
|
- The start point of event tracing will be reset after leaving channel.
|
||||||
|
@return
|
||||||
|
- 0: Success.
|
||||||
|
- < 0: Failure.
|
||||||
|
- `-2(AgoraErrorCodeInvalidArgument)`: The parameter is invalid. Check the channel ID and local uid set by parameter `connection`.
|
||||||
|
- `-7(AgoraErrorCodeNotInitialized)`: The SDK is not initialized.
|
||||||
|
*/
|
||||||
|
- (int)startMediaRenderingTracingEx:(AgoraRtcConnection * _Nonnull)connection NS_SWIFT_NAME(startMediaRenderingTracingEx(_:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds multiple SDK delegate.
|
||||||
|
*
|
||||||
|
* @param delegate The AgoraRtcEngineDelegate object.
|
||||||
|
* @param connection The AgoraRtcConnection object.
|
||||||
|
*/
|
||||||
|
- (void)addDelegateEx:(id<AgoraRtcEngineDelegate> _Nonnull)delegate connection:(AgoraRtcConnection * _Nonnull)connection NS_SWIFT_NAME(addDelegateEx(_:connection:));
|
||||||
|
|
||||||
|
/**-----------------------------------------------------------------------------
|
||||||
|
* @name Built-in Encryption
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** Enables/Disables the built-in encryption.
|
||||||
|
|
||||||
|
In scenarios requiring high security, Agora recommends calling enableEncryption to enable the built-in encryption before joining a channel.
|
||||||
|
|
||||||
|
All users in the same channel must use the same encryption mode and encryption key. Once all users leave the channel, the encryption key of this channel is automatically cleared.
|
||||||
|
|
||||||
|
**Note**
|
||||||
|
|
||||||
|
- If you enable the built-in encryption, you cannot use the RTMP streaming function.
|
||||||
|
|
||||||
|
@param enabled Whether to enable the built-in encryption:
|
||||||
|
|
||||||
|
- YES: Enable the built-in encryption.
|
||||||
|
- NO: Disable the built-in encryption.
|
||||||
|
|
||||||
|
@param config Configurations of built-in encryption schemas. See AgoraEncryptionConfig.
|
||||||
|
@param connection \ref AgoraRtcConnection by channelId and uid combine
|
||||||
|
|
||||||
|
@return - 0: Success.
|
||||||
|
- < 0: Failure.
|
||||||
|
|
||||||
|
- -2 (`AgoraErrorCodeInvalidArgument`): An invalid parameter is used. Set the parameter with a valid value.
|
||||||
|
- -7 (`AgoraErrorCodeNotInitialized`): The SDK is not initialized. Initialize the `AgoraRtcEngineKit` instance before calling this method.
|
||||||
|
- -4 (`AgoraErrorCodeNotSupported`): The encryption mode is incorrect or the SDK fails to load the external encryption library. Check the enumeration or reload the external encryption library.
|
||||||
|
*/
|
||||||
|
- (int)enableEncryptionEx:(bool)enabled encryptionConfig:(AgoraEncryptionConfig *_Nonnull)config connection:(AgoraRtcConnection* _Nonnull)connection NS_SWIFT_NAME(enableEncryptionEx(_:encryptionConfig:connection:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes multiple SDK delegate.
|
||||||
|
*
|
||||||
|
* @param delegate The AgoraRtcEngineDelegate object.
|
||||||
|
* @param connection The AgoraRtcConnection object.
|
||||||
|
*/
|
||||||
|
- (void)removeDelegateEx:(id<AgoraRtcEngineDelegate> _Nonnull)delegate connection:(AgoraRtcConnection * _Nonnull)connection NS_SWIFT_NAME(removeDelegateEx(_:connection:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the current call ID.
|
||||||
|
*
|
||||||
|
* When a user joins a channel, a call ID is generated to identify the call.
|
||||||
|
*
|
||||||
|
* After a call ends, you can call `rate` or `complain` to gather feedback from
|
||||||
|
* your customer.
|
||||||
|
*
|
||||||
|
* @param connection The AgoraRtcConnection object.
|
||||||
|
* @return The call ID if the method call is successful.
|
||||||
|
*/
|
||||||
|
- (NSString * _Nullable)getCallIdEx:(AgoraRtcConnection * _Nonnull)connection NS_SWIFT_NAME(getCallIdEx(_:));
|
||||||
|
|
||||||
|
@end
|
||||||
|
NS_ASSUME_NONNULL_END
|
|
@ -0,0 +1,19 @@
|
||||||
|
//
|
||||||
|
// AgoraRtcKit.h
|
||||||
|
// AgoraRtcKit
|
||||||
|
//
|
||||||
|
// Copyright (c) 2018 Agora. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <AgoraRtcKit/AgoraRtcEngineKit.h>
|
||||||
|
#import <AgoraRtcKit/AgoraRtcEngineKitEx.h>
|
||||||
|
#import <AgoraRtcKit/AgoraBaseDelegate.h>
|
||||||
|
#import <AgoraRtcKit/AgoraRtcAudioSpectrumDelegate.h>
|
||||||
|
#import <AgoraRtcKit/AgoraMediaFilterEventDelegate.h>
|
||||||
|
#import <AgoraRtcKit/AgoraConstants.h>
|
||||||
|
#import <AgoraRtcKit/AgoraEnumerates.h>
|
||||||
|
#import <AgoraRtcKit/AgoraObjects.h>
|
||||||
|
#import <AgoraRtcKit/AgoraRtcEngineDelegate2.h>
|
||||||
|
#import <AgoraRtcKit/AgoraRtcMediaPlayerProtocol.h>
|
||||||
|
#import <AgoraRtcKit/AgoraSpatialAudioKit.h>
|
||||||
|
#import <AgoraRtcKit/AgoraMusicContentCenter.h>
|
|
@ -0,0 +1,551 @@
|
||||||
|
//
|
||||||
|
// AgoraRtcMediaPlayerProtocol.h
|
||||||
|
// AgoraRtcMediaPlayerProtocol
|
||||||
|
//
|
||||||
|
// Copyright (c) 2020 Agora. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import "AgoraObjects.h"
|
||||||
|
#import "AgoraRtcAudioSpectrumDelegate.h"
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
typedef UIView View;
|
||||||
|
#elif TARGET_OS_MAC
|
||||||
|
#import <AppKit/AppKit.h>
|
||||||
|
typedef NSView View;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
@protocol AgoraRtcMediaPlayerAudioFrameDelegate;
|
||||||
|
@protocol AgoraRtcMediaPlayerVideoFrameDelegate;
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
@protocol AgoraRtcMediaPlayerProtocol <NSObject>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get unique media player id of the media player entity.
|
||||||
|
* @return
|
||||||
|
* - >= 0: The mediaPlayerId of this media player entity.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)getMediaPlayerId NS_SWIFT_NAME(getMediaPlayerId());
|
||||||
|
/**
|
||||||
|
* Opens a media file with a specified URL.
|
||||||
|
* @param url The URL of the media file that you want to play.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)open:(NSString *)url startPos:(NSInteger)startPos NS_SWIFT_NAME(open(_:startPos:));
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens a media file with MediaSource
|
||||||
|
* @param source see `AgoraMediaSource`
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)openWithMediaSource:(AgoraMediaSource *)source NS_SWIFT_NAME(open(with:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open the Agora CDN media source.
|
||||||
|
* @param src The src of the media file that you want to play.
|
||||||
|
* @param startPos The playback position (ms).
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)openWithAgoraCDNSrc:(NSString *)src startPos:(NSInteger)startPos NS_SWIFT_NAME(open(withAgoraCDNSrc:startPos:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the number of Agora CDN lines.
|
||||||
|
* @return
|
||||||
|
* - > 0: number of CDN.
|
||||||
|
* - <= 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)getAgoraCDNLineCount NS_SWIFT_NAME(getAgoraCDNLineCount());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Switch Agora CDN lines.
|
||||||
|
* @param index Specific line.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)switchAgoraCDNLineByIndex:(int)index NS_SWIFT_NAME(switchAgoraCDNLine(by:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the line of the current CDN.
|
||||||
|
* @return
|
||||||
|
* - >= 0: Specific line.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)getCurrentAgoraCDNIndex NS_SWIFT_NAME(getCurrentAgoraCDNIndex());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable automatic CDN line switching.
|
||||||
|
* @param enable Whether enable.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)enableAutoSwitchAgoraCDN:(BOOL)enable NS_SWIFT_NAME(enableAutoSwitchAgoraCDN(_:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the CDN source token and timestamp.
|
||||||
|
* @param token token.
|
||||||
|
* @param ts ts.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)renewAgoraCDNSrcToken:(NSString *)token ts:(NSInteger)ts NS_SWIFT_NAME(renewAgoraCDNSrcToken(_:ts:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Switch the CDN source.
|
||||||
|
* @param src Specific line.
|
||||||
|
* @param syncPts Live streaming must be set to false.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)switchAgoraCDNSrc:(NSString *)src syncPts:(BOOL)syncPts NS_SWIFT_NAME(switchAgoraCDNSrc(_:syncPts:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plays the media file.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)play NS_SWIFT_NAME(play());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pauses playing the media file.
|
||||||
|
*/
|
||||||
|
- (int)pause NS_SWIFT_NAME(pause());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stops playing the current media file.
|
||||||
|
*/
|
||||||
|
- (int)stop NS_SWIFT_NAME(stop());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resumes playing the media file.
|
||||||
|
*/
|
||||||
|
- (int)resume NS_SWIFT_NAME(resume());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the current playback position of the media file.
|
||||||
|
* @param position The new playback position (ms).
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)seekToPosition:(NSInteger)position NS_SWIFT_NAME(seek(toPosition:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the pitch of the current media file.
|
||||||
|
* @param pitch Sets the pitch of the local music file by chromatic scale. The default value is 0,
|
||||||
|
* which means keeping the original pitch. The value ranges from -12 to 12, and the pitch value
|
||||||
|
* between consecutive values is a chromatic value. The greater the absolute value of this
|
||||||
|
* parameter, the higher or lower the pitch of the local music file.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)setAudioPitch:(NSInteger)pitch NS_SWIFT_NAME(setAudioPitch(_:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the duration of the media file.
|
||||||
|
*/
|
||||||
|
- (NSInteger)getDuration NS_SWIFT_NAME(getDuration());
|
||||||
|
/**
|
||||||
|
* Gets the current playback position of the media file.(ms).
|
||||||
|
*/
|
||||||
|
- (NSInteger)getPosition NS_SWIFT_NAME(getPosition());
|
||||||
|
/**
|
||||||
|
* Gets the number of the media streams in the media resource.
|
||||||
|
*/
|
||||||
|
- (NSInteger)getStreamCount NS_SWIFT_NAME(getStreamCount());
|
||||||
|
|
||||||
|
/** Gets the detailed information of the media stream.
|
||||||
|
|
||||||
|
@param index The index of the media stream.
|
||||||
|
|
||||||
|
@return * If the call succeeds, returns the detailed information of the media
|
||||||
|
stream. See AgoraMediaStreamInfo.
|
||||||
|
* If the call fails and returns nil.
|
||||||
|
*/
|
||||||
|
- (AgoraRtcMediaStreamInfo *_Nullable)getStreamByIndex:(int)index NS_SWIFT_NAME(getStreamBy(_:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets whether to loop the media file for playback.
|
||||||
|
* @param loopCount the number of times looping the media file.
|
||||||
|
* - 0: Play the audio effect once.
|
||||||
|
* - 1: Play the audio effect twice.
|
||||||
|
* - -1: Play the audio effect in a loop indefinitely, until stopEffect() or stop() is called.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)setLoopCount:(int)loopCount NS_SWIFT_NAME(setLoopCount(_:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change playback speed
|
||||||
|
* @param speed the enum of playback speed
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)setPlaybackSpeed:(int)speed NS_SWIFT_NAME(setPlaybackSpeed(_:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Select playback audio track of the media file
|
||||||
|
* @param index the index of the audio track in media file
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)selectAudioTrack:(int)index NS_SWIFT_NAME(selectAudioTrack(_:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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_ERROR MEDIA_PLAYER_ERROR}.
|
||||||
|
* - -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
|
||||||
|
*/
|
||||||
|
- (int)selectMultiAudioTrack:(NSInteger)playoutTrackIndex publishTrackIndex:(NSInteger)publishTrackIndex NS_SWIFT_NAME(selectMultiAudioTrack(_:publishTrackIndex:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* take screenshot while playing video
|
||||||
|
* @param filename the filename of screenshot file
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)takeScreenshot:(NSString *)filename NS_SWIFT_NAME(takeScreenshot(_:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* select internal subtitles in video
|
||||||
|
* @param index the index of the internal subtitles
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)selectInternalSubtitle:(int)index NS_SWIFT_NAME(selectInternalSubtitle(_:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set an external subtitle for video
|
||||||
|
* @param url The URL of the subtitle file that you want to load.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)setExternalSubtitle:(NSString *)url NS_SWIFT_NAME(setExternalSubtitle(_:));
|
||||||
|
|
||||||
|
/** Gets current playback state.
|
||||||
|
|
||||||
|
@return * The call succeeds and returns current playback state. See
|
||||||
|
AgoraMediaPlayerState.
|
||||||
|
* The call fails and returns nil.
|
||||||
|
*/
|
||||||
|
- (AgoraMediaPlayerState)getPlayerState NS_SWIFT_NAME(getPlayerState());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Turn mute on or off
|
||||||
|
*
|
||||||
|
* @param isMute Whether the media source is mute.
|
||||||
|
* YES: Yes.
|
||||||
|
* NO: No.
|
||||||
|
* @return mute Whether to mute on
|
||||||
|
*/
|
||||||
|
- (int)mute:(bool)isMute NS_SWIFT_NAME(mute(_:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get mute state
|
||||||
|
*
|
||||||
|
* @return mute Whether is mute on
|
||||||
|
*/
|
||||||
|
- (BOOL)getMute NS_SWIFT_NAME(getMute());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Adjust playback volume
|
||||||
|
*
|
||||||
|
* @param volume The volume value to be adjusted
|
||||||
|
* The volume can be adjusted from 0 to 400:
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
- (int)adjustPlayoutVolume:(int)volume NS_SWIFT_NAME(adjustPlayoutVolume(_:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the current playback volume
|
||||||
|
*
|
||||||
|
* @return volume
|
||||||
|
*/
|
||||||
|
- (int)getPlayoutVolume NS_SWIFT_NAME(getPlayoutVolume());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief adjust publish signal volume
|
||||||
|
*/
|
||||||
|
- (int)adjustPublishSignalVolume:(int)volume NS_SWIFT_NAME(adjustPublishSignalVolume(_:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief get publish signal volume
|
||||||
|
*/
|
||||||
|
- (int)getPublishSignalVolume NS_SWIFT_NAME(getPublishSignalVolume());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Modify player option before opening file or url,
|
||||||
|
* @param [in] key
|
||||||
|
* the option key name
|
||||||
|
* @param [in] value
|
||||||
|
* the option value
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure. See AgoraMediaPlayerError.
|
||||||
|
*/
|
||||||
|
- (int)setPlayerOption:(NSString *)key value:(NSInteger)value NS_SWIFT_NAME(setPlayerOption(_:value:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Modify player option before opening file or url,
|
||||||
|
* @param [in] key
|
||||||
|
* the option key name
|
||||||
|
* @param [in] value
|
||||||
|
* the option value
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure. See AgoraMediaPlayerError.
|
||||||
|
*/
|
||||||
|
- (int)setPlayerOptionString:(NSString *)key value:(NSString *)value NS_SWIFT_NAME(setPlayerOptionString(_:value:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set video rendering view
|
||||||
|
*/
|
||||||
|
- (int)setView:(View *_Nullable)view NS_SWIFT_NAME(setView(_:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set video display mode
|
||||||
|
*
|
||||||
|
* @param mode Video display mode
|
||||||
|
* @return int < 0 on behalf of an error, the value corresponds to one of MEDIA_PLAYER_ERROR
|
||||||
|
*/
|
||||||
|
- (int)setRenderMode:(AgoraMediaPlayerRenderMode)mode NS_SWIFT_NAME(setRenderMode(_:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current play src.
|
||||||
|
* @return
|
||||||
|
* - current play src of raw bytes.
|
||||||
|
*/
|
||||||
|
- (NSString *)getPlaySrc NS_SWIFT_NAME(getPlaySrc());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Switch the media source when open a media through "open" API
|
||||||
|
* @param src Specific src.
|
||||||
|
* @param syncPts Live streaming must be set to false.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)switchSrc:(NSString *)src syncPts:(BOOL)syncPts NS_SWIFT_NAME(switchSrc(_:syncPts:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Preload a media source
|
||||||
|
* @param src Specific src.
|
||||||
|
* @param startPos The starting position (ms) for playback. Default value is 0.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)preloadSrc:(NSString *)src startPos:(int)startPos NS_SWIFT_NAME(preloadSrc(_:startPos:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* unload a media source
|
||||||
|
* @param src Specific src.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)unloadSrc:(NSString *)src NS_SWIFT_NAME(unloadSrc(_:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Play a pre-loaded media source
|
||||||
|
* @param src Specific src.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)playPreloadedSrc:(NSString *)src NS_SWIFT_NAME(playPreloadedSrc(_:));
|
||||||
|
|
||||||
|
/** Set dual-mono output mode of the music file.
|
||||||
|
@param mode The audio dual mono mode. See AgoraAudioDualMonoMode.
|
||||||
|
|
||||||
|
@return
|
||||||
|
- 0: Success.
|
||||||
|
- < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)setAudioDualMonoMode:(AgoraAudioDualMonoMode)mode NS_SWIFT_NAME(setAudioDualMonoMode(_:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* Open media file or stream with custom soucrce.
|
||||||
|
* The custom data source provides a data stream input callback, and the player will continue to call back this interface, requesting the user to fill in the data that needs to be played.
|
||||||
|
*
|
||||||
|
* @param startPos Set the starting position for playback, in seconds.
|
||||||
|
* @param onReadDataCallback The player requests to read the data callback , see `AgoraRtcMediaPlayerOnReadCallback`
|
||||||
|
* @param onSeekCallback The Player seek event callback, see `AgoraRtcMediaPlayerOnSeekCallback`
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)openWithCustomSourceAtStartPos:(NSInteger)startPos
|
||||||
|
withPlayerOnReadData:(AgoraRtcMediaPlayerCustomSourceOnReadCallback)onReadDataCallback
|
||||||
|
andPlayerOnSeek:(AgoraRtcMediaPlayerCustomSourceOnSeekCallback)onSeekCallback NS_SWIFT_NAME(openWithCustomSourceAtStartPos(_:withPlayerOnReadData:andPlayerOnSeek:));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set spatial audio params for the music file. It can be called after the media player
|
||||||
|
* was created.
|
||||||
|
*
|
||||||
|
* @params params See `AgoraSpatialAudioParams`. If it's
|
||||||
|
* not set, then the spatial audio will be disabled; or it will be enabled.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)setSpatialAudioParams:(AgoraSpatialAudioParams* _Nonnull)params NS_SWIFT_NAME(setSpatialAudioParams(_:));
|
||||||
|
|
||||||
|
#pragma mark Callback Audio PCM Frame
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers & unregister the player audio observer
|
||||||
|
*
|
||||||
|
* @param delegate observer object, pass nil to unregister
|
||||||
|
* @return
|
||||||
|
* - YES: Success.
|
||||||
|
* - NO: Failure.
|
||||||
|
*/
|
||||||
|
- (BOOL)setAudioFrameDelegate:(id<AgoraRtcMediaPlayerAudioFrameDelegate> _Nullable)delegate NS_SWIFT_NAME(setAudioFrameDelegate(_:));
|
||||||
|
|
||||||
|
#pragma mark Callback Video Frame
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers & unregister the player video observer
|
||||||
|
*
|
||||||
|
* @param delegate observer object, pass nil to unregister.
|
||||||
|
* @return
|
||||||
|
* - YES: Success.
|
||||||
|
* - NO: Failure.
|
||||||
|
*/
|
||||||
|
- (BOOL)setVideoFrameDelegate:(id<AgoraRtcMediaPlayerVideoFrameDelegate> _Nullable)delegate NS_SWIFT_NAME(setVideoFrameDelegate(_:));
|
||||||
|
|
||||||
|
- (int)registerMediaPlayerAudioSpectrumDelegate:(id<AgoraAudioSpectrumDelegate> _Nullable)delegate
|
||||||
|
intervalInMS:(NSUInteger)intervalInMS NS_SWIFT_NAME(registerMediaPlayerAudioSpectrumDelegate(_:intervalInMS:));
|
||||||
|
|
||||||
|
- (int)unregisterMediaPlayerAudioSpectrumDelegate:(id<AgoraAudioSpectrumDelegate> _Nullable)delegate NS_SWIFT_NAME(unregisterMediaPlayerAudioSpectrumDelegate(_:));
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
@protocol AgoraRtcMediaPlayerCacheManagerProtocol <NSObject>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get shared cacheManager instance.
|
||||||
|
* @return cacheManager instance.
|
||||||
|
*/
|
||||||
|
+ (instancetype)sharedInstance NS_SWIFT_NAME(sharedInstance());
|
||||||
|
/**
|
||||||
|
* Remove all media resource cache files.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)removeAllCaches NS_SWIFT_NAME(removeAllCaches());
|
||||||
|
/**
|
||||||
|
* Remove the latest media resource cache file.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)removeOldCache NS_SWIFT_NAME(removeOldCache());
|
||||||
|
/**
|
||||||
|
* Remove the cache file by uri, setting by MediaSource.
|
||||||
|
* @param uri URI,identify the uniqueness of the property, Set from `MeidaSource`
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)removeCacheByUri:(NSString *)uri NS_SWIFT_NAME(removeCache(byUri:));
|
||||||
|
/**
|
||||||
|
* Set cache file path that files will be saved to.
|
||||||
|
* @param cacheDir cacheDir path.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)setCacheDir:(NSString *)cacheDir NS_SWIFT_NAME(setCacheDir(_:));
|
||||||
|
/**
|
||||||
|
* Set the maximum number of cached files.
|
||||||
|
* @param count maximum number of cached files.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)setMaxCacheFileCount:(NSInteger)count NS_SWIFT_NAME(setMaxCacheFileCount(_:));
|
||||||
|
/**
|
||||||
|
* Set the total size of the largest cache file.
|
||||||
|
* @param cacheSize total size of the largest cache file.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)setMaxCacheFileSize:(NSInteger)cacheSize NS_SWIFT_NAME(setMaxCacheFileSize(_:));
|
||||||
|
/**
|
||||||
|
* Set whether the player will clean up the cache in the order of resource usage.
|
||||||
|
* @param enable enable the player to automatically clear the cache.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (int)enableAutoRemoveCache:(BOOL)enable NS_SWIFT_NAME(enableAutoRemoveCache(_:));
|
||||||
|
/**
|
||||||
|
* Get the cache directory you have set.
|
||||||
|
* @return cacheDir
|
||||||
|
*/
|
||||||
|
- (NSString *)cacheDir NS_SWIFT_NAME(cacheDir());
|
||||||
|
/**
|
||||||
|
* Get the maximum number of cached files.
|
||||||
|
* @return
|
||||||
|
* > 0: file count.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (NSInteger)maxCacheFileCount NS_SWIFT_NAME(maxCacheFileCount());
|
||||||
|
/**
|
||||||
|
* Get the total size of the largest cache file
|
||||||
|
* @return
|
||||||
|
* > 0: file size.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (NSInteger)maxCacheFileSize NS_SWIFT_NAME(maxCacheFileSize());
|
||||||
|
/**
|
||||||
|
* Get the number of all cache files.
|
||||||
|
* @return
|
||||||
|
* > 0: file count.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
- (NSInteger)cacheFileCount NS_SWIFT_NAME(cacheFileCount());
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
|
@ -0,0 +1,108 @@
|
||||||
|
//
|
||||||
|
// AgoraSpatialAudioKit.h
|
||||||
|
// AgoraRtcKit
|
||||||
|
//
|
||||||
|
// Copyright (c) 2018 Agora. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef AgoraSpatialAudioKit_h
|
||||||
|
#define AgoraSpatialAudioKit_h
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import "AgoraEnumerates.h"
|
||||||
|
#import "AgoraObjects.h"
|
||||||
|
|
||||||
|
__attribute__((visibility("default"))) @interface AgoraRemoteVoicePositionInfo : NSObject
|
||||||
|
@property(strong, nonatomic) NSArray<NSNumber*> * _Nonnull position;
|
||||||
|
@property(strong, nonatomic) NSArray<NSNumber*> * _Nullable forward;
|
||||||
|
@end
|
||||||
|
|
||||||
|
__attribute__((visibility("default"))) @interface AgoraSpatialAudioZone : NSObject
|
||||||
|
//the zone id
|
||||||
|
@property(assign, nonatomic) NSInteger zoneSetId;
|
||||||
|
//zone center point
|
||||||
|
@property(strong, nonatomic) NSArray<NSNumber*> * _Nonnull position;
|
||||||
|
//forward direction
|
||||||
|
@property(strong, nonatomic) NSArray<NSNumber*> * _Nonnull forward;
|
||||||
|
//right direction
|
||||||
|
@property(strong, nonatomic) NSArray<NSNumber*> * _Nonnull right;
|
||||||
|
//up direction
|
||||||
|
@property(strong, nonatomic) NSArray<NSNumber*> * _Nonnull up;
|
||||||
|
//the forward side length of the zone
|
||||||
|
@property(assign, nonatomic) float forwardLength;
|
||||||
|
//tehe right side length of the zone
|
||||||
|
@property(assign, nonatomic) float rightLength;
|
||||||
|
//the up side length of the zone
|
||||||
|
@property(assign, nonatomic) float upLength;
|
||||||
|
//the audio attenuation of zone
|
||||||
|
@property(assign, nonatomic) float audioAttenuation;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@class AgoraRtcEngineKit, AgoraBaseSpatialAudioKit, AgoraLocalSpatialAudioKit;
|
||||||
|
|
||||||
|
__attribute__((visibility("default"))) @interface AgoraCloudSpatialAudioConfig : NSObject
|
||||||
|
@property(assign, nonatomic) AgoraRtcEngineKit* _Nullable rtcEngine;
|
||||||
|
/** The App ID issued to you by Agora. See [How to get the App ID](https://docs.agora.io/en/Agora%20Platform/token#get-an-app-id). Only users in apps with the same App ID can join the same channel and communicate with each other. Use an App ID to create only one AgoraRtcEngineKit instance. To change your App ID, call [destroy]([AgoraRtcEngineKit destroy]) to `destroy` the current AgoraRtcEngineKit instance, and after `destroy` returns 0, call [sharedEngineWithConfig]([AgoraRtcEngineKit sharedEngineWithConfig:delegate:]) to create an AgoraRtcEngineKit instance with the new App ID.
|
||||||
|
*/
|
||||||
|
@property(copy, nonatomic) NSString* _Nullable appId;
|
||||||
|
/** The region for connection. This advanced feature applies to scenarios that have regional restrictions. <p>For the regions that Agora supports, see AgoraAreaCode. The area codes support bitwise operation. After specifying the region, the SDK connects to the Agora servers within that region.</p>
|
||||||
|
*/
|
||||||
|
@property(assign, nonatomic) NSUInteger deployRegion;
|
||||||
|
@end
|
||||||
|
|
||||||
|
__attribute__((visibility("default"))) @interface AgoraLocalSpatialAudioConfig : NSObject
|
||||||
|
@property(assign, nonatomic) AgoraRtcEngineKit* _Nullable rtcEngine;
|
||||||
|
@end
|
||||||
|
|
||||||
|
__attribute__((visibility("default"))) @interface AgoraBaseSpatialAudioKit : NSObject
|
||||||
|
|
||||||
|
- (int)setMaxAudioRecvCount:(NSUInteger)maxCount NS_SWIFT_NAME(setMaxAudioRecvCount(_:));
|
||||||
|
|
||||||
|
- (int)setAudioRecvRange:(float)range NS_SWIFT_NAME(setAudioRecvRange(_:));
|
||||||
|
|
||||||
|
- (int)setDistanceUnit:(float)unit NS_SWIFT_NAME(setDistanceUnit(_:));
|
||||||
|
|
||||||
|
- (int)updatePlayerPositionInfo:(NSInteger)playerId positionInfo:(AgoraRemoteVoicePositionInfo* _Nonnull)positionInfo NS_SWIFT_NAME(updatePlayerPositionInfo(_:positionInfo:));
|
||||||
|
|
||||||
|
- (int)updateSelfPosition:(NSArray<NSNumber*>* _Nonnull)position axisForward:(NSArray<NSNumber*>* _Nonnull)axisForward axisRight:(NSArray<NSNumber*>* _Nonnull)axisRight axisUp:(NSArray<NSNumber*>* _Nonnull)axisUp NS_SWIFT_NAME(updateSelfPosition(_:axisForward:axisRight:axisUp:));
|
||||||
|
|
||||||
|
- (int)updateSelfPositionEx:(NSArray<NSNumber*>* _Nonnull)position
|
||||||
|
axisForward:(NSArray<NSNumber*>* _Nonnull)axisForward
|
||||||
|
axisRight:(NSArray<NSNumber*>* _Nonnull)axisRight
|
||||||
|
axisUp:(NSArray<NSNumber*>* _Nonnull)axisUp
|
||||||
|
connection:(AgoraRtcConnection * _Nonnull)connection NS_SWIFT_NAME(updateSelfPositionEx(_:axisForward:axisRight:axisUp:connection:));
|
||||||
|
|
||||||
|
- (int)muteLocalAudioStream:(BOOL)mute NS_SWIFT_NAME(muteLocalAudioStream(_:));
|
||||||
|
|
||||||
|
- (int)muteAllRemoteAudioStreams:(BOOL)mute NS_SWIFT_NAME(muteAllRemoteAudioStreams(_:));
|
||||||
|
|
||||||
|
- (int)setZones:(NSArray<AgoraSpatialAudioZone*> * _Nullable)zones NS_SWIFT_NAME(setZones(_:));
|
||||||
|
|
||||||
|
- (int)setPlayerAttenuation:(double)attenuation playerId:(NSUInteger)playerId forceSet:(BOOL)forceSet NS_SWIFT_NAME(setPlayerAttenuation(_:playerId:forceSet:));
|
||||||
|
|
||||||
|
- (int)muteRemoteAudioStream:(NSUInteger)uid mute:(BOOL)mute NS_SWIFT_NAME(muteRemoteAudioStream(_:mute:));
|
||||||
|
|
||||||
|
@end
|
||||||
|
__attribute__((visibility("default"))) @interface AgoraLocalSpatialAudioKit : AgoraBaseSpatialAudioKit
|
||||||
|
|
||||||
|
+ (instancetype _Nonnull)sharedLocalSpatialAudioWithConfig:(AgoraLocalSpatialAudioConfig* _Nonnull)config NS_SWIFT_NAME(sharedLocalSpatialAudio(with:));
|
||||||
|
|
||||||
|
+ (void)destroy NS_SWIFT_NAME(destroy());
|
||||||
|
|
||||||
|
- (int)updateRemotePosition:(NSUInteger)uid positionInfo:(AgoraRemoteVoicePositionInfo* _Nonnull)posInfo NS_SWIFT_NAME(updateRemotePosition(_:positionInfo:));
|
||||||
|
|
||||||
|
- (int)updateRemotePositionEx:(NSUInteger)uid positionInfo:(AgoraRemoteVoicePositionInfo* _Nonnull)posInfo connection:(AgoraRtcConnection * _Nonnull)connection NS_SWIFT_NAME(updateRemotePositionEx(_:positionInfo:connection:));
|
||||||
|
|
||||||
|
- (int)removeRemotePosition:(NSUInteger)uid NS_SWIFT_NAME(removeRemotePosition(_:));
|
||||||
|
|
||||||
|
- (int)removeRemotePositionEx:(NSUInteger)uid connection:(AgoraRtcConnection * _Nonnull)connection NS_SWIFT_NAME(removeRemotePositionEx(_:connection:));
|
||||||
|
|
||||||
|
- (int)clearRemotePositions NS_SWIFT_NAME(clearRemotePositions());
|
||||||
|
|
||||||
|
- (int)clearRemotePositionsEx:(AgoraRtcConnection * _Nonnull)connection NS_SWIFT_NAME(clearRemotePositionsEx(_:));
|
||||||
|
|
||||||
|
- (int)setRemoteAudioAttenuation:(double)attenuation userId:(NSUInteger)uid forceSet:(BOOL)forceSet NS_SWIFT_NAME(setRemoteAudioAttenuation(_:userId:forceSet:));
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#endif /* AgoraSpatialAudioKit_h */
|
|
@ -0,0 +1,44 @@
|
||||||
|
|
||||||
|
// Copyright (c) 2019 Agora.io. All rights reserved
|
||||||
|
|
||||||
|
// This program is confidential and proprietary to Agora.io.
|
||||||
|
// And may not be copied, reproduced, modified, disclosed to others, published
|
||||||
|
// or used, in whole or in part, without the express prior written permission
|
||||||
|
// of Agora.io.
|
||||||
|
|
||||||
|
#pragma once // NOLINT(build/header_guard)
|
||||||
|
|
||||||
|
#include "AgoraRefPtr.h"
|
||||||
|
|
||||||
|
namespace agora {
|
||||||
|
namespace rtc {
|
||||||
|
|
||||||
|
struct ImagePayloadData {
|
||||||
|
ImagePayloadData(int seq, uint8_t* pixel, int fileSize, int w, int h, int64_t ts)
|
||||||
|
: seqid(seq),
|
||||||
|
size(fileSize),
|
||||||
|
width(w),
|
||||||
|
height(h),
|
||||||
|
timestamp(ts){
|
||||||
|
}
|
||||||
|
|
||||||
|
int seqid;
|
||||||
|
int size;
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
int64_t timestamp;
|
||||||
|
uint8_t* buffer;
|
||||||
|
void* privdata;
|
||||||
|
int privsize;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* The IFileUploadService class, which enables upload file service.
|
||||||
|
*/
|
||||||
|
class IFileUploaderService : public RefCountInterface {
|
||||||
|
public:
|
||||||
|
virtual ~IFileUploaderService() {}
|
||||||
|
virtual int startImageUpload(const ImagePayloadData* imgData) = 0;
|
||||||
|
virtual int stopImageUpload() = 0;
|
||||||
|
};
|
||||||
|
} // namespace rtc
|
||||||
|
} // namespace agora
|
|
@ -0,0 +1,98 @@
|
||||||
|
//
|
||||||
|
// Agora Media SDK
|
||||||
|
//
|
||||||
|
// Copyright (c) 2015 Agora IO. All rights reserved.
|
||||||
|
//
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#ifndef OPTIONAL_ENUM_CLASS
|
||||||
|
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
|
||||||
|
#define OPTIONAL_ENUM_CLASS enum class
|
||||||
|
#else
|
||||||
|
#define OPTIONAL_ENUM_CLASS enum
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef OPTIONAL_LOG_LEVEL_SPECIFIER
|
||||||
|
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
|
||||||
|
#define OPTIONAL_LOG_LEVEL_SPECIFIER LOG_LEVEL::
|
||||||
|
#else
|
||||||
|
#define OPTIONAL_LOG_LEVEL_SPECIFIER
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace agora {
|
||||||
|
namespace commons {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Supported logging severities of SDK
|
||||||
|
*/
|
||||||
|
OPTIONAL_ENUM_CLASS LOG_LEVEL {
|
||||||
|
LOG_LEVEL_NONE = 0x0000,
|
||||||
|
LOG_LEVEL_INFO = 0x0001,
|
||||||
|
LOG_LEVEL_WARN = 0x0002,
|
||||||
|
LOG_LEVEL_ERROR = 0x0004,
|
||||||
|
LOG_LEVEL_FATAL = 0x0008,
|
||||||
|
LOG_LEVEL_API_CALL = 0x0010,
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
The SDK uses ILogWriter class Write interface to write logs as application
|
||||||
|
The application inherits the methods Write() to implentation their own log writ
|
||||||
|
|
||||||
|
Write has default implementation, it writes logs to files.
|
||||||
|
Application can use setLogFile() to change file location, see description of set
|
||||||
|
*/
|
||||||
|
class ILogWriter {
|
||||||
|
public:
|
||||||
|
/** user defined log Write function
|
||||||
|
@param level log level
|
||||||
|
@param message log message content
|
||||||
|
@param length log message length
|
||||||
|
@return
|
||||||
|
- 0: success
|
||||||
|
- <0: failure
|
||||||
|
*/
|
||||||
|
virtual int32_t writeLog(LOG_LEVEL level, const char* message, uint16_t length) = 0;
|
||||||
|
|
||||||
|
virtual ~ILogWriter() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
enum LOG_FILTER_TYPE {
|
||||||
|
LOG_FILTER_OFF = 0,
|
||||||
|
LOG_FILTER_DEBUG = 0x080f,
|
||||||
|
LOG_FILTER_INFO = 0x000f,
|
||||||
|
LOG_FILTER_WARN = 0x000e,
|
||||||
|
LOG_FILTER_ERROR = 0x000c,
|
||||||
|
LOG_FILTER_CRITICAL = 0x0008,
|
||||||
|
LOG_FILTER_MASK = 0x80f,
|
||||||
|
};
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
/** Definition of LogConfiguration
|
||||||
|
*/
|
||||||
|
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
|
||||||
|
*/
|
||||||
|
uint32_t fileSizeInKB;
|
||||||
|
/** The log level, set LOG_LEVEL_INFO to use default log level
|
||||||
|
*/
|
||||||
|
LOG_LEVEL level;
|
||||||
|
|
||||||
|
LogConfig() : filePath(NULL), fileSizeInKB(DEFAULT_LOG_SIZE_IN_KB), level(OPTIONAL_LOG_LEVEL_SPECIFIER LOG_LEVEL_INFO) {}
|
||||||
|
};
|
||||||
|
} // namespace commons
|
||||||
|
} // namespace agora
|
||||||
|
|
||||||
|
#undef OPTIONAL_LOG_LEVEL_SPECIFIER
|
|
@ -0,0 +1,41 @@
|
||||||
|
//
|
||||||
|
// Agora SDK
|
||||||
|
//
|
||||||
|
// Copyright (c) 2021 Agora.io. All rights reserved.
|
||||||
|
//
|
||||||
|
#pragma once // NOLINT(build/header_guard)
|
||||||
|
|
||||||
|
#include "AgoraBase.h"
|
||||||
|
#include "AgoraRefPtr.h"
|
||||||
|
|
||||||
|
namespace agora {
|
||||||
|
namespace rtc {
|
||||||
|
|
||||||
|
class IMediaPlayer;
|
||||||
|
|
||||||
|
class IMediaComponentFactory {
|
||||||
|
public:
|
||||||
|
/** This method creates media player.
|
||||||
|
*/
|
||||||
|
virtual agora_refptr<IMediaPlayer> createMediaPlayer(
|
||||||
|
agora::media::base::MEDIA_PLAYER_SOURCE_TYPE type = agora::media::base::MEDIA_PLAYER_SOURCE_DEFAULT) = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual ~IMediaComponentFactory() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
} //namespace rtc
|
||||||
|
} // namespace agora
|
||||||
|
|
||||||
|
/** \addtogroup createMediaComponentFactory
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Creates an \ref agora::rtc::IMediaComponentFactory "IMediaComponentFactory" object and returns the pointer.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - The pointer to \ref agora::rtc::IMediaComponentFactory "IMediaComponentFactory": Success.
|
||||||
|
* - A null pointer: Failure.
|
||||||
|
*/
|
||||||
|
AGORA_API agora::rtc::IMediaComponentFactory* AGORA_CALL createAgoraMediaComponentFactory();
|
||||||
|
/** @} */
|
|
@ -0,0 +1,267 @@
|
||||||
|
//
|
||||||
|
// Agora Media SDK
|
||||||
|
//
|
||||||
|
// Copyright (c) 2015 Agora IO. All rights reserved.
|
||||||
|
//
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "AgoraBase.h"
|
||||||
|
#include "AgoraMediaBase.h"
|
||||||
|
#include "AgoraRefPtr.h"
|
||||||
|
|
||||||
|
namespace agora {
|
||||||
|
namespace media {
|
||||||
|
|
||||||
|
/** dual-mono music output mode
|
||||||
|
*/
|
||||||
|
enum AUDIO_MIXING_DUAL_MONO_MODE {
|
||||||
|
/* 0: Original mode */
|
||||||
|
AUDIO_MIXING_DUAL_MONO_AUTO = 0,
|
||||||
|
/* 1: Left channel mode */
|
||||||
|
AUDIO_MIXING_DUAL_MONO_L = 1,
|
||||||
|
/* 2: Right channel mode */
|
||||||
|
AUDIO_MIXING_DUAL_MONO_R = 2,
|
||||||
|
/* 3: Mixed channel mode */
|
||||||
|
AUDIO_MIXING_DUAL_MONO_MIX = 3
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The IMediaEngine class.
|
||||||
|
*/
|
||||||
|
class IMediaEngine {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Registers an audio frame observer object.
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* Ensure that you call this method before \ref IRtcEngine::joinChannel "joinChannel".
|
||||||
|
*
|
||||||
|
* @param observer A pointer to the audio frame observer object: IAudioFrameObserver,
|
||||||
|
* nullptr means unregistering observer instead.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int registerAudioFrameObserver(IAudioFrameObserver* observer) = 0;
|
||||||
|
/**
|
||||||
|
* Registers a video frame observer object.
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* - Ensure that you call this method before joining the channel.
|
||||||
|
* - If you register an observer for video raw video data, you cannot register an IVideoEncodedFrameObserver
|
||||||
|
* object.
|
||||||
|
*
|
||||||
|
* @param observer A pointer to the video frame observer: IVideoFrameObserver.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int registerVideoFrameObserver(IVideoFrameObserver* observer) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a receiver object for the encoded video image.
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* - Ensure that you call this method before joining the channel.
|
||||||
|
*
|
||||||
|
* @param observer A pointer to the observer of the encoded video image: \ref IVideoEncodedFrameObserver
|
||||||
|
* "IVideoEncodedFrameObserver".
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int registerVideoEncodedFrameObserver(IVideoEncodedFrameObserver* observer) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pushes the external audio data to the app.
|
||||||
|
*
|
||||||
|
* @param frame The audio buffer data.
|
||||||
|
* @param trackId The audio track ID.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int pushAudioFrame(IAudioFrameObserver::AudioFrame* frame, rtc::track_id_t trackId = 0) = 0;
|
||||||
|
|
||||||
|
virtual int pushCaptureAudioFrame(IAudioFrameObserver::AudioFrame* frame) = 0;
|
||||||
|
|
||||||
|
virtual int pushReverseAudioFrame(IAudioFrameObserver::AudioFrame* frame) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pulls the remote audio data.
|
||||||
|
*
|
||||||
|
* After a successful method call, the app pulls the decoded and mixed audio data for playback.
|
||||||
|
*
|
||||||
|
* The difference between this method and the \ref onPlaybackAudioFrame "onPlaybackAudioFrame" is as follows:
|
||||||
|
* - `onPlaybackAudioFrame`: The SDK sends the audio data to the app once every 10 ms. Any delay in processing
|
||||||
|
* the audio frames may result in audio jitter.
|
||||||
|
* - `pullAudioFrame`: The app pulls the remote audio data. After setting the audio data parameters, the
|
||||||
|
* SDK adjusts the frame buffer and avoids problems caused by jitter in the external audio playback.
|
||||||
|
*
|
||||||
|
* @param frame The pointer to the audio frame: AudioFrame.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int pullAudioFrame(IAudioFrameObserver::AudioFrame* frame) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the external video source.
|
||||||
|
*
|
||||||
|
* Once the external video source is enabled, the SDK prepares to accept the external video frame.
|
||||||
|
*
|
||||||
|
* @param enabled Determines whether to enable the external video source.
|
||||||
|
* - true: Enable the external video source. Once set, the SDK creates the external source and prepares
|
||||||
|
* video data from `pushVideoFrame` or `pushEncodedVideoImage`.
|
||||||
|
* - false: Disable the external video source.
|
||||||
|
* @param useTexture Determines whether to use textured video data.
|
||||||
|
* - true: Use texture, which is not supported now.
|
||||||
|
* - False: Do not use texture.
|
||||||
|
* @param sourceType Determines the type of external video source frame.
|
||||||
|
* - ENCODED_VIDEO_FRAME: The external video source is encoded.
|
||||||
|
* - VIDEO_FRAME: The external video source is not encoded.
|
||||||
|
* @param encodedVideoOption Video encoded track option, which is only used for ENCODED_VIDEO_FRAME.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setExternalVideoSource(
|
||||||
|
bool enabled, bool useTexture, EXTERNAL_VIDEO_SOURCE_TYPE sourceType = VIDEO_FRAME,
|
||||||
|
rtc::SenderOptions encodedVideoOption = rtc::SenderOptions()) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the external audio source.
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* Ensure that you call this method before joining the channel.
|
||||||
|
*
|
||||||
|
* @deprecated This method is deprecated. Use createCustomAudioTrack(rtc::AUDIO_TRACK_TYPE trackType, const rtc::AudioTrackConfig& config) instead.
|
||||||
|
*
|
||||||
|
* @param enabled Determines whether to enable the external audio source:
|
||||||
|
* - true: Enable the external audio source.
|
||||||
|
* - false: (default) Disable the external audio source.
|
||||||
|
* @param sampleRate The Sample rate (Hz) of the external audio source, which can set be as
|
||||||
|
* 8000, 16000, 32000, 44100, or 48000.
|
||||||
|
* @param channels The number of channels of the external audio source, which can be set as 1 or 2:
|
||||||
|
* - 1: Mono.
|
||||||
|
* - 2: Stereo.
|
||||||
|
* @param localPlayback Enable/Disables the local playback of external audio track:
|
||||||
|
* - true: Enable local playback
|
||||||
|
* - false: (Default) Do not enable local playback
|
||||||
|
* @param publish Determines whether to publish the external audio track:
|
||||||
|
* - true: (Default) Publish the external audio track.
|
||||||
|
* - false: Don`t publish the external audio track.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setExternalAudioSource(bool enabled, int sampleRate, int channels, bool localPlayback = false, bool publish = true) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a custom audio track and get the audio track id.
|
||||||
|
*
|
||||||
|
* @note Ensure that you call this method before calling `joinChannel`.
|
||||||
|
*
|
||||||
|
* @param trackType The type of custom audio track
|
||||||
|
* See AUDIO_TRACK_TYPE.
|
||||||
|
*
|
||||||
|
* @param config The config of custom audio track
|
||||||
|
* See AudioTrackConfig.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - If the call is successful, SDK returns audio track id.
|
||||||
|
* - If the call fails, SDK returns 0xffffffff.
|
||||||
|
*/
|
||||||
|
virtual rtc::track_id_t createCustomAudioTrack(rtc::AUDIO_TRACK_TYPE trackType, const rtc::AudioTrackConfig& config) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destroy custom audio track by trackId
|
||||||
|
*
|
||||||
|
* @param trackId The custom audio track id.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int destroyCustomAudioTrack(rtc::track_id_t trackId) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the external audio sink.
|
||||||
|
*
|
||||||
|
* This method applies to scenarios where you want to use external audio
|
||||||
|
* data for playback. After calling the \ref IRtcEngine::initialize "initialize"
|
||||||
|
* method and pass value of false in the `enableAudioDevice` member in the RtcEngineContext struct, you can call
|
||||||
|
* the \ref agora::media::IMediaEngine::pullAudioFrame "pullAudioFrame" method to pull the remote audio data, process
|
||||||
|
* it, and play it with the audio effects that you want.
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* Once you call the \ref IRtcEngine::initialize "initialize" method and pass value of false in the `enableAudioDevice`
|
||||||
|
* member in the RtcEngineContext struct, the app will not retrieve any audio data from the
|
||||||
|
* \ref agora::media::IAudioFrameObserver::onPlaybackAudioFrame "onPlaybackAudioFrame" callback.
|
||||||
|
*
|
||||||
|
* @param enabled Sets whether or not to the external audio sink
|
||||||
|
* - true: Enables the external audio sink.
|
||||||
|
* - false: Disables the external audio sink.
|
||||||
|
* @param sampleRate Sets the sample rate (Hz) of the external audio sink, which can be set as 16000, 32000, 44100 or 48000.
|
||||||
|
* @param channels Sets the number of audio channels of the external
|
||||||
|
* audio sink:
|
||||||
|
* - 1: Mono.
|
||||||
|
* - 2: Stereo.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setExternalAudioSink(bool enabled, int sampleRate, int channels) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the external audio track.
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* Ensure that you call this method before joining the channel.
|
||||||
|
*
|
||||||
|
* @param trackId The custom audio track id.
|
||||||
|
* @param enabled Enable/Disables the local playback of external audio track:
|
||||||
|
* - true: Enable local playback
|
||||||
|
* - false: Do not enable local playback
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int enableCustomAudioLocalPlayback(rtc::track_id_t trackId, bool enabled) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pushes the external video frame to the app.
|
||||||
|
*
|
||||||
|
* @param frame The external video frame: ExternalVideoFrame.
|
||||||
|
* @param videoTrackId The id of the video track.
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 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.
|
||||||
|
* @param length The data length.
|
||||||
|
* @param videoEncodedFrameInfo The reference to the information of the encoded video frame:
|
||||||
|
* \ref agora::rtc::EncodedVideoFrameInfo "EncodedVideoFrameInfo".
|
||||||
|
* @param videoTrackId The id of the video track.
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int pushEncodedVideoImage(const uint8_t* imageBuffer, size_t length,
|
||||||
|
const agora::rtc::EncodedVideoFrameInfo& videoEncodedFrameInfo,
|
||||||
|
unsigned int videoTrackId = 0) = 0;
|
||||||
|
|
||||||
|
virtual void release() = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual ~IMediaEngine() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace media
|
||||||
|
|
||||||
|
} // namespace agora
|
|
@ -0,0 +1,654 @@
|
||||||
|
//
|
||||||
|
// Agora SDK
|
||||||
|
//
|
||||||
|
// Copyright (c) 2020 Agora.io. All rights reserved.
|
||||||
|
//
|
||||||
|
#pragma once // NOLINT(build/header_guard)
|
||||||
|
|
||||||
|
#include "AgoraBase.h"
|
||||||
|
#include "AgoraMediaBase.h"
|
||||||
|
#include "AgoraMediaPlayerTypes.h"
|
||||||
|
#include "AgoraRefPtr.h"
|
||||||
|
|
||||||
|
namespace agora {
|
||||||
|
namespace base {
|
||||||
|
class IAgoraService;
|
||||||
|
}
|
||||||
|
namespace rtc {
|
||||||
|
|
||||||
|
class ILocalAudioTrack;
|
||||||
|
class ILocalVideoTrack;
|
||||||
|
class IMediaPlayerSourceObserver;
|
||||||
|
class IMediaPlayerCustomDataProvider;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The IMediaPlayerEntity class provides access to a media player entity. If yout want to playout
|
||||||
|
* multiple media sources simultaneously, create multiple media player source objects.
|
||||||
|
*/
|
||||||
|
class IMediaPlayer : public RefCountInterface {
|
||||||
|
protected:
|
||||||
|
virtual ~IMediaPlayer() {}
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual int initialize(base::IAgoraService* agora_service) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get unique media player id of the media player entity.
|
||||||
|
* @return
|
||||||
|
* - >= 0: The source id of this media player entity.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int getMediaPlayerId() const = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens a media file with a specified URL.
|
||||||
|
* @param url The URL of the media file that you want to play.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int open(const char* url, int64_t startPos) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* @brief Open media file or stream with custom soucrce.
|
||||||
|
* @param startPos Set the starting position for playback, in seconds
|
||||||
|
* @param observer dataProvider object
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int openWithCustomSource(int64_t startPos, media::base::IMediaPlayerCustomDataProvider* provider) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Open a media file with a media file source.
|
||||||
|
* @param source Media file source that you want to play, see `MediaSource`
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int openWithMediaSource(const media::base::MediaSource &source) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plays the media file.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int play() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pauses playing the media file.
|
||||||
|
*/
|
||||||
|
virtual int pause() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stops playing the current media file.
|
||||||
|
*/
|
||||||
|
virtual int stop() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resumes playing the media file.
|
||||||
|
*/
|
||||||
|
virtual int resume() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the current playback position of the media file.
|
||||||
|
* @param newPos The new playback position (ms).
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int seek(int64_t newPos) = 0;
|
||||||
|
|
||||||
|
/** Sets the pitch of the current media file.
|
||||||
|
* @param pitch Sets the pitch of the local music file by chromatic scale. The default value is 0,
|
||||||
|
* which means keeping the original pitch. The value ranges from -12 to 12, and the pitch value between
|
||||||
|
* consecutive values is a chromatic value. The greater the absolute value of this parameter, the
|
||||||
|
* higher or lower the pitch of the local music file.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setAudioPitch(int pitch) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the duration of the media file.
|
||||||
|
* @param duration A reference to the duration of the media file.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int getDuration(int64_t& duration) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the current playback position of the media file.
|
||||||
|
* @param currentPosition A reference to the current playback position (ms).
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int getPlayPosition(int64_t& pos) = 0;
|
||||||
|
|
||||||
|
virtual int getStreamCount(int64_t& count) = 0;
|
||||||
|
|
||||||
|
virtual int getStreamInfo(int64_t index, media::base::PlayerStreamInfo* info) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets whether to loop the media file for playback.
|
||||||
|
* @param loopCount the number of times looping the media file.
|
||||||
|
* - 0: Play the audio effect once.
|
||||||
|
* - 1: Play the audio effect twice.
|
||||||
|
* - -1: Play the audio effect in a loop indefinitely, until stopEffect() or stop() is called.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setLoopCount(int loopCount) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change playback speed
|
||||||
|
* @param speed the value of playback speed ref [50-400]
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setPlaybackSpeed(int speed) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Slect playback audio track of the media 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_ERROR MEDIA_PLAYER_ERROR}.
|
||||||
|
* - -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
|
||||||
|
* @param value the value of option param
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setPlayerOption(const char* key, int value) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* change player option before play a file
|
||||||
|
* @param key the key of the option param
|
||||||
|
* @param value the value of option param
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setPlayerOption(const char* key, const char* value) = 0;
|
||||||
|
/**
|
||||||
|
* take screenshot while playing video
|
||||||
|
* @param filename the filename of screenshot file
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int takeScreenshot(const char* filename) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* select internal subtitles in video
|
||||||
|
* @param index the index of the internal subtitles
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int selectInternalSubtitle(int index) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set an external subtitle for video
|
||||||
|
* @param url The URL of the subtitle file that you want to load.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setExternalSubtitle(const char* url) = 0;
|
||||||
|
|
||||||
|
virtual media::base::MEDIA_PLAYER_STATE getState() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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
|
||||||
|
*/
|
||||||
|
virtual int mute(bool muted) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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
|
||||||
|
*/
|
||||||
|
virtual int getMute(bool& muted) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Adjust playback volume
|
||||||
|
*
|
||||||
|
* @param volume The volume value to be adjusted
|
||||||
|
* The volume can be adjusted from 0 to 400:
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
virtual int adjustPlayoutVolume(int volume) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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
|
||||||
|
*/
|
||||||
|
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
|
||||||
|
*/
|
||||||
|
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
|
||||||
|
*/
|
||||||
|
virtual int getPublishSignalVolume(int& volume) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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
|
||||||
|
*/
|
||||||
|
virtual int setView(media::base::view_t view) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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
|
||||||
|
*/
|
||||||
|
virtual int setRenderMode(media::base::RENDER_MODE_TYPE renderMode) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a media player source observer.
|
||||||
|
*
|
||||||
|
* Once the media player source observer is registered, you can use the observer to monitor the state change of the media player.
|
||||||
|
* @param observer The pointer to the IMediaPlayerSourceObserver object.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int registerPlayerSourceObserver(IMediaPlayerSourceObserver* observer) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Releases the media player source observer.
|
||||||
|
* @param observer The pointer to the IMediaPlayerSourceObserver object.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int unregisterPlayerSourceObserver(IMediaPlayerSourceObserver* observer) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the audio frame observer.
|
||||||
|
*
|
||||||
|
* @param observer The pointer to the IAudioFrameObserver object.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int registerAudioFrameObserver(media::base::IAudioFrameObserver* observer) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers an audio observer.
|
||||||
|
*
|
||||||
|
* @param observer The audio observer, reporting the reception of each audio
|
||||||
|
* frame. See
|
||||||
|
* \ref media::base::IAudioFrameObserver "IAudioFrameObserver" for
|
||||||
|
* details.
|
||||||
|
* @param mode Use mode of the audio frame. See #RAW_AUDIO_FRAME_OP_MODE_TYPE.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int registerAudioFrameObserver(media::base::IAudioFrameObserver* observer,
|
||||||
|
RAW_AUDIO_FRAME_OP_MODE_TYPE mode) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Releases the audio frame observer.
|
||||||
|
* @param observer The pointer to the IAudioFrameObserver object.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int unregisterAudioFrameObserver(media::base::IAudioFrameObserver* observer) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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
|
||||||
|
*/
|
||||||
|
virtual int registerVideoFrameObserver(media::base::IVideoFrameObserver* observer) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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
|
||||||
|
*/
|
||||||
|
virtual int unregisterVideoFrameObserver(agora::media::base::IVideoFrameObserver* observer) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers the audio frame spectrum observer.
|
||||||
|
*
|
||||||
|
* @param observer The pointer to the {@link media::base::IAudioSpectrumObserver IAudioSpectrumObserver} object.
|
||||||
|
* @param intervalInMS Sets the time interval(ms) between two consecutive audio spectrum callback.
|
||||||
|
* The default value is 100. This param should be larger than 10.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int registerMediaPlayerAudioSpectrumObserver(media::IAudioSpectrumObserver* observer, int intervalInMS) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Releases the audio frame spectrum observer.
|
||||||
|
* @param observer The pointer to the {@link media::base::IAudioSpectrumObserver IAudioSpectrumObserver} object.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int unregisterMediaPlayerAudioSpectrumObserver(media::IAudioSpectrumObserver* observer) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set dual-mono output mode of the music file.
|
||||||
|
*
|
||||||
|
* @param mode dual mono mode. See #agora::media::AUDIO_DUAL_MONO_MODE
|
||||||
|
*/
|
||||||
|
virtual int setAudioDualMonoMode(agora::media::base::AUDIO_DUAL_MONO_MODE mode) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get sdk version and build number of player SDK.
|
||||||
|
* @return String of the SDK version.
|
||||||
|
*/
|
||||||
|
virtual const char* getPlayerSdkVersion() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current play src.
|
||||||
|
* @return
|
||||||
|
* - current play src of raw bytes.
|
||||||
|
*/
|
||||||
|
virtual const char* getPlaySrc() = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open the Agora CDN media source.
|
||||||
|
* @param src The src of the media file that you want to play.
|
||||||
|
* @param startPos The playback position (ms).
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int openWithAgoraCDNSrc(const char* src, int64_t startPos) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the number of Agora CDN lines.
|
||||||
|
* @return
|
||||||
|
* - > 0: number of CDN.
|
||||||
|
* - <= 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int getAgoraCDNLineCount() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Switch Agora CDN lines.
|
||||||
|
* @param index Specific CDN line index.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int switchAgoraCDNLineByIndex(int index) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the line of the current CDN.
|
||||||
|
* @return
|
||||||
|
* - >= 0: Specific line.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int getCurrentAgoraCDNIndex() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable automatic CDN line switching.
|
||||||
|
* @param enable Whether enable.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int enableAutoSwitchAgoraCDN(bool enable) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the CDN source token and timestamp.
|
||||||
|
* @param token token.
|
||||||
|
* @param ts ts.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int renewAgoraCDNSrcToken(const char* token, int64_t ts) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Switch the CDN source when open a media through "openWithAgoraCDNSrc" API
|
||||||
|
* @param src Specific src.
|
||||||
|
* @param syncPts Live streaming must be set to false.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int switchAgoraCDNSrc(const char* src, bool syncPts = false) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Switch the media source when open a media through "open" API
|
||||||
|
* @param src Specific src.
|
||||||
|
* @param syncPts Live streaming must be set to false.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int switchSrc(const char* src, bool syncPts = true) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Preload a media source
|
||||||
|
* @param src Specific src.
|
||||||
|
* @param startPos The starting position (ms) for playback. Default value is 0.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int preloadSrc(const char* src, int64_t startPos) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Play a pre-loaded media source
|
||||||
|
* @param src Specific src.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int playPreloadedSrc(const char* src) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unload a preloaded media source
|
||||||
|
* @param src Specific src.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int unloadSrc(const char* src) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set spatial audio params for the music file. It can be called after the media player
|
||||||
|
* was created.
|
||||||
|
*
|
||||||
|
* @param params See #agora::SpatialAudioParams. If it's
|
||||||
|
* not set, then the spatial audio will be disabled; or it will be enabled.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setSpatialAudioParams(const SpatialAudioParams& params) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set sound position params for the music file. It can be called after the media player
|
||||||
|
* was created.
|
||||||
|
*
|
||||||
|
*@param pan The sound position of the music file. The value ranges from -1.0 to 1.0:
|
||||||
|
*- 0.0: the music sound comes from the front.
|
||||||
|
*- -1.0: the music sound comes from the left.
|
||||||
|
*- 1.0: the music sound comes from the right.
|
||||||
|
*@param gain Gain of the music. The value ranges from 0.0 to 100.0. The default value is 100.0 (the original gain of the music). The smaller the value, the less the gain.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setSoundPositionParams(float pan, float gain) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set delay of playback to local device.
|
||||||
|
*
|
||||||
|
*@param delay_ms The delay_ms for playback to local device:
|
||||||
|
* - for default, the pipeline default is 160ms, 16 buffer before pipeline start consuming
|
||||||
|
* - for playeffect, it need to play as soon as possible for short file, sugguest to used 50ms
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setAudioPlaybackDelay(int delay_ms) = 0;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class is used to set and manage the player cache, implemented in the
|
||||||
|
* form of a singleton, independent of the player.
|
||||||
|
*/
|
||||||
|
class IMediaPlayerCacheManager {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Delete the longest used cache file in order to release some of the cache file disk usage.
|
||||||
|
* (usually used when the cache quota notification is received)
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int removeAllCaches() = 0;
|
||||||
|
/**
|
||||||
|
* Remove the latest media resource cache file.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int removeOldCache() = 0;
|
||||||
|
/**
|
||||||
|
* Remove the cache file by uri, setting by MediaSource.
|
||||||
|
* @param uri URI,identify the uniqueness of the property, Set from `MeidaSource`
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int removeCacheByUri(const char *uri) = 0;
|
||||||
|
/**
|
||||||
|
* Set cache file path that files will be saved to.
|
||||||
|
* @param path file path.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setCacheDir(const char *path) = 0;
|
||||||
|
/**
|
||||||
|
* Set the maximum number of cached files.
|
||||||
|
* @param count maximum number of cached files.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setMaxCacheFileCount(int count) = 0;
|
||||||
|
/**
|
||||||
|
* Set the maximum size of cache file disk usage.
|
||||||
|
* @param cacheSize total size of the largest cache file.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setMaxCacheFileSize(int64_t cacheSize) = 0;
|
||||||
|
/**
|
||||||
|
* Whether to automatically delete old cache files when the cache file usage reaches the limit.
|
||||||
|
* @param enable enable the player to automatically clear the cache.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int enableAutoRemoveCache(bool enable) = 0;
|
||||||
|
/**
|
||||||
|
* Get the cache directory.
|
||||||
|
* @param path cache path, recieve a pointer to be copied to.
|
||||||
|
* @param length the length to be copied.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int getCacheDir(char* path, int length) = 0;
|
||||||
|
/**
|
||||||
|
* Get the maximum number of cached files.
|
||||||
|
* @return
|
||||||
|
* > 0: file count.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int getMaxCacheFileCount() = 0;
|
||||||
|
/**
|
||||||
|
* Get the total size of the largest cache file
|
||||||
|
* @return
|
||||||
|
* > 0: file size.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int64_t getMaxCacheFileSize() = 0;
|
||||||
|
/**
|
||||||
|
* Get the number of all cache files.
|
||||||
|
* @return
|
||||||
|
* > 0: file count.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int getCacheFileCount() = 0;
|
||||||
|
|
||||||
|
virtual ~IMediaPlayerCacheManager(){};
|
||||||
|
};
|
||||||
|
|
||||||
|
} //namespace rtc
|
||||||
|
} // namespace agora
|
||||||
|
|
||||||
|
AGORA_API agora::rtc::IMediaPlayerCacheManager* AGORA_CALL getMediaPlayerCacheManager();
|
|
@ -0,0 +1,486 @@
|
||||||
|
//
|
||||||
|
// Agora SDK
|
||||||
|
//
|
||||||
|
// Copyright (c) 2018 Agora.io. All rights reserved.
|
||||||
|
//
|
||||||
|
#pragma once // NOLINT(build/header_guard)
|
||||||
|
|
||||||
|
#include "AgoraBase.h"
|
||||||
|
#include "AgoraMediaBase.h"
|
||||||
|
#include "AgoraMediaPlayerTypes.h"
|
||||||
|
#include "AgoraRefPtr.h"
|
||||||
|
|
||||||
|
namespace agora {
|
||||||
|
namespace rtc {
|
||||||
|
|
||||||
|
class IMediaPlayerSourceObserver;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The IMediaPlayerSource class provides access to a media player source. To playout multiple media sources simultaneously,
|
||||||
|
* create multiple media player source objects.
|
||||||
|
*/
|
||||||
|
class IMediaPlayerSource : public RefCountInterface {
|
||||||
|
protected:
|
||||||
|
virtual ~IMediaPlayerSource() {}
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the unique source ID of the media player source.
|
||||||
|
* @return
|
||||||
|
* - >=0: The source ID of this media player source.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int getSourceId() const = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens a media file with a specified URL.
|
||||||
|
* @param url The path of the media file. Both the local path and online path are supported.
|
||||||
|
* @param startPos The starting position (ms) for playback. Default value is 0.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int open(const char* url, int64_t startPos) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* @brief Open media file or stream with custom soucrce.
|
||||||
|
* @param startPos Set the starting position for playback, in seconds
|
||||||
|
* @param observer dataProvider object
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int openWithCustomSource(int64_t startPos, media::base::IMediaPlayerCustomDataProvider* provider) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens a media file with a media file source.
|
||||||
|
* @param source Media file source that you want to play, see `MediaSource`
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int openWithMediaSource(const media::base::MediaSource &source) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plays the media file.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int play() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pauses the playback.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int pause() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stops the playback.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int stop() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resumes the playback.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int resume() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the playback position of the media file.
|
||||||
|
* @param newPos The new playback position (ms).
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int seek(int64_t newPos) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the duration of the media file.
|
||||||
|
* @param [out] duration A reference to the duration of the media file.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int getDuration(int64_t& duration) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the current playback position of the media file.
|
||||||
|
* @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}.
|
||||||
|
*/
|
||||||
|
virtual int getPlayPosition(int64_t& pos) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the number of the media streams in the media source.
|
||||||
|
* @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}.
|
||||||
|
*/
|
||||||
|
virtual int getStreamCount(int64_t& count) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the detailed information of a media stream.
|
||||||
|
* @param index The index of the media stream.
|
||||||
|
* @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}.
|
||||||
|
*/
|
||||||
|
virtual int getStreamInfo(int64_t index, media::base::PlayerStreamInfo* info) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets whether to loop the media file for playback.
|
||||||
|
* @param loopCount The number of times of looping the media file.
|
||||||
|
* - 0: Play the media file once.
|
||||||
|
* - 1: Play the media file twice.
|
||||||
|
* - -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}.
|
||||||
|
*/
|
||||||
|
virtual int setLoopCount(int64_t loopCount) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Changes the playback speed.
|
||||||
|
* @param speed The playback speed ref [50-400].
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure. See {@link media::base::MEDIA_PLAYER_ERROR MEDIA_PLAYER_ERROR}.
|
||||||
|
*/
|
||||||
|
virtual int setPlaybackSpeed(int speed) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Selects an audio track of the media file for playback.
|
||||||
|
* @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}.
|
||||||
|
*/
|
||||||
|
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_ERROR MEDIA_PLAYER_ERROR}.
|
||||||
|
* - -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}.
|
||||||
|
*/
|
||||||
|
virtual int setPlayerOption(const char* key, int64_t value) = 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}.
|
||||||
|
*/
|
||||||
|
virtual int setPlayerOption(const char* key, const char* value) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Takes a screenshot when playing a video file.
|
||||||
|
* @param filename The filename of the screenshot file.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure. See {@link media::base::MEDIA_PLAYER_ERROR MEDIA_PLAYER_ERROR}.
|
||||||
|
*/
|
||||||
|
virtual int takeScreenshot(const char* filename) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Selects internal subtitles for a video file.
|
||||||
|
* @param index The index of the internal subtitles.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure. See {@link media::base::MEDIA_PLAYER_ERROR MEDIA_PLAYER_ERROR}.
|
||||||
|
*/
|
||||||
|
virtual int selectInternalSubtitle(int64_t index) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets an external subtitle file for a video file.
|
||||||
|
* @param url The URL of the subtitle file.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure. See {@link media::base::MEDIA_PLAYER_ERROR MEDIA_PLAYER_ERROR}.
|
||||||
|
*/
|
||||||
|
virtual int setExternalSubtitle(const char* url) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the playback state.
|
||||||
|
* @return The current playback state. See {@link media::base::MEDIA_PLAYER_STATE MEDIA_PLAYER_STATE} for details.
|
||||||
|
*/
|
||||||
|
virtual media::base::MEDIA_PLAYER_STATE getState() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a media player source observer.
|
||||||
|
*
|
||||||
|
* Once the media player source observer is registered, you can use the observer to monitor the state change of the media player.
|
||||||
|
* @param observer The pointer to the IMediaPlayerSourceObserver object.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure. See {@link media::base::MEDIA_PLAYER_ERROR MEDIA_PLAYER_ERROR}.
|
||||||
|
*/
|
||||||
|
virtual int registerPlayerSourceObserver(IMediaPlayerSourceObserver* observer) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Releases the media player source observer.
|
||||||
|
* @param observer The pointer to the IMediaPlayerSourceObserver object.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure. See {@link media::base::MEDIA_PLAYER_ERROR MEDIA_PLAYER_ERROR}.
|
||||||
|
*/
|
||||||
|
virtual int unregisterPlayerSourceObserver(IMediaPlayerSourceObserver* observer) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers the audio frame observer.
|
||||||
|
*
|
||||||
|
* @param observer The pointer to the {@link media::base::IAudioFrameObserver IAudioFrameObserver} object.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure. See {@link media::base::MEDIA_PLAYER_ERROR MEDIA_PLAYER_ERROR}.
|
||||||
|
*/
|
||||||
|
virtual int registerAudioFrameObserver(media::base::IAudioFrameObserver* observer) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Releases the audio frame observer.
|
||||||
|
* @param observer The pointer to the {@link media::base::IAudioFrameObserver IAudioFrameObserver} object.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure. See {@link media::base::MEDIA_PLAYER_ERROR MEDIA_PLAYER_ERROR}.
|
||||||
|
*/
|
||||||
|
virtual int unregisterAudioFrameObserver(media::base::IAudioFrameObserver* observer) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open the Agora CDN media source.
|
||||||
|
* @param src The src of the media file that you want to play.
|
||||||
|
* @param startPos The playback position (ms).
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int openWithAgoraCDNSrc(const char* src, int64_t startPos) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the number of Agora CDN lines.
|
||||||
|
* @return
|
||||||
|
* - > 0: number of CDN.
|
||||||
|
* - <= 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int getAgoraCDNLineCount() = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Switch Agora CDN lines.
|
||||||
|
* @param index Specific CDN line index.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int switchAgoraCDNLineByIndex(int index) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the line of the current CDN.
|
||||||
|
* @return
|
||||||
|
* - >= 0: Specific line.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int getCurrentAgoraCDNIndex() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable automatic CDN line switching.
|
||||||
|
* @param enable Whether enable.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int enableAutoSwitchAgoraCDN(bool enable) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the CDN source token and timestamp.
|
||||||
|
* @param token token.
|
||||||
|
* @param ts ts.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int renewAgoraCDNSrcToken(const char* token, int64_t ts) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Switch the CDN source when open a media through "openWithAgoraCDNSrc" API
|
||||||
|
* @param src Specific src.
|
||||||
|
* @param syncPts Live streaming must be set to false.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int switchAgoraCDNSrc(const char* src, bool syncPts = false) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Switch the media source when open a media through "open" API
|
||||||
|
* @param src Specific src.
|
||||||
|
* @param syncPts Live streaming must be set to false.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int switchSrc(const char* src, bool syncPts) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Preload a media source
|
||||||
|
* @param src Specific src.
|
||||||
|
* @param startPos The starting position (ms) for playback. Default value is 0.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int preloadSrc(const char* src, int64_t startPos) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unload a preloaded media source
|
||||||
|
* @param src Specific src.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int unloadSrc(const char* src) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Play a pre-loaded media source
|
||||||
|
* @param src Specific src.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int playPreloadedSrc(const char* src) = 0;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class class reports runtime events to the applications.
|
||||||
|
*/
|
||||||
|
class IMediaPlayerSourceObserver {
|
||||||
|
public:
|
||||||
|
virtual ~IMediaPlayerSourceObserver() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Reports the playback state change.
|
||||||
|
*
|
||||||
|
* 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}.
|
||||||
|
*/
|
||||||
|
virtual void onPlayerSourceStateChanged(media::base::MEDIA_PLAYER_STATE state,
|
||||||
|
media::base::MEDIA_PLAYER_ERROR ec) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Reports current playback progress.
|
||||||
|
*
|
||||||
|
* The callback occurs once every one second during the playback and reports the current playback progress.
|
||||||
|
* @param positionMs Current playback progress (milisecond).
|
||||||
|
* @param timestampMs Current NTP(Network Time Protocol) time (milisecond).
|
||||||
|
*/
|
||||||
|
virtual void onPositionChanged(int64_t positionMs, int64_t timestampMs) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Reports the playback event.
|
||||||
|
*
|
||||||
|
* - After calling the `seek` method, the SDK triggers the callback to report the results of the seek operation.
|
||||||
|
* - After calling the `selectAudioTrack` method, the SDK triggers the callback to report that the audio track changes.
|
||||||
|
*
|
||||||
|
* @param eventCode The playback event. See {@link media::base::MEDIA_PLAYER_EVENT MEDIA_PLAYER_EVENT}.
|
||||||
|
* @param elapsedTime The playback elapsed time.
|
||||||
|
* @param message The playback message.
|
||||||
|
*/
|
||||||
|
virtual void onPlayerEvent(media::base::MEDIA_PLAYER_EVENT eventCode, int64_t elapsedTime, const char* message) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Occurs when the metadata is received.
|
||||||
|
*
|
||||||
|
* The callback occurs when the player receives the media metadata and reports the detailed information of the media metadata.
|
||||||
|
* @param data The detailed data of the media metadata.
|
||||||
|
* @param length The data length (bytes).
|
||||||
|
*/
|
||||||
|
virtual void onMetaData(const void* data, int length) = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Triggered when play buffer updated, once every 1 second
|
||||||
|
*
|
||||||
|
* @param int cached buffer during playing, in milliseconds
|
||||||
|
*/
|
||||||
|
virtual void onPlayBufferUpdated(int64_t playCachedBuffer) = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Triggered when the player preloadSrc
|
||||||
|
*
|
||||||
|
* @param event
|
||||||
|
*/
|
||||||
|
virtual void onPreloadEvent(const char* src, media::base::PLAYER_PRELOAD_EVENT event) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Occurs when one playback of the media file is completed.
|
||||||
|
*/
|
||||||
|
virtual void onCompleted() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief AgoraCDN Token has expired and needs to be set up with renewAgoraCDNSrcToken(const char* src).
|
||||||
|
*/
|
||||||
|
virtual void onAgoraCDNTokenWillExpire() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Reports current playback source bitrate changed.
|
||||||
|
* @brief Reports current playback source info changed.
|
||||||
|
*
|
||||||
|
* @param from Streaming media information before the change.
|
||||||
|
* @param to Streaming media information after the change.
|
||||||
|
*/
|
||||||
|
virtual void onPlayerSrcInfoChanged(const media::base::SrcInfo& from, const media::base::SrcInfo& to) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Triggered when media player information updated.
|
||||||
|
*
|
||||||
|
* @param info Include information of media player.
|
||||||
|
*/
|
||||||
|
virtual void onPlayerInfoUpdated(const media::base::PlayerUpdatedInfo& info) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Triggered every 200 millisecond ,update player current volume range [0,255]
|
||||||
|
*
|
||||||
|
* @param volume volume of current player.
|
||||||
|
*/
|
||||||
|
virtual void onAudioVolumeIndication(int volume) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} //namespace rtc
|
||||||
|
} // namespace agora
|
|
@ -0,0 +1,26 @@
|
||||||
|
//
|
||||||
|
// Agora SDK
|
||||||
|
//
|
||||||
|
// Copyright (c) 2022 Agora.io. All rights reserved.
|
||||||
|
//
|
||||||
|
#pragma once // NOLINT(build/header_guard)
|
||||||
|
|
||||||
|
#include "AgoraBase.h"
|
||||||
|
#include "AgoraMediaBase.h"
|
||||||
|
#include "IAgoraRtcEngineEx.h"
|
||||||
|
|
||||||
|
namespace agora {
|
||||||
|
namespace rtc {
|
||||||
|
|
||||||
|
class IMediaRecorder {
|
||||||
|
protected:
|
||||||
|
virtual ~IMediaRecorder() {}
|
||||||
|
public:
|
||||||
|
virtual int setMediaRecorderObserver(const RtcConnection& connection, media::IMediaRecorderObserver* callback) = 0;
|
||||||
|
virtual int startRecording(const RtcConnection& connection, const media::MediaRecorderConfiguration& config) = 0;
|
||||||
|
virtual int stopRecording(const RtcConnection& connection) = 0;
|
||||||
|
virtual void release() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} //namespace rtc
|
||||||
|
} // namespace agora
|
|
@ -0,0 +1,332 @@
|
||||||
|
//
|
||||||
|
// Agora SDK
|
||||||
|
// Copyright (c) 2019 Agora.io. All rights reserved.
|
||||||
|
//
|
||||||
|
// Created by xiaohua.lu in 2020-03.
|
||||||
|
// CodeStyle: Google C++
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once // NOLINT(build/header_guard)
|
||||||
|
|
||||||
|
|
||||||
|
#include "AgoraBase.h"
|
||||||
|
#include "AgoraMediaBase.h"
|
||||||
|
#include "AgoraMediaPlayerTypes.h"
|
||||||
|
#include "AgoraRefPtr.h"
|
||||||
|
|
||||||
|
namespace agora {
|
||||||
|
namespace rtc {
|
||||||
|
|
||||||
|
|
||||||
|
class IMediaStreamingSourceObserver;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The error code of streaming source
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
enum STREAMING_SRC_ERR {
|
||||||
|
STREAMING_SRC_ERR_NONE = 0, ///< no error
|
||||||
|
STREAMING_SRC_ERR_UNKNOWN = 1, ///< unknown error
|
||||||
|
STREAMING_SRC_ERR_INVALID_PARAM = 2, ///< invalid parameter
|
||||||
|
STREAMING_SRC_ERR_BAD_STATE = 3, ///< bad status
|
||||||
|
STREAMING_SRC_ERR_NO_MEM = 4, ///< not enough memory
|
||||||
|
STREAMING_SRC_ERR_BUFFER_OVERFLOW = 5, ///< buffer overflow
|
||||||
|
STREAMING_SRC_ERR_BUFFER_UNDERFLOW = 6, ///< buffer underflow
|
||||||
|
STREAMING_SRC_ERR_NOT_FOUND = 7, ///< buffer underflow
|
||||||
|
STREAMING_SRC_ERR_TIMEOUT = 8, ///< buffer underflow
|
||||||
|
STREAMING_SRC_ERR_EXPIRED = 9, ///< expired
|
||||||
|
STREAMING_SRC_ERR_UNSUPPORTED = 10, ///< unsupported
|
||||||
|
STREAMING_SRC_ERR_NOT_EXIST = 11, ///< component not exist
|
||||||
|
STREAMING_SRC_ERR_EXIST = 12, ///< component already exist
|
||||||
|
STREAMING_SRC_ERR_OPEN = 13, ///< fail to IO open
|
||||||
|
STREAMING_SRC_ERR_CLOSE = 14, ///< fail to IO close
|
||||||
|
STREAMING_SRC_ERR_READ = 15, ///< fail to IO read
|
||||||
|
STREAMING_SRC_ERR_WRITE = 16, ///< fail to IO write
|
||||||
|
STREAMING_SRC_ERR_SEEK = 17, ///< fail to IO seek
|
||||||
|
STREAMING_SRC_ERR_EOF = 18, ///< reach to IO EOF, can do nothing
|
||||||
|
STREAMING_SRC_ERR_CODECOPEN = 19, ///< fail to codec open
|
||||||
|
STREAMING_SRC_ERR_CODECCLOSE = 20, ///< fail to codec close
|
||||||
|
STREAMING_SRC_ERR_CODECPROC = 21, ///< fail to codec process
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The state machine of Streaming Source
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
enum STREAMING_SRC_STATE {
|
||||||
|
STREAMING_SRC_STATE_CLOSED = 0, ///< streaming source still closed, can do nothing
|
||||||
|
STREAMING_SRC_STATE_OPENING = 1, ///< after call open() method and start parsing streaming source
|
||||||
|
STREAMING_SRC_STATE_IDLE = 2, ///< streaming source is ready waiting for play
|
||||||
|
STREAMING_SRC_STATE_PLAYING = 3, ///< after call play() method, playing & pushing the AV data
|
||||||
|
STREAMING_SRC_STATE_SEEKING = 4, ///< after call seek() method, start seeking poisition
|
||||||
|
STREAMING_SRC_STATE_EOF = 5, ///< The position is located at end, can NOT playing
|
||||||
|
STREAMING_SRC_STATE_ERROR = 6, ///< The error status and can do nothing except close
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The input SEI data
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
struct InputSeiData {
|
||||||
|
int32_t type; ///< SEI type
|
||||||
|
int64_t timestamp; ///< the frame timestamp which be attached
|
||||||
|
int64_t frame_index; ///< the frame index which be attached
|
||||||
|
uint8_t* private_data; ///< SEI really data
|
||||||
|
int32_t data_size; ///< size of really data
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The IMediaStreamingSource class provides access to a media streaming source demuxer.
|
||||||
|
* To playout multiple stream sources simultaneously,
|
||||||
|
* create multiple media stream source objects.
|
||||||
|
*/
|
||||||
|
class IMediaStreamingSource : public RefCountInterface {
|
||||||
|
public:
|
||||||
|
virtual ~IMediaStreamingSource() {};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Opens a media streaming source with a specified URL.
|
||||||
|
* @param url The path of the media file. Both the local path and online path are supported.
|
||||||
|
* @param startPos The starting position (ms) for pushing. Default value is 0.
|
||||||
|
* @param auto_play whether start playing after opened
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure
|
||||||
|
*/
|
||||||
|
virtual int open(const char* url, int64_t start_pos, bool auto_play = true) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Close current media streaming source
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure
|
||||||
|
*/
|
||||||
|
virtual int close() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Gets the unique source ID of the streaming source.
|
||||||
|
* @return
|
||||||
|
* - ≧ 0: The source ID of this media player source.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int getSourceId() const = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Retrieve whether video stream is valid
|
||||||
|
* @return: valid or invalid
|
||||||
|
*/
|
||||||
|
virtual bool isVideoValid() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Retrieve whether audio stream is valid
|
||||||
|
* @return: valid or invalid
|
||||||
|
*/
|
||||||
|
virtual bool isAudioValid() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Gets the duration of the streaming source.
|
||||||
|
* @param [out] duration A reference to the duration of the media file.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure. See {@link STREAMINGSRC_ERR}.
|
||||||
|
*/
|
||||||
|
virtual int getDuration(int64_t& duration) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Gets the number of the streming source
|
||||||
|
* @param [out] count The number of the media streams in the media source.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure. See {@link STREAMINGSRC_ERR}.
|
||||||
|
*/
|
||||||
|
virtual int getStreamCount(int64_t& count) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Gets the detailed information of a media stream.
|
||||||
|
* @param index The index of the media stream.
|
||||||
|
* @param [out] out_info The detailed information of the media stream. See \ref media::base::PlayerStreamInfo "PlayerStreamInfo" for details.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure. See {@link STREAMINGSRC_ERR}.
|
||||||
|
*/
|
||||||
|
virtual int getStreamInfo(int64_t index, media::base::PlayerStreamInfo* out_info) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Sets whether to loop the streaming source for playback.
|
||||||
|
* @param loop_count The number of times of looping the media file.
|
||||||
|
* - 1: Play the media file once.
|
||||||
|
* - 2: Play the media file twice.
|
||||||
|
* - <= 0: Play the media file in a loop indefinitely, until {@link stop} is called.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure. See {@link STREAMINGSRC_ERR}.
|
||||||
|
*/
|
||||||
|
virtual int setLoopCount(int64_t loop_count) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Play & push the streaming source.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure. See {@link STREAMINGSRC_ERR}.
|
||||||
|
*/
|
||||||
|
virtual int play() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Pauses the playing & pushing of the streaming source, Keep current position.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure. See {@link STREAMINGSRC_ERR}.
|
||||||
|
*/
|
||||||
|
virtual int pause() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Stop the playing & pushing of the streaming source, set the position to 0.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.See {@link STREAMINGSRC_ERR}.
|
||||||
|
*/
|
||||||
|
virtual int stop() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Sets the playback position of the streaming source.
|
||||||
|
* After seek done, it will return to previous status
|
||||||
|
* @param newPos The new playback position (ms).
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure. See {@link STREAMINGSRC_ERR}.
|
||||||
|
*/
|
||||||
|
virtual int seek(int64_t new_pos) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Gets the current playback position of the media file.
|
||||||
|
* @param [out] pos A reference to the current playback position (ms).
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure. See {@link STREAMINGSRC_ERR}.
|
||||||
|
*/
|
||||||
|
virtual int getCurrPosition(int64_t& pos) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @breif Gets the status of current streaming source.
|
||||||
|
* @return The current state machine
|
||||||
|
*/
|
||||||
|
virtual STREAMING_SRC_STATE getCurrState() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief append the SEI data which can be sent attached to video packet
|
||||||
|
* @param type SEI type
|
||||||
|
* @param timestamp the video frame timestamp which attached to
|
||||||
|
* @param frame_index the video frame timestamp which attached to
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure. See {@link STREAMINGSRC_ERR}.
|
||||||
|
*/
|
||||||
|
virtual int appendSeiData(const InputSeiData& inSeiData) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a media player source observer.
|
||||||
|
*
|
||||||
|
* Once the media player source observer is registered, you can use the observer to monitor the state change of the media player.
|
||||||
|
* @param observer The pointer to the IMediaStreamingSource object.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure. See {@link STREAMINGSRC_ERR}.
|
||||||
|
*/
|
||||||
|
virtual int registerObserver(IMediaStreamingSourceObserver* observer) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Releases the media player source observer.
|
||||||
|
* @param observer The pointer to the IMediaStreamingSource object.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure. See {@link STREAMINGSRC_ERR}.
|
||||||
|
*/
|
||||||
|
virtual int unregisterObserver(IMediaStreamingSourceObserver* observer) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Parse a media information with a specified URL.
|
||||||
|
* @param url : The path of the media file. Both the local path and online path are supported.
|
||||||
|
* @param video_info : The output video information, It means no video track while video_info.streamIndex less than 0
|
||||||
|
* @param audio_info : The output audio information, It means no audio track while audio_info.streamIndex less than 0
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure
|
||||||
|
*/
|
||||||
|
virtual int parseMediaInfo(const char* url,
|
||||||
|
media::base::PlayerStreamInfo& video_info,
|
||||||
|
media::base::PlayerStreamInfo& audio_info) = 0;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This observer interface of media streaming source
|
||||||
|
*/
|
||||||
|
class IMediaStreamingSourceObserver {
|
||||||
|
public:
|
||||||
|
virtual ~IMediaStreamingSourceObserver() {};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Reports the playback state change.
|
||||||
|
* 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 STREAMING_SRC_STATE}.
|
||||||
|
* @param ec The player's error code. See {@link STREAMINGSRC_ERR}.
|
||||||
|
*/
|
||||||
|
virtual void onStateChanged(STREAMING_SRC_STATE state, STREAMING_SRC_ERR err_code) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Triggered when file is opened
|
||||||
|
* @param err_code The error code
|
||||||
|
* @return None
|
||||||
|
*/
|
||||||
|
virtual void onOpenDone(STREAMING_SRC_ERR err_code) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Triggered when seeking is done
|
||||||
|
* @param err_code The error code
|
||||||
|
* @return None
|
||||||
|
*/
|
||||||
|
virtual void onSeekDone(STREAMING_SRC_ERR err_code) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Triggered when playing is EOF
|
||||||
|
* @param progress_ms the progress position
|
||||||
|
* @param repeat_count means repeated count of playing
|
||||||
|
*/
|
||||||
|
virtual void onEofOnce(int64_t progress_ms, int64_t repeat_count) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Reports current playback progress.
|
||||||
|
* The callback triggered once every one second during the playing status
|
||||||
|
* @param position_ms Current playback progress (millisecond).
|
||||||
|
*/
|
||||||
|
virtual void onProgress(int64_t position_ms) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Occurs when the metadata is received.
|
||||||
|
* The callback occurs when the player receives the media metadata
|
||||||
|
* and reports the detailed information of the media metadata.
|
||||||
|
* @param data The detailed data of the media metadata.
|
||||||
|
* @param length The data length (bytes).
|
||||||
|
*/
|
||||||
|
virtual void onMetaData(const void* data, int length) = 0;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} //namespace rtc
|
||||||
|
} // namespace agora
|
||||||
|
|
|
@ -0,0 +1,539 @@
|
||||||
|
//
|
||||||
|
// Agora Media SDK
|
||||||
|
//
|
||||||
|
// Created by FanYuanYuan in 2022-05.
|
||||||
|
// Copyright (c) 2022 Agora IO. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "AgoraRefPtr.h"
|
||||||
|
#include "IAgoraMediaPlayer.h"
|
||||||
|
|
||||||
|
namespace agora {
|
||||||
|
namespace rtc {
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 0: No error occurs and preload succeeds.
|
||||||
|
*/
|
||||||
|
kPreloadStatusCompleted = 0,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 1: A general error occurs.
|
||||||
|
*/
|
||||||
|
kPreloadStatusFailed = 1,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 2: The media file is preloading.
|
||||||
|
*/
|
||||||
|
kPreloadStatusPreloading = 2,
|
||||||
|
/**
|
||||||
|
* 3: The media file is removed.
|
||||||
|
*/
|
||||||
|
kPreloadStatusRemoved = 3,
|
||||||
|
} PreloadStatusCode;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 0: No error occurs and request succeeds.
|
||||||
|
*/
|
||||||
|
kMusicContentCenterStatusOk = 0,
|
||||||
|
/**
|
||||||
|
* 1: A general error occurs.
|
||||||
|
*/
|
||||||
|
kMusicContentCenterStatusErr = 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,
|
||||||
|
/**
|
||||||
|
* 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,
|
||||||
|
/**
|
||||||
|
* 4: Internal data parse error. Please contact technical support
|
||||||
|
*/
|
||||||
|
kMusicContentCenterStatusErrInternalDataParse = 4,
|
||||||
|
/**
|
||||||
|
* 5: Music loading error. Please contact technical support
|
||||||
|
*/
|
||||||
|
kMusicContentCenterStatusErrMusicLoading = 5,
|
||||||
|
/**
|
||||||
|
* 6: Music decryption error. Please contact technical support
|
||||||
|
*/
|
||||||
|
kMusicContentCenterStatusErrMusicDecryption = 6,
|
||||||
|
/**
|
||||||
|
* 7: Http internal error. suggest retry later.
|
||||||
|
*/
|
||||||
|
kMusicContentCenterStatusErHttpInternalError = 7,
|
||||||
|
} MusicContentCenterStatusCode;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Name of the music chart
|
||||||
|
*/
|
||||||
|
const char* chartName;
|
||||||
|
/**
|
||||||
|
* Id of the music chart, which is used to get music list
|
||||||
|
*/
|
||||||
|
int32_t id;
|
||||||
|
} MusicChartInfo;
|
||||||
|
|
||||||
|
enum MUSIC_CACHE_STATUS_TYPE {
|
||||||
|
/**
|
||||||
|
* 0: Music is already cached.
|
||||||
|
*/
|
||||||
|
MUSIC_CACHE_STATUS_TYPE_CACHED = 0,
|
||||||
|
/**
|
||||||
|
* 1: Music is being cached.
|
||||||
|
*/
|
||||||
|
MUSIC_CACHE_STATUS_TYPE_CACHING = 1
|
||||||
|
};
|
||||||
|
|
||||||
|
struct MusicCacheInfo {
|
||||||
|
/**
|
||||||
|
* The songCode of music.
|
||||||
|
*/
|
||||||
|
int64_t songCode;
|
||||||
|
/**
|
||||||
|
* The cache status of the music.
|
||||||
|
*/
|
||||||
|
MUSIC_CACHE_STATUS_TYPE status;
|
||||||
|
MusicCacheInfo():songCode(0), status(MUSIC_CACHE_STATUS_TYPE_CACHED) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
class MusicChartCollection : public RefCountInterface {
|
||||||
|
public:
|
||||||
|
virtual int getCount() = 0;
|
||||||
|
virtual MusicChartInfo* get(int index) = 0;
|
||||||
|
protected:
|
||||||
|
virtual ~MusicChartCollection() = default;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct MvProperty
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The resolution of the mv
|
||||||
|
*/
|
||||||
|
const char* resolution;
|
||||||
|
/**
|
||||||
|
* The bandwidth of the mv
|
||||||
|
*/
|
||||||
|
const char* bandwidth;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ClimaxSegment
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The start time of climax segment
|
||||||
|
*/
|
||||||
|
int32_t startTimeMs;
|
||||||
|
/**
|
||||||
|
* The end time of climax segment
|
||||||
|
*/
|
||||||
|
int32_t endTimeMs;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Music
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The songCode of music
|
||||||
|
*/
|
||||||
|
int64_t songCode;
|
||||||
|
/**
|
||||||
|
* The name of music
|
||||||
|
*/
|
||||||
|
const char* name;
|
||||||
|
/**
|
||||||
|
* The singer of music
|
||||||
|
*/
|
||||||
|
const char* singer;
|
||||||
|
/**
|
||||||
|
* The poster url of music
|
||||||
|
*/
|
||||||
|
const char* poster;
|
||||||
|
/**
|
||||||
|
* The release time of music
|
||||||
|
*/
|
||||||
|
const char* releaseTime;
|
||||||
|
/**
|
||||||
|
* The duration (in seconds) of music
|
||||||
|
*/
|
||||||
|
int32_t durationS;
|
||||||
|
/**
|
||||||
|
* The type of music
|
||||||
|
* 1, mp3 with instrumental accompaniment and original
|
||||||
|
* 2, mp3 only with instrumental accompaniment
|
||||||
|
* 3, mp3 only with original
|
||||||
|
* 4, mp4 with instrumental accompaniment and original
|
||||||
|
* 5, mv only
|
||||||
|
* 6, new type mp4 with instrumental accompaniment and original
|
||||||
|
* detail at document of music media center
|
||||||
|
*/
|
||||||
|
int32_t type;
|
||||||
|
/**
|
||||||
|
* The pitch type of music.
|
||||||
|
* 1, xml lyric has pitch
|
||||||
|
* 2, lyric has no pitch
|
||||||
|
*/
|
||||||
|
int32_t pitchType;
|
||||||
|
/**
|
||||||
|
* The number of lyrics available for the music
|
||||||
|
*/
|
||||||
|
int32_t lyricCount;
|
||||||
|
/**
|
||||||
|
* The lyric list of music
|
||||||
|
* 0, xml
|
||||||
|
* 1, lrc
|
||||||
|
*/
|
||||||
|
int32_t* lyricList;
|
||||||
|
/**
|
||||||
|
* The number of climax segments of the music
|
||||||
|
*/
|
||||||
|
int32_t climaxSegmentCount;
|
||||||
|
/**
|
||||||
|
* The climax segment list of music
|
||||||
|
*/
|
||||||
|
ClimaxSegment* climaxSegmentList;
|
||||||
|
/**
|
||||||
|
* The number of mv of the music
|
||||||
|
* If this value is greater than zero, it means the current music has MV resource
|
||||||
|
*/
|
||||||
|
int32_t mvPropertyCount;
|
||||||
|
/**
|
||||||
|
* The mv property list of music
|
||||||
|
*/
|
||||||
|
MvProperty* mvPropertyList;
|
||||||
|
};
|
||||||
|
|
||||||
|
class MusicCollection : public RefCountInterface {
|
||||||
|
public:
|
||||||
|
virtual int getCount() = 0;
|
||||||
|
virtual int getTotal() = 0;
|
||||||
|
virtual int getPage() = 0;
|
||||||
|
virtual int getPageSize() = 0;
|
||||||
|
virtual Music* getMusic(int32_t index) = 0;
|
||||||
|
protected:
|
||||||
|
virtual ~MusicCollection() = default;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class IMusicContentCenterEventHandler {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* The music chart result callback; occurs when getMusicCharts method is called.
|
||||||
|
*
|
||||||
|
* @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
|
||||||
|
*/
|
||||||
|
virtual void onMusicChartsResult(const char* requestId, agora_refptr<MusicChartCollection> result, MusicContentCenterStatusCode errorCode) = 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
|
||||||
|
*/
|
||||||
|
virtual void onMusicCollectionResult(const char* requestId, agora_refptr<MusicCollection> result, MusicContentCenterStatusCode errorCode) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lyric url callback of getLyric, occurs when getLyric is called
|
||||||
|
*
|
||||||
|
* @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
|
||||||
|
*/
|
||||||
|
virtual void onLyricResult(const char* requestId, int64_t songCode, const char* lyricUrl, MusicContentCenterStatusCode errorCode) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simple info callback of getSongSimpleInfo, occurs when getSongSimpleInfo is called
|
||||||
|
*
|
||||||
|
* @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
|
||||||
|
*/
|
||||||
|
virtual void onSongSimpleInfoResult(const char* requestId, int64_t songCode, const char* simpleInfo, MusicContentCenterStatusCode errorCode) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Preload process callback, occurs when preload is called
|
||||||
|
*
|
||||||
|
* @param requestId The request id is same as that returned by preload.
|
||||||
|
* @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
|
||||||
|
*/
|
||||||
|
virtual void onPreLoadEvent(const char* requestId, int64_t songCode, int percent, const char* lyricUrl, PreloadStatusCode status, MusicContentCenterStatusCode errorCode) = 0;
|
||||||
|
|
||||||
|
virtual ~IMusicContentCenterEventHandler() {};
|
||||||
|
};
|
||||||
|
|
||||||
|
struct MusicContentCenterConfiguration {
|
||||||
|
/**
|
||||||
|
* The app ID of the project that has enabled the music content center
|
||||||
|
*/
|
||||||
|
const char *appId;
|
||||||
|
/**
|
||||||
|
* Music content center need token to connect with server
|
||||||
|
*/
|
||||||
|
const char *token;
|
||||||
|
/**
|
||||||
|
* The user ID when using music content center. It can be different from that of the rtc product.
|
||||||
|
*/
|
||||||
|
int64_t mccUid;
|
||||||
|
/**
|
||||||
|
* The max number which the music content center caches cannot exceed 50.
|
||||||
|
*/
|
||||||
|
int32_t maxCacheSize;
|
||||||
|
/**
|
||||||
|
* The mccdomain, used to control the domain name of music content center, usually developer do not need to set it. Only under Tech supporter's help, can set the value.
|
||||||
|
* @technical preview
|
||||||
|
*/
|
||||||
|
const char* mccDomain;
|
||||||
|
/**
|
||||||
|
* Event handler to get callback result.
|
||||||
|
*/
|
||||||
|
IMusicContentCenterEventHandler* eventHandler;
|
||||||
|
MusicContentCenterConfiguration():appId(nullptr),token(nullptr),eventHandler(nullptr),mccUid(0),maxCacheSize(10), mccDomain(nullptr){}
|
||||||
|
MusicContentCenterConfiguration(const char*appid,const char* token,int64_t id,IMusicContentCenterEventHandler* handler,int32_t maxSize = 10, const char* apiurl = nullptr):
|
||||||
|
appId(appid),token(token),mccUid(id),eventHandler(handler),maxCacheSize(maxSize), mccDomain(apiurl){}
|
||||||
|
};
|
||||||
|
|
||||||
|
class IMusicPlayer : public IMediaPlayer {
|
||||||
|
protected:
|
||||||
|
virtual ~IMusicPlayer() {};
|
||||||
|
|
||||||
|
public:
|
||||||
|
IMusicPlayer() {};
|
||||||
|
using IMediaPlayer::open;
|
||||||
|
/**
|
||||||
|
* Open a media file with specified parameters.
|
||||||
|
*
|
||||||
|
* @param songCode The identifier of the media file that you want to play.
|
||||||
|
* @param startPos The playback position (ms) of the music file.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int open(int64_t songCode, int64_t startPos = 0) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class IMusicContentCenter
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
virtual ~IMusicContentCenter(){};
|
||||||
|
public:
|
||||||
|
IMusicContentCenter() {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the IMusicContentCenter
|
||||||
|
* Set token of music content center and other params
|
||||||
|
*
|
||||||
|
* @param configuration
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int initialize(const MusicContentCenterConfiguration & configuration) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renew token of music content center
|
||||||
|
*
|
||||||
|
* @param token The new token.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int renewToken(const char* token) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* release music content center resource.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
virtual void release() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* register event handler.
|
||||||
|
*/
|
||||||
|
virtual int registerEventHandler(IMusicContentCenterEventHandler* eventHandler) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* unregister event handler.
|
||||||
|
*/
|
||||||
|
virtual int unregisterEventHandler() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a music player source object and return its pointer.
|
||||||
|
* @return
|
||||||
|
* - The pointer to \ref rtc::IMusicPlayer "IMusicPlayer",
|
||||||
|
* if the method call succeeds.
|
||||||
|
* - The empty pointer NULL, if the method call fails.
|
||||||
|
*/
|
||||||
|
virtual agora_refptr<IMusicPlayer> createMusicPlayer() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get music chart collection of music.
|
||||||
|
* If the method call succeeds, get result from the
|
||||||
|
* \ref agora::rtc::IMusicContentCenterEventHandler::onMusicChartsResult
|
||||||
|
* "onMusicChartsResult" callback
|
||||||
|
* @param requestId The request id you will get of this query, format is uuid.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int getMusicCharts(agora::util::AString& requestId) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get music collection of the music chart by musicChartId and page info.
|
||||||
|
* If the method call success, get result from the
|
||||||
|
* \ref agora::rtc::IMusicContentCenterEventHandler::onMusicCollectionResult
|
||||||
|
* "onMusicCollectionResult" callback
|
||||||
|
* @param requestId The request id you will get of this query, format is uuid.
|
||||||
|
* @param musicChartId The music chart id obtained from getMusicCharts.
|
||||||
|
* @param page The page of the music chart, starting from 1
|
||||||
|
* @param pageSize The page size, max is 50.
|
||||||
|
* @param jsonOption The ext param, default is null.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int getMusicCollectionByMusicChartId(agora::util::AString& requestId, int32_t musicChartId, int32_t page, int32_t pageSize, const char* jsonOption = nullptr) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search music by keyword and page info.
|
||||||
|
* If the method call success, get result from the
|
||||||
|
* \ref agora::rtc::IMusicContentCenterEventHandler::onMusicCollectionResult
|
||||||
|
* "onMusicCollectionResult" callback
|
||||||
|
* @param requestId The request id you will get of this query, format is uuid.
|
||||||
|
* @param keyWord The key word to search.
|
||||||
|
* @param page The page of music search result , start from 1.
|
||||||
|
* @param pageSize The page size, max is 50.
|
||||||
|
* @param jsonOption The ext param, default is null.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int searchMusic(agora::util::AString& requestId, const char* keyWord, int32_t page, int32_t pageSize, const char* jsonOption = nullptr) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Preload a media file with specified parameters.
|
||||||
|
*
|
||||||
|
* @deprecated This method is deprecated. Use preload(int64_t songCode) instead.
|
||||||
|
*
|
||||||
|
* @param songCode The identifier of the media file that you want to play.
|
||||||
|
* @param jsonOption The ext param, default is null.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int preload(int64_t songCode, const char* jsonOption) __deprecated = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Preload a media file with specified parameters.
|
||||||
|
*
|
||||||
|
* @param requestId The request id you will get of this query, format is uuid.
|
||||||
|
* @param songCode The identifier of the media file that you want to play.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int preload(agora::util::AString& requestId, int64_t songCode) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a media file cache
|
||||||
|
*
|
||||||
|
* @param songCode The identifier of the media file that you want to play.
|
||||||
|
* @return
|
||||||
|
* - 0: Success; the cached media file is removed.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int removeCache(int64_t songCode) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get cached media files.
|
||||||
|
* Before calling this API, you should allocate a memory buffer that stores the cached media file information, and pass the pointer of the buffer as the input parameter cacheInfo, and set the size of the memory buffer to cacheInfoSize.
|
||||||
|
* The sample code below illustrates how to request the cached media file information:
|
||||||
|
*
|
||||||
|
* cacheInfoSize = 10 // Allocate a memory buffer of 10 MusicCacheInfo size
|
||||||
|
* agora::rtc::MusicCacheInfo *infos = new agora::rtc::MusicCacheInfo[cacheInfoSize];
|
||||||
|
* int ret = self.imcc->getCaches(infos, cacheInfoSize);
|
||||||
|
* if (ret < 0) { // error occurred!
|
||||||
|
* return;
|
||||||
|
* }
|
||||||
|
* std::cout << "the cache size:" << cacheInfoSize << std::endl; // The cache size: 5
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param cacheInfo An output parameter; A pointer to the memory buffer that stores the cached media file information. The memory buffer pointed to by cacheInfo should be allocated by yourself before calling this API.
|
||||||
|
* @param cacheInfoSize
|
||||||
|
* - Input: The number of MusicCacheInfo's size that you get from the memory.
|
||||||
|
* - Output: The actual number of MusicCacheInfo struct that is returned.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int getCaches(MusicCacheInfo *cacheInfo, int32_t* cacheInfoSize) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the media file is preloaded
|
||||||
|
*
|
||||||
|
* @param songCode The identifier of the media file that you want to play.
|
||||||
|
* @return
|
||||||
|
* - 0: Success, file is preloaded.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int isPreloaded(int64_t songCode) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get lyric of the music.
|
||||||
|
*
|
||||||
|
* @param requestId The request id you will get of this query, format is uuid.
|
||||||
|
* @param songCode The identifier of the media file that you want to play.
|
||||||
|
* @param LyricType The type of the lyric file. 0:xml or 1:lrc.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int getLyric(agora::util::AString& requestId, int64_t songCode, int32_t LyricType = 0) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the metadata of a specific music. Once this method is called, the SDK triggers the onSongSimpleInfoResult callback to report the metadata of the music.
|
||||||
|
*
|
||||||
|
* @param requestId The request id you will get of this query, format is uuid.
|
||||||
|
* @param songCode The identifier of the media file.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int getSongSimpleInfo(agora::util::AString& requestId, int64_t songCode) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get internal songCodeKey from songCode and jsonOption
|
||||||
|
*
|
||||||
|
* @param songCode The identifier of the media file.
|
||||||
|
* @param jsonOption An extention parameter. The default value is null. it’s a json-format string and the `key` and `value` can be customized according to your scenarios.
|
||||||
|
* @param internalSongCode The identifier of internal
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
|
||||||
|
virtual int getInternalSongCode(int64_t songCode, const char* jsonOption, int64_t& internalSongCode) = 0;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace rtc
|
||||||
|
} // namespace agora
|
|
@ -0,0 +1,307 @@
|
||||||
|
//
|
||||||
|
// Agora Engine SDK
|
||||||
|
//
|
||||||
|
// Created by minbo in 2019-10.
|
||||||
|
// Copyright (c) 2019 Agora.io. All rights reserved.
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license
|
||||||
|
* that can be found in the LICENSE file in the root of the source
|
||||||
|
* tree. An additional intellectual property rights grant can be found
|
||||||
|
* in the file PATENTS. All contributing project authors may
|
||||||
|
* be found in the AUTHORS file in the root of the source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once // NOLINT(build/header_guard)
|
||||||
|
|
||||||
|
// external key
|
||||||
|
/**
|
||||||
|
* set the range of ports available for connection
|
||||||
|
* @example "{\"rtc.udp_port_range\":[4500, 5000]}"
|
||||||
|
*/
|
||||||
|
#define KEY_RTC_UDP_PORT_RANGE "rtc.udp_port_range"
|
||||||
|
/**
|
||||||
|
* set the list of ports available for connection
|
||||||
|
* @example "{\"rtc.udp_port_list\":[4501, 4502, 4503, 4504, 4505, 4506]}"
|
||||||
|
*/
|
||||||
|
#define KEY_RTC_UDP_PORT_LIST "rtc.udp_port_list"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get the fd of sending socket available for connection
|
||||||
|
* note: set method is not supported.
|
||||||
|
*/
|
||||||
|
#define KEY_RTC_UDP_SEND_FD "rtc.udp_send_fd"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set the video encoder mode (hardware or software)
|
||||||
|
*/
|
||||||
|
#define KEY_RTC_VIDEO_ENABLED_HW_ENCODER "engine.video.enable_hw_encoder"
|
||||||
|
#define KEY_RTC_VIDEO_HARDWARE_ENCODEING "che.hardware_encoding"
|
||||||
|
#define KEY_RTC_VIDEO_H264_HWENC "che.video.h264.hwenc"
|
||||||
|
/**
|
||||||
|
* set the hardware video encoder provider (nv for nvidia or qsv for intel)
|
||||||
|
*/
|
||||||
|
#define KEY_RTC_VIDEO_HW_ENCODER_PROVIDER "engine.video.hw_encoder_provider"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set the video decoder mode (hardware or software)
|
||||||
|
*/
|
||||||
|
#define KEY_RTC_VIDEO_ENABLED_HW_DECODER "engine.video.enable_hw_decoder"
|
||||||
|
#define KEY_RTC_VIDEO_HARDWARE_DECODING "che.hardware_decoding"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set the hardware video decoder provider (h264_cuvid(default) or h264_qsv)
|
||||||
|
*/
|
||||||
|
#define KEY_RTC_VIDEO_HW_DECODER_PROVIDER "engine.video.hw_decoder_provider"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* override the lua policy
|
||||||
|
*/
|
||||||
|
#define KEY_RTC_VIDEO_OVERRIDE_SMALLVIDEO_NOT_USE_HWENC_POLICY "engine.video.override_smallvideo_not_use_hwenc_policy"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* enable/disable video packet retransmission, enabled by default
|
||||||
|
*/
|
||||||
|
#define KEY_RTC_VIDEO_RESEND "rtc.video_resend"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* enable/disable audio packet retransmission, enabled by default
|
||||||
|
*/
|
||||||
|
#define KEY_RTC_AUDIO_RESEND "rtc.audio_resend"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set the bitrate ratio for video
|
||||||
|
*/
|
||||||
|
#define KEY_RTC_VIDEO_BITRATE_ADJUST_RATIO "rtc.video.bitrate_adjust_ratio"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set the minbitrate / bitrate ratio for video
|
||||||
|
*/
|
||||||
|
#define KEY_RTC_VIDEO_MINBITRATE_RATIO "rtc.video.minbitrate_ratio"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set the degradation preference
|
||||||
|
*/
|
||||||
|
#define KEY_RTC_VIDEO_DEGRADATION_PREFERENCE "rtc.video.degradation_preference"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set the degradation fps down step
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define KEY_RTC_VIDEO_DEGRADATION_FPS_DOWN_STEP "rtc.video.degradation_fps_down_step"
|
||||||
|
/**
|
||||||
|
* set the degradation fps up step
|
||||||
|
*/
|
||||||
|
#define KEY_RTC_VIDEO_DEGRADATION_FPS_UP_STEP "rtc.video.degradation_fps_up_step"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set the duration ms for connection lost callback
|
||||||
|
*/
|
||||||
|
#define KEY_RTC_CONNECTION_LOST_PERIOD "rtc.connection_lost_period"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set the local ip
|
||||||
|
*/
|
||||||
|
#define KEY_RTC_LOCAL_IP "rtc.local.ip"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set the network interface
|
||||||
|
*/
|
||||||
|
#define KEY_RTC_NETWORK_INTERFACE "rtc.network.interface"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set the video codec type, such as "H264", "JPEG"
|
||||||
|
*/
|
||||||
|
#define KEY_RTC_VIDEO_CODEC_TYPE "engine.video.codec_type"
|
||||||
|
#define KEY_RTC_VIDEO_CODEC_INDEX "che.video.videoCodecIndex"
|
||||||
|
/**
|
||||||
|
* only use average QP for quality scaling
|
||||||
|
*/
|
||||||
|
#define KEY_RTC_VIDEO_QUALITY_SCALE_ONLY_ON_AVERAGE_QP "engine.video.quality_scale_only_on_average_qp"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* low bound for quality scaling
|
||||||
|
*/
|
||||||
|
#define KEY_RTC_VIDEO_H264_QP_THRESHOLD_LOW "engine.video.h264_qp_thresholds_low"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* high bound for quality scaling
|
||||||
|
*/
|
||||||
|
#define KEY_RTC_VIDEO_H264_QP_THRESHOLD_HIGH "engine.video.h264_qp_thresholds_high"
|
||||||
|
|
||||||
|
|
||||||
|
namespace agora {
|
||||||
|
|
||||||
|
namespace util {
|
||||||
|
template <class T>
|
||||||
|
class CopyableAutoPtr;
|
||||||
|
|
||||||
|
class IString;
|
||||||
|
typedef CopyableAutoPtr<IString> AString;
|
||||||
|
} // namespace util
|
||||||
|
|
||||||
|
namespace base {
|
||||||
|
|
||||||
|
class IAgoraParameter {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* release the resource
|
||||||
|
*/
|
||||||
|
virtual void release() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set bool value of the json
|
||||||
|
* @param [in] key
|
||||||
|
* the key name
|
||||||
|
* @param [in] value
|
||||||
|
* the value
|
||||||
|
* @return return 0 if success or an error code
|
||||||
|
*/
|
||||||
|
virtual int setBool(const char* key, bool value) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set int value of the json
|
||||||
|
* @param [in] key
|
||||||
|
* the key name
|
||||||
|
* @param [in] value
|
||||||
|
* the value
|
||||||
|
* @return return 0 if success or an error code
|
||||||
|
*/
|
||||||
|
virtual int setInt(const char* key, int value) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set unsigned int value of the json
|
||||||
|
* @param [in] key
|
||||||
|
* the key name
|
||||||
|
* @param [in] value
|
||||||
|
* the value
|
||||||
|
* @return return 0 if success or an error code
|
||||||
|
*/
|
||||||
|
virtual int setUInt(const char* key, unsigned int value) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set double value of the json
|
||||||
|
* @param [in] key
|
||||||
|
* the key name
|
||||||
|
* @param [in] value
|
||||||
|
* the value
|
||||||
|
* @return return 0 if success or an error code
|
||||||
|
*/
|
||||||
|
virtual int setNumber(const char* key, double value) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set string value of the json
|
||||||
|
* @param [in] key
|
||||||
|
* the key name
|
||||||
|
* @param [in] value
|
||||||
|
* the value
|
||||||
|
* @return return 0 if success or an error code
|
||||||
|
*/
|
||||||
|
virtual int setString(const char* key, const char* value) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set object value of the json
|
||||||
|
* @param [in] key
|
||||||
|
* the key name
|
||||||
|
* @param [in] value
|
||||||
|
* the value
|
||||||
|
* @return return 0 if success or an error code
|
||||||
|
*/
|
||||||
|
virtual int setObject(const char* key, const char* value) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set array value of the json
|
||||||
|
* @param [in] key
|
||||||
|
* the key name
|
||||||
|
* @param [in] value
|
||||||
|
* the value
|
||||||
|
* @return return 0 if success or an error code
|
||||||
|
*/
|
||||||
|
virtual int setArray(const char* key, const char* value) = 0;
|
||||||
|
/**
|
||||||
|
* get bool value of the json
|
||||||
|
* @param [in] key
|
||||||
|
* the key name
|
||||||
|
* @param [in, out] value
|
||||||
|
* the value
|
||||||
|
* @return return 0 if success or an error code
|
||||||
|
*/
|
||||||
|
virtual int getBool(const char* key, bool& value) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get int value of the json
|
||||||
|
* @param [in] key
|
||||||
|
* the key name
|
||||||
|
* @param [in, out] value
|
||||||
|
* the value
|
||||||
|
* @return return 0 if success or an error code
|
||||||
|
*/
|
||||||
|
virtual int getInt(const char* key, int& value) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get unsigned int value of the json
|
||||||
|
* @param [in] key
|
||||||
|
* the key name
|
||||||
|
* @param [in, out] value
|
||||||
|
* the value
|
||||||
|
* @return return 0 if success or an error code
|
||||||
|
*/
|
||||||
|
virtual int getUInt(const char* key, unsigned int& value) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get double value of the json
|
||||||
|
* @param [in] key
|
||||||
|
* the key name
|
||||||
|
* @param [in, out] value
|
||||||
|
* the value
|
||||||
|
* @return return 0 if success or an error code
|
||||||
|
*/
|
||||||
|
virtual int getNumber(const char* key, double& value) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get string value of the json
|
||||||
|
* @param [in] key
|
||||||
|
* the key name
|
||||||
|
* @param [in, out] value
|
||||||
|
* the value
|
||||||
|
* @return return 0 if success or an error code
|
||||||
|
*/
|
||||||
|
virtual int getString(const char* key, agora::util::AString& value) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get a child object value of the json
|
||||||
|
* @param [in] key
|
||||||
|
* the key name
|
||||||
|
* @param [in, out] value
|
||||||
|
* the value
|
||||||
|
* @return return 0 if success or an error code
|
||||||
|
*/
|
||||||
|
virtual int getObject(const char* key, agora::util::AString& value) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get array value of the json
|
||||||
|
* @param [in] key
|
||||||
|
* the key name
|
||||||
|
* @param [in, out] value
|
||||||
|
* the value
|
||||||
|
* @return return 0 if success or an error code
|
||||||
|
*/
|
||||||
|
virtual int getArray(const char* key, const char* args, agora::util::AString& value) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set parameters of the sdk or engine
|
||||||
|
* @param [in] parameters
|
||||||
|
* the parameters
|
||||||
|
* @return return 0 if success or an error code
|
||||||
|
*/
|
||||||
|
virtual int setParameters(const char* parameters) = 0;
|
||||||
|
|
||||||
|
virtual int convertPath(const char* filePath, agora::util::AString& value) = 0;
|
||||||
|
|
||||||
|
virtual ~IAgoraParameter() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace base
|
||||||
|
} // namespace agora
|
|
@ -0,0 +1,92 @@
|
||||||
|
//
|
||||||
|
// Agora SDK
|
||||||
|
//
|
||||||
|
// Copyright (c) 2021 Agora.io. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once // NOLINT(build/header_guard)
|
||||||
|
|
||||||
|
#include "AgoraBase.h"
|
||||||
|
#include "AgoraRefPtr.h"
|
||||||
|
|
||||||
|
namespace agora {
|
||||||
|
namespace base {
|
||||||
|
class IAgoraService;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace rtc {
|
||||||
|
class ILocalAudioTrack;
|
||||||
|
class IRtcEngineEventHandler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
The states of the rhythm player.
|
||||||
|
*/
|
||||||
|
enum RHYTHM_PLAYER_STATE_TYPE {
|
||||||
|
/** 810: The rhythm player is idle. */
|
||||||
|
RHYTHM_PLAYER_STATE_IDLE = 810,
|
||||||
|
/** 811: The rhythm player is opening files. */
|
||||||
|
RHYTHM_PLAYER_STATE_OPENING,
|
||||||
|
/** 812: Files opened successfully, the rhythm player starts decoding files. */
|
||||||
|
RHYTHM_PLAYER_STATE_DECODING,
|
||||||
|
/** 813: Files decoded successfully, the rhythm player starts mixing the two files and playing back them locally. */
|
||||||
|
RHYTHM_PLAYER_STATE_PLAYING,
|
||||||
|
/** 814: The rhythm player is starting to fail, and you need to check the error code for detailed failure reasons. */
|
||||||
|
RHYTHM_PLAYER_STATE_FAILED,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
The error codes of the rhythm player.
|
||||||
|
*/
|
||||||
|
enum RHYTHM_PLAYER_ERROR_TYPE {
|
||||||
|
/** 0: The rhythm player works well. */
|
||||||
|
RHYTHM_PLAYER_ERROR_OK = 0,
|
||||||
|
/** 1: The rhythm player occurs a internal error. */
|
||||||
|
RHYTHM_PLAYER_ERROR_FAILED = 1,
|
||||||
|
/** 801: The rhythm player can not open the file. */
|
||||||
|
RHYTHM_PLAYER_ERROR_CAN_NOT_OPEN = 801,
|
||||||
|
/** 802: The rhythm player can not play the file. */
|
||||||
|
RHYTHM_PLAYER_ERROR_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,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The configuration of rhythm player,
|
||||||
|
* which is set in startRhythmPlayer or configRhythmPlayer.
|
||||||
|
*/
|
||||||
|
struct AgoraRhythmPlayerConfig {
|
||||||
|
/**
|
||||||
|
* The number of beats per measure. The range is 1 to 9.
|
||||||
|
* The default value is 4,
|
||||||
|
* which means that each measure contains one downbeat and three upbeats.
|
||||||
|
*/
|
||||||
|
int beatsPerMeasure;
|
||||||
|
/*
|
||||||
|
* The range is 60 to 360.
|
||||||
|
* The default value is 60,
|
||||||
|
* which means that the rhythm player plays 60 beats in one minute.
|
||||||
|
*/
|
||||||
|
int beatsPerMinute;
|
||||||
|
|
||||||
|
AgoraRhythmPlayerConfig() : beatsPerMeasure(4), beatsPerMinute(60) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The IRhythmPlayer class provides access to a rhythm player entity.
|
||||||
|
* A rhythm player synthesizes beats, plays them locally, and pushes them remotely.
|
||||||
|
*/
|
||||||
|
class IRhythmPlayer : public RefCountInterface {
|
||||||
|
protected:
|
||||||
|
virtual ~IRhythmPlayer() {}
|
||||||
|
|
||||||
|
public:
|
||||||
|
static agora_refptr<IRhythmPlayer> Create();
|
||||||
|
virtual int initialize(base::IAgoraService* agora_service, IRtcEngineEventHandler* event_handler, bool is_pass_thru_mode) = 0;
|
||||||
|
virtual int playRhythm(const char* sound1, const char* sound2, const AgoraRhythmPlayerConfig& config) = 0;
|
||||||
|
virtual int stopRhythm() = 0;
|
||||||
|
virtual int configRhythmPlayer(const AgoraRhythmPlayerConfig& config) = 0;
|
||||||
|
virtual agora_refptr<ILocalAudioTrack> getRhythmPlayerTrack() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} //namespace rtc
|
||||||
|
} // namespace agora
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,715 @@
|
||||||
|
//
|
||||||
|
// Agora Rtm SDK
|
||||||
|
//
|
||||||
|
// Created by junhao Wang in 2018-05.
|
||||||
|
// Copyright (c) 2018 Agora IO. All rights reserved.
|
||||||
|
//
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
namespace agora {
|
||||||
|
|
||||||
|
namespace rtm {
|
||||||
|
|
||||||
|
enum PEER_MESSAGE_STATE {
|
||||||
|
PEER_MESSAGE_INIT = 0,
|
||||||
|
PEER_MESSAGE_FAILURE = 1,
|
||||||
|
PEER_MESSAGE_PEER_UNREACHABLE = 2,
|
||||||
|
PEER_MESSAGE_RECEIVED_BY_PEER = 3,
|
||||||
|
PEER_MESSAGE_SENT_TIMEOUT = 4,
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* The login error code.
|
||||||
|
*/
|
||||||
|
enum LOGIN_ERR_CODE {
|
||||||
|
/**
|
||||||
|
* 0: Login succeeds. No error occurs.
|
||||||
|
*/
|
||||||
|
LOGIN_ERR_OK = 0,
|
||||||
|
/**
|
||||||
|
* 1: Login fails for reasons unknown.
|
||||||
|
*/
|
||||||
|
LOGIN_ERR_UNKNOWN = 1,
|
||||||
|
/**
|
||||||
|
* 2: The server rejects the login, either because the user has already logged in, or because
|
||||||
|
* the RTM service is not initialized.
|
||||||
|
*/
|
||||||
|
LOGIN_ERR_REJECTED = 2, // ALREADY LOGIN OR NOT INITIALIZED, SERVER REJECT
|
||||||
|
/**
|
||||||
|
* 3: Invalid login arguments.
|
||||||
|
*/
|
||||||
|
LOGIN_ERR_INVALID_ARGUMENT = 3,
|
||||||
|
/**
|
||||||
|
* 4: The App ID is invalid.
|
||||||
|
*/
|
||||||
|
LOGIN_ERR_INVALID_APP_ID = 4,
|
||||||
|
/**
|
||||||
|
* 5: The token is invalid.
|
||||||
|
*/
|
||||||
|
LOGIN_ERR_INVALID_TOKEN = 5,
|
||||||
|
/**
|
||||||
|
* 6: The login is rejected because the token has expired.
|
||||||
|
*/
|
||||||
|
LOGIN_ERR_TOKEN_EXPIRED = 6,
|
||||||
|
/**
|
||||||
|
* 7: Authentication of the RTMP token fails.
|
||||||
|
*/
|
||||||
|
LOGIN_ERR_NOT_AUTHORIZED = 7,
|
||||||
|
/**
|
||||||
|
* 8: The login times out. The current timeout is set as six seconds.
|
||||||
|
*/
|
||||||
|
LOGIN_ERR_TIMEOUT = 8,
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* The logout error code.
|
||||||
|
*/
|
||||||
|
enum LOGOUT_ERR_CODE {
|
||||||
|
/**
|
||||||
|
* 0: Logout succeeds. No error occurs.
|
||||||
|
*/
|
||||||
|
LOGOUT_ERR_OK = 0,
|
||||||
|
/**
|
||||||
|
* 1: Logout fails.
|
||||||
|
*/
|
||||||
|
LOGOUT_ERR_REJECTED = 1,
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* The connection state.
|
||||||
|
*/
|
||||||
|
enum CONNECTION_STATE {
|
||||||
|
/**
|
||||||
|
* 1: The SDK has logged in the RTM service.
|
||||||
|
*/
|
||||||
|
CONNECTION_STATE_CONNECTED = 1,
|
||||||
|
/**
|
||||||
|
* 2: The initial state. The SDK is disconnected from the RTM service.
|
||||||
|
*/
|
||||||
|
CONNECTION_STATE_DISCONNECTED = 2,
|
||||||
|
/**
|
||||||
|
* 3: The SDK gives up logging in the RTM service, mainly because another instance has logged in the RTM
|
||||||
|
* service with the same user ID.
|
||||||
|
*
|
||||||
|
* Call the logout() method before calling login to log in the RTM service again.
|
||||||
|
*/
|
||||||
|
CONNECTION_STATE_ABORTED = 3,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The state of the channel message.
|
||||||
|
*/
|
||||||
|
enum CHANNEL_MESSAGE_STATE {
|
||||||
|
/**
|
||||||
|
* 1: The channel message is received by the server.
|
||||||
|
*/
|
||||||
|
CHANNEL_MESSAGE_RECEIVED_BY_SERVER = 1,
|
||||||
|
/**
|
||||||
|
* 3: The SDK has not received a response from the server in five seconds. The current timeout is set as
|
||||||
|
* five seconds.
|
||||||
|
*/
|
||||||
|
CHANNEL_MESSAGE_SENT_TIMEOUT = 3,
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* The join channel error.
|
||||||
|
*/
|
||||||
|
enum JOIN_CHANNEL_ERR {
|
||||||
|
/**
|
||||||
|
0: The method call succeeds, or the user joins the channel successfully.
|
||||||
|
*/
|
||||||
|
JOIN_CHANNEL_ERR_OK = 0,
|
||||||
|
|
||||||
|
/**
|
||||||
|
1: Common failure. The user fails to join the channel.
|
||||||
|
*/
|
||||||
|
JOIN_CHANNEL_ERR_FAILURE = 1,
|
||||||
|
|
||||||
|
/**
|
||||||
|
2: **RESERVED FOR FUTURE USE**
|
||||||
|
*/
|
||||||
|
JOIN_CHANNEL_ERR_REJECTED = 2, // Usually occurs when the user is already in the channel
|
||||||
|
|
||||||
|
/**
|
||||||
|
3: The user fails to join the channel because the argument is invalid.
|
||||||
|
*/
|
||||||
|
JOIN_CHANNEL_ERR_INVALID_ARGUMENT = 3,
|
||||||
|
|
||||||
|
/**
|
||||||
|
4: A timeout occurs when joining the channel. The current timeout is set as five seconds. Possible reasons: The user is in the \ref agora::rtm::CONNECTION_STATE_ABORTED "CONNECTION_STATE_ABORTED" state.
|
||||||
|
*/
|
||||||
|
JOIN_CHANNEL_TIMEOUT = 4,
|
||||||
|
|
||||||
|
/**
|
||||||
|
5: The number of the RTM channels you are in exceeds the limit of 20.
|
||||||
|
*/
|
||||||
|
JOIN_CHANNEL_ERR_EXCEED_LIMIT = 5,
|
||||||
|
|
||||||
|
/**
|
||||||
|
6: The user is joining or has joined the channel.
|
||||||
|
*/
|
||||||
|
JOIN_CHANNEL_ERR_ALREADY_JOINED = 6,
|
||||||
|
|
||||||
|
/**
|
||||||
|
7: The method call frequency exceeds 50 queries every three seconds.
|
||||||
|
*/
|
||||||
|
JOIN_CHANNEL_ERR_TOO_OFTEN = 7,
|
||||||
|
|
||||||
|
/**
|
||||||
|
8: The frequency of joining the same channel exceeds two times every five seconds.
|
||||||
|
*/
|
||||||
|
JOIN_CHANNEL_ERR_JOIN_SAME_CHANNEL_TOO_OFTEN = 8,
|
||||||
|
|
||||||
|
/**
|
||||||
|
101: \ref agora::rtm::IRtmService "IRtmService" is not initialized.
|
||||||
|
*/
|
||||||
|
JOIN_CHANNEL_ERR_NOT_INITIALIZED = 101,
|
||||||
|
|
||||||
|
/**
|
||||||
|
102: The user does not call the \ref agora::rtm::IRtmService::login "login" method, or the method call of \ref agora::rtm::IRtmService::login "login" does not succeed before joining the channel.
|
||||||
|
*/
|
||||||
|
JOIN_CHANNEL_ERR_USER_NOT_LOGGED_IN = 102,
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
@brief Error codes related to leaving a channel.
|
||||||
|
*/
|
||||||
|
enum LEAVE_CHANNEL_ERR {
|
||||||
|
|
||||||
|
/**
|
||||||
|
0: The method call succeeds, or the user leaves the channel successfully.
|
||||||
|
*/
|
||||||
|
LEAVE_CHANNEL_ERR_OK = 0,
|
||||||
|
|
||||||
|
/**
|
||||||
|
1: Common failure. The user fails to leave the channel.
|
||||||
|
*/
|
||||||
|
LEAVE_CHANNEL_ERR_FAILURE = 1,
|
||||||
|
|
||||||
|
/**
|
||||||
|
2: **RESERVED FOR FUTURE USE**
|
||||||
|
*/
|
||||||
|
LEAVE_CHANNEL_ERR_REJECTED = 2,
|
||||||
|
|
||||||
|
/**
|
||||||
|
3: The user is not in the channel.
|
||||||
|
*/
|
||||||
|
LEAVE_CHANNEL_ERR_NOT_IN_CHANNEL = 3,
|
||||||
|
|
||||||
|
/**
|
||||||
|
101: \ref agora::rtm::IRtmService "IRtmService" is not initialized.
|
||||||
|
*/
|
||||||
|
LEAVE_CHANNEL_ERR_NOT_INITIALIZED = 101,
|
||||||
|
|
||||||
|
/**
|
||||||
|
102: The user does not call the \ref agora::rtm::IRtmService::login "login" method, or the method call of \ref agora::rtm::IRtmService::login "login" does not succeed before calling the \ref agora::rtm::IChannel::leave "leave" method.
|
||||||
|
*/
|
||||||
|
LEAVE_CHANNEL_ERR_USER_NOT_LOGGED_IN = 102,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The reason for a user to leave the channel.
|
||||||
|
*/
|
||||||
|
enum LEAVE_CHANNEL_REASON {
|
||||||
|
/**
|
||||||
|
* 1: The user quits the channel.
|
||||||
|
*/
|
||||||
|
LEAVE_CHANNEL_REASON_QUIT = 1,
|
||||||
|
/**
|
||||||
|
* 2: The user is kicked off the channel.
|
||||||
|
*/
|
||||||
|
LEAVE_CHANNEL_REASON_KICKED = 2,
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
@brief Error codes related to sending a channel message.
|
||||||
|
*/
|
||||||
|
enum CHANNEL_MESSAGE_ERR_CODE {
|
||||||
|
|
||||||
|
/**
|
||||||
|
0: The method call succeeds, or the server receives the channel message.
|
||||||
|
*/
|
||||||
|
CHANNEL_MESSAGE_ERR_OK = 0,
|
||||||
|
|
||||||
|
/**
|
||||||
|
1: Common failure. The user fails to send the channel message.
|
||||||
|
*/
|
||||||
|
CHANNEL_MESSAGE_ERR_FAILURE = 1,
|
||||||
|
|
||||||
|
/**
|
||||||
|
2: The SDK does not receive a response from the server in 10 seconds. The current timeout is set as 10 seconds. Possible reasons: The user is in the \ref agora::rtm::CONNECTION_STATE_ABORTED "CONNECTION_STATE_ABORTED" state.
|
||||||
|
*/
|
||||||
|
CHANNEL_MESSAGE_ERR_SENT_TIMEOUT = 2,
|
||||||
|
|
||||||
|
/**
|
||||||
|
3: The method call frequency exceeds the limit of (RTM SDK for Windows C++) 180 calls every three seconds or (RTM SDK for Linux C++) 1500 calls every three seconds, with channel and peer messages taken together..
|
||||||
|
*/
|
||||||
|
CHANNEL_MESSAGE_ERR_TOO_OFTEN = 3,
|
||||||
|
|
||||||
|
/**
|
||||||
|
4: The message is null or exceeds 32 KB in length.
|
||||||
|
*/
|
||||||
|
CHANNEL_MESSAGE_ERR_INVALID_MESSAGE = 4,
|
||||||
|
|
||||||
|
/**
|
||||||
|
101: \ref agora::rtm::IRtmService "IRtmService" is not initialized.
|
||||||
|
*/
|
||||||
|
CHANNEL_MESSAGE_ERR_NOT_INITIALIZED = 101,
|
||||||
|
|
||||||
|
/**
|
||||||
|
102: The user does not call the \ref agora::rtm::IRtmService::login "login" method, or the method call of \ref agora::rtm::IRtmService::login "login" does not succeed before sending out a channel message.
|
||||||
|
*/
|
||||||
|
CHANNEL_MESSAGE_ERR_USER_NOT_LOGGED_IN = 102,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The response code.
|
||||||
|
*/
|
||||||
|
enum RESPONSE_CODE {
|
||||||
|
/**
|
||||||
|
* 1: The response
|
||||||
|
*/
|
||||||
|
RESPONSE_CODE_SUCCESS = 1,
|
||||||
|
RESPONSE_CODE_FAILURE = 2,
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* The message type.
|
||||||
|
*/
|
||||||
|
enum MESSAGE_TYPE {
|
||||||
|
/**
|
||||||
|
* 0: The message type is undefined.
|
||||||
|
*/
|
||||||
|
MESSAGE_TYPE_UNDEFINED = 0,
|
||||||
|
/**
|
||||||
|
* 1: A text message.
|
||||||
|
*/
|
||||||
|
MESSAGE_TYPE_TEXT = 1,
|
||||||
|
/**
|
||||||
|
* 2: A raw message in binary, for example, audio data, or video data.
|
||||||
|
*/
|
||||||
|
MESSAGE_TYPE_BINARY = 2,
|
||||||
|
/**
|
||||||
|
* 4: A converge message.
|
||||||
|
*/
|
||||||
|
MESSAGE_TYPE_CONVERGE = 4,
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* The IMessage class.
|
||||||
|
*/
|
||||||
|
class IMessage {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Creates an IMessage instance.
|
||||||
|
*
|
||||||
|
* The created IMessage instance can be either for a channel message or for a peer-to-peer message.
|
||||||
|
*
|
||||||
|
* You can set the content of the text message later using the setText() method.
|
||||||
|
* @return
|
||||||
|
* - An empty text IMessage instance, if the method call succeeds.
|
||||||
|
*/
|
||||||
|
static IMessage *createMessage();
|
||||||
|
virtual ~IMessage() {}
|
||||||
|
/**
|
||||||
|
* Gets the ID of the message.
|
||||||
|
* @return The ID of the current IMessage instance.
|
||||||
|
*/
|
||||||
|
virtual int64_t getMessageId() const = 0;
|
||||||
|
/**
|
||||||
|
* Gets the message type.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int getMessageType() const = 0;
|
||||||
|
/**
|
||||||
|
* Sets the content of the text message, or the text description of the raw message.
|
||||||
|
* @param str The content of the text message, or the text description of the raw message. The maximum length
|
||||||
|
* is 32 KB.
|
||||||
|
*/
|
||||||
|
virtual void setText(const char *str) = 0;
|
||||||
|
/**
|
||||||
|
* Gets the content of the text messsage, or the text description of the raw message.
|
||||||
|
* @return
|
||||||
|
* - The content of the text message or the text description of the raw message.
|
||||||
|
*/
|
||||||
|
virtual const char *getText() const = 0;
|
||||||
|
/**
|
||||||
|
* Get pointer of custom raw message
|
||||||
|
* @return
|
||||||
|
* - The content of binary raw message
|
||||||
|
*/
|
||||||
|
virtual const unsigned char *getRawMessageData() const = 0;
|
||||||
|
/**
|
||||||
|
* Get length of custom raw message
|
||||||
|
* @return
|
||||||
|
* - The length of binary raw message in bytes
|
||||||
|
*/
|
||||||
|
virtual int getRawMessageLength() const = 0;
|
||||||
|
/**
|
||||||
|
* Set message type
|
||||||
|
*/
|
||||||
|
virtual void setMessageType(int32_t type) = 0;
|
||||||
|
/**
|
||||||
|
* Set raw binary message
|
||||||
|
*/
|
||||||
|
virtual void setRawMessage(const uint8_t* data, int length) = 0;
|
||||||
|
/**
|
||||||
|
* Releases the IMessage instance.
|
||||||
|
*/
|
||||||
|
virtual void release() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The IChannelMember class.
|
||||||
|
*/
|
||||||
|
class IChannelMember {
|
||||||
|
public:
|
||||||
|
virtual ~IChannelMember() {}
|
||||||
|
/**
|
||||||
|
* Gets the ID of the channel member.
|
||||||
|
* @return The ID of the channel member.
|
||||||
|
*/
|
||||||
|
virtual const char *getMemberId() const = 0;
|
||||||
|
/**
|
||||||
|
* Gets the ID of the channel.
|
||||||
|
* @return The ID of the channel.
|
||||||
|
*/
|
||||||
|
virtual const char *getChannelId() const = 0;
|
||||||
|
/**
|
||||||
|
* Releases the IChannelMember class.
|
||||||
|
*/
|
||||||
|
virtual void release() = 0;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* The IChannelAttributes class.
|
||||||
|
*/
|
||||||
|
class IChannelAttributes {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Creates an IChannelAttributes instance.
|
||||||
|
* @return
|
||||||
|
* - An IChannelAttributes instance, if the method call succeeds.
|
||||||
|
*/
|
||||||
|
static IChannelAttributes *createChannelAttributes();
|
||||||
|
/**
|
||||||
|
* Adds an attribute to a specified channel.
|
||||||
|
*
|
||||||
|
* @param key The pointer to the attribute key.
|
||||||
|
* @param value The pointer to the attribute value.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int addAttribute(const char *key, const char *value) = 0;
|
||||||
|
/**
|
||||||
|
* Removes an attribute from the channel.
|
||||||
|
* @param key The pointer to the attribute key.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int removeAttribute(const char *key) = 0;
|
||||||
|
/**
|
||||||
|
* Gets the size of the attributes.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int getAttributesSize() const = 0;
|
||||||
|
/**
|
||||||
|
* Gets the channel attributes.
|
||||||
|
* @param size The size of the channel attributes.
|
||||||
|
* @param key The pointer to the key of each channel attribute.
|
||||||
|
* @param value The pointer to the value of each channel attribute.
|
||||||
|
*/
|
||||||
|
virtual void getAttributes(int size, char **key,
|
||||||
|
char **value) const = 0; // todo: discussion, how to traveral
|
||||||
|
/**
|
||||||
|
* Gets the value of a channel attribute using the attribute key.
|
||||||
|
* @param key The pointer to the key of the channel attribute that you want to get.
|
||||||
|
*/
|
||||||
|
virtual const char *getAttributeValue(const char *key) const = 0;
|
||||||
|
/**
|
||||||
|
* Releases the IChannelAttributes instance.
|
||||||
|
* @param
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int release() = 0;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* The IChannelEventHandler class.
|
||||||
|
*/
|
||||||
|
class IChannelEventHandler {
|
||||||
|
public:
|
||||||
|
virtual ~IChannelEventHandler() {}
|
||||||
|
/**
|
||||||
|
* Occurs when the local user successfully joins a channel.
|
||||||
|
*/
|
||||||
|
virtual void onJoinSuccess() {}
|
||||||
|
/**
|
||||||
|
* Occurs when the local user fails to join a channel.
|
||||||
|
* @param errorCode The error code: #JOIN_CHANNEL_ERR.
|
||||||
|
*/
|
||||||
|
virtual void onJoinFailure(JOIN_CHANNEL_ERR errorCode) {}
|
||||||
|
/**
|
||||||
|
* Occurs when the local user leaves a channel.
|
||||||
|
* @param errorCode The error code. See #LEAVE_CHANNEL_ERR.
|
||||||
|
*/
|
||||||
|
virtual void onLeave(LEAVE_CHANNEL_ERR errorCode) {}
|
||||||
|
/**
|
||||||
|
* Occurs when the local user receives a channel message.
|
||||||
|
* @param message The pointer to the messsage: IMessage.
|
||||||
|
*/
|
||||||
|
virtual void onMessageReceived(const char *userId, const IMessage *message) {}
|
||||||
|
/**
|
||||||
|
* Reports the state of the message sent by the local user.
|
||||||
|
* @param messageId ID of the message.
|
||||||
|
* @param state The state of the message: #CHANNEL_MESSAGE_STATE.
|
||||||
|
*/
|
||||||
|
virtual void onSendMessageState(int64_t messageId, CHANNEL_MESSAGE_STATE state) {}
|
||||||
|
/**
|
||||||
|
Returns the result of the \ref agora::rtm::IChannel::sendMessage "sendMessage" method call.
|
||||||
|
|
||||||
|
@param messageId The ID of the sent channel message.
|
||||||
|
@param state The error codes. See #CHANNEL_MESSAGE_ERR_CODE.
|
||||||
|
*/
|
||||||
|
virtual void onSendMessageResult(long long messageId, CHANNEL_MESSAGE_ERR_CODE state) {}
|
||||||
|
/**
|
||||||
|
* Occurs when another member joins the channel.
|
||||||
|
* @param member The pointer to the member who joins the channel: IChannelMember.
|
||||||
|
*/
|
||||||
|
virtual void onMemberJoined(IChannelMember *member) {}
|
||||||
|
/**
|
||||||
|
* Occurs when the other member leaves the channel.
|
||||||
|
* @param member The pointer to the member who leaves the channel: IChannelMember.
|
||||||
|
*/
|
||||||
|
virtual void onMemberLeft(IChannelMember *member) {}
|
||||||
|
/**
|
||||||
|
* Reports all the members in the channel.
|
||||||
|
* @param members The pointer to each member in the channel: IChannelMember.
|
||||||
|
* @param userCount The number of users in the channel.
|
||||||
|
*/
|
||||||
|
virtual void onMembersGotten(IChannelMember **members, int userCount) {}
|
||||||
|
/**
|
||||||
|
* Occurs when the channel attributes are updated.
|
||||||
|
* @param attributes The pointer to the current channel attributes: IChannelAttributes.
|
||||||
|
*/
|
||||||
|
virtual void onAttributesUpdated(const IChannelAttributes *attributes) {}
|
||||||
|
/**
|
||||||
|
* Occurs when the local user calls updateAttributes().
|
||||||
|
* @param requestId ID of the current attribute update request.
|
||||||
|
* @param resCode The response code: #RESPONSE_CODE.
|
||||||
|
*/
|
||||||
|
virtual void onUpdateAttributesResponse(int64_t requestId, RESPONSE_CODE resCode) {}
|
||||||
|
/**
|
||||||
|
* Occurs when the channel attributes are deleted.
|
||||||
|
* @param attributes The pointer to the channel attributes that you want to remove: IChannelAttributes.
|
||||||
|
*/
|
||||||
|
virtual void onAttributesDeleted(const IChannelAttributes *attributes) {}
|
||||||
|
/**
|
||||||
|
* Occurs when the local user calls deleteAttributes().
|
||||||
|
* @param requestId ID of the current attribute delete request.
|
||||||
|
* @param resCode The response code: #RESPONSE_CODE.
|
||||||
|
*/
|
||||||
|
virtual void onDeleteAttributesResponse(int64_t requestId, RESPONSE_CODE resCode) {}
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* The IChannel class.
|
||||||
|
*/
|
||||||
|
class IChannel {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Sets an event handler for IChannel.
|
||||||
|
* @param eventHandler The pointer to the event handler of IChannel: IChannelEventHandler.
|
||||||
|
*/
|
||||||
|
virtual void setEventHandler(IChannelEventHandler *eventHandler) = 0;
|
||||||
|
/**
|
||||||
|
* Joins the current channel.
|
||||||
|
*
|
||||||
|
* A successful method call triggers either onJoinSuccess() or onJoinFailure() on the local client, to report
|
||||||
|
* the state of joining the channel.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int join() = 0;
|
||||||
|
/**
|
||||||
|
* Leaves the current channel.
|
||||||
|
*
|
||||||
|
* After the local user successfully leaves the channel, the SDK triggers the onLeave() on the local client.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int leave() = 0;
|
||||||
|
/**
|
||||||
|
* Sends a channel message.
|
||||||
|
*
|
||||||
|
* After you successfully send a channel message, all members in the channel receive the message in the
|
||||||
|
* onMessageReceived() callback.
|
||||||
|
* @param message The pointer to the channel message that you want to send: IMessage.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int sendMessage(const IMessage *message) = 0;
|
||||||
|
/**
|
||||||
|
* Updates the channel attributes.
|
||||||
|
*
|
||||||
|
* A successful method call triggers the onUpdateAttributesResponse() callback on the local client.
|
||||||
|
* @param attributes The pointer to the channel attributes that you want to update: IChannelAttributes.
|
||||||
|
* @param requestId ID of the current update request.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int updateAttributes(IChannelAttributes *attributes, int64_t &requestId) = 0;
|
||||||
|
/**
|
||||||
|
* Removes the channel attributes.
|
||||||
|
*
|
||||||
|
* A successful method call triggers the onDeleteAttributesResponse() callback on the local client.
|
||||||
|
* @param attributes The pointer to the channel attributes that you want to remove: IChannelAttributes.
|
||||||
|
* @param requestId ID of the current delete request.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int deleteAttributes(IChannelAttributes *attributes, int64_t &requestId) = 0;
|
||||||
|
/**
|
||||||
|
* Gets the current request ID.
|
||||||
|
* @return
|
||||||
|
* - The pointer to the request ID, if the method call succeeds.
|
||||||
|
* - An empty pointer NULL, if the method call fails.
|
||||||
|
*/
|
||||||
|
virtual const char *getId() const = 0;
|
||||||
|
|
||||||
|
// sync_call
|
||||||
|
/**
|
||||||
|
* Releases the IChannel instance.
|
||||||
|
*
|
||||||
|
* This is a synchronous method call, which means that the SDK reports the result of this method call
|
||||||
|
* after the IChannel instance is successfully released.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int release() = 0;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* The IRtmServiceEventHandler class.
|
||||||
|
*/
|
||||||
|
class IRtmServiceEventHandler {
|
||||||
|
public:
|
||||||
|
virtual ~IRtmServiceEventHandler() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Occurs when the user successfully logs in the RTM service.
|
||||||
|
*/
|
||||||
|
virtual void onLoginSuccess() {}
|
||||||
|
/**
|
||||||
|
* Occurs when the user fails to log in the RTM service.
|
||||||
|
* @param errorCode The reason for the login failure: #LOGIN_ERR_CODE.
|
||||||
|
*/
|
||||||
|
virtual void onLoginFailure(LOGIN_ERR_CODE errorCode) {}
|
||||||
|
/**
|
||||||
|
* Occurs when the user successfully logs out of the RTM service.
|
||||||
|
*/
|
||||||
|
virtual void onLogout() {}
|
||||||
|
/**
|
||||||
|
* Occurs when the connection state of the local user has changed.
|
||||||
|
* @param state The current connection state: #CONNECTION_STATE.
|
||||||
|
*/
|
||||||
|
virtual void onConnectionStateChanged(CONNECTION_STATE state) {}
|
||||||
|
/**
|
||||||
|
* Reports the state of sending a message.
|
||||||
|
* @param messageId ID of the message.
|
||||||
|
* @param state The current state of the message: #PEER_MESSAGE_STATE.
|
||||||
|
*/
|
||||||
|
virtual void onSendMessageState(int64_t messageId, PEER_MESSAGE_STATE state) {}
|
||||||
|
/**
|
||||||
|
* Occurs when the local user receives a message from a remote user.
|
||||||
|
* @param peerId ID of the remote user that sends the message.
|
||||||
|
* @param message The pointer to the message: IMessage.
|
||||||
|
*/
|
||||||
|
virtual void onMessageReceivedFromPeer(const char *peerId, const IMessage *message) {}
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* The IRtmService class.
|
||||||
|
*/
|
||||||
|
class IRtmService {
|
||||||
|
public:
|
||||||
|
virtual ~IRtmService() {}
|
||||||
|
/**
|
||||||
|
* Creates and gets an IRtmService instance.
|
||||||
|
* @param appId The pointer to the app ID.
|
||||||
|
* @param eventHandler The pointer to the IRtmServiceEventHandler object.
|
||||||
|
* @param eventSpace The connection specific ID, used during report to argus.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int initialize(const char *appId, IRtmServiceEventHandler *eventHandler) = 0;
|
||||||
|
/**
|
||||||
|
* Releases the IRtmServiceEventHandler object.
|
||||||
|
* @param eventHandler The pointer to the IRtmServiceEventHandler object.
|
||||||
|
*/
|
||||||
|
virtual void unregisterObserver(IRtmServiceEventHandler *eventHandler) = 0;
|
||||||
|
/**
|
||||||
|
* Releases the IRtmService instance.
|
||||||
|
* @param sync Determines whether to report the result of this method call synchronously.
|
||||||
|
* - true: Report the result of this method call after the IRtmService instance is released.
|
||||||
|
* - false: (Default) Report the result of this method call immediately, even when the IRtmService is not
|
||||||
|
* released.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int release(bool sync = false) = 0;
|
||||||
|
/**
|
||||||
|
* Logs in the RTM service.
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* - If you login with the same user ID from a different instance, your previous login will be kicked.
|
||||||
|
* - The call frequency limit of this method is 2 queries per second.
|
||||||
|
* @param token The token used to log in the RTM service.
|
||||||
|
* @param userId ID of the user logging in the RTM service.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int login(const char *token, const char *userId) = 0;
|
||||||
|
/**
|
||||||
|
* Logs out of the RTM service.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int logout() = 0;
|
||||||
|
/**
|
||||||
|
* Sends a peer message to a specified remote user.
|
||||||
|
*
|
||||||
|
* @param peerId The pointer to the ID of the remote user.
|
||||||
|
* @param message The pointer to message: IMessage.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int sendMessageToPeer(const char *peerId, const IMessage *message) = 0;
|
||||||
|
/**
|
||||||
|
* Creates an RTM channel.
|
||||||
|
*
|
||||||
|
* @param channelId The unique channel name for an RTM session. Supported character scopes are:
|
||||||
|
* - All lowercase English letters: a to z.
|
||||||
|
* - All uppercase English letters: A to Z.
|
||||||
|
* - All numeric characters: 0 to 9.
|
||||||
|
* - The space character.
|
||||||
|
* - Punctuation characters and other symbols, including: "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=",
|
||||||
|
* ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", ","
|
||||||
|
*
|
||||||
|
* @param eventHandler The pointer to IChannelEventHandler.
|
||||||
|
* @return
|
||||||
|
* - The pointer to an IChannel instance, if the method call succeeds.
|
||||||
|
* - An empty pointer NULL, if the method call fails.
|
||||||
|
*/
|
||||||
|
virtual IChannel *createChannel(const char *channelId, IChannelEventHandler *eventHandler) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace rtm
|
||||||
|
} // namespace agora
|
|
@ -0,0 +1,192 @@
|
||||||
|
|
||||||
|
// Copyright (c) 2019 Agora.io. All rights reserved
|
||||||
|
|
||||||
|
// This program is confidential and proprietary to Agora.io.
|
||||||
|
// And may not be copied, reproduced, modified, disclosed to others, published
|
||||||
|
// or used, in whole or in part, without the express prior written permission
|
||||||
|
// of Agora.io.
|
||||||
|
|
||||||
|
#pragma once // NOLINT(build/header_guard)
|
||||||
|
|
||||||
|
#include "AgoraBase.h"
|
||||||
|
#include "AgoraRefPtr.h"
|
||||||
|
#include "IAgoraService.h"
|
||||||
|
#include "NGIAgoraRtcConnection.h"
|
||||||
|
|
||||||
|
namespace agora {
|
||||||
|
namespace rtc {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The events in the RTMP channel.
|
||||||
|
*/
|
||||||
|
enum RTMP_CHANNEL_EVENT
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 0: The live stream service is disconnected.
|
||||||
|
*/
|
||||||
|
RTMP_CHANNEL_EVENT_DISCONNECT = 0,
|
||||||
|
/**
|
||||||
|
* 1: The live stream service has left the channel.
|
||||||
|
*/
|
||||||
|
RTMP_CHANNEL_EVENT_LEAVE_CHANNEL = 1,
|
||||||
|
/**
|
||||||
|
* 2: The live stream service is banned by the server.
|
||||||
|
*/
|
||||||
|
RTMP_CHANNEL_EVENT_BANNED_BY_SERVER = 2
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* The IRtmpStreamingObserver class, which monitors events in of the live streaming service.
|
||||||
|
*/
|
||||||
|
class IRtmpStreamingObserver {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Occurs when the state of the RTMP streaming changes.
|
||||||
|
*
|
||||||
|
* The SDK triggers this callback to report the result of the local user calling
|
||||||
|
* `addPublishStreamUrl` or `removePublishStreamUrl`.
|
||||||
|
*
|
||||||
|
* This callback also reports the streaming URL and its current streaming state. When exceptions
|
||||||
|
* occur, you can troubleshoot issues by referring to the detailed error description in the `errCode`
|
||||||
|
* parameter.
|
||||||
|
*
|
||||||
|
* @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.
|
||||||
|
*/
|
||||||
|
virtual void onRtmpStreamingStateChanged(const char* url, RTMP_STREAM_PUBLISH_STATE state,
|
||||||
|
RTMP_STREAM_PUBLISH_ERROR_TYPE errCode) {
|
||||||
|
(void)url;
|
||||||
|
(void)state;
|
||||||
|
(void)errCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Reports events during the RTMP or RTMPS streaming.
|
||||||
|
*
|
||||||
|
* @since v3.1.0
|
||||||
|
*
|
||||||
|
* @param url The RTMP or RTMPS streaming URL.
|
||||||
|
* @param eventCode The event code. See #RTMP_STREAMING_EVENT
|
||||||
|
*/
|
||||||
|
virtual void onRtmpStreamingEvent(const char* url, RTMP_STREAMING_EVENT eventCode) {
|
||||||
|
(void)url;
|
||||||
|
(void)eventCode;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Occurs when the publisher's transcoding settings are updated.
|
||||||
|
*
|
||||||
|
* When the `LiveTranscoding` class in the `setLiveTransocding` method updates, the SDK triggers this callback
|
||||||
|
* to report the update information.
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* If you call the `setLiveTranscoding` method to set the `LiveTranscoding` class for the first time, the SDK
|
||||||
|
* does not trigger this callback.
|
||||||
|
*/
|
||||||
|
virtual void onTranscodingUpdated() {}
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* The IRtmpStreamingService class, which enables the live stream service.
|
||||||
|
*/
|
||||||
|
class IRtmpStreamingService : public RefCountInterface {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/** Publishes the local stream without transcoding to a specified CDN live RTMP address. (CDN live only.)
|
||||||
|
|
||||||
|
* The SDK returns the result of this method call in the \ref IRtcEngineEventHandler::onStreamPublished "onStreamPublished" callback.
|
||||||
|
|
||||||
|
* The \ref agora::rtc::IRtcEngine::startRtmpStreamWithoutTranscoding "startRtmpStreamWithoutTranscoding" method call triggers the \ref agora::rtc::IRtcEngineEventHandler::onRtmpStreamingStateChanged "onRtmpStreamingStateChanged" callback on the local client to report the state of adding a local stream to the CDN.
|
||||||
|
* @note
|
||||||
|
* - Ensure that the user joins the channel before calling this method.
|
||||||
|
* - This method adds only one stream RTMP URL address each time it is called.
|
||||||
|
* - The RTMP URL address must not contain special characters, such as Chinese language characters.
|
||||||
|
* - This method applies to Live Broadcast only.
|
||||||
|
|
||||||
|
* @param url The CDN streaming URL in the RTMP format. The maximum length of this parameter is 1024 bytes.
|
||||||
|
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
* - #ERR_INVALID_ARGUMENT (2): The RTMP URL address is NULL or has a string length of 0.
|
||||||
|
* - #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;
|
||||||
|
|
||||||
|
/** Publishes the local stream with transcoding to a specified CDN live RTMP address. (CDN live only.)
|
||||||
|
|
||||||
|
* The SDK returns the result of this method call in the \ref IRtcEngineEventHandler::onStreamPublished "onStreamPublished" callback.
|
||||||
|
|
||||||
|
* The \ref agora::rtc::IRtcEngine::startRtmpStreamWithTranscoding "startRtmpStreamWithTranscoding" method call triggers the \ref agora::rtc::IRtcEngineEventHandler::onRtmpStreamingStateChanged "onRtmpStreamingStateChanged" callback on the local client to report the state of adding a local stream to the CDN.
|
||||||
|
* @note
|
||||||
|
* - Ensure that the user joins the channel before calling this method.
|
||||||
|
* - This method adds only one stream RTMP URL address each time it is called.
|
||||||
|
* - The RTMP URL address must not contain special characters, such as Chinese language characters.
|
||||||
|
* - This method applies to Live Broadcast only.
|
||||||
|
|
||||||
|
* @param url The CDN streaming URL in the RTMP format. The maximum length of this parameter is 1024 bytes.
|
||||||
|
* @param transcoding Sets the CDN live audio/video transcoding settings. See LiveTranscoding.
|
||||||
|
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
* - #ERR_INVALID_ARGUMENT (2): The RTMP URL address is NULL or has a string length of 0.
|
||||||
|
* - #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;
|
||||||
|
|
||||||
|
/** Update the video layout and audio settings for CDN live. (CDN live only.)
|
||||||
|
* @note This method applies to Live Broadcast only.
|
||||||
|
|
||||||
|
* @param transcoding Sets the CDN live audio/video transcoding settings. See LiveTranscoding.
|
||||||
|
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int updateRtmpTranscoding(const LiveTranscoding& transcoding) = 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
|
||||||
|
* or IRtcEngine::startRtmpStreamWithTranscoding "startRtmpStreamWithTranscoding" method) from a CDN live stream.
|
||||||
|
* The SDK returns the result of this method call in the \ref IRtcEngineEventHandler::onStreamUnpublished "onStreamUnpublished" callback.
|
||||||
|
|
||||||
|
* The \ref agora::rtc::IRtcEngine::stopRtmpStream "stopRtmpStream" method call triggers the \ref agora::rtc::IRtcEngineEventHandler::onRtmpStreamingStateChanged "onRtmpStreamingStateChanged" callback on the local client to report the state of removing an RTMP stream from the CDN.
|
||||||
|
* @note
|
||||||
|
* - This method removes only one RTMP URL address each time it is called.
|
||||||
|
* - The RTMP URL address must not contain special characters, such as Chinese language characters.
|
||||||
|
* - This method applies to Live Broadcast only.
|
||||||
|
|
||||||
|
* @param url The RTMP URL address to be removed. The maximum length of this parameter is 1024 bytes.
|
||||||
|
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int stopRtmpStream(const char* url) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers an RTMP streaming observer.
|
||||||
|
* @param observer The pointer to an RTMP streaming observer. See \ref agora::rtc::IRtmpStreamingObserver "IRtmpStreamingObserver".
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int registerObserver(IRtmpStreamingObserver* observer) = 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".
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int unregisterObserver(IRtmpStreamingObserver* observer) = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
~IRtmpStreamingService() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace rtc
|
||||||
|
} // namespace agora
|
|
@ -0,0 +1,968 @@
|
||||||
|
// Agora SDK
|
||||||
|
//
|
||||||
|
// Copyright (c) 2018 Agora.io. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once // NOLINT(build/header_guard)
|
||||||
|
|
||||||
|
#include "IAgoraLog.h"
|
||||||
|
#include "AgoraBase.h"
|
||||||
|
#include "AgoraOptional.h"
|
||||||
|
|
||||||
|
namespace agora {
|
||||||
|
namespace rtc {
|
||||||
|
class IRtcConnection;
|
||||||
|
class IRtmpConnection;
|
||||||
|
class ILocalUser;
|
||||||
|
class IMediaDeviceManager;
|
||||||
|
class INGAudioDeviceManager;
|
||||||
|
struct TConnectionInfo;
|
||||||
|
struct RtcConnectionConfiguration;
|
||||||
|
struct RtmpConnectionConfiguration;
|
||||||
|
class ILocalAudioTrack;
|
||||||
|
class IMediaPlayerSource;
|
||||||
|
class IMediaStreamingSource;
|
||||||
|
class ICameraCapturer;
|
||||||
|
class IScreenCapturer;
|
||||||
|
class IScreenCapturer2;
|
||||||
|
class IAudioPcmDataSender;
|
||||||
|
class IAudioEncodedFrameSender;
|
||||||
|
class IVideoFrameSender;
|
||||||
|
class IVideoEncodedImageSender;
|
||||||
|
class IVideoSourceNode;
|
||||||
|
class IVideoMixerSource;
|
||||||
|
class IVideoFrameTransceiver;
|
||||||
|
class ILocalVideoTrack;
|
||||||
|
class IMediaNodeFactory;
|
||||||
|
class IRecordingDeviceSource;
|
||||||
|
class IRemoteAudioMixerSource;
|
||||||
|
class IRtmpStreamingService;
|
||||||
|
class IMediaPacketSender;
|
||||||
|
class IMediaRelayService;
|
||||||
|
class IAudioDeviceManager;
|
||||||
|
class IAudioDeviceManagerObserver;
|
||||||
|
|
||||||
|
class IMediaExtensionObserver;
|
||||||
|
class IExtensionProvider;
|
||||||
|
class IFileUploaderService;
|
||||||
|
/**
|
||||||
|
* The audio encoder configuration.
|
||||||
|
*/
|
||||||
|
struct AudioEncoderConfiguration {
|
||||||
|
/**
|
||||||
|
* The audio profile: #AUDIO_PROFILE_TYPE
|
||||||
|
*/
|
||||||
|
AUDIO_PROFILE_TYPE audioProfile;
|
||||||
|
|
||||||
|
AudioEncoderConfiguration() : audioProfile(AUDIO_PROFILE_DEFAULT) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace rtc
|
||||||
|
|
||||||
|
namespace rtm {
|
||||||
|
class IRtmService;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace base {
|
||||||
|
class IServiceObserver;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The global configurations for \ref agora::base::IAgoraService "AgoraService".
|
||||||
|
*
|
||||||
|
* Set these configurations when calling \ref agora::base::IAgoraService::initialize "initialize".
|
||||||
|
*/
|
||||||
|
struct AgoraServiceConfiguration {
|
||||||
|
/**
|
||||||
|
* Whether to enable the audio processing module.
|
||||||
|
* - `true`: (Default) Enable the audio processing module.
|
||||||
|
* - `false`: Disable the audio processing module. If you disable the audio processing module, you cannot create audio tracks.
|
||||||
|
*/
|
||||||
|
bool enableAudioProcessor;
|
||||||
|
/**
|
||||||
|
* Whether to enable the audio device module. The function of the audio device module is to manage audio devices,
|
||||||
|
* such as recording and playing audio.
|
||||||
|
* - `true`: (Default) Enable the audio device module. Audio recording and playback is available.
|
||||||
|
* - `false`: Disable the audio device module. Audio recording and playback is unavailable.
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* If you set `enableAudioDevice` as `false` and set `enableAudioProcessor` as `true`, you cannot use audio devices,
|
||||||
|
* but you can push PCM audio data.
|
||||||
|
*/
|
||||||
|
bool enableAudioDevice;
|
||||||
|
/**
|
||||||
|
* Whether to enable video.
|
||||||
|
* - `true`: Enable video.
|
||||||
|
* - `false`: (Default) Disable video.
|
||||||
|
*/
|
||||||
|
bool enableVideo;
|
||||||
|
/**
|
||||||
|
* The user context.
|
||||||
|
* - For Windows, it is the handle of the window that loads the video. Specify this value to support plugging or unplugging the video devices while the host is powered on.
|
||||||
|
* - For Android, it is the context of activity.
|
||||||
|
*/
|
||||||
|
void* context;
|
||||||
|
/**
|
||||||
|
* The App ID of your project.
|
||||||
|
*/
|
||||||
|
const char* appId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The supported area code, default is AREA_CODE_GLOB
|
||||||
|
*/
|
||||||
|
unsigned int areaCode;
|
||||||
|
|
||||||
|
/** The channel profile. For details, see \ref agora::CHANNEL_PROFILE_TYPE "CHANNEL_PROFILE_TYPE". The default channel profile is `CHANNEL_PROFILE_LIVE_BROADCASTING`.
|
||||||
|
*/
|
||||||
|
agora::CHANNEL_PROFILE_TYPE channelProfile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The license used for verification when connectting channel. Charge according to the license
|
||||||
|
*/
|
||||||
|
const char* license;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The audio scenario. See \ref agora::rtc::AUDIO_SCENARIO_TYPE "AUDIO_SCENARIO_TYPE". The default value is `AUDIO_SCENARIO_DEFAULT`.
|
||||||
|
*/
|
||||||
|
rtc::AUDIO_SCENARIO_TYPE audioScenario;
|
||||||
|
/**
|
||||||
|
* The config for custumer set log path, log size and log level.
|
||||||
|
*/
|
||||||
|
commons::LogConfig logConfig;
|
||||||
|
/**
|
||||||
|
* Whether to enable string uid.
|
||||||
|
*/
|
||||||
|
bool useStringUid;
|
||||||
|
/**
|
||||||
|
* The service observer.
|
||||||
|
*/
|
||||||
|
IServiceObserver* serviceObserver;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Thread priority for SDK common threads
|
||||||
|
*/
|
||||||
|
Optional<rtc::THREAD_PRIORITY_TYPE> threadPriority;
|
||||||
|
/**
|
||||||
|
* Whether use egl context in current thread as sdk‘s root egl context
|
||||||
|
* which shared by all egl related modules. eg. camera capture, video renderer.
|
||||||
|
* @note
|
||||||
|
* This property applies to Android only.
|
||||||
|
*/
|
||||||
|
bool useExternalEglContext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines whether to enable domain limit.
|
||||||
|
* - `true`: only connect to servers that already parsed by DNS
|
||||||
|
* - `false`: (Default) connect to servers with no limit
|
||||||
|
*/
|
||||||
|
bool domainLimit;
|
||||||
|
|
||||||
|
AgoraServiceConfiguration() : enableAudioProcessor(true),
|
||||||
|
enableAudioDevice(true),
|
||||||
|
enableVideo(false),
|
||||||
|
context(NULL),
|
||||||
|
appId(NULL),
|
||||||
|
areaCode(rtc::AREA_CODE_GLOB),
|
||||||
|
channelProfile(agora::CHANNEL_PROFILE_LIVE_BROADCASTING),
|
||||||
|
license(NULL),
|
||||||
|
audioScenario(rtc::AUDIO_SCENARIO_DEFAULT),
|
||||||
|
useStringUid(false),
|
||||||
|
serviceObserver(NULL),
|
||||||
|
useExternalEglContext(false),
|
||||||
|
domainLimit(false){}
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* The audio session configurations.
|
||||||
|
*
|
||||||
|
* Set these configurations when calling \ref agora::base::IAgoraService::setAudioSessionConfiguration "setAudioSessionConfiguration".
|
||||||
|
*/
|
||||||
|
struct AudioSessionConfiguration {
|
||||||
|
/**
|
||||||
|
* Whether to enable audio input (recording) and audio output (playback):
|
||||||
|
* - `true`: Enable audio recording and playback.
|
||||||
|
* - `false`: Disable audio recording and playback, which prevents audio input
|
||||||
|
* and output.
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* - For the recording function to work, the user must grant permission for audio recording.
|
||||||
|
* - By default, the audio of your app is nonmixable, which means
|
||||||
|
* activating audio sessions in your app interrupts other nonmixable audio sessions.
|
||||||
|
* Set `allowMixWithOthers` as `true` to allow audio mixing.
|
||||||
|
*/
|
||||||
|
Optional<bool> playbackAndRecord;
|
||||||
|
/**
|
||||||
|
* Whether to enable chat mode:
|
||||||
|
* - `true`: Enable chat mode. This mode is for apps that are engaged in two-way
|
||||||
|
* real-time communication, such as a voice or video chat.
|
||||||
|
* - `false`: Disable chat mode.
|
||||||
|
*
|
||||||
|
* For a video chat, set this member as `true` and set the audio route to the speaker.
|
||||||
|
*/
|
||||||
|
Optional<bool> chatMode;
|
||||||
|
/**
|
||||||
|
* Whether the audio defaults to the built-in speaker:
|
||||||
|
* - `true`: The audio defaults to the built-in speaker.
|
||||||
|
* - `false`: The audio does not default to the built-in speaker.
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* This member is available only when `playbackAndRecord` is set as `true`.
|
||||||
|
*/
|
||||||
|
Optional<bool> defaultToSpeaker;
|
||||||
|
/**
|
||||||
|
* Whether to temporarily change the current audio route to the built-in speaker:
|
||||||
|
* - `true`: Set the current audio route to the built-in speaker.
|
||||||
|
* - `false`: Do not set the current audio route to the built-in speaker.
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* This member is available only when the `playbackAndRecord` member is set as `true`.
|
||||||
|
*/
|
||||||
|
Optional<bool> overrideSpeaker;
|
||||||
|
/**
|
||||||
|
* Whether to mix the audio from this session with the audio from active audio sessions in other apps.
|
||||||
|
* - `true`: Mix the audio sessions.
|
||||||
|
* - `false`: Do not mix the audio session.
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* This member is available only when the `playbackAndRecord` member is set as `true`.
|
||||||
|
*/
|
||||||
|
Optional<bool> allowMixWithOthers;
|
||||||
|
/**
|
||||||
|
* Whether to duck the audio from this session with the audio from active audio sessions in other apps.
|
||||||
|
* - `true`: Duck the audio sessions.
|
||||||
|
* - `false`: Do not duck the audio session.
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* This member is available only when the `playbackAndRecord` member is set as `true`.
|
||||||
|
*/
|
||||||
|
Optional<bool> allowDuckOthers;
|
||||||
|
/**
|
||||||
|
* Whether to allow Bluetooth handsfree devices to appear as available audio input
|
||||||
|
* devices:
|
||||||
|
* - `true`: Allow Bluetooth handsfree devices to appear as available audio input routes.
|
||||||
|
* - `false`: Do not allow Bluetooth handsfree devices to appear as available audio input
|
||||||
|
* routes.
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* This member is available only when the `playbackAndRecord` member is set as `true`.
|
||||||
|
*/
|
||||||
|
Optional<bool> allowBluetooth;
|
||||||
|
/**
|
||||||
|
* Whether to allow the audio from this session to be routed to Bluetooth
|
||||||
|
* devices that support the Advanced Audio Distribution Profile (A2DP).
|
||||||
|
* - `true`: Allow the audio from this session to be routed to Bluetooth devices that
|
||||||
|
* support the Advanced Audio Distribution Profile (A2DP).
|
||||||
|
* - `false`: Do not allow the audio from this session to be routed to Bluetooth devices that
|
||||||
|
* support the Advanced Audio Distribution Profile (A2DP).
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* This member is available only when the `playbackAndRecord` member is set as `true`.
|
||||||
|
*/
|
||||||
|
Optional<bool> allowBluetoothA2DP;
|
||||||
|
/**
|
||||||
|
* The expected audio sample rate (kHz) of this session.
|
||||||
|
*
|
||||||
|
* The value range is [8,48]. The actual sample rate may differ based on the audio sampling
|
||||||
|
* device in use.
|
||||||
|
*/
|
||||||
|
Optional<double> sampleRate;
|
||||||
|
/**
|
||||||
|
* The expected input and output buffer duration (ms) of this session.
|
||||||
|
*
|
||||||
|
* The value range is [0,93]. The actual I/O buffer duration might be lower
|
||||||
|
* than the set value based on the hardware in use.
|
||||||
|
*/
|
||||||
|
Optional<double> ioBufferDuration;
|
||||||
|
/**
|
||||||
|
* The expected number of input audio channels of this session.
|
||||||
|
*/
|
||||||
|
Optional<int> inputNumberOfChannels;
|
||||||
|
/**
|
||||||
|
* The expected number of output audio channels of this session.
|
||||||
|
*/
|
||||||
|
Optional<int> outputNumberOfChannels;
|
||||||
|
/**
|
||||||
|
* Initialize the AudioSession with the value for category. (iOS only)
|
||||||
|
*/
|
||||||
|
Optional<int> category;
|
||||||
|
|
||||||
|
void SetAll(const AudioSessionConfiguration& change) {
|
||||||
|
SetFrom(&playbackAndRecord, change.playbackAndRecord);
|
||||||
|
SetFrom(&chatMode, change.chatMode);
|
||||||
|
SetFrom(&defaultToSpeaker, change.defaultToSpeaker);
|
||||||
|
SetFrom(&overrideSpeaker, change.overrideSpeaker);
|
||||||
|
SetFrom(&allowMixWithOthers, change.allowMixWithOthers);
|
||||||
|
SetFrom(&allowDuckOthers, change.allowDuckOthers);
|
||||||
|
SetFrom(&allowBluetooth, change.allowBluetooth);
|
||||||
|
SetFrom(&allowBluetoothA2DP, change.allowBluetoothA2DP);
|
||||||
|
SetFrom(&sampleRate, change.sampleRate);
|
||||||
|
SetFrom(&ioBufferDuration, change.ioBufferDuration);
|
||||||
|
SetFrom(&inputNumberOfChannels, change.inputNumberOfChannels);
|
||||||
|
SetFrom(&outputNumberOfChannels, change.outputNumberOfChannels);
|
||||||
|
SetFrom(&category, change.category);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator==(const AudioSessionConfiguration& o) const {
|
||||||
|
return playbackAndRecord == o.playbackAndRecord && chatMode == o.chatMode &&
|
||||||
|
defaultToSpeaker == o.defaultToSpeaker && overrideSpeaker == o.overrideSpeaker &&
|
||||||
|
allowMixWithOthers == o.allowMixWithOthers && allowDuckOthers == o.allowDuckOthers &&
|
||||||
|
allowBluetooth == o.allowBluetooth && allowBluetoothA2DP == o.allowBluetoothA2DP && sampleRate == o.sampleRate &&
|
||||||
|
ioBufferDuration == o.ioBufferDuration &&
|
||||||
|
inputNumberOfChannels == o.inputNumberOfChannels &&
|
||||||
|
outputNumberOfChannels == o.outputNumberOfChannels &&
|
||||||
|
category == o.category;
|
||||||
|
}
|
||||||
|
bool operator!=(const AudioSessionConfiguration& o) const { return !(*this == o); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
template <typename T>
|
||||||
|
static void SetFrom(Optional<T>* s, const Optional<T>& o) {
|
||||||
|
if (o) {
|
||||||
|
*s = o;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* The audio mixing mode.
|
||||||
|
*/
|
||||||
|
enum TMixMode {
|
||||||
|
/**
|
||||||
|
* Mix all the local audio tracks in the channel.
|
||||||
|
*/
|
||||||
|
MIX_ENABLED,
|
||||||
|
/**
|
||||||
|
* Do not mix the local audio tracks in the channel.
|
||||||
|
*/
|
||||||
|
MIX_DISABLED,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The IServiceObserver class.
|
||||||
|
*/
|
||||||
|
class IServiceObserver {
|
||||||
|
public:
|
||||||
|
virtual ~IServiceObserver() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reports the permission error.
|
||||||
|
* @param permission {@link PERMISSION}
|
||||||
|
*/
|
||||||
|
virtual void onPermissionError(agora::rtc::PERMISSION_TYPE permissionType) {}
|
||||||
|
/**
|
||||||
|
* Reports the audio device error.
|
||||||
|
* @param error {@link ERROR_CODE_TYPE}
|
||||||
|
*/
|
||||||
|
virtual void onAudioDeviceError(ERROR_CODE_TYPE error, const char* description) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The IAgoraService class.
|
||||||
|
*
|
||||||
|
* `IAgoraService` is the entry point of Agora low-level APIs. Use this interface to
|
||||||
|
* create access points to Agora interfaces, including RTC connections and media tracks.
|
||||||
|
*
|
||||||
|
* You can create an `IAgoraService` object by calling \ref agora::base::IAgoraService::createAgoraService "createAgoraService".
|
||||||
|
*
|
||||||
|
* You can configure the `IAgoraService` object for different user scenarios on the global level by using `AgoraServiceConfiguration`.
|
||||||
|
*/
|
||||||
|
class IAgoraService {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Initializes the \ref agora::base::IAgoraService "AgoraService" object.
|
||||||
|
*
|
||||||
|
* @param config The configuration of the initialization. For details, see \ref agora::base::AgoraServiceConfiguration "AgoraServiceConfiguration".
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
* - `ERR_INVALID_ARGUMENT`, if `context` in `AgoraServiceConfiguration` is not provided for
|
||||||
|
* Android.
|
||||||
|
* - `ERR_INIT_NET_ENGINE`, if the network engine cannot be initialized. On Windows, the error occurs mostly because the connection to the local port is disabled by the firewall. In this case, turn off the firewall and then turn it on again.
|
||||||
|
*/
|
||||||
|
virtual int initialize(const AgoraServiceConfiguration& config) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flush log & cache before exit
|
||||||
|
*/
|
||||||
|
virtual void atExit() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Releases the \ref agora::base::IAgoraService "AgoraService" object.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int release() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configures the preset audio scenario.
|
||||||
|
*
|
||||||
|
* @param scenario The preset audio scenario: \ref agora::rtc::AUDIO_SCENARIO_TYPE
|
||||||
|
* "AUDIO_SCENARIO_TYPE".
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setAudioSessionPreset(agora::rtc::AUDIO_SCENARIO_TYPE scenario) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Customizes the audio session configuration.
|
||||||
|
*
|
||||||
|
* @param config The reference to the audio session configuration: \ref agora::base::AudioSessionConfiguration "AudioSessionConfiguration".
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setAudioSessionConfiguration(const AudioSessionConfiguration& config) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the audio session configuration.
|
||||||
|
*
|
||||||
|
* @param [out] config The pointer to the audio session configuration: \ref agora::base::AudioSessionConfiguration "AudioSessionConfiguration".
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int getAudioSessionConfiguration(AudioSessionConfiguration* config) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the path and size of the SDK log files.
|
||||||
|
*
|
||||||
|
* The SDK records all the log data during the SDK runtime in two log files,
|
||||||
|
* each with a default size of 512 KB. If you set `fileSize` as 1024 KB,
|
||||||
|
* the SDK outputs log files with a maximum size of 2 MB. If the total size
|
||||||
|
* of the log files exceeds the set value, the new output log
|
||||||
|
* overwrites the old output log.
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* To ensure that the output log is complete, call this method immediately after calling
|
||||||
|
* \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).
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setLogFile(const char* filePath, unsigned int fileSize) = 0;
|
||||||
|
/**
|
||||||
|
* Sets the SDK log output filter.
|
||||||
|
*
|
||||||
|
* The log level follows the sequence of OFF, CRITICAL, ERROR, WARNING, INFO, and DEBUG.
|
||||||
|
*
|
||||||
|
* Select a level to output the logs in and above the selected level.
|
||||||
|
* For example, if you set the log level to WARNING, you can see the logs in the levels of CRITICAL, ERROR, and WARNING.
|
||||||
|
*
|
||||||
|
* @param filters The log output filter.
|
||||||
|
* - `LOG_LEVEL_NONE (0x0000)`: Do not output any log file.
|
||||||
|
* - `LOG_LEVEL_INFO (0x0001)`: (Recommended) Output log files of the INFO level.
|
||||||
|
* - `LOG_LEVEL_WARN (0x0002)`: Output log files of the WARN level.
|
||||||
|
* - `LOG_LEVEL_ERROR (0x0004)`: Output log files of the ERROR level.
|
||||||
|
* - `LOG_LEVEL_FATAL (0x0008)`: Output log files of the FATAL level.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setLogFilter(unsigned int filters) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an \ref agora::rtc::IRtcConnection "RtcConnection" object and returns the pointer.
|
||||||
|
*
|
||||||
|
* @param cfg The reference to the RTC connection configuration: \ref agora::rtc::RtcConnectionConfiguration "RtcConnectionConfiguration".
|
||||||
|
* @return
|
||||||
|
* - The pointer to \ref rtc::IRtcConnection "IRtcConnection": Success.
|
||||||
|
* - A null pointer: Failure.
|
||||||
|
*/
|
||||||
|
virtual agora_refptr<rtc::IRtcConnection> createRtcConnection(
|
||||||
|
const rtc::RtcConnectionConfiguration& cfg) = 0;
|
||||||
|
|
||||||
|
virtual agora_refptr<rtc::IRtmpConnection> createRtmpConnection(
|
||||||
|
const rtc::RtmpConnectionConfiguration& cfg) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a local audio track object and returns the pointer.
|
||||||
|
*
|
||||||
|
* By default, the audio track is created from the selected audio input device, such as
|
||||||
|
* the built-in microphone on a mobile device.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - The pointer to \ref rtc::ILocalAudioTrack "ILocalAudioTrack": Success.
|
||||||
|
* - A null pointer: Failure.
|
||||||
|
* - `INVALID_STATE`, if `enableAudioProcessor` in \ref agora::base::AgoraServiceConfiguration "AgoraServiceConfiguration" is set as `false`.
|
||||||
|
*/
|
||||||
|
virtual agora_refptr<rtc::ILocalAudioTrack> 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<rtc::ILocalAudioTrack> createLocalMixedAudioTrack() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a local audio track object with a PCM data sender and returns the pointer.
|
||||||
|
*
|
||||||
|
* Once created, this track can be used to send PCM audio data.
|
||||||
|
*
|
||||||
|
* @param audioSource The pointer to the PCM audio data sender: \ref agora::rtc::IAudioPcmDataSender "IAudioPcmDataSender".
|
||||||
|
* @return
|
||||||
|
* - The pointer to \ref rtc::ILocalAudioTrack "ILocalAudioTrack": Success.
|
||||||
|
* - A null pointer: Failure.
|
||||||
|
* - `INVALID_STATE`, if `enableAudioProcessor` in \ref agora::base::AgoraServiceConfiguration "AgoraServiceConfiguration" is set as `false`.
|
||||||
|
*/
|
||||||
|
virtual agora_refptr<rtc::ILocalAudioTrack> createCustomAudioTrack(
|
||||||
|
agora_refptr<rtc::IAudioPcmDataSender> audioSource) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a local audio track object with a PCM data sender and returns the pointer.
|
||||||
|
* The source is not intended to be mixed with other source.
|
||||||
|
*
|
||||||
|
* Once created, this track can be used to send PCM audio data.
|
||||||
|
*
|
||||||
|
* @param audioSource The pointer to the PCM audio data sender: \ref agora::rtc::IAudioPcmDataSender "IAudioPcmDataSender".
|
||||||
|
* @return
|
||||||
|
* - The pointer to \ref rtc::ILocalAudioTrack "ILocalAudioTrack": Success.
|
||||||
|
* - A null pointer: Failure.
|
||||||
|
* - `INVALID_STATE`, if `enableAudioProcessor` in \ref agora::base::AgoraServiceConfiguration "AgoraServiceConfiguration" is set as `false`.
|
||||||
|
*/
|
||||||
|
virtual agora_refptr<rtc::ILocalAudioTrack> createDirectCustomAudioTrack(
|
||||||
|
agora_refptr<rtc::IAudioPcmDataSender> audioSource) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a local audio track object with a PCM data sender and returns the pointer.
|
||||||
|
*
|
||||||
|
* Once created, this track can be used to send PCM audio data.
|
||||||
|
*
|
||||||
|
* @param audioSource The pointer to the PCM audio data sender: \ref agora::rtc::IAudioPcmDataSender "IAudioPcmDataSender".
|
||||||
|
* @param enableAec Whether enable audio echo cancellation for PCM audio data.
|
||||||
|
* @return
|
||||||
|
* - The pointer to \ref rtc::ILocalAudioTrack "ILocalAudioTrack": Success.
|
||||||
|
* - A null pointer: Failure.
|
||||||
|
* - `INVALID_STATE`, if `enableAudioProcessor` in \ref agora::base::AgoraServiceConfiguration "AgoraServiceConfiguration" is set as `false`.
|
||||||
|
*/
|
||||||
|
virtual agora_refptr<rtc::ILocalAudioTrack> createCustomAudioTrack(
|
||||||
|
agora_refptr<rtc::IAudioPcmDataSender> audioSource, bool enableAec) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a local audio track object with two PCM data sender and returns the pointer.
|
||||||
|
*
|
||||||
|
* Once created, this track can be used to send PCM audio data with echo cancellation.
|
||||||
|
*
|
||||||
|
* @param audioSource The pointer to the recording PCM audio data sender: \ref agora::rtc::IAudioPcmDataSender "IAudioPcmDataSender".
|
||||||
|
* @param audioReverseSource The pointer to the playout PCM audio data sender: \ref agora::rtc::IAudioPcmDataSender "IAudioPcmDataSender".
|
||||||
|
* @param audioSourceDelay The delay of recording pcm data when do echo cancellation.
|
||||||
|
* @return
|
||||||
|
* - The pointer to \ref rtc::ILocalAudioTrack "ILocalAudioTrack": Success.
|
||||||
|
* - A null pointer: Failure.
|
||||||
|
* - `INVALID_STATE`, if `enableAudioProcessor` in \ref agora::base::AgoraServiceConfiguration "AgoraServiceConfiguration" is set as `false`.
|
||||||
|
*/
|
||||||
|
virtual agora_refptr<rtc::ILocalAudioTrack> createCustomAudioTrack(agora_refptr<rtc::IAudioPcmDataSender> audioSource,
|
||||||
|
agora_refptr<rtc::IAudioPcmDataSender> audioReverseSource,
|
||||||
|
int audioSourceDelay) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a local audio track object with a audio mixer source and returns the pointer.
|
||||||
|
*
|
||||||
|
* Once created, this track can be used to send PCM audio data.
|
||||||
|
*
|
||||||
|
* @param audioSource The pointer to the audio mixer source : \ref agora::rtc::IRemoteAudioMixerSource "IRemoteAudioMixerSource".
|
||||||
|
* @return
|
||||||
|
* - The pointer to \ref rtc::ILocalAudioTrack "ILocalAudioTrack", if the method call succeeds.
|
||||||
|
* - A null pointer, if the method call fails.
|
||||||
|
* - `INVALID_STATE`, if `enableAudioProcessor` in `AgoraServiceConfiguration` is set as `false`.
|
||||||
|
*/
|
||||||
|
virtual agora_refptr<rtc::ILocalAudioTrack> createCustomAudioTrack(
|
||||||
|
agora_refptr<rtc::IRemoteAudioMixerSource> audioSource) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a local audio track object with an encoded audio frame sender and returns the pointer.
|
||||||
|
*
|
||||||
|
* Once created, this track can be used to send encoded audio frames, such as Opus frames.
|
||||||
|
*
|
||||||
|
* @param audioSource The pointer to the encoded audio frame sender: \ref agora::rtc::IAudioEncodedFrameSender "IAudioEncoderFrameSender".
|
||||||
|
* @param mixMode The mixing mode of the encoded audio in the channel: #TMixMode.
|
||||||
|
* @return
|
||||||
|
* - The pointer to \ref rtc::ILocalAudioTrack "ILocalAudioTrack": Success.
|
||||||
|
* - A null pointer: Failure.
|
||||||
|
* - `INVALID_STATE`, if `enableAudioProcessor` is set as `false` in \ref agora::base::AgoraServiceConfiguration "AgoraServiceConfiguration".
|
||||||
|
*/
|
||||||
|
virtual agora_refptr<rtc::ILocalAudioTrack> createCustomAudioTrack(
|
||||||
|
agora_refptr<rtc::IAudioEncodedFrameSender> audioSource, TMixMode mixMode) = 0;
|
||||||
|
/// @cond (!Linux)
|
||||||
|
/**
|
||||||
|
* Creates a local audio track object with a media packet sender and returns the pointer.
|
||||||
|
*
|
||||||
|
* Once created, this track can be used to send audio packets, such as customized UDP/RTP packets.
|
||||||
|
*
|
||||||
|
* @param source The pointer to the media packet sender: \ref agora::rtc::IMediaPacketSender "IMediaPacketSender".
|
||||||
|
* @return
|
||||||
|
* - The pointer to \ref rtc::ILocalAudioTrack "ILocalAudioTrack": Success.
|
||||||
|
* - A null pointer: Failure.
|
||||||
|
* - `INVALID_STATE`, if `enableAudioProcessor` is set as `false` in \ref agora::base::AgoraServiceConfiguration "AgoraServiceConfiguration".
|
||||||
|
*/
|
||||||
|
virtual agora_refptr<rtc::ILocalAudioTrack> createCustomAudioTrack(
|
||||||
|
agora_refptr<rtc::IMediaPacketSender> source) = 0;
|
||||||
|
/// @endcond
|
||||||
|
/**
|
||||||
|
* Creates a local audio track object with an IMediaPlayerSource object and returns the pointer.
|
||||||
|
*
|
||||||
|
* Once created, this track can be used to send PCM audio data decoded from a media player.
|
||||||
|
*
|
||||||
|
* @param audioSource The pointer to the player source. See \ref agora::rtc::IMediaPlayerSource "IMediaPlayerSource".
|
||||||
|
* @return
|
||||||
|
* - The pointer to \ref rtc::ILocalAudioTrack "ILocalAudioTrack": Success.
|
||||||
|
* - A null pointer: Failure.
|
||||||
|
* - `INVALID_STATE`, if `enableAudioProcessor` is set as `false` in \ref agora::base::AgoraServiceConfiguration "AgoraServiceConfiguration".
|
||||||
|
*/
|
||||||
|
virtual agora_refptr<rtc::ILocalAudioTrack> createMediaPlayerAudioTrack(
|
||||||
|
agora_refptr<rtc::IMediaPlayerSource> audioSource) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a local audio track object with an IMediaStreamingSource object and returns the pointer.
|
||||||
|
*
|
||||||
|
* Once created, this track can be used to send encoded audio data which demuxed from a media streaming.
|
||||||
|
*
|
||||||
|
* @param streamingSource The pointer to the streaming source. See \ref agora::rtc::IMediaStreamingSource "IMediaStreamingSource".
|
||||||
|
* @return
|
||||||
|
* - The pointer to \ref rtc::ILocalAudioTrack "ILocalAudioTrack": Success.
|
||||||
|
* - A null pointer: Failure.
|
||||||
|
* - `INVALID_STATE`, if `enableAudioProcessor` is set as `false` in \ref agora::base::AgoraServiceConfiguration "AgoraServiceConfiguration".
|
||||||
|
*/
|
||||||
|
virtual agora_refptr<rtc::ILocalAudioTrack> createMediaStreamingAudioTrack(
|
||||||
|
agora_refptr<rtc::IMediaStreamingSource> streamingSource) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a local audio track object with the recording device source and returns the pointer.
|
||||||
|
*
|
||||||
|
* Once created, this track can be used to send audio data got from a recording device.
|
||||||
|
* @param audioSource The pointer to the recording device source. See \ref agora::rtc::IRecordingDeviceSource "IRecordingDeviceSource".
|
||||||
|
* @param enableAec Whether enable audio echo cancellation for loopback recording. If loopback
|
||||||
|
* recording device is a virtual sound card, it should be false, or it should be true.
|
||||||
|
* @return
|
||||||
|
* - The pointer to \ref rtc::ILocalAudioTrack "ILocalAudioTrack": Success.
|
||||||
|
* - A null pointer: Failure.
|
||||||
|
*/
|
||||||
|
virtual agora_refptr<rtc::ILocalAudioTrack> createRecordingDeviceAudioTrack(
|
||||||
|
agora_refptr<rtc::IRecordingDeviceSource> audioSource, bool enableAec) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an audio device manager object and returns the pointer.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - The pointer to \ref rtc::INGAudioDeviceManager "INGAudioDeviceManager": Success.
|
||||||
|
* - A null pointer: Failure.
|
||||||
|
*/
|
||||||
|
virtual agora_refptr<rtc::INGAudioDeviceManager> createAudioDeviceManager() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a media node factory object and returns the pointer.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - The pointer to \ref rtc::IMediaNodeFactory "IMediaNodeFactory": Success.
|
||||||
|
* - A null pointer: Failure.
|
||||||
|
*/
|
||||||
|
virtual agora_refptr<rtc::IMediaNodeFactory> createMediaNodeFactory() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a local video track object with a camera capturer and returns the pointer.
|
||||||
|
*
|
||||||
|
* Once created, this track can be used to send video data captured by the camera.
|
||||||
|
*
|
||||||
|
* @param videoSource The pointer to the camera capturer: \ref agora::rtc::ICameraCapturer "ICameraCapturer".
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - The pointer to \ref rtc::ILocalVideoTrack "ILocalVideoTrack": Success.
|
||||||
|
* - A null pointer: Failure.
|
||||||
|
*/
|
||||||
|
virtual agora_refptr<rtc::ILocalVideoTrack> createCameraVideoTrack(
|
||||||
|
agora_refptr<rtc::ICameraCapturer> 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<rtc::ILocalVideoTrack> createScreenVideoTrack(
|
||||||
|
agora_refptr<rtc::IScreenCapturer> videoSource, const char* id = OPTIONAL_NULLPTR) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a local video track object with a video mixer and returns the pointer.
|
||||||
|
*
|
||||||
|
* Once created, this track can be used to send video data processed by the video mixer.
|
||||||
|
*
|
||||||
|
* @param videoSource The pointer to the video mixer. See \ref agora::rtc::IVideoMixerSource "IVideoMixerSource".
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - The pointer to \ref rtc::ILocalVideoTrack "ILocalVideoTrack": Success.
|
||||||
|
* - A null pointer: Failure.
|
||||||
|
*/
|
||||||
|
virtual agora_refptr<rtc::ILocalVideoTrack> createMixedVideoTrack(agora_refptr<rtc::IVideoMixerSource> videoSource,
|
||||||
|
const char* id = OPTIONAL_NULLPTR) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a local video track object with a video frame transceiver and returns the pointer.
|
||||||
|
*
|
||||||
|
* Once created, this track can be used to send video data processed by the transceiver.
|
||||||
|
*
|
||||||
|
* @param transceiver The pointer to the video transceiver. See \ref agora::rtc::IVideoFrameTransceiver "IVideoFrameTransceiver".
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - The pointer to \ref rtc::ILocalVideoTrack "ILocalVideoTrack": Success.
|
||||||
|
* - A null pointer: Failure.
|
||||||
|
*/
|
||||||
|
virtual agora_refptr<rtc::ILocalVideoTrack> createTranscodedVideoTrack(agora_refptr<rtc::IVideoFrameTransceiver> transceiver,
|
||||||
|
const char* id = OPTIONAL_NULLPTR) = 0;
|
||||||
|
|
||||||
|
/// @cond (!RTSA)
|
||||||
|
/**
|
||||||
|
* Creates a local video track object with a customized video source and returns the pointer.
|
||||||
|
*
|
||||||
|
* Once created, this track can be used to send video data from a customized source.
|
||||||
|
*
|
||||||
|
* @param videoSource The pointer to the customized video frame sender: \ref agora::rtc::IVideoFrameSender "IVideoFrameSender".
|
||||||
|
* @return
|
||||||
|
* - The pointer to \ref rtc::ILocalVideoTrack "ILocalVideoTrack": Success.
|
||||||
|
* - A null pointer: Failure.
|
||||||
|
*/
|
||||||
|
virtual agora_refptr<rtc::ILocalVideoTrack> createCustomVideoTrack(
|
||||||
|
agora_refptr<rtc::IVideoFrameSender> videoSource, const char* id = OPTIONAL_NULLPTR) = 0;
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a local video track object with an encoded video image sender and returns the pointer.
|
||||||
|
*
|
||||||
|
* Once created, this track can be used to send encoded video images, such as H.264 or VP8 frames.
|
||||||
|
*
|
||||||
|
* @param videoSource The pointer to the encoded video frame sender. See \ref agora::rtc::IVideoEncodedImageSender "IVideoEncodedImageSender".
|
||||||
|
* @param options The configuration for creating video encoded image track.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - The pointer to \ref rtc::ILocalVideoTrack "ILocalVideoTrack": Success.
|
||||||
|
* - A null pointer: Failure.
|
||||||
|
*/
|
||||||
|
virtual agora_refptr<rtc::ILocalVideoTrack> createCustomVideoTrack(
|
||||||
|
agora_refptr<rtc::IVideoEncodedImageSender> videoSource,
|
||||||
|
const rtc::SenderOptions& options,
|
||||||
|
const char* id = OPTIONAL_NULLPTR) = 0;
|
||||||
|
|
||||||
|
#if defined(__ANDROID__) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE)
|
||||||
|
/**
|
||||||
|
* Creates a local video track object with a screen capture source extension and returns the pointer.
|
||||||
|
*
|
||||||
|
* Once created, this track can be used to work with the screen capture extension.
|
||||||
|
*
|
||||||
|
* @param screen The pointer to the screen capture source.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - The pointer to \ref rtc::ILocalVideoTrack "ILocalVideoTrack": Success.
|
||||||
|
* - A null pointer: Failure.
|
||||||
|
*/
|
||||||
|
virtual agora_refptr<rtc::ILocalVideoTrack> createScreenCaptureVideoTrack(
|
||||||
|
agora_refptr<rtc::IScreenCapturer2> screen) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a local audio track object with a screen capture source extension and returns the pointer.
|
||||||
|
*
|
||||||
|
* Once created, this track can be used to work with the screen capture extension.
|
||||||
|
*
|
||||||
|
* @param screen The pointer to the screen capture source.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - The pointer to \ref rtc::ILocalAudioTrack "ILocalAudioTrack": Success.
|
||||||
|
* - A null pointer: Failure.
|
||||||
|
*/
|
||||||
|
virtual agora_refptr<rtc::ILocalAudioTrack> createScreenCaptureAudioTrack(
|
||||||
|
agora_refptr<rtc::IScreenCapturer2> screen) = 0;
|
||||||
|
#else
|
||||||
|
/**
|
||||||
|
* Creates a local video track object with a screen capture source extension and returns the pointer.
|
||||||
|
*
|
||||||
|
* Once created, this track can be used to work with the screen capture extension.
|
||||||
|
*
|
||||||
|
* @param screen The pointer to the screen capture source.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - The pointer to \ref rtc::ILocalVideoTrack "ILocalVideoTrack": Success.
|
||||||
|
* - A null pointer: Failure.
|
||||||
|
*/
|
||||||
|
virtual agora_refptr<rtc::ILocalVideoTrack> createScreenCaptureVideoTrack(
|
||||||
|
agora_refptr<rtc::IScreenCapturer> screen, const char* id = OPTIONAL_NULLPTR) = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/// @cond (!Linux)
|
||||||
|
/**
|
||||||
|
* Creates a local video track object with a media packet sender and returns the pointer.
|
||||||
|
*
|
||||||
|
* Once created, this track can be used to send video packets, such as customized UDP/RTP packets.
|
||||||
|
*
|
||||||
|
* @param source The pointer to the media packet sender: \ref agora::rtc::IMediaPacketSender "IMediaPacketSender".
|
||||||
|
* @return
|
||||||
|
* - The pointer to \ref rtc::ILocalVideoTrack "ILocalVideoTrack": Success.
|
||||||
|
* - A null pointer: Failure.
|
||||||
|
*/
|
||||||
|
virtual agora_refptr<rtc::ILocalVideoTrack> createCustomVideoTrack(
|
||||||
|
agora_refptr<rtc::IMediaPacketSender> source, const char* id = OPTIONAL_NULLPTR) = 0;
|
||||||
|
/// @endcond
|
||||||
|
/**
|
||||||
|
* Creates a local video track object with an IMediaPlayerSource object and returns the pointer.
|
||||||
|
*
|
||||||
|
* Once created, this track can be used to send YUV frames decoded from a player.
|
||||||
|
*
|
||||||
|
* @param videoSource The pointer to the player source. See \ref agora::rtc::IMediaPlayerSource "IMediaPlayerSource".
|
||||||
|
* @return
|
||||||
|
* - The pointer to \ref rtc::ILocalAudioTrack "ILocalAudioTrack": Success.
|
||||||
|
* - A null pointer: Failure.
|
||||||
|
*/
|
||||||
|
virtual agora_refptr<rtc::ILocalVideoTrack> createMediaPlayerVideoTrack(
|
||||||
|
agora_refptr<rtc::IMediaPlayerSource> videoSource, const char* id = OPTIONAL_NULLPTR) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a local video track object with an IMediaStreamingSource object and returns the pointer.
|
||||||
|
*
|
||||||
|
* Once created, this track can be used to send H264 frames which demuxed from a streaming.
|
||||||
|
*
|
||||||
|
* @param streamingSource The pointer to the player source. See \ref agora::rtc::IMediaStreamingSource "IMediaStreamingSource".
|
||||||
|
* @return
|
||||||
|
* - The pointer to \ref rtc::ILocalAudioTrack "ILocalAudioTrack": Success.
|
||||||
|
* - A null pointer: Failure.
|
||||||
|
*/
|
||||||
|
virtual agora_refptr<rtc::ILocalVideoTrack> createMediaStreamingVideoTrack(
|
||||||
|
agora_refptr<rtc::IMediaStreamingSource> streamingSource, const char* id = OPTIONAL_NULLPTR) = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an RTMP streaming service object and returns the pointer.
|
||||||
|
*
|
||||||
|
* @param rtcConnection The pointer to \ref rtc::IRtcConnection "IRtcConnection".
|
||||||
|
* @param appId The App ID of the live streaming service.
|
||||||
|
* @return
|
||||||
|
* - The pointer to \ref rtc::IRtmpStreamingService "IRtmpStreamingService": Success.
|
||||||
|
* - A null pointer: Failure.
|
||||||
|
*/
|
||||||
|
virtual agora_refptr<rtc::IRtmpStreamingService> createRtmpStreamingService(
|
||||||
|
agora_refptr<rtc::IRtcConnection> rtcConnection, const char* appId) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an Media Relay service object and returns the pointer.
|
||||||
|
*
|
||||||
|
* @param rtcConnection The pointer to \ref rtc::IRtcConnection "IRtcConnection".
|
||||||
|
* @param appId The App ID of the media relay service.
|
||||||
|
* @return
|
||||||
|
* - The pointer to \ref rtc::IMediaRelayService "IMediaRelayService", if the method call
|
||||||
|
* succeeds.
|
||||||
|
* - A null pointer, if the method call fails.
|
||||||
|
*/
|
||||||
|
virtual agora_refptr<rtc::IMediaRelayService> createMediaRelayService(
|
||||||
|
agora_refptr<rtc::IRtcConnection> rtcConnection, const char* appId) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an file upload object and returns the pointer.
|
||||||
|
*
|
||||||
|
* @param rtcConnection The pointer to \ref rtc::IRtcConnection "IRtcConnection".
|
||||||
|
* @param appId The App ID of the media relay service.
|
||||||
|
* @return
|
||||||
|
* - The pointer to \ref rtc::IFileUploaderService "IFileUploaderService", if the method call
|
||||||
|
* succeeds.
|
||||||
|
* - A null pointer, if the method call fails.
|
||||||
|
*/
|
||||||
|
virtual agora_refptr<rtc::IFileUploaderService> createFileUploadService(
|
||||||
|
agora_refptr<rtc::IRtcConnection> rtcConnection, const char* appId) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an RTM servive object and returns the pointer.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - The pointer to \ref rtm::IRtmService "IRtmService": Success.
|
||||||
|
* - A null pointer: Failure.
|
||||||
|
*/
|
||||||
|
virtual rtm::IRtmService* createRtmService() = 0;
|
||||||
|
|
||||||
|
virtual int addExtensionObserver(agora::agora_refptr<agora::rtc::IMediaExtensionObserver> observer) = 0;
|
||||||
|
|
||||||
|
virtual int removeExtensionObserver(agora::agora_refptr<agora::rtc::IMediaExtensionObserver> observer) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an audio device manager and returns the pointer.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - The pointer to \ref rtc::IAudioDeviceManager "IAudioDeviceManager": Success.
|
||||||
|
* - A null pointer: Failure.
|
||||||
|
*/
|
||||||
|
virtual agora_refptr<rtc::IAudioDeviceManager> createAudioDeviceManagerComponent(
|
||||||
|
rtc::IAudioDeviceManagerObserver *observer) = 0;
|
||||||
|
/**
|
||||||
|
* @brief Get the ID of the registered extension
|
||||||
|
*
|
||||||
|
* @param provider_name The pointer to provider name string (null-terminated)
|
||||||
|
* @param extension_name The pointer to extension name string (null-terminated)
|
||||||
|
* @return
|
||||||
|
* - Pointer to the extension id string (null-terminated). The pointer will be valid during service's lifetime
|
||||||
|
*/
|
||||||
|
virtual const char* getExtensionId(const char* provider_name, const char* extension_name) = 0;
|
||||||
|
|
||||||
|
#if defined (_WIN32) || defined(__linux__) || defined(__ANDROID__)
|
||||||
|
/**
|
||||||
|
* @brief load the dynamic library of the extension
|
||||||
|
*
|
||||||
|
* @param path path of the extension library
|
||||||
|
* @param unload_after_use unload the library when engine release
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
virtual int loadExtensionProvider(const char* path, bool unload_after_use = false) = 0;
|
||||||
|
#endif
|
||||||
|
/**
|
||||||
|
* Enable extension.
|
||||||
|
* If the extension is enabled, the track loads the extension automatically.
|
||||||
|
*
|
||||||
|
* @param provider_name name for provider, e.g. agora.io.
|
||||||
|
* @param extension_name name for extension, e.g. agora.beauty.
|
||||||
|
* @param track_id id for the track, OPTIONAL_NULLPTR means effective on all tracks
|
||||||
|
* @param auto_enable_on_track if the extension is automatically open on track.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int enableExtension(
|
||||||
|
const char* provider_name, const char* extension_name, const char* track_id = NULL,
|
||||||
|
bool auto_enable_on_track = false) = 0;
|
||||||
|
/**
|
||||||
|
* Disable extension.
|
||||||
|
*
|
||||||
|
* @param provider_name name for provider, e.g. agora.io.
|
||||||
|
* @param extension_name name for extension, e.g. agora.beauty.
|
||||||
|
* @param track_id id for the track, OPTIONAL_NULLPTR means effective on all tracks
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int disableExtension(
|
||||||
|
const char* provider_name, const char* extension_name, const char* track_id = NULL) = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual ~IAgoraService() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace base
|
||||||
|
} // namespace agora
|
||||||
|
|
||||||
|
/** \addtogroup createAgoraService
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Creates an \ref agora::base::IAgoraService "IAgoraService" object and returns the pointer.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - The pointer to \ref agora::base::IAgoraService "IAgoraService": Success.
|
||||||
|
* - A null pointer: Failure.
|
||||||
|
*/
|
||||||
|
AGORA_API agora::base::IAgoraService* AGORA_CALL createAgoraService();
|
||||||
|
/** @} */
|
|
@ -0,0 +1,314 @@
|
||||||
|
//
|
||||||
|
// AgoraRtcEngine SDK
|
||||||
|
//
|
||||||
|
// Copyright (c) 2019 Agora.io. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef AGORA_SPATIAL_AUDIO_H
|
||||||
|
#define AGORA_SPATIAL_AUDIO_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "AgoraBase.h"
|
||||||
|
#include "AgoraMediaBase.h"
|
||||||
|
#include "AgoraRefPtr.h"
|
||||||
|
#include "IAgoraRtcEngineEx.h"
|
||||||
|
|
||||||
|
namespace agora {
|
||||||
|
namespace rtc {
|
||||||
|
|
||||||
|
// The information of remote voice position
|
||||||
|
struct RemoteVoicePositionInfo {
|
||||||
|
// The coordnate of remote voice source, (x, y, z)
|
||||||
|
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 {
|
||||||
|
//the zone id
|
||||||
|
int zoneSetId;
|
||||||
|
//zone center point
|
||||||
|
float position[3];
|
||||||
|
//forward direction
|
||||||
|
float forward[3];
|
||||||
|
//right direction
|
||||||
|
float right[3];
|
||||||
|
//up direction
|
||||||
|
float up[3];
|
||||||
|
//the forward side length of the zone
|
||||||
|
float forwardLength;
|
||||||
|
//tehe right side length of the zone
|
||||||
|
float rightLength;
|
||||||
|
//the up side length of the zone
|
||||||
|
float upLength;
|
||||||
|
//the audio attenuation of zone
|
||||||
|
float audioAttenuation;
|
||||||
|
SpatialAudioZone() = default;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** The definition of LocalSpatialAudioConfig
|
||||||
|
*/
|
||||||
|
struct LocalSpatialAudioConfig {
|
||||||
|
/*The reference to \ref IRtcEngine, which is the base interface class of the Agora RTC SDK and provides
|
||||||
|
* the real-time audio and video communication functionality.
|
||||||
|
*/
|
||||||
|
agora::rtc::IRtcEngine* rtcEngine;
|
||||||
|
|
||||||
|
LocalSpatialAudioConfig() : rtcEngine(NULL) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
/** The IBaseSpatialAudioEngine class provides the common methods of ICloudSpatialAudioEngine and ILocalSpatialAudioEngine.
|
||||||
|
*/
|
||||||
|
class IBaseSpatialAudioEngine: public RefCountInterface {
|
||||||
|
protected:
|
||||||
|
virtual ~IBaseSpatialAudioEngine() {}
|
||||||
|
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Releases all the resources occupied by spatial audio engine.
|
||||||
|
*/
|
||||||
|
virtual void release() = 0;
|
||||||
|
/**
|
||||||
|
* This method sets the maximum number of streams that a player can receive in a
|
||||||
|
* specified audio reception range.
|
||||||
|
*
|
||||||
|
* @note You can call this method either before or after calling enterRoom:
|
||||||
|
* - Calling this method before enterRoom affects the maximum number of received streams
|
||||||
|
* the next time the player enters a room.
|
||||||
|
* - Calling this method after entering a room changes the current maximum number of
|
||||||
|
* received streams of the player.
|
||||||
|
*
|
||||||
|
* @param maxCount The maximum number of streams that a player can receive within
|
||||||
|
* a specified audio reception range. If the number of receivable streams exceeds
|
||||||
|
* the set value, the SDK receives the set number of streams closest to the player.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - <0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setMaxAudioRecvCount(int maxCount) = 0;
|
||||||
|
/**
|
||||||
|
* This method sets the audio reception range. The unit of the audio reception range
|
||||||
|
* is the same as the unit of distance in the game engine.
|
||||||
|
*
|
||||||
|
* @note You can call this method either before or after calling enterRoom.
|
||||||
|
* During the game, you can call it multiple times to update the audio reception range.
|
||||||
|
*
|
||||||
|
* @param range The maximum audio reception range, in the unit of game engine distance.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - <0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setAudioRecvRange(float range) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method sets distance unit of game engine. The smaller the unit is, the sound fades slower
|
||||||
|
* with distance.
|
||||||
|
*
|
||||||
|
* @note You can call this method either before or after calling enterRoom.
|
||||||
|
* During the game, you can call it multiple times to update the distance unit.
|
||||||
|
*
|
||||||
|
* @param unit The number of meters that the game engine distance per unit is equal to. For example, setting unit as 2 means the game engine distance per unit equals 2 meters.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - <0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setDistanceUnit(float unit) = 0;
|
||||||
|
/**
|
||||||
|
* Updates the position of local user.
|
||||||
|
* When calling it in ICloudSpatialAudioEngine, it triggers the SDK to update the user position to the Agora spatial audio server. The Agora spatial audio server uses the users' world coordinates and audio reception range to determine whether they are within each other's specified audio reception range.
|
||||||
|
* When calling it in ILocalSpatialAudioEngine, it triggers the SDK to calculate the relative position between the local and remote users and updates spatial audio parameters.
|
||||||
|
*
|
||||||
|
* when calling it in ICloudSpatialAudioEngine, you should notice:
|
||||||
|
* @note
|
||||||
|
* - Call the method after calling enterRoom.
|
||||||
|
* - The call frequency is determined by the app. Agora recommends calling this method every
|
||||||
|
* 120 to 7000 ms. Otherwise, the SDK may lose synchronization with the server.
|
||||||
|
*
|
||||||
|
* @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.
|
||||||
|
* @return
|
||||||
|
* - 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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the position of a media player in scene. This method has same behavior both in ICloudSpatialAudioEngine and ILocalSpatialAudioEngine.
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* - This method is suggested to be called once if you don't move media player in the virtual space.
|
||||||
|
*
|
||||||
|
* @param playerId The ID of the media player. You can get it by IMediaPlayer::getMediaPlayerId.
|
||||||
|
* @param positionInfo The position information of media player in the virtual space. For details inforamtion, see the declaration of RemoteVoicePositionInfo.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - <0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int updatePlayerPositionInfo(int playerId, const RemoteVoicePositionInfo& positionInfo) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set parameters for spatial audio engine. It's deprecated for using.
|
||||||
|
*
|
||||||
|
* @param params The parameter string.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - <0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setParameters(const char* params) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mute or unmute local audio stream.
|
||||||
|
*
|
||||||
|
* @param mute When it's false, it will send local audio stream, otherwise it will not send local audio stream.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - <0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int muteLocalAudioStream(bool mute) = 0;
|
||||||
|
/**
|
||||||
|
* Mute all remote audio streams. It determines wether SDK receves remote audio streams or not.
|
||||||
|
*
|
||||||
|
* @param mute When it's false, SDK will receive remote audio streams, otherwise SDK will not receive remote audio streams.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - <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.
|
||||||
|
*
|
||||||
|
* @param uid The ID of the remote user.
|
||||||
|
* @param mute When it's false, SDK will receive remote user audio streams, otherwise SDK will not receive remote user audio streams.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - <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;
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 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;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace rtc
|
||||||
|
} // namespace agora
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,482 @@
|
||||||
|
//
|
||||||
|
// Agora SDK
|
||||||
|
//
|
||||||
|
// Copyright (c) 2021 Agora.io. All rights reserved.
|
||||||
|
//
|
||||||
|
#pragma once // NOLINT(build/header_guard)
|
||||||
|
|
||||||
|
namespace agora {
|
||||||
|
namespace rtc {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The maximum device ID length.
|
||||||
|
*/
|
||||||
|
enum MAX_DEVICE_ID_LENGTH_TYPE {
|
||||||
|
/**
|
||||||
|
* The maximum device ID length is 512.
|
||||||
|
*/
|
||||||
|
MAX_DEVICE_ID_LENGTH = 512
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The IAudioDeviceCollection class.
|
||||||
|
*/
|
||||||
|
class IAudioDeviceCollection {
|
||||||
|
public:
|
||||||
|
virtual ~IAudioDeviceCollection() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the total number of the playback or recording devices.
|
||||||
|
*
|
||||||
|
* Call \ref IAudioDeviceManager::enumeratePlaybackDevices
|
||||||
|
* "enumeratePlaybackDevices" first, and then call this method to return the
|
||||||
|
* number of the audio playback devices.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - The number of the audio devices, if the method call succeeds.
|
||||||
|
* - < 0, if the method call fails.
|
||||||
|
*/
|
||||||
|
virtual int getCount() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the information of a specified audio device.
|
||||||
|
* @param index An input parameter that specifies the audio device.
|
||||||
|
* @param deviceName An output parameter that indicates the device name.
|
||||||
|
* @param deviceId An output parameter that indicates the device ID.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int getDevice(int index, char deviceName[MAX_DEVICE_ID_LENGTH],
|
||||||
|
char deviceId[MAX_DEVICE_ID_LENGTH]) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies a device with the device ID.
|
||||||
|
* @param deviceId The device ID.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setDevice(const char deviceId[MAX_DEVICE_ID_LENGTH]) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the default audio device of the system (for macOS and Windows only).
|
||||||
|
*
|
||||||
|
* @param deviceName The name of the system default audio device.
|
||||||
|
* @param deviceId The device ID of the the system default audio device.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int getDefaultDevice(char deviceName[MAX_DEVICE_ID_LENGTH], char deviceId[MAX_DEVICE_ID_LENGTH]) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the volume of the app.
|
||||||
|
*
|
||||||
|
* @param volume The volume of the app. The value range is [0, 255].
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setApplicationVolume(int volume) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the volume of the app.
|
||||||
|
*
|
||||||
|
* @param volume The volume of the app. The value range is [0, 255]
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int getApplicationVolume(int &volume) = 0;
|
||||||
|
|
||||||
|
/** Mutes or unmutes the app.
|
||||||
|
*
|
||||||
|
* @param mute Determines whether to mute the app:
|
||||||
|
* - true: Mute the app.
|
||||||
|
* - false: Unmute the app.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setApplicationMute(bool mute) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the mute state of the app.
|
||||||
|
*
|
||||||
|
* @param mute A reference to the mute state of the app:
|
||||||
|
* - true: The app is muted.
|
||||||
|
* - false: The app is not muted.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int isApplicationMute(bool &mute) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Releases all IAudioDeviceCollection resources.
|
||||||
|
*/
|
||||||
|
virtual void release() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The IAudioDeviceManager class.
|
||||||
|
*/
|
||||||
|
class IAudioDeviceManager : public RefCountInterface {
|
||||||
|
public:
|
||||||
|
virtual ~IAudioDeviceManager() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enumerates the audio playback devices.
|
||||||
|
*
|
||||||
|
* This method returns an IAudioDeviceCollection object that includes all the
|
||||||
|
* audio playback devices in the system. With the IAudioDeviceCollection
|
||||||
|
* object, the app can enumerate the audio playback devices. The app must call
|
||||||
|
* the \ref IAudioDeviceCollection::release "IAudioDeviceCollection::release"
|
||||||
|
* method to release the returned object after using it.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - A pointer to the IAudioDeviceCollection object that includes all the
|
||||||
|
* audio playback devices in the system, if the method call succeeds.
|
||||||
|
* - The empty pointer NULL, if the method call fails.
|
||||||
|
*/
|
||||||
|
virtual IAudioDeviceCollection *enumeratePlaybackDevices() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enumerates the audio recording devices.
|
||||||
|
*
|
||||||
|
* This method returns an IAudioDeviceCollection object that includes all the
|
||||||
|
* audio recording devices in the system. With the IAudioDeviceCollection
|
||||||
|
* object, the app can enumerate the audio recording devices. The app needs to
|
||||||
|
* call the \ref IAudioDeviceCollection::release
|
||||||
|
* "IAudioDeviceCollection::release" method to release the returned object
|
||||||
|
* after using it.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - A pointer to the IAudioDeviceCollection object that includes all the
|
||||||
|
* audio recording devices in the system, if the method call succeeds.
|
||||||
|
* - The empty pointer NULL, if the method call fails.
|
||||||
|
*/
|
||||||
|
virtual IAudioDeviceCollection *enumerateRecordingDevices() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies an audio playback device with the device ID.
|
||||||
|
*
|
||||||
|
* @param deviceId ID of the audio playback device. It can be retrieved by the
|
||||||
|
* \ref enumeratePlaybackDevices "enumeratePlaybackDevices" method. Plugging
|
||||||
|
* or unplugging the audio device does not change the device ID.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setPlaybackDevice(const char deviceId[MAX_DEVICE_ID_LENGTH]) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the ID of the audio playback device.
|
||||||
|
* @param deviceId An output parameter that specifies the ID of the audio
|
||||||
|
* playback device.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int getPlaybackDevice(char deviceId[MAX_DEVICE_ID_LENGTH]) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the device ID and device name of the audio playback device.
|
||||||
|
* @param deviceId An output parameter that specifies the ID of the audio
|
||||||
|
* playback device.
|
||||||
|
* @param deviceName An output parameter that specifies the name of the audio
|
||||||
|
* playback device.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int getPlaybackDeviceInfo(char deviceId[MAX_DEVICE_ID_LENGTH],
|
||||||
|
char deviceName[MAX_DEVICE_ID_LENGTH]) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the volume of the audio playback device.
|
||||||
|
* @param volume The volume of the audio playing device. The value range is
|
||||||
|
* [0, 255].
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setPlaybackDeviceVolume(int volume) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the volume of the audio playback device.
|
||||||
|
* @param volume The volume of the audio playback device. The value range is
|
||||||
|
* [0, 255].
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int getPlaybackDeviceVolume(int *volume) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies an audio recording device with the device ID.
|
||||||
|
*
|
||||||
|
* @param deviceId ID of the audio recording device. It can be retrieved by
|
||||||
|
* the \ref enumerateRecordingDevices "enumerateRecordingDevices" method.
|
||||||
|
* Plugging or unplugging the audio device does not change the device ID.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setRecordingDevice(const char deviceId[MAX_DEVICE_ID_LENGTH]) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the audio recording device by the device ID.
|
||||||
|
*
|
||||||
|
* @param deviceId ID of the audio recording device.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int getRecordingDevice(char deviceId[MAX_DEVICE_ID_LENGTH]) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the information of the audio recording device by the device ID and
|
||||||
|
* device name.
|
||||||
|
*
|
||||||
|
* @param deviceId ID of the audio recording device.
|
||||||
|
* @param deviceName The name of the audio recording device.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int getRecordingDeviceInfo(char deviceId[MAX_DEVICE_ID_LENGTH],
|
||||||
|
char deviceName[MAX_DEVICE_ID_LENGTH]) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the volume of the recording device.
|
||||||
|
* @param volume The volume of the recording device. The value range is [0,
|
||||||
|
* 255].
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setRecordingDeviceVolume(int volume) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the volume of the recording device.
|
||||||
|
* @param volume The volume of the microphone, ranging from 0 to 255.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int getRecordingDeviceVolume(int *volume) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies an audio loopback recording device with the device ID.
|
||||||
|
*
|
||||||
|
* @param deviceId ID of the audio loopback recording device. It can be retrieved by
|
||||||
|
* the \ref enumeratePlaybackDevices "enumeratePlaybackDevices" method.
|
||||||
|
* Plugging or unplugging the audio device does not change the device ID.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setLoopbackDevice(const char deviceId[MAX_DEVICE_ID_LENGTH]) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the audio loopback recording device by the device ID.
|
||||||
|
*
|
||||||
|
* @param deviceId ID of the audio loopback recording device.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int getLoopbackDevice(char deviceId[MAX_DEVICE_ID_LENGTH]) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mutes or unmutes the audio playback device.
|
||||||
|
*
|
||||||
|
* @param mute Determines whether to mute the audio playback device.
|
||||||
|
* - true: Mute the device.
|
||||||
|
* - false: Unmute the device.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setPlaybackDeviceMute(bool mute) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the mute state of the playback device.
|
||||||
|
*
|
||||||
|
* @param mute A pointer to the mute state of the playback device.
|
||||||
|
* - true: The playback device is muted.
|
||||||
|
* - false: The playback device is unmuted.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int getPlaybackDeviceMute(bool *mute) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mutes or unmutes the audio recording device.
|
||||||
|
*
|
||||||
|
* @param mute Determines whether to mute the recording device.
|
||||||
|
* - true: Mute the microphone.
|
||||||
|
* - false: Unmute the microphone.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setRecordingDeviceMute(bool mute) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the mute state of the audio recording device.
|
||||||
|
*
|
||||||
|
* @param mute A pointer to the mute state of the recording device.
|
||||||
|
* - true: The microphone is muted.
|
||||||
|
* - false: The microphone is unmuted.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int getRecordingDeviceMute(bool *mute) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts the audio playback device test.
|
||||||
|
*
|
||||||
|
* This method tests if the playback device works properly. In the test, the
|
||||||
|
* SDK plays an audio file specified by the user. If the user hears the audio,
|
||||||
|
* the playback device works properly.
|
||||||
|
*
|
||||||
|
* @param testAudioFilePath The file path of the audio file for the test,
|
||||||
|
* which is an absolute path in UTF8:
|
||||||
|
* - Supported file format: wav, mp3, m4a, and aac.
|
||||||
|
* - Supported file sampling rate: 8000, 16000, 32000, 44100, and 48000.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0, if the method call succeeds and you can hear the sound of the
|
||||||
|
* specified audio file.
|
||||||
|
* - An error code, if the method call fails.
|
||||||
|
*/
|
||||||
|
virtual int startPlaybackDeviceTest(const char *testAudioFilePath) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stops the audio playback device test.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int stopPlaybackDeviceTest() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts the recording device test.
|
||||||
|
*
|
||||||
|
* This method tests whether the recording device works properly. Once the
|
||||||
|
* test starts, the SDK uses the \ref
|
||||||
|
* IRtcEngineEventHandler::onAudioVolumeIndication "onAudioVolumeIndication"
|
||||||
|
* callback to notify the app on the volume information.
|
||||||
|
*
|
||||||
|
* @param indicationInterval The time interval (ms) between which the SDK
|
||||||
|
* triggers the `onAudioVolumeIndication` callback.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int startRecordingDeviceTest(int indicationInterval) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stops the recording device test.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int stopRecordingDeviceTest() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts the audio device loopback test.
|
||||||
|
*
|
||||||
|
* This method tests whether the local audio devices are working properly.
|
||||||
|
* After calling this method, the microphone captures the local audio and
|
||||||
|
* plays it through the speaker, and the \ref
|
||||||
|
* IRtcEngineEventHandler::onAudioVolumeIndication "onAudioVolumeIndication"
|
||||||
|
* callback returns the local audio volume information at the set interval.
|
||||||
|
*
|
||||||
|
* @note This method tests the local audio devices and does not report the
|
||||||
|
* network conditions.
|
||||||
|
* @param indicationInterval The time interval (ms) at which the \ref
|
||||||
|
* IRtcEngineEventHandler::onAudioVolumeIndication "onAudioVolumeIndication"
|
||||||
|
* callback returns.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int startAudioDeviceLoopbackTest(int indicationInterval) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stops the audio device loopback test.
|
||||||
|
*
|
||||||
|
* @note Ensure that you call this method to stop the loopback test after
|
||||||
|
* calling the \ref IAudioDeviceManager::startAudioDeviceLoopbackTest
|
||||||
|
* "startAudioDeviceLoopbackTest" method.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int stopAudioDeviceLoopbackTest() = 0;
|
||||||
|
|
||||||
|
/** The status of following system default playback device.
|
||||||
|
|
||||||
|
@note The status of following system default playback device.
|
||||||
|
|
||||||
|
@param enable Variable to whether the current device follow system default playback device or not.
|
||||||
|
- true: The current device will change when the system default playback device changed.
|
||||||
|
- false: The current device will change only current device is removed.
|
||||||
|
@return
|
||||||
|
- 0: Success.
|
||||||
|
- < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int followSystemPlaybackDevice(bool enable) = 0;
|
||||||
|
|
||||||
|
/** The status of following system default recording device.
|
||||||
|
|
||||||
|
@note The status of following system default recording device.
|
||||||
|
|
||||||
|
@param enable Variable to whether the current device follow system default recording device or not.
|
||||||
|
- true: The current device will change when the system default recording device changed.
|
||||||
|
- false: The current device will change only current device is removed.
|
||||||
|
@return
|
||||||
|
- 0: Success.
|
||||||
|
- < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int followSystemRecordingDevice(bool enable) = 0;
|
||||||
|
|
||||||
|
/** The status of following system default loopback device.
|
||||||
|
|
||||||
|
@note The status of following system default loopback device.
|
||||||
|
|
||||||
|
@param enable Variable to whether the current device follow system default loopback device or not.
|
||||||
|
- true: The current device will change when the system default loopback device changed.
|
||||||
|
- false: The current device will change only current device is removed.
|
||||||
|
@return
|
||||||
|
- 0: Success.
|
||||||
|
- < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int followSystemLoopbackDevice(bool enable) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Releases all IAudioDeviceManager resources.
|
||||||
|
*/
|
||||||
|
virtual void release() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace rtc
|
||||||
|
} // namespace agora
|
|
@ -0,0 +1,550 @@
|
||||||
|
//
|
||||||
|
// Agora SDK
|
||||||
|
//
|
||||||
|
// Copyright (c) 2018 Agora.io. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once // NOLINT(build/header_guard)
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
#include "AgoraBase.h"
|
||||||
|
#include "AgoraRefPtr.h"
|
||||||
|
|
||||||
|
namespace agora {
|
||||||
|
namespace media {
|
||||||
|
namespace base {
|
||||||
|
class IAudioFrameObserver;
|
||||||
|
} // namespace base
|
||||||
|
} // namespace media
|
||||||
|
|
||||||
|
namespace rtc {
|
||||||
|
|
||||||
|
static const int kAdmMaxDeviceNameSize = 128;
|
||||||
|
static const int kAdmMaxGuidSize = 128;
|
||||||
|
static const int kIntervalInMillseconds = 200;
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(_WIN32) || (defined(__APPLE__) && TARGET_OS_MAC && !TARGET_OS_IPHONE)
|
||||||
|
/**
|
||||||
|
* The struct of AudioDeviceInfo.
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* This struct applies to Windows and macOS only.
|
||||||
|
*/
|
||||||
|
struct AudioDeviceInfo {
|
||||||
|
/**
|
||||||
|
* The name of the device. The maximum name size is 128 bytes. The default value is 0.
|
||||||
|
*/
|
||||||
|
char deviceName[kAdmMaxDeviceNameSize];
|
||||||
|
/**
|
||||||
|
* The ID of the device. The maximum size is 128 bytes. The default value is 0.
|
||||||
|
*/
|
||||||
|
char deviceId[kAdmMaxGuidSize];
|
||||||
|
/**
|
||||||
|
* Determines whether the current device is selected for audio capturing or playback.
|
||||||
|
* - true: Select the current device for audio capturing or playback.
|
||||||
|
* - false: (Default) Do not select the current device for audio capturing or playback.
|
||||||
|
*/
|
||||||
|
bool isCurrentSelected;
|
||||||
|
/**
|
||||||
|
* Determines whether the current device is the audio playout device.
|
||||||
|
* - true: (Default) The current device is the playout device.
|
||||||
|
* - false: The current device is not the playout device.
|
||||||
|
*/
|
||||||
|
bool isPlayoutDevice;
|
||||||
|
|
||||||
|
AudioDeviceInfo() : isCurrentSelected(false),
|
||||||
|
isPlayoutDevice(true) {
|
||||||
|
memset(deviceName, 0, sizeof(deviceName));
|
||||||
|
memset(deviceId, 0, sizeof(deviceId));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
#endif // _WIN32 || (TARGET_OS_MAC && !TARGET_OS_IPHONE)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The struct of LoopbackRecordingOption
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
*/
|
||||||
|
struct LoopbackRecordingOption {
|
||||||
|
/**
|
||||||
|
* the name of the device. the maximum name size is 128 bytes. the default value is 0.
|
||||||
|
*/
|
||||||
|
Optional<const char *> deviceName;
|
||||||
|
/**
|
||||||
|
* allow output device change when enable loopback recording.
|
||||||
|
*/
|
||||||
|
Optional<bool> allowDeviceChange;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The IAudioDeviceManagerObserver class.
|
||||||
|
*/
|
||||||
|
class IAudioDeviceManagerObserver
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~IAudioDeviceManagerObserver() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Occurs when the device state changes, for example, when a device is added or removed.
|
||||||
|
*
|
||||||
|
* To get the current information of the connected audio devices, call \ref agora::rtc::INGAudioDeviceManager::getNumberOfPlayoutDevices "getNumberOfPlayoutDevices".
|
||||||
|
*/
|
||||||
|
virtual void onDeviceStateChanged() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Occurs when the device state changes, for example, when a device is added or removed or default device change.
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* This method applies to Windows only now.
|
||||||
|
*
|
||||||
|
* @param deviceId Pointer to the device ID.
|
||||||
|
* @param deviceType Device type: #MEDIA_DEVICE_TYPE.
|
||||||
|
* @param deviceState Device state: #MEDIA_DEVICE_STATE_TYPE..
|
||||||
|
*/
|
||||||
|
virtual void onAudioDeviceStateChanged(const char *deviceId, int deviceType, int deviceState) = 0;
|
||||||
|
|
||||||
|
/** Indicates incoming volume. This can be used to test microphone or speaker.
|
||||||
|
*
|
||||||
|
* @param deviceType Device type: #MEDIA_DEVICE_TYPE.
|
||||||
|
* @param volume volume between 0 (lowest volume) to 255 (highest volume).
|
||||||
|
*/
|
||||||
|
virtual void onVolumeIndication(int deviceType, int volume) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Occurs when the audio route changes.
|
||||||
|
*
|
||||||
|
* @param route The current audio route. See #AudioRoute.
|
||||||
|
*/
|
||||||
|
virtual void onRoutingChanged(AudioRoute route) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Occurs when the audio device volume changes.
|
||||||
|
*
|
||||||
|
* @param deviceType The device type, see #MEDIA_DEVICE_TYPE.
|
||||||
|
* @param volume The volume of the audio device.
|
||||||
|
* @param muted Whether the audio device is muted:
|
||||||
|
* - true: The audio device is muted.
|
||||||
|
* - false: The audio device is not muted.
|
||||||
|
*/
|
||||||
|
virtual void onAudioDeviceVolumeChanged(int deviceType, int volume, bool muted) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class IRecordingDeviceSource : public RefCountInterface {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Initialize the recording device source.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int initRecording(const char* deviceName = NULL) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start the recording device.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int startRecording() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stop the recording device.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int stopRecording() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers an audio frame observer.
|
||||||
|
*
|
||||||
|
* @param observer The pointer to the IAudioFrameObserver object.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int registerAudioFrameObserver(media::base::IAudioFrameObserver* observer) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Releases the registered IAudioFrameObserver object.
|
||||||
|
*
|
||||||
|
* @param observer The pointer to the IAudioFrameObserver object created by the `registerAudioPcmDataCallback` method.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int unregisterAudioFrameObserver(media::base::IAudioFrameObserver* observer) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set parameter to object loopback device;
|
||||||
|
* @param option
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setLoopbackDeviceParameter(const LoopbackRecordingOption &option) = 0;
|
||||||
|
|
||||||
|
virtual ~IRecordingDeviceSource() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The INGAudioDeciceManager class.
|
||||||
|
*
|
||||||
|
* This class provides access to audio volume and audio route control, as well as device enumeration and
|
||||||
|
* selection on the PC.
|
||||||
|
*/
|
||||||
|
class INGAudioDeviceManager : public RefCountInterface {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Creates a audio device source object and returns the pointer.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - The pointer to \ref rtc::IRecordingDeviceSource "IRecordingDeviceSource", if the method call
|
||||||
|
* succeeds.
|
||||||
|
* - An empty pointer NULL: Failure.
|
||||||
|
*/
|
||||||
|
virtual agora_refptr<IRecordingDeviceSource> createRecordingDeviceSource(char deviceId[kAdmMaxDeviceNameSize]) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the volume of the microphone.
|
||||||
|
* @param volume The volume of the microphone. The value range is [0, 255].
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setMicrophoneVolume(unsigned int volume) = 0;
|
||||||
|
/**
|
||||||
|
* Gets the volume of the microphone.
|
||||||
|
* @param volume The volume of the microphone.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int getMicrophoneVolume(unsigned int& volume) = 0;
|
||||||
|
/**
|
||||||
|
* Sets the volume of the speaker.
|
||||||
|
* @param volume The volume of the speaker. The value range is [2, 255].
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setSpeakerVolume(unsigned int volume) = 0;
|
||||||
|
/**
|
||||||
|
* Gets the volume of the speaker.
|
||||||
|
* @param volume The volume of the speaker.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int getSpeakerVolume(unsigned int& volume) = 0;
|
||||||
|
/**
|
||||||
|
* Captures or stops capturing the local audio with the microphone.
|
||||||
|
* @param mute Determines whether to capture or stop capturing the local audio with the microphone.
|
||||||
|
* - true: Stop capturing the local audio.
|
||||||
|
* - false: (Default) Capture the local audio.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setMicrophoneMute(bool mute) = 0;
|
||||||
|
/**
|
||||||
|
* Gets the mute state of the microphone.
|
||||||
|
* @param mute The mute state of the microphone.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int getMicrophoneMute(bool& mute) = 0;
|
||||||
|
/**
|
||||||
|
* Plays or stops playing the remote audio with the speaker.
|
||||||
|
* @param mute Determines whether to play or stop playing the remote audio.
|
||||||
|
* - true: Stop playing the remote audio.
|
||||||
|
* - false: (Default) Play the remote audio.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setSpeakerMute(bool mute) = 0;
|
||||||
|
/**
|
||||||
|
* Gets the mute state of the speaker.
|
||||||
|
* @param mute A reference to the mute state of the speaker.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int getSpeakerMute(bool& mute) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the playout parameters of audio device.
|
||||||
|
* @param params A point to the struct AudioParameters.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int getPlayoutAudioParameters(AudioParameters* params) const = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the record parameters of audio device.
|
||||||
|
* @param params A point to the struct AudioParameters.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int getRecordAudioParameters(AudioParameters* params) const = 0;
|
||||||
|
|
||||||
|
#if defined(__ANDROID__) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE)
|
||||||
|
/**
|
||||||
|
* Sets the default audio routing.
|
||||||
|
*
|
||||||
|
* This method allows apps to change the current audio route for the received audio.
|
||||||
|
* Noted: In Low Level API, we don't support default audio routing, i.e.,
|
||||||
|
* setDefaultAudioRouteToSpeakerphone. This can be done in RTC engine.
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* This method applies to Android and iOS only.
|
||||||
|
*
|
||||||
|
* @param route The default audio route. See #AudioRoute.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setDefaultAudioRouting(AudioRoute route) = 0;
|
||||||
|
/**
|
||||||
|
* Changes the current audio routing.
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* This method applies to Android and iOS only.
|
||||||
|
*
|
||||||
|
* @param route The audio route that you want to change to. See #AudioRoute.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int changeAudioRouting(AudioRoute route) = 0;
|
||||||
|
/**
|
||||||
|
* Gets the current audio routing.
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* This method applies to Android and iOS only.
|
||||||
|
*
|
||||||
|
* @param route A reference to the audio route: AudioRoute.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int getCurrentRouting(AudioRoute& route) = 0;
|
||||||
|
#endif // __ANDROID__ || TARGET_OS_IPHONE
|
||||||
|
|
||||||
|
#if defined(_WIN32) || (defined(__APPLE__) && TARGET_OS_MAC && !TARGET_OS_IPHONE)
|
||||||
|
/**
|
||||||
|
* Gets the index numbers of all audio playout devices.
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* This method applies to Windows or macOS only.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - The index numbers of the audio playout devices: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int getNumberOfPlayoutDevices() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the index numbers of all audio recording devices.
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* This method applies to Windows or macOS only.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - The index numbers of the audio recording devices: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int getNumberOfRecordingDevices() = 0;
|
||||||
|
/**
|
||||||
|
* Gets the information of the current audio playout device.
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* This method applies to Windows or macOS only.
|
||||||
|
*
|
||||||
|
* @param index The index number of the current audio playout device.
|
||||||
|
* @return
|
||||||
|
* The information of the audio playout device. See \ref agora::rtc::AudioDeviceInfo "AudioDeviceInfo".
|
||||||
|
*/
|
||||||
|
virtual AudioDeviceInfo getPlayoutDeviceInfo(int index) = 0;
|
||||||
|
/**
|
||||||
|
* Gets the information of the current recording device.
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* This method applies to Windows or macOS only.
|
||||||
|
*
|
||||||
|
* @param index The index number of the current recording device.
|
||||||
|
* @return
|
||||||
|
* The information of the recording device. See \ref agora::rtc::AudioDeviceInfo "AudioDeviceInfo".
|
||||||
|
*/
|
||||||
|
virtual AudioDeviceInfo getRecordingDeviceInfo(int index) = 0;
|
||||||
|
/**
|
||||||
|
* Sets the audio playback device.
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* This method applies to Windows or macOS only.
|
||||||
|
*
|
||||||
|
* @param index The index number of the audio playout device.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setPlayoutDevice(int index) = 0;
|
||||||
|
/**
|
||||||
|
* Sets the recording device.
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* This method applies to Windows or macOS only.
|
||||||
|
*
|
||||||
|
* @param index The index number of the recording device.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setRecordingDevice(int index) = 0;
|
||||||
|
/** The status of following system default playback device.
|
||||||
|
|
||||||
|
@note The status of following system default playback device.
|
||||||
|
|
||||||
|
@param enable Variable to whether the current device follow system default playback device or not.
|
||||||
|
- true: The current device will change when the system default playback device changed.
|
||||||
|
- false: The current device will change only current device is removed.
|
||||||
|
@return
|
||||||
|
- 0: Success.
|
||||||
|
- < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int followSystemPlaybackDevice(bool enable) = 0;
|
||||||
|
|
||||||
|
/** The status of following system default recording device.
|
||||||
|
|
||||||
|
@note The status of following system default recording device.
|
||||||
|
|
||||||
|
@param enable Variable to whether the current device follow system default recording device or not.
|
||||||
|
- true: The current device will change when the system default recording device changed.
|
||||||
|
- false: The current device will change only current device is removed.
|
||||||
|
@return
|
||||||
|
- 0: Success.
|
||||||
|
- < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int followSystemRecordingDevice(bool enable) = 0;
|
||||||
|
#endif // _WIN32 || (TARGET_OS_MAC && !TARGET_OS_IPHONE)
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
/**
|
||||||
|
* Sets the volume of the app.
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* This method applies to Windows only.
|
||||||
|
*
|
||||||
|
* @param volume The volume of the app. The value range is [0, 255].
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setApplicationVolume(unsigned int volume) = 0;
|
||||||
|
/**
|
||||||
|
* Gets the volume of the app.
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* This method applies to Windows only.
|
||||||
|
*
|
||||||
|
* @param volume The volume of the app. The value range is [0, 255].
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int getApplicationVolume(unsigned int& volume) = 0;
|
||||||
|
/**
|
||||||
|
* Sets the mute state of the app.
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* This method applies to Windows only.
|
||||||
|
*
|
||||||
|
* @param mute Determines whether to set the app to the mute state.
|
||||||
|
* - true: Set the app to the mute state.
|
||||||
|
* - false: (Default) Do not set the app to the mute state.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setApplicationMuteState(bool mute) = 0;
|
||||||
|
/**
|
||||||
|
* Gets the mute state of the app.
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* This method applies to Windows only.
|
||||||
|
*
|
||||||
|
* @param mute A reference to the mute state of the app.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int getApplicationMuteState(bool& mute) = 0;
|
||||||
|
/**
|
||||||
|
* Gets the information of the current audio loopback device.
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* This method applies to Windows or macOS only.
|
||||||
|
*
|
||||||
|
* @param index The index number of the current audio playout device.
|
||||||
|
* @return
|
||||||
|
* The information of the audio playout device. See \ref agora::rtc::AudioDeviceInfo "AudioDeviceInfo".
|
||||||
|
*/
|
||||||
|
virtual AudioDeviceInfo getLoopbackDeviceInfo(int index) = 0;
|
||||||
|
/**
|
||||||
|
* Sets the audio loopback device.
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* This method applies to Windows only.
|
||||||
|
*
|
||||||
|
* @param index The index number of the audio playout device.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setLoopbackDevice(int index) = 0;
|
||||||
|
/** The status of following system default loopback device.
|
||||||
|
|
||||||
|
@note The status of following system default loopback device.
|
||||||
|
|
||||||
|
@param enable Variable to whether the current device follow system default loopback device or not.
|
||||||
|
- true: The current device will change when the system default loopback device changed.
|
||||||
|
- false: The current device will change only current device is removed.
|
||||||
|
@return
|
||||||
|
- 0: Success.
|
||||||
|
- < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int followSystemLoopbackDevice(bool enable) = 0;
|
||||||
|
#endif // _WIN32
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers an IAudioDeviceManagerObserver object.
|
||||||
|
*
|
||||||
|
* You need to implement the IAudioDeviceManageObserver class in this method, and register callbacks
|
||||||
|
* according to your scenario.
|
||||||
|
*
|
||||||
|
* @param observer A pointer to the IAudioDeviceManagerObserver class.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int registerObserver(IAudioDeviceManagerObserver* observer, void(*safeDeleter)(IAudioDeviceManagerObserver*) = NULL) = 0;
|
||||||
|
/**
|
||||||
|
* Releases the IAudioDeviceManagerObserver object.
|
||||||
|
* @param observer The pointer to the IAudioDeviceManagerObserver class registered using #registerObserver.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int unregisterObserver(IAudioDeviceManagerObserver* observer) = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
~INGAudioDeviceManager() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
} //namespace rtc
|
||||||
|
} // namespace agora
|
|
@ -0,0 +1,724 @@
|
||||||
|
|
||||||
|
// Copyright (c) 2018 Agora.io. All rights reserved
|
||||||
|
|
||||||
|
// This program is confidential and proprietary to Agora.io.
|
||||||
|
// And may not be copied, reproduced, modified, disclosed to others, published
|
||||||
|
// or used, in whole or in part, without the express prior written permission
|
||||||
|
// of Agora.io.
|
||||||
|
|
||||||
|
#pragma once // NOLINT(build/header_guard)
|
||||||
|
|
||||||
|
#include "AgoraBase.h"
|
||||||
|
|
||||||
|
// FIXME(Ender): use this class instead of AudioSendStream as local track
|
||||||
|
namespace agora {
|
||||||
|
namespace rtc {
|
||||||
|
class IAudioTrackStateObserver;
|
||||||
|
class IAudioFilter;
|
||||||
|
class IAudioSinkBase;
|
||||||
|
class IMediaPacketReceiver;
|
||||||
|
class IAudioEncodedFrameReceiver;
|
||||||
|
/**
|
||||||
|
* Properties of audio frames expected by a sink.
|
||||||
|
*
|
||||||
|
* @note The source determines the audio frame to be sent to the sink based on a variety of factors,
|
||||||
|
* such as other sinks or the capability of the source.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
struct AudioSinkWants {
|
||||||
|
/** The sample rate of the audio frame to be sent to the sink. */
|
||||||
|
int samplesPerSec;
|
||||||
|
|
||||||
|
/** The number of audio channels of the audio frame to be sent to the sink. */
|
||||||
|
size_t channels;
|
||||||
|
|
||||||
|
/** The audio track number of the audio frame to be sent to the sink. */
|
||||||
|
int audioTrackNumber;
|
||||||
|
|
||||||
|
AudioSinkWants() : samplesPerSec(0),
|
||||||
|
channels(0),
|
||||||
|
audioTrackNumber(-1) {}
|
||||||
|
AudioSinkWants(int sampleRate, size_t chs) : samplesPerSec(sampleRate),
|
||||||
|
channels(chs) {audioTrackNumber = -1;}
|
||||||
|
AudioSinkWants(int sampleRate, size_t chs, int trackNum) : samplesPerSec(sampleRate), channels(chs), audioTrackNumber(trackNum) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The IAudioTrack class.
|
||||||
|
*/
|
||||||
|
class IAudioTrack : public RefCountInterface {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* The position of the audio filter in audio frame.
|
||||||
|
*/
|
||||||
|
enum AudioFilterPosition {
|
||||||
|
/**
|
||||||
|
* Work on the local playback
|
||||||
|
*/
|
||||||
|
RecordingLocalPlayback,
|
||||||
|
/**
|
||||||
|
* Work on the post audio processing.
|
||||||
|
*/
|
||||||
|
PostAudioProcessing,
|
||||||
|
/**
|
||||||
|
* Work on the remote audio before mixing.
|
||||||
|
*/
|
||||||
|
RemoteUserPlayback,
|
||||||
|
/**
|
||||||
|
* Work on the pcm source.
|
||||||
|
*/
|
||||||
|
PcmSource,
|
||||||
|
/**
|
||||||
|
* Work on the sending branch of the pcm source.
|
||||||
|
*/
|
||||||
|
PcmSourceSending,
|
||||||
|
/**
|
||||||
|
* Work on the local playback branch of the pcm source.
|
||||||
|
*/
|
||||||
|
PcmSourceLocalPlayback,
|
||||||
|
/**
|
||||||
|
* Work on the playback after remote-audio mix.
|
||||||
|
*/
|
||||||
|
RemoteMixedPlayback,
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Adjusts the playback volume.
|
||||||
|
* @param volume The playback volume. The value ranges between 0 and 100 (default).
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int adjustPlayoutVolume(int volume) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the current playback volume.
|
||||||
|
* @param volume A pointer to the playback volume.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int getPlayoutVolume(int* volume) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds an audio filter.
|
||||||
|
*
|
||||||
|
* By adding an audio filter, you can apply various audio effects to the audio, for example, voice change.
|
||||||
|
* @param filter A pointer to the audio filter. See \ref agora::rtc::IAudioFilter "IAudioFilter".
|
||||||
|
* @param position The position of the audio filter. See \ref agora::rtc::IAudioTrack::AudioFilterPosition "AudioFilterPosition".
|
||||||
|
* @return
|
||||||
|
* - `true`: Success.
|
||||||
|
* - `false`: Failure.
|
||||||
|
*/
|
||||||
|
virtual bool addAudioFilter(agora_refptr<IAudioFilter> filter, AudioFilterPosition position, ExtensionContext* extContext = NULL) = 0;
|
||||||
|
/**
|
||||||
|
* Removes the audio filter added by callling `addAudioFilter`.
|
||||||
|
*
|
||||||
|
* @param filter The pointer to the audio filter that you want to remove. See \ref agora::rtc::IAudioFilter "IAudioFilter".
|
||||||
|
* @param position The position of the audio filter. See #AudioFilterPosition.
|
||||||
|
* @return
|
||||||
|
* - `true`: Success.
|
||||||
|
* - `false`: Failure.
|
||||||
|
*/
|
||||||
|
virtual bool removeAudioFilter(agora_refptr<IAudioFilter> filter, AudioFilterPosition position) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable / Disable specified audio filter
|
||||||
|
* @param id id of the filter
|
||||||
|
* @param enable enable / disable the filter with given id
|
||||||
|
* @param position The position of the audio filter. See #AudioFilterPosition.
|
||||||
|
* @return
|
||||||
|
* - 0: success
|
||||||
|
* - <0: failure
|
||||||
|
*/
|
||||||
|
virtual int enableAudioFilter(const char* id, bool enable, AudioFilterPosition position) {
|
||||||
|
(void)id;
|
||||||
|
(void)enable;
|
||||||
|
(void)position;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set the properties of the specified audio filter
|
||||||
|
* @param id id of the filter
|
||||||
|
* @param key key of the property
|
||||||
|
* @param jsonValue json str value of the property
|
||||||
|
* @param position The position of the audio filter. See #AudioFilterPosition.
|
||||||
|
* @return
|
||||||
|
* - 0: success
|
||||||
|
* - <0: failure
|
||||||
|
*/
|
||||||
|
virtual int setFilterProperty(const char* id, const char* key, const char* jsonValue, AudioFilterPosition position) {
|
||||||
|
(void)id;
|
||||||
|
(void)key;
|
||||||
|
(void)jsonValue;
|
||||||
|
(void)position;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get the properties of the specified video filter
|
||||||
|
* @param id id of the filter
|
||||||
|
* @param key key of the property
|
||||||
|
* @param jsonValue json str value of the property
|
||||||
|
* @param bufSize max length of the json value buffer
|
||||||
|
* @param position The position of the audio filter. See #AudioFilterPosition.
|
||||||
|
* @return
|
||||||
|
* - 0: success
|
||||||
|
* - <0: failure
|
||||||
|
*/
|
||||||
|
virtual int getFilterProperty(const char* id, const char* key, char* jsonValue, size_t bufSize, AudioFilterPosition position) {
|
||||||
|
(void)id;
|
||||||
|
(void)key;
|
||||||
|
(void)jsonValue;
|
||||||
|
(void)bufSize;
|
||||||
|
(void)position;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the audio filter by its name.
|
||||||
|
*
|
||||||
|
* @param name The name of the audio filter.
|
||||||
|
* @param position The position of the audio filter. See #AudioFilterPosition.
|
||||||
|
* @return
|
||||||
|
* - The pointer to the audio filter: Success.
|
||||||
|
* - A null pointer: Failure.
|
||||||
|
*/
|
||||||
|
virtual agora_refptr<IAudioFilter> getAudioFilter(const char *name, AudioFilterPosition position) const = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds an audio sink to get PCM data from the audio track.
|
||||||
|
*
|
||||||
|
* @param sink The pointer to the audio sink. See \ref agora::rtc::IAudioSinkBase "IAudioSinkBase".
|
||||||
|
* @param wants The properties an audio frame should have when it is delivered to the sink. See \ref agora::rtc::AudioSinkWants "AudioSinkWants".
|
||||||
|
* @return
|
||||||
|
* - `true`: Success.
|
||||||
|
* - `false`: Failure.
|
||||||
|
*/
|
||||||
|
virtual bool addAudioSink(agora_refptr<IAudioSinkBase> sink, const AudioSinkWants& wants) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes an audio sink.
|
||||||
|
*
|
||||||
|
* @param sink The pointer to the audio sink to be removed. See \ref agora::rtc::IAudioSinkBase "IAudioSinkBase".
|
||||||
|
* @return
|
||||||
|
* - `true`: Success.
|
||||||
|
* - `false`: Failure.
|
||||||
|
*/
|
||||||
|
virtual bool removeAudioSink(agora_refptr<IAudioSinkBase> sink) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The observer of the local audio track.
|
||||||
|
*/
|
||||||
|
class ILocalAudioTrackObserver {
|
||||||
|
public:
|
||||||
|
virtual ~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".
|
||||||
|
*/
|
||||||
|
virtual void onLocalAudioTrackStateChanged(LOCAL_AUDIO_STREAM_STATE state,
|
||||||
|
LOCAL_AUDIO_STREAM_ERROR errorCode) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* `ILocalAudioTrack` is the basic class for local audio tracks, providing main methods of local audio tracks.
|
||||||
|
*
|
||||||
|
* You can create a local audio track by calling one of the following methods:
|
||||||
|
* - `createLocalAudioTrack`
|
||||||
|
* - `createCustomAudioTrack`
|
||||||
|
* - `createMediaPlayerAudioTrack`
|
||||||
|
* @if (!Linux)
|
||||||
|
* You can also use the APIs in the \ref agora::rtc::INGAudioDeviceManager "IAudioDeviceManager" class if multiple recording devices are available in the system.
|
||||||
|
* @endif
|
||||||
|
*
|
||||||
|
* After creating local audio tracks, you can publish one or more local audio
|
||||||
|
* tracks by calling \ref agora::rtc::ILocalUser::publishAudio "publishAudio".
|
||||||
|
*/
|
||||||
|
class ILocalAudioTrack : public IAudioTrack {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Statistics of a local audio track.
|
||||||
|
*/
|
||||||
|
struct LocalAudioTrackStats {
|
||||||
|
/**
|
||||||
|
* The source ID of the local audio track.
|
||||||
|
*/
|
||||||
|
uint32_t source_id;
|
||||||
|
/**
|
||||||
|
* The number of audio frames in the buffer.
|
||||||
|
*
|
||||||
|
* When sending PCM data, the PCM data is first stored in a buffer area.
|
||||||
|
* Then a thread gets audio frames from the buffer and sends PCM data.
|
||||||
|
*/
|
||||||
|
uint32_t buffered_pcm_data_list_size;
|
||||||
|
/**
|
||||||
|
* The number of audio frames missed by the thread that gets PCM data from the buffer.
|
||||||
|
*/
|
||||||
|
uint32_t missed_audio_frames;
|
||||||
|
/**
|
||||||
|
* The number of audio frames sent by the thread that gets PCM data from the buffer.
|
||||||
|
*/
|
||||||
|
uint32_t sent_audio_frames;
|
||||||
|
/**
|
||||||
|
* The number of audio frames sent by the user.
|
||||||
|
*/
|
||||||
|
uint32_t pushed_audio_frames;
|
||||||
|
/**
|
||||||
|
* The number of dropped audio frames caused by insufficient buffer size.
|
||||||
|
*/
|
||||||
|
uint32_t dropped_audio_frames;
|
||||||
|
/**
|
||||||
|
* The number of playout audio frames.
|
||||||
|
*/
|
||||||
|
uint32_t playout_audio_frames;
|
||||||
|
/**
|
||||||
|
* The type of audio effect.
|
||||||
|
*/
|
||||||
|
uint32_t effect_type;
|
||||||
|
/**
|
||||||
|
* Whether the hardware ear monitor is enabled.
|
||||||
|
*/
|
||||||
|
uint32_t hw_ear_monitor;
|
||||||
|
/**
|
||||||
|
* Whether the local audio track is enabled.
|
||||||
|
*/
|
||||||
|
bool enabled;
|
||||||
|
/**
|
||||||
|
* The volume that ranges from 0 to 255.
|
||||||
|
*/
|
||||||
|
uint32_t audio_volume; // [0,255]
|
||||||
|
|
||||||
|
LocalAudioTrackStats() : source_id(0),
|
||||||
|
buffered_pcm_data_list_size(0),
|
||||||
|
missed_audio_frames(0),
|
||||||
|
sent_audio_frames(0),
|
||||||
|
pushed_audio_frames(0),
|
||||||
|
dropped_audio_frames(0),
|
||||||
|
playout_audio_frames(0),
|
||||||
|
effect_type(0),
|
||||||
|
hw_ear_monitor(0),
|
||||||
|
enabled(false),
|
||||||
|
audio_volume(0) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Enables or disables the local audio track.
|
||||||
|
*
|
||||||
|
* Once the local audio is enabled, the SDK allows for local audio capturing, processing, and encoding.
|
||||||
|
*
|
||||||
|
* @param enable Whether to enable the audio track:
|
||||||
|
* - `true`: Enable the local audio track.
|
||||||
|
* - `false`: Disable the local audio track.
|
||||||
|
*/
|
||||||
|
virtual void setEnabled(bool enable) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets whether the local audio track is enabled.
|
||||||
|
* @return Whether the local audio track is enabled:
|
||||||
|
* - `true`: The local track is enabled.
|
||||||
|
* - `false`: The local track is disabled.
|
||||||
|
*/
|
||||||
|
virtual bool isEnabled() const = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the state of the local audio.
|
||||||
|
* @return The state of the local audio: #LOCAL_AUDIO_STREAM_STATE: Success.
|
||||||
|
*/
|
||||||
|
virtual LOCAL_AUDIO_STREAM_STATE getState() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the statistics of the local audio track: LocalAudioTrackStats.
|
||||||
|
* @return The statistics of the local audio: LocalAudioTrackStats: Success.
|
||||||
|
*/
|
||||||
|
virtual LocalAudioTrackStats GetStats() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adjusts the audio volume for publishing.
|
||||||
|
*
|
||||||
|
* @param volume The volume for publishing. The value ranges between 0 and 100 (default).
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int adjustPublishVolume(int volume) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the current volume for publishing.
|
||||||
|
* @param volume A pointer to the publishing volume.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int getPublishVolume(int* volume) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables or disables local playback.
|
||||||
|
* @param enable Whether to enable local playback:
|
||||||
|
* - `true`: Enable local playback.
|
||||||
|
* - `false`: Disable local playback.
|
||||||
|
* @param sync Whether to destroy local playback synchronously:
|
||||||
|
* - `true`: Destroy local playback synchronously.
|
||||||
|
* - `false`: Destroy local playback asynchronously.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int enableLocalPlayback(bool enable, bool sync = true) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables in-ear monitoring (for Android and iOS only).
|
||||||
|
*
|
||||||
|
* @param enabled Determines whether to enable in-ear monitoring.
|
||||||
|
* - true: Enable.
|
||||||
|
* - false: (Default) Disable.
|
||||||
|
* @param includeAudioFilters The type of the ear monitoring: #EAR_MONITORING_FILTER_TYPE
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int enableEarMonitor(bool enable, int includeAudioFilters) = 0;
|
||||||
|
/** Register an local audio track observer
|
||||||
|
*
|
||||||
|
* @param observer A pointer to the local audio track observer: \ref agora::rtc::ILocalAudioTrackObserver
|
||||||
|
* "ILocalAudioTrackObserver".
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int registerTrackObserver(ILocalAudioTrackObserver* observer) = 0;
|
||||||
|
/** Releases the local audio track observer
|
||||||
|
*
|
||||||
|
* @param observer A pointer to the local audio track observer: \ref agora::rtc::ILocalAudioTrackObserver
|
||||||
|
* "ILocalAudioTrackObserver".
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int unregisterTrackObserver(ILocalAudioTrackObserver* observer) = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
~ILocalAudioTrack() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The statistics of a remote audio track.
|
||||||
|
*/
|
||||||
|
struct RemoteAudioTrackStats {
|
||||||
|
/**
|
||||||
|
* The user ID of the remote user who sends the audio track.
|
||||||
|
*/
|
||||||
|
uid_t uid;
|
||||||
|
/**
|
||||||
|
* The audio quality of the remote audio track: #QUALITY_TYPE.
|
||||||
|
*/
|
||||||
|
int quality;
|
||||||
|
/**
|
||||||
|
* The network delay (ms) from the sender to the receiver.
|
||||||
|
*/
|
||||||
|
int network_transport_delay;
|
||||||
|
/**
|
||||||
|
* The delay (ms) from the receiver to the jitter buffer.
|
||||||
|
*/
|
||||||
|
uint32_t jitter_buffer_delay;
|
||||||
|
/**
|
||||||
|
* The audio frame loss rate in the reported interval.
|
||||||
|
*/
|
||||||
|
int audio_loss_rate;
|
||||||
|
/**
|
||||||
|
* The number of audio channels.
|
||||||
|
*/
|
||||||
|
int num_channels;
|
||||||
|
/**
|
||||||
|
* The sample rate (Hz) of the received audio track in the reported interval.
|
||||||
|
*/
|
||||||
|
int received_sample_rate;
|
||||||
|
/**
|
||||||
|
* The average bitrate (Kbps) of the received audio track in the reported interval.
|
||||||
|
* */
|
||||||
|
int received_bitrate;
|
||||||
|
/**
|
||||||
|
* The total freeze time (ms) of the remote audio track after the remote user joins the channel.
|
||||||
|
* In a session, audio freeze occurs when the audio frame loss rate reaches 4%.
|
||||||
|
* The total audio freeze time = The audio freeze number × 2 seconds.
|
||||||
|
*/
|
||||||
|
int total_frozen_time;
|
||||||
|
/**
|
||||||
|
* The total audio freeze time as a percentage (%) of the total time when the audio is available.
|
||||||
|
* */
|
||||||
|
int frozen_rate;
|
||||||
|
/**
|
||||||
|
* The number of audio bytes received.
|
||||||
|
*/
|
||||||
|
int64_t received_bytes;
|
||||||
|
/**
|
||||||
|
* The average packet waiting time (ms) in the jitter buffer.
|
||||||
|
*/
|
||||||
|
int mean_waiting_time;
|
||||||
|
/**
|
||||||
|
* The samples of expanded speech.
|
||||||
|
*/
|
||||||
|
size_t expanded_speech_samples;
|
||||||
|
/**
|
||||||
|
* The samples of expanded noise.
|
||||||
|
*/
|
||||||
|
size_t expanded_noise_samples;
|
||||||
|
/**
|
||||||
|
* The timestamps since last report.
|
||||||
|
*/
|
||||||
|
uint32_t timestamps_since_last_report;
|
||||||
|
/**
|
||||||
|
* The minimum sequence number.
|
||||||
|
*/
|
||||||
|
uint16_t min_sequence_number;
|
||||||
|
/**
|
||||||
|
* The maximum sequence number.
|
||||||
|
*/
|
||||||
|
uint16_t max_sequence_number;
|
||||||
|
/**
|
||||||
|
* The audio energy.
|
||||||
|
*/
|
||||||
|
int32_t audio_level;
|
||||||
|
/**
|
||||||
|
* audio downlink average process time
|
||||||
|
*/
|
||||||
|
uint32_t downlink_process_time_ms;
|
||||||
|
/**
|
||||||
|
* audio neteq loss because of expired
|
||||||
|
*/
|
||||||
|
uint32_t packet_expired_loss;
|
||||||
|
/**
|
||||||
|
* audio neteq packet arrival expired time ms
|
||||||
|
*/
|
||||||
|
uint32_t packet_max_expired_ms;
|
||||||
|
/**
|
||||||
|
* audio neteq jitter peak num in two second
|
||||||
|
*/
|
||||||
|
uint32_t burst_peak_num;
|
||||||
|
/**
|
||||||
|
* audio neteq jitter calc by burst opti feature
|
||||||
|
*/
|
||||||
|
uint32_t burst_jitter;
|
||||||
|
/**
|
||||||
|
* audio base target level
|
||||||
|
*/
|
||||||
|
uint32_t target_level_base_ms;
|
||||||
|
/**
|
||||||
|
* audio average target level
|
||||||
|
*/
|
||||||
|
uint32_t target_level_prefered_ms;
|
||||||
|
/**
|
||||||
|
* audio average accelerate ratio in 2s
|
||||||
|
*/
|
||||||
|
uint16_t accelerate_rate;
|
||||||
|
/**
|
||||||
|
* audio average preemptive expand ratio in 2s
|
||||||
|
*/
|
||||||
|
uint16_t preemptive_expand_rate;
|
||||||
|
/**
|
||||||
|
* The count of 80 ms frozen in 2 seconds
|
||||||
|
*/
|
||||||
|
uint16_t frozen_count_80_ms;
|
||||||
|
/**
|
||||||
|
* The time of 80 ms frozen in 2 seconds
|
||||||
|
*/
|
||||||
|
uint16_t frozen_time_80_ms;
|
||||||
|
/**
|
||||||
|
* The count of 200 ms frozen in 2 seconds
|
||||||
|
*/
|
||||||
|
uint16_t frozen_count_200_ms;
|
||||||
|
/**
|
||||||
|
* The time of 200 ms frozen in 2 seconds
|
||||||
|
*/
|
||||||
|
uint16_t frozen_time_200_ms;
|
||||||
|
/**
|
||||||
|
* The estimate delay
|
||||||
|
*/
|
||||||
|
uint32_t delay_estimate_ms;
|
||||||
|
/**
|
||||||
|
* The MOS value
|
||||||
|
*/
|
||||||
|
uint32_t mos_value;
|
||||||
|
/**
|
||||||
|
* Duration of inbandfec
|
||||||
|
*/
|
||||||
|
int32_t fec_decode_ms;
|
||||||
|
/**
|
||||||
|
* The total time (ms) when the remote user neither stops sending the audio
|
||||||
|
* stream nor disables the audio module after joining the channel.
|
||||||
|
*/
|
||||||
|
uint64_t total_active_time;
|
||||||
|
/**
|
||||||
|
* The total publish duration (ms) of the remote audio stream.
|
||||||
|
*/
|
||||||
|
uint64_t publish_duration;
|
||||||
|
|
||||||
|
int32_t e2e_delay_ms;
|
||||||
|
/**
|
||||||
|
* Quality of experience (QoE) of the local user when receiving a remote audio stream. See #EXPERIENCE_QUALITY_TYPE.
|
||||||
|
*/
|
||||||
|
int qoe_quality;
|
||||||
|
/**
|
||||||
|
* The reason for poor QoE of the local user when receiving a remote audio stream. See #EXPERIENCE_POOR_REASON.
|
||||||
|
*/
|
||||||
|
int32_t quality_changed_reason;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of downlink audio effect.
|
||||||
|
*/
|
||||||
|
int32_t downlink_effect_type;
|
||||||
|
|
||||||
|
RemoteAudioTrackStats() :
|
||||||
|
uid(0),
|
||||||
|
quality(0),
|
||||||
|
network_transport_delay(0),
|
||||||
|
jitter_buffer_delay(0),
|
||||||
|
audio_loss_rate(0),
|
||||||
|
num_channels(0),
|
||||||
|
received_sample_rate(0),
|
||||||
|
received_bitrate(0),
|
||||||
|
total_frozen_time(0),
|
||||||
|
frozen_rate(0),
|
||||||
|
received_bytes(0),
|
||||||
|
mean_waiting_time(0),
|
||||||
|
expanded_speech_samples(0),
|
||||||
|
expanded_noise_samples(0),
|
||||||
|
timestamps_since_last_report(0),
|
||||||
|
min_sequence_number(0xFFFF),
|
||||||
|
max_sequence_number(0),
|
||||||
|
audio_level(0),
|
||||||
|
downlink_process_time_ms(0),
|
||||||
|
packet_expired_loss(0),
|
||||||
|
packet_max_expired_ms(0),
|
||||||
|
burst_peak_num(0),
|
||||||
|
burst_jitter(0),
|
||||||
|
target_level_base_ms(0),
|
||||||
|
target_level_prefered_ms(0),
|
||||||
|
accelerate_rate(0),
|
||||||
|
preemptive_expand_rate(0),
|
||||||
|
frozen_count_80_ms(0),
|
||||||
|
frozen_time_80_ms(0),
|
||||||
|
frozen_count_200_ms(0),
|
||||||
|
frozen_time_200_ms(0),
|
||||||
|
delay_estimate_ms(0),
|
||||||
|
mos_value(0),
|
||||||
|
fec_decode_ms(-1),
|
||||||
|
total_active_time(0),
|
||||||
|
publish_duration(0),
|
||||||
|
e2e_delay_ms(0),
|
||||||
|
qoe_quality(0),
|
||||||
|
quality_changed_reason(0),
|
||||||
|
downlink_effect_type(0) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The IRemoteAudioTrack class.
|
||||||
|
*/
|
||||||
|
class IRemoteAudioTrack : public IAudioTrack {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Gets the statistics of the remote audio track.
|
||||||
|
* @param stats A reference to the statistics of the remote audio track: RemoteAudioTrackStats.
|
||||||
|
* @return
|
||||||
|
* - `true`: Success.
|
||||||
|
* - `false`: Failure.
|
||||||
|
*/
|
||||||
|
virtual bool getStatistics(RemoteAudioTrackStats& stats) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the state of the remote audio.
|
||||||
|
* @return The state of the remote audio: #REMOTE_AUDIO_STATE.
|
||||||
|
*/
|
||||||
|
virtual REMOTE_AUDIO_STATE getState() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers an `IMediaPacketReceiver` object.
|
||||||
|
*
|
||||||
|
* You need to implement the `IMediaPacketReceiver` class in this method. Once you successfully register
|
||||||
|
* the media packet receiver, the SDK triggers the `onMediaPacketReceived` callback when it receives an
|
||||||
|
* audio packet.
|
||||||
|
*
|
||||||
|
* @param packetReceiver The pointer to the `IMediaPacketReceiver` object.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int registerMediaPacketReceiver(IMediaPacketReceiver* packetReceiver) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Releases the `IMediaPacketReceiver` object.
|
||||||
|
* @param packetReceiver The pointer to the `IMediaPacketReceiver` object.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int unregisterMediaPacketReceiver(IMediaPacketReceiver* packetReceiver) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers an `IAudioEncodedFrameReceiver` object.
|
||||||
|
*
|
||||||
|
* You need to implement the `IAudioEncodedFrameReceiver` class in this method. Once you successfully register
|
||||||
|
* the media packet receiver, the SDK triggers the `onEncodedAudioFrameReceived` callback when it receives an
|
||||||
|
* audio packet.
|
||||||
|
*
|
||||||
|
* @param packetReceiver The pointer to the `IAudioEncodedFrameReceiver` object.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int registerAudioEncodedFrameReceiver(IAudioEncodedFrameReceiver* packetReceiver) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Releases the `IAudioEncodedFrameReceiver` object.
|
||||||
|
* @param packetReceiver The pointer to the `IAudioEncodedFrameReceiver` object.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int unregisterAudioEncodedFrameReceiver(IAudioEncodedFrameReceiver* packetReceiver) = 0;
|
||||||
|
|
||||||
|
/** Sets the sound position and gain
|
||||||
|
|
||||||
|
@param pan The sound position of the remote user. The value ranges from -1.0 to 1.0:
|
||||||
|
- 0.0: the remote sound comes from the front.
|
||||||
|
- -1.0: the remote sound comes from the left.
|
||||||
|
- 1.0: the remote sound comes from the right.
|
||||||
|
@param gain Gain of the remote user. The value ranges from 0.0 to 100.0. The default value is 100.0 (the original gain of the remote user). The smaller the value, the less the gain.
|
||||||
|
|
||||||
|
@return
|
||||||
|
- 0: Success.
|
||||||
|
- < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setRemoteVoicePosition(float pan, float gain) = 0;
|
||||||
|
|
||||||
|
/** enable spatial audio
|
||||||
|
|
||||||
|
@param enabled enable/disable spatial audio:
|
||||||
|
- true: enable spatial audio.
|
||||||
|
- false: disable spatial audio.
|
||||||
|
@return
|
||||||
|
- 0: Success.
|
||||||
|
- < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int enableSpatialAudio(bool enabled) = 0;
|
||||||
|
|
||||||
|
/** Sets remote user parameters for spatial audio
|
||||||
|
|
||||||
|
@param params spatial audio parameters
|
||||||
|
|
||||||
|
@return
|
||||||
|
- 0: Success.
|
||||||
|
- < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setRemoteUserSpatialAudioParams(const agora::SpatialAudioParams& params) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace rtc
|
||||||
|
} // namespace agora
|
|
@ -0,0 +1,565 @@
|
||||||
|
//
|
||||||
|
// Agora SDK
|
||||||
|
//
|
||||||
|
// Copyright (c) 2019 Agora.io. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once // NOLINT(build/header_guard)
|
||||||
|
|
||||||
|
#include "AgoraBase.h"
|
||||||
|
#include "AgoraRefPtr.h"
|
||||||
|
|
||||||
|
namespace agora {
|
||||||
|
namespace rtc {
|
||||||
|
class IVideoSinkBase;
|
||||||
|
class ICameraCaptureObserver;
|
||||||
|
/**
|
||||||
|
* The ICameraCapturer class, which provides access to a camera capturer.
|
||||||
|
*/
|
||||||
|
class ICameraCapturer : public RefCountInterface {
|
||||||
|
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* The camera source.
|
||||||
|
*/
|
||||||
|
enum CAMERA_SOURCE {
|
||||||
|
/**
|
||||||
|
* The camera source is the rear camera.
|
||||||
|
*/
|
||||||
|
CAMERA_BACK,
|
||||||
|
/**
|
||||||
|
* The camera source is the front camera.
|
||||||
|
*/
|
||||||
|
CAMERA_FRONT,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The camera state.
|
||||||
|
*/
|
||||||
|
enum CAMERA_STATE {
|
||||||
|
/**
|
||||||
|
* The camera source is started.
|
||||||
|
*/
|
||||||
|
CAMERA_STARTED,
|
||||||
|
/**
|
||||||
|
* The camera source is stopped.
|
||||||
|
*/
|
||||||
|
CAMERA_STOPPED,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Interface for receiving information about available camera devices.
|
||||||
|
/**
|
||||||
|
* The IDeviceInfo class, which manages the information of available cameras.
|
||||||
|
*/
|
||||||
|
class IDeviceInfo {
|
||||||
|
public:
|
||||||
|
virtual ~IDeviceInfo() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Releases the device.
|
||||||
|
*/
|
||||||
|
virtual void release() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the number of all available cameras.
|
||||||
|
* @return The number of all available cameras.
|
||||||
|
*/
|
||||||
|
virtual uint32_t NumberOfDevices() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the name of a specified camera.
|
||||||
|
* @param deviceNumber The index number of the device.
|
||||||
|
* @param deviceNameUTF8 The name of the device.
|
||||||
|
* @param deviceNameLength The length of the device name.
|
||||||
|
* @param deviceUniqueIdUTF8 The unique ID of the device.
|
||||||
|
* @param deviceUniqueIdLength The length of the device ID.
|
||||||
|
* @param productUniqueIdUTF8 The unique ID of the product.
|
||||||
|
* @param productUniqueIdLength The length of the product ID.
|
||||||
|
* @param deviceTypeUTF8 The camera type of the device.
|
||||||
|
* @param deviceTypeLength The length of the camera type.
|
||||||
|
* @return
|
||||||
|
* The name of the device in the UTF8 format: Success.
|
||||||
|
*/
|
||||||
|
virtual int32_t GetDeviceName(uint32_t deviceNumber, char* deviceNameUTF8,
|
||||||
|
uint32_t deviceNameLength, char* deviceUniqueIdUTF8,
|
||||||
|
uint32_t deviceUniqueIdLength, char* productUniqueIdUTF8 = 0,
|
||||||
|
uint32_t productUniqueIdLength = 0,
|
||||||
|
char* deviceTypeUTF8 = 0, uint32_t deviceTypeLength = 0) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the capability number for a specified device.
|
||||||
|
* @param deviceUniqueIdUTF8 The pointer to the ID of the device in the UTF8 format.
|
||||||
|
* @return
|
||||||
|
* The capability number of the device.
|
||||||
|
*/
|
||||||
|
virtual int32_t NumberOfCapabilities(const char* deviceUniqueIdUTF8) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the capability of a specified device.
|
||||||
|
* @param deviceUniqueIdUTF8 The pointer to the ID of the device in the UTF8 format.
|
||||||
|
* @param deviceCapabilityNumber The capability number of the device.
|
||||||
|
* @param capability The reference to the video capability. See {@link VideoFormat}.
|
||||||
|
* @return
|
||||||
|
* The capability number of the device.
|
||||||
|
*/
|
||||||
|
virtual int32_t GetCapability(const char* deviceUniqueIdUTF8,
|
||||||
|
const uint32_t deviceCapabilityNumber,
|
||||||
|
VideoFormat& capability) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
#if defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IPHONE)
|
||||||
|
/**
|
||||||
|
* Sets the camera source.
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* This method applies to Android and iOS only.
|
||||||
|
*
|
||||||
|
* @param source The camera source that you want to capture. See #CAMERA_SOURCE.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setCameraSource(CAMERA_SOURCE source) = 0;
|
||||||
|
/**
|
||||||
|
* Gets the camera source.
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* This method applies to Android and iOS only.
|
||||||
|
*
|
||||||
|
* @return The camera source. See #CAMERA_SOURCE.
|
||||||
|
*/
|
||||||
|
virtual CAMERA_SOURCE getCameraSource() = 0;
|
||||||
|
/**
|
||||||
|
* Switch the camera source
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* This method applies to Android and iOS only.
|
||||||
|
*/
|
||||||
|
virtual void switchCamera() = 0;
|
||||||
|
/**
|
||||||
|
* Returns whether zooming is supported by the current device.
|
||||||
|
* @note
|
||||||
|
* This method applies to Android and iOS only.
|
||||||
|
* This interface returns valid values only after the device is initialized.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - true: zooming is supported.
|
||||||
|
* - false: zooming is not supported or device is not initialized.
|
||||||
|
*/
|
||||||
|
virtual bool isZoomSupported() = 0;
|
||||||
|
/**
|
||||||
|
* Sets the zooming factor of the device.
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* This method applies to Android and iOS only.
|
||||||
|
*
|
||||||
|
* @param zoomValue The zooming factor of the device.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int32_t setCameraZoom(float zoomValue) = 0;
|
||||||
|
/**
|
||||||
|
* Gets the max zooming factor of the device.
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* This method applies to Android and iOS only.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - The max zooming factor of the device
|
||||||
|
*/
|
||||||
|
virtual float getCameraMaxZoom() = 0;
|
||||||
|
/**
|
||||||
|
* Returns whether auto-focus is supported by the current device.
|
||||||
|
* @note
|
||||||
|
* This method applies to Android and iOS only.
|
||||||
|
* This interface returns valid values only after device is initialized.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - true: auto-focus is supported.
|
||||||
|
* - false: auto-focus is not supported or device is not initialized.
|
||||||
|
*/
|
||||||
|
virtual bool isFocusSupported() = 0;
|
||||||
|
/**
|
||||||
|
* Sets the focus area of the current device.
|
||||||
|
* @note
|
||||||
|
* This method applies to Android and iOS only.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int32_t setCameraFocus(float x, float y) = 0;
|
||||||
|
/**
|
||||||
|
* Returns whether auto face focus is supported by the current device.
|
||||||
|
* @note
|
||||||
|
* This method applies to Android and iOS only.
|
||||||
|
* This interface returns valid values only after device is initialized.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - true: auto-face-focus is supported.
|
||||||
|
* - false: auto-face-focus is not supported or device is not initialized.
|
||||||
|
*/
|
||||||
|
virtual bool isAutoFaceFocusSupported() = 0;
|
||||||
|
/**
|
||||||
|
* Enables or disables auto face focus.
|
||||||
|
* @note
|
||||||
|
* This method applies to Android and iOS only.
|
||||||
|
* This interface returns valid values only after device is initialized.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int32_t setCameraAutoFaceFocus(bool enable) = 0;
|
||||||
|
/**
|
||||||
|
* Enables or disables auto face detection.
|
||||||
|
* @note
|
||||||
|
* This method applies to Android and iOS only.
|
||||||
|
* This interface returns valid values only after device is initialized.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int32_t enableFaceDetection(bool enable) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether the camera face detect is supported.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - true: The camera face detect is supported.
|
||||||
|
* - false: The camera face detect is not supported.
|
||||||
|
*/
|
||||||
|
virtual bool isCameraFaceDetectSupported() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether the camera flash function is supported.
|
||||||
|
*
|
||||||
|
* The SDK uses the front camera by default, so if you call `isCameraTorchSupported` directly,
|
||||||
|
* you can find out from the return value whether the device supports enabling the flash
|
||||||
|
* when using the front camera. If you want to check whether the device supports enabling the
|
||||||
|
* flash when using the rear camera, call \ref IRtcEngine::switchCamera "switchCamera"
|
||||||
|
* to switch the camera used by the SDK to the rear camera, and then call `isCameraTorchSupported`.
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* - Call this method after the camera is started.
|
||||||
|
* - This method is for Android and iOS only.
|
||||||
|
* - On iPads with system version 15, even if `isCameraTorchSupported` returns true, you might
|
||||||
|
* fail to successfully enable the flash by calling \ref IRtcEngine::setCameraTorchOn "setCameraTorchOn"
|
||||||
|
* due to system issues.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - true: The device supports enabling the flash.
|
||||||
|
* - false: The device does not support enabling the flash.
|
||||||
|
*/
|
||||||
|
virtual bool isCameraTorchSupported() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @note
|
||||||
|
* - Call this method after the camera is started.
|
||||||
|
* - This method is for Android and iOS only.
|
||||||
|
* - On iPads with system version 15, even if \ref IRtcEngine::isCameraTorchSupported "isCameraTorchSupported"
|
||||||
|
* returns true, you might fail to successfully enable the flash by calling `setCameraTorchOn` due to
|
||||||
|
* system issues.
|
||||||
|
*
|
||||||
|
* @param isOn Determines whether to enable the flash:
|
||||||
|
* - true: Enable the flash.
|
||||||
|
* - false: Disable the flash.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0: Success
|
||||||
|
* - < 0: Failure
|
||||||
|
*/
|
||||||
|
virtual int setCameraTorchOn(bool isOn) = 0;
|
||||||
|
|
||||||
|
/** Checks whether the camera exposure function is supported.
|
||||||
|
*
|
||||||
|
* Ensure that you call this method after the camera starts, for example, by calling `startPreview` or `joinChannel`.
|
||||||
|
*
|
||||||
|
* @since v2.3.2.
|
||||||
|
* @return
|
||||||
|
* <ul>
|
||||||
|
* <li>true: The device supports the camera exposure function.</li>
|
||||||
|
* <li>false: The device does not support the camera exposure function.</li>
|
||||||
|
* </ul>
|
||||||
|
*/
|
||||||
|
virtual bool isCameraExposurePositionSupported() = 0;
|
||||||
|
|
||||||
|
/** Sets the camera exposure position.
|
||||||
|
*
|
||||||
|
* Ensure that you call this method after the camera starts, for example, by calling `startPreview` or `joinChannel`.
|
||||||
|
*
|
||||||
|
* A successful setCameraExposurePosition method call triggers the {@link IRtcEngineEventHandler#onCameraExposureAreaChanged onCameraExposureAreaChanged} callback on the local client.
|
||||||
|
* @since v2.3.2.
|
||||||
|
* @param positionXinView The horizontal coordinate of the touch point in the view.
|
||||||
|
* @param positionYinView The vertical coordinate of the touch point in the view.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* <ul>
|
||||||
|
* <li>0: Success.</li>
|
||||||
|
* <li>< 0: Failure.</li>
|
||||||
|
* </ul>
|
||||||
|
*/
|
||||||
|
virtual int setCameraExposurePosition(float positionXinView, float positionYinView) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the camera mirror mode.
|
||||||
|
*
|
||||||
|
* This method applies to iOS only. It supports setting the mirror mode within and outside a channel.
|
||||||
|
*
|
||||||
|
* @param mirror The desired video mirror mode of the camera.
|
||||||
|
*
|
||||||
|
* Key considerations:
|
||||||
|
* - Call this method before starting the camera. The preferred call sequence is: setCameraMirror -> startPreview -> joinChannel.
|
||||||
|
* - Supported mirror modes are VIDEO_MIRROR_MODE_AUTO (front camera mirrored), VIDEO_MIRROR_MODE_ENABLED (front and back cameras mirrored), and VIDEO_MIRROR_MODE_DISABLED (no mirroring).
|
||||||
|
* - To optimize performance by using capture-side mirroring instead of calling setVideoEncoderConfiguration or videoframeobserver's getMirrorApplied method.
|
||||||
|
* - Use setLocalVideo and setRemoteVideo with the desired mirror settings for local and remote rendering.
|
||||||
|
Example usage:
|
||||||
|
Using the front camera, local mirroring and remote non-mirroring.
|
||||||
|
Using the rear camera, local non-mirroring, remote non-mirroring.
|
||||||
|
- No stickers.:
|
||||||
|
local:setLocalVideo:mirrorMode(auto)
|
||||||
|
remote:setRemoteVideo:mirrorMode(auto)
|
||||||
|
- With stickers:
|
||||||
|
local:setCameraMirror(auto) + setLocalVideo:mirrorMode(disable)
|
||||||
|
remote:setRemoteVideo:mirrorMode(auto)
|
||||||
|
* The API also supports private parameters:
|
||||||
|
* - Use parameter "{\"rtc.camera_capture_mirror_mode\":0}" to manually set the mirror mode.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setCameraMirror(VIDEO_MIRROR_MODE_TYPE mirror) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether exposure value adjusting is supported by the current device.
|
||||||
|
* @note
|
||||||
|
* This method applies to iOS only.
|
||||||
|
* This interface returns valid values only after the device is initialized.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - true: exposure value adjusting is supported.
|
||||||
|
* - false: exposure value adjusting is not supported or device is not initialized.
|
||||||
|
*/
|
||||||
|
virtual bool isCameraExposureSupported() = 0;
|
||||||
|
/**
|
||||||
|
* Sets the exposure factor of the device.
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* This method applies to iOS only.
|
||||||
|
*
|
||||||
|
* @param exposureValue The exposure value bias factor of the device.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int32_t setCameraExposureFactor(float exposureValue) = 0;
|
||||||
|
|
||||||
|
#if (defined(__APPLE__) && TARGET_OS_IOS)
|
||||||
|
/**
|
||||||
|
* Enables or disables the AVCaptureMultiCamSession.
|
||||||
|
*
|
||||||
|
* @param enable Determines whether to use the AVCaptureMultiCamSession:
|
||||||
|
* - true: Enable the AVCaptureMultiCamSession.
|
||||||
|
* - false: Disable the AVCaptureMultiCamSession.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual bool enableMultiCamera(bool enable) = 0;
|
||||||
|
/**
|
||||||
|
* Checks whether the camera auto exposure function is supported.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - true: The camera auto exposure function is supported.
|
||||||
|
* - false: The camera auto exposure function is not supported.
|
||||||
|
*/
|
||||||
|
virtual bool isCameraAutoExposureFaceModeSupported() = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables the camera auto exposure face function.
|
||||||
|
*
|
||||||
|
* @param enabled Determines whether to enable the camera auto exposure face mode.
|
||||||
|
* - true: Enable the auto exposure face function.
|
||||||
|
* - false: Do not enable the auto exposure face function.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* <ul>
|
||||||
|
* <li>0: Success.</li>
|
||||||
|
* <li>< 0: Failure.</li>
|
||||||
|
* </ul>
|
||||||
|
*/
|
||||||
|
virtual int setCameraAutoExposureFaceModeEnabled(bool enabled) = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined(_WIN32) || (defined(__linux__) && !defined(__ANDROID__)) || \
|
||||||
|
(defined(__APPLE__) && TARGET_OS_MAC && !TARGET_OS_IPHONE)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a DeviceInfo object.
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* This method applies to Windows, macOS, and Linux only.
|
||||||
|
* @return
|
||||||
|
* - The pointer to \ref agora::rtc::ICameraCapturer::IDeviceInfo "IDeviceInfo": Success.
|
||||||
|
* - An empty pointer NULL: Failure.
|
||||||
|
*/
|
||||||
|
virtual IDeviceInfo* createDeviceInfo() = 0;
|
||||||
|
/**
|
||||||
|
* Initializes the device with the device ID.
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* This method applies to Windows, macOS, and Linux only.
|
||||||
|
*
|
||||||
|
* @param deviceId The pointer to the device ID.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int initWithDeviceId(const char* deviceId) = 0;
|
||||||
|
/**
|
||||||
|
* Initializes the device with the device name.
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* This method applies to Windows, macOS, and Linux only.
|
||||||
|
*
|
||||||
|
* @param deviceName The pointer to the device name.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int initWithDeviceName(const char* deviceName) = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the format of the video captured by the camera.
|
||||||
|
*
|
||||||
|
* If you do not set the video capturing format, the SDK automatically chooses a proper format according to the video encoder configuration of the video track.
|
||||||
|
*
|
||||||
|
* @param capture_format The reference to the video format: VideoFormat.
|
||||||
|
*/
|
||||||
|
virtual void setCaptureFormat(const VideoFormat& capture_format) = 0;
|
||||||
|
/**
|
||||||
|
* Gets the format of the video captured by the camera.
|
||||||
|
* @return
|
||||||
|
* VideoFormat.
|
||||||
|
*/
|
||||||
|
virtual VideoFormat getCaptureFormat() = 0;
|
||||||
|
/**
|
||||||
|
* Register a camera observer.
|
||||||
|
*
|
||||||
|
* @param observer Instance of the capture observer.
|
||||||
|
*/
|
||||||
|
virtual int registerCameraObserver(ICameraCaptureObserver* observer) = 0;
|
||||||
|
/**
|
||||||
|
* Unregisters the camera observer.
|
||||||
|
*
|
||||||
|
* @param observer Instance of the capture observer.
|
||||||
|
*/
|
||||||
|
virtual int unregisterCameraObserver(ICameraCaptureObserver* observer) = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
~ICameraCapturer() {}
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* The ICameraCaptureObserver class, which handles camera capture events.
|
||||||
|
*/
|
||||||
|
class ICameraCaptureObserver {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Occurs when the camera focus area changes.
|
||||||
|
*
|
||||||
|
* @note The SDK triggers this callback when the local user changes the camera focus position by
|
||||||
|
* calling the \ref agora::rtc::ICameraCapturer::setCameraFocus "setCameraFocus" method.
|
||||||
|
*
|
||||||
|
* @param imageWidth Width of the changed camera focus area.
|
||||||
|
* @param imageHeight Height of the changed camera focus area.
|
||||||
|
* @param x x coordinate of the changed camera focus area.
|
||||||
|
* @param y y coordinate of the changed camera focus area.
|
||||||
|
*/
|
||||||
|
virtual void onCameraFocusAreaChanged(int imageWidth, int imageHeight, int x, int y) {
|
||||||
|
(void) imageWidth;
|
||||||
|
(void) imageHeight;
|
||||||
|
(void) x;
|
||||||
|
(void) y;
|
||||||
|
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Reports the face detection result of the local user. Applies to Android and iOS only.
|
||||||
|
*
|
||||||
|
* Once you enable face detection by calling \ref agora::rtc::ICameraCapturer::setCameraFaceDetection "setCameraFaceDetection" (true),
|
||||||
|
* you can get the following information on the local user in real-time:
|
||||||
|
* - The width and height of the local video.
|
||||||
|
* - The position of the human face in the local video.
|
||||||
|
* - The distance between the human face and the device screen.
|
||||||
|
* This value is based on the fitting calculation of the local video size and the position of the human face.
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* - If the SDK does not detect a face, it reduces the frequency of this callback to reduce power consumption on the local device.
|
||||||
|
* - The SDK stops triggering this callback when a human face is in close proximity to the screen.
|
||||||
|
* - On Android, the distance value reported in this callback may be slightly different from the actual distance.
|
||||||
|
* Therefore, Agora does not recommend using it for accurate calculation.
|
||||||
|
*
|
||||||
|
* @param imageWidth The width (px) of the local video.
|
||||||
|
* @param imageHeight The height (px) of the local video.
|
||||||
|
* @param vecRectangle The position and size of the human face on the local video:
|
||||||
|
* - `x`: The x coordinate (px) of the human face in the local video. Taking the top left corner of the captured video as the origin,
|
||||||
|
* the x coordinate represents the relative lateral displacement of the top left corner of the human face to the origin.
|
||||||
|
* - `y`: The y coordinate (px) of the human face in the local video. Taking the top left corner of the captured video as the origin,
|
||||||
|
* the y coordinate represents the relative longitudinal displacement of the top left corner of the human face to the origin.
|
||||||
|
* - `width`: The width (px) of the human face in the captured video.
|
||||||
|
* - `height`: The height (px) of the human face in the captured video.
|
||||||
|
* @param vecDistance The distance (cm) between the human face and the screen.
|
||||||
|
* @param numFaces The number of faces detected. If the value is 0, it means that no human face is detected.
|
||||||
|
*/
|
||||||
|
virtual void onFacePositionChanged(
|
||||||
|
int imageWidth, int imageHeight, const Rectangle* vecRectangle, const int* vecDistance, int numFaces) {
|
||||||
|
(void) imageWidth;
|
||||||
|
(void) imageHeight;
|
||||||
|
(void) vecRectangle;
|
||||||
|
(void) vecDistance;
|
||||||
|
(void) numFaces;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Occurs when the camera exposure area changes.
|
||||||
|
*
|
||||||
|
* The SDK triggers this callback when the local user changes the camera exposure position by calling the setCameraExposurePosition method.
|
||||||
|
*
|
||||||
|
* @note This callback is for Android and iOS only.
|
||||||
|
*
|
||||||
|
* @param x x coordinate of the changed camera exposure area.
|
||||||
|
* @param y y coordinate of the changed camera exposure area.
|
||||||
|
* @param width Width of the changed camera exposure area.
|
||||||
|
* @param height Height of the changed camera exposure area.
|
||||||
|
*/
|
||||||
|
virtual void onCameraExposureAreaChanged(int x, int y, int width, int height) {
|
||||||
|
(void)x;
|
||||||
|
(void)y;
|
||||||
|
(void)width;
|
||||||
|
(void)height;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void onCameraStateChanged(ICameraCapturer::CAMERA_STATE state, ICameraCapturer::CAMERA_SOURCE source) {
|
||||||
|
(void) state;
|
||||||
|
(void) source;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual ~ICameraCaptureObserver() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace rtc
|
||||||
|
} // namespace agora
|
|
@ -0,0 +1,100 @@
|
||||||
|
//
|
||||||
|
// Copyright (c) 2020 Agora.io. All rights reserved
|
||||||
|
|
||||||
|
// This program is confidential and proprietary to Agora.io.
|
||||||
|
// And may not be copied, reproduced, modified, disclosed to others, published
|
||||||
|
// or used, in whole or in part, without the express prior written permission
|
||||||
|
// of Agora.io.
|
||||||
|
|
||||||
|
#pragma once // NOLINT(build/header_guard)
|
||||||
|
#include "AgoraBase.h"
|
||||||
|
#include "AgoraRefPtr.h"
|
||||||
|
#include "AgoraRefCountedObject.h"
|
||||||
|
#include "IAgoraLog.h"
|
||||||
|
#include "NGIAgoraVideoFrame.h"
|
||||||
|
#include "NGIAgoraExtensionProvider.h"
|
||||||
|
|
||||||
|
namespace agora {
|
||||||
|
namespace rtc {
|
||||||
|
class IExtensionProvider;
|
||||||
|
/**
|
||||||
|
* Interface for handling agora extensions.
|
||||||
|
*/
|
||||||
|
class IExtensionControl {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Agora Extension Capabilities.
|
||||||
|
*/
|
||||||
|
struct Capabilities {
|
||||||
|
/**
|
||||||
|
* Whether to support audio extensions.
|
||||||
|
*/
|
||||||
|
bool audio;
|
||||||
|
/**
|
||||||
|
* Whether to support video extensions.
|
||||||
|
*/
|
||||||
|
bool video;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the capabilities of agora extensions.
|
||||||
|
*
|
||||||
|
* @param capabilities Supported extension capabilities.
|
||||||
|
*/
|
||||||
|
virtual void getCapabilities(Capabilities& capabilities) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Recycles internal frame memory with a specified Video frame type.
|
||||||
|
*
|
||||||
|
* The SDK automatically recycles deprecated video frames. However,
|
||||||
|
* you can still call this method to perform an immediate memory recycle.
|
||||||
|
* @param type Frame type to be recycled.
|
||||||
|
*/
|
||||||
|
virtual void recycleVideoCache() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method dumps the content of the video frame to the specified file.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0: The method call succeeds.
|
||||||
|
* - <0: The method call fails.
|
||||||
|
*/
|
||||||
|
virtual int dumpVideoFrame(agora_refptr<IVideoFrame> frame, const char* file) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets log file.
|
||||||
|
*
|
||||||
|
* @param level Logging level. See #commons::LOG_LEVEL.
|
||||||
|
* @param message Message to add to the log file.
|
||||||
|
* @return
|
||||||
|
* - 0: The method call succeeds.
|
||||||
|
* - <0: The method call fails.
|
||||||
|
*/
|
||||||
|
virtual int log(commons::LOG_LEVEL level, const char* message) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Post extension events to SDK.
|
||||||
|
*
|
||||||
|
* @param provider name of the provider
|
||||||
|
* @param extension name of the extension
|
||||||
|
* @param event_key key of the extension event
|
||||||
|
* @param event_json_str string of the extension event
|
||||||
|
* @return
|
||||||
|
* - 0: The method call succeeds.
|
||||||
|
* - <0: The method call fails.
|
||||||
|
*/
|
||||||
|
virtual int fireEvent(const char* provider, const char* extension, const char* event_key, const char* value) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register provider to the SDK
|
||||||
|
* @param provider name of the provider
|
||||||
|
* @param instance instance of the provider
|
||||||
|
*/
|
||||||
|
virtual int registerProvider(const char* provider, agora_refptr<IExtensionProvider> instance) = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual ~IExtensionControl() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace rtc
|
||||||
|
} // namespace agora
|
|
@ -0,0 +1,122 @@
|
||||||
|
//
|
||||||
|
// Agora SDK
|
||||||
|
//
|
||||||
|
// Copyright (c) 2021 Agora.io. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "AgoraRefPtr.h"
|
||||||
|
#include "NGIAgoraMediaNode.h"
|
||||||
|
#include "AgoraExtensionVersion.h"
|
||||||
|
|
||||||
|
namespace agora {
|
||||||
|
namespace rtc {
|
||||||
|
class IExtensionControl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interfaces for Extension Provider
|
||||||
|
* User can implement these interfaces for providing their own media node implementations to SDK.
|
||||||
|
* Please refer to \ref agora::RefCountedObject to wrap your implementation so that it can be
|
||||||
|
* held by agora::agora_refptr.
|
||||||
|
* For example:
|
||||||
|
* class YourExtensionProvide: public IExtensionProvider {
|
||||||
|
* // Your Concrete implementaion
|
||||||
|
* };
|
||||||
|
*
|
||||||
|
* // Use agroa::RefCountedObject to provide RefCountInterface implementation for you implementation,
|
||||||
|
* // intantiate and wrap it with agora_refptr.
|
||||||
|
*
|
||||||
|
* agora_refptr<IExtensionProvider> provider = new RefCountedObject<YourExtensionProvide>(Arg1, Arg2, ...);
|
||||||
|
*
|
||||||
|
* You can instantiate your AudioFilter/VideoFilter/VideoSink in the same way.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class IExtensionProvider : public RefCountInterface {
|
||||||
|
public:
|
||||||
|
enum EXTENSION_TYPE {
|
||||||
|
/**
|
||||||
|
* note: discarded, Don't use it anymore.
|
||||||
|
*/
|
||||||
|
AUDIO_FILTER,
|
||||||
|
VIDEO_PRE_PROCESSING_FILTER,
|
||||||
|
VIDEO_POST_PROCESSING_FILTER,
|
||||||
|
AUDIO_SINK,
|
||||||
|
VIDEO_SINK,
|
||||||
|
/*
|
||||||
|
* Used to modify locally captured audio data to play, such as ear monitoring.
|
||||||
|
*/
|
||||||
|
AUDIO_RECORDING_LOCAL_PLAYBACK_FILTER = 10000,
|
||||||
|
/*
|
||||||
|
* Used to modify audio data after the local APM (3A).
|
||||||
|
*/
|
||||||
|
AUDIO_POST_PROCESSING_FILTER = 10001,
|
||||||
|
/*
|
||||||
|
* Used to modify received and decoded remote user audio data.
|
||||||
|
*/
|
||||||
|
AUDIO_REMOTE_USER_PLAYBACK_FILTER = 10002,
|
||||||
|
/*
|
||||||
|
* note: It is used internally by agora and does not support users other than agora.
|
||||||
|
*
|
||||||
|
* Used to modify the audio data of the sender's PCM source to take effect for sending and local playback.
|
||||||
|
*/
|
||||||
|
AUDIO_PCM_SOURCE_FILTER = 10003,
|
||||||
|
/*
|
||||||
|
* note: It is used internally by agora and does not support users other than agora.
|
||||||
|
*
|
||||||
|
* Used to Modifying the audio data of the sender's PCM source is only effect for the sending.
|
||||||
|
*/
|
||||||
|
AUDIO_PCM_SOURCE_SENDING_FILTER = 10004,
|
||||||
|
/*
|
||||||
|
* note: It is used internally by agora and does not support users other than agora.
|
||||||
|
*
|
||||||
|
* Used to Modifying the audio data of the sender's PCM source is only effect for the local playback.
|
||||||
|
*/
|
||||||
|
AUDIO_PCM_SOURCE_LOCAL_PLAYBACK_FILTER = 10005,
|
||||||
|
/*
|
||||||
|
* note: It is used internally by agora and does not support users other than agora.
|
||||||
|
*
|
||||||
|
* Used to modify local playback audio data after the remote audio mixed.
|
||||||
|
*/
|
||||||
|
AUDIO_REMOTE_MIXED_PLAYBACK_FILTER = 10006,
|
||||||
|
UNKNOWN = 0xFFFF,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ExtensionMetaInfo {
|
||||||
|
EXTENSION_TYPE type;
|
||||||
|
const char* extension_name;
|
||||||
|
};
|
||||||
|
|
||||||
|
virtual void setExtensionControl(IExtensionControl* control) {}
|
||||||
|
|
||||||
|
virtual void enumerateExtensions(ExtensionMetaInfo* extension_list,
|
||||||
|
int& extension_count) {
|
||||||
|
(void) extension_list;
|
||||||
|
extension_count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual agora_refptr<IAudioFilter> createAudioFilter(const char* name) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual agora_refptr<IExtensionVideoFilter> createVideoFilter(const char* name) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual agora_refptr<IVideoSinkBase> createVideoSink(const char* name) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void setProperty(const char* key, const char* value) {}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual ~IExtensionProvider() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
class IExtensionProviderV2 : public IExtensionProvider {
|
||||||
|
public:
|
||||||
|
virtual void getExtensionVersion(const char* extension_name, ExtensionVersion& version) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace rtc
|
||||||
|
} // namespace agora
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,893 @@
|
||||||
|
#pragma once
|
||||||
|
#include "AgoraRefPtr.h"
|
||||||
|
#include "AgoraBase.h"
|
||||||
|
#include "IAgoraLog.h"
|
||||||
|
#include "NGIAgoraVideoFrame.h"
|
||||||
|
#include "AgoraExtensionVersion.h"
|
||||||
|
|
||||||
|
#ifndef OPTIONAL_PROCESSRESULT_SPECIFIER
|
||||||
|
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
|
||||||
|
#define OPTIONAL_PROCESSRESULT_SPECIFIER ProcessResult::
|
||||||
|
#else
|
||||||
|
#define OPTIONAL_PROCESSRESULT_SPECIFIER
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace webrtc {
|
||||||
|
struct AudioFrameHandleInfo;
|
||||||
|
} // namespace webrtc
|
||||||
|
|
||||||
|
namespace agora {
|
||||||
|
namespace rtc {
|
||||||
|
/**
|
||||||
|
* The `IAudioFilterBase` class is the base class for audio filters. You can use this class to implement your own filter
|
||||||
|
* and add it to an audio track.
|
||||||
|
*/
|
||||||
|
class IAudioFilterBase : public RefCountInterface {
|
||||||
|
public:
|
||||||
|
// Return false if filter decide to drop the frame.
|
||||||
|
// Implementation should not change samples_per_channel_/sample_rate_hz_/num_channels_
|
||||||
|
// Implementation should just adapt data of audio frame.
|
||||||
|
/**
|
||||||
|
* Adapts the audio frame.
|
||||||
|
* @param inAudioFrame The reference to the audio frame that you want to adapt.
|
||||||
|
* @param adaptedFrame The reference to the adapted audio frame.
|
||||||
|
* @return
|
||||||
|
* - `true`: Success.
|
||||||
|
* - `false`: Failure. For example, the IAudiofilter object drops the audio frame.
|
||||||
|
*/
|
||||||
|
virtual bool adaptAudioFrame(const media::base::AudioPcmFrame& inAudioFrame,
|
||||||
|
media::base::AudioPcmFrame& adaptedFrame) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the sample rate supported by the audio filter, the framework will resample
|
||||||
|
* the audio data and then pass it to the audio filter.
|
||||||
|
* @return
|
||||||
|
* - 0: Audio data will not be resampled.
|
||||||
|
* - > 0: Audio data will be resampled to this sample rate.
|
||||||
|
*/
|
||||||
|
virtual int getPreferredSampleRate() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the channel number supported by the audio filter, the framework will resample
|
||||||
|
* the audio data and then pass it to the audio filter. If the user does not
|
||||||
|
* overwrite, resampling will not be done by default.
|
||||||
|
* @return
|
||||||
|
* - 0: Audio data will not be resampled.
|
||||||
|
* - > 0: Audio data will be resampled to this sample rate.
|
||||||
|
*/
|
||||||
|
virtual int getPreferredChannelNumbers() = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
~IAudioFilterBase() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The `IAudioFilter` class.
|
||||||
|
*
|
||||||
|
* This class is the intermediate node for audio, which reads audio frames from the underlying
|
||||||
|
* pipeline and writes audio frames back after adaptation.
|
||||||
|
*/
|
||||||
|
class IAudioFilter : public IAudioFilterBase {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Enables or disables the audio filter.
|
||||||
|
* @param enable Whether to enable the audio filter:
|
||||||
|
* - `true`: Enable the audio filter.
|
||||||
|
* - `false`: Do not enable the audio filter.
|
||||||
|
*/
|
||||||
|
virtual void setEnabled(bool enable) = 0;
|
||||||
|
/**
|
||||||
|
* Checks whether the audio filter is enabled.
|
||||||
|
* @return
|
||||||
|
* - `true`: The audio filter is enabled.
|
||||||
|
* - `false`: The audio filter is not enabled.
|
||||||
|
*/
|
||||||
|
virtual bool isEnabled() const = 0;
|
||||||
|
/**
|
||||||
|
* Sets a private property in the `IAudioFilter` class.
|
||||||
|
*
|
||||||
|
* @param key The pointer to the property name.
|
||||||
|
* @param buf The pointer to the buffer of this private property.
|
||||||
|
* @param buf_size The buffer size of this private property.
|
||||||
|
* @return
|
||||||
|
* - The actual size of the private property, if the method call succeeds.
|
||||||
|
* - -1, if the method call fails.
|
||||||
|
*/
|
||||||
|
virtual int setProperty(const char* key, const void* buf, int buf_size) = 0;
|
||||||
|
/**
|
||||||
|
* Gets a private property in the `IAudioFilter` class.
|
||||||
|
*
|
||||||
|
* @param name The pointer to the property name.
|
||||||
|
* @param buf The pointer to the buffer of this private property.
|
||||||
|
* @param buf_size The buffer size of this private property.
|
||||||
|
* @return
|
||||||
|
* - The actual size of the private property, if the method call succeeds.
|
||||||
|
* - -1, if the method call fails.
|
||||||
|
*/
|
||||||
|
virtual int getProperty(const char* key, void* buf, int buf_size) const = 0;
|
||||||
|
/**
|
||||||
|
* Gets the name of the `IAudioFilter` class.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - The name of the audio filter, if the method call succeeds.
|
||||||
|
* - An empty string, if the method call fails.
|
||||||
|
*/
|
||||||
|
virtual const char * getName() const = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the sample rate supported by the audio filter, the framework will resample
|
||||||
|
* the audio data and then pass it to the audio filter. If the user does not
|
||||||
|
* overwrite, resampling will not be done by default.
|
||||||
|
* @return
|
||||||
|
* - 0: Audio data will not be resampled.
|
||||||
|
* - > 0: Audio data will be resampled to this sample rate.
|
||||||
|
*/
|
||||||
|
virtual int getPreferredSampleRate() { return 0; };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the channel number supported by the audio filter, the framework will resample
|
||||||
|
* the audio data and then pass it to the audio filter. If the user does not
|
||||||
|
* overwrite, resampling will not be done by default.
|
||||||
|
* @return
|
||||||
|
* - 0: Audio data will not be resampled.
|
||||||
|
* - > 0: Audio data will be resampled to this sample rate.
|
||||||
|
*/
|
||||||
|
virtual int getPreferredChannelNumbers() { return 0; };
|
||||||
|
|
||||||
|
protected:
|
||||||
|
~IAudioFilter() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
class IAudioFilterV2 : public IAudioFilter {
|
||||||
|
public:
|
||||||
|
class Control : public RefCountInterface {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Post an event and notify the end users.
|
||||||
|
* @param key '\0' ended string that describes the key of the event
|
||||||
|
* @param value '\0' ended string that describes the value of the event
|
||||||
|
*/
|
||||||
|
virtual int postEvent(const char* key, const char* value) = 0;
|
||||||
|
/**
|
||||||
|
* @brief print log to the SDK.
|
||||||
|
* @param level Log level @ref agora::commons::LOG_LEVEL
|
||||||
|
* @param format log formatter string
|
||||||
|
* @param ... variadic arguments
|
||||||
|
*/
|
||||||
|
virtual void printLog(commons::LOG_LEVEL level, const char* format, ...) = 0;
|
||||||
|
};
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief AgoraSDK set IAudioFilterV2::Control to filter
|
||||||
|
* @param control IAudioFilterV2::Control
|
||||||
|
*/
|
||||||
|
virtual void setExtensionControl(agora::agora_refptr<IAudioFilterV2::Control> control) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The `IVideoFilterBase` class is the base class for video filters. You can use this class to implement your own filter
|
||||||
|
* and add the filter to a video track.
|
||||||
|
*/
|
||||||
|
class IVideoFilterBase : public RefCountInterface {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Adapts the video frame.
|
||||||
|
*
|
||||||
|
* @param capturedFrame The reference to the captured video frame that you want to adapt.
|
||||||
|
* @param adaptedFrame The reference to the adapted video frame.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - `true`: Success.
|
||||||
|
* - `false`: Failure, if, for example, the `IVideofilter` object drops the video frame.
|
||||||
|
*/
|
||||||
|
virtual bool adaptVideoFrame(const media::base::VideoFrame& capturedFrame,
|
||||||
|
media::base::VideoFrame& adaptedFrame) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
// TODO(Bob): private inherit?
|
||||||
|
/**
|
||||||
|
* The IVideoFilter class.
|
||||||
|
*
|
||||||
|
* This class is the intermediate node for video, which contains both the video source and the video
|
||||||
|
* sink. It reads video frames from the underlying video pipeline and writes video frames back after
|
||||||
|
* adaptation.
|
||||||
|
*/
|
||||||
|
class IVideoFilter : public IVideoFilterBase {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Enables or disables the video filter.
|
||||||
|
* @param enable Whether to enable the video filter:
|
||||||
|
* - `true`: (Default) Enable the video filter.
|
||||||
|
* - `false`: Do not enable the video filter. If the filter is disabled, frames will be passed without
|
||||||
|
* adaption.
|
||||||
|
*/
|
||||||
|
virtual void setEnabled(bool enable) {}
|
||||||
|
/**
|
||||||
|
* Checks whether the video filter is enabled.
|
||||||
|
* @return
|
||||||
|
* - `true`: The video filter is enabled.
|
||||||
|
* - `false`: The video filter is not enabled.
|
||||||
|
*/
|
||||||
|
virtual bool isEnabled() { return true; }
|
||||||
|
/**
|
||||||
|
* Sets a private property in the `IVideoFilter` class.
|
||||||
|
*
|
||||||
|
* @param key The pointer to the property name.
|
||||||
|
* @param buf The pointer to the buffer of this private property.
|
||||||
|
* @param buf_size The buffer size of this private property.
|
||||||
|
* @return
|
||||||
|
* - The actual size of the private property, if the method call succeeds.
|
||||||
|
* - -1, if the method call fails.
|
||||||
|
*/
|
||||||
|
virtual int setProperty(const char* key, const void* buf, size_t buf_size) { return -1; }
|
||||||
|
/**
|
||||||
|
* Gets a private property in the IVideoFilter class.
|
||||||
|
*
|
||||||
|
* @param key The pointer to the property name.
|
||||||
|
* @param buf The pointer to the buffer of this private property.
|
||||||
|
* @param buf_size The buffer size of this private property.
|
||||||
|
* @return
|
||||||
|
* - The actual size of the private property, if the method call succeeds.
|
||||||
|
* - -1, if the method call fails.
|
||||||
|
*/
|
||||||
|
virtual int getProperty(const char* key, void* buf, size_t buf_size) { return -1; }
|
||||||
|
/**
|
||||||
|
* This function is invoked right before data stream starts.
|
||||||
|
* Custom filter can override this function for initialization.
|
||||||
|
* @return
|
||||||
|
* - `true`: The initialization succeeds.
|
||||||
|
* - `false`: The initialization fails.
|
||||||
|
*/
|
||||||
|
virtual bool onDataStreamWillStart() { return true; }
|
||||||
|
/**
|
||||||
|
* This function is invoked right before data stream stops.
|
||||||
|
* Custom filter can override this function for deinitialization.
|
||||||
|
*/
|
||||||
|
virtual void onDataStreamWillStop() { }
|
||||||
|
/**
|
||||||
|
* This function indicates if the filter is for internal use.
|
||||||
|
* @note Do not override this function.
|
||||||
|
* @return
|
||||||
|
* - `true`: The filter is implemented by external users.
|
||||||
|
* - `false`: The filter is implemented by internal users.
|
||||||
|
*/
|
||||||
|
virtual bool isExternal() { return true; }
|
||||||
|
/**
|
||||||
|
* This function indicates if the filter is implemented by third-party providers.
|
||||||
|
* @note Do not override this function.
|
||||||
|
* @return
|
||||||
|
* - `true`: The filter is implemented by third-party providers.
|
||||||
|
* - `false`: otherwise.
|
||||||
|
*/
|
||||||
|
virtual bool isExtensionFilter() { return false; }
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The IExtensionVideoFilter class.
|
||||||
|
*
|
||||||
|
* This class defines the interfaces that a external video extension provider can implement
|
||||||
|
* so as to be loaded by SDK as an "3rd party extension" for video pre- or post- processing.
|
||||||
|
*/
|
||||||
|
class IExtensionVideoFilter : public IVideoFilter {
|
||||||
|
public:
|
||||||
|
enum ProcessMode {
|
||||||
|
kSync, // Indicates that video frame data will be exchanged via "adaptVideoFrame"
|
||||||
|
kAsync, // Indicates that video frame data will be exchanged via "pendVideoFrame" & "deliverVideoFrame"
|
||||||
|
};
|
||||||
|
|
||||||
|
enum ProcessResult {
|
||||||
|
kSuccess, // Video frame data is successfully processed
|
||||||
|
kBypass, // Video frame data should bypass the current filter and flow to its successsors
|
||||||
|
kDrop, // Video Frame data should be discarded
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The IExtensionVideoFilter::Control class.
|
||||||
|
*
|
||||||
|
* This class defines the interfaces that the extension filter can leverage to interact with the SDK.
|
||||||
|
* The "IExtensionVideoFilter::Control" object will be passed to the filter when SDK invoke the filter's
|
||||||
|
* "start" interface.
|
||||||
|
*/
|
||||||
|
class Control : public RefCountInterface {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Filter can invoke this function to deliver the processed frame to SDK if the Process Mode is
|
||||||
|
* designated as "kAsync" by the filter via "getProcessMode".
|
||||||
|
* @param frame the processed video frame
|
||||||
|
* @return see @ref ProcessResult
|
||||||
|
*/
|
||||||
|
virtual ProcessResult deliverVideoFrame(agora::agora_refptr<IVideoFrame> frame) = 0;
|
||||||
|
/**
|
||||||
|
* @brief Filter can invoke this function to get the IVideoFrameMemoryPool object if a new IVideoFrame
|
||||||
|
* data object is needed.
|
||||||
|
*/
|
||||||
|
virtual agora::agora_refptr<IVideoFrameMemoryPool> getMemoryPool() = 0;
|
||||||
|
/**
|
||||||
|
* @brief Post an event and notify the end users.
|
||||||
|
* @param key '\0' ended string that describes the key of the event
|
||||||
|
* @param value '\0' ended string that describes the value of the event
|
||||||
|
*/
|
||||||
|
virtual int postEvent(const char* key, const char* value) = 0;
|
||||||
|
/**
|
||||||
|
* @brief print log to the SDK.
|
||||||
|
* @param level Log level @ref agora::commons::LOG_LEVEL
|
||||||
|
* @param format log formatter string
|
||||||
|
* @param ... variadic arguments
|
||||||
|
*/
|
||||||
|
virtual void printLog(commons::LOG_LEVEL level, const char* format, ...) = 0;
|
||||||
|
/**
|
||||||
|
* @brief Ask SDK to disable the current filter if a fatal error is detected
|
||||||
|
* @param error error code
|
||||||
|
* @param msg error message
|
||||||
|
*/
|
||||||
|
virtual void disableMe(int error, const char* msg) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief SDK will invoke this API first to get the filter's requested process mode @ref ProcessMode and threading model
|
||||||
|
* @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.
|
||||||
|
* @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.
|
||||||
|
*
|
||||||
|
* @param control object to @ref IExtensionFilter::Control that pass to the filter which can be used for future interaction with the SDK
|
||||||
|
* @return error code
|
||||||
|
*/
|
||||||
|
virtual int start(agora::agora_refptr<Control> control) = 0;
|
||||||
|
/**
|
||||||
|
* @brief SDK will invoke this API when the data stream is about to stop. Filter can perform cleanup jobs in this step
|
||||||
|
*
|
||||||
|
* @return error code
|
||||||
|
*/
|
||||||
|
virtual int stop() = 0;
|
||||||
|
/**
|
||||||
|
* @brief SDK will invoke this API every time before sending data to the filter. Filter can desigante the type @ref VideoFrameInfo::Type
|
||||||
|
* and format @ref MemPixelBuffer::Format of the next frame. SDK will then try to perform type / format conversion before sending data to
|
||||||
|
* the filter.
|
||||||
|
*
|
||||||
|
* @param type requested type of the next frame
|
||||||
|
* @param format requested formant of the next frame
|
||||||
|
*/
|
||||||
|
virtual void getVideoFormatWanted(VideoFrameData::Type& type, RawPixelBuffer::Format& format) = 0;
|
||||||
|
/**
|
||||||
|
* @brief SDK will invoke this API to send video frame to the filter if process mode is "Async". Filter invokes control's "deliverFrame"
|
||||||
|
* to send back the frame after processing.
|
||||||
|
*
|
||||||
|
* @param frame frame pending for processing
|
||||||
|
*/
|
||||||
|
virtual ProcessResult pendVideoFrame(agora::agora_refptr<IVideoFrame> frame) {
|
||||||
|
return OPTIONAL_PROCESSRESULT_SPECIFIER kBypass;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief SDK will invoke this API to send video frame to the filter if process mode is "Sync".
|
||||||
|
*
|
||||||
|
* @param frame frame pending for processing
|
||||||
|
*/
|
||||||
|
virtual ProcessResult adaptVideoFrame(agora::agora_refptr<IVideoFrame> in, agora::agora_refptr<IVideoFrame>& out) {
|
||||||
|
return OPTIONAL_PROCESSRESULT_SPECIFIER kBypass;
|
||||||
|
}
|
||||||
|
/* Occurs each time needs to get rotation apply.
|
||||||
|
*
|
||||||
|
* @return Determines whether to rotate.
|
||||||
|
* - true: need to rotate.
|
||||||
|
* - false: no rotate.
|
||||||
|
*/
|
||||||
|
virtual bool getRotationApplied() { return false; }
|
||||||
|
|
||||||
|
// NOTE: The following two interfaces should never be overriden!
|
||||||
|
virtual bool isExtensionFilter() { return true; }
|
||||||
|
virtual bool adaptVideoFrame(
|
||||||
|
const media::base::VideoFrame& capturedFrame,
|
||||||
|
media::base::VideoFrame& adaptedFrame) {
|
||||||
|
return -ERR_NOT_SUPPORTED;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The `IVideoSinkBase` class is the base class for the custom video sink.
|
||||||
|
*/
|
||||||
|
class IVideoSinkBase : public RefCountInterface {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Sets a private property in the `IVideoFilter` class.
|
||||||
|
*
|
||||||
|
* @param key The pointer to the property name.
|
||||||
|
* @param buf The pointer to the buffer of this private property.
|
||||||
|
* @param buf_size The buffer size of this private property.
|
||||||
|
* @return
|
||||||
|
* - The actual size of the private property, if the method call succeeds.
|
||||||
|
* - -1, if the method call fails.
|
||||||
|
*/
|
||||||
|
virtual int setProperty(const char* key, const void* buf, int buf_size) { return -1; }
|
||||||
|
/**
|
||||||
|
* Gets a private property in the `IVideoFilter` class.
|
||||||
|
*
|
||||||
|
* @param key The pointer to the property name.
|
||||||
|
* @param buf The pointer to the buffer of this private property.
|
||||||
|
* @param buf_size The buffer size of this private property.
|
||||||
|
* @return
|
||||||
|
* - The actual size of the private property, if the method call succeeds.
|
||||||
|
* - -1, if the method call fails.
|
||||||
|
*/
|
||||||
|
virtual int getProperty(const char* key, void* buf, int buf_size) { return -1; }
|
||||||
|
/**
|
||||||
|
* Occurs when the `IVideoSinkBase` object receives the video frame.
|
||||||
|
* @param videoFrame The reference to the video frame.
|
||||||
|
*/
|
||||||
|
virtual int onFrame(const media::base::VideoFrame& videoFrame) = 0;
|
||||||
|
/**
|
||||||
|
* Used internally to distinguish between external and internal sinks.
|
||||||
|
* External application should not override this interface.
|
||||||
|
*/
|
||||||
|
virtual bool isExternalSink() { return true; }
|
||||||
|
/**
|
||||||
|
* This function is invoked right before data stream starts.
|
||||||
|
* Custom sink can override this function for initialization.
|
||||||
|
* @return
|
||||||
|
* - `true`, if initialization succeeds.
|
||||||
|
* - `false`, if initialization fails.
|
||||||
|
*/
|
||||||
|
virtual bool onDataStreamWillStart() { return true; }
|
||||||
|
/**
|
||||||
|
* This function is invoked right before data stream stops.
|
||||||
|
* Custom sink can override this function for deinitialization.
|
||||||
|
*/
|
||||||
|
virtual void onDataStreamWillStop() { }
|
||||||
|
/**
|
||||||
|
* Whether to mirror the video frame.
|
||||||
|
* @return
|
||||||
|
* - true: mirror the video frame.
|
||||||
|
* - false: do not mirror the video frame.
|
||||||
|
*/
|
||||||
|
virtual bool applyMirror() { return false; }
|
||||||
|
/**
|
||||||
|
* Whether to rotate the video frame.
|
||||||
|
* @return
|
||||||
|
* - true: rotate the video frame.
|
||||||
|
* - false: do not rotate the video frame.
|
||||||
|
*/
|
||||||
|
virtual bool applyRotation() { return false; }
|
||||||
|
};
|
||||||
|
|
||||||
|
class IMediaExtensionObserver : public RefCountInterface {
|
||||||
|
public:
|
||||||
|
virtual ~IMediaExtensionObserver() {}
|
||||||
|
virtual void onEvent(const char* provider, const char* extension, const char* key, const char* json_value) __deprecated {}
|
||||||
|
virtual void onExtensionStopped(const char* provider, const char* extension) __deprecated {}
|
||||||
|
virtual void onExtensionStarted(const char* provider, const char* extension) __deprecated {}
|
||||||
|
virtual void onExtensionError(const char* provider, const char* extension, int error, const char* message) __deprecated {}
|
||||||
|
|
||||||
|
virtual bool needExtensionContext() {return false;} // callback with conetxt interface if true
|
||||||
|
virtual void onEventWithContext(const ExtensionContext& context, const char* key, const char* json_value) {}
|
||||||
|
virtual void onExtensionStoppedWithContext(const ExtensionContext& context) {}
|
||||||
|
virtual void onExtensionStartedWithContext(const ExtensionContext& context) {}
|
||||||
|
virtual void onExtensionErrorWithContext(const ExtensionContext& context, int error, const char* message) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The IAudioPcmDataSender class.
|
||||||
|
*
|
||||||
|
* In scenarios involving custom audio source, you can use the `IAudioPcmDataSender` class to send PCM audio data directly to the audio track. If the audio track is disabled, the sent audio data is automatically discarded.
|
||||||
|
*/
|
||||||
|
class IAudioPcmDataSender : public RefCountInterface {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Sends the PCM audio data to the local audio track.
|
||||||
|
*
|
||||||
|
* @param audio_data The PCM audio data to be sent.
|
||||||
|
* @param samples_per_channel The number of audio samples in 10 ms for each audio channel.
|
||||||
|
* @param bytes_per_sample The number of bytes in each sample.
|
||||||
|
* @param number_of_channels The number of audio channels.
|
||||||
|
* @param sample_rate The sample rate (Hz). The minimum value is 8000.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int sendAudioPcmData(
|
||||||
|
const void* audio_data, uint32_t capture_timestamp,
|
||||||
|
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)
|
||||||
|
|
||||||
|
protected:
|
||||||
|
~IAudioPcmDataSender() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The `IAudioEncodedFrameSender` class.
|
||||||
|
*
|
||||||
|
* In scenarios involving custom audio source, you can use the `IAudioEncodedFrameSender` class to
|
||||||
|
* send encoded audio data directly to the audio track. If the track is disabled, the sent audio
|
||||||
|
* data will be automatically discarded.
|
||||||
|
*/
|
||||||
|
class IAudioEncodedFrameSender : public RefCountInterface {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Sends the encoded audio frame to the local audio track.
|
||||||
|
*
|
||||||
|
* @param payload_data The pointer to the payload data.
|
||||||
|
* @param payload_size The payload size.
|
||||||
|
* @param audioFrameInfo The reference to the information of the audio frame:
|
||||||
|
* \ref agora::rtc::EncodedAudioFrameInfo "EncodedAudioFrameInfo".
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - `true`: Success.
|
||||||
|
* - `false`: Failure.
|
||||||
|
*/
|
||||||
|
virtual bool sendEncodedAudioFrame(const uint8_t* payload_data, size_t payload_size,
|
||||||
|
const EncodedAudioFrameInfo& audioFrameInfo) = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
~IAudioEncodedFrameSender() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
class IAudioEncodedFrameReceiver {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Occurs when the track receives an audio encodeed frame packet.
|
||||||
|
*
|
||||||
|
* @param packet The pointer to the audio packet.
|
||||||
|
* @param length The length of the packet.
|
||||||
|
* @param info The packet info.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
virtual bool onEncodedAudioFrameReceived (
|
||||||
|
const uint8_t *packet, size_t length, const media::base::AudioEncodedFrameInfo& info) = 0;
|
||||||
|
|
||||||
|
virtual ~IAudioEncodedFrameReceiver() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The IMediaPacketReceiver class. You can register a receiver in remote audio or video tracks to trigger
|
||||||
|
* callbacks when RTP/UDP packets are received.
|
||||||
|
*/
|
||||||
|
class IMediaPacketReceiver {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Occurs when the track receives a media packet.
|
||||||
|
*
|
||||||
|
* @param packet The pointer to the media packet.
|
||||||
|
* @param length The length of the packet.
|
||||||
|
* @param options The packet info.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
virtual bool onMediaPacketReceived(
|
||||||
|
const uint8_t *packet, size_t length, const agora::media::base::PacketOptions& options) = 0;
|
||||||
|
|
||||||
|
virtual ~IMediaPacketReceiver() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The IMediaControlPacketReceiver class.
|
||||||
|
*
|
||||||
|
* You can register a receiver in audio or video tracks to trigger callbacks
|
||||||
|
* when RTCP/UDP packets are received.
|
||||||
|
*/
|
||||||
|
class IMediaControlPacketReceiver {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Occurs when the track receives media control packet.
|
||||||
|
*
|
||||||
|
* @param packet The pointer to the media packet.
|
||||||
|
* @param length The length of the packet.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
virtual bool onMediaControlPacketReceived(uid_t uid, const uint8_t *packet, size_t length) = 0;
|
||||||
|
|
||||||
|
virtual ~IMediaControlPacketReceiver() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The `IMediaPacketSender` class.
|
||||||
|
*
|
||||||
|
* You can use the `IMediaPacketSender` class to create a LocalVideoTrack or LocalAudioTrack,
|
||||||
|
* and then send media packets directly to the track. The media packets are RTP/UDP packets that contain
|
||||||
|
* media payload. If the track is disabled, the packets will be automatically discarded.
|
||||||
|
*/
|
||||||
|
class IMediaPacketSender : public RefCountInterface {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Sends the frame packet to the local track.
|
||||||
|
*
|
||||||
|
* @param packet The pointer to the packet.
|
||||||
|
* @param length The packet size.
|
||||||
|
* @param options The packet information: {@link media::base::PacketOptions PacketOptions}.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - `true`: Success.
|
||||||
|
* - `false`: Failure.
|
||||||
|
*/
|
||||||
|
virtual int sendMediaPacket(const uint8_t *packet, size_t length,
|
||||||
|
const media::base::PacketOptions &options) = 0;
|
||||||
|
protected:
|
||||||
|
~IMediaPacketSender() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The `IMediaControlPacketSender` class.
|
||||||
|
*
|
||||||
|
* You can get the `IMediaControlPacketSender` class object from a video track or audio track,
|
||||||
|
* and then send media control packets directly. The media control packets are RTCP/UDP packets that contain
|
||||||
|
* media control payload. If the track is disabled, the packets will be automatically discarded.
|
||||||
|
*/
|
||||||
|
class IMediaControlPacketSender {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Sends the media control packet to a specified user.
|
||||||
|
* Currently, we only support sending packets through video tracks.
|
||||||
|
*
|
||||||
|
* @param userId ID of the user to send the packet to.
|
||||||
|
* @param packet The pointer to the packet.
|
||||||
|
* @param length The packet size.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - `true`: Success.
|
||||||
|
* - `false`: Failure.
|
||||||
|
*/
|
||||||
|
virtual int sendPeerMediaControlPacket(media::base::user_id_t userId,
|
||||||
|
const uint8_t *packet,
|
||||||
|
size_t length) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends the media transport control packet to all users.
|
||||||
|
* Currently, we only support sending packets through video tracks.
|
||||||
|
* @param packet The pointer to the packet.
|
||||||
|
* @param length The packet size.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - `true`: Success.
|
||||||
|
* - `false`: Failure.
|
||||||
|
*/
|
||||||
|
virtual int sendBroadcastMediaControlPacket(const uint8_t *packet, size_t length) = 0;
|
||||||
|
|
||||||
|
virtual ~IMediaControlPacketSender() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The `IAudioSinkBase` class is the base class for the audio sink. You can use this class to implement your own sink
|
||||||
|
* and add the sink to an audio track.
|
||||||
|
*/
|
||||||
|
class IAudioSinkBase : public RefCountInterface {
|
||||||
|
public:
|
||||||
|
/** Gets the audio frame.
|
||||||
|
*
|
||||||
|
* @param audioframe {@link media::base::AudioPcmFrame AudioPcmFrame}
|
||||||
|
* @return
|
||||||
|
* - `true`: Success.
|
||||||
|
* - `false`: Failure.
|
||||||
|
*/
|
||||||
|
virtual bool onAudioFrame(const media::base::AudioPcmFrame& audioFrame) = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
~IAudioSinkBase() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The `IVideoFrameSender` class.
|
||||||
|
*
|
||||||
|
* In scenarios involving custom video sources, you can use this class to send the video
|
||||||
|
* data directly to a video track. If the video track is disabled, the sent data will
|
||||||
|
* be automatically discarded.
|
||||||
|
*/
|
||||||
|
class IVideoFrameSender : public RefCountInterface {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Sends the video frame to the video track.
|
||||||
|
*
|
||||||
|
* @param videoFrame The reference to the video frame to send.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int sendVideoFrame(const media::base::ExternalVideoFrame& videoFrame) = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
~IVideoFrameSender() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The `IVideoEncodedImageSender` class.
|
||||||
|
*
|
||||||
|
* In scenarios involving custom video sources, you can use this class to send the encoded video data
|
||||||
|
* directly to the video track. If the video track is disabled, the sent video image will be
|
||||||
|
* automatically discarded.
|
||||||
|
*/
|
||||||
|
class IVideoEncodedImageSender : public RefCountInterface {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Sends the encoded video image to the video track.
|
||||||
|
* @param imageBuffer The video buffer.
|
||||||
|
* @param length The data length of the video data.
|
||||||
|
* @param videoEncodedFrameInfo The reference to the information of the encoded video frame:
|
||||||
|
* {@link EncodedVideoFrameInfo}.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - `true`: Success.
|
||||||
|
* - `false`: Failure.
|
||||||
|
*/
|
||||||
|
virtual bool sendEncodedVideoImage(const uint8_t* imageBuffer, size_t length,
|
||||||
|
const EncodedVideoFrameInfo& videoEncodedFrameInfo) = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
~IVideoEncodedImageSender() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The IVideoBeautyFilter class.
|
||||||
|
*/
|
||||||
|
class IVideoBeautyFilter : public IVideoFilter {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* The video image enhancement options.
|
||||||
|
*/
|
||||||
|
struct BeautyOptions {
|
||||||
|
/**
|
||||||
|
* The lightening contrast level.
|
||||||
|
*/
|
||||||
|
enum LIGHTENING_CONTRAST_LEVEL {
|
||||||
|
/**
|
||||||
|
* 0: Low contrast level.
|
||||||
|
*/
|
||||||
|
LIGHTENING_CONTRAST_LOW = 0,
|
||||||
|
/**
|
||||||
|
* (Default) Normal contrast level.
|
||||||
|
*/
|
||||||
|
LIGHTENING_CONTRAST_NORMAL,
|
||||||
|
/**
|
||||||
|
* High contrast level.
|
||||||
|
*/
|
||||||
|
LIGHTENING_CONTRAST_HIGH
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The contrast level, usually used with {@link lighteningLevel} to brighten the video:
|
||||||
|
* #LIGHTENING_CONTRAST_LEVEL.
|
||||||
|
*/
|
||||||
|
LIGHTENING_CONTRAST_LEVEL lighteningContrastLevel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The brightness level. The value ranges from 0.0 (original) to 1.0.
|
||||||
|
*/
|
||||||
|
float lighteningLevel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The sharpness level. The value ranges from 0.0 (original) to 1.0. This parameter is usually
|
||||||
|
* used to remove blemishes.
|
||||||
|
*/
|
||||||
|
float smoothnessLevel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The redness level. The value ranges from 0.0 (original) to 1.0. This parameter adjusts the
|
||||||
|
* red saturation level.
|
||||||
|
*/
|
||||||
|
float rednessLevel;
|
||||||
|
|
||||||
|
BeautyOptions(LIGHTENING_CONTRAST_LEVEL contrastLevel, float lightening, float smoothness,
|
||||||
|
float redness)
|
||||||
|
: lighteningContrastLevel(contrastLevel),
|
||||||
|
lighteningLevel(lightening),
|
||||||
|
smoothnessLevel(smoothness),
|
||||||
|
rednessLevel(redness) {}
|
||||||
|
|
||||||
|
BeautyOptions()
|
||||||
|
: lighteningContrastLevel(LIGHTENING_CONTRAST_NORMAL),
|
||||||
|
lighteningLevel(0),
|
||||||
|
smoothnessLevel(0),
|
||||||
|
rednessLevel(0) {}
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Sets the image enhancement options.
|
||||||
|
* @param enabled Whether to enable image enhancement.
|
||||||
|
* - `true`: Enable image enhancement.
|
||||||
|
* - `false`: Do not enable image enhancement.
|
||||||
|
* @param options The image enhancement options: BeautyOptions.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setBeautyEffectOptions(bool enabled, BeautyOptions options) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The `IVideoRenderer` class.
|
||||||
|
*/
|
||||||
|
class IVideoRenderer : public IVideoSinkBase {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Sets the render mode.
|
||||||
|
* @param renderMode The video render mode.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setRenderMode(media::base::RENDER_MODE_TYPE renderMode) = 0;
|
||||||
|
/**
|
||||||
|
* Sets the render mode of the view.
|
||||||
|
* @param view the view to set render mode.
|
||||||
|
* @param renderMode The video render mode.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setRenderMode(void* view, media::base::RENDER_MODE_TYPE renderMode) = 0;
|
||||||
|
/**
|
||||||
|
* Sets whether to mirror the video.
|
||||||
|
* @param mirror Whether to mirror the video:
|
||||||
|
* - `true`: Mirror the video.
|
||||||
|
* - `false`: Do not mirror the video.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setMirror(bool mirror) = 0;
|
||||||
|
/**
|
||||||
|
* Sets whether to mirror the video.
|
||||||
|
* @param view the view to set mirror mode.
|
||||||
|
* @param mirror Whether to mirror the video:
|
||||||
|
* - `true`: Mirror the video.
|
||||||
|
* - `false`: Do not mirror the video.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setMirror(void* view, bool mirror) = 0;
|
||||||
|
/**
|
||||||
|
* Sets the video display window.
|
||||||
|
* @param view The pointer to the video display window.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int setView(void* view) = 0;
|
||||||
|
/**
|
||||||
|
* Sets the video display window.
|
||||||
|
* @param view The pointer to the video display window.
|
||||||
|
* @param cropArea (Optional) Sets the relative location of the region to show. See Rectangle.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int addView(void* view, const Rectangle& cropArea) = 0;
|
||||||
|
/**
|
||||||
|
* Stops rendering the video view on the window.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int unsetView() = 0;
|
||||||
|
/**
|
||||||
|
* remove rendering the video view on the window.
|
||||||
|
* @return
|
||||||
|
* - 0: Success.
|
||||||
|
* - < 0: Failure.
|
||||||
|
*/
|
||||||
|
virtual int removeView(void* view) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
static const int kDeviceIdSize = 128;
|
||||||
|
|
||||||
|
class IVideoTrack;
|
||||||
|
/**
|
||||||
|
* The `IVideoFrameTransceiver` class.
|
||||||
|
*/
|
||||||
|
class IVideoFrameTransceiver : public RefCountInterface {
|
||||||
|
public:
|
||||||
|
virtual int getTranscodingDelayMs() = 0;
|
||||||
|
virtual int addVideoTrack(agora_refptr<IVideoTrack> track) = 0;
|
||||||
|
virtual int removeVideoTrack(agora_refptr<IVideoTrack> track) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,256 @@
|
||||||
|
//
|
||||||
|
// Agora SDK
|
||||||
|
//
|
||||||
|
// Copyright (c) 2019 Agora.io. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once // NOLINT(build/header_guard)
|
||||||
|
|
||||||
|
#include "AgoraBase.h"
|
||||||
|
|
||||||
|
namespace agora {
|
||||||
|
namespace rtc {
|
||||||
|
|
||||||
|
class IAudioPcmDataSender;
|
||||||
|
class IAudioEncodedFrameSender;
|
||||||
|
class IRemoteAudioMixerSource;
|
||||||
|
class ICameraCapturer;
|
||||||
|
class IScreenCapturer;
|
||||||
|
class IVideoMixerSource;
|
||||||
|
class IVideoFrameTransceiver;
|
||||||
|
class IVideoFrameSender;
|
||||||
|
class IVideoRenderer;
|
||||||
|
class IVideoFilter;
|
||||||
|
class IAudioFilter;
|
||||||
|
class IVideoSinkBase;
|
||||||
|
class IVideoEncodedImageSender;
|
||||||
|
class IMediaPlayerSource;
|
||||||
|
class IMediaPacketSender;
|
||||||
|
class IMediaStreamingSource;
|
||||||
|
class IScreenCapturer2;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The `IMediaNodeFactory` class.
|
||||||
|
*/
|
||||||
|
class IMediaNodeFactory : public RefCountInterface {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Creates a PCM audio data sender.
|
||||||
|
*
|
||||||
|
* This method creates an `IAudioPcmDataSender` object, which can be used by \ref agora::base::IAgoraService::createCustomAudioTrack(agora_refptr< rtc::IAudioPcmDataSender > audioSource) "createCustomAudioTrack" to send PCM audio data.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - The pointer to \ref agora::rtc::IAudioPcmDataSender "IAudioPcmDataSender": Success.
|
||||||
|
* - A null pointer: Failure.
|
||||||
|
*/
|
||||||
|
virtual agora_refptr<IAudioPcmDataSender> createAudioPcmDataSender() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an encoded audio data sender.
|
||||||
|
*
|
||||||
|
* This method creates an IAudioEncodedFrameSender object, which can be used by \ref agora::base::IAgoraService::createCustomAudioTrack(agora_refptr< rtc::IAudioEncodedFrameSender > audioSource, TMixMode mixMode) "createCustomAudioTrack" to send encoded audio data.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - The pointer to IAudioEncodedFrameSender: Success.
|
||||||
|
* - A null pointer: Failure.
|
||||||
|
*/
|
||||||
|
virtual agora_refptr<IAudioEncodedFrameSender> 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<IRemoteAudioMixerSource> createRemoteAudioMixerSource() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a camera capturer.
|
||||||
|
*
|
||||||
|
* Once a camera capturer object is created, you can use the video data captured by the camera as
|
||||||
|
* the custom video source.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - The pointer to ICameraCapturer: Success.
|
||||||
|
* - A null pointer: Failure.
|
||||||
|
*/
|
||||||
|
virtual agora_refptr<ICameraCapturer> createCameraCapturer() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a screen capturer.
|
||||||
|
*
|
||||||
|
* Once a screen capturer object is created, you can use the screen video data as the custom video
|
||||||
|
* source.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - The pointer to IScreenCapturer: Success.
|
||||||
|
* - A null pointer: Failure.
|
||||||
|
*/
|
||||||
|
virtual agora_refptr<IScreenCapturer> createScreenCapturer() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a video mixer.
|
||||||
|
*
|
||||||
|
* Once a video mixer object is created, you can use the video mixer data as the custom video
|
||||||
|
* source.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - The pointer to IVideoMixerSource: Success.
|
||||||
|
* - A null pointer: Failure.
|
||||||
|
*/
|
||||||
|
virtual agora_refptr<IVideoMixerSource> createVideoMixer() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a video transceiver.
|
||||||
|
*
|
||||||
|
* Once a video transceiver object is created, you can use the video transceiver data as the custom video
|
||||||
|
* source.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - The pointer to IVideoFrameTransceiver: Success.
|
||||||
|
* - A null pointer: Failure.
|
||||||
|
*/
|
||||||
|
virtual agora_refptr<IVideoFrameTransceiver> createVideoFrameTransceiver() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a video frame sender.
|
||||||
|
*
|
||||||
|
* This method creates an `IVideoFrameSender` object, which can be used by \ref agora::base::IAgoraService::createCustomVideoTrack(agora_refptr<rtc::IVideoFrameSender> videoSource) "createCustomVideoTrack" to
|
||||||
|
* send the custom video data.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - The pointer to \ref agora::rtc::IVideoFrameSender "IVideoFrameSender": Success.
|
||||||
|
* - A null pointer: Failure.
|
||||||
|
*/
|
||||||
|
virtual agora_refptr<IVideoFrameSender> createVideoFrameSender() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an encoded video image sender.
|
||||||
|
*
|
||||||
|
* This method creates an `IVideoEncodedImageSender` object, which can be used by \ref agora::base::IAgoraService::createCustomVideoTrack(agora_refptr<rtc::IVideoEncodedImageSender> videoSource, SenderOptions& options) "createCustomVideoTrack" to send the encoded video data.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - The pointer to `IVideoEncodedImageSender`: Success.
|
||||||
|
* - A null pointer: Failure.
|
||||||
|
*/
|
||||||
|
virtual agora_refptr<IVideoEncodedImageSender> createVideoEncodedImageSender() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a built-in video renderer.
|
||||||
|
*
|
||||||
|
* @param view The video window view.
|
||||||
|
* @return
|
||||||
|
* - The pointer to `IVideoRenderer`: Success.
|
||||||
|
* - A null pointer: Failure.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
virtual agora_refptr<IVideoRenderer> createVideoRenderer() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an audio filter for the extension.
|
||||||
|
*
|
||||||
|
* This method creates an `IAudioFilter` object, which can be used to filter the audio data from the
|
||||||
|
* inside extension.
|
||||||
|
*
|
||||||
|
* @param provider_name provider name string.
|
||||||
|
* @param extension_name extension name string.
|
||||||
|
* @return
|
||||||
|
* - The pointer to IAudioFilter: Success.
|
||||||
|
* - A null pointer: Failure.
|
||||||
|
*/
|
||||||
|
virtual agora_refptr<IAudioFilter> createAudioFilter(const char* provider_name, const char* extension_name) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a video filter for the extension.
|
||||||
|
*
|
||||||
|
* This method creates an `IVideoFilter` object, which can be used to filter the video from inside
|
||||||
|
* extension.
|
||||||
|
*
|
||||||
|
* @param provider_name provider name string.
|
||||||
|
* @param extension_name extension name string.
|
||||||
|
* @return
|
||||||
|
* - The pointer to IVideoFilter: Success.
|
||||||
|
* - A null pointer: Failure.
|
||||||
|
*/
|
||||||
|
virtual agora_refptr<IVideoFilter> createVideoFilter(const char* provider_name, const char* extension_name) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a video sink for the extension.
|
||||||
|
*
|
||||||
|
* This method creates an IVideoSinkBase object, which can be used to receive the video from the
|
||||||
|
* inside extension.
|
||||||
|
*
|
||||||
|
* @param provider_name provider name string.
|
||||||
|
* @param extension_name extension name string.
|
||||||
|
* @return
|
||||||
|
* - The pointer to IVideoSinkBase: Success.
|
||||||
|
* - A null pointer: Failure.
|
||||||
|
*/
|
||||||
|
virtual agora_refptr<IVideoSinkBase> createVideoSink(const char* provider_name, const char* extension_name) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a media player source object and returns the pointer.
|
||||||
|
*
|
||||||
|
* @param type The type of media player source you want to create.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - The pointer to \ref rtc::IMediaPlayerSource "IMediaPlayerSource", if the method call
|
||||||
|
* succeeds.
|
||||||
|
* - A null pointer: Failure.
|
||||||
|
*/
|
||||||
|
virtual agora_refptr<IMediaPlayerSource> createMediaPlayerSource(media::base::MEDIA_PLAYER_SOURCE_TYPE type = agora::media::base::MEDIA_PLAYER_SOURCE_DEFAULT) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Creates a media streaming source object and returns the pointer.
|
||||||
|
*
|
||||||
|
* @param type The type of media streaming source you want to create.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - The pointer to \ref rtc::IMediaStreamingSource "IMediaStreamingSource", if the method call
|
||||||
|
* succeeds.
|
||||||
|
* - A null pointer: Failure.
|
||||||
|
*/
|
||||||
|
virtual agora_refptr<IMediaStreamingSource> createMediaStreamingSource() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a media packet sender object and returns the pointer.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - The pointer to \ref rtc::IMediaPacketSender "IMediaPacketSender", if the method call
|
||||||
|
* succeeds.
|
||||||
|
* - A null pointer: Failure.
|
||||||
|
*/
|
||||||
|
virtual agora_refptr<IMediaPacketSender> createMediaPacketSender() = 0;
|
||||||
|
|
||||||
|
#if defined(__ANDROID__) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE)
|
||||||
|
/**
|
||||||
|
* Creates screen capture source extension with given provider&extension names
|
||||||
|
* @param provider_name provider name string.
|
||||||
|
* @param extension_name extension name string.
|
||||||
|
* @return
|
||||||
|
* - The pointer to IScreenCapturer: Success.
|
||||||
|
* - A null pointer: Failure.
|
||||||
|
*/
|
||||||
|
virtual agora_refptr<IScreenCapturer2> createScreenCapturer2(const char* provider_name, const char* extension_name) = 0;
|
||||||
|
#else
|
||||||
|
/**
|
||||||
|
* Creates screen capture source extension with given provider&extension names
|
||||||
|
* @param provider_name provider name string.
|
||||||
|
* @param extension_name extension name string.
|
||||||
|
* @return
|
||||||
|
* - The pointer to IScreenCapturer: Success.
|
||||||
|
* - A null pointer: Failure.
|
||||||
|
*/
|
||||||
|
virtual agora_refptr<IScreenCapturer> createScreenCapturer(const char* provider_name, const char* extension_name) = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
protected:
|
||||||
|
~IMediaNodeFactory() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace rtc
|
||||||
|
} // namespace agora
|
|
@ -0,0 +1,44 @@
|
||||||
|
//
|
||||||
|
// Agora SDK
|
||||||
|
//
|
||||||
|
// Copyright (c) 2020 Agora.io. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "AgoraRefPtr.h"
|
||||||
|
|
||||||
|
namespace agora {
|
||||||
|
namespace rtc {
|
||||||
|
|
||||||
|
class IRemoteAudioTrack;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The IRemoteAudioMixerSource class abstracts a multi-in-single-out audio source which receives audio
|
||||||
|
* streams from multiple remote audio tracks and generate mixed audio stream in user defined output
|
||||||
|
* format.
|
||||||
|
*/
|
||||||
|
class IRemoteAudioMixerSource : public RefCountInterface {
|
||||||
|
public:
|
||||||
|
virtual ~IRemoteAudioMixerSource() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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<IRemoteAudioTrack> track) = 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<IRemoteAudioTrack> track) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the delay time for mix.
|
||||||
|
*/
|
||||||
|
virtual int getMixDelay() const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace rtc
|
||||||
|
} // namespace agora
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue