Skip to content

Commit

Permalink
code clanup
Browse files Browse the repository at this point in the history
  • Loading branch information
shogo4405 committed May 22, 2022
1 parent 9a48857 commit 165b977
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 16 deletions.
2 changes: 0 additions & 2 deletions app/src/main/java/com/haishinkit/studio/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import android.view.MenuItem
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import com.google.android.material.bottomnavigation.BottomNavigationView
import com.haishinkit.graphics.PixelTransformFactory
import com.haishinkit.vulkan.VkPixelTransform

class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemSelectedListener {
private var fragment: Fragment? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ import android.app.Service
import android.content.Intent
import android.content.pm.ServiceInfo
import android.media.projection.MediaProjectionManager
import android.os.*
import android.os.Build
import android.os.Handler
import android.os.IBinder
import android.os.Looper
import android.os.Message
import android.os.Messenger
import android.util.DisplayMetrics
import android.util.Log
import androidx.annotation.RequiresApi
Expand All @@ -16,7 +21,6 @@ import com.haishinkit.event.Event
import com.haishinkit.event.EventUtils
import com.haishinkit.event.IEventListener
import com.haishinkit.graphics.filter.BicubicVideoEffect
import com.haishinkit.graphics.filter.DefaultVideoEffect
import com.haishinkit.graphics.filter.VideoEffect
import com.haishinkit.media.AudioRecordSource
import com.haishinkit.media.MediaProjectionSource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import android.content.Context
import android.content.Intent
import android.content.ServiceConnection
import android.media.projection.MediaProjectionManager
import android.os.*
import android.os.Build
import android.os.Bundle
import android.os.IBinder
import android.os.Message
import android.os.Messenger
import android.util.Log
import android.view.LayoutInflater
import android.view.View
Expand All @@ -19,11 +23,8 @@ import androidx.fragment.app.Fragment
import com.haishinkit.graphics.filter.BicubicVideoEffect
import com.haishinkit.graphics.filter.BilinearVideoEffect
import com.haishinkit.graphics.filter.DefaultVideoEffect
import com.haishinkit.graphics.filter.MonochromeVideoEffect
import com.haishinkit.net.NetStream
import com.haishinkit.rtmp.RtmpConnection
import com.haishinkit.rtmp.RtmpStream
import java.nio.ByteBuffer

class MediaProjectionTabFragment : Fragment(), ServiceConnection {
private var messenger: Messenger? = null
Expand All @@ -46,13 +47,31 @@ class MediaProjectionTabFragment : Fragment(), ServiceConnection {
val filter = v.findViewById<Button>(R.id.filter_button)
filter.setOnClickListener {
if (filter.text == "Normal") {
messenger?.send(Message.obtain(null, MediaProjectionService.MSG_SET_VIDEO_EFFECT, BicubicVideoEffect()))
messenger?.send(
Message.obtain(
null,
MediaProjectionService.MSG_SET_VIDEO_EFFECT,
BicubicVideoEffect()
)
)
filter.text = "Bicubic"
} else if (filter.text == "Bicubic") {
messenger?.send(Message.obtain(null, MediaProjectionService.MSG_SET_VIDEO_EFFECT, BilinearVideoEffect()))
messenger?.send(
Message.obtain(
null,
MediaProjectionService.MSG_SET_VIDEO_EFFECT,
BilinearVideoEffect()
)
)
filter.text = "Bilinear"
} else {
messenger?.send(Message.obtain(null, MediaProjectionService.MSG_SET_VIDEO_EFFECT, DefaultVideoEffect.shared))
messenger?.send(
Message.obtain(
null,
MediaProjectionService.MSG_SET_VIDEO_EFFECT,
DefaultVideoEffect.shared
)
)
filter.text = "Normal"
}
}
Expand Down
13 changes: 10 additions & 3 deletions app/src/main/java/com/haishinkit/studio/PreferenceTagFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ import android.graphics.Paint
import android.graphics.Rect
import android.os.Bundle
import android.util.Log
import android.view.*
import android.view.Choreographer
import android.view.LayoutInflater
import android.view.SurfaceHolder
import android.view.SurfaceView
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import androidx.fragment.app.Fragment
import java.lang.Exception

class PreferenceTagFragment : Fragment(), Choreographer.FrameCallback {
private lateinit var holderA: SurfaceHolder
Expand All @@ -22,7 +26,10 @@ class PreferenceTagFragment : Fragment(), Choreographer.FrameCallback {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Log.i(TAG, "VkPixelTransform::isSupported() = ${com.haishinkit.vulkan.VkPixelTransform.isSupported()}")
Log.i(
TAG,
"VkPixelTransform::isSupported() = ${com.haishinkit.vulkan.VkPixelTransform.isSupported()}"
)
context?.let {
Log.d(TAG, "setAssetManager")
renderer?.assetManager = it.assets
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import android.view.Surface
import com.haishinkit.graphics.filter.VideoEffect
import com.haishinkit.graphics.gles.Kernel
import com.haishinkit.graphics.gles.Texture
import java.lang.RuntimeException

internal class GlPixelTransform : PixelTransform, Choreographer.FrameCallback {
override var outputSurface: Surface?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ class VkPixelTransform : PixelTransform {
external fun inspectDevices(): String

override fun readPixels(lambda: (bitmap: Bitmap?) -> Unit) {
val bitmap = Bitmap.createBitmap(imageExtent.width, imageExtent.height, Bitmap.Config.ARGB_8888)
val bitmap =
Bitmap.createBitmap(imageExtent.width, imageExtent.height, Bitmap.Config.ARGB_8888)
lambda(bitmap)
}

Expand Down

0 comments on commit 165b977

Please sign in to comment.