Skip to content

Commit

Permalink
1.0.7 优化模糊
Browse files Browse the repository at this point in the history
  • Loading branch information
LxzBUG committed Dec 22, 2022
1 parent e27b164 commit aae70ce
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 17 deletions.
4 changes: 2 additions & 2 deletions screenShareKit/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ android {
defaultConfig {
minSdkVersion 21
targetSdkVersion 30
versionCode 7
versionName "1.0.6"
versionCode 8
versionName "1.0.7"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import android.media.MediaCodecInfo
import android.media.MediaFormat
import android.media.projection.MediaProjection
import android.media.projection.MediaProjectionManager
import android.os.Build
import android.os.Handler
import android.os.IBinder
import android.os.Looper
Expand Down Expand Up @@ -59,6 +60,13 @@ class ScreenReaderService : Service() {
setInteger(MediaFormat.KEY_BITRATE_MODE, MediaCodecInfo.EncoderCapabilities.BITRATE_MODE_CBR)
setInteger(MediaFormat.KEY_FRAME_RATE, encodeBuilder.encodeConfig.frameRate) //帧数
setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, 1)
setLong(MediaFormat.KEY_REPEAT_PREVIOUS_FRAME_AFTER,1000000/45)
if (Build.MANUFACTURER.contentEquals("XIAOMI")) {
format.setInteger(MediaFormat.KEY_BITRATE_MODE, MediaCodecInfo.EncoderCapabilities.BITRATE_MODE_CQ)
} else {
format.setInteger(MediaFormat.KEY_BITRATE_MODE, MediaCodecInfo.EncoderCapabilities.BITRATE_MODE_VBR)
}
setInteger(MediaFormat.KEY_COMPLEXITY, MediaCodecInfo.EncoderCapabilities.BITRATE_MODE_CBR)
}
codec = MediaCodec.createEncoderByType(MIME)
codec?.let {
Expand Down Expand Up @@ -96,7 +104,7 @@ class ScreenReaderService : Service() {
}

override fun onOutputFormatChanged(codec: MediaCodec, format: MediaFormat) {
val width = format.getInteger(MediaFormat.KEY_WIDTH)
val width = format.getInteger(MediaFormat.KEY_WIDTH)
val height = format.getInteger(MediaFormat.KEY_HEIGHT)
Log.d("Screenll","${width}++++${height}")

Expand Down Expand Up @@ -165,6 +173,13 @@ class ScreenReaderService : Service() {
setInteger(MediaFormat.KEY_BITRATE_MODE, MediaCodecInfo.EncoderCapabilities.BITRATE_MODE_CBR)
setInteger(MediaFormat.KEY_FRAME_RATE, encodeBuilder.encodeConfig.frameRate) //帧数
setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, 1)
setLong(MediaFormat.KEY_REPEAT_PREVIOUS_FRAME_AFTER,1000000/45)
if (Build.MANUFACTURER.contentEquals("XIAOMI")) {
format.setInteger(MediaFormat.KEY_BITRATE_MODE, MediaCodecInfo.EncoderCapabilities.BITRATE_MODE_CQ)
} else {
format.setInteger(MediaFormat.KEY_BITRATE_MODE, MediaCodecInfo.EncoderCapabilities.BITRATE_MODE_VBR)
}
setInteger(MediaFormat.KEY_COMPLEXITY, MediaCodecInfo.EncoderCapabilities.BITRATE_MODE_CBR)
}
codec = MediaCodec.createEncoderByType(MIME)
codec?.let {
Expand Down Expand Up @@ -271,15 +286,15 @@ class ScreenReaderService : Service() {
}


internal companion object GetIntent{
private const val MIME = "Video/AVC"
private const val RESULT_CODE = "RESULT_CODE"
private const val DATA = "DATA"
private const val ACTION = "ACTION"
private const val START = "START"
private const val STOP = "STOP"
private const val RESET = "RESET"
private const val SCREENCAP_NAME = "screen_cap"
internal companion object GetIntent{
private const val MIME = "Video/AVC"
private const val RESULT_CODE = "RESULT_CODE"
private const val DATA = "DATA"
private const val ACTION = "ACTION"
private const val START = "START"
private const val STOP = "STOP"
private const val RESET = "RESET"
private const val SCREENCAP_NAME = "screen_cap"

fun getStartIntent(context: Context?, resultCode: Int, data: Intent):Intent{
return Intent(context, ScreenReaderService::class.java).apply {
Expand All @@ -294,11 +309,11 @@ class ScreenReaderService : Service() {
}
}

fun reset(context: Context?):Intent{
return Intent(context, ScreenReaderService::class.java).apply {
putExtra(ACTION, RESET)
}
}
fun reset(context: Context?):Intent{
return Intent(context, ScreenReaderService::class.java).apply {
putExtra(ACTION, RESET)
}
}

}
}

0 comments on commit aae70ce

Please sign in to comment.