Open yubinjin opened 5 months ago
Hello,
You can't stream because you are not rendering correctly the surface provided by VideoSource class (USBCameraSource). You are rendering the surface of the TextureView so you only have a preview and the stream never receive video data. You should render the surface provided inside USBCameraSource on the start method.
You can try follow this post (you can use the last library version for it): https://github.com/pedroSG94/RTSP-Server/issues/110 Or use this branch to test: https://github.com/pedroSG94/RootEncoder/tree/feature/extra-video-source In the Rotation example, you can select USB camera as video source
package com.seoul.fire.usb.activity
import android.content.Context import android.graphics.SurfaceTexture import android.util.Log import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.LifecycleRegistry import com.jiangdg.ausbc.CameraClient import com.pedro.library.util.sources.video.VideoSource
class USBCameraSource( private val context: Context, private val cameraClient: CameraClient,
): VideoSource(), LifecycleOwner {
private var mWidth = 1280
private var mHeight = 720
init {
Log.d("camera_str", "USBCameraSource INIT!")
}
private val lifecycleRegistry = LifecycleRegistry(this)
override fun create(width: Int, height: Int, fps: Int, rotation: Int): Boolean {
mWidth = width
mHeight = height
return try {
Log.d("camera_str", "defining Render size to $width Width and $height height")
created = true
true
} catch (e : Exception){
Log.d("camera_str","EXCEPTION ON CREATE USBCAMERASOURCE -> $e")
false
}
}
override fun start(surfaceTexture: SurfaceTexture) {
this.surfaceTexture = surfaceTexture
lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_START)
//cameraClient.openCamera(surfaceTexture,mWidth,mHeight)
}
override fun stop() {
lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_STOP)
cameraClient.let {
it.closeCamera()
surfaceTexture = null
}
}
override fun release() {
lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_DESTROY)
}
override fun isRunning(): Boolean {
return cameraClient.isCameraOpened()!!
}
override val lifecycle: Lifecycle
get() = lifecycleRegistry
} is this problam??
Yes, that class is not correct and for the same reason part of the code in USBActivity is wrong too. I recommend you follow the links I shared you
thank you for answer!!!! so i configured to my code package com.seoul.fire.usb.activity
import android.content.Context import android.graphics.SurfaceTexture import android.util.Log import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.LifecycleRegistry import com.seoul.fire.usb.activity.CameraClient2 import com.pedro.library.util.sources.video.VideoSource
class USBCameraSource( private val context: Context, private val cameraClient: CameraClient2, ): VideoSource(), LifecycleOwner {
private var mWidth = 1280
private var mHeight = 720
init {
Log.d("camera_str", "USBCameraSource INIT!")
}
private val lifecycleRegistry = LifecycleRegistry(this)
override fun start(surfaceTexture: SurfaceTexture) {
this.surfaceTexture = surfaceTexture
lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_START)
cameraClient.openCamera(surfaceTexture,mWidth,mHeight)
}
override fun stop() {
lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_STOP)
cameraClient.let {
it.closeCamera()
surfaceTexture = null
}
}
override fun release() {
lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_DESTROY)
}
override fun create(width: Int, height: Int, fps: Int, rotation: Int): Boolean {
mWidth = width
mHeight = height
return try {
Log.d("camera_str", "defining Render size to $width Width and $height height")
cameraClient.setRenderSize(width,height)
created = true
true
} catch (e : Exception){
Log.d("camera_str","EXCEPTION ON CREATE USBCAMERASOURCE -> $e")
false
}
}
override fun isRunning(): Boolean {
return cameraClient.isCameraOpened()!!
}
override val lifecycle: Lifecycle
get() = lifecycleRegistry
}
this but it is error
FATAL EXCEPTION: camera_manager
Process: com.seoul.fire, PID: 18830
java.lang.UnsatisfiedLinkError: No implementation found for long com.jiangdg.uvc.UVCCamera.nativeCreate() (tried Java_com_jiangdg_uvc_UVCCamera_nativeCreate and Java_com_jiangdg_uvc_UVCCamera_nativeCreate__)
at com.jiangdg.uvc.UVCCamera.nativeCreate(Native Method)
at com.jiangdg.uvc.UVCCamera.
Hello,
That error is related with the usb camera library. The library is not compiling correctly. The c++ Code of the library is missed
i can't streaming rtsp this is my code package com.seoul.fire.usb.activity; import com.jiangdg.ausbc.camera.CameraUvcStrategy; import com.jiangdg.ausbc.camera.bean.CameraRequest; import com.pedro.rtspserver.server.ClientListener; import com.pedro.rtspserver.server.ServerClient; import com.seoul.fire.rtsp.ExampleRtspActivity; import com.seoul.fire.usb.activity.StreamingController; import android.Manifest; import android.content.Context; import android.content.Intent; import android.content.pm.ActivityInfo; import android.content.pm.PackageManager; import android.content.res.ColorStateList; import android.graphics.SurfaceTexture; import android.hardware.usb.UsbDevice; import android.hardware.usb.UsbManager; import android.os.Bundle;
import android.os.SystemClock; import android.telephony.TelephonyManager; import android.text.TextUtils; import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.SurfaceHolder; import android.view.TextureView; import android.view.View; import android.view.WindowManager; import android.widget.ImageButton; import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; import androidx.core.content.ContextCompat;
import com.google.gson.Gson; import com.herohan.uvcapp.CameraHelper; import com.herohan.uvcapp.ICameraHelper; import com.herohan.uvcapp.ImageCapture; import com.herohan.uvcapp.VideoCapture; import com.hjq.permissions.XXPermissions; import com.jiangdg.ausbc.CameraClient; import com.pedro.common.ConnectChecker; import com.pedro.encoder.input.video.CameraOpenException; import com.pedro.encoder.utils.gl.AspectRatioMode; import com.pedro.library.rtsp.RtspStream; import com.pedro.library.util.sources.audio.MicrophoneSource; import com.pedro.library.view.OrientationForced; import com.seoul.fire.MyFusedLocationProvider; import com.seoul.fire.R; import com.seoul.fire.databinding.ActivityUsbBinding; import com.seoul.fire.usb.fragment.CameraControlsDialogFragment; import com.seoul.fire.usb.fragment.DeviceListDialogFragment; import com.seoul.fire.usb.fragment.VideoFormatDialogFragment; import com.seoul.fire.usb.utils.SaveHelper; import com.serenegiant.opengl.renderer.MirrorMode; import com.serenegiant.usb.IButtonCallback; import com.serenegiant.usb.Size; import com.serenegiant.usb.USBMonitor; import com.serenegiant.utils.UriHelper;
import java.io.File; import java.text.DecimalFormat; import java.util.Timer; import java.util.TimerTask;
public class USBActivity extends AppCompatActivity implements ClientListener, ConnectChecker {
// rtspStream.startPreview(); // 이 위치에서 CameraHelper 초기화를 먼저 수행 button = findViewById(R.id.usb_start_stop); lockScreenButton= findViewById(R.id.usb_lock_screen); // button.setOnClickListener(this); myFusedLocationProvider = new MyFusedLocationProvider(this);
// rtspStream = new RtspStream( // (Context) this, // (ConnectChecker) this, // new USBCameraSource(this,mCameraHelper), // new MicrophoneSource() // // ); // rtspStream.getStreamClient().setReTries(10);
}
// startPreview( mBinding.viewMainPreview);
// mCameraHelper.setImageCaptureConfig( // mCameraHelper.getImageCaptureConfig().setCaptureMode(ImageCapture.CAPTURE_MODE_MAXIMIZE_QUALITY)); mCameraHelper.setImageCaptureConfig( mCameraHelper.getImageCaptureConfig().setJpegCompressionQuality(90)); }
// .setAudioCaptureEnable(false) .setBitRate((int) (1024 1024 25 * 0.25)) .setVideoFrameRate(25) .setIFrameInterval(1)); }
} and the log repeatly can you help me?? 024-06-13 16:59:53.359 27273-27434 RtspClient com.seoul.fire I waiting for sps and pps 2024-06-13 16:59:58.354 27273-27441 RtspClient com.seoul.fire I write teardown success 2024-06-13 16:59:58.355 27273-27441 RtspClient com.seoul.fire E connection error kotlinx.coroutines.JobCancellationException: StandaloneCoroutine was cancelled; job=StandaloneCoroutine{Cancelling}@eb32c3a 2024-06-13 16:59:58.365 27273-27391 RtspClient com.seoul.fire I write teardown success 2024-06-13 16:59:58.365 27273-27442 RtspClient com.seoul.fire E connection error kotlinx.coroutines.JobCancellationException: Job was cancelled; job=JobImpl{Cancelling}@4a81e48