Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENDOC-277 Rtc indention #1560

Merged
merged 2 commits into from
Jul 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<PlatformWrapper platform="macos">
```swift
func rtcEngine(_ engine: AgoraRtcEngineKit,
channelMediaRelayStateDidChange state: AgoraChannelMediaRelayState, error: AgoraChannelMediaRelayError) {
channelMediaRelayStateDidChange state: AgoraChannelMediaRelayState,
error: AgoraChannelMediaRelayError) {
// This example shows toast messages when the relay state changes,
// a production level app needs to handle state change properly.
switch state {
Expand Down Expand Up @@ -36,7 +37,8 @@ func rtcEngine(_ engine: AgoraRtcEngineKit,
<PlatformWrapper platform="ios">
```swift
func rtcEngine(_ engine: AgoraRtcEngineKit,
channelMediaRelayStateDidChange state: AgoraChannelMediaRelayState, error: AgoraChannelMediaRelayError) {
channelMediaRelayStateDidChange state: AgoraChannelMediaRelayState,
error: AgoraChannelMediaRelayError) {
// This example shows toast messages when the relay state changes,
// a production level app needs to handle state change properly.
switch state {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

<PlatformWrapper platform="macos">
```swift
@objc func mediaPlayerBtnClicked(sender: NSButton!) {
@objc func mediaPlayerBtnClicked(sender: NSButton!) {
// Initialize the mediaPlayer and open a media file
if (mediaPlayer == nil) {
// Create an instance of the media player
Expand Down Expand Up @@ -42,7 +42,7 @@
</PlatformWrapper>
<PlatformWrapper platform="ios">
```swift
@objc func mediaPlayerBtnClicked(sender: UIButton!) {
@objc func mediaPlayerBtnClicked(sender: UIButton!) {
// Initialize the mediaPlayer and open a media file
if (mediaPlayer == nil) {
// Create an instance of the media player
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

```javascript
AgoraRTC.createMicrophoneAudioTrack({
AEC: false, // Turn off echo cancellation
AGC: false, // Turn off gain control
ANS: false, // Turn off noise reduction
AEC: false, // Turn off echo cancellation
AGC: false, // Turn off gain control
ANS: false, // Turn off noise reduction
}).then(/**...**/);
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,26 @@ To implement cross-channel media stream relay in your <Vpl k="CLIENT" />, take t
During cross-channel media stream relay, the SDK reports changes in the status of media stream relay through the `onChannelMediaRelayStateChanged` callback. Implement relevant business logic based on the [status codes](#status-codes).

```swift
func rtcEngine(_ engine: AgoraRtcEngineKit, channelMediaRelayStateDidChange state: AgoraChannelMediaRelayState, error: AgoraChannelMediaRelayError) {
func rtcEngine(_ engine: AgoraRtcEngineKit,
channelMediaRelayStateDidChange state: AgoraChannelMediaRelayState,
error: AgoraChannelMediaRelayError) {

LogUtils.log(message: "channelMediaRelayStateDidChange: \(state.rawValue) error \(error.rawValue)", level: .info)
isProcessing = false

switch state {
case .running:
isRelaying = true
case .failure:
showAlert(message: "Media Relay Failed: \(error.rawValue)")
isRelaying = false
case .idle:
isRelaying = false
default: break
case .running:
isRelaying = true

case .failure:
showAlert(message: "Media Relay Failed: \(error.rawValue)")
isRelaying = false

case .idle:
isRelaying = false

default:
break
}
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,14 @@ To implement cross-channel media stream relay in your <Vpl k="CLIENT" />, take t
During cross-channel media stream relay, the SDK reports changes in the status of media stream relay through the `onChannelMediaRelayStateChanged` callback. Implement relevant business logic based on the [status codes](#status-codes).

```cpp
class CAgoraCrossChannelEventHandler : public IRtcEngineEventHandler
{
virtual void onChannelMediaRelayStateChanged(CHANNEL_MEDIA_RELAY_STATE state, CHANNEL_MEDIA_RELAY_ERROR code)override {
class CAgoraCrossChannelEventHandler : public IRtcEngineEventHandler {
virtual void onChannelMediaRelayStateChanged(
CHANNEL_MEDIA_RELAY_STATE state,
CHANNEL_MEDIA_RELAY_ERROR code) override {
if (m_hMsgHanlder)
::PostMessage(m_hMsgHanlder, WM_MSGID(EID_CHANNEL_MEDIA_RELAY_STATE_CHNAGENED), state, code);
::PostMessage(m_hMsgHanlder,
WM_MSGID(EID_CHANNEL_MEDIA_RELAY_STATE_CHNAGENED),
state, code);
}
};
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,18 @@ Take the following steps to implement this workflow:
</Admonition>

```cpp
void MultiVideoSourceTracksYUVReaderHander::OnYUVRead(int width, int height, unsigned char* buffer, int size)
{
void MultiVideoSourceTracksYUVReaderHander::OnYUVRead(int width, int height,
unsigned char* buffer,
int size) {
if (m_mediaEngine == nullptr || m_rtcEngine == nullptr) {
return;
}

// Set the video pixel format to I420
m_videoFrame.format = agora::media::base::VIDEO_PIXEL_I420;
// Set the video data type to raw data
m_videoFrame.type = agora::media::base::ExternalVideoFrame::VIDEO_BUFFER_TYPE::VIDEO_BUFFER_RAW_DATA;
m_videoFrame.type = agora::media::base::ExternalVideoFrame::
VIDEO_BUFFER_TYPE::VIDEO_BUFFER_RAW_DATA;
// Pass the width, height, and buffer of the captured YUV video data to videoFrame
m_videoFrame.height = height;
m_videoFrame.stride = width;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,60 +22,59 @@ To add built-in media stream encryption to your <Vpl k="CLIENT" />, refer to the
To implement this logic, refer to the following code:

```cpp
#include <boost/algorithm/string/trim.hpp>
#include <boost/archive/iterators/base64_from_binary.hpp>
#include <boost/archive/iterators/binary_from_base64.hpp>
#include <boost/archive/iterators/transform_width.hpp>
#include <boost/range/algorithm/copy.hpp>

namespace detail
{
using Base64FromBinary = boost::archive::iterators::base64_from_binary<
boost::archive::iterators::transform_width<const char*, 6, 8>>;

using BinaryFromBase64 = boost::archive::iterators::transform_width<
boost::archive::iterators::binary_from_base64<std::string::const_iterator>,
8, 6>;
}

void decodeBase64(const std::string& encoded, std::vector<uint8_t>& out)
{
auto unpadded = encoded;

const auto num_padded = std::count(begin(encoded), end(encoded), '=');
std::replace(begin(unpadded), end(unpadded), '=', 'A'); // A_64 == \0

std::string decoded{detail::BinaryFromBase64{begin(unpadded)},
detail::BinaryFromBase64{begin(unpadded) + unpadded.length()}};

decoded.erase(end(decoded) - num_padded, end(decoded));
std::copy(begin(decoded), end(decoded), out.begin());
}

// Initialize the rtcEngine before calling this method
int enableEncryption() {
std::string secret;
std::string kdfSaltBase64;
std::vector<uint8_t> kdfSalt;
for (int i = 0; i < 32; ++i) {
kdfSalt.push_back(0);
}
if(!getSecretAndSaltFromSever(secret, kdfSaltBase64))
return -1;
if(rtcEngine && decodeBase64(kdfSaltBase64, kdfSalt)) {
// Create an instance of EncryptionConfig
agora::rtc::EncryptionConfig config;
// Set the encryption mode to AES_128_GCM2
config.encryptionMode = AES_128_GCM2;
// Set the encryption key
config.encryptionKey = secret.c_str();
// Set the sault
memcpy(config.encryptionKdfSalt, kdfSalt.data(), sizeof(config.encryptionKdfSalt));
// Turn on built-in encryption
return rtcEngine->enableEncryption(true, config);
}
return -1;
}
#include <boost/algorithm/string/trim.hpp>
#include <boost/archive/iterators/base64_from_binary.hpp>
#include <boost/archive/iterators/binary_from_base64.hpp>
#include <boost/archive/iterators/transform_width.hpp>
#include <boost/range/algorithm/copy.hpp>

namespace detail {
using Base64FromBinary = boost::archive::iterators::base64_from_binary<
boost::archive::iterators::transform_width<const char*, 6, 8>>;

using BinaryFromBase64 = boost::archive::iterators::transform_width<
boost::archive::iterators::binary_from_base64<std::string::const_iterator>,
8, 6>;
}

void decodeBase64(const std::string& encoded, std::vector<uint8_t>& out) {
auto unpadded = encoded;

const auto num_padded = std::count(begin(encoded), end(encoded), '=');
std::replace(begin(unpadded), end(unpadded), '=', 'A'); // A_64 == \0

std::string decoded{
detail::BinaryFromBase64{begin(unpadded)},
detail::BinaryFromBase64{begin(unpadded) + unpadded.length()}};

decoded.erase(end(decoded) - num_padded, end(decoded));
std::copy(begin(decoded), end(decoded), out.begin());
}

// Initialize the rtcEngine before calling this method
int enableEncryption() {
std::string secret;
std::string kdfSaltBase64;
std::vector<uint8_t> kdfSalt;
for (int i = 0; i < 32; ++i) {
kdfSalt.push_back(0);
}
if (!getSecretAndSaltFromSever(secret, kdfSaltBase64)) return -1;
if (rtcEngine && decodeBase64(kdfSaltBase64, kdfSalt)) {
// Create an instance of EncryptionConfig
agora::rtc::EncryptionConfig config;
// Set the encryption mode to AES_128_GCM2
config.encryptionMode = AES_128_GCM2;
// Set the encryption key
config.encryptionKey = secret.c_str();
// Set the sault
memcpy(config.encryptionKdfSalt, kdfSalt.data(),
sizeof(config.encryptionKdfSalt));
// Turn on built-in encryption
return rtcEngine->enableEncryption(true, config);
}
return -1;
}
```

The sample code utilizes Boost, a third-party library, which you can download [here](https://boostorg.jfrog.io/artifactory/main/release/).
Expand Down
Loading
Loading