Skip to content

Commit

Permalink
Added Debug checkbox in live view
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeyvasilyev committed Jan 5, 2022
1 parent 28a05e1 commit a948163
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
3 changes: 3 additions & 0 deletions app/src/main/java/com/alexvas/rtsp/demo/live/LiveFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class LiveFragment : Fragment() {
binding.etRtspPassword.isEnabled = false
binding.cbVideo.isEnabled = false
binding.cbAudio.isEnabled = false
binding.cbDebug.isEnabled = false
}

override fun onRtspStatusConnected() {
Expand All @@ -50,6 +51,7 @@ class LiveFragment : Fragment() {
binding.bnSnapshot.isEnabled = false
binding.cbVideo.isEnabled = true
binding.cbAudio.isEnabled = true
binding.cbDebug.isEnabled = true
binding.etRtspRequest.isEnabled = true
binding.etRtspUsername.isEnabled = true
binding.etRtspPassword.isEnabled = true
Expand Down Expand Up @@ -160,6 +162,7 @@ class LiveFragment : Fragment() {
} else {
val uri = Uri.parse(liveViewModel.rtspRequest.value)
binding.svVideo.init(uri, liveViewModel.rtspUsername.value, liveViewModel.rtspPassword.value, "rtsp-client-android")
binding.svVideo.debug = binding.cbDebug.isChecked
binding.svVideo.start(binding.cbVideo.isChecked, binding.cbAudio.isChecked)
}
}
Expand Down
15 changes: 8 additions & 7 deletions app/src/main/res/layout/fragment_live.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,18 @@
<CheckBox
android:id="@+id/cbAudio"
android:text="Audio"
android:checked="false"
android:layout_margin="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

<!-- <CheckBox-->
<!-- android:id="@+id/cbDebug"-->
<!-- android:text="Debug"-->
<!-- android:checked="true"-->
<!-- android:layout_margin="20dp"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content" />-->
<CheckBox
android:id="@+id/cbDebug"
android:text="Debug"
android:checked="false"
android:layout_margin="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>

<Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import java.util.concurrent.atomic.AtomicBoolean

open class RtspSurfaceView: SurfaceView {

var debug: Boolean = false

private lateinit var uri: Uri
private var username: String? = null
private var password: String? = null
Expand Down Expand Up @@ -220,7 +222,7 @@ open class RtspSurfaceView: SurfaceView {
val rtspClient = RtspClient.Builder(socket, uri.toString(), rtspStopped, proxyClientListener)
.requestVideo(requestVideo)
.requestAudio(requestAudio)
// .withDebug(false)
.withDebug(debug)
.withUserAgent(userAgent)
.withCredentials(username, password)
.build()
Expand Down

0 comments on commit a948163

Please sign in to comment.