├── sample ├── .gitignore ├── src │ └── main │ │ ├── res │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ ├── values │ │ │ ├── strings.xml │ │ │ ├── dimens.xml │ │ │ └── styles.xml │ │ ├── menu │ │ │ └── menu_main.xml │ │ ├── values-w820dp │ │ │ └── dimens.xml │ │ └── layout │ │ │ └── activity_main.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── eu │ │ └── sv244 │ │ └── torrentstreamer │ │ └── sample │ │ └── MainActivity.java ├── proguard-rules.pro └── build.gradle ├── library ├── .gitignore ├── src │ └── main │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── com │ │ └── github │ │ └── sv244 │ │ └── torrentstream │ │ ├── exceptions │ │ ├── NotInitializedException.java │ │ ├── TorrentInfoException.java │ │ └── DirectoryCreationException.java │ │ ├── StreamStatus.java │ │ ├── listeners │ │ ├── TorrentListener.java │ │ ├── TorrentAddedAlertListener.java │ │ └── DHTStatsAlertListener.java │ │ ├── utils │ │ ├── ThreadUtils.java │ │ └── FileUtils.java │ │ ├── TorrentOptions.java │ │ ├── Torrent.java │ │ └── TorrentStream.java ├── proguard-rules.pro └── build.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── settings.gradle ├── gradle.properties ├── README.md ├── gradlew.bat └── gradlew /sample/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /library/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /library/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndroidTorrent/TorrentStream-Android/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndroidTorrent/TorrentStream-Android/HEAD/sample/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndroidTorrent/TorrentStream-Android/HEAD/sample/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndroidTorrent/TorrentStream-Android/HEAD/sample/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AndroidTorrent/TorrentStream-Android/HEAD/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sat Aug 08 21:50:44 CEST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | .idea/ 15 | *.iml 16 | 17 | # Gradle files 18 | .gradle/ 19 | build/ 20 | 21 | # Local configuration file (sdk path, etc) 22 | local.properties 23 | 24 | # Proguard folder generated by Eclipse 25 | proguard/ 26 | 27 | # Log Files 28 | *.log 29 | 30 | # Keystore 31 | *.jks -------------------------------------------------------------------------------- /sample/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/Sebastiaan/Development/Android/SDK/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /library/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/Sebastiaan/Development/Android/SDK/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * * This file is part of TorrentStreamer-Android. 4 | * * 5 | * * TorrentStreamer-Android is free software: you can redistribute it and/or modify 6 | * * it under the terms of the GNU General Public License as published by 7 | * * the Free Software Foundation, either version 3 of the License, or 8 | * * (at your option) any later version. 9 | * * 10 | * * TorrentStreamer-Android is distributed in the hope that it will be useful, 11 | * * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * * GNU General Public License for more details. 14 | * * 15 | * * You should have received a copy of the GNU General Public License 16 | * * along with TorrentStreamer-Android. If not, see . 17 | * 18 | */ 19 | 20 | include ':library', ':sample' 21 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | TorrentStream-Android 2 | ====== 3 | 4 | A torrent streamer library for Android based on [jlibtorrent](https://github.com/frostwire/frostwire-jlibtorrent). 5 | 6 | Used in [Popcorn Time for Android](https://github.com/popcorn-official/popcorn-android) and definitely not done yet. 7 | 8 | Using 9 | -------- 10 | 11 | See the sample. 12 | 13 | Available on Maven Central as 'com.github.sv244:torrentstream-android' 14 | 15 | License 16 | -------- 17 | 18 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 19 | 20 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 21 | 22 | You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. 23 | 24 | -------------------------------------------------------------------------------- /sample/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 19 | 20 | 21 | TorrentStreamer Sample 22 | 23 | Hello world! 24 | Settings 25 | 26 | -------------------------------------------------------------------------------- /sample/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 19 | 20 | 21 | 22 | 16dp 23 | 16dp 24 | 25 | -------------------------------------------------------------------------------- /sample/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 19 | 20 | 21 | 22 | 23 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /library/src/main/java/com/github/sv244/torrentstream/exceptions/NotInitializedException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of TorrentStreamer-Android. 3 | * 4 | * TorrentStreamer-Android is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * TorrentStreamer-Android 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 | * You should have received a copy of the GNU General Public License 15 | * along with TorrentStreamer-Android. If not, see . 16 | */ 17 | 18 | package com.github.sv244.torrentstream.exceptions; 19 | 20 | public class NotInitializedException extends Exception { 21 | 22 | public NotInitializedException() { 23 | super("TorrentStreamer is not initialized. Call init() first before getting an instance."); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /library/src/main/java/com/github/sv244/torrentstream/exceptions/TorrentInfoException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * * This file is part of TorrentStreamer-Android. 4 | * * 5 | * * TorrentStreamer-Android is free software: you can redistribute it and/or modify 6 | * * it under the terms of the GNU General Public License as published by 7 | * * the Free Software Foundation, either version 3 of the License, or 8 | * * (at your option) any later version. 9 | * * 10 | * * TorrentStreamer-Android is distributed in the hope that it will be useful, 11 | * * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * * GNU General Public License for more details. 14 | * * 15 | * * You should have received a copy of the GNU General Public License 16 | * * along with TorrentStreamer-Android. If not, see . 17 | * 18 | */ 19 | 20 | package com.github.sv244.torrentstream.exceptions; 21 | 22 | public class TorrentInfoException extends Exception { 23 | 24 | public TorrentInfoException() { 25 | super("No torrent info could be found"); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /library/src/main/java/com/github/sv244/torrentstream/exceptions/DirectoryCreationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * * This file is part of TorrentStreamer-Android. 4 | * * 5 | * * TorrentStreamer-Android is free software: you can redistribute it and/or modify 6 | * * it under the terms of the GNU General Public License as published by 7 | * * the Free Software Foundation, either version 3 of the License, or 8 | * * (at your option) any later version. 9 | * * 10 | * * TorrentStreamer-Android is distributed in the hope that it will be useful, 11 | * * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * * GNU General Public License for more details. 14 | * * 15 | * * You should have received a copy of the GNU General Public License 16 | * * along with TorrentStreamer-Android. If not, see . 17 | * 18 | */ 19 | 20 | package com.github.sv244.torrentstream.exceptions; 21 | 22 | public class DirectoryCreationException extends Exception { 23 | 24 | public DirectoryCreationException() { 25 | super("Could not create save directory"); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /sample/src/main/res/menu/menu_main.xml: -------------------------------------------------------------------------------- 1 | 19 | 20 | 23 | 25 | 26 | -------------------------------------------------------------------------------- /sample/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 19 | 20 | 21 | 24 | 64dp 25 | 26 | -------------------------------------------------------------------------------- /library/src/main/java/com/github/sv244/torrentstream/StreamStatus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of TorrentStreamer-Android. 3 | * 4 | * TorrentStreamer-Android is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * TorrentStreamer-Android 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 | * You should have received a copy of the GNU General Public License 15 | * along with TorrentStreamer-Android. If not, see . 16 | */ 17 | 18 | package com.github.sv244.torrentstream; 19 | 20 | public class StreamStatus { 21 | public final float progress; 22 | public final int bufferProgress; 23 | public final int seeds; 24 | public final float downloadSpeed; 25 | 26 | protected StreamStatus(float progress, int bufferProgress, int seeds, int downloadSpeed) { 27 | this.progress = progress; 28 | this.bufferProgress = bufferProgress; 29 | this.seeds = seeds; 30 | this.downloadSpeed = downloadSpeed; 31 | } 32 | } -------------------------------------------------------------------------------- /library/src/main/java/com/github/sv244/torrentstream/listeners/TorrentListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of TorrentStreamer-Android. 3 | * 4 | * TorrentStreamer-Android is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * TorrentStreamer-Android 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 | * You should have received a copy of the GNU General Public License 15 | * along with TorrentStreamer-Android. If not, see . 16 | */ 17 | 18 | package com.github.sv244.torrentstream.listeners; 19 | 20 | import com.github.sv244.torrentstream.StreamStatus; 21 | import com.github.sv244.torrentstream.Torrent; 22 | 23 | public interface TorrentListener { 24 | void onStreamPrepared(Torrent torrent); 25 | 26 | void onStreamStarted(Torrent torrent); 27 | 28 | void onStreamError(Torrent torrent, Exception e); 29 | 30 | void onStreamReady(Torrent torrent); 31 | 32 | void onStreamProgress(Torrent torrent, StreamStatus status); 33 | 34 | void onStreamStopped(); 35 | } 36 | -------------------------------------------------------------------------------- /library/src/main/java/com/github/sv244/torrentstream/utils/ThreadUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * * This file is part of TorrentStreamer-Android. 4 | * * 5 | * * TorrentStreamer-Android is free software: you can redistribute it and/or modify 6 | * * it under the terms of the GNU General Public License as published by 7 | * * the Free Software Foundation, either version 3 of the License, or 8 | * * (at your option) any later version. 9 | * * 10 | * * TorrentStreamer-Android is distributed in the hope that it will be useful, 11 | * * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * * GNU General Public License for more details. 14 | * * 15 | * * You should have received a copy of the GNU General Public License 16 | * * along with TorrentStreamer-Android. If not, see . 17 | * 18 | */ 19 | 20 | package com.github.sv244.torrentstream.utils; 21 | 22 | import android.os.Handler; 23 | import android.os.Looper; 24 | 25 | public class ThreadUtils { 26 | 27 | /** 28 | * Execute the given {@link Runnable} on the ui thread. 29 | * 30 | * @param runnable The runnable to execute. 31 | */ 32 | public static void runOnUiThread(Runnable runnable) { 33 | Thread uiThread = Looper.getMainLooper().getThread(); 34 | if (Thread.currentThread() != uiThread) new Handler(Looper.getMainLooper()).post(runnable); 35 | else runnable.run(); 36 | } 37 | } -------------------------------------------------------------------------------- /library/src/main/java/com/github/sv244/torrentstream/utils/FileUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * * This file is part of TorrentStreamer-Android. 4 | * * 5 | * * TorrentStreamer-Android is free software: you can redistribute it and/or modify 6 | * * it under the terms of the GNU General Public License as published by 7 | * * the Free Software Foundation, either version 3 of the License, or 8 | * * (at your option) any later version. 9 | * * 10 | * * TorrentStreamer-Android is distributed in the hope that it will be useful, 11 | * * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * * GNU General Public License for more details. 14 | * * 15 | * * You should have received a copy of the GNU General Public License 16 | * * along with TorrentStreamer-Android. If not, see . 17 | * 18 | */ 19 | 20 | package com.github.sv244.torrentstream.utils; 21 | 22 | import java.io.File; 23 | 24 | public class FileUtils { 25 | 26 | /** 27 | * Delete every item below the File location 28 | * 29 | * @param file Location 30 | */ 31 | public static boolean recursiveDelete(File file) { 32 | if (file.isDirectory()) { 33 | String[] children = file.list(); 34 | if (children == null) return false; 35 | for (String child : children) { 36 | recursiveDelete(new File(file, child)); 37 | } 38 | } 39 | 40 | return file.delete(); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /sample/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * * This file is part of TorrentStreamer-Android. 4 | * * 5 | * * TorrentStreamer-Android is free software: you can redistribute it and/or modify 6 | * * it under the terms of the GNU General Public License as published by 7 | * * the Free Software Foundation, either version 3 of the License, or 8 | * * (at your option) any later version. 9 | * * 10 | * * TorrentStreamer-Android is distributed in the hope that it will be useful, 11 | * * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * * GNU General Public License for more details. 14 | * * 15 | * * You should have received a copy of the GNU General Public License 16 | * * along with TorrentStreamer-Android. If not, see . 17 | * 18 | */ 19 | 20 | apply plugin: 'com.android.application' 21 | 22 | android { 23 | compileSdkVersion 23 24 | buildToolsVersion "23.0.0" 25 | 26 | defaultConfig { 27 | applicationId "com.github.torrentstreamer.sample" 28 | minSdkVersion 15 29 | targetSdkVersion 23 30 | versionCode 1 31 | versionName "1.0" 32 | } 33 | buildTypes { 34 | release { 35 | minifyEnabled false 36 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 37 | } 38 | } 39 | lintOptions { 40 | abortOnError false 41 | } 42 | } 43 | 44 | dependencies { 45 | compile fileTree(dir: 'libs', include: ['*.jar']) 46 | compile 'com.android.support:appcompat-v7:23.0.1' 47 | compile project(':library') 48 | } 49 | -------------------------------------------------------------------------------- /library/src/main/java/com/github/sv244/torrentstream/listeners/TorrentAddedAlertListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * * This file is part of TorrentStreamer-Android. 4 | * * 5 | * * TorrentStreamer-Android is free software: you can redistribute it and/or modify 6 | * * it under the terms of the GNU General Public License as published by 7 | * * the Free Software Foundation, either version 3 of the License, or 8 | * * (at your option) any later version. 9 | * * 10 | * * TorrentStreamer-Android is distributed in the hope that it will be useful, 11 | * * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * * GNU General Public License for more details. 14 | * * 15 | * * You should have received a copy of the GNU General Public License 16 | * * along with TorrentStreamer-Android. If not, see . 17 | * 18 | */ 19 | 20 | package com.github.sv244.torrentstream.listeners; 21 | 22 | import com.frostwire.jlibtorrent.AlertListener; 23 | import com.frostwire.jlibtorrent.alerts.Alert; 24 | import com.frostwire.jlibtorrent.alerts.AlertType; 25 | import com.frostwire.jlibtorrent.alerts.TorrentAddedAlert; 26 | 27 | public abstract class TorrentAddedAlertListener implements AlertListener { 28 | @Override 29 | public int[] types() { 30 | return new int[] { AlertType.TORRENT_ADDED.getSwig() }; 31 | } 32 | 33 | @Override 34 | public void alert(Alert alert) { 35 | switch (alert.getType()) { 36 | case TORRENT_ADDED: 37 | torrentAdded((TorrentAddedAlert) alert); 38 | break; 39 | } 40 | } 41 | 42 | public abstract void torrentAdded(TorrentAddedAlert alert); 43 | } 44 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 19 | 20 | 27 | 28 |