RTSP server android

21 Views Asked by At

I've been trying to write an RTSP app in android which would use the phone's camera to stream an RTSP video. Basically an RTSP server. I've been trying with libstreaming library, but somehow I couldn't make it work. Can you help me with that? I'd be grateful.

override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) val hasCamera = packageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA_ANY)

    binding = ActivityMainBinding.inflate(layoutInflater)
    
    val url = "rtsp://192.168.50.7:1234"

    mSurfaceView = binding.surface

    val holder = mSurfaceView?.holder
    val mediaPLayer: MediaPlayer = MediaPlayer()
    mediaPLayer.setAudioStreamType(AudioManager.STREAM_MUSIC)
    try{
        mediaPLayer.setDataSource(url)
        Log.d(TAG, "Setting data source")
        mediaPLayer.setOnPreparedListener {
            mediaPLayer.setDisplay(holder)
            mediaPLayer.start()
            Log.d(TAG, "Playing")
        }
        mediaPLayer.prepareAsync()
    } catch (e: Exception){
        e.printStackTrace()
        Log.d(TAG, "Error: ${e.message}")
    }
}

I've been trying with this code, but it doesen't working as I was expecting. I'd like to get access to the rtsp stream with the local or public IP address, and play the rtsp stream in VLC or in other sites.

0

There are 0 best solutions below