Skip to content

Commit 1b4b2ad

Browse files
committed
发布TRTC C++ SDK 6.9.0.8315
1. 支持软件/硬件音量设置。 2. 支持BGM是否本地远端音量分开设置。 3. 支持本地录制模块。 4. 支持自定义直播流ID。 5. 支持更纯音频、音视频、音频+画布等更丰富的混流设置。 6. bug/crash fix。 (C# 优化)
1 parent d678d2b commit 1b4b2ad

File tree

3 files changed

+67
-34
lines changed

3 files changed

+67
-34
lines changed

Windows/CSharpDemo/TRTCDeviceTestForm.cs

+10
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,16 @@ public void OnTestSpeakerVolume(uint volume)
212212
}
213213
}
214214

215+
public void OnPlayBGMComplete(TXLiteAVError errCode)
216+
{
217+
this.bgmTestBtn.Text = "启动BGM测试";
218+
}
219+
220+
public void onAudioEffectFinished(int effectId, int code)
221+
{
222+
this.audioEffectTestBtn.Text = "启动音效测试";
223+
}
224+
215225
private void OnExitPicBoxClick(object sender, EventArgs e)
216226
{
217227
this.Hide();

Windows/CSharpDemo/TRTCMainForm.cs

+28-28
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@ public TRTCMainForm(TRTCLoginForm loginForm)
8181
InitializeComponent();
8282

8383
this.Disposed += new EventHandler(OnDisposed);
84-
// 窗口退出事件监听
85-
this.FormClosing += new FormClosingEventHandler(OnExitLabelClick);
8684

8785
// 初始化数据。
8886
mLoginForm = loginForm;
@@ -150,23 +148,17 @@ private void RemoveCustomVideoView(Control parent, string userId, TRTCVideoStrea
150148
if (mVideoViews.TryGetValue(key, out videoView))
151149
{
152150
videoView.RemoveEngine(mTRTCCloud);
153-
parent.Controls.Remove(videoView);
154151
mVideoViews.Remove(key);
152+
parent.Controls.Remove(videoView);
155153
}
156154
}
157155

158156
private void OnDisposed(object sender, EventArgs e)
159157
{
160158
// 清理资源
159+
mTRTCCloud.removeCallback(this);
160+
mTRTCCloud.setLogCallback(null);
161161
mTRTCCloud = null;
162-
if (mCustomCaptureForm != null)
163-
mCustomCaptureForm.Dispose();
164-
if (mDeviceForm != null)
165-
mDeviceForm.Dispose();
166-
if (mDeviceTestForm != null)
167-
mDeviceTestForm.Dispose();
168-
if (mSettingForm != null)
169-
mSettingForm.Dispose();
170162
}
171163

172164
private void OnFormLoad(object sender, EventArgs e)
@@ -473,7 +465,14 @@ public void onError(TXLiteAVError errCode, string errMsg, IntPtr arg)
473465
public void onExitRoom(int reason)
474466
{
475467
mIsEnterSuccess = false;
468+
// 如果进房成功,需要正常退房再关闭窗口,防止资源未清理和释放完毕
469+
Uninit();
476470
this.Close();
471+
if (mLoginForm == null)
472+
{
473+
mLoginForm = new TRTCLoginForm();
474+
}
475+
mLoginForm.Show();
477476
}
478477

479478
/// <summary>
@@ -513,8 +512,6 @@ private void Uninit()
513512
mMixStreamVideoMeta.Clear();
514513
mRemoteUsers.Clear();
515514
mPKUsers.Clear();
516-
mTRTCCloud.removeCallback(this);
517-
mTRTCCloud.setLogCallback(null);
518515
// 注意:系统混音功能暂时不支持64位系统
519516
if (!Util.IsSys64bit())
520517
{
@@ -529,6 +526,7 @@ private void Uninit()
529526
}
530527
if (this.mixTransCodingCheckBox.Checked)
531528
mTRTCCloud.setMixTranscodingConfig(null);
529+
532530
}
533531

534532
/// <summary>
@@ -900,8 +898,6 @@ private void SetVisableInfoView(int pos, bool visable)
900898
private void OnExitLabelClick(object sender, EventArgs e)
901899
{
902900
// 退出房间
903-
if (mIsFirstExitRoom) return;
904-
mIsFirstExitRoom = true;
905901
if (mBeautyForm != null)
906902
mBeautyForm.Close();
907903
if (mDeviceTestForm != null)
@@ -916,22 +912,14 @@ private void OnExitLabelClick(object sender, EventArgs e)
916912
mDeviceTestForm.Close();
917913
if (mDeviceForm != null)
918914
mDeviceForm.Close();
919-
Uninit();
920-
// 如果进房成功,需要正常退房再关闭窗口,防止资源未清理和释放完毕
921915
if (mIsEnterSuccess)
922916
{
923917
mTRTCCloud.exitRoom();
924-
this.Hide();
925918
}
926919
else
927920
{
928-
this.Close();
921+
onExitRoom(0);
929922
}
930-
if (mLoginForm == null)
931-
{
932-
mLoginForm = new TRTCLoginForm();
933-
}
934-
mLoginForm.Show();
935923
}
936924

937925
private void OnSettingLabelClick(object sender, EventArgs e)
@@ -1327,11 +1315,11 @@ private void OnShareUrlLabelClick(object sender, EventArgs e)
13271315
ShowMessage("请勾选云端混流选项!");
13281316
return;
13291317
}
1330-
// 计算 CDN 地址(格式: http://[bizid].liveplay.myqcloud.com/live/[bizid]_[streamid].flv )
1318+
// 计算 CDN 地址(格式: http://[bizid].liveplay.myqcloud.com/live/sdkappid_roomId_userId_main.flv )
13311319
int bizId = GenerateTestUserSig.BIZID;
1332-
// streamid = MD5 (房间号_用户名_流类型)
1333-
string streamId = Util.MD5(String.Format("{0}_{1}_{2}", mRoomId, Util.UTF16To8(mUserId), "main"));
1334-
string shareUrl = String.Format("http://{0}.liveplay.myqcloud.com/live/{0}_{1}.flv", bizId, streamId);
1320+
// streamid = SDKAPPID_房间号_用户名_流类型
1321+
string streamId = String.Format("{0}_{1}_{2}_{3}", GenerateTestUserSig.SDKAPPID, mRoomId, Util.UTF16To8(mUserId), "main");
1322+
string shareUrl = String.Format("http://{0}.liveplay.myqcloud.com/live/{1}.flv", bizId, streamId);
13351323
Log.I("播放地址: " + shareUrl);
13361324
Clipboard.SetDataObject(shareUrl);
13371325
ShowMessage("播放地址:(已复制到剪切板)\n" + shareUrl);
@@ -1763,6 +1751,12 @@ public void onPlayBGMBegin(TXLiteAVError errCode)
17631751
public void onPlayBGMComplete(TXLiteAVError errCode)
17641752
{
17651753
Log.I(String.Format("onPlayBGMComplete : errCode = {0}", errCode));
1754+
if (this.IsHandleCreated)
1755+
this.BeginInvoke(new Action(() =>
1756+
{
1757+
if (mDeviceTestForm != null)
1758+
mDeviceTestForm.OnPlayBGMComplete(errCode);
1759+
}));
17661760
}
17671761

17681762
public void onPlayBGMProgress(uint progressMS, uint durationMS)
@@ -1820,6 +1814,12 @@ public void onSetMixTranscodingConfig(int errCode, string errMsg)
18201814
public void onAudioEffectFinished(int effectId, int code)
18211815
{
18221816
Log.I(String.Format("onAudioEffectFinished : effectId = {0}, code = {1}", effectId, code));
1817+
if (this.IsHandleCreated)
1818+
this.BeginInvoke(new Action(() =>
1819+
{
1820+
if (mDeviceTestForm != null)
1821+
mDeviceTestForm.onAudioEffectFinished(effectId, code);
1822+
}));
18231823
}
18241824

18251825
public void onSpeedTest(TRTCSpeedTestResult currentResult, uint finishedCount, uint totalCount)

Windows/CSharpDemo/TXLiteAVVideoView.cs

+29-6
Original file line numberDiff line numberDiff line change
@@ -227,15 +227,35 @@ public bool AppendVideoFrame(byte[] data, int width, int height, TRTCVideoPixelF
227227
}
228228

229229
// 回到主线程刷新当前画面
230-
if (this.IsHandleCreated)
230+
this.InvokeOnUiThreadIfRequired(new Action(() =>
231231
{
232-
this.Invoke(new Action(() =>
232+
this.Refresh();
233+
}));
234+
return true;
235+
}
236+
237+
private void InvokeOnUiThreadIfRequired(Action action)
238+
{
239+
try
240+
{
241+
if (!this.IsDisposed)
233242
{
234-
this.Refresh();
235-
}));
236-
return true;
243+
if (this.InvokeRequired)
244+
{
245+
this.Invoke(action);
246+
}
247+
else
248+
{
249+
action.Invoke();
250+
}
251+
}
252+
else
253+
System.Threading.Thread.CurrentThread.Abort();
254+
}
255+
catch (Exception ex)
256+
{
257+
Log.E(ex.Message);
237258
}
238-
return false;
239259
}
240260

241261
protected override void OnPaint(PaintEventArgs pe)
@@ -546,8 +566,11 @@ public void onRenderVideoFrame(string userId, TRTCVideoStreamType streamType, TR
546566
}
547567
}
548568
}
569+
549570
if (view != null)
571+
{
550572
view.AppendVideoFrame(frame.data, (int)frame.width, (int)frame.height, frame.videoFormat, frame.rotation);
573+
}
551574
}
552575
}
553576

0 commit comments

Comments
 (0)