小编Cre*_*tar的帖子

使用 MotionLayout 并使用数据绑定设置可见性失败

我正在使用implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta1',并启用了数据绑定。

当我的看法

<ImageView
            android:id="@+id/im_lightning"
            android:layout_width="24dp"
            android:layout_height="24dp"
            android:layout_marginTop="24dp"
            android:layout_marginEnd="4dp"
            android:contentDescription="@string/charging"
            android:src="@drawable/ic_lightning"
            android:visibility="@{batteryViewModel.liveData.charging ? View.VISIBLE : View.GONE}"
            app:layout_constraintBottom_toBottomOf="@id/tv_percent"
            app:layout_constraintRight_toLeftOf="@id/tv_percent"
            app:layout_constraintTop_toTopOf="@id/tv_percent"
            app:layout_constraintVertical_bias="1.0" />
Run Code Online (Sandbox Code Playgroud)

围绕协调器布局,其可见性变化按预期发生。一旦我将它包装在 MotionLayout 中,可见性更改就不会像以前一样工作。准确地说,视图在应该可见的时候不可见。它在触发事件后变为可见一秒钟,然后恢复为不可见。这是一个已知的错误?

需要时的代码:

协调器布局:

<androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/colorBackground">
        <ImageView (same as above) />
</androidx.constraintlayout.widget.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)

运动布局:

<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context=".ui.MainActivity">

    <androidx.constraintlayout.motion.widget.MotionLayout
        android:id="@+id/motion_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/colorBackground"
        app:layoutDescription="@xml/home_scene_0"
        app:showPaths="true">

        <ImageView (same as above) />
    </androidx.constraintlayout.motion.widget.MotionLayout>
    <data>
        <import type="android.view.View" />
        <variable
            name="batteryViewModel"
            type="rish.crearo.minimalphone.viewmodels.BatteryViewModel" />
    </data>
</layout>
Run Code Online (Sandbox Code Playgroud)

android android-coordinatorlayout android-motionlayout

6
推荐指数
1
解决办法
2797
查看次数

有效绘制字节数组流以在 Android 中显示的选项

简单来说,我需要做的就是在Android中显示视频帧的实时流(每帧都是YUV420格式)。我有一个回调函数,我在其中接收单个帧作为字节数组。看起来像这样的东西:

public void onFrameReceived(byte[] frame, int height, int width, int format) {
    // display this frame to surfaceview/textureview.
}
Run Code Online (Sandbox Code Playgroud)

一个可行但缓慢的选择是将字节数组转换为位图并绘制到 SurfaceView 上的画布上。将来,我希望能够改变该帧的亮度、对比度等,因此希望我可以使用 OpenGL-ES 来实现同样的目的。我还有哪些其他选择可以有效地做到这一点?

Camera请记住,与或类的实现不同MediaPlayer,我无法将输出定向到表面视图/纹理视图,camera.setPreviewTexture(surfaceTexture);因为我使用 C 中的 Gstreamer 接收单个帧。

android opengl-es surfaceview textureview

5
推荐指数
1
解决办法
2382
查看次数

将 EoS 发送到文件接收器,同时从 tee 中删除分支

我写了一个v4l2src同时显示和记录的代码。我的管道看起来像:

               / [queue] ! [videosink]
v4l2src ! tee !  
               \ [queue] ! [filesink]
Run Code Online (Sandbox Code Playgroud)

目前我可以一起显示+记录,还可以随意动态启动和停止记录分支(使用 ctrl+c sigint 处理程序进行启动/停止)。我在这个答案和本文的部分内容中使用了@thiagoss的建议。

问题 :

我面临的唯一问题是在取消链接时将 EoS 发送到 filesink 分支。gst_element_send_event(-->?<--, gst_event_new_eos());我应该将事件发送到哪个元素?我无法将其发送到整个管道,因为 1. 分支现在已取消链接,2. 即使我这样做,它也会关闭视频接收器。

我尝试过的:在删除 mp4mux 并仅保存 h264 编码视频时,我可以使用 gst-playbin 来查看视频,这意味着分支创建和取消链接正确发生。

以下是我的代码。

#include <string.h>
#include <gst/gst.h>
#include <signal.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>

// v4l2src ! tee name=t t. ! x264enc ! mp4mux ! filesink location=/home/rish/Desktop/okay.264 t. ! videoconvert ! autovideosink

static GMainLoop *loop;
static GstElement *pipeline, *src, *tee, …
Run Code Online (Sandbox Code Playgroud)

gstreamer

3
推荐指数
1
解决办法
5637
查看次数