Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a7c1cb3

Browse files
committed
[Windows]perfect Media Encrypt case(NMS-9807).
1 parent b268519 commit a7c1cb3

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

windows/APIExample/APIExample/Advanced/MediaEncrypt/CAgoraMediaEncryptDlg.cpp

100644100755
Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ void CAgoraMediaEncryptDlg::ResumeStatus()
144144
m_lstInfo.ResetContent();
145145
m_edtEncryptKey.SetWindowText(_T(""));
146146
m_staDetails.SetWindowText(_T(""));
147+
m_btnSetEncrypt.EnableWindow(TRUE);
147148
m_joinChannel = false;
148149
m_initialize = false;
149150
m_setEncrypt = false;
@@ -156,10 +157,18 @@ BOOL CAgoraMediaEncryptDlg::OnInitDialog()
156157
m_localVideoWnd.Create(NULL, NULL, WS_CHILD | WS_VISIBLE | WS_BORDER | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, CRect(0, 0, 1, 1), this, ID_BASEWND_VIDEO + 100);
157158
RECT rcArea;
158159
m_staVideoArea.GetClientRect(&rcArea);
160+
int halfWidth = (rcArea.right - rcArea.left) / 2;
161+
rcArea.right = rcArea.left + halfWidth;
159162
m_localVideoWnd.MoveWindow(&rcArea);
160163
m_localVideoWnd.ShowWindow(SW_SHOW);
161-
int nIndex = 0;
164+
m_remoteVideoWnd.Create(NULL, NULL, WS_CHILD | WS_VISIBLE | WS_BORDER | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, CRect(0, 0, 1, 1), this, ID_BASEWND_VIDEO + 101);
165+
rcArea.left = rcArea.right;
166+
rcArea.right = rcArea.left + halfWidth;
167+
m_remoteVideoWnd.MoveWindow(&rcArea);
168+
m_remoteVideoWnd.ShowWindow(SW_SHOW);
169+
m_remoteVideoWnd.SetUID(0);
162170

171+
int nIndex = 0;
163172
//m_cmbEncryptMode.InsertString(nIndex++, _T("aes-128-xts"));
164173
//m_cmbEncryptMode.InsertString(nIndex++, _T("aes-128-ecb"));
165174
//m_cmbEncryptMode.InsertString(nIndex++, _T("aes-256-xts"));
@@ -278,6 +287,7 @@ LRESULT CAgoraMediaEncryptDlg::OnEIDJoinChannelSuccess(WPARAM wParam, LPARAM lPa
278287
strInfo.Format(_T("%s:join success, uid=%u"), getCurrentTime(), wParam);
279288
m_lstInfo.InsertString(m_lstInfo.GetCount(), strInfo);
280289
m_localVideoWnd.SetUID(wParam);
290+
m_btnSetEncrypt.EnableWindow(FALSE);
281291
//notify parent window
282292
::PostMessage(GetParent()->GetSafeHwnd(), WM_MSGID(EID_JOINCHANNEL_SUCCESS), TRUE, 0);
283293
return 0;
@@ -293,6 +303,7 @@ LRESULT CAgoraMediaEncryptDlg::OnEIDLeaveChannel(WPARAM wParam, LPARAM lParam)
293303
CString strInfo;
294304
strInfo.Format(_T("leave channel success %s"), getCurrentTime());
295305
m_lstInfo.InsertString(m_lstInfo.GetCount(), strInfo);
306+
m_btnSetEncrypt.EnableWindow(TRUE);
296307
::PostMessage(GetParent()->GetSafeHwnd(), WM_MSGID(EID_JOINCHANNEL_SUCCESS), FALSE, 0);
297308
return 0;
298309
}
@@ -301,8 +312,19 @@ LRESULT CAgoraMediaEncryptDlg::OnEIDLeaveChannel(WPARAM wParam, LPARAM lParam)
301312
LRESULT CAgoraMediaEncryptDlg::OnEIDUserJoined(WPARAM wParam, LPARAM lParam)
302313
{
303314
CString strInfo;
304-
strInfo.Format(_T("%u joined"), wParam);
315+
uid_t remoteUid = wParam;
316+
strInfo.Format(_T("%u joined"), remoteUid);
305317
m_lstInfo.InsertString(m_lstInfo.GetCount(), strInfo);
318+
319+
if (m_remoteVideoWnd.GetUID() == 0) {
320+
m_remoteVideoWnd.SetUID(remoteUid);
321+
322+
VideoCanvas canvas;
323+
canvas.view = m_remoteVideoWnd.GetSafeHwnd();
324+
canvas.renderMode = agora::media::base::RENDER_MODE_HIDDEN;
325+
canvas.uid = remoteUid;
326+
m_rtcEngine->setupRemoteVideo(canvas);
327+
}
306328
return 0;
307329
}
308330

@@ -316,6 +338,16 @@ LRESULT CAgoraMediaEncryptDlg::OnEIDUserOffline(WPARAM wParam, LPARAM lParam)
316338
strInfo.Format(_T("%u offline, reason:%d"), remoteUid, lParam);
317339
m_lstInfo.InsertString(m_lstInfo.GetCount(), strInfo);
318340

341+
if (m_remoteVideoWnd.GetUID() == remoteUid) {
342+
m_remoteVideoWnd.SetUID(0);
343+
m_remoteVideoWnd.Reset();
344+
345+
VideoCanvas canvas;
346+
canvas.view = nullptr;
347+
canvas.uid = remoteUid;
348+
m_rtcEngine->setupRemoteVideo(canvas);
349+
}
350+
319351
return 0;
320352
}
321353

windows/APIExample/APIExample/Advanced/MediaEncrypt/CAgoraMediaEncryptDlg.h

100644100755
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ class CAgoraMediaEncryptDlg : public CDialogEx
115115
bool m_setEncrypt = false;
116116
IRtcEngine* m_rtcEngine = nullptr;
117117
CAGVideoWnd m_localVideoWnd;
118+
CAGVideoWnd m_remoteVideoWnd;
118119
CAgoraMediaEncryptHandler m_eventHandler;
119120
// agora sdk message window handler
120121
LRESULT OnEIDJoinChannelSuccess(WPARAM wParam, LPARAM lParam);

0 commit comments

Comments
 (0)