Skip to content

Commit

Permalink
fix screen example orientation
Browse files Browse the repository at this point in the history
  • Loading branch information
pedroSG94 committed Mar 25, 2024
1 parent e716ae1 commit eb0784d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/src/main/java/com/pedro/streamer/screen/ScreenService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class ScreenService: Service(), ConnectChecker {
private val width = 640
private val height = 480
private val vBitrate = 1200 * 1000
private var rotation = 0
private var rotation = 0 //0 for landscape or 90 for portrait
private val sampleRate = 32000
private val isStereo = true
private val aBitrate = 128 * 1000
Expand Down Expand Up @@ -140,6 +140,10 @@ class ScreenService: Service(), ConnectChecker {
val mediaProjection = mediaProjectionManager.getMediaProjection(resultCode, data)
val screenSource = ScreenSource(applicationContext, mediaProjection)
return try {
//ScreenSource need use always setCameraOrientation(0) because the MediaProjection handle orientation.
//You also need remove autoHandleOrientation if you are using it.
//You need to call it after prepareVideo to override the default value.
genericStream.getGlInterface().setCameraOrientation(0)
genericStream.changeVideoSource(screenSource)
true
} catch (ignored: IllegalArgumentException) {
Expand Down

0 comments on commit eb0784d

Please sign in to comment.