Closed savuerka closed 2 months ago
Hello,
You can replace RtspServerCamera1 to RtspServerCamera2 directly and all methods works.
The only difference is if you are using a TextureView you need replace it to a OpenGlView because TextureView is no longer supported by RtspServerCamera2. In layout XML:
<com.pedro.rtplibrary.view.OpenGlView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/surfaceView"
app:aspectRatioMode="adjust"
/>
In Activity:
//Replace class interface
class CameraDemoActivity : AppCompatActivity(), ConnectChecker, ClientListener,
SurfaceHolder.Callback {
//Replace surface variable
private lateinit var surfaceView: OpenGlView
//onCreate
surfaceView.holder.addCallback(this)
//Implement the new interface (adaptPreview method is removed)
override fun surfaceCreated(holder: SurfaceHolder) {
}
override fun surfaceChanged(holder: SurfaceHolder, format: Int, width: Int, height: Int) {
if (!rtspServerCamera1.isOnPreview) {
rtspServerCamera1.startPreview()
}
}
override fun surfaceDestroyed(holder: SurfaceHolder) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2 && rtspServerCamera1.isRecording) {
rtspServerCamera1.stopRecord()
bRecord.setBackgroundResource(R.drawable.record_icon)
PathUtils.updateGallery(this, recordPath)
}
if (rtspServerCamera1.isStreaming) {
rtspServerCamera1.stopStream()
bStream.setImageResource(R.drawable.stream_icon)
}
if (rtspServerCamera1.isOnPreview) rtspServerCamera1.stopPreview()
ScreenOrientation.unlockScreen(this)
}
Thank you very much, everything works perfectly!
Good day! Could you please advise if there is an example of using RtspServerCamera2? And if not, how could the original example be modified to work with RtspServerCamera2?