Coder Social home page Coder Social logo

nativerecorder's Introduction

NativeRecorder

NativeRecorder is a native call recorder supported up to Android 8.1, supports flac.
Tested on samsung phone.

I made a fake_dlopen through hacking. However, it cannot be used from the Android 9 version.

So.. I made it public.

It's been a while since it's been made and there may be parts that need to be corrected,,,
If it doesn't work, please fix it

How to use

private fun record() {
        val outputfile = makeOutputFile() + ".flac"

        File(outputfile)

        try {
            val audioRecord = NativeSample()
            val flacencoder = FlacEncoder()
            try {
                val audiorecordsetResult = audioRecord.audioRecordSet(
                    MediaRecorder.AudioSource.MIC,
                    frequency, audioEncoding,
                    channelConfiguration, bufferSize
                )
                Dlog.d("record set result: $audiorecordsetResult")

                flacencoder.init(
                    frequency, audioEncoding, channelConfiguration,
                    compressLevel, outputfile
                )
            } catch (e: Exception) {
                Dlog.e("error : $e")
            }
            var data: ByteArray
            audioRecord.start()
            isRecording = true
            while (isRecording) {
                try {
                    // read
                    data = audioRecord.read(bufferSize)
                    val processResult = flacencoder.process(data, bufferSize)
                    if (!processResult) {
                        Dlog.d("flac encoding error")
                        return
                    }
                } catch (e: Exception) {
                    Dlog.e("error : $e")
                }
                if (!isRecording) {
                    Dlog.d("!isRecording")
                }
            }

            audioRecord.stop()

            // audioRecord.stop() -> flacencoder.finish() -> audioRecord.release()
            val finishResult = flacencoder.finish()
            if (!finishResult) {
                Dlog.d("err")
            } else {
                Dlog.d("success stop")
            }

            audioRecord.release()

        } catch (t: Throwable) {
            Log.e("AudioRecord", "Recording Failed")
        }

    }

nativerecorder's People

Contributors

bourbonkk avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

govnotest

nativerecorder's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.