Skip to content

Commit

Permalink
add fix (#102)
Browse files Browse the repository at this point in the history
add publish/unpublish stream controller in demo
  • Loading branch information
xiayangqun authored Sep 13, 2022
1 parent 39aaa19 commit 8e9590f
Show file tree
Hide file tree
Showing 12 changed files with 2,601 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ public class AudioMixing : MonoBehaviour
internal Logger Log;
internal IRtcEngine RtcEngine = null;

private Toggle _urlToggle;
private Toggle _loopbackToggle;

// Start is called before the first frame update
private void Start()
{
Expand Down Expand Up @@ -123,10 +126,11 @@ private void StartAudioMixing()
Debug.Log("StartAudioMixing returns: " + ret);
}


private void PlayEffectTest()
{
Debug.Log("Playing with " + (_urlToggle.isOn ? "URL" : "local file"));
RtcEngine.PlayEffect(1, _urlToggle.isOn ? Sound_URL : _localPath, 1, 1.0, 0, 100, true);
RtcEngine.PlayEffect(1, _urlToggle.isOn ? Sound_URL : _localPath, 1, 1.0, 0, 100, !_loopbackToggle.isOn, 0);
}

private void StopEffectTest()
Expand Down Expand Up @@ -198,8 +202,7 @@ private void HandleEffectButton()
}


private Toggle _urlToggle { get; set; }
private Toggle _loopbackToggle { get; set; }


#endregion
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 1}
m_AnchorMax: {x: 0.5, y: 1}
m_AnchoredPosition: {x: -0.000030517578, y: -27.217377}
m_AnchoredPosition: {x: -0.000030517578, y: -27.217407}
m_SizeDelta: {x: 160, y: 30}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &243413516
Expand Down Expand Up @@ -187,6 +187,68 @@ CanvasRenderer:
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 243413514}
--- !u!1 &349196943
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 349196946}
- component: {fileID: 349196945}
- component: {fileID: 349196944}
m_Layer: 0
m_Name: EventSystem
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &349196944
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 349196943}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 1077351063, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_HorizontalAxis: Horizontal
m_VerticalAxis: Vertical
m_SubmitButton: Submit
m_CancelButton: Cancel
m_InputActionsPerSecond: 10
m_RepeatDelay: 0.5
m_ForceModuleActive: 0
--- !u!114 &349196945
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 349196943}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -619905303, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_FirstSelected: {fileID: 0}
m_sendNavigationEvents: 1
m_DragThreshold: 5
--- !u!4 &349196946
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 349196943}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1156149138
GameObject:
m_ObjectHideFlags: 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ public class DualCamera : MonoBehaviour
public uint UID1 = 123;
public uint UID2 = 456;

public Button MainPublishButton;
public Button MainUnpublishButton;
public Button SecondPublishButton;
public Button SecondUnpublishButton;

// Use this for initialization
private void Start()
{
Expand Down Expand Up @@ -96,7 +101,7 @@ public void MainCameraJoinChannel()
RtcEngine.EnableAudio();
RtcEngine.EnableVideo();
RtcEngine.SetClientRole(CLIENT_ROLE_TYPE.CLIENT_ROLE_BROADCASTER);

var ret = RtcEngine.StartPrimaryCameraCapture(_config1);
Log.UpdateLog(
string.Format("StartPrimaryCameraCapture returns: {0}", ret));
Expand All @@ -118,6 +123,37 @@ public void MainCameraLeaveChannel()
Debug.Log("MainCameraLeaveChannel returns: " + ret);
}

public void MainCameraPublish()
{
ChannelMediaOptions options1 = new ChannelMediaOptions();
options1.publishCameraTrack.SetValue(true);
options1.publishMicrophoneTrack.SetValue(true);
var connection = new RtcConnection();
connection.channelId = _channelName;
connection.localUid = UID1;
RtcEngine.UpdateChannelMediaOptionsEx(options1, connection);


MainPublishButton.gameObject.SetActive(false);
MainUnpublishButton.gameObject.SetActive(true);

}

public void MainCameraUnPublish()
{
ChannelMediaOptions options1 = new ChannelMediaOptions();
options1.publishCameraTrack.SetValue(false);
options1.publishMicrophoneTrack.SetValue(false);
var connection = new RtcConnection();
connection.channelId = _channelName;
connection.localUid = UID1;
RtcEngine.UpdateChannelMediaOptions(options1);

MainPublishButton.gameObject.SetActive(true);
MainUnpublishButton.gameObject.SetActive(false);
}


public void SecondCameraJoinChannel()
{
var ret = RtcEngine.StartSecondaryCameraCapture(_config2);
Expand All @@ -142,6 +178,36 @@ public void SecondCameraLeaveChannel()
Debug.Log("SecondCameraLeaveChannel returns: " + ret);
}

public void SecondCameraPublish()
{
ChannelMediaOptions options1 = new ChannelMediaOptions();
options1.publishSecondaryCameraTrack.SetValue(true);

var connection = new RtcConnection();
connection.channelId = _channelName;
connection.localUid = UID2;
RtcEngine.UpdateChannelMediaOptionsEx(options1, connection);

SecondPublishButton.gameObject.SetActive(false);
SecondUnpublishButton.gameObject.SetActive(true);

}

public void SecondCameraUnpublish()
{
ChannelMediaOptions options1 = new ChannelMediaOptions();
options1.publishSecondaryCameraTrack.SetValue(false);

var connection = new RtcConnection();
connection.channelId = _channelName;
connection.localUid = UID2;
RtcEngine.UpdateChannelMediaOptionsEx(options1, connection);

SecondPublishButton.gameObject.SetActive(true);
SecondUnpublishButton.gameObject.SetActive(false);
}


private void GetVideoDeviceManager()
{
_videoDeviceManager = RtcEngine.GetVideoDeviceManager();
Expand Down
Loading

0 comments on commit 8e9590f

Please sign in to comment.