Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Show webCam Video above chat #467

Merged
merged 3 commits into from
Jan 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class MeetingScreenFragment : Fragment(), MeetingShareCallback.ShareEvent {
private lateinit var meetingScreenBinding: MeetingScreenBinding
private lateinit var inMeetingService: InMeetingService
private lateinit var primaryVideoViewManager: MobileRTCVideoViewManager
private lateinit var webCamVideoViewManager: MobileRTCVideoViewManager

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand All @@ -33,6 +34,7 @@ class MeetingScreenFragment : Fragment(), MeetingShareCallback.ShareEvent {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
primaryVideoViewManager = meetingScreenBinding.primaryMeetingView.videoViewManager
webCamVideoViewManager = meetingScreenBinding.webCamView.videoViewManager
renderVideo()
}

Expand All @@ -46,17 +48,46 @@ class MeetingScreenFragment : Fragment(), MeetingShareCallback.ShareEvent {
}

private fun renderVideo() {
primaryVideoViewManager.removeAllVideoUnits()
renderPrimaryVideo()
renderWebCamVideo()
}

val defaultVideoViewRenderInfo = MobileRTCVideoUnitRenderInfo(0, 0, 100, 100)
private fun renderPrimaryVideo() {
primaryVideoViewManager.removeAllVideoUnits()
val screenShareUserId = inMeetingService.activeShareUserID()
if (inMeetingService.inMeetingShareController.isOtherSharing && inMeetingService.isHostUser(screenShareUserId)) {
val defaultVideoViewRenderInfo = MobileRTCVideoUnitRenderInfo(0, 0, 100, 100)
if (isHostSharingScreen(screenShareUserId)) {
primaryVideoViewManager.addShareVideoUnit(screenShareUserId, defaultVideoViewRenderInfo)
} else {
primaryVideoViewManager.addActiveVideoUnit(defaultVideoViewRenderInfo)
}
}

private fun renderWebCamVideo() {
webCamVideoViewManager.removeAllVideoUnits()

val screenShareUserId = inMeetingService.activeShareUserID()
if (isHostSharingScreen(screenShareUserId)) {
meetingScreenBinding.webCamView.visibility = View.VISIBLE
val defaultVideoViewRenderInfo = MobileRTCVideoUnitRenderInfo(0, 0, 100, 100).apply {
is_border_visible = false
aspect_mode = MobileRTCVideoUnitAspectMode.VIDEO_ASPECT_PAN_AND_SCAN
}
webCamVideoViewManager.addAttendeeVideoUnit(
inMeetingService.activeShareUserID(),
defaultVideoViewRenderInfo
)
} else {
meetingScreenBinding.webCamView.visibility = View.GONE
}
}

private fun isHostSharingScreen(screenShareUserId: Long): Boolean {
return inMeetingService.inMeetingShareController.isOtherSharing && inMeetingService.isHostUser(
screenShareUserId
)
}

override fun onResume() {
super.onResume()
meetingScreenBinding.primaryMeetingView.onResume()
Expand Down
31 changes: 23 additions & 8 deletions course/src/main/res/layout/meeting_screen.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,36 @@
android:layout_height="match_parent"
android:focusable="false"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/chatContainer"
app:layout_constraintEnd_toStartOf="@+id/sidebar"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<androidx.fragment.app.FragmentContainerView
android:id="@+id/chatContainer"
android:name="in.testpress.course.ui.ChatFragment"
android:layout_width="230dp"
<androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/sidebar"
android:layout_width="215dp"
android:layout_height="0dp"
android:background="@color/white"
android:orientation="vertical"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/primaryMeetingView"
app:layout_constraintTop_toTopOf="parent"
tools:layout="@layout/fragment_chat" />
app:layout_constraintTop_toTopOf="parent">

<us.zoom.sdk.MobileRTCVideoView
android:id="@+id/webCamView"
android:layout_width="match_parent"
android:layout_height="130dp"
android:focusable="false"
android:visibility="gone" />

<androidx.fragment.app.FragmentContainerView
android:id="@+id/chatContainer"
android:name="in.testpress.course.ui.ChatFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:visibility="visible"
tools:layout="@layout/fragment_chat" />
</androidx.appcompat.widget.LinearLayoutCompat>
</androidx.constraintlayout.widget.ConstraintLayout>