@@ -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
220221void 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.
255275void 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
349368void CDlgBeauty2::SetBeauty ()
@@ -526,11 +545,22 @@ void CDlgBeauty2::OnNMCustomdrawSliderBrihtness(NMHDR* pNMHDR, LRESULT* pResult)
526545void 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+ }
0 commit comments