Skip to content

Commit

Permalink
fix reverse orientation using setConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
pedroSG94 committed Mar 5, 2024
1 parent 19b7feb commit aa2ed32
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Expand Up @@ -78,7 +78,7 @@ class CameraFragment: Fragment(), ConnectChecker {
private val width = 640
private val height = 480
private val vBitrate = 1200 * 1000
private var rotation = 0
private var rotation = 90
private val sampleRate = 32000
private val isStereo = true
private val aBitrate = 128 * 1000
Expand Down Expand Up @@ -147,7 +147,7 @@ class CameraFragment: Fragment(), ConnectChecker {
is CameraXSource -> source.switchCamera()
}
}
genericStream.setConfig(resources.configuration)
genericStream.setConfig(resources.configuration, requireContext())
return view
}

Expand Down Expand Up @@ -185,7 +185,7 @@ class CameraFragment: Fragment(), ConnectChecker {

override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)
genericStream.setConfig(newConfig)
genericStream.setConfig(newConfig, requireContext())
}

override fun onConnectionStarted(url: String) {
Expand Down
7 changes: 5 additions & 2 deletions library/src/main/java/com/pedro/library/base/StreamBase.kt
Expand Up @@ -34,6 +34,7 @@ import com.pedro.encoder.Frame
import com.pedro.encoder.audio.AudioEncoder
import com.pedro.encoder.audio.GetAacData
import com.pedro.encoder.input.audio.GetMicrophoneData
import com.pedro.encoder.input.video.CameraHelper
import com.pedro.encoder.utils.CodecUtil
import com.pedro.encoder.video.FormatVideoEncoder
import com.pedro.encoder.video.GetVideoData
Expand All @@ -49,6 +50,7 @@ import com.pedro.library.util.streamclient.StreamBaseClient
import com.pedro.library.view.GlStreamInterface
import java.nio.ByteBuffer


/**
* Created by pedro on 21/2/22.
*
Expand Down Expand Up @@ -341,8 +343,9 @@ abstract class StreamBase(
glInterface.setCameraOrientation(orientation)
}

fun setConfig(config: Configuration) {
val isReversed = config.layoutDirection == Configuration.SCREENLAYOUT_LONG_YES
fun setConfig(config: Configuration, context: Context) {
val orientation = CameraHelper.getCameraOrientation(context)
val isReversed = orientation == 180 || orientation == 270
when (config.orientation) {
Configuration.ORIENTATION_LANDSCAPE -> {
if (isReversed) {
Expand Down

0 comments on commit aa2ed32

Please sign in to comment.