Skip to content

Commit cfe4b1a

Browse files
windows api-example 4.6.0
1 parent b3820cf commit cfe4b1a

6 files changed

Lines changed: 424 additions & 90 deletions

File tree

windows/APIExample/APIExample/Advanced/Beauty2.0/CDlgBeauty2.0.cpp

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,13 @@ bool CDlgBeauty2::InitAgora()
184184
m_initialize = true;
185185
m_lstInfo.InsertString(m_lstInfo.GetCount(), _T("initialize success"));
186186

187-
188187
CString strInfo;
189188
ret = m_rtcEngine->enableExtension("agora_video_filters_clear_vision", "clear_vision", true);
190189
strInfo.Format(_T("enableExtension: %d"), ret);
191190
m_lstInfo.InsertString(m_lstInfo.GetCount(), strInfo);
192191
m_lstInfo.InsertString(m_lstInfo.GetCount(), _T("agora_video_filters_clear_vision"));
193192
m_lstInfo.InsertString(m_lstInfo.GetCount(), _T("clear_vision"));
193+
194194
//enable video in the engine.
195195
m_rtcEngine->enableVideo();
196196
m_lstInfo.InsertString(m_lstInfo.GetCount(), _T("enable video"));
@@ -216,10 +216,14 @@ bool CDlgBeauty2::InitAgora()
216216

217217
return true;
218218
}
219+
219220
//UnInitialize the Agora SDK
220221
void CDlgBeauty2::UnInitAgora()
221222
{
222223
if (m_rtcEngine) {
224+
// 清理美颜资源
225+
CleanupBeautyResources();
226+
223227
if (m_joinChannel) {
224228
//leave channel primary camera
225229
m_joinChannel = !m_rtcEngine->leaveChannel();
@@ -250,6 +254,22 @@ void CDlgBeauty2::UnInitAgora()
250254
}
251255
}
252256

257+
void CDlgBeauty2::CleanupBeautyResources()
258+
{
259+
if (m_videoEffectObject && m_rtcEngine) {
260+
// 销毁VideoEffectObject
261+
m_rtcEngine->destroyVideoEffectObject(m_videoEffectObject);
262+
m_videoEffectObject = nullptr;
263+
264+
// 禁用扩展
265+
m_rtcEngine->enableExtension(
266+
"agora_video_filters_clear_vision",
267+
"clear_vision",
268+
false,
269+
agora::media::PRIMARY_CAMERA_SOURCE
270+
);
271+
}
272+
}
253273

254274
//Initialize the Ctrl Text.
255275
void CDlgBeauty2::InitCtrlText()
@@ -343,7 +363,6 @@ BOOL CDlgBeauty2::OnInitDialog()
343363
ResumeStatus();
344364

345365
return TRUE; // return TRUE unless you set the focus to a control
346-
347366
}
348367

349368
void CDlgBeauty2::SetBeauty()
@@ -526,11 +545,22 @@ void CDlgBeauty2::OnNMCustomdrawSliderBrihtness(NMHDR* pNMHDR, LRESULT* pResult)
526545
void CDlgBeauty2::OnBnClickedCheckExtention()
527546
{
528547
int checked = mCkExtention.GetCheck();
529-
if (checked)
530-
{
531-
mBeautyDlgEx->ShowWindow(SW_SHOW);
532-
}
533-
else {
534-
mBeautyDlgEx->ShowWindow(SW_HIDE);
548+
if (checked) {
549+
if (mBeautyDlgEx) {
550+
mBeautyDlgEx->ShowWindow(SW_SHOW);
551+
}
552+
} else {
553+
if (mBeautyDlgEx) {
554+
mBeautyDlgEx->ShowWindow(SW_HIDE);
555+
}
535556
}
536557
}
558+
559+
CString CDlgBeauty2::GetExePath()
560+
{
561+
TCHAR szPath[MAX_PATH];
562+
GetModuleFileName(NULL, szPath, MAX_PATH);
563+
CString strExePath = szPath;
564+
int nPos = strExePath.ReverseFind('\\');
565+
return strExePath.Left(nPos); // 去掉exe文件名,得到目录路径
566+
}

windows/APIExample/APIExample/Advanced/Beauty2.0/CDlgBeauty2.0.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class CBeautyEventHandler2 : public agora::rtc::IRtcEngineEventHandler
2424
is called without a user ID specified. The server will automatically assign one
2525
parameters:
2626
channel:channel name.
27-
uid: user ID¡£If the UID is specified in the joinChannel, that ID is returned here;
27+
uid: user ID��If the UID is specified in the joinChannel, that ID is returned here;
2828
Otherwise, use the ID automatically assigned by the Agora server.
2929
elapsed: The Time from the joinChannel until this event occurred (ms).
3030
*/
@@ -73,9 +73,13 @@ class CDlgBeauty2 : public CDialogEx
7373
private:
7474
void SetBeauty();
7575
void SetColorful();
76+
void InitializeBeautyResources();
77+
void CleanupBeautyResources();
78+
CString GetExePath();
7679
bool m_initialize = false;
7780
bool m_joinChannel = false;
7881
agora::rtc::IRtcEngine* m_rtcEngine = nullptr;
82+
agora::rtc::IVideoEffectObject* m_videoEffectObject = nullptr;
7983
CBeautyEventHandler2 m_eventHandler;
8084
CAGVideoWnd m_videoWnds[2];
8185
CDlgBeautyEx2* mBeautyDlgEx;

0 commit comments

Comments
 (0)