├── .gitignore ├── .gitmodules ├── BUILDING ├── COPYING ├── README ├── app ├── build.gradle ├── src │ ├── androidTest │ │ └── java │ │ │ └── cc │ │ │ └── echonet │ │ │ └── coolmicapp │ │ │ └── test │ │ │ └── MainActivityBasicTest.java │ └── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ └── cc │ │ │ └── echonet │ │ │ ├── coolmicapp │ │ │ ├── AboutActivity.java │ │ │ ├── BackgroundService │ │ │ │ ├── Client │ │ │ │ │ ├── Client.java │ │ │ │ │ ├── EventListener.java │ │ │ │ │ └── SyncOnce.java │ │ │ │ ├── Constants.java │ │ │ │ ├── Server │ │ │ │ │ ├── Driver.java │ │ │ │ │ └── Server.java │ │ │ │ └── State.java │ │ │ ├── CMTS.java │ │ │ ├── Configuration │ │ │ │ ├── Audio.java │ │ │ │ ├── Codec.java │ │ │ │ ├── DialogIdentifier.java │ │ │ │ ├── DialogState.java │ │ │ │ ├── GlobalConfiguration.java │ │ │ │ ├── Manager.java │ │ │ │ ├── Profile.java │ │ │ │ ├── ProfileBase.java │ │ │ │ ├── Server.java │ │ │ │ ├── Station.java │ │ │ │ ├── Track.java │ │ │ │ ├── VUMeter.java │ │ │ │ └── Volume.java │ │ │ ├── Dialog.java │ │ │ ├── FileFormatDetector.java │ │ │ ├── Icecast │ │ │ │ ├── Command.java │ │ │ │ ├── Icecast.java │ │ │ │ ├── Request │ │ │ │ │ ├── Request.java │ │ │ │ │ └── Stats.java │ │ │ │ ├── Response │ │ │ │ │ ├── Response.java │ │ │ │ │ └── Stats.java │ │ │ │ └── State.java │ │ │ ├── MainActivity.java │ │ │ ├── MetadataDialog.java │ │ │ ├── PromptDialog.java │ │ │ ├── SettingsActivity.java │ │ │ ├── StationMetadataDialog.java │ │ │ ├── TextProgressBar.java │ │ │ ├── TrackMetadataDialog.java │ │ │ ├── Utils.java │ │ │ └── VerticalSeekBar.java │ │ │ └── coolmicdspjava │ │ │ ├── CallbackHandler.java │ │ │ ├── InputStreamAdapter.java │ │ │ ├── VUMeterResult.java │ │ │ ├── Wrapper.java │ │ │ └── WrapperConstants.java │ │ ├── jni │ │ ├── Android.mk │ │ ├── Application.mk │ │ ├── CMakeLists.txt │ │ ├── cmake │ │ │ ├── AddPrefix.cmake │ │ │ └── ReadVariables.cmake │ │ ├── include │ │ │ ├── os.h │ │ │ ├── shout │ │ │ │ ├── config.h │ │ │ │ └── shout.h │ │ │ └── stream │ │ │ │ └── util.h │ │ ├── libcoolmic-dsp-android-build-wrapper │ │ │ ├── Android.mk │ │ │ └── CMakeLists.txt │ │ ├── libcoolmic-dsp-java │ │ │ ├── Android.mk │ │ │ ├── CMakeLists.txt │ │ │ ├── InputStreamAdapter.c │ │ │ ├── InputStreamAdapter.h │ │ │ └── wrapper.c │ │ ├── libigloo-android-build-wrapper │ │ │ ├── Android.mk │ │ │ ├── CMakeLists.txt │ │ │ └── include │ │ │ │ ├── config.h │ │ │ │ └── igloo │ │ │ │ └── config.h │ │ ├── libogg-android-build-wrapper │ │ │ ├── Android.mk │ │ │ ├── CMakeLists.txt │ │ │ └── ogg │ │ │ │ └── config_types.h │ │ ├── libshout-android-build-wrapper │ │ │ ├── Android.mk │ │ │ ├── CMakeLists.txt │ │ │ └── thread.c.patch │ │ ├── libvorbis-android-build-wrapper │ │ │ ├── Android.mk │ │ │ └── CMakeLists.txt │ │ └── opus-android-build-wrapper │ │ │ ├── Android.mk │ │ │ ├── CMakeLists.txt │ │ │ └── config.h │ │ └── res │ │ ├── drawable-hdpi │ │ ├── home.png │ │ ├── icon.png │ │ └── mic.png │ │ ├── drawable-ldpi │ │ ├── icon.png │ │ └── mic.png │ │ ├── drawable-mdpi │ │ ├── icon.png │ │ └── mic.png │ │ ├── drawable-xhdpi │ │ ├── icon.png │ │ └── mic.png │ │ ├── drawable │ │ └── progress_bar_vertical.xml │ │ ├── layout │ │ ├── activity_about.xml │ │ ├── home.xml │ │ └── metadata_list_entry.xml │ │ ├── menu │ │ └── main_activity_menu.xml │ │ ├── values-w820dp │ │ └── dimens.xml │ │ ├── values │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ │ └── xml │ │ └── pref_all.xml └── version.properties ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── import-summary.txt └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | app/build/ 3 | app/release 4 | app/src/main/libs/ 5 | app/src/main/obj/ 6 | lsp/ 7 | local.properties 8 | 9 | 10 | # Stolen from: https://github.com/google/iosched/blob/master/.gitignore and http://stackoverflow.com/questions/16736856/what-should-be-in-my-gitignore-for-an-android-studio-project 11 | # build native files 12 | *.o 13 | *.so 14 | 15 | # built application files 16 | *.apk 17 | *.ap_ 18 | 19 | # files for the dex VM 20 | *.dex 21 | 22 | # Java class files 23 | *.class 24 | 25 | # generated files 26 | bin/ 27 | gen/ 28 | out/ 29 | build/ 30 | 31 | # Local configuration file (sdk path, etc) 32 | local.properties 33 | 34 | # Eclipse project files 35 | .classpath 36 | .project 37 | 38 | # Windows thumbnail db 39 | .DS_Store 40 | 41 | # IDEA/Android Studio project files, because 42 | # the project can be imported from settings.gradle 43 | .idea 44 | *.iml 45 | 46 | # Old-style IDEA project files 47 | *.ipr 48 | *.iws 49 | 50 | # Local IDEA workspace 51 | .idea/workspace.xml 52 | 53 | # Gradle cache 54 | .gradle 55 | 56 | # Sandbox stuff 57 | _sandbox 58 | app/.externalNativeBuild 59 | app/.cxx/ 60 | app/defaultConfig/ 61 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "app/src/main/jni/libshout/libshout"] 2 | path = app/src/main/jni/libshout-android-build-wrapper/libshout 3 | url = ../icecast-libshout.git 4 | [submodule "app/src/main/jni/libigloo-android-build-wrapper/libigloo"] 5 | path = app/src/main/jni/libigloo-android-build-wrapper/libigloo 6 | url = ../icecast-common.git 7 | [submodule "app/src/main/jni/libcoolmic-dsp/libcoolmic-dsp"] 8 | path = app/src/main/jni/libcoolmic-dsp-android-build-wrapper/libcoolmic-dsp 9 | url = ../libcoolmic-dsp.git 10 | [submodule "app/src/main/jni/opus/opus"] 11 | path = app/src/main/jni/opus-android-build-wrapper/opus 12 | url = https://gitlab.xiph.org/xiph/opus.git 13 | [submodule "app/src/main/jni/libogg-android-build-wrapper/libogg"] 14 | path = app/src/main/jni/libogg-android-build-wrapper/libogg 15 | url = https://gitlab.xiph.org/xiph/ogg.git 16 | [submodule "app/src/main/jni/libvorbis-android-build-wrapper/libvorbis"] 17 | path = app/src/main/jni/libvorbis-android-build-wrapper/libvorbis 18 | url = https://gitlab.xiph.org/xiph/vorbis.git 19 | -------------------------------------------------------------------------------- /BUILDING: -------------------------------------------------------------------------------- 1 | How to build coolmic: 2 | 1. Download Android Studio and the NDK 3 | 2. Clone this repository 4 | 3. Run the following commands: 5 | $ git submodule init 6 | $ git submodule update --init --recursive 7 | 4. Import the Project into Android Studio. Select gradle-wrapper. 8 | 5. Hit build(Arrovdown with 011001 next to it. 9 | 6. Hit the Build Menu and then Build APK 10 | 7. You can find the resulting APK under ./app/build/outputs/apk/ 11 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | -=-=-=-=-=-=-=-=-=-=- 2 | Cool Mic 1.x README 3 | -=-=-=-=-=-=-=-=-=-=- 4 | 5 | Cool Mic is an open source Icecast source client. It livestreams audio captured by your Android 6 | device’s microphone or mic in / line in jack. It can stream to any Icecast server in the 7 | open-source audio formats Ogg/Opus and Ogg/Vorbis. It has many features and a simple, easy to use 8 | interface. Cool Mic aims to be the best way to livestream quality audio from your 9 | smartphone or tablet. 10 | 11 | 12 | -=-=-=-=- 13 | Features 14 | -=-=-=-=- 15 | 16 | + Streams live audio from microphone or mic/line jack to any Icecast 2.x server 17 | + Configurable metadata (Title, Artist) sent to Icecast 18 | + Easy sharing of your unique livestream URL 19 | + Auto-reconnect feature 20 | + Input gain (input volume) slider 21 | + Graphical VU meter with adjustable update interval 22 | + Active listener count (current + peak/max) 23 | + Broadcast length timer 24 | + Supports the open source, patent free Ogg/Opus audio codec 25 | + Supports the open source, patent free Ogg/Vorbis audio codec 26 | + Configurable Opus + Vorbis quality level settings 27 | + Configurable Icecast ‘source‘ username 28 | + Configurable number of audio channels (1/Mono, 2/Stereo) 29 | + Configurable sample rate (8000, 11025, 16000, 22050, 44100, 48000Hz) 30 | + Configurable server port (Under “Connection”, use SERVER:PORT) 31 | + Scan QR Code for auto-configuration 32 | + Allows basic testing by using predefined Cool Mic Test Server configuration (CMTS) 33 | + Prevents screen + Wi-Fi sleep mode during livestream 34 | + Check current Cool Mic -> Android OS permissions 35 | + Simple and easy to use interface 36 | + 100% Open Source (GPLv3) Android app 37 | 38 | 39 | -=-=-=-=-=-=-=-=-=-=-=-=-=- 40 | Getting Involved / Contact 41 | -=-=-=-=-=-=-=-=-=-=-=-=-=- 42 | 43 | We are actively seeking people to help develop Cool Mic. If you are interested, please use the 44 | following methods to contact us: 45 | 46 | + EMail: team@coolmic.net 47 | + IRC: #coolmic on Freenode (irc.freenode.net) 48 | + Mailing Lists: 49 | CoolMic-Dev: https://lists.logicalnetworking.net/listinfo/coolmic-dev 50 | CoolMic-User: https://lists.logicalnetworking.net/listinfo/coolmic-user 51 | 52 | + Website: https://coolmic.net 53 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | import java.text.SimpleDateFormat 2 | 3 | apply plugin: 'com.android.application' 4 | 5 | // Create a variable called keystorePropertiesFile, and initialize it to your 6 | // keystore.properties file, in the rootProject folder. 7 | def versionPropertiesFile = projectDir.toPath().resolve("version.properties").toFile() 8 | 9 | // Initialize a new Properties() object called keystoreProperties. 10 | def versionProperties = new Properties() 11 | 12 | // Load your keystore.properties file into the keystoreProperties object. 13 | versionProperties.load(new FileInputStream(versionPropertiesFile)) 14 | 15 | Integer versionMajor = versionProperties['versionMajor'] as Integer 16 | Integer versionMinor = versionProperties['versionMinor'] as Integer 17 | Integer versionPatch = versionProperties['versionPatch'] as Integer 18 | 19 | String versionNameTmp = "${versionMajor}.${versionMinor}.${versionPatch}" 20 | Integer versionCodeTmp = versionMajor * 10000 + versionMinor * 100 + versionPatch 21 | 22 | task appVersion { 23 | doLast { 24 | println "${versionNameTmp}-${versionCodeTmp}" 25 | } 26 | } 27 | 28 | android { 29 | compileSdkVersion 29 30 | defaultConfig { 31 | applicationId "cc.echonet.coolmicapp" 32 | versionCode versionCodeTmp 33 | versionName versionNameTmp 34 | 35 | minSdkVersion 16 36 | targetSdkVersion 29 37 | 38 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 39 | 40 | buildConfigField "String", "GIT_REVISION", "\"${gitRevision()}\"" 41 | buildConfigField "String", "GIT_BRANCH", "\"${gitBranch()}\"" 42 | buildConfigField "String", "GIT_AUTHOR", "\"${gitAuthor()}\"" 43 | buildConfigField "String", "GIT_DIRTY", "\"${gitDirty()}\"" 44 | buildConfigField "String", "BUILD_TS", "\"${buildTimeStamp()}\"" 45 | buildConfigField "String", "HTTP_PRODUCT", "\"CoolMic\"" 46 | buildConfigField "String", "HTTP_VERSION", "VERSION_NAME" 47 | buildConfigField "String", "HTTP_COMMENT", "\"build-ts:\" + BUILD_TS + \"; git-rev:\" + GIT_REVISION" 48 | 49 | // `return void` removes the lint error: `Not all execution paths return a value`. 50 | return void 51 | } 52 | buildTypes { 53 | release { 54 | minifyEnabled false 55 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' 56 | resValue "string", "app_version","${defaultConfig.versionName}" 57 | } 58 | debug { 59 | versionNameSuffix ".debug" 60 | resValue "string", "app_version","${defaultConfig.versionName}${versionNameSuffix}" 61 | } 62 | } 63 | flavorDimensions "version" 64 | productFlavors { 65 | defaultConfig { 66 | dimension "version" 67 | } 68 | debugdev { 69 | dimension "version" 70 | applicationIdSuffix ".debug" 71 | versionNameSuffix "-debug" 72 | } 73 | } 74 | externalNativeBuild { 75 | cmake { 76 | path 'src/main/jni/CMakeLists.txt' 77 | } 78 | } 79 | compileOptions { 80 | sourceCompatibility = 1.8 81 | targetCompatibility = 1.8 82 | } 83 | buildToolsVersion = '28.0.3' 84 | } 85 | 86 | static def gitRevision() { 87 | try { 88 | return "git rev-parse HEAD".execute().text.trim() 89 | } 90 | catch(Exception ignored) 91 | { 92 | return "N/A" 93 | } 94 | } 95 | 96 | static def gitBranch() { 97 | try { 98 | return "git rev-parse --symbolic-full-name HEAD".execute().text.trim() 99 | } 100 | catch(Exception ignored) 101 | { 102 | return "N/A" 103 | } 104 | } 105 | 106 | static def gitAuthor() { 107 | try { 108 | return "git --no-pager show -s --format=\"%aN <%aE>\" HEAD".execute().text.trim() 109 | } 110 | catch(Exception ignored) 111 | { 112 | return "N/A" 113 | } 114 | } 115 | 116 | static def gitDirty() { 117 | try { 118 | if ("git status --porcelain".execute().text.trim().isEmpty()) { 119 | return "false" 120 | } else { 121 | return "true" 122 | } 123 | } 124 | catch(Exception ignored) 125 | { 126 | return "N/A" 127 | } 128 | } 129 | 130 | static def buildTimeStamp() { 131 | try { 132 | def df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z") //you can change it 133 | df.setTimeZone(TimeZone.getTimeZone("UTC")) 134 | return df.format(new Date()) 135 | } 136 | catch(Exception ignored) 137 | { 138 | return "N/A" 139 | } 140 | } 141 | 142 | dependencies { 143 | implementation 'androidx.legacy:legacy-support-v4:1.0.0' 144 | implementation 'com.google.zxing:android-integration:3.2.1' 145 | api 'androidx.annotation:annotation:1.1.0' 146 | 147 | androidTestImplementation 'androidx.test.ext:junit:1.1.1' 148 | androidTestImplementation 'androidx.test:runner:1.2.0' 149 | androidTestImplementation 'androidx.test:rules:1.2.0' 150 | // Optional -- Hamcrest library 151 | androidTestImplementation 'org.hamcrest:hamcrest-library:1.3' 152 | // Optional -- UI testing with Espresso 153 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' 154 | 155 | 156 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3' 157 | implementation 'org.jetbrains:annotations:19.0.0' 158 | } 159 | -------------------------------------------------------------------------------- /app/src/androidTest/java/cc/echonet/coolmicapp/test/MainActivityBasicTest.java: -------------------------------------------------------------------------------- 1 | package cc.echonet.coolmicapp.test; 2 | 3 | import androidx.test.ext.junit.runners.AndroidJUnit4; 4 | 5 | import org.junit.Rule; 6 | import org.junit.Test; 7 | import org.junit.runner.RunWith; 8 | 9 | import androidx.test.rule.ActivityTestRule; 10 | import androidx.test.filters.LargeTest; 11 | 12 | import cc.echonet.coolmicapp.MainActivity; 13 | import cc.echonet.coolmicapp.R; 14 | 15 | import static androidx.test.espresso.Espresso.onView; 16 | import static androidx.test.espresso.action.ViewActions.click; 17 | import static androidx.test.espresso.assertion.ViewAssertions.matches; 18 | import static androidx.test.espresso.matcher.ViewMatchers.withId; 19 | import static androidx.test.espresso.matcher.ViewMatchers.withText; 20 | 21 | @RunWith(AndroidJUnit4.class) 22 | @LargeTest 23 | public class MainActivityBasicTest { 24 | 25 | private static final String STRING_LISTENER = "N/A(N/A)"; 26 | private static final String STRING_TIMER = "00:00:00"; 27 | 28 | @Rule 29 | public ActivityTestRule mActivityRule = new ActivityTestRule<>( 30 | MainActivity.class); 31 | 32 | @Test 33 | public void basicFields_Test() { 34 | onView(withId(R.id.txtListeners)).check(matches(withText(STRING_LISTENER))); 35 | onView(withId(R.id.timerValue)).check(matches(withText(STRING_TIMER))); 36 | onView(withId(R.id.start_recording_button)).check(matches(withText("START LIVESTREAM"))); 37 | onView(withId(R.id.start_recording_button)).perform(click()); 38 | onView(withId(R.id.start_recording_button)).check(matches(withText("START LIVESTREAM"))); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 14 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 30 | 33 | 34 | 37 | 40 | 41 | 42 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /app/src/main/java/cc/echonet/coolmicapp/AboutActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) Jordan Erickson - 2014-2020, 3 | * Copyright (C) Löwenfelsen UG (haftungsbeschränkt) - 2015-2020 4 | * on behalf of Jordan Erickson. 5 | * 6 | * This file is part of Cool Mic. 7 | * 8 | * Cool Mic is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Cool Mic is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Cool Mic. If not, see . 20 | * 21 | */ 22 | 23 | package cc.echonet.coolmicapp; 24 | 25 | import android.app.ActionBar; 26 | import android.app.Activity; 27 | import android.content.ClipData; 28 | import android.content.ClipboardManager; 29 | import android.content.Intent; 30 | import android.net.Uri; 31 | import android.os.Build; 32 | import android.os.Bundle; 33 | import android.view.MenuItem; 34 | import android.view.View; 35 | import android.widget.TextView; 36 | import android.widget.Toast; 37 | import androidx.annotation.StringRes; 38 | import androidx.core.app.NavUtils; 39 | import cc.echonet.coolmicapp.Configuration.*; 40 | import cc.echonet.coolmicdspjava.Wrapper; 41 | import org.jetbrains.annotations.NotNull; 42 | 43 | import java.util.Locale; 44 | 45 | public class AboutActivity extends Activity { 46 | private ClipboardManager myClipboard; 47 | private int extra = 0; 48 | 49 | @Override 50 | protected void onCreate(Bundle savedInstanceState) { 51 | final @NotNull GlobalConfiguration globalConfiguration = new Manager(this).getGlobalConfiguration(); 52 | final @NotNull View developerModeLabel; 53 | 54 | super.onCreate(savedInstanceState); 55 | setContentView(R.layout.activity_about); 56 | 57 | this.setupActionBar(); 58 | 59 | developerModeLabel = findViewById(R.id.lblDeveloperMode); 60 | 61 | String shortRev = BuildConfig.GIT_REVISION.substring(BuildConfig.GIT_REVISION.length() - 8); 62 | 63 | ((TextView) findViewById(R.id.txtVersion)).setText(BuildConfig.VERSION_NAME); 64 | ((TextView) findViewById(R.id.txtBuildType)).setText(BuildConfig.BUILD_TYPE); 65 | ((TextView) findViewById(R.id.txtBuildTS)).setText(BuildConfig.BUILD_TS); 66 | ((TextView) findViewById(R.id.txtGITBranch)).setText(BuildConfig.GIT_BRANCH); 67 | ((TextView) findViewById(R.id.txtGITRevision)).setText(shortRev); 68 | ((TextView) findViewById(R.id.txtGITDirty)).setText(BuildConfig.GIT_DIRTY); 69 | ((TextView) findViewById(R.id.txtAPILevel)).setText(String.format(Locale.ROOT, "%d", Build.VERSION.SDK_INT)); 70 | ((TextView) findViewById(R.id.txtSystemArch)).setText(System.getProperty("os.arch")); 71 | 72 | findViewById(R.id.txtVersion).setOnClickListener(v -> { 73 | extra++; 74 | if (extra == 6) { 75 | Toast.makeText(AboutActivity.this, "yes", Toast.LENGTH_SHORT).show(); 76 | globalConfiguration.setDeveloperMode(true); 77 | developerModeLabel.setVisibility(View.VISIBLE); 78 | } 79 | }); 80 | 81 | developerModeLabel.setVisibility(globalConfiguration.getDeveloperMode() ? View.VISIBLE : View.GONE); 82 | developerModeLabel.setOnClickListener(v -> { 83 | globalConfiguration.setDeveloperMode(false); 84 | developerModeLabel.setVisibility(View.GONE); 85 | }); 86 | 87 | myClipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); 88 | 89 | findViewById(R.id.cmdAboutCopy).setOnClickListener(this::onCMDAboutCopy); 90 | findViewById(R.id.cmdDebugCopy).setOnClickListener(this::onCMDDebugCopy); 91 | findViewById(R.id.cmdOpenPrivacyPolicy).setOnClickListener(this::onCMDAboutOpenPP); 92 | findViewById(R.id.cmdOpenLicenses).setOnClickListener(this::onCMDAboutOpenLicenses); 93 | findViewById(R.id.cmdOpenSponsor).setOnClickListener(this::onCMDAboutOpenSponsor); 94 | } 95 | 96 | /** 97 | * Set up the {@link android.app.ActionBar}, if the API is available. 98 | */ 99 | private void setupActionBar() { 100 | ActionBar actionBar = getActionBar(); 101 | if (actionBar != null) { 102 | // Show the Up button in the action bar. 103 | actionBar.setDisplayHomeAsUpEnabled(true); 104 | } 105 | } 106 | 107 | public boolean onOptionsItemSelected(MenuItem item) { 108 | // Respond to the action bar's Up/Home button 109 | if (item.getItemId() == android.R.id.home) { 110 | NavUtils.navigateUpFromSameTask(this); 111 | return true; 112 | } 113 | 114 | return super.onOptionsItemSelected(item); 115 | } 116 | 117 | private @NotNull String getInfoAsString(boolean debug) { 118 | final @NotNull String base = getString( 119 | R.string.aboutactivity_copy_string, 120 | BuildConfig.VERSION_NAME, 121 | BuildConfig.BUILD_TYPE, 122 | BuildConfig.GIT_BRANCH, 123 | BuildConfig.GIT_REVISION, 124 | BuildConfig.GIT_DIRTY, 125 | Build.VERSION.SDK_INT, 126 | System.getProperty("os.arch") 127 | ); 128 | 129 | if (!debug) 130 | return base; 131 | 132 | { 133 | final @NotNull Manager manager = new Manager(this); 134 | final @NotNull GlobalConfiguration globalConfiguration = manager.getGlobalConfiguration(); 135 | final @NotNull Profile profile = manager.getCurrentProfile(); 136 | final @NotNull Audio audio = profile.getAudio(); 137 | final @NotNull Codec codec = profile.getCodec(); 138 | final @NotNull Volume volume = profile.getVolume(); 139 | 140 | return getString(R.string.aboutactivity_copy_string_debug, base, 141 | globalConfiguration.getDeveloperMode(), 142 | globalConfiguration.getCurrentProfileName(), 143 | audio.getSampleRate(), 144 | audio.getChannels(), 145 | codec.getType(), 146 | codec.getQuality(), 147 | profile.getVUMeter().getInterval(), 148 | volume.getLeft(), 149 | volume.getRight(), 150 | CMTS.isCMTSConnection(profile), 151 | Wrapper.getStaticInitializationState() 152 | ); 153 | } 154 | } 155 | 156 | private void onCMDAboutCopy(View view) { 157 | ClipData myClip = ClipData.newPlainText("text", getInfoAsString(false)); 158 | myClipboard.setPrimaryClip(myClip); 159 | Toast.makeText(getApplicationContext(), R.string.aboutactivity_copied_string, Toast.LENGTH_SHORT).show(); 160 | } 161 | 162 | private void onCMDDebugCopy(View view) { 163 | ClipData myClip = ClipData.newPlainText("text", getInfoAsString(true)); 164 | myClipboard.setPrimaryClip(myClip); 165 | Toast.makeText(getApplicationContext(), R.string.aboutactivity_copied_string, Toast.LENGTH_SHORT).show(); 166 | } 167 | 168 | private void goToURI(@StringRes int uri) { 169 | final Intent helpIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(getString(uri))); 170 | startActivity(helpIntent); 171 | } 172 | 173 | private void onCMDAboutOpenPP(View view) { 174 | goToURI(R.string.url_privacy_policy); 175 | } 176 | 177 | private void onCMDAboutOpenLicenses(View view) { 178 | goToURI(R.string.url_licenses); 179 | } 180 | 181 | private void onCMDAboutOpenSponsor(View view) { 182 | goToURI(R.string.url_sponsor); 183 | } 184 | 185 | } 186 | -------------------------------------------------------------------------------- /app/src/main/java/cc/echonet/coolmicapp/BackgroundService/Client/EventListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) Jordan Erickson - 2014-2020, 3 | * Copyright (C) Löwenfelsen UG (haftungsbeschränkt) - 2015-2020 4 | * on behalf of Jordan Erickson. 5 | * 6 | * This file is part of Cool Mic. 7 | * 8 | * Cool Mic is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Cool Mic is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Cool Mic. If not, see . 20 | * 21 | */ 22 | 23 | package cc.echonet.coolmicapp.BackgroundService.Client; 24 | 25 | import cc.echonet.coolmicapp.BackgroundService.State; 26 | import cc.echonet.coolmicdspjava.VUMeterResult; 27 | 28 | public interface EventListener { 29 | void onBackgroundServiceConnected(); 30 | void onBackgroundServiceDisconnected(); 31 | void onBackgroundServiceState(State state); 32 | void onBackgroundServiceError(/*TODO*/); 33 | void onBackgroundServiceStartRecording(); 34 | void onBackgroundServiceStopRecording(); 35 | void onBackgroundServicePermissionsMissing(); 36 | void onBackgroundServiceConnectionUnset(); /* TODO: ??? */ 37 | void onBackgroundServiceCMTSTOSAcceptMissing(); 38 | void onBackgroundServiceVUMeterUpdate(VUMeterResult result); 39 | void onBackgroundServiceGainUpdate(int left, int right); 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/java/cc/echonet/coolmicapp/BackgroundService/Client/SyncOnce.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) Jordan Erickson - 2014-2020, 3 | * Copyright (C) Löwenfelsen UG (haftungsbeschränkt) - 2015-2020 4 | * on behalf of Jordan Erickson. 5 | * 6 | * This file is part of Cool Mic. 7 | * 8 | * Cool Mic is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Cool Mic is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Cool Mic. If not, see . 20 | * 21 | */ 22 | 23 | package cc.echonet.coolmicapp.BackgroundService.Client; 24 | 25 | import android.util.Log; 26 | 27 | import org.jetbrains.annotations.NotNull; 28 | 29 | public class SyncOnce { 30 | @SuppressWarnings("HardcodedFileSeparator") 31 | private static final String TAG = "BGS/Client/SyncOnce"; 32 | 33 | private final @NotNull Object notifyBus = new Object(); 34 | private boolean state = false; 35 | 36 | public void ready() { 37 | state = true; 38 | 39 | Log.d(TAG, "ready: this=" + this); 40 | 41 | synchronized (notifyBus) { 42 | notifyBus.notifyAll(); 43 | } 44 | } 45 | 46 | public void sync() throws InterruptedException { 47 | Log.d(TAG, "sync: this=" + this + ", IN"); 48 | 49 | while (true) { 50 | synchronized (this) { 51 | if (state) { 52 | Log.d(TAG, "sync: this=" + this + ", OUT"); 53 | return; 54 | } 55 | } 56 | 57 | synchronized (notifyBus) { 58 | notifyBus.wait(50); 59 | } 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /app/src/main/java/cc/echonet/coolmicapp/BackgroundService/Constants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) Jordan Erickson - 2014-2020, 3 | * Copyright (C) Löwenfelsen UG (haftungsbeschränkt) - 2015-2020 4 | * on behalf of Jordan Erickson. 5 | * 6 | * This file is part of Cool Mic. 7 | * 8 | * Cool Mic is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Cool Mic is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Cool Mic. If not, see . 20 | * 21 | */ 22 | 23 | package cc.echonet.coolmicapp.BackgroundService; 24 | 25 | public class Constants { 26 | /* client-to-server */ 27 | public static final int C2S_MSG_STATE = 1; 28 | public static final int C2S_MSG_STREAM_ACTION = 2; 29 | public static final int C2S_MSG_STREAM_RELOAD = 3; 30 | public static final int C2S_MSG_GAIN = 4; 31 | public static final int C2S_MSG_STREAM_STOP = 5; 32 | public static final int C2S_MSG_NEXT_SEGMENT = 6; 33 | 34 | /* server-to-client */ 35 | public static final int S2C_MSG_STATE_REPLY = 52; 36 | public static final int S2C_MSG_STREAM_STOP_REPLY = 53; 37 | public static final int S2C_MSG_STREAM_START_REPLY = 54; 38 | public static final int S2C_MSG_PERMISSIONS_MISSING = 55; 39 | public static final int S2C_MSG_CONNECTION_UNSET = 56; 40 | public static final int S2C_MSG_CMTS_TOS = 57; 41 | public static final int S2C_MSG_VUMETER = 58; 42 | public static final int S2C_MSG_ERROR = 59; 43 | public static final int S2C_MSG_GAIN = 60; 44 | 45 | /* ???-to-server */ 46 | public static final int H2S_MSG_TIMER = 100; 47 | 48 | /* any-to-any */ 49 | public static final int A2A_MSG_NONE = 1000; 50 | 51 | public static final int NEXTSEGMENT_REQUEST_CODE = 33; 52 | 53 | public static final int NOTIFICATION_ID_LED = 0; 54 | 55 | public enum CONTROL_UI { 56 | CONTROL_UI_CONNECTING, 57 | CONTROL_UI_CONNECTED, 58 | CONTROL_UI_DISCONNECTED 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /app/src/main/java/cc/echonet/coolmicapp/BackgroundService/Server/Driver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) Jordan Erickson - 2014-2020, 3 | * Copyright (C) Löwenfelsen UG (haftungsbeschränkt) - 2015-2020 4 | * on behalf of Jordan Erickson. 5 | * 6 | * This file is part of Cool Mic. 7 | * 8 | * Cool Mic is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Cool Mic is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Cool Mic. If not, see . 20 | * 21 | */ 22 | 23 | package cc.echonet.coolmicapp.BackgroundService.Server; 24 | 25 | import android.content.Context; 26 | import android.media.AudioFormat; 27 | import android.media.AudioRecord; 28 | import android.util.Log; 29 | import android.widget.Toast; 30 | import androidx.annotation.NonNull; 31 | import androidx.annotation.Nullable; 32 | import cc.echonet.coolmicapp.BuildConfig; 33 | import cc.echonet.coolmicapp.Configuration.Profile; 34 | import cc.echonet.coolmicapp.Configuration.Server; 35 | import cc.echonet.coolmicapp.Configuration.Track; 36 | import cc.echonet.coolmicapp.R; 37 | import cc.echonet.coolmicdspjava.CallbackHandler; 38 | import cc.echonet.coolmicdspjava.Wrapper; 39 | import cc.echonet.coolmicdspjava.WrapperConstants; 40 | import org.jetbrains.annotations.Contract; 41 | import org.jetbrains.annotations.NotNull; 42 | 43 | import java.io.Closeable; 44 | import java.io.IOException; 45 | import java.io.InputStream; 46 | import java.util.HashMap; 47 | import java.util.Locale; 48 | import java.util.Map; 49 | import java.util.Objects; 50 | 51 | final class Driver implements Closeable { 52 | @SuppressWarnings("HardcodedFileSeparator") 53 | private static final String TAG = "BGS/Driver"; 54 | 55 | private final @NonNull Wrapper wrapper = new Wrapper(); 56 | private final @NonNull Context context; 57 | private @NonNull Profile profile; 58 | private final @NonNull CallbackHandler callbackHandler; 59 | private @Nullable String codec; 60 | 61 | private WrapperConstants.WrapperInitializationStatus initWrapper() { 62 | final WrapperConstants.WrapperInitializationStatus status = wrapper.getState(); 63 | final Context applicationContext = context.getApplicationContext(); 64 | 65 | Log.d(TAG, "initWrapper: status = " + status); 66 | 67 | switch (status) { 68 | case WRAPPER_UNINITIALIZED: 69 | break; 70 | case WRAPPER_INITIALIZATION_ERROR: 71 | Log.d(TAG, "initWrapper: Wrapper's exception: " + Objects.requireNonNull(wrapper.getInitException())); 72 | Toast.makeText(applicationContext, R.string.mainactivity_native_components_init_error, Toast.LENGTH_SHORT).show(); 73 | break; 74 | case WRAPPER_INTITIALIZED: 75 | Log.d(TAG, "initWrapper: Wrapper is ready."); 76 | break; 77 | default: 78 | Toast.makeText(applicationContext, R.string.mainactivity_native_components_unknown_state, Toast.LENGTH_SHORT).show(); 79 | } 80 | 81 | return status; 82 | } 83 | 84 | Driver(@NonNull Context context, @NonNull Profile profile, @NonNull CallbackHandler callbackHandler) { 85 | this.context = context; 86 | this.profile = profile; 87 | this.callbackHandler = callbackHandler; 88 | 89 | Log.d(TAG, "Driver() called with: context = [" + context + "], profile = [" + profile + "], callbackHandler = [" + callbackHandler + "]"); 90 | 91 | initWrapper(); 92 | } 93 | 94 | public void setProfile(@NonNull Profile profile) { 95 | this.profile = profile; 96 | } 97 | 98 | public boolean isReady() { 99 | return initWrapper() == WrapperConstants.WrapperInitializationStatus.WRAPPER_INTITIALIZED; 100 | } 101 | 102 | public boolean hasCore() { 103 | return isReady() && wrapper.isPrepared(); 104 | } 105 | 106 | public void startStream() throws IOException { 107 | Server server = profile.getServer(); 108 | 109 | String hostname = server.getHostname(); 110 | int port_num = server.getPort(); 111 | String username = server.getUsername(); 112 | String password = server.getPassword(); 113 | String mountpoint = server.getMountpoint(); 114 | 115 | int sampleRate = profile.getAudio().getSampleRate(); 116 | int channel = profile.getAudio().getChannels(); 117 | 118 | codec = profile.getCodec().getType(); 119 | 120 | int bufferSize = AudioRecord.getMinBufferSize(sampleRate, channel == 1 ? AudioFormat.CHANNEL_IN_MONO : AudioFormat.CHANNEL_IN_STEREO, AudioFormat.ENCODING_PCM_16BIT); 121 | 122 | Log.d(TAG, hostname); 123 | Log.d(TAG, Integer.toString(port_num)); 124 | 125 | Log.d(TAG, "Minimum Buffer Size: " + bufferSize); 126 | int status = wrapper.prepare(callbackHandler, hostname, port_num, username, password, mountpoint, codec, sampleRate, channel, bufferSize, 127 | BuildConfig.HTTP_PRODUCT, BuildConfig.HTTP_VERSION, BuildConfig.HTTP_COMMENT, profile.getStation().getMetadata()); 128 | 129 | if (status != 0) { 130 | throw new IOException("Failed to init Core: " + status); 131 | } 132 | 133 | reloadParameters(false); 134 | 135 | status = wrapper.start(); 136 | 137 | Log.d(TAG, "Status:" + status); 138 | 139 | if (status != 0) { 140 | throw new IOException(context.getString(R.string.exception_start_failed, status)); 141 | } 142 | } 143 | 144 | public boolean stopStream() { 145 | codec = null; 146 | if (hasCore()) { 147 | wrapper.close(); 148 | return true; 149 | } 150 | return false; 151 | } 152 | 153 | public void reloadParameters(boolean restart) throws IOException { 154 | final @NotNull Track track = profile.getTrack(); 155 | final @NotNull Map<@NotNull String, @NotNull String> trackMetadata = new HashMap<>(); 156 | int status; 157 | 158 | for (final @NotNull String key : track.getKeys()) { 159 | trackMetadata.put(key.toUpperCase(Locale.ROOT), Objects.requireNonNull(track.getValue(key, null))); 160 | } 161 | 162 | status = wrapper.performMetaDataQualityUpdate(trackMetadata, profile.getCodec().getQuality(), restart); 163 | 164 | if (status != 0) { 165 | throw new IOException(context.getString(R.string.exception_failed_metadata_quality, status)); 166 | } 167 | 168 | if (profile.getServer().getReconnect()) { 169 | status = wrapper.setReconnectionProfile("enabled"); 170 | } else { 171 | status = wrapper.setReconnectionProfile("disabled"); 172 | } 173 | 174 | if (status != 0) { 175 | throw new IOException(context.getString(R.string.exception_failed_reconnect, status)); 176 | } 177 | 178 | int interval = profile.getVUMeter().getInterval(); 179 | 180 | /* Normalize interval to a sample rate of 48kHz (as per Opus specs). */ 181 | interval = (interval * profile.getAudio().getSampleRate()) / 48000; 182 | 183 | wrapper.setVuMeterInterval(interval); 184 | } 185 | 186 | public void setGain(int scale, int left, int right) { 187 | wrapper.setMasterGain(scale, left, right); 188 | } 189 | 190 | public void setGain(int scale, int gain) { 191 | wrapper.setMasterGain(scale, gain); 192 | } 193 | 194 | public void nextSegment(@Nullable InputStream inputStream) { 195 | 196 | if (inputStream == null) { 197 | wrapper.nextSegment(); 198 | } else { 199 | wrapper.nextSegment(inputStream); 200 | } 201 | } 202 | 203 | @Contract(pure = true) 204 | public @Nullable String getCodec() { 205 | return codec; 206 | } 207 | 208 | @Override 209 | public void close() { 210 | stopStream(); 211 | } 212 | } 213 | -------------------------------------------------------------------------------- /app/src/main/java/cc/echonet/coolmicapp/BackgroundService/State.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) Jordan Erickson - 2014-2020, 3 | * Copyright (C) Löwenfelsen UG (haftungsbeschränkt) - 2015-2020 4 | * on behalf of Jordan Erickson. 5 | * 6 | * This file is part of Cool Mic. 7 | * 8 | * Cool Mic is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Cool Mic is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Cool Mic. If not, see . 20 | * 21 | */ 22 | 23 | package cc.echonet.coolmicapp.BackgroundService; 24 | 25 | import android.content.Context; 26 | import android.util.Log; 27 | 28 | import org.jetbrains.annotations.NotNull; 29 | 30 | import java.io.Serializable; 31 | 32 | import cc.echonet.coolmicapp.R; 33 | 34 | /** 35 | * Created by stephan on 2/24/18. 36 | */ 37 | 38 | public class State implements Serializable { 39 | public Constants.CONTROL_UI uiState = Constants.CONTROL_UI.CONTROL_UI_DISCONNECTED; 40 | public String txtState = "Disconnected"; 41 | 42 | public int bindCounts = 0; 43 | public int clientCount = 0; 44 | public boolean initialConnectPerformed = false; 45 | public long timerInMS = 0L; 46 | public long startTime = 0L; 47 | public int listeners_current; 48 | public int listeners_peak; 49 | public long lastStateFetch = 0L; 50 | public boolean hadError = false; 51 | public long channels = 1; 52 | public boolean isLive = true; 53 | 54 | public State() { 55 | Log.v("State", "BSS constructed"); 56 | } 57 | 58 | public @NotNull String getTimerString(@NotNull Context context) { 59 | int secs = (int) (timerInMS / 1000); 60 | int mins = secs / 60; 61 | int hours = mins / 60; 62 | 63 | secs = secs % 60; 64 | mins = mins % 60; 65 | 66 | return context.getString(R.string.timer_format, hours, mins, secs); 67 | } 68 | 69 | public @NotNull String getTextState(@NotNull Context context) { 70 | return txtState; 71 | } 72 | 73 | public @NotNull String getListenersString(@NotNull Context context) { 74 | return context.getString(R.string.formatListeners, listeners_current, listeners_peak); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /app/src/main/java/cc/echonet/coolmicapp/CMTS.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) Jordan Erickson - 2014-2020, 3 | * Copyright (C) Löwenfelsen UG (haftungsbeschränkt) - 2015-2020 4 | * on behalf of Jordan Erickson. 5 | * 6 | * This file is part of Cool Mic. 7 | * 8 | * Cool Mic is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Cool Mic is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Cool Mic. If not, see . 20 | * 21 | */ 22 | 23 | package cc.echonet.coolmicapp; 24 | 25 | import android.content.Context; 26 | import android.util.Base64; 27 | 28 | import org.jetbrains.annotations.NotNull; 29 | 30 | import java.security.MessageDigest; 31 | import java.security.NoSuchAlgorithmException; 32 | import java.util.UUID; 33 | 34 | import cc.echonet.coolmicapp.Configuration.Profile; 35 | import cc.echonet.coolmicapp.Configuration.Server; 36 | 37 | public final class CMTS { 38 | private static final String[] CMTSHosts = {"coolmic.net", "echonet.cc", "64.142.100.248", "64.142.100.249", "46.165.219.118"}; 39 | 40 | public static boolean isCMTSConnection(@NotNull Profile profile) { 41 | String serverName = profile.getServer().getHostname(); 42 | 43 | for (String cmtsHost : CMTSHosts) { 44 | if (serverName.endsWith(cmtsHost)) { 45 | return true; 46 | } 47 | } 48 | 49 | return false; 50 | } 51 | 52 | private static String generateShortUuid() { 53 | UUID uuid = UUID.randomUUID(); 54 | MessageDigest md; 55 | try { 56 | md = MessageDigest.getInstance("SHA-256"); 57 | } catch (NoSuchAlgorithmException e) { 58 | e.printStackTrace(); 59 | return uuid.toString(); 60 | } 61 | 62 | 63 | md.update(uuid.toString().getBytes()); 64 | byte[] digest = md.digest(); 65 | 66 | return Base64.encodeToString(digest, Base64.URL_SAFE | Base64.NO_WRAP | Base64.NO_PADDING).substring(0, 20); 67 | } 68 | 69 | public static void loadCMTSData(@NotNull Profile profile) { 70 | final @NotNull String randomComponent = generateShortUuid(); 71 | final @NotNull Context context = profile.getContext(); 72 | final @NotNull Server server; 73 | 74 | /* copy profile so we have our own edit state */ 75 | profile = new Profile(profile); 76 | 77 | profile.edit(); 78 | 79 | profile.getCodec().setType(context.getString(R.string.pref_default_audio_codec)); 80 | profile.getAudio().setSampleRate(Integer.parseInt(context.getString(R.string.pref_default_audio_samplerate))); 81 | server = profile.getServer(); 82 | server.setAddress(context.getString(R.string.pref_default_connection_address)); 83 | server.setUsername(context.getString(R.string.pref_default_connection_username)); 84 | server.setPassword(context.getString(R.string.pref_default_connection_password)); 85 | server.setMountpoint(context.getString(R.string.pref_default_connection_mountpoint, randomComponent)); 86 | 87 | profile.apply(); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /app/src/main/java/cc/echonet/coolmicapp/Configuration/Audio.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) Jordan Erickson - 2014-2020, 3 | * Copyright (C) Löwenfelsen UG (haftungsbeschränkt) - 2015-2020 4 | * on behalf of Jordan Erickson. 5 | * 6 | * This file is part of Cool Mic. 7 | * 8 | * Cool Mic is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Cool Mic is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Cool Mic. If not, see . 20 | * 21 | */ 22 | 23 | package cc.echonet.coolmicapp.Configuration; 24 | 25 | import org.jetbrains.annotations.NotNull; 26 | 27 | import cc.echonet.coolmicapp.R; 28 | 29 | public class Audio extends ProfileBase { 30 | Audio(@NotNull ProfileBase profile) { 31 | super(profile); 32 | } 33 | 34 | public int getSampleRate() { 35 | return Integer.parseInt(getString("audio_samplerate", R.string.pref_default_audio_samplerate)); 36 | } 37 | 38 | public void setSampleRate(int sampleRate) { 39 | editor.putString("audio_samplerate", Integer.toString(sampleRate)); 40 | } 41 | 42 | public int getChannels() { 43 | return Integer.parseInt(getString("audio_channels", R.string.pref_default_audio_channels)); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /app/src/main/java/cc/echonet/coolmicapp/Configuration/Codec.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) Jordan Erickson - 2014-2020, 3 | * Copyright (C) Löwenfelsen UG (haftungsbeschränkt) - 2015-2020 4 | * on behalf of Jordan Erickson. 5 | * 6 | * This file is part of Cool Mic. 7 | * 8 | * Cool Mic is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Cool Mic is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Cool Mic. If not, see . 20 | * 21 | */ 22 | 23 | package cc.echonet.coolmicapp.Configuration; 24 | 25 | import org.jetbrains.annotations.NotNull; 26 | import org.jetbrains.annotations.Nullable; 27 | 28 | import cc.echonet.coolmicapp.R; 29 | 30 | @SuppressWarnings("HardcodedFileSeparator") 31 | public class Codec extends ProfileBase { 32 | public static final @NotNull String TYPE_OGG = "application/ogg"; 33 | public static final @NotNull String TYPE_OPUS = "audio/ogg; codec=opus"; 34 | public static final @NotNull String TYPE_VORBIS = "audio/ogg; codec=vorbis"; 35 | public static final @NotNull String TYPE_AAC = "audio/aac"; 36 | public static final @NotNull String TYPE_MP3 = "audio/mpeg"; 37 | 38 | private final @NotNull Audio audio; 39 | 40 | Codec(@NotNull ProfileBase profile, @NotNull Audio audio) { 41 | super(profile); 42 | this.audio = audio; 43 | } 44 | 45 | public @NotNull Audio getAudio() { 46 | return audio; 47 | } 48 | 49 | public String getType() { 50 | return getString("audio_codec", R.string.pref_default_audio_codec); 51 | } 52 | 53 | public void setType(String type) { 54 | editor.putString("audio_codec", type); 55 | 56 | if (type.equals(TYPE_OPUS)) { 57 | /* Opus only supports 48kHz */ 58 | audio.setSampleRate(48000); 59 | } 60 | } 61 | 62 | public double getQuality() { 63 | return Double.parseDouble(getString("audio_quality", R.string.pref_default_audio_quality)); 64 | } 65 | 66 | public static boolean isOgg(@Nullable String type) { 67 | if (type == null) 68 | return false; 69 | 70 | switch (type) { 71 | case TYPE_OGG: 72 | case TYPE_VORBIS: 73 | case TYPE_OPUS: 74 | return true; 75 | } 76 | 77 | return false; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /app/src/main/java/cc/echonet/coolmicapp/Configuration/DialogIdentifier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) Jordan Erickson - 2014-2020, 3 | * Copyright (C) Löwenfelsen UG (haftungsbeschränkt) - 2015-2020 4 | * on behalf of Jordan Erickson. 5 | * 6 | * This file is part of Cool Mic. 7 | * 8 | * Cool Mic is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Cool Mic is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Cool Mic. If not, see . 20 | * 21 | */ 22 | 23 | package cc.echonet.coolmicapp.Configuration; 24 | 25 | public enum DialogIdentifier { 26 | FIRST_TIME, 27 | NEW_VERSION, 28 | PERMISSIONS; 29 | } 30 | -------------------------------------------------------------------------------- /app/src/main/java/cc/echonet/coolmicapp/Configuration/DialogState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) Jordan Erickson - 2014-2020, 3 | * Copyright (C) Löwenfelsen UG (haftungsbeschränkt) - 2015-2020 4 | * on behalf of Jordan Erickson. 5 | * 6 | * This file is part of Cool Mic. 7 | * 8 | * Cool Mic is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Cool Mic is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Cool Mic. If not, see . 20 | * 21 | */ 22 | 23 | package cc.echonet.coolmicapp.Configuration; 24 | 25 | import org.jetbrains.annotations.NotNull; 26 | 27 | import cc.echonet.coolmicapp.BuildConfig; 28 | 29 | public class DialogState extends ProfileBase { 30 | private static final String KEY_VERSION = "version"; 31 | private static final String KEY_TIMESTAMP = "timestamp"; 32 | 33 | private final @NotNull DialogIdentifier dialogIdentifier; 34 | 35 | DialogState(@NotNull ProfileBase profile, @NotNull DialogIdentifier dialogId) { 36 | super(profile); 37 | this.dialogIdentifier = dialogId; 38 | } 39 | 40 | private String buildKey(String subkey) { 41 | return "dialogstate-" + getDialogIdentifier() + "-" + subkey; 42 | } 43 | 44 | private String buildVersionString() { 45 | return BuildConfig.VERSION_NAME + " " + 46 | BuildConfig.GIT_REVISION + "-" + 47 | BuildConfig.GIT_DIRTY + " " + 48 | "[" + BuildConfig.BUILD_TS + "]"; 49 | } 50 | 51 | public @NotNull DialogIdentifier getDialogIdentifier() { 52 | return dialogIdentifier; 53 | } 54 | 55 | public boolean hasEverShown() { 56 | return !getString(buildKey(KEY_VERSION)).equals(""); 57 | } 58 | 59 | public boolean hasShownInThisVersion() { 60 | return buildVersionString().equals(getString(buildKey(KEY_VERSION))); 61 | } 62 | 63 | public void shown() { 64 | edit(); 65 | editor.putString(buildKey(KEY_VERSION), buildVersionString()); 66 | editor.putLong(buildKey(KEY_TIMESTAMP), System.currentTimeMillis()); 67 | apply(); 68 | } 69 | 70 | public void reset() { 71 | edit(); 72 | editor.putString(buildKey(KEY_VERSION), ""); 73 | editor.putLong(buildKey(KEY_TIMESTAMP), Long.MIN_VALUE); 74 | apply(); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /app/src/main/java/cc/echonet/coolmicapp/Configuration/GlobalConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) Jordan Erickson - 2014-2020, 3 | * Copyright (C) Löwenfelsen UG (haftungsbeschränkt) - 2015-2020 4 | * on behalf of Jordan Erickson. 5 | * 6 | * This file is part of Cool Mic. 7 | * 8 | * Cool Mic is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Cool Mic is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Cool Mic. If not, see . 20 | * 21 | */ 22 | 23 | package cc.echonet.coolmicapp.Configuration; 24 | 25 | import android.content.Context; 26 | import android.content.SharedPreferences; 27 | import android.preference.PreferenceManager; 28 | 29 | import org.jetbrains.annotations.Contract; 30 | import org.jetbrains.annotations.NotNull; 31 | 32 | import cc.echonet.coolmicapp.BuildConfig; 33 | 34 | public class GlobalConfiguration { 35 | private static final String PROFILE_NAME = "_global"; 36 | private static final String KEY_PROFILE_CURRENT = "profile_current"; 37 | private static final String KEY_DEVELOPER_MODE = "developer_mode"; 38 | 39 | private final @NotNull Context context; 40 | private final @NotNull SharedPreferences prefs; 41 | 42 | public GlobalConfiguration(@NotNull Context context) { 43 | this.context = context; 44 | this.prefs = context.getSharedPreferences(PROFILE_NAME, Context.MODE_PRIVATE); 45 | 46 | setDefaults(); 47 | } 48 | 49 | private void setDefaults() { 50 | SharedPreferences.Editor editor; 51 | 52 | if (prefs.getBoolean(PreferenceManager.KEY_HAS_SET_DEFAULT_VALUES, false)) 53 | return; 54 | 55 | editor = prefs.edit(); 56 | 57 | editor.putString(KEY_PROFILE_CURRENT, Manager.DEFAULT_PROFILE); 58 | editor.putBoolean(KEY_DEVELOPER_MODE, getDeveloperModeDefault()); 59 | 60 | editor.putBoolean(PreferenceManager.KEY_HAS_SET_DEFAULT_VALUES, true).apply(); 61 | editor.apply(); 62 | } 63 | 64 | public String getCurrentProfileName() { 65 | return prefs.getString(KEY_PROFILE_CURRENT, Manager.DEFAULT_PROFILE); 66 | } 67 | 68 | public void setCurrentProfileName(String profileName) { 69 | Profile.assertValidProfileName(profileName); 70 | prefs.edit().putString(KEY_PROFILE_CURRENT, profileName).apply(); 71 | } 72 | 73 | @Contract(pure = true) 74 | private boolean getDeveloperModeDefault() { 75 | //noinspection ConstantConditions 76 | return BuildConfig.FLAVOR.equals("debugdev"); 77 | } 78 | 79 | public boolean getDeveloperMode() { 80 | return prefs.getBoolean(KEY_DEVELOPER_MODE, getDeveloperModeDefault()); 81 | } 82 | 83 | public void setDeveloperMode(boolean mode) { 84 | prefs.edit().putBoolean(KEY_DEVELOPER_MODE, mode).apply(); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /app/src/main/java/cc/echonet/coolmicapp/Configuration/Manager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) Jordan Erickson - 2014-2020, 3 | * Copyright (C) Löwenfelsen UG (haftungsbeschränkt) - 2015-2020 4 | * on behalf of Jordan Erickson. 5 | * 6 | * This file is part of Cool Mic. 7 | * 8 | * Cool Mic is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Cool Mic is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Cool Mic. If not, see . 20 | * 21 | */ 22 | 23 | package cc.echonet.coolmicapp.Configuration; 24 | 25 | import android.content.Context; 26 | 27 | import org.jetbrains.annotations.NotNull; 28 | 29 | import java.util.ArrayList; 30 | import java.util.List; 31 | 32 | public class Manager { 33 | static final String DEFAULT_PROFILE = "default"; 34 | 35 | private final @NotNull Context context; 36 | private final @NotNull GlobalConfiguration globalConfiguration; 37 | 38 | public Manager(@NotNull Context context) { 39 | this.context = context; 40 | this.globalConfiguration = new GlobalConfiguration(context); 41 | } 42 | 43 | public List getProfileNames() { 44 | // TODO: Implement actual reading of the list... 45 | ArrayList list = new ArrayList<>(); 46 | list.add(DEFAULT_PROFILE); 47 | return list; 48 | } 49 | 50 | public Profile getDefaultProfile() { 51 | return getProfile(DEFAULT_PROFILE); 52 | } 53 | 54 | public Profile getProfile(String name) { 55 | return new Profile(context, name); 56 | } 57 | 58 | public Profile getCurrentProfile() { 59 | return getProfile(globalConfiguration.getCurrentProfileName()); 60 | } 61 | 62 | public @NotNull GlobalConfiguration getGlobalConfiguration() { 63 | return globalConfiguration; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /app/src/main/java/cc/echonet/coolmicapp/Configuration/Profile.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) Jordan Erickson - 2014-2020, 3 | * Copyright (C) Löwenfelsen UG (haftungsbeschränkt) - 2015-2020 4 | * on behalf of Jordan Erickson. 5 | * 6 | * This file is part of Cool Mic. 7 | * 8 | * Cool Mic is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Cool Mic is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Cool Mic. If not, see . 20 | * 21 | */ 22 | 23 | package cc.echonet.coolmicapp.Configuration; 24 | 25 | import android.content.Context; 26 | 27 | import org.jetbrains.annotations.NotNull; 28 | 29 | public class Profile extends ProfileBase { 30 | private static final int DEFAULT_VOLUME = 100; 31 | 32 | public Profile(@NotNull Profile profile) { 33 | super(profile); 34 | } 35 | 36 | public Profile(@NotNull Context context, @NotNull String profile) { 37 | super(context, profile); 38 | } 39 | 40 | //Stolen from: http://stackoverflow.com/a/23704728 & http://stackoverflow.com/a/18879453 (removed the shortening because it did not work reliably) 41 | public @NotNull Track getTrack() { 42 | return new Track(this); 43 | } 44 | 45 | public @NotNull Station getStation() { 46 | return new Station(this); 47 | } 48 | 49 | public @NotNull Server getServer() { 50 | return new Server(this); 51 | } 52 | 53 | public @NotNull Audio getAudio() { 54 | return new Audio(this); 55 | } 56 | 57 | public @NotNull Codec getCodec() { 58 | return new Codec(this, getAudio()); 59 | } 60 | 61 | public @NotNull VUMeter getVUMeter() { 62 | return new VUMeter(this); 63 | } 64 | 65 | public @NotNull Volume getVolume() { 66 | return new Volume(this, getAudio()); 67 | } 68 | 69 | public @NotNull DialogState getDialogState(DialogIdentifier dialogIdentifier) { 70 | return new DialogState(this, dialogIdentifier); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /app/src/main/java/cc/echonet/coolmicapp/Configuration/ProfileBase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) Jordan Erickson - 2014-2020, 3 | * Copyright (C) Löwenfelsen UG (haftungsbeschränkt) - 2015-2020 4 | * on behalf of Jordan Erickson. 5 | * 6 | * This file is part of Cool Mic. 7 | * 8 | * Cool Mic is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Cool Mic is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Cool Mic. If not, see . 20 | * 21 | */ 22 | 23 | package cc.echonet.coolmicapp.Configuration; 24 | 25 | import android.annotation.SuppressLint; 26 | import android.content.Context; 27 | import android.content.SharedPreferences; 28 | import android.preference.PreferenceManager; 29 | 30 | import org.jetbrains.annotations.NotNull; 31 | 32 | import cc.echonet.coolmicapp.R; 33 | 34 | abstract class ProfileBase { 35 | protected final Context context; 36 | protected String profileName; 37 | protected final SharedPreferences prefs; 38 | protected SharedPreferences.Editor editor; 39 | 40 | public static void assertValidProfileName(String profileName) { 41 | if (profileName.startsWith("_")) 42 | throw new IllegalArgumentException("Bad Profile name: "+profileName); 43 | } 44 | 45 | ProfileBase(Context context, String profileName) { 46 | assertValidProfileName(profileName); 47 | 48 | this.context = context; 49 | this.profileName = profileName; 50 | this.prefs = context.getSharedPreferences(profileName, Context.MODE_PRIVATE); 51 | 52 | if (!this.prefs.getBoolean(PreferenceManager.KEY_HAS_SET_DEFAULT_VALUES, false)) { 53 | PreferenceManager.setDefaultValues(context, profileName, Context.MODE_PRIVATE, R.xml.pref_all, true); 54 | 55 | this.prefs.edit().putBoolean(PreferenceManager.KEY_HAS_SET_DEFAULT_VALUES, true).apply(); 56 | } 57 | } 58 | 59 | ProfileBase(@NotNull ProfileBase profile) { 60 | this.context = profile.context; 61 | this.profileName = profile.profileName; 62 | this.prefs = profile.prefs; 63 | this.editor = profile.editor; 64 | } 65 | 66 | String getString(String key) { 67 | return getString(key, ""); 68 | } 69 | 70 | String getString(String key, String def) { 71 | return prefs.getString(key, def); 72 | } 73 | 74 | String getString(String key, int def) { 75 | return getString(key, context.getString(def)); 76 | } 77 | 78 | boolean getBoolean(String key, boolean def) { 79 | return prefs.getBoolean(key, def); 80 | } 81 | 82 | public String getName() { 83 | return profileName; 84 | } 85 | 86 | public Context getContext() { 87 | return context; 88 | } 89 | 90 | @SuppressLint("CommitPrefEdits") 91 | public void edit() { 92 | editor = prefs.edit(); 93 | } 94 | 95 | public void apply() { 96 | editor.apply(); 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /app/src/main/java/cc/echonet/coolmicapp/Configuration/Server.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) Jordan Erickson - 2014-2020, 3 | * Copyright (C) Löwenfelsen UG (haftungsbeschränkt) - 2015-2020 4 | * on behalf of Jordan Erickson. 5 | * 6 | * This file is part of Cool Mic. 7 | * 8 | * Cool Mic is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Cool Mic is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Cool Mic. If not, see . 20 | * 21 | */ 22 | 23 | package cc.echonet.coolmicapp.Configuration; 24 | 25 | import org.jetbrains.annotations.NotNull; 26 | 27 | import java.net.MalformedURLException; 28 | import java.net.URL; 29 | import java.util.Locale; 30 | 31 | public class Server extends ProfileBase { 32 | Server(@NotNull ProfileBase profile) { 33 | super(profile); 34 | } 35 | 36 | @SuppressWarnings("SameReturnValue") 37 | public @NotNull String getProtocol() { 38 | // TODO: This is static for now but may change in future. 39 | return "http"; 40 | } 41 | 42 | public String getHostname() { 43 | String serverName = getString("connection_address"); 44 | 45 | if (serverName.indexOf(':') > 0) { 46 | serverName = serverName.split(":", 2)[0]; 47 | } 48 | 49 | return serverName; 50 | } 51 | 52 | public int getPort() { 53 | String serverName = getString("connection_address"); 54 | 55 | if (serverName.indexOf(':') > 0) { 56 | return Integer.parseInt(serverName.split(":", 2)[1]); 57 | } 58 | 59 | return 8000; 60 | } 61 | 62 | public void setAddress(@NotNull String hostname, int port) { 63 | if (hostname.indexOf(':') > 0) 64 | throw new IllegalArgumentException("Bad Hostname"); 65 | 66 | if (port < 0 || port > 65535) 67 | throw new IllegalArgumentException("Bad Port number"); 68 | 69 | if (port == 0) { 70 | editor.putString("connection_address", hostname); 71 | } else { 72 | editor.putString("connection_address", String.format(Locale.ENGLISH, "%s:%d", hostname, port)); 73 | } 74 | } 75 | 76 | public void setAddress(@NotNull String address) { 77 | String hostname; 78 | int port; 79 | 80 | if (address.indexOf(':') > 0) { 81 | String[] splitted = address.split(":", 2); 82 | hostname = splitted[0]; 83 | port = Integer.parseInt(splitted[1]); 84 | } else { 85 | hostname = address; 86 | port = 0; 87 | } 88 | 89 | setAddress(hostname, port); 90 | } 91 | 92 | public String getUsername() { 93 | return getString("connection_username"); 94 | } 95 | 96 | public void setUsername(String username) { 97 | editor.putString("connection_username", username); 98 | } 99 | 100 | public String getPassword() { 101 | return getString("connection_password"); 102 | } 103 | 104 | public void setPassword(String password) { 105 | editor.putString("connection_password", password); 106 | } 107 | 108 | public boolean getReconnect() { 109 | return getBoolean("connection_reconnect", false); 110 | } 111 | 112 | public String getMountpoint() { 113 | return getString("connection_mountpoint"); 114 | } 115 | 116 | public void setMountpoint(String mountpoint) { 117 | editor.putString("connection_mountpoint", mountpoint); 118 | } 119 | 120 | public boolean isSet() { 121 | return !getHostname().isEmpty() && !getMountpoint().isEmpty() && !getUsername().isEmpty() && !getPassword().isEmpty(); 122 | } 123 | 124 | public URL getStreamURL() throws MalformedURLException { 125 | return new URL(getProtocol(), getHostname(), getPort(), getMountpoint()); 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /app/src/main/java/cc/echonet/coolmicapp/Configuration/Station.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) Jordan Erickson - 2014-2020, 3 | * Copyright (C) Löwenfelsen UG (haftungsbeschränkt) - 2015-2020 4 | * on behalf of Jordan Erickson. 5 | * 6 | * This file is part of Cool Mic. 7 | * 8 | * Cool Mic is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Cool Mic is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Cool Mic. If not, see . 20 | * 21 | */ 22 | 23 | package cc.echonet.coolmicapp.Configuration; 24 | 25 | import cc.echonet.coolmicapp.Utils; 26 | import org.jetbrains.annotations.*; 27 | 28 | import java.util.*; 29 | 30 | public class Station extends ProfileBase { 31 | private static final @NotNull String[] KEY_LIST = new String[]{"name", "genre", "url", "description", "irc"}; 32 | public static final @NotNull @UnmodifiableView List<@NotNull String> STANDARD_KEYS = Collections.unmodifiableList(Arrays.asList(KEY_LIST)); 33 | 34 | private static void assertValidKey(@NotNull String key) { 35 | for (final @NotNull String validKey : KEY_LIST) { 36 | if (key.equals(validKey)) { 37 | return; 38 | } 39 | } 40 | 41 | throw new IllegalArgumentException("Invalid key: " + key); 42 | } 43 | 44 | public static @NotNull String getKeyDisplayName(@NotNull String key) { 45 | if (key.length() < 4) 46 | return key.toUpperCase(Locale.ROOT); 47 | return Utils.toUpperFirst(key); 48 | } 49 | 50 | Station(@NotNull ProfileBase profile) { 51 | super(profile); 52 | } 53 | 54 | @Unmodifiable 55 | public @NotNull Map<@NotNull String, @NotNull String> getMetadata() { 56 | final @NotNull Map<@NotNull String, @NotNull String> ret = new HashMap<>(); 57 | 58 | for (final @NotNull String key : KEY_LIST) { 59 | final @Nullable String value = getString("station_" + key); 60 | if (value != null && !value.isEmpty()) 61 | ret.put(key, value); 62 | } 63 | 64 | return Collections.unmodifiableMap(ret); 65 | } 66 | 67 | @Contract("_, !null -> !null; _, null -> _") 68 | public @Nullable String getValue(@NotNull String key, @Nullable String def) { 69 | assertValidKey(key); 70 | return getString("station_" + key, def); 71 | } 72 | 73 | public void setValue(@NotNull String key, @Nullable String value) { 74 | assertValidKey(key); 75 | editor.putString("station_" + key, value); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /app/src/main/java/cc/echonet/coolmicapp/Configuration/Track.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) Jordan Erickson - 2014-2020, 3 | * Copyright (C) Löwenfelsen UG (haftungsbeschränkt) - 2015-2020 4 | * on behalf of Jordan Erickson. 5 | * 6 | * This file is part of Cool Mic. 7 | * 8 | * Cool Mic is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Cool Mic is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Cool Mic. If not, see . 20 | * 21 | */ 22 | 23 | package cc.echonet.coolmicapp.Configuration; 24 | 25 | import cc.echonet.coolmicapp.Utils; 26 | import org.jetbrains.annotations.Contract; 27 | import org.jetbrains.annotations.NotNull; 28 | import org.jetbrains.annotations.Nullable; 29 | import org.jetbrains.annotations.UnmodifiableView; 30 | 31 | import java.util.ArrayList; 32 | import java.util.Arrays; 33 | import java.util.Collections; 34 | import java.util.List; 35 | import java.util.Locale; 36 | import java.util.Map; 37 | 38 | public class Track extends ProfileBase { 39 | public static final @NotNull @UnmodifiableView List<@NotNull String> STANDARD_KEYS = 40 | Collections.unmodifiableList( 41 | Arrays.asList("title", "version", "album", "artist", "performer", "copyright", "license", "organization", "description", "genre", "location", "contact")); 42 | private static final @NotNull String PREF_PREFIX = "trackmetadata_key_"; 43 | private static final @NotNull String PREF_PREFIX_LEGACY = "general_"; 44 | 45 | Track(@NotNull ProfileBase profile) { 46 | super(profile); 47 | } 48 | 49 | private static boolean isLegacyKey(@NotNull String key) { 50 | key = normalizeKey(key); 51 | 52 | return key.equals("artist") || key.equals("title"); 53 | } 54 | 55 | public static @NotNull String getKeyDisplayName(@NotNull String key) { 56 | key = normalizeKey(key); 57 | 58 | if (key.contains("_")) 59 | return key.toUpperCase(Locale.ROOT); 60 | 61 | return Utils.toUpperFirst(key); 62 | } 63 | 64 | public static @NotNull String normalizeKey(@NotNull String key) { 65 | return key.toLowerCase(Locale.ROOT).replaceAll("[^a-z0-9_]", "_"); 66 | } 67 | 68 | public @NotNull List getKeys() { 69 | final @NotNull List ret = new ArrayList<>(); 70 | 71 | for (final @NotNull Map.Entry entry : prefs.getAll().entrySet()) { 72 | if (entry.getValue() instanceof String) { 73 | final @NotNull String key = entry.getKey(); 74 | final @NotNull String value = (String) entry.getValue(); 75 | 76 | if (key.startsWith(PREF_PREFIX) && !value.isEmpty()) { 77 | ret.add(key.substring(PREF_PREFIX.length())); 78 | } 79 | } 80 | } 81 | 82 | for (final @NotNull String key : new String[]{"artist", "title"}) { 83 | if (!ret.contains(key)) 84 | if (getValue(key, null) != null) 85 | ret.add(key); 86 | } 87 | 88 | Collections.sort(ret); 89 | 90 | return ret; 91 | } 92 | 93 | @Contract("_, !null -> !null; _, null -> _") 94 | public @Nullable String getValue(@NotNull String key, @Nullable String def) { 95 | final @Nullable String ret; 96 | 97 | key = normalizeKey(key); 98 | 99 | if (isLegacyKey(key)) 100 | def = getString(PREF_PREFIX_LEGACY + key, def); 101 | 102 | ret = getString(PREF_PREFIX + key, def); 103 | 104 | if (ret == null || ret.isEmpty()) 105 | return def; 106 | 107 | return ret; 108 | } 109 | 110 | public void setValue(@NotNull String key, @Nullable String value) { 111 | key = normalizeKey(key); 112 | 113 | if (isLegacyKey(key)) 114 | editor.remove(PREF_PREFIX_LEGACY + key); 115 | 116 | key = PREF_PREFIX + key; 117 | 118 | if (value == null) { 119 | editor.remove(key); 120 | } else { 121 | editor.putString(key, value); 122 | } 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /app/src/main/java/cc/echonet/coolmicapp/Configuration/VUMeter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) Jordan Erickson - 2014-2020, 3 | * Copyright (C) Löwenfelsen UG (haftungsbeschränkt) - 2015-2020 4 | * on behalf of Jordan Erickson. 5 | * 6 | * This file is part of Cool Mic. 7 | * 8 | * Cool Mic is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Cool Mic is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Cool Mic. If not, see . 20 | * 21 | */ 22 | 23 | package cc.echonet.coolmicapp.Configuration; 24 | 25 | import org.jetbrains.annotations.NotNull; 26 | 27 | import cc.echonet.coolmicapp.R; 28 | 29 | public class VUMeter extends ProfileBase { 30 | VUMeter(@NotNull ProfileBase profile) { 31 | super(profile); 32 | } 33 | 34 | public int getInterval() { 35 | return Integer.parseInt(getString("vumeter_interval", R.string.pref_default_vumeter_interval)); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/java/cc/echonet/coolmicapp/Configuration/Volume.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) Jordan Erickson - 2014-2020, 3 | * Copyright (C) Löwenfelsen UG (haftungsbeschränkt) - 2015-2020 4 | * on behalf of Jordan Erickson. 5 | * 6 | * This file is part of Cool Mic. 7 | * 8 | * Cool Mic is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Cool Mic is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Cool Mic. If not, see . 20 | * 21 | */ 22 | 23 | package cc.echonet.coolmicapp.Configuration; 24 | 25 | import org.jetbrains.annotations.NotNull; 26 | 27 | public class Volume extends ProfileBase { 28 | private static final int DEFAULT_VOLUME = 100; 29 | 30 | private final @NotNull Audio audio; 31 | 32 | Volume(@NotNull ProfileBase profile, @NotNull Audio audio) { 33 | super(profile); 34 | 35 | this.audio = audio; 36 | } 37 | 38 | public @NotNull Audio getAudio() { 39 | return audio; 40 | } 41 | 42 | public int getLeft() { 43 | return prefs.getInt("volume_left", DEFAULT_VOLUME); 44 | } 45 | 46 | public int getRight() { 47 | return prefs.getInt("volume_left", DEFAULT_VOLUME); 48 | } 49 | 50 | public void setLeft(int volume) { 51 | prefs.edit().putInt("volume_left", volume).apply(); 52 | } 53 | 54 | public void setRight(int volume) { 55 | prefs.edit().putInt("volume_right", volume).apply(); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /app/src/main/java/cc/echonet/coolmicapp/Dialog.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) Jordan Erickson - 2014-2020, 3 | * Copyright (C) Löwenfelsen UG (haftungsbeschränkt) - 2015-2020 4 | * on behalf of Jordan Erickson. 5 | * 6 | * This file is part of Cool Mic. 7 | * 8 | * Cool Mic is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Cool Mic is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Cool Mic. If not, see . 20 | * 21 | */ 22 | 23 | package cc.echonet.coolmicapp; 24 | 25 | import android.app.AlertDialog; 26 | import android.content.Context; 27 | import android.content.Intent; 28 | import android.net.Uri; 29 | import android.text.Html; 30 | import android.text.method.LinkMovementMethod; 31 | import android.widget.TextView; 32 | 33 | import org.jetbrains.annotations.NotNull; 34 | import org.jetbrains.annotations.Nullable; 35 | 36 | import cc.echonet.coolmicapp.Configuration.DialogIdentifier; 37 | import cc.echonet.coolmicapp.Configuration.DialogState; 38 | import cc.echonet.coolmicapp.Configuration.Profile; 39 | 40 | public class Dialog { 41 | private static final String KEY_TITLE = "title"; 42 | private static final String KEY_MESSAGE = "message"; 43 | private static final String KEY_URL = "url"; 44 | private static final int CONTENT_PADDING = 50; 45 | 46 | private final @NotNull DialogIdentifier dialogIdentifier; 47 | private final @NotNull Context context; 48 | private final @NotNull Profile profile; 49 | private final @Nullable Runnable onDone; 50 | 51 | public Dialog(@NotNull DialogIdentifier dialogIdentifier, @NotNull Context context, @NotNull Profile profile) { 52 | this(dialogIdentifier, context, profile, null); 53 | } 54 | 55 | public Dialog(@NotNull DialogIdentifier dialogIdentifier, @NotNull Context context, @NotNull Profile profile, @Nullable Runnable onDone) { 56 | this.dialogIdentifier = dialogIdentifier; 57 | this.context = context; 58 | this.profile = profile; 59 | this.onDone = onDone; 60 | } 61 | 62 | private String getString(@NotNull String subkey) { 63 | return Utils.getStringByName(context, "popup_" + dialogIdentifier.toString().toLowerCase() + "_" + subkey); 64 | } 65 | 66 | private void onDone() { 67 | if (onDone != null) 68 | onDone.run(); 69 | } 70 | 71 | public void show() { 72 | final @NotNull TextView tv = new TextView(context); 73 | 74 | AlertDialog.Builder builder = new AlertDialog.Builder(context); 75 | builder.setTitle(getString(KEY_TITLE)); 76 | tv.setText(Html.fromHtml(getString(KEY_MESSAGE))); 77 | tv.setMovementMethod(LinkMovementMethod.getInstance()); 78 | tv.setPaddingRelative(CONTENT_PADDING, tv.getPaddingTop(), CONTENT_PADDING, tv.getPaddingBottom()); 79 | builder.setView(tv); 80 | builder.setPositiveButton(android.R.string.ok, (dialogInterface, i) -> { 81 | dialogInterface.dismiss(); 82 | onDone(); 83 | }); 84 | builder.setNeutralButton(R.string.popup_any_more, ((dialogInterface, i) -> { 85 | final @NotNull Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(getString(KEY_URL))); 86 | context.startActivity(intent); 87 | onDone(); 88 | })); 89 | builder.show(); 90 | profile.getDialogState(dialogIdentifier).shown(); 91 | } 92 | 93 | public void showIfNecessary() { 94 | final DialogState dialogState = profile.getDialogState(dialogIdentifier); 95 | boolean necessary = false; 96 | 97 | switch (dialogIdentifier) { 98 | case FIRST_TIME: 99 | necessary = !dialogState.hasEverShown(); 100 | break; 101 | case NEW_VERSION: 102 | necessary = !dialogState.hasShownInThisVersion(); 103 | break; 104 | } 105 | 106 | if (necessary) 107 | show(); 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /app/src/main/java/cc/echonet/coolmicapp/FileFormatDetector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) Jordan Erickson - 2014-2020, 3 | * Copyright (C) Löwenfelsen UG (haftungsbeschränkt) - 2015-2020 4 | * on behalf of Jordan Erickson. 5 | * 6 | * This file is part of Cool Mic. 7 | * 8 | * Cool Mic is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Cool Mic is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Cool Mic. If not, see . 20 | * 21 | */ 22 | 23 | package cc.echonet.coolmicapp; 24 | 25 | import cc.echonet.coolmicapp.Configuration.Codec; 26 | import org.jetbrains.annotations.Contract; 27 | import org.jetbrains.annotations.NotNull; 28 | import org.jetbrains.annotations.Nullable; 29 | 30 | import java.io.IOException; 31 | import java.io.InputStream; 32 | 33 | public final class FileFormatDetector { 34 | private static final byte[] MAGIC_OGG = new byte[]{'O', 'g', 'g', 'S', 0}; 35 | private static final byte[] MAGIC_VORBIS = new byte[]{1, 'v', 'o', 'r', 'b', 'i', 's'}; 36 | private static final byte[] MAGIC_OPUS = new byte[]{'O', 'p', 'u', 's', 'H', 'e', 'a', 'd'}; 37 | private static final byte MAGIC_AAC_SYNC_ONE = (byte)0xFF; 38 | private static final byte MAGIC_AAC_SYNC_TWO = (byte)0xF0; 39 | private static final byte MAGIC_AAC_SYNC_TWO_MASK = (byte)0xF6; 40 | private static final byte MAGIC_MP3_SYNC_ONE = (byte)0xFF; 41 | private static final byte[] MAGIC_MP3_SYNC_TWO = new byte[]{(byte) 0xF2, (byte) 0xF3, (byte) 0xF5}; 42 | private static final byte MAGIC_MP3_SYNC_TWO_MASK = (byte)0xF6; 43 | 44 | @Contract(pure = true) 45 | private static boolean isSubArray(final byte[] raw, final int offset, final byte[] magic) { 46 | try { 47 | for (int i = 0; i < magic.length; i++) 48 | if (raw[offset + i] != magic[i]) 49 | return false; 50 | } catch (Throwable e) { 51 | return false; 52 | } 53 | return true; 54 | } 55 | 56 | @Contract(pure = true) 57 | private static boolean isPartOf(final byte val, final byte[] magic) { 58 | for (final byte e : magic) { 59 | if (val == e) 60 | return true; 61 | } 62 | 63 | return false; 64 | } 65 | 66 | @Contract(pure = true) 67 | private static boolean isOgg(final byte[] raw) { 68 | return isSubArray(raw, 0, MAGIC_OGG); 69 | } 70 | 71 | @Contract(pure = true) 72 | private static int oggOffsetToBody(final byte[] raw) { 73 | return 27 + (raw[26] & 0xFF); 74 | } 75 | 76 | @Contract(pure = true) 77 | private static boolean isVorbis(final byte[] raw, final int bodyOffset) { 78 | return isSubArray(raw, bodyOffset, MAGIC_VORBIS); 79 | } 80 | 81 | @Contract(pure = true) 82 | private static boolean isOpus(final byte[] raw, final int bodyOffset) { 83 | return isSubArray(raw, bodyOffset, MAGIC_OPUS); 84 | } 85 | 86 | @Contract(pure = true) 87 | private static boolean isAAC(final byte[] raw) { 88 | try { 89 | if (raw[0] != MAGIC_AAC_SYNC_ONE) 90 | return false; 91 | 92 | if ((raw[1] & MAGIC_AAC_SYNC_TWO_MASK) != MAGIC_AAC_SYNC_TWO) 93 | return false; 94 | 95 | return true; 96 | } catch (Throwable e) { 97 | return false; 98 | } 99 | } 100 | 101 | @Contract(pure = true) 102 | private static boolean isMP3(final byte[] raw) { 103 | try { 104 | if (raw[0] != MAGIC_MP3_SYNC_ONE) 105 | return false; 106 | 107 | if (!isPartOf((byte)(raw[1] & MAGIC_MP3_SYNC_TWO_MASK), MAGIC_MP3_SYNC_TWO)) 108 | return false; 109 | 110 | return true; 111 | } catch (Throwable e) { 112 | return false; 113 | } 114 | } 115 | 116 | public static @Nullable String detect(@NotNull InputStream inputStream) { 117 | final byte[] buffer = new byte[64]; 118 | final int have; 119 | 120 | try { 121 | have = inputStream.read(buffer); 122 | } catch (IOException e) { 123 | return null; 124 | } 125 | 126 | if (have < 1) 127 | return null; 128 | 129 | if (isOgg(buffer)) { 130 | try { 131 | int bodyOffset = oggOffsetToBody(buffer); 132 | 133 | if (isVorbis(buffer, bodyOffset)) 134 | return Codec.TYPE_VORBIS; 135 | 136 | if (isOpus(buffer, bodyOffset)) 137 | return Codec.TYPE_OPUS; 138 | 139 | } catch (Throwable ignored) { 140 | } 141 | return Codec.TYPE_OGG; 142 | } 143 | 144 | if (isAAC(buffer)) 145 | return Codec.TYPE_AAC; 146 | 147 | if (isMP3(buffer)) 148 | return Codec.TYPE_MP3; 149 | 150 | return null; 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /app/src/main/java/cc/echonet/coolmicapp/Icecast/Command.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) Jordan Erickson - 2014-2020, 3 | * Copyright (C) Löwenfelsen UG (haftungsbeschränkt) - 2015-2020 4 | * on behalf of Jordan Erickson. 5 | * 6 | * This file is part of Cool Mic. 7 | * 8 | * Cool Mic is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Cool Mic is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Cool Mic. If not, see . 20 | * 21 | */ 22 | 23 | package cc.echonet.coolmicapp.Icecast; 24 | 25 | import org.jetbrains.annotations.NotNull; 26 | 27 | public enum Command { 28 | STATS("stats.xml"); 29 | 30 | private final @NotNull String endpoint; 31 | 32 | Command(@NotNull String endpoint) { 33 | this.endpoint = endpoint; 34 | } 35 | 36 | @NotNull String getEndpoint() { 37 | return endpoint; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/src/main/java/cc/echonet/coolmicapp/Icecast/Icecast.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) Jordan Erickson - 2014-2020, 3 | * Copyright (C) Löwenfelsen UG (haftungsbeschränkt) - 2015-2020 4 | * on behalf of Jordan Erickson. 5 | * 6 | * This file is part of Cool Mic. 7 | * 8 | * Cool Mic is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Cool Mic is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Cool Mic. If not, see . 20 | * 21 | */ 22 | 23 | package cc.echonet.coolmicapp.Icecast; 24 | 25 | import cc.echonet.coolmicapp.Icecast.Request.Stats; 26 | import org.jetbrains.annotations.NotNull; 27 | import org.jetbrains.annotations.Nullable; 28 | 29 | import java.io.Closeable; 30 | import java.io.IOException; 31 | import java.net.MalformedURLException; 32 | import java.net.URL; 33 | import java.util.Locale; 34 | 35 | public class Icecast implements Closeable { 36 | private final @NotNull String protocol; 37 | private final @NotNull String host; 38 | private final int port; 39 | private String username; 40 | private String password; 41 | 42 | public Icecast(@NotNull String protocol, @NotNull String host, int port) { 43 | this.protocol = protocol; 44 | this.host = host; 45 | this.port = port; 46 | } 47 | 48 | public void setCredentials(String username, String password) { 49 | this.username = username; 50 | this.password = password; 51 | } 52 | 53 | @SuppressWarnings("HardcodedFileSeparator") 54 | URL getCommandURL(@NotNull Command command, @Nullable String mount) throws MalformedURLException { 55 | String url; 56 | 57 | // TODO: Improve this mess... 58 | if (mount == null) { 59 | url = String.format(Locale.ENGLISH, "%s://%s:%s@%s:%d/admin/%s", protocol, username, password, host, port, command.getEndpoint()); 60 | } else { 61 | url = String.format(Locale.ENGLISH, "%s://%s:%s@%s:%d/admin/%s?mount=/%s", protocol, username, password, host, port, command.getEndpoint(), mount); 62 | } 63 | 64 | return new URL(url); 65 | } 66 | 67 | public Stats getStats(@Nullable String mount) throws IOException { 68 | return new Stats(getCommandURL(Command.STATS, mount)); 69 | } 70 | 71 | @Override 72 | public void close() { 73 | // no-op. 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /app/src/main/java/cc/echonet/coolmicapp/Icecast/Request/Request.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) Jordan Erickson - 2014-2020, 3 | * Copyright (C) Löwenfelsen UG (haftungsbeschränkt) - 2015-2020 4 | * on behalf of Jordan Erickson. 5 | * 6 | * This file is part of Cool Mic. 7 | * 8 | * Cool Mic is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Cool Mic is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Cool Mic. If not, see . 20 | * 21 | */ 22 | 23 | package cc.echonet.coolmicapp.Icecast.Request; 24 | 25 | import android.renderscript.RSInvalidStateException; 26 | import android.util.Base64; 27 | 28 | import org.jetbrains.annotations.NotNull; 29 | 30 | import java.io.Closeable; 31 | import java.io.IOException; 32 | import java.net.HttpURLConnection; 33 | import java.net.URL; 34 | 35 | import cc.echonet.coolmicapp.Icecast.Response.Response; 36 | import cc.echonet.coolmicapp.Icecast.State; 37 | 38 | abstract public class Request implements Closeable { 39 | protected HttpURLConnection connection; 40 | protected State state = State.UNCONNECTED; 41 | protected Response response; 42 | 43 | public Request(@NotNull URL url) throws IOException { 44 | connection = (HttpURLConnection) url.openConnection(); 45 | 46 | connection.setUseCaches(false); 47 | connection.setDoOutput(false); 48 | 49 | connection.setRequestMethod("GET"); 50 | connection.setRequestProperty("Accept-Charset", "utf-8"); 51 | connection.setRequestProperty("Accept-Encoding", "text/xml"); 52 | connection.setRequestProperty("Accept-Language", "en-US"); 53 | connection.setRequestProperty("Authorization", "Basic " + Base64.encodeToString(url.getUserInfo().getBytes(), Base64.NO_WRAP)); 54 | } 55 | 56 | public Response getResponse() { 57 | if (state != State.FINISHED) 58 | throw new RSInvalidStateException("Request not yet finished"); 59 | 60 | return response; 61 | } 62 | 63 | protected void setError() { 64 | state = State.ERROR; 65 | } 66 | 67 | public State getState() { 68 | return state; 69 | } 70 | 71 | abstract public void finish(); 72 | 73 | public void connect() throws IOException { 74 | if (state != State.UNCONNECTED) 75 | return; 76 | 77 | connection.connect(); 78 | state = State.CONNECTED; 79 | } 80 | 81 | @Override 82 | public void close() { 83 | if (connection == null) 84 | return; 85 | 86 | connection.disconnect(); 87 | connection = null; 88 | state = State.CLOSED; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /app/src/main/java/cc/echonet/coolmicapp/Icecast/Request/Stats.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) Jordan Erickson - 2014-2020, 3 | * Copyright (C) Löwenfelsen UG (haftungsbeschränkt) - 2015-2020 4 | * on behalf of Jordan Erickson. 5 | * 6 | * This file is part of Cool Mic. 7 | * 8 | * Cool Mic is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Cool Mic is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Cool Mic. If not, see . 20 | * 21 | */ 22 | 23 | package cc.echonet.coolmicapp.Icecast.Request; 24 | 25 | import android.util.Log; 26 | import cc.echonet.coolmicapp.Icecast.State; 27 | import org.jetbrains.annotations.NotNull; 28 | import org.w3c.dom.Document; 29 | import org.xml.sax.SAXException; 30 | 31 | import javax.xml.parsers.DocumentBuilder; 32 | import javax.xml.parsers.DocumentBuilderFactory; 33 | import javax.xml.parsers.ParserConfigurationException; 34 | import javax.xml.xpath.*; 35 | import java.io.IOException; 36 | import java.io.PrintWriter; 37 | import java.io.StringWriter; 38 | import java.net.URL; 39 | 40 | public class Stats extends Request { 41 | 42 | public Stats(@NotNull URL url) throws IOException { 43 | super(url); 44 | Log.d("CM-StreamStatsService", "url=" + url); 45 | } 46 | 47 | private @NotNull String exceptionToString(@NotNull Exception ex) { 48 | StringWriter sw = new StringWriter(); 49 | ex.printStackTrace(new PrintWriter(sw)); 50 | return sw.toString(); 51 | } 52 | 53 | @Override 54 | public void finish() { 55 | try { 56 | connect(); 57 | 58 | if (connection.getResponseCode() != 200) { 59 | Log.e("CM-StreamStatsService", "HTTP error, invalid server status code: " + connection.getResponseMessage()); 60 | setError(); 61 | return; 62 | } 63 | 64 | final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 65 | final DocumentBuilder builder = factory.newDocumentBuilder(); 66 | final Document doc = builder.parse(connection.getInputStream()); 67 | 68 | Log.d("CM-StreamStatsService", "Parsed Document " + doc.toString()); 69 | 70 | final XPathFactory xpathFactory = XPathFactory.newInstance(); 71 | final XPath xpath = xpathFactory.newXPath(); 72 | 73 | Log.d("CM-StreamStatsService", "post xpath"); 74 | 75 | //noinspection HardcodedFileSeparator 76 | final XPathExpression expr_listeners = xpath.compile("/icestats/source/listeners/text()"); 77 | //noinspection HardcodedFileSeparator 78 | final XPathExpression expr_listeners_peak = xpath.compile("/icestats/source/listener_peak/text()"); 79 | 80 | Log.d("CM-StreamStatsService", "post xpath compile"); 81 | 82 | final String listeners = (String) expr_listeners.evaluate(doc, XPathConstants.STRING); 83 | final String listeners_peak = (String) expr_listeners_peak.evaluate(doc, XPathConstants.STRING); 84 | 85 | Log.d("CM-StreamStatsService", "post xpath eval " + listeners + " " + listeners_peak); 86 | 87 | int listenersCurrent = -1; 88 | int listenersPeak = -1; 89 | 90 | if (!listeners.isEmpty()) { 91 | listenersCurrent = Integer.parseInt(listeners); 92 | } else { 93 | Log.d("CM-StreamStatsService", "found no listeners"); 94 | } 95 | 96 | if (!listeners_peak.isEmpty()) { 97 | listenersPeak = Integer.parseInt(listeners_peak); 98 | } else { 99 | Log.d("CM-StreamStatsService", "found no listeners peak"); 100 | } 101 | 102 | response = new cc.echonet.coolmicapp.Icecast.Response.Stats(listenersCurrent, listenersPeak); 103 | state = State.FINISHED; 104 | } catch (XPathExpressionException e) { 105 | Log.e("CM-StreamStatsService", "XPException while fetching Stats: " + exceptionToString(e)); 106 | setError(); 107 | } catch (SAXException e) { 108 | Log.e("CM-StreamStatsService", "SAXException while fetching Stats: " + exceptionToString(e)); 109 | setError(); 110 | } catch (ParserConfigurationException e) { 111 | Log.e("CM-StreamStatsService", "PCException while fetching Stats: " + exceptionToString(e)); 112 | setError(); 113 | } catch (IOException e) { 114 | Log.e("CM-StreamStatsService", "IOException while fetching Stats: " + exceptionToString(e)); 115 | setError(); 116 | } catch (Exception e) { 117 | Log.e("CM-StreamStatsService", "Exception while fetching Stats: " + exceptionToString(e)); 118 | setError(); 119 | } 120 | } 121 | 122 | @Override 123 | public cc.echonet.coolmicapp.Icecast.Response.Stats getResponse() { 124 | return (cc.echonet.coolmicapp.Icecast.Response.Stats) super.getResponse(); 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /app/src/main/java/cc/echonet/coolmicapp/Icecast/Response/Response.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) Jordan Erickson - 2014-2020, 3 | * Copyright (C) Löwenfelsen UG (haftungsbeschränkt) - 2015-2020 4 | * on behalf of Jordan Erickson. 5 | * 6 | * This file is part of Cool Mic. 7 | * 8 | * Cool Mic is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Cool Mic is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Cool Mic. If not, see . 20 | * 21 | */ 22 | 23 | package cc.echonet.coolmicapp.Icecast.Response; 24 | 25 | public abstract class Response { 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/cc/echonet/coolmicapp/Icecast/Response/Stats.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) Jordan Erickson - 2014-2020, 3 | * Copyright (C) Löwenfelsen UG (haftungsbeschränkt) - 2015-2020 4 | * on behalf of Jordan Erickson. 5 | * 6 | * This file is part of Cool Mic. 7 | * 8 | * Cool Mic is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Cool Mic is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Cool Mic. If not, see . 20 | * 21 | */ 22 | 23 | package cc.echonet.coolmicapp.Icecast.Response; 24 | 25 | public class Stats extends Response { 26 | private final int listenerCurrent; 27 | private final int listenerPeak; 28 | 29 | public Stats(int listenerCurrent, int listenerPeak) { 30 | this.listenerCurrent = listenerCurrent; 31 | this.listenerPeak = listenerPeak; 32 | } 33 | 34 | public int getListenerCurrent() { 35 | return listenerCurrent; 36 | } 37 | 38 | public int getListenerPeak() { 39 | return listenerPeak; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/src/main/java/cc/echonet/coolmicapp/Icecast/State.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) Jordan Erickson - 2014-2020, 3 | * Copyright (C) Löwenfelsen UG (haftungsbeschränkt) - 2015-2020 4 | * on behalf of Jordan Erickson. 5 | * 6 | * This file is part of Cool Mic. 7 | * 8 | * Cool Mic is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Cool Mic is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Cool Mic. If not, see . 20 | * 21 | */ 22 | 23 | package cc.echonet.coolmicapp.Icecast; 24 | 25 | public enum State { 26 | UNCONNECTED, 27 | CONNECTED, 28 | FINISHED, 29 | ERROR, 30 | CLOSED; 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/java/cc/echonet/coolmicapp/MetadataDialog.java: -------------------------------------------------------------------------------- 1 | package cc.echonet.coolmicapp; 2 | 3 | import android.app.AlertDialog; 4 | import android.content.Context; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.widget.ArrayAdapter; 8 | import android.widget.ListView; 9 | import android.widget.TextView; 10 | import androidx.annotation.NonNull; 11 | import androidx.annotation.Nullable; 12 | import cc.echonet.coolmicapp.Configuration.Profile; 13 | import org.jetbrains.annotations.Contract; 14 | import org.jetbrains.annotations.NotNull; 15 | 16 | import java.util.ArrayList; 17 | import java.util.Iterator; 18 | import java.util.List; 19 | import java.util.Objects; 20 | 21 | abstract class MetadataDialog { 22 | abstract static class Adapter extends ArrayAdapter { 23 | protected final @NotNull Profile profile; 24 | 25 | abstract protected @NotNull List<@NotNull String> getKeys(); 26 | abstract protected void setMetadata(@NotNull String key, @Nullable String value); 27 | @Contract("_, !null -> !null") 28 | abstract protected String getValue(@NotNull String key, @Nullable String def); 29 | abstract protected String getKeyDisplayName(@NotNull String key); 30 | 31 | public Adapter(@NonNull Context context, @NotNull Profile profile) { 32 | super(context, R.layout.metadata_list_entry, R.id.metadata_key, new ArrayList<>()); 33 | this.profile = profile; 34 | reloadData(); 35 | } 36 | 37 | public void reloadData() { 38 | clear(); 39 | addAll(getKeys()); 40 | notifyDataSetChanged(); 41 | } 42 | 43 | @NonNull 44 | @Override 45 | public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { 46 | final @NonNull View view = super.getView(position, convertView, parent); 47 | final @NonNull String key = Objects.requireNonNull(super.getItem(position)); 48 | final @NonNull String value = getValue(key, ""); 49 | final @NonNull String keyDisplayName = getKeyDisplayName(key); 50 | 51 | ((TextView)view.findViewById(R.id.metadata_key)).setText(keyDisplayName); 52 | ((TextView)view.findViewById(R.id.metadata_value)).setText(value); 53 | 54 | view.setOnClickListener(v -> PromptDialog.prompt(getContext(), keyDisplayName, value, result -> setMetadata(key, result))); 55 | 56 | view.findViewById(R.id.metadata_delete_key).setOnClickListener(v -> setMetadata(key, null)); 57 | 58 | return view; 59 | } 60 | } 61 | 62 | protected final @NotNull Context context; 63 | protected final @NotNull Profile profile; 64 | protected final @NotNull AlertDialog.Builder builder; 65 | protected final @NotNull A adapter; 66 | protected @Nullable Runnable onDone = null; 67 | 68 | protected abstract boolean customKeysAllowed(); 69 | protected abstract @NotNull List<@NotNull String> getStandardKeys(); 70 | 71 | protected void askKey(@NotNull String key) { 72 | PromptDialog.prompt(context, adapter.getKeyDisplayName(key), null, result -> adapter.setMetadata(key, result)); 73 | } 74 | 75 | protected void addKey() { 76 | final @NotNull AlertDialog.Builder builder = new AlertDialog.Builder(context); 77 | final @NotNull List<@NotNull String> keys = new ArrayList<>(getStandardKeys()); 78 | final @NotNull String[] supported; 79 | 80 | for (Iterator iterator = keys.iterator(); iterator.hasNext(); ) { 81 | final @NotNull String key = iterator.next(); 82 | final @Nullable String value = adapter.getValue(key, null); 83 | if (value != null && !value.isEmpty()) 84 | iterator.remove(); 85 | } 86 | 87 | if (customKeysAllowed()) { 88 | keys.add(context.getString(R.string.metadata_custom)); 89 | } 90 | 91 | supported = keys.toArray(new String[0]); 92 | 93 | for (int i = 0; i < supported.length; i++) 94 | supported[i] = adapter.getKeyDisplayName(supported[i]); 95 | 96 | builder.setItems(supported, (dialog, which) -> { 97 | dialog.dismiss(); 98 | if (customKeysAllowed() && which == (supported.length - 1)) { 99 | PromptDialog.prompt(context, context.getString(R.string.metadata_key_name), null, this::askKey); 100 | } else { 101 | askKey(supported[which]); 102 | } 103 | }); 104 | 105 | builder.show(); 106 | } 107 | 108 | protected void setup() { 109 | final @NotNull ListView listView = new ListView(context); 110 | 111 | listView.setAdapter(adapter); 112 | 113 | builder.setView(listView); 114 | 115 | builder.setCancelable(true); 116 | 117 | builder.setPositiveButton(android.R.string.ok, (dialog, which) -> done()); 118 | builder.setNeutralButton(R.string.metadata_add, null); 119 | 120 | builder.setOnCancelListener(dialog -> done()); 121 | } 122 | 123 | protected void done() { 124 | if (onDone != null) 125 | onDone.run(); 126 | } 127 | 128 | @Contract(pure = true) 129 | public MetadataDialog(@NotNull Context context, @NotNull Profile profile, @NotNull A adapter) { 130 | this.context = context; 131 | this.profile = profile; 132 | this.builder = new AlertDialog.Builder(context); 133 | this.adapter = adapter; 134 | setup(); 135 | } 136 | 137 | public void show() { 138 | final @NotNull AlertDialog dialog = builder.create(); 139 | dialog.setOnShowListener(dialogInterface -> dialog.getButton(AlertDialog.BUTTON_NEUTRAL).setOnClickListener(v -> addKey())); 140 | dialog.show(); 141 | } 142 | 143 | public void setOnDone(@Nullable Runnable onDone) { 144 | this.onDone = onDone; 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /app/src/main/java/cc/echonet/coolmicapp/PromptDialog.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) Jordan Erickson - 2014-2020, 3 | * Copyright (C) Löwenfelsen UG (haftungsbeschränkt) - 2015-2020 4 | * on behalf of Jordan Erickson. 5 | * 6 | * This file is part of Cool Mic. 7 | * 8 | * Cool Mic is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Cool Mic is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Cool Mic. If not, see . 20 | * 21 | */ 22 | 23 | package cc.echonet.coolmicapp; 24 | 25 | import android.app.AlertDialog; 26 | import android.content.Context; 27 | import android.view.WindowManager; 28 | import android.widget.EditText; 29 | 30 | import androidx.annotation.NonNull; 31 | import androidx.annotation.Nullable; 32 | 33 | import java.util.Objects; 34 | 35 | public final class PromptDialog { 36 | public interface ResultCallback { 37 | void result(@Nullable String result); 38 | } 39 | 40 | public static void prompt(@NonNull Context context, @NonNull String title, @Nullable String value, @NonNull ResultCallback resultCallback) { 41 | final @NonNull AlertDialog.Builder builder = new AlertDialog.Builder(context); 42 | final @NonNull EditText editText = new EditText(context); 43 | final @NonNull AlertDialog dialog; 44 | 45 | if (value == null) 46 | value = ""; 47 | 48 | editText.setText(value); 49 | editText.setSingleLine(); 50 | editText.requestFocus(); 51 | 52 | builder.setTitle(title); 53 | builder.setView(editText); 54 | 55 | builder.setOnCancelListener(ignored -> resultCallback.result(String.valueOf(editText.getText()))); 56 | builder.setPositiveButton(android.R.string.ok, (dialog1, which) -> resultCallback.result(String.valueOf(editText.getText()))); 57 | 58 | dialog = builder.create(); 59 | editText.setOnEditorActionListener((v, actionId, event) -> { 60 | dialog.cancel(); 61 | return true; 62 | }); 63 | dialog.show(); 64 | Objects.requireNonNull(dialog.getWindow()).setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /app/src/main/java/cc/echonet/coolmicapp/StationMetadataDialog.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) Jordan Erickson - 2014-2020, 3 | * Copyright (C) Löwenfelsen UG (haftungsbeschränkt) - 2015-2021 4 | * on behalf of Jordan Erickson. 5 | * 6 | * This file is part of Cool Mic. 7 | * 8 | * Cool Mic is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Cool Mic is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Cool Mic. If not, see . 20 | * 21 | */ 22 | 23 | package cc.echonet.coolmicapp; 24 | 25 | import android.content.Context; 26 | import androidx.annotation.NonNull; 27 | import androidx.annotation.Nullable; 28 | import cc.echonet.coolmicapp.Configuration.Profile; 29 | import cc.echonet.coolmicapp.Configuration.Station; 30 | import org.jetbrains.annotations.NotNull; 31 | 32 | import java.util.ArrayList; 33 | import java.util.List; 34 | import java.util.Locale; 35 | 36 | public class StationMetadataDialog extends MetadataDialog { 37 | final static class Adapter extends MetadataDialog.Adapter { 38 | 39 | protected @NotNull List<@NotNull String> getKeys() { 40 | return new ArrayList<>(profile.getStation().getMetadata().keySet()); 41 | } 42 | 43 | @Override 44 | protected String getValue(@NotNull String key, @Nullable String def) { 45 | return profile.getStation().getValue(key, def); 46 | } 47 | 48 | @Override 49 | protected String getKeyDisplayName(@NotNull String key) { 50 | return Station.getKeyDisplayName(key); 51 | } 52 | 53 | public Adapter(@NonNull @NotNull Context context, @NotNull Profile profile) { 54 | super(context, profile); 55 | } 56 | 57 | @Override 58 | protected void setMetadata(@NotNull String key, @Nullable String value) { 59 | profile.edit(); 60 | profile.getStation().setValue(key.toLowerCase(Locale.ROOT), value); 61 | profile.apply(); 62 | reloadData(); 63 | } 64 | } 65 | 66 | protected boolean customKeysAllowed() { 67 | return false; 68 | } 69 | 70 | protected @NotNull List<@NotNull String> getStandardKeys() { 71 | return Station.STANDARD_KEYS; 72 | } 73 | 74 | public StationMetadataDialog(@NotNull Context context, @NotNull Profile profile) { 75 | super(context, profile, new Adapter(context, profile)); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /app/src/main/java/cc/echonet/coolmicapp/TextProgressBar.java: -------------------------------------------------------------------------------- 1 | package cc.echonet.coolmicapp; 2 | 3 | import android.content.Context; 4 | import android.graphics.Canvas; 5 | import android.graphics.Color; 6 | import android.graphics.Paint; 7 | import android.graphics.Rect; 8 | import android.util.AttributeSet; 9 | import android.widget.ProgressBar; 10 | 11 | import org.jetbrains.annotations.NotNull; 12 | 13 | /** 14 | * http://colintmiller.com/how-to-add-text-over-a-progress-bar-on-android/ 15 | */ 16 | public class TextProgressBar extends ProgressBar { 17 | private String text = ""; 18 | private @NotNull final Paint textPaint = new Paint(); 19 | private @NotNull final Rect bounds = new Rect(); 20 | 21 | public TextProgressBar(Context context) { 22 | super(context); 23 | textPaint.setColor(Color.BLACK); 24 | } 25 | 26 | public TextProgressBar(Context context, AttributeSet attrs) { 27 | super(context, attrs); 28 | textPaint.setColor(Color.BLACK); 29 | } 30 | 31 | public TextProgressBar(Context context, AttributeSet attrs, int defStyle) { 32 | super(context, attrs, defStyle); 33 | textPaint.setColor(Color.BLACK); 34 | } 35 | 36 | @Override 37 | protected synchronized void onDraw(Canvas canvas) { 38 | // First draw the regular progress bar, then custom draw our text 39 | super.onDraw(canvas); 40 | 41 | textPaint.getTextBounds(text, 0, text.length(), bounds); 42 | int x = getWidth() / 2 - bounds.centerX(); 43 | int y = getHeight() / 2 - bounds.centerY(); 44 | canvas.drawText(text, x, y, textPaint); 45 | } 46 | 47 | public synchronized void setText(String text) { 48 | this.text = text; 49 | drawableStateChanged(); 50 | } 51 | 52 | public void setTextColor(int color) { 53 | textPaint.setColor(color); 54 | drawableStateChanged(); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /app/src/main/java/cc/echonet/coolmicapp/TrackMetadataDialog.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) Jordan Erickson - 2014-2020, 3 | * Copyright (C) Löwenfelsen UG (haftungsbeschränkt) - 2015-2020 4 | * on behalf of Jordan Erickson. 5 | * 6 | * This file is part of Cool Mic. 7 | * 8 | * Cool Mic is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Cool Mic is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Cool Mic. If not, see . 20 | * 21 | */ 22 | 23 | package cc.echonet.coolmicapp; 24 | 25 | import android.content.Context; 26 | import androidx.annotation.NonNull; 27 | import androidx.annotation.Nullable; 28 | import cc.echonet.coolmicapp.Configuration.Profile; 29 | import cc.echonet.coolmicapp.Configuration.Track; 30 | import org.jetbrains.annotations.Contract; 31 | import org.jetbrains.annotations.NotNull; 32 | 33 | import java.util.List; 34 | 35 | public class TrackMetadataDialog extends MetadataDialog { 36 | final static class Adapter extends MetadataDialog.Adapter { 37 | 38 | @Override 39 | protected @NotNull List<@NotNull String> getKeys() { 40 | return profile.getTrack().getKeys(); 41 | } 42 | 43 | @Override 44 | protected String getValue(@NotNull String key, @Nullable String def) { 45 | return profile.getTrack().getValue(key, def); 46 | } 47 | 48 | protected String getKeyDisplayName(@NotNull String key) { 49 | return Track.getKeyDisplayName(key); 50 | } 51 | 52 | public Adapter(@NonNull @NotNull Context context, @NotNull Profile profile) { 53 | super(context, profile); 54 | } 55 | 56 | @Override 57 | public void setMetadata(@NotNull String key, @Nullable String value) { 58 | profile.edit(); 59 | profile.getTrack().setValue(key, value); 60 | profile.apply(); 61 | reloadData(); 62 | } 63 | } 64 | 65 | protected boolean customKeysAllowed() { 66 | return true; 67 | } 68 | 69 | protected @NotNull List<@NotNull String> getStandardKeys() { 70 | return Track.STANDARD_KEYS; 71 | } 72 | 73 | @Contract(pure = true) 74 | public TrackMetadataDialog(@NotNull Context context, @NotNull Profile profile) { 75 | super(context, profile, new Adapter(context, profile)); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /app/src/main/java/cc/echonet/coolmicapp/VerticalSeekBar.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Jörg Eisfeld 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 2 7 | * of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | */ 14 | package cc.echonet.coolmicapp; 15 | 16 | import android.content.Context; 17 | import android.graphics.Canvas; 18 | import android.util.AttributeSet; 19 | import android.view.MotionEvent; 20 | import android.widget.SeekBar; 21 | 22 | import androidx.annotation.NonNull; 23 | 24 | /** 25 | * Implementation of an easy vertical SeekBar, based on the normal SeekBar. 26 | */ 27 | public class VerticalSeekBar extends SeekBar { 28 | /** 29 | * The angle by which the SeekBar view should be rotated. 30 | */ 31 | private static final int ROTATION_ANGLE = -90; 32 | 33 | /** 34 | * A change listener registrating start and stop of tracking. Need an own listener because the listener in SeekBar 35 | * is private. 36 | */ 37 | private OnSeekBarChangeListener mOnSeekBarChangeListener; 38 | 39 | /** 40 | * Standard constructor to be implemented for all views. 41 | * 42 | * @param context The Context the view is running in, through which it can access the current theme, resources, etc. 43 | * @see android.view.View#View(Context) 44 | */ 45 | public VerticalSeekBar(final Context context) { 46 | super(context); 47 | } 48 | 49 | /** 50 | * Standard constructor to be implemented for all views. 51 | * 52 | * @param context The Context the view is running in, through which it can access the current theme, resources, etc. 53 | * @param attrs The attributes of the XML tag that is inflating the view. 54 | * @see android.view.View#View(Context, AttributeSet) 55 | */ 56 | public VerticalSeekBar(final Context context, final AttributeSet attrs) { 57 | super(context, attrs); 58 | } 59 | 60 | /** 61 | * Standard constructor to be implemented for all views. 62 | * 63 | * @param context The Context the view is running in, through which it can access the current theme, resources, etc. 64 | * @param attrs The attributes of the XML tag that is inflating the view. 65 | * @param defStyle An attribute in the current theme that contains a reference to a style resource that supplies default 66 | * values for the view. Can be 0 to not look for defaults. 67 | * @see android.view.View#View(Context, AttributeSet, int) 68 | */ 69 | public VerticalSeekBar(final Context context, final AttributeSet attrs, final int defStyle) { 70 | super(context, attrs, defStyle); 71 | } 72 | 73 | /* 74 | * (non-Javadoc) ${see_to_overridden} 75 | */ 76 | @Override 77 | protected final void onSizeChanged(final int width, final int height, final int oldWidth, final int oldHeight) { 78 | super.onSizeChanged(height, width, oldHeight, oldWidth); 79 | } 80 | 81 | /* 82 | * (non-Javadoc) ${see_to_overridden} 83 | */ 84 | @SuppressWarnings("SuspiciousNameCombination") 85 | @Override 86 | protected final synchronized void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec) { 87 | super.onMeasure(heightMeasureSpec, widthMeasureSpec); 88 | setMeasuredDimension(getMeasuredHeight(), getMeasuredWidth()); 89 | } 90 | 91 | /* 92 | * (non-Javadoc) ${see_to_overridden} 93 | */ 94 | @Override 95 | protected final void onDraw(@NonNull final Canvas c) { 96 | c.rotate(ROTATION_ANGLE); 97 | c.translate(-getHeight(), 0); 98 | 99 | super.onDraw(c); 100 | } 101 | 102 | /* 103 | * (non-Javadoc) ${see_to_overridden} 104 | */ 105 | @Override 106 | public final void setOnSeekBarChangeListener(final OnSeekBarChangeListener listener) { 107 | // Do not use super for the listener, as this would not set the fromUser flag properly 108 | mOnSeekBarChangeListener = listener; 109 | } 110 | 111 | /* 112 | * (non-Javadoc) ${see_to_overridden} 113 | */ 114 | @Override 115 | public final boolean onTouchEvent(@NonNull final MotionEvent event) { 116 | if (!isEnabled()) { 117 | return false; 118 | } 119 | 120 | switch (event.getAction()) { 121 | case MotionEvent.ACTION_DOWN: 122 | setProgressInternally(getMax() - (int) (getMax() * event.getY() / getHeight()), true); 123 | if (mOnSeekBarChangeListener != null) { 124 | mOnSeekBarChangeListener.onStartTrackingTouch(this); 125 | } 126 | break; 127 | 128 | case MotionEvent.ACTION_MOVE: 129 | setProgressInternally(getMax() - (int) (getMax() * event.getY() / getHeight()), true); 130 | break; 131 | 132 | case MotionEvent.ACTION_UP: 133 | setProgressInternally(getMax() - (int) (getMax() * event.getY() / getHeight()), true); 134 | if (mOnSeekBarChangeListener != null) { 135 | mOnSeekBarChangeListener.onStopTrackingTouch(this); 136 | } 137 | break; 138 | 139 | case MotionEvent.ACTION_CANCEL: 140 | if (mOnSeekBarChangeListener != null) { 141 | mOnSeekBarChangeListener.onStopTrackingTouch(this); 142 | } 143 | break; 144 | 145 | default: 146 | break; 147 | } 148 | 149 | return true; 150 | } 151 | 152 | /** 153 | * Set the progress by the user. (Unfortunately, Seekbar.setProgressInternally(int, boolean) is not accessible.) 154 | * 155 | * @param progress the progress. 156 | * @param fromUser flag indicating if the change was done by the user. 157 | */ 158 | public final void setProgressInternally(final int progress, final boolean fromUser) { 159 | if (progress != getProgress()) { 160 | super.setProgress(progress); 161 | if (mOnSeekBarChangeListener != null) { 162 | mOnSeekBarChangeListener.onProgressChanged(this, progress, fromUser); 163 | } 164 | } 165 | onSizeChanged(getWidth(), getHeight(), 0, 0); 166 | } 167 | 168 | /* 169 | * (non-Javadoc) ${see_to_overridden} 170 | */ 171 | @Override 172 | public final void setProgress(final int progress) { 173 | setProgressInternally(progress, false); 174 | } 175 | } 176 | -------------------------------------------------------------------------------- /app/src/main/java/cc/echonet/coolmicdspjava/CallbackHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) Jordan Erickson - 2014-2020, 3 | * Copyright (C) Löwenfelsen UG (haftungsbeschränkt) - 2015-2020 4 | * on behalf of Jordan Erickson. 5 | * 6 | * This file is part of Cool Mic. 7 | * 8 | * Cool Mic is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Cool Mic is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Cool Mic. If not, see . 20 | * 21 | */ 22 | 23 | package cc.echonet.coolmicdspjava; 24 | 25 | public interface CallbackHandler { 26 | void callbackHandler(WrapperConstants.WrapperCallbackEvents what, int arg0, int arg1); 27 | void callbackVUMeterHandler(VUMeterResult result); 28 | } 29 | -------------------------------------------------------------------------------- /app/src/main/java/cc/echonet/coolmicdspjava/InputStreamAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) Jordan Erickson - 2014-2020, 3 | * Copyright (C) Löwenfelsen UG (haftungsbeschränkt) - 2015-2020 4 | * on behalf of Jordan Erickson. 5 | * 6 | * This file is part of Cool Mic. 7 | * 8 | * Cool Mic is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Cool Mic is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Cool Mic. If not, see . 20 | * 21 | */ 22 | 23 | package cc.echonet.coolmicdspjava; 24 | 25 | import java.io.EOFException; 26 | import java.io.IOException; 27 | import java.io.InputStream; 28 | 29 | public class InputStreamAdapter { 30 | private InputStream is; 31 | private boolean isEOF; 32 | 33 | public InputStreamAdapter(InputStream is) { 34 | this.is = is; 35 | this.isEOF = false; 36 | } 37 | 38 | private int callback(String task, byte[] buffer) { 39 | try { 40 | switch (task) { 41 | case "close": 42 | is.close(); 43 | is = null; 44 | break; 45 | case "read": 46 | try { 47 | int ret = is.read(buffer); 48 | 49 | if (ret < buffer.length) 50 | isEOF = true; 51 | 52 | return ret; 53 | } catch (EOFException e) { 54 | isEOF = true; 55 | return -1; 56 | } 57 | case "eof": 58 | return isEOF ? 1 : 0; 59 | } 60 | } catch (IOException e) { 61 | return -1; 62 | } 63 | 64 | return -1; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /app/src/main/java/cc/echonet/coolmicdspjava/VUMeterResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) Jordan Erickson - 2014-2020, 3 | * Copyright (C) Löwenfelsen UG (haftungsbeschränkt) - 2015-2020 4 | * on behalf of Jordan Erickson. 5 | * 6 | * This file is part of Cool Mic. 7 | * 8 | * Cool Mic is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Cool Mic is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Cool Mic. If not, see . 20 | * 21 | */ 22 | 23 | package cc.echonet.coolmicdspjava; 24 | 25 | import java.io.Serializable; 26 | 27 | /** 28 | * Created by stephanj on 23.05.2016. 29 | */ 30 | public class VUMeterResult implements Serializable { 31 | 32 | public VUMeterResult(int rate, int channels, long frames, int global_peak, double global_power, int global_peak_color, int global_power_color) { 33 | this.rate = rate; 34 | this.channels = channels; 35 | this.frames = frames; 36 | this.global_peak = global_peak; 37 | this.global_power = global_power; 38 | this.global_peak_color = global_peak_color; 39 | this.global_power_color = global_power_color; 40 | } 41 | 42 | public final int rate; 43 | public final int channels; 44 | 45 | public final long frames; 46 | 47 | public final int global_peak; 48 | public final double global_power; 49 | 50 | public int[] channels_peak; 51 | public double[] channels_power; 52 | 53 | public final int global_peak_color; 54 | public final int global_power_color; 55 | 56 | public int[] channels_peak_color; 57 | public int[] channels_power_color; 58 | 59 | @SuppressWarnings("unused") 60 | public void setChannelPeakPower(int channel, int peak, double power, int peak_color, int power_color) { 61 | if (this.channels_peak == null) { 62 | this.channels_peak = new int[16]; 63 | } 64 | 65 | if (this.channels_power == null) { 66 | this.channels_power = new double[16]; 67 | } 68 | 69 | if (this.channels_peak_color == null) { 70 | this.channels_peak_color = new int[16]; 71 | } 72 | 73 | if (this.channels_power_color == null) { 74 | this.channels_power_color = new int[16]; 75 | } 76 | 77 | this.channels_peak[channel] = peak; 78 | this.channels_power[channel] = power; 79 | 80 | this.channels_peak_color[channel] = peak_color; 81 | this.channels_power_color[channel] = power_color; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /app/src/main/java/cc/echonet/coolmicdspjava/WrapperConstants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) Jordan Erickson - 2014-2020, 3 | * Copyright (C) Löwenfelsen UG (haftungsbeschränkt) - 2015-2020 4 | * on behalf of Jordan Erickson. 5 | * 6 | * This file is part of Cool Mic. 7 | * 8 | * Cool Mic is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * Cool Mic is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with Cool Mic. If not, see . 20 | * 21 | */ 22 | 23 | package cc.echonet.coolmicdspjava; 24 | 25 | /** 26 | * Created by stephanj on 17.02.2018. 27 | */ 28 | 29 | public class WrapperConstants { 30 | public enum WrapperInitializationStatus {WRAPPER_UNINITIALIZED, WRAPPER_INITIALIZATION_ERROR, WRAPPER_INTITIALIZED} 31 | 32 | public enum WrapperCallbackEvents {THREAD_POST_START, THREAD_PRE_STOP, THREAD_POST_STOP, THREAD_STOP, ERROR, STREAMSTATE, RECONNECT, SEGMENT_CONNECT, SEGMENT_DISCONNECT} 33 | } 34 | -------------------------------------------------------------------------------- /app/src/main/jni/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | LOCAL_C_INCLUDE := $(LOCAL_PATH)/include 4 | 5 | include $(addprefix $(LOCAL_PATH)/, $(addsuffix /Android.mk, \ 6 | libigloo-android-build-wrapper \ 7 | opus-android-build-wrapper \ 8 | libogg-android-build-wrapper \ 9 | libvorbis-android-build-wrapper \ 10 | libshout-android-build-wrapper \ 11 | libcoolmic-dsp-android-build-wrapper \ 12 | libcoolmic-dsp-java \ 13 | )) 14 | 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/jni/Application.mk: -------------------------------------------------------------------------------- 1 | APP_ABI := arm64-v8a x86 x86_64 2 | APP_PLATFORM := android-16 3 | -------------------------------------------------------------------------------- /app/src/main/jni/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10.2) 2 | 3 | project(CoolMic ) 4 | 5 | set(CMAKE_VERBOSE_MAKEFILE on) 6 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_LIST_DIR}/cmake" ) 7 | 8 | 9 | add_library(commoninclude INTERFACE) 10 | target_include_directories(commoninclude INTERFACE include) 11 | 12 | add_library(commoninclude-shout INTERFACE) 13 | target_include_directories(commoninclude-shout INTERFACE include/shout) 14 | 15 | 16 | add_subdirectory(libogg-android-build-wrapper) 17 | add_subdirectory(libvorbis-android-build-wrapper) 18 | add_subdirectory(opus-android-build-wrapper) 19 | add_subdirectory(libigloo-android-build-wrapper) 20 | add_subdirectory(libshout-android-build-wrapper) 21 | add_subdirectory(libcoolmic-dsp-android-build-wrapper) 22 | add_subdirectory(libcoolmic-dsp-java) 23 | -------------------------------------------------------------------------------- /app/src/main/jni/cmake/AddPrefix.cmake: -------------------------------------------------------------------------------- 1 | #source https://github.com/juselius/vasp-cmake/blob/master/cmake/AddPrefix.cmake 2 | 3 | # Prefix a variable or a list with a string. 4 | # 5 | # set (foo a b c) 6 | # add_prefix(bar ../ "${foo}") 7 | # 8 | # jonas.juselius@uit.no 2013 9 | # 10 | 11 | 12 | function (add_prefix var pfix lst) 13 | foreach(i ${lst}) 14 | set (f ${f} ${pfix}/${i}) 15 | endforeach() 16 | set (${var} ${f} PARENT_SCOPE) 17 | endfunction() -------------------------------------------------------------------------------- /app/src/main/jni/cmake/ReadVariables.cmake: -------------------------------------------------------------------------------- 1 | # source: https://gist.github.com/tusharpm/d71dd6cab8a00320ddb48cc82bf7f64c 2 | 3 | # Simple CMake utility to read variables from MK files 4 | # - Gets contents from given file (name or path) 5 | # - Parses the assignment statements 6 | # - Makes the same assignments in the PARENT_SCOPE 7 | 8 | if(POLICY CMP0007) 9 | cmake_policy(SET CMP0007 NEW) 10 | endif() 11 | 12 | function(ReadVariables MKFile) 13 | file(READ "${MKFile}" FileContents) 14 | string(REPLACE "\\\n" "" FileContents ${FileContents}) 15 | string(REPLACE "\n" ";" FileLines ${FileContents}) 16 | list(REMOVE_ITEM FileLines "") 17 | foreach(line ${FileLines}) 18 | string(REPLACE "=" ";" line_split ${line}) 19 | list(LENGTH line_split count) 20 | if (count LESS 2) 21 | message(STATUS "Skipping ${line}") 22 | continue() 23 | endif() 24 | list(GET line_split -1 value) 25 | string(STRIP ${value} value) 26 | separate_arguments(value) 27 | list(REMOVE_AT line_split -1) 28 | foreach(var_name ${line_split}) 29 | string(STRIP ${var_name} var_name) 30 | set(${var_name} ${value} PARENT_SCOPE) 31 | endforeach() 32 | endforeach() 33 | endfunction() 34 | 35 | # # An example usage of the ReadVariables function 36 | 37 | # # Do this once in the project's top CMakeLists.txt 38 | # include(ReadVariables.cmake) 39 | 40 | # # Use the following from subdirectories as required 41 | # # CAUTION: this sets variables in the current scope (directory/function) 42 | # ReadVariables(opus_sources.mk) 43 | # message("OPUS_SOURCES: ${OPUS_SOURCES}") -------------------------------------------------------------------------------- /app/src/main/jni/include/os.h: -------------------------------------------------------------------------------- 1 | #ifdef _MSC_VER 2 | typedef __int64 int64_t; 3 | typedef unsigned __int64 uint64_t; 4 | typedef unsigned __int32 uint32_t; 5 | typedef __int32 int32_t; 6 | typedef int ssize_t; 7 | #endif 8 | -------------------------------------------------------------------------------- /app/src/main/jni/include/shout/config.h: -------------------------------------------------------------------------------- 1 | /* config.h. Generated from config.h.in by configure. */ 2 | /* config.h.in. Generated from configure.ac by autoheader. */ 3 | 4 | #ifndef __CONFIG_H__ 5 | #define __CONFIG_H__ 1 6 | 7 | /* Define to 1 if you have the header file. */ 8 | #define HAVE_ARPA_INET_H 1 9 | 10 | /* Define if you have the C99 integer types */ 11 | #define HAVE_C99_INTTYPES 1 12 | 13 | /* Define to 1 if you have the header file. */ 14 | #define HAVE_DLFCN_H 1 15 | 16 | /* Define to 1 if you have the `endhostent' function. */ 17 | /* #undef HAVE_ENDHOSTENT */ 18 | 19 | /* Define to 1 if you have the `ftime' function. */ 20 | #define HAVE_FTIME 1 21 | 22 | /* Define to 1 if you have the `getaddrinfo' function. */ 23 | #define HAVE_GETADDRINFO 1 24 | 25 | /* Define if you have the getnameinfo function */ 26 | #define HAVE_GETNAMEINFO 1 27 | 28 | /* Define to 1 if you have the `gettimeofday' function. */ 29 | #define HAVE_GETTIMEOFDAY 1 30 | 31 | /* Define to 1 if you have the `inet_aton' function. */ 32 | #define HAVE_INET_ATON 1 33 | 34 | /* Define to 1 if you have the `inet_pton' function. */ 35 | #define HAVE_INET_PTON 1 36 | 37 | /* Define to 1 if you have the header file. */ 38 | #define HAVE_INTTYPES_H 1 39 | 40 | /* Define to 1 if you have the header file. */ 41 | #define HAVE_MEMORY_H 1 42 | 43 | /* Define if you have the nanosleep function */ 44 | #define HAVE_NANOSLEEP 1 45 | 46 | /* Define if you have libogg installed */ 47 | /* #undef HAVE_OGG */ 48 | 49 | /* Define if you have libopenssl. */ 50 | /* #undef HAVE_OPENSSL */ 51 | 52 | /* Define if you have POSIX threads libraries and header files. */ 53 | /* #undef HAVE_PTHREAD */ 54 | 55 | /* Define to 1 if you have the `pthread_spin_lock' function. */ 56 | /* #undef HAVE_PTHREAD_SPIN_LOCK */ 57 | 58 | /* Define if you have the sethostent function */ 59 | /* #undef HAVE_SETHOSTENT */ 60 | 61 | /* Define to 1 if the system has the type `socklen_t'. */ 62 | #define HAVE_SOCKLEN_T 1 63 | 64 | /* Define if you want speex streams supported */ 65 | /* #undef HAVE_SPEEX */ 66 | 67 | /* Define to 1 if you have the header file. */ 68 | #define HAVE_STDINT_H 1 69 | 70 | /* Define to 1 if you have the header file. */ 71 | #define HAVE_STDLIB_H 1 72 | 73 | /* Define to 1 if you have the header file. */ 74 | #define HAVE_STRINGS_H 1 75 | 76 | /* Define to 1 if you have the header file. */ 77 | #define HAVE_STRING_H 1 78 | 79 | /* Define to 1 if `ss_family' is a member of `struct sockaddr_storage'. */ 80 | #define HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY 1 81 | 82 | /* Define to 1 if you have the header file. */ 83 | #define HAVE_SYS_SELECT_H 1 84 | 85 | /* Define to 1 if you have the header file. */ 86 | #define HAVE_SYS_SOCKET_H 1 87 | 88 | /* Define to 1 if you have the header file. */ 89 | #define HAVE_SYS_STAT_H 1 90 | 91 | /* Define to 1 if you have the header file. */ 92 | /* #undef HAVE_SYS_TIMEB_H */ 93 | 94 | /* Define to 1 if you have the header file. */ 95 | #define HAVE_SYS_TYPES_H 1 96 | 97 | /* Define to 1 if you have the header file. */ 98 | #define HAVE_SYS_UIO_H 1 99 | 100 | /* Define if you want theora streams supported */ 101 | /* #undef HAVE_THEORA */ 102 | 103 | /* Define to 1 if you have the header file. */ 104 | #define HAVE_UNISTD_H 1 105 | 106 | /* Define if you have winsock2.h on MINGW */ 107 | /* #undef HAVE_WINSOCK2_H */ 108 | 109 | /* Define to 1 if you have the `writev' function. */ 110 | #define HAVE_WRITEV 1 111 | 112 | /* Shout library major version */ 113 | #define LIBSHOUT_MAJOR 2 114 | 115 | /* Shout library patch version */ 116 | #define LIBSHOUT_MICRO 1 117 | 118 | /* Shout library minor version */ 119 | #define LIBSHOUT_MINOR 4 120 | 121 | /* Define to the sub-directory in which libtool stores uninstalled libraries. 122 | */ 123 | #define LT_OBJDIR ".libs/" 124 | 125 | /* Define if you don't want to use the thread library */ 126 | /* #undef NO_THREAD */ 127 | 128 | /* Name of package */ 129 | #define PACKAGE "libshout" 130 | 131 | /* Define to the address where bug reports for this package should be sent. */ 132 | #define PACKAGE_BUGREPORT "icecast-dev@xiph.org" 133 | 134 | /* Define to the full name of this package. */ 135 | #define PACKAGE_NAME "libshout" 136 | 137 | /* Define to the full name and version of this package. */ 138 | #define PACKAGE_STRING "libshout 2.4.1" 139 | 140 | /* Define to the one symbol short name of this package. */ 141 | #define PACKAGE_TARNAME "libshout" 142 | 143 | /* Define to the home page for this package. */ 144 | #define PACKAGE_URL "" 145 | 146 | /* Define to the version of this package. */ 147 | #define PACKAGE_VERSION "2.4.1" 148 | 149 | /* Define to necessary symbol if this constant uses a non-standard name on 150 | your system. */ 151 | /* #undef PTHREAD_CREATE_JOINABLE */ 152 | 153 | /* The size of `int', as computed by sizeof. */ 154 | /* #undef SIZEOF_INT */ 155 | 156 | /* The size of `long', as computed by sizeof. */ 157 | /* #undef SIZEOF_LONG */ 158 | 159 | /* The size of `long long', as computed by sizeof. */ 160 | /* #undef SIZEOF_LONG_LONG */ 161 | 162 | /* The size of `short', as computed by sizeof. */ 163 | /* #undef SIZEOF_SHORT */ 164 | 165 | /* Define to 1 if you have the ANSI C header files. */ 166 | #define STDC_HEADERS 1 167 | 168 | /* Define to 1 if you can safely include both and . */ 169 | #define TIME_WITH_SYS_TIME 1 170 | 171 | /* Version number of package */ 172 | #define VERSION "2.4.1" 173 | 174 | #ifndef HAVE_C99_INTTYPES 175 | # if SIZEOF_SHORT == 4 176 | typedef unsigned short uint32_t; 177 | # elif SIZEOF_INT == 4 178 | typedef unsigned int uint32_t; 179 | # elif SIZEOF_LONG == 4 180 | typedef unsigned long uint32_t; 181 | # endif 182 | # if SIZEOF_INT == 8 183 | typedef unsigned int uint64_t; 184 | # elif SIZEOF_LONG == 8 185 | typedef unsigned long uint64_t; 186 | # elif SIZEOF_LONG_LONG == 8 187 | typedef unsigned long long uint64_t; 188 | # endif 189 | #endif 190 | 191 | 192 | #ifndef HAVE_SOCKLEN_T 193 | typedef int socklen_t; 194 | #endif 195 | 196 | 197 | /* Define if you have POSIX and GNU specifications */ 198 | #define _GNU_SOURCE /**/ 199 | 200 | /* Define if you have POSIX and XPG specifications */ 201 | #define _XOPEN_SOURCE 600 202 | 203 | 204 | /* name mangling to protect code we share with other libraries */ 205 | #define _mangle(proc) _shout_ ## proc 206 | 207 | 208 | /* Define to empty if `const' does not conform to ANSI C. */ 209 | /* #undef const */ 210 | 211 | /* Define to `__inline__' or `__inline' if that's what the C compiler 212 | calls it, or to nothing if 'inline' is not supported under any name. */ 213 | #ifndef __cplusplus 214 | /* #undef inline */ 215 | #endif 216 | 217 | /* define if va_copy is not available */ 218 | /* #undef va_copy */ 219 | 220 | #endif 221 | -------------------------------------------------------------------------------- /app/src/main/jni/include/stream/util.h: -------------------------------------------------------------------------------- 1 | /* Programmer: Nicholas Wertzberger 2 | * Email: wertnick@gmail.com 3 | * 4 | * A listing of helper functions for integrating with the JNI. 5 | */ 6 | #ifndef _STREAM_UTIL_H 7 | #define _STREAM_UTIL_H 8 | 9 | enum { 10 | BAD_MEM = -1, 11 | }; 12 | 13 | void 14 | JNU_ThrowByName(JNIEnv *env, const char *name, const char *msg, int code); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /app/src/main/jni/libcoolmic-dsp-android-build-wrapper/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_MODULE := coolmic-dsp 6 | LOCAL_C_INCLUDES := $(LOCAL_PATH)/libcoolmic-dsp/include 7 | LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/libcoolmic-dsp/include 8 | LOCAL_CFLAGS += -I$(LOCAL_PATH)/../include -fsigned-char -DHAVE_SNDDRV_DRIVER_OPENSL -DHAVE_SNDDRV_DRIVER_STDIO -DHAVE_ENC_OPUS -DHAVE_ENC_OPUS_BROKEN_INCLUDE_PATH#LOCAL_CFLAGS += -march=armv6 -marm -mfloat-abi=softfp -mfpu=vfp 9 | 10 | LOCAL_SHARED_LIBRARIES := libogg libvorbis libshout libopus libigloo 11 | 12 | #-lshout -L$(LOCAL_PATH)/../libshout/src/.libs/ 13 | 14 | LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog -lOpenSLES 15 | 16 | SOURCE_FILES = coolmic-dsp.c enc.c enc_vorbis.c enc_opus.c common_opus.c iohandle.c shout.c simple.c snddev.c vumeter.c tee.c snddev_null.c snddev_sine.c snddev_opensl.c snddev_stdio.c util.c metadata.c logging.c transform.c simple-segment.c 17 | 18 | LOCAL_SRC_FILES := $(foreach c,$(SOURCE_FILES),libcoolmic-dsp/src/$c) 19 | 20 | include $(BUILD_SHARED_LIBRARY) 21 | -------------------------------------------------------------------------------- /app/src/main/jni/libcoolmic-dsp-android-build-wrapper/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Sets the minimum version of CMake required to build the native 2 | # library. 3 | cmake_minimum_required(VERSION 3.10.2) 4 | 5 | include(AddPrefix) 6 | 7 | list(APPEND coolmicDSPSources coolmic-dsp.c enc.c enc_vorbis.c enc_opus.c common_opus.c iohandle.c shout.c simple.c snddev.c vumeter.c tee.c snddev_null.c snddev_sine.c snddev_opensl.c snddev_stdio.c util.c metadata.c logging.c transform.c simple-segment.c) 8 | 9 | add_prefix(coolmicDSPSources ${CMAKE_CURRENT_LIST_DIR}/libcoolmic-dsp/src/ "${coolmicDSPSources}") 10 | 11 | add_library(coolmic-dsp SHARED ${coolmicDSPSources}) 12 | 13 | target_compile_options(coolmic-dsp PRIVATE -fsigned-char -DHAVE_SNDDRV_DRIVER_OPENSL -DHAVE_SNDDRV_DRIVER_STDIO -DHAVE_ENC_OPUS -DHAVE_ENC_OPUS_BROKEN_INCLUDE_PATH) 14 | 15 | target_include_directories(coolmic-dsp PUBLIC ${CMAKE_CURRENT_LIST_DIR}/libcoolmic-dsp/include) 16 | 17 | find_library(log-lib log) 18 | find_library(opensles-lib OpenSLES) 19 | 20 | target_link_libraries(coolmic-dsp ${log-lib} ${opensles-lib} ogg vorbis vorbisenc shout opus igloo) -------------------------------------------------------------------------------- /app/src/main/jni/libcoolmic-dsp-java/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_MODULE := coolmic-dsp-java 6 | LOCAL_CFLAGS += -I$(LOCAL_PATH)/../include -I$(LOCAL_PATH)/../include/shout -I$(LOCAL_PATH)/../libcoolmic-dsp/libcoolmic-dsp/include/ -fsigned-char -std=c99 7 | #LOCAL_CFLAGS += -march=armv6 -marm -mfloat-abi=softfp -mfpu=vfp 8 | 9 | LOCAL_SHARED_LIBRARIES := libogg libvorbis libshout libcoolmic-dsp libigloo 10 | 11 | LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog 12 | #-lshout -L$(LOCAL_PATH)/../libshout/src/.libs/ 13 | 14 | LOCAL_SRC_FILES := \ 15 | wrapper.c InputStreamAdapter.c 16 | 17 | include $(BUILD_SHARED_LIBRARY) 18 | -------------------------------------------------------------------------------- /app/src/main/jni/libcoolmic-dsp-java/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Sets the minimum version of CMake required to build the native 2 | # library. 3 | cmake_minimum_required(VERSION 3.10.2) 4 | 5 | add_library(coolmic-dsp-java SHARED InputStreamAdapter.c wrapper.c) 6 | 7 | target_compile_options(coolmic-dsp-java PRIVATE -fsigned-char -std=c99) 8 | 9 | target_include_directories(coolmic-dsp-java PUBLIC ${CMAKE_CURRENT_LIST_DIR}) 10 | 11 | find_library(log-lib log) 12 | 13 | target_link_libraries(coolmic-dsp-java ${log-lib} coolmic-dsp) -------------------------------------------------------------------------------- /app/src/main/jni/libcoolmic-dsp-java/InputStreamAdapter.c: -------------------------------------------------------------------------------- 1 | // 2 | // Created by phschafft on 2019/06/03. 3 | // 4 | 5 | #include "InputStreamAdapter.h" 6 | #include 7 | #include 8 | 9 | struct InputStreamAdapter { 10 | JavaVM *vm; 11 | jobject adapter; 12 | jmethodID callback; 13 | }; 14 | 15 | 16 | InputStreamAdapter_t * inputStreamAdapter_new(JNIEnv *env, jobject adapter) { 17 | InputStreamAdapter_t *self = calloc(1, sizeof(*self)); 18 | jclass cls; 19 | 20 | if (!self) 21 | return NULL; 22 | 23 | 24 | if ((*env)->GetJavaVM(env, &(self->vm)) != 0) { 25 | free(self); 26 | return NULL; 27 | } 28 | 29 | self->adapter = (*env)->NewGlobalRef(env, adapter); 30 | 31 | if (!self->adapter) { 32 | free(self); 33 | return NULL; 34 | } 35 | 36 | cls = (*env)->GetObjectClass(env, adapter); 37 | self->callback = (*env)->GetMethodID(env, cls, "callback", "(Ljava/lang/String;[B)I"); 38 | 39 | return self; 40 | } 41 | 42 | static int callback(InputStreamAdapter_t *self, const char *task, void *buf, size_t len) 43 | { 44 | JNIEnv * env; 45 | int getEnvStat; 46 | jint ret; 47 | jstring jtask; 48 | jbyteArray jbuf; 49 | jbyte *jnbuf; 50 | 51 | getEnvStat = (*(self->vm))->GetEnv(self->vm, (void **)&env, JNI_VERSION_1_6); 52 | 53 | if (getEnvStat == JNI_EDETACHED) { 54 | if ((*(self->vm))->AttachCurrentThread(self->vm, &env, NULL) != 0) { 55 | return -1; 56 | } 57 | } else if (getEnvStat == JNI_OK) { 58 | // 59 | } else if (getEnvStat == JNI_EVERSION) { 60 | return -1; 61 | } 62 | 63 | jtask = (*env)->NewStringUTF(env, task); 64 | 65 | jbuf = (*env)->NewByteArray(env, len); 66 | 67 | ret = (*env)->CallIntMethod(env, self->adapter, self->callback, jtask, jbuf); 68 | 69 | if (ret > 0 && ret <= len) { 70 | jnbuf = (*env)->GetByteArrayElements(env, jbuf, NULL); 71 | memcpy(buf, jnbuf, (size_t) ret); 72 | (*env)->ReleaseByteArrayElements(env, jbuf, jnbuf, 0); 73 | } 74 | 75 | (*env)->DeleteLocalRef(env, jbuf); 76 | (*env)->DeleteLocalRef(env, jtask); 77 | 78 | return ret; 79 | } 80 | 81 | int inputStreamAdapter_close(InputStreamAdapter_t *self) 82 | { 83 | JNIEnv * env; 84 | callback(self, "close", NULL, 0); 85 | if ((*(self->vm))->GetEnv(self->vm, (void **)&env, JNI_VERSION_1_6) == JNI_OK) { 86 | // Not sure why, but we must not detach the thread here. 87 | // (*(self->vm))->DetachCurrentThread(self->vm); 88 | } 89 | 90 | free(self); 91 | 92 | return 0; 93 | } 94 | ssize_t inputStreamAdapter_read(InputStreamAdapter_t *self, void * buf, size_t len) 95 | { 96 | return callback(self, "read", buf, len); 97 | } 98 | 99 | 100 | static int __eof (void *userdata) 101 | { 102 | InputStreamAdapter_t *self = userdata; 103 | 104 | return callback(self, "eof", NULL, 0); 105 | } 106 | 107 | coolmic_iohandle_t * inputStreamAdapter_new_iohandle(JNIEnv * env, jobject adapter) 108 | { 109 | InputStreamAdapter_t *self = inputStreamAdapter_new(env, adapter); 110 | if (!self) 111 | return NULL; 112 | 113 | return coolmic_iohandle_new(NULL, igloo_RO_NULL, self, inputStreamAdapter_close, inputStreamAdapter_read, __eof); 114 | } 115 | -------------------------------------------------------------------------------- /app/src/main/jni/libcoolmic-dsp-java/InputStreamAdapter.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by phschafft on 2019/06/03. 3 | // 4 | 5 | #include 6 | #include 7 | #include "../libogg-android-build-wrapper/ogg/config_types.h" 8 | 9 | #ifndef COOLMIC_INPUTSTREAMADAPTER_H 10 | #define COOLMIC_INPUTSTREAMADAPTER_H 11 | 12 | typedef struct InputStreamAdapter InputStreamAdapter_t; 13 | 14 | InputStreamAdapter_t * inputStreamAdapter_new(JNIEnv * env, jobject adapter); 15 | int inputStreamAdapter_close(InputStreamAdapter_t *self); 16 | ssize_t inputStreamAdapter_read(InputStreamAdapter_t *self, void * buf, size_t len); 17 | 18 | coolmic_iohandle_t * inputStreamAdapter_new_iohandle(JNIEnv * env, jobject adapter); 19 | 20 | #endif //COOLMIC_INPUTSTREAMADAPTER_H 21 | -------------------------------------------------------------------------------- /app/src/main/jni/libigloo-android-build-wrapper/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_MODULE := libigloo 6 | LOCAL_CFLAGS += -I$(LOCAL_PATH)/include -I$(LOCAL_PATH)/libigloo/include -I$(LOCAL_PATH)/libigloo/src -ffast-math -fsigned-char -DHAVE_CONFIG_H=1 7 | 8 | LOCAL_SRC_FILES := libigloo/net/sock.c libigloo/net/resolver.c libigloo/thread/thread.c libigloo/httpp/httpp.c libigloo/httpp/encoding.c libigloo/avl/avl.c libigloo/log/log.c libigloo/timing/timing.c libigloo/src/buffer.c libigloo/src/libigloo.c libigloo/src/list.c libigloo/src/ro.c 9 | 10 | LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/libigloo/include $(LOCAL_PATH)/include 11 | 12 | include $(BUILD_SHARED_LIBRARY) 13 | -------------------------------------------------------------------------------- /app/src/main/jni/libigloo-android-build-wrapper/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Sets the minimum version of CMake required to build the native 2 | # library. 3 | cmake_minimum_required(VERSION 3.10.2) 4 | 5 | add_library(igloo SHARED libigloo/net/sock.c libigloo/net/resolver.c libigloo/thread/thread.c libigloo/httpp/httpp.c libigloo/httpp/encoding.c libigloo/avl/avl.c libigloo/log/log.c libigloo/timing/timing.c libigloo/src/buffer.c libigloo/src/libigloo.c libigloo/src/list.c libigloo/src/ro.c) 6 | 7 | target_compile_options(igloo PRIVATE -ffast-math -fsigned-char -DHAVE_CONFIG_H=1) 8 | 9 | target_include_directories(igloo 10 | PUBLIC 11 | ${CMAKE_CURRENT_LIST_DIR}/libigloo/include 12 | ${CMAKE_CURRENT_LIST_DIR}/include 13 | PRIVATE 14 | ${CMAKE_CURRENT_LIST_DIR}/libigloo/src 15 | ) 16 | 17 | 18 | -------------------------------------------------------------------------------- /app/src/main/jni/libigloo-android-build-wrapper/include/config.h: -------------------------------------------------------------------------------- 1 | #ifndef _INCLUDE_IGLOO_CONFIG_H2 2 | #define _INCLUDE_IGLOO_CONFIG_H2 1 3 | 4 | /* include/igloo/config.h. Generated automatically at end of configure. */ 5 | /* config.h. Generated from config.h.in by configure. */ 6 | /* config.h.in. Generated from configure.ac by autoheader. */ 7 | 8 | /* Define to 1 if your system has a working `chown' function. */ 9 | #ifndef HAVE_CHOWN 10 | #define HAVE_CHOWN 1 11 | #endif 12 | 13 | /* Define to 1 if you have the header file. */ 14 | #ifndef HAVE_DLFCN_H 15 | #define HAVE_DLFCN_H 1 16 | #endif 17 | 18 | /* Define to 1 if you have the `endhostent' function. */ 19 | //#ifndef HAVE_ENDHOSTENT 20 | //#define HAVE_ENDHOSTENT 1 21 | //#endif 22 | 23 | /* Define to 1 if you have the `fork' function. */ 24 | #ifndef HAVE_FORK 25 | #define HAVE_FORK 1 26 | #endif 27 | 28 | /* Define to 1 if you have the `ftime' function. */ 29 | #ifndef HAVE_FTIME 30 | #define HAVE_FTIME 1 31 | #endif 32 | 33 | /* Define to 1 if you have the `getaddrinfo' function. */ 34 | #ifndef HAVE_GETADDRINFO 35 | #define HAVE_GETADDRINFO 1 36 | #endif 37 | 38 | /* Define to 1 if you have the `gethostname' function. */ 39 | #ifndef HAVE_GETHOSTNAME 40 | #define HAVE_GETHOSTNAME 1 41 | #endif 42 | 43 | /* Define if you have the getnameinfo function */ 44 | #ifndef HAVE_GETNAMEINFO 45 | #define HAVE_GETNAMEINFO 1 46 | #endif 47 | 48 | /* Define to 1 if you have the `gettimeofday' function. */ 49 | #ifndef HAVE_GETTIMEOFDAY 50 | #define HAVE_GETTIMEOFDAY 1 51 | #endif 52 | 53 | /* Define to 1 if you have the header file. */ 54 | #ifndef HAVE_GRP_H 55 | #define HAVE_GRP_H 1 56 | #endif 57 | 58 | /* Define to 1 if you have the `inet_aton' function. */ 59 | #ifndef HAVE_INET_ATON 60 | #define HAVE_INET_ATON 1 61 | #endif 62 | 63 | /* Define to 1 if you have the header file. */ 64 | #ifndef HAVE_INTTYPES_H 65 | #define HAVE_INTTYPES_H 1 66 | #endif 67 | 68 | /* Define to 1 if you have the header file. */ 69 | #ifndef HAVE_MEMORY_H 70 | #define HAVE_MEMORY_H 1 71 | #endif 72 | 73 | /* Define if you have nanosleep */ 74 | #ifndef HAVE_NANOSLEEP 75 | #define HAVE_NANOSLEEP 1 76 | #endif 77 | 78 | /* Define to 1 if you have the `poll' function. */ 79 | #ifndef HAVE_POLL 80 | #define HAVE_POLL 1 81 | #endif 82 | 83 | /* Define if you have POSIX threads libraries and header files. */ 84 | #ifndef HAVE_PTHREAD 85 | #define HAVE_PTHREAD 1 86 | #endif 87 | 88 | /* Define to 1 if you have the `pthread_spin_lock' function. */ 89 | //#ifndef HAVE_PTHREAD_SPIN_LOCK 90 | //#define HAVE_PTHREAD_SPIN_LOCK 1 91 | //#endif 92 | 93 | /* Define to 1 if you have the header file. */ 94 | #ifndef HAVE_PWD_H 95 | #define HAVE_PWD_H 1 96 | #endif 97 | 98 | /* Define if you have the sethostent function */ 99 | //#ifndef HAVE_SETHOSTENT 100 | //#define HAVE_SETHOSTENT 1 101 | //#endif 102 | 103 | /* Define to 1 if you have the header file. */ 104 | #ifndef HAVE_STDINT_H 105 | #define HAVE_STDINT_H 1 106 | #endif 107 | 108 | /* Define to 1 if you have the header file. */ 109 | #ifndef HAVE_STDLIB_H 110 | #define HAVE_STDLIB_H 1 111 | #endif 112 | 113 | /* Define to 1 if you have the header file. */ 114 | #ifndef HAVE_STRINGS_H 115 | #define HAVE_STRINGS_H 1 116 | #endif 117 | 118 | /* Define to 1 if you have the header file. */ 119 | #ifndef HAVE_STRING_H 120 | #define HAVE_STRING_H 1 121 | #endif 122 | 123 | /* Define to 1 if you have the header file. */ 124 | #ifndef HAVE_SYS_SELECT_H 125 | #define HAVE_SYS_SELECT_H 1 126 | #endif 127 | 128 | /* Define to 1 if you have the header file. */ 129 | #ifndef HAVE_SYS_SOCKET_H 130 | #define HAVE_SYS_SOCKET_H 1 131 | #endif 132 | 133 | /* Define to 1 if you have the header file. */ 134 | #ifndef HAVE_SYS_STAT_H 135 | #define HAVE_SYS_STAT_H 1 136 | #endif 137 | 138 | /* Define to 1 if you have the header file. */ 139 | //#ifndef HAVE_SYS_TIMEB_H 140 | //#define HAVE_SYS_TIMEB_H 1 141 | //#endif 142 | 143 | /* Define to 1 if you have the header file. */ 144 | #ifndef HAVE_SYS_TYPES_H 145 | #define HAVE_SYS_TYPES_H 1 146 | #endif 147 | 148 | /* Define to 1 if you have the header file. */ 149 | #ifndef HAVE_SYS_UIO_H 150 | #define HAVE_SYS_UIO_H 1 151 | #endif 152 | 153 | /* Define to 1 if the system has the `transparent_union' type attribute */ 154 | #ifndef HAVE_TYPE_ATTRIBUTE_TRANSPARENT_UNION 155 | #define HAVE_TYPE_ATTRIBUTE_TRANSPARENT_UNION 1 156 | #endif 157 | 158 | /* Define to 1 if you have the header file. */ 159 | #ifndef HAVE_UNISTD_H 160 | #define HAVE_UNISTD_H 1 161 | #endif 162 | 163 | /* Define to 1 if you have the `vfork' function. */ 164 | #ifndef HAVE_VFORK 165 | #define HAVE_VFORK 1 166 | #endif 167 | 168 | /* Define to 1 if you have the header file. */ 169 | /* #undef HAVE_VFORK_H */ 170 | 171 | /* Define if you have winsock2.h on MINGW */ 172 | /* #undef HAVE_WINSOCK2_H */ 173 | 174 | /* Define to 1 if `fork' works. */ 175 | #ifndef HAVE_WORKING_FORK 176 | #define HAVE_WORKING_FORK 1 177 | #endif 178 | 179 | /* Define to 1 if `vfork' works. */ 180 | #ifndef HAVE_WORKING_VFORK 181 | #define HAVE_WORKING_VFORK 1 182 | #endif 183 | 184 | /* Define to 1 if you have the `writev' function. */ 185 | #ifndef HAVE_WRITEV 186 | #define HAVE_WRITEV 1 187 | #endif 188 | 189 | /* Define to the sub-directory in which libtool stores uninstalled libraries. 190 | */ 191 | #ifndef LT_OBJDIR 192 | #define LT_OBJDIR ".libs/" 193 | #endif 194 | 195 | /* Define to 1 if assertions should be disabled. */ 196 | /* #undef NDEBUG */ 197 | 198 | /* Name of package */ 199 | #ifndef PACKAGE 200 | #define PACKAGE "igloo" 201 | #endif 202 | 203 | /* Define to the address where bug reports for this package should be sent. */ 204 | #ifndef PACKAGE_BUGREPORT 205 | #define PACKAGE_BUGREPORT "icecast@xiph.org" 206 | #endif 207 | 208 | /* Define to the full name of this package. */ 209 | #ifndef PACKAGE_NAME 210 | #define PACKAGE_NAME "igloo" 211 | #endif 212 | 213 | /* Define to the full name and version of this package. */ 214 | #ifndef PACKAGE_STRING 215 | #define PACKAGE_STRING "igloo 0.0.1" 216 | #endif 217 | 218 | /* Define to the one symbol short name of this package. */ 219 | #ifndef PACKAGE_TARNAME 220 | #define PACKAGE_TARNAME "igloo" 221 | #endif 222 | 223 | /* Define to the home page for this package. */ 224 | #ifndef PACKAGE_URL 225 | #define PACKAGE_URL "" 226 | #endif 227 | 228 | /* Define to the version of this package. */ 229 | #ifndef PACKAGE_VERSION 230 | #define PACKAGE_VERSION "0.0.1" 231 | #endif 232 | 233 | /* Define to necessary symbol if this constant uses a non-standard name on 234 | your system. */ 235 | /* #undef PTHREAD_CREATE_JOINABLE */ 236 | 237 | /* Define to 1 if you have the ANSI C header files. */ 238 | #ifndef STDC_HEADERS 239 | #define STDC_HEADERS 1 240 | #endif 241 | 242 | /* Define to 1 if you can safely include both and . */ 243 | #ifndef TIME_WITH_SYS_TIME 244 | #define TIME_WITH_SYS_TIME 1 245 | #endif 246 | 247 | /* Version number of package */ 248 | #ifndef VERSION 249 | #define VERSION "0.0.1" 250 | #endif 251 | 252 | /* Enable large inode numbers on Mac OS X 10.5. */ 253 | #ifndef _DARWIN_USE_64_BIT_INODE 254 | # define _DARWIN_USE_64_BIT_INODE 1 255 | #endif 256 | 257 | /* Number of bits in a file offset, on hosts where this is settable. */ 258 | /* #undef _FILE_OFFSET_BITS */ 259 | 260 | /* Define to include GNU extensions to POSIX */ 261 | #ifndef _GNU_SOURCE 262 | #define _GNU_SOURCE 1 263 | #endif 264 | 265 | /* Define for large files, on AIX-style hosts. */ 266 | /* #undef _LARGE_FILES */ 267 | 268 | /* Define to `int' if doesn't define. */ 269 | /* #undef gid_t */ 270 | 271 | /* Define to `long int' if does not define. */ 272 | /* #undef off_t */ 273 | 274 | /* Define to `int' if does not define. */ 275 | /* #undef pid_t */ 276 | 277 | /* Define to `unsigned int' if does not define. */ 278 | /* #undef size_t */ 279 | 280 | /* Define to `int' if does not define. */ 281 | /* #undef ssize_t */ 282 | 283 | /* Define to `int' if doesn't define. */ 284 | /* #undef uid_t */ 285 | 286 | /* Define as `fork' if `vfork' does not work. */ 287 | /* #undef vfork */ 288 | 289 | /* once: _INCLUDE_IGLOO_CONFIG_H */ 290 | #endif 291 | -------------------------------------------------------------------------------- /app/src/main/jni/libogg-android-build-wrapper/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_MODULE := libogg 6 | LOCAL_C_INCLUDES = $(LOCAL_PATH) 7 | LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/libogg/include $(LOCAL_PATH) 8 | LOCAL_CFLAGS += -I$(LOCAL_PATH)/../include -I$(LOCAL_PATH)/libogg/include -I$(LOCAL_PATH)/libogg/src -ffast-math -fsigned-char 9 | #LOCAL_CFLAGS += -march=armv6 -marm -mfloat-abi=softfp -mfpu=vfp 10 | 11 | 12 | LOCAL_SRC_FILES := \ 13 | libogg/src/bitwise.c \ 14 | libogg/src/framing.c 15 | 16 | 17 | 18 | include $(BUILD_SHARED_LIBRARY) 19 | -------------------------------------------------------------------------------- /app/src/main/jni/libogg-android-build-wrapper/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Sets the minimum version of CMake required to build the native 2 | # library. 3 | cmake_minimum_required(VERSION 3.10.2) 4 | 5 | option(BUILD_SHARED_LIBS "" ON) 6 | add_subdirectory(libogg) -------------------------------------------------------------------------------- /app/src/main/jni/libogg-android-build-wrapper/ogg/config_types.h: -------------------------------------------------------------------------------- 1 | #ifndef __CONFIG_TYPES_H__ 2 | #define __CONFIG_TYPES_H__ 3 | 4 | /* these are filled in by configure */ 5 | #define INCLUDE_INTTYPES_H 1 6 | #define INCLUDE_STDINT_H 1 7 | #define INCLUDE_SYS_TYPES_H 1 8 | 9 | #if INCLUDE_INTTYPES_H 10 | # include 11 | #endif 12 | #if INCLUDE_STDINT_H 13 | # include 14 | #endif 15 | #if INCLUDE_SYS_TYPES_H 16 | # include 17 | #endif 18 | 19 | typedef short ogg_int16_t; 20 | typedef unsigned short ogg_uint16_t; 21 | typedef int ogg_int32_t; 22 | typedef unsigned int ogg_uint32_t; 23 | typedef long long ogg_int64_t; 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /app/src/main/jni/libshout-android-build-wrapper/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_MODULE := libshout 6 | LOCAL_CFLAGS += -I$(LOCAL_PATH)/../include -I$(LOCAL_PATH)/../include/shout -I$(LOCAL_PATH)/libshout/src -I$(LOCAL_PATH)/libshout/src/common -I$(LOCAL_PATH)/libshout/include -ffast-math -fsigned-char -DHAVE_CONFIG_H=1 -DDISABLE_PTHREAD_BLA=1 7 | #LOCAL_CFLAGS += -march=armv6 -marm -mfloat-abi=softfp -mfpu=vfp 8 | LOCAL_SHARED_LIBRARIES := libvorbis libogg 9 | 10 | LOCAL_SRC_FILES := libshout/src/common/net/sock.c libshout/src/common/net/resolver.c libshout/src/common/thread/thread.c libshout/src/common/httpp/httpp.c libshout/src/common/httpp/encoding.c libshout/src/common/avl/avl.c libshout/src/common/log/log.c libshout/src/common/timing/timing.c libshout/src/util.c libshout/src/queue.c libshout/src/proto_http.c libshout/src/proto_xaudiocast.c libshout/src/proto_icy.c libshout/src/proto_roaraudio.c libshout/src/format_ogg.c libshout/src/format_webm.c libshout/src/format_mp3.c libshout/src/codec_vorbis.c libshout/src/codec_opus.c libshout/src/shout.c libshout/src/connection.c 11 | 12 | include $(BUILD_SHARED_LIBRARY) 13 | -------------------------------------------------------------------------------- /app/src/main/jni/libshout-android-build-wrapper/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Sets the minimum version of CMake required to build the native 2 | # library. 3 | cmake_minimum_required(VERSION 3.10.2) 4 | 5 | add_library(shout 6 | SHARED 7 | libshout/src/common/net/sock.c 8 | libshout/src/common/net/resolver.c 9 | libshout/src/common/thread/thread.c 10 | libshout/src/common/httpp/httpp.c 11 | libshout/src/common/httpp/encoding.c 12 | libshout/src/common/avl/avl.c 13 | libshout/src/common/log/log.c 14 | libshout/src/common/timing/timing.c 15 | libshout/src/util.c 16 | libshout/src/queue.c 17 | libshout/src/proto_http.c 18 | libshout/src/proto_xaudiocast.c 19 | libshout/src/proto_icy.c 20 | libshout/src/proto_roaraudio.c 21 | libshout/src/format_ogg.c 22 | libshout/src/format_webm.c 23 | libshout/src/format_mp3.c 24 | libshout/src/codec_vorbis.c 25 | libshout/src/codec_opus.c 26 | libshout/src/shout.c 27 | libshout/src/connection.c 28 | ) 29 | 30 | target_compile_options(shout PRIVATE -ffast-math -fsigned-char -DHAVE_CONFIG_H=1 -DDISABLE_PTHREAD_BLA=1) 31 | 32 | target_include_directories(shout 33 | PRIVATE 34 | ${CMAKE_CURRENT_LIST_DIR}/libshout/src 35 | ${CMAKE_CURRENT_LIST_DIR}/libshout/src/common 36 | ${CMAKE_CURRENT_LIST_DIR}/libshout/include 37 | ) 38 | 39 | target_link_libraries(shout commoninclude commoninclude-shout ogg vorbis) -------------------------------------------------------------------------------- /app/src/main/jni/libshout-android-build-wrapper/thread.c.patch: -------------------------------------------------------------------------------- 1 | diff --git a/thread/thread.c b/thread/thread.c 2 | index e29ea20..04d2b14 100644 3 | --- a/thread/thread.c 4 | +++ b/thread/thread.c 5 | @@ -221,9 +221,10 @@ void thread_shutdown(void) 6 | static void _block_signals(void) 7 | { 8 | #ifndef _WIN32 9 | +#ifndef DISABLE_PTHREAD_BLA 10 | sigset_t ss; 11 | 12 | - sigfillset(&ss); 13 | + //sigfillset(&ss); 14 | 15 | /* These ones we want */ 16 | sigdelset(&ss, SIGKILL); 17 | @@ -237,6 +238,7 @@ static void _block_signals(void) 18 | #endif 19 | } 20 | #endif 21 | +#endif 22 | } 23 | 24 | /* 25 | @@ -247,6 +249,7 @@ static void _block_signals(void) 26 | static void _catch_signals(void) 27 | { 28 | #ifndef _WIN32 29 | +#ifndef DISABLE_PTHREAD_BLA 30 | sigset_t ss; 31 | 32 | sigemptyset(&ss); 33 | @@ -264,6 +267,7 @@ static void _catch_signals(void) 34 | #endif 35 | } 36 | #endif 37 | +#endif 38 | } 39 | 40 | 41 | @@ -299,7 +303,11 @@ thread_type *thread_create_c(char *name, void *(*start_routine)(void *), 42 | start->thread = thread; 43 | 44 | pthread_attr_setstacksize (&attr, 512*1024); 45 | + 46 | +#ifndef DISABLE_PTHREAD_BLA 47 | pthread_attr_setinheritsched (&attr, PTHREAD_INHERIT_SCHED); 48 | +#endif 49 | + 50 | if (detached) 51 | { 52 | pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED); 53 | @@ -656,7 +664,10 @@ static void *_start_routine(void *arg) 54 | LOG_INFO4("Added thread %d [%s] started at [%s:%d]", thread->thread_id, thread->name, thread->file, thread->line); 55 | #endif 56 | 57 | +#ifndef DISABLE_PTHREAD_BLA 58 | pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, NULL); 59 | +#endif 60 | + 61 | free (start); 62 | 63 | (start_routine)(real_arg); 64 | -------------------------------------------------------------------------------- /app/src/main/jni/libvorbis-android-build-wrapper/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_MODULE := libvorbis 6 | LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/libvorbis/include 7 | LOCAL_CFLAGS += -I$(LOCAL_PATH)/../include -I$(LOCAL_PATH)/libvorbis/include -I$(LOCAL_PATH)/libvorbis/lib -ffast-math -fsigned-char 8 | #LOCAL_CFLAGS += -march=armv6 -marm -mfloat-abi=softfp -mfpu=vfp 9 | LOCAL_SHARED_LIBRARIES := libogg 10 | 11 | LOCAL_SRC_FILES := \ 12 | libvorbis/lib/mdct.c \ 13 | libvorbis/lib/smallft.c \ 14 | libvorbis/lib/block.c \ 15 | libvorbis/lib/envelope.c \ 16 | libvorbis/lib/window.c \ 17 | libvorbis/lib/lsp.c \ 18 | libvorbis/lib/lpc.c \ 19 | libvorbis/lib/analysis.c \ 20 | libvorbis/lib/synthesis.c \ 21 | libvorbis/lib/psy.c \ 22 | libvorbis/lib/info.c \ 23 | libvorbis/lib/floor1.c \ 24 | libvorbis/lib/floor0.c \ 25 | libvorbis/lib/res0.c \ 26 | libvorbis/lib/mapping0.c \ 27 | libvorbis/lib/registry.c \ 28 | libvorbis/lib/codebook.c \ 29 | libvorbis/lib/sharedbook.c \ 30 | libvorbis/lib/lookup.c \ 31 | libvorbis/lib/bitrate.c \ 32 | libvorbis/lib/vorbisfile.c \ 33 | libvorbis/lib/vorbisenc.c 34 | 35 | include $(BUILD_SHARED_LIBRARY) 36 | -------------------------------------------------------------------------------- /app/src/main/jni/libvorbis-android-build-wrapper/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Sets the minimum version of CMake required to build the native 2 | # library. 3 | cmake_minimum_required(VERSION 3.10.2) 4 | 5 | set(BUILD_SHARED_LIBS ON) 6 | add_subdirectory(libvorbis) -------------------------------------------------------------------------------- /app/src/main/jni/opus-android-build-wrapper/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | include $(LOCAL_PATH)/opus/celt_sources.mk 5 | include $(LOCAL_PATH)/opus/silk_sources.mk 6 | include $(LOCAL_PATH)/opus/opus_sources.mk 7 | 8 | LOCAL_MODULE := opus 9 | LOCAL_CFLAGS += -I$(LOCAL_PATH)/opus/include -I$(LOCAL_PATH)/ -I$(LOCAL_PATH)/opus/celt/ -I$(LOCAL_PATH)/opus/silk/ -I$(LOCAL_PATH)/opus/silk/float/ -fsigned-char -DHAVE_CONFIG_H=1 10 | #LOCAL_CFLAGS += -march=armv6 -marm -mfloat-abi=softfp -mfpu=vfp 11 | 12 | LOCAL_SRC_FILES := $(addprefix opus/, $(CELT_SOURCES)) $(addprefix opus/, $(SILK_SOURCES) $(SILK_SOURCES_FLOAT)) $(addprefix opus/, $(OPUS_SOURCES) $(OPUS_SOURCES_FLOAT)) 13 | 14 | LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) 15 | include $(BUILD_SHARED_LIBRARY) 16 | -------------------------------------------------------------------------------- /app/src/main/jni/opus-android-build-wrapper/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Sets the minimum version of CMake required to build the native 2 | # library. 3 | cmake_minimum_required(VERSION 3.10.2) 4 | 5 | set(BUILD_SHARED_LIBS ON) 6 | add_subdirectory(opus) 7 | -------------------------------------------------------------------------------- /app/src/main/jni/opus-android-build-wrapper/config.h: -------------------------------------------------------------------------------- 1 | /* config.h. Generated from config.h.in by configure. */ 2 | /* config.h.in. Generated from configure.ac by autoheader. */ 3 | 4 | /* Get CPU Info by asm method */ 5 | //#define CPU_INFO_BY_ASM 1 6 | 7 | /* Get CPU Info by c method */ 8 | /* #undef CPU_INFO_BY_C */ 9 | 10 | /* Custom modes */ 11 | /* #undef CUSTOM_MODES */ 12 | 13 | /* Do not build the float API */ 14 | /* #undef DISABLE_FLOAT_API */ 15 | 16 | /* Assertions */ 17 | /* #undef ENABLE_ASSERTIONS */ 18 | 19 | /* Ambisonics Support */ 20 | /* #undef ENABLE_EXPERIMENTAL_AMBISONICS */ 21 | 22 | /* Debug fixed-point implementation */ 23 | /* #undef FIXED_DEBUG */ 24 | 25 | /* Compile as fixed-point (for machines without a fast enough FPU) */ 26 | /* #undef FIXED_POINT */ 27 | 28 | /* Float approximations */ 29 | /* #undef FLOAT_APPROX */ 30 | 31 | /* Fuzzing */ 32 | /* #undef FUZZING */ 33 | 34 | /* Define to 1 if you have the header file. */ 35 | /* #undef HAVE_ALLOCA_H */ 36 | 37 | /* NE10 library is installed on host. Make sure it is on target! */ 38 | /* #undef HAVE_ARM_NE10 */ 39 | 40 | /* Define to 1 if you have the header file. */ 41 | #define HAVE_DLFCN_H 1 42 | 43 | /* Define to 1 if you have the header file. */ 44 | #define HAVE_INTTYPES_H 1 45 | 46 | /* Define to 1 if you have the `lrint' function. */ 47 | #define HAVE_LRINT 1 48 | 49 | /* Define to 1 if you have the `lrintf' function. */ 50 | #define HAVE_LRINTF 1 51 | 52 | /* Define to 1 if you have the header file. */ 53 | #define HAVE_MEMORY_H 1 54 | 55 | /* Define to 1 if you have the header file. */ 56 | #define HAVE_STDINT_H 1 57 | 58 | /* Define to 1 if you have the header file. */ 59 | #define HAVE_STDLIB_H 1 60 | 61 | /* Define to 1 if you have the header file. */ 62 | #define HAVE_STRINGS_H 1 63 | 64 | /* Define to 1 if you have the header file. */ 65 | #define HAVE_STRING_H 1 66 | 67 | /* Define to 1 if you have the header file. */ 68 | #define HAVE_SYS_STAT_H 1 69 | 70 | /* Define to 1 if you have the header file. */ 71 | #define HAVE_SYS_TYPES_H 1 72 | 73 | /* Define to 1 if you have the header file. */ 74 | #define HAVE_UNISTD_H 1 75 | 76 | /* Define to 1 if you have the `__malloc_hook' function. */ 77 | /* #undef HAVE___MALLOC_HOOK */ 78 | 79 | /* Define to the sub-directory where libtool stores uninstalled libraries. */ 80 | #define LT_OBJDIR ".libs/" 81 | 82 | /* Make use of ARM asm optimization */ 83 | /* #undef OPUS_ARM_ASM */ 84 | 85 | /* Use generic ARMv4 inline asm optimizations */ 86 | /* #undef OPUS_ARM_INLINE_ASM */ 87 | 88 | /* Use ARMv5E inline asm optimizations */ 89 | /* #undef OPUS_ARM_INLINE_EDSP */ 90 | 91 | /* Use ARMv6 inline asm optimizations */ 92 | /* #undef OPUS_ARM_INLINE_MEDIA */ 93 | 94 | /* Use ARM NEON inline asm optimizations */ 95 | /* #undef OPUS_ARM_INLINE_NEON */ 96 | 97 | /* Define if assembler supports EDSP instructions */ 98 | /* #undef OPUS_ARM_MAY_HAVE_EDSP */ 99 | 100 | /* Define if assembler supports ARMv6 media instructions */ 101 | /* #undef OPUS_ARM_MAY_HAVE_MEDIA */ 102 | 103 | /* Define if compiler supports NEON instructions */ 104 | /* #undef OPUS_ARM_MAY_HAVE_NEON */ 105 | 106 | /* Compiler supports ARMv7/Aarch64 Neon Intrinsics */ 107 | /* #undef OPUS_ARM_MAY_HAVE_NEON_INTR */ 108 | 109 | /* Define if binary requires Aarch64 Neon Intrinsics */ 110 | /* #undef OPUS_ARM_PRESUME_AARCH64_NEON_INTR */ 111 | 112 | /* Define if binary requires EDSP instruction support */ 113 | /* #undef OPUS_ARM_PRESUME_EDSP */ 114 | 115 | /* Define if binary requires ARMv6 media instruction support */ 116 | /* #undef OPUS_ARM_PRESUME_MEDIA */ 117 | 118 | /* Define if binary requires NEON instruction support */ 119 | /* #undef OPUS_ARM_PRESUME_NEON */ 120 | 121 | /* Define if binary requires NEON intrinsics support */ 122 | /* #undef OPUS_ARM_PRESUME_NEON_INTR */ 123 | 124 | /* This is a build of OPUS */ 125 | #define OPUS_BUILD /**/ 126 | 127 | /* Use run-time CPU capabilities detection */ 128 | #define OPUS_HAVE_RTCD 1 129 | 130 | /* Compiler supports X86 AVX Intrinsics */ 131 | /*#define OPUS_X86_MAY_HAVE_AVX 1*/ 132 | 133 | /* Compiler supports X86 SSE Intrinsics */ 134 | /*#define OPUS_X86_MAY_HAVE_SSE 1*/ 135 | 136 | /* Compiler supports X86 SSE2 Intrinsics */ 137 | /*#define OPUS_X86_MAY_HAVE_SSE2 1*/ 138 | 139 | /* Compiler supports X86 SSE4.1 Intrinsics */ 140 | /*#define OPUS_X86_MAY_HAVE_SSE4_1 1*/ 141 | 142 | /* Define if binary requires AVX intrinsics support */ 143 | /* #undef OPUS_X86_PRESUME_AVX */ 144 | 145 | /* Define if binary requires SSE intrinsics support */ 146 | /*#define OPUS_X86_PRESUME_SSE 1*/ 147 | 148 | /* Define if binary requires SSE2 intrinsics support */ 149 | /*#define OPUS_X86_PRESUME_SSE2 1*/ 150 | 151 | /* Define if binary requires SSE4.1 intrinsics support */ 152 | /* #undef OPUS_X86_PRESUME_SSE4_1 */ 153 | 154 | /* Define to the address where bug reports for this package should be sent. */ 155 | #define PACKAGE_BUGREPORT "opus@xiph.org" 156 | 157 | /* Define to the full name of this package. */ 158 | #define PACKAGE_NAME "opus" 159 | 160 | /* Define to the full name and version of this package. */ 161 | #define PACKAGE_STRING "opus 1.1.3-1-gc1acbe0-dirty" 162 | 163 | /* Define to the one symbol short name of this package. */ 164 | #define PACKAGE_TARNAME "opus" 165 | 166 | /* Define to the home page for this package. */ 167 | #define PACKAGE_URL "" 168 | 169 | /* Define to the version of this package. */ 170 | #define PACKAGE_VERSION "1.1.3-1-gc1acbe0-dirty" 171 | 172 | /* Define to 1 if you have the ANSI C header files. */ 173 | #define STDC_HEADERS 1 174 | 175 | /* Make use of alloca */ 176 | /* #undef USE_ALLOCA */ 177 | 178 | /* Use C99 variable-size arrays */ 179 | #define VAR_ARRAYS 1 180 | 181 | /* Define to empty if `const' does not conform to ANSI C. */ 182 | /* #undef const */ 183 | 184 | /* Define to `__inline__' or `__inline' if that's what the C compiler 185 | calls it, or to nothing if 'inline' is not supported under any name. */ 186 | #ifndef __cplusplus 187 | /* #undef inline */ 188 | #endif 189 | 190 | /* Define to the equivalent of the C99 'restrict' keyword, or to 191 | nothing if this is not supported. Do not define if restrict is 192 | supported directly. */ 193 | #define restrict __restrict 194 | /* Work around a bug in Sun C++: it does not support _Restrict or 195 | __restrict__, even though the corresponding Sun C compiler ends up with 196 | "#define restrict _Restrict" or "#define restrict __restrict__" in the 197 | previous line. Perhaps some future version of Sun C++ will work with 198 | restrict; if so, hopefully it defines __RESTRICT like Sun C does. */ 199 | #if defined __SUNPRO_CC && !defined __RESTRICT 200 | # define _Restrict 201 | # define __restrict__ 202 | #endif 203 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoolMicApp/CoolMicApp-Android/4810d260d8f405ecadb6eef92da701f20d8e3dff/app/src/main/res/drawable-hdpi/home.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoolMicApp/CoolMicApp-Android/4810d260d8f405ecadb6eef92da701f20d8e3dff/app/src/main/res/drawable-hdpi/icon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/mic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoolMicApp/CoolMicApp-Android/4810d260d8f405ecadb6eef92da701f20d8e3dff/app/src/main/res/drawable-hdpi/mic.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-ldpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoolMicApp/CoolMicApp-Android/4810d260d8f405ecadb6eef92da701f20d8e3dff/app/src/main/res/drawable-ldpi/icon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-ldpi/mic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoolMicApp/CoolMicApp-Android/4810d260d8f405ecadb6eef92da701f20d8e3dff/app/src/main/res/drawable-ldpi/mic.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoolMicApp/CoolMicApp-Android/4810d260d8f405ecadb6eef92da701f20d8e3dff/app/src/main/res/drawable-mdpi/icon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/mic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoolMicApp/CoolMicApp-Android/4810d260d8f405ecadb6eef92da701f20d8e3dff/app/src/main/res/drawable-mdpi/mic.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoolMicApp/CoolMicApp-Android/4810d260d8f405ecadb6eef92da701f20d8e3dff/app/src/main/res/drawable-xhdpi/icon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/mic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoolMicApp/CoolMicApp-Android/4810d260d8f405ecadb6eef92da701f20d8e3dff/app/src/main/res/drawable-xhdpi/mic.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/progress_bar_vertical.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 13 | 14 | 15 | 16 | 17 | 18 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /app/src/main/res/layout/metadata_list_entry.xml: -------------------------------------------------------------------------------- 1 | 2 | 23 | 24 | 32 | 33 | 40 | 41 | 48 | 49 |