在我的应用程序中,我使用openTok作为音频和视频调用功能。附件是我正在创建的图像,用于视频调用,以旋转摄像机视图,有一个摄像机旋转图标。
在发布流之前,这个图标到旋转相机的位置是一样的,但是一旦流被发布,这个图标就消失了。它之所以发生,是因为z阶。如下所述的发布流的代码:
private void startPublisherStreaming() {
mPublisher = new Publisher.Builder(getContext())
.resolution(Publisher.CameraCaptureResolution.LOW)
.frameRate(Publisher.CameraCaptureFrameRate.FPS_7)
.name(name)
.build();
mPublisher.setPublisherListener(VideoCallFragment.this);
mPublisher.setStyle(BaseVideoRenderer.STYLE_VIDEO_SCALE, BaseVideoRenderer.STYLE_VIDEO_FILL);
mPublisher.setPublishAudio(true);
mPublisher.setPublishVideo(true);
flSubStream.addView(mPublisher.getView());
if (mPublisher.getView() instanceof GLSurfaceView) {
((GLSurfaceView) mPublisher.getView()).setZOrderOnTop(true);
}
ivFlipCamera.bringToFront();
mSession.publish(mPublisher);
}
一旦眩光表面得到渲染,它就会出现在顶部,旋转图标就会返回。为了恢复图标,我使用的是bringtoFront(),但这不起作用。下面是用于布局的xml。
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/cl_frag_audio_call"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/main_bg">
<FrameLayout
android:id="@+id/container_main_streaming"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_call_time"
style="@style/NormalTextView"
android:layout_width="0dp"
android:layout_height="@dimen/height_call_timer"
android:layout_marginTop="4dp"
android:background="@color/colorTransBlack"
android:gravity="center"
android:text="@string/dummy_call_duration"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.constraintlayout.widget.ConstraintLayout
android:padding="@dimen/default_app_margin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/default_quarter_app_margin"
android:background="@color/colorTransBlack"
app:layout_constraintBottom_toTopOf="@+id/group"
app:layout_constraintStart_toStartOf="parent">
<RelativeLayout
android:id="@+id/container_stream"
android:layout_width="@dimen/sub_streaming_size"
android:layout_height="@dimen/sub_streaming_size"
app:layout_constraintBottom_toTopOf="@+id/tv_stream_name"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
</RelativeLayout>
<ImageView
android:id="@+id/iv_flip_camera"
android:layout_width="@dimen/camera_flip_size"
android:layout_height="@dimen/camera_flip_size"
android:src="@drawable/call_camera_flip_ico"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_stream_name"
style="@style/SmallTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/default_half_app_margin"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/group"
android:layout_width="match_parent"
android:layout_height="@dimen/calling_options_group_height"
android:background="@color/colorTransBlack"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<ImageView
android:tag="1"
android:id="@+id/iv_video_switch"
android:layout_width="@dimen/calling_option_size"
android:layout_height="@dimen/calling_option_size"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/iv_speaker"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/call_vid_ico" />
<ImageView
android:id="@+id/iv_mic"
android:layout_width="@dimen/calling_option_size"
android:layout_height="@dimen/calling_option_size"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/iv_chat"
app:layout_constraintStart_toEndOf="@+id/iv_speaker"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/call_mic_ico" />
<ImageView
android:id="@+id/iv_chat"
android:layout_width="@dimen/calling_option_size"
android:layout_height="@dimen/calling_option_size"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/iv_add_user"
app:layout_constraintStart_toEndOf="@+id/iv_mic"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/call_chat_dis_ico" />
<ImageView
android:id="@+id/iv_add_user"
android:layout_width="@dimen/calling_option_size"
android:layout_height="@dimen/calling_option_size"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/iv_end_call"
app:layout_constraintStart_toEndOf="@+id/iv_chat"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/call_adduser_off_ico" />
<ImageView
android:id="@+id/iv_end_call"
android:layout_width="@dimen/calling_option_size"
android:layout_height="@dimen/calling_option_size"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/iv_add_user"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/call_incoming_reject_ico" />
<ImageView
android:id="@+id/iv_speaker"
android:layout_width="@dimen/calling_option_size"
android:layout_height="@dimen/calling_option_size"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/iv_mic"
app:layout_constraintStart_toEndOf="@+id/iv_video_switch"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/call_speaker_ico_enable" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
你知道如何在GLsurfaceview上引入旋转图标吗?
发布于 2020-09-03 00:22:04
一种选择是切换到使用TextureView而不是GLSurfaceView,一般来说,当使用TextureView而不是GLSurfaceView时,视图合成要容易得多。
在构建会话时,可以通过这样做来启用TextureView。
Session builder = new Session.Builder(this, apiKey, sessionId)
.sessionOptions(new Session.SessionOptions() {
@Override
public boolean useTextureViews() {
return true;
}
}).build();
https://stackoverflow.com/questions/63709672
复制