Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MusicDAO first prototype #34

Merged
merged 29 commits into from
May 13, 2020
Merged

MusicDAO first prototype #34

merged 29 commits into from
May 13, 2020

Conversation

Tim-W
Copy link
Contributor

@Tim-W Tim-W commented May 11, 2020

First pull request for this project: https://github.com/Tribler/tribler/issues/5134

This is a first experimental iteration. Many things should be improved in the future regarding stability of playback, streaming and buffering.

MusicDAO
In short, the MusicDAO is an IPv8 app where users can share and discover tracks on the trustchain. Track streaming, downloading, and seeking interactions are done using JLibtorrent.

A user can publish a Release (which is an album/EP/single/...), after which the app creates a magnet link referring to these audio tracks. Then, the app creates a proposal block for the trustchain which contains some metadata (release date, title, ...) this metadata is submitted by the user with a dialog. When a signed block is discovered (currently are self-signed), the app tries to obtain the file list using JLibtorrent. Each file can be streamed independently on clicking the play button.

Screens


Videos
Video 1: Load Example. https://drive.google.com/open?id=1xbcm2jbuEn5baqISQ6OBNcwAtp3vQiP3 This uses a default magnet link for an album that has a decent amount of peers. The user submits the metadata and the block gets proposed and signed. Then playback.
Video 2: Share Track. https://drive.google.com/open?id=1nXFSWxaXE6hzuKHocksaL3lLNjO_j0lq Note: as a fresh magnet link is generated in this video, there is only 1 peer. For this reason it will be difficult to obtain the metadata of the magnet link (cold start issue, write about this in thesis) so the video stops there.

app-debug.apk2.zip

Tim-W added 17 commits March 31, 2020 00:32
…ow the download progress. Be able to select each track individually, load it to the AudioPlayer which has an android MediaPlayer object and can play it
…ith the rest of the app. Fix multiple bugs, add progressbar
…cally, clear cache on startup, fix switching tracks
� Conflicts:
�	app/build.gradle
�	app/src/main/AndroidManifest.xml
�	app/src/main/java/nl/tudelft/trustchain/app/AppDefinition.kt
�	app/src/main/java/nl/tudelft/trustchain/app/TrustChainApplication.kt
�	settings.gradle
@MattSkala
Copy link
Collaborator

It looks like dependencies are clashing because the project now includes two different versions of jlibtorrent. I think you'll have to make sure the same version is used by TorrentStream-Android and FOC module. I see the latest master of TorrentStream-Android already uses jlibtorrent 1.2.5.0, but it's not released yet, so you could include it as a Git submodule and depend on its implementation.

Then you'll probably have to use Gradle exclude mechanism to exclude duplicate classes from one of the modules: https://docs.gradle.org/current/dsl/org.gradle.api.artifacts.dsl.DependencyHandler.html

@MattSkala
Copy link
Collaborator

Also please change your base branch from dao to master, as dao is merged already.

@synctext
Copy link
Member

from FOC inclusion I think we don't need (unstable) bleeding edge code. Feel free to decide which version of Libtorrent to include or magically use both.

@Tim-W Tim-W changed the base branch from dao to master May 11, 2020 20:14
@Tim-W Tim-W changed the title WIP: MusicDAO MusicDAO first prototype May 12, 2020
@Tim-W Tim-W marked this pull request as ready for review May 12, 2020 12:56
@Tim-W
Copy link
Contributor Author

Tim-W commented May 12, 2020

@synctext @MattSkala Ready for review.
Also I added documentation to README.md and added 2 videos and 3 screenshots. Pls see the text on the pull request.

@MattSkala thanks for the help with Jlibtorrent. fixed it now

@MattSkala
Copy link
Collaborator

Thanks for the pull request.

Can you please add ktlint plugin to your module to enforce consistent code style? It should be enough to add apply plugin: 'org.jlleitschuh.gradle.ktlint' at the top of your build.gradle and configure using ktlint block in the same way as in other modules.

I see there are some compiler warnings. You should see them after running ./gradlew check --no-build-cache. Can you please fix those? I would recommend you to treat compiler warnings as errors by setting android.kotlinOptions.allWarningsAsErrors = true in your build.gradle, in the same way as in other modules. In that way, they will not go unnoticed by the CI check that should now run automatically for every pull request.

@synctext
Copy link
Member

synctext commented May 13, 2020

Installed .apk linked above: app-debug.apk.zip
That crashed a few times. @MattSkala should have error reports from his central Google reporting server now, build 1100.
It played music! Saw fascinating fast updates of bandwidth stats and DHT details from Libtorrent! Does not seem to have "autoplay" when it has 100% of file downloaded. btw I could not understand the exact role of the 2 play buttons: one below progress bar and before the track name (understand this is an early release and lack of time for polish).

@Tim-W
Copy link
Contributor Author

Tim-W commented May 13, 2020

@synctext Thanks for trying it out. Yes there is still quite some work to do to make streaming and error handling, autoplay, seeking more stable. That will take more days with debugging and testing unfortunately.
In terms of the 2 buttons, see the description for these videos in the PR description:

Video 1: Load Example. This uses a default magnet link for an album that has a decent amount of peers. The user submits the metadata and the block gets proposed and signed. Then playback.
Video 2: Share Track. Note: as a fresh magnet link is generated in this video, there is only 1 peer. For this reason it will be difficult to obtain the metadata of the magnet link (cold start issue, write about this in thesis) so the video stops there.

@MattSkala Thanks for the feedback, I'll try to fix the warnings etc

@Tim-W
Copy link
Contributor Author

Tim-W commented May 13, 2020

A test is failing in the build but I don't think it has anything to do with the code from musicdao. @MattSkala any idea what goes wrong here? Can the build be manually restarted?


nl.tudelft.ipv8.messaging.tftp.TFTPEndpointTest > send FAILED
    java.lang.AssertionError at TFTPEndpointTest.kt:28

150 tests completed, 1 failed

> Task :ipv8:test FAILED
> Task :freedomOfComputing:generateReleaseUnitTestStubRFile
> Task :freedomOfComputing:generateDebugUnitTestStubRFile
448 actionable tasks: 448 executed

@MattSkala
Copy link
Collaborator

That was my flaky test that I should fix, it passed after restart.

I was just quickly testing the app and it crashes when you open Music DAO, leave, and open it again:

2020-05-13 14:58:52.722 5307-5307/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: nl.tudelft.trustchain, PID: 5307
    java.lang.RuntimeException: Unable to start activity ComponentInfo{nl.tudelft.trustchain/com.example.musicdao.MusicService}: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3270)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
     Caused by: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
        at android.view.ViewGroup.addViewInner(ViewGroup.java:5150)
        at android.view.ViewGroup.addView(ViewGroup.java:4979)
        at android.view.ViewGroup.addView(ViewGroup.java:4919)
        at com.example.musicdao.MusicService.onCreate(MusicService.kt:56)
        at android.app.Activity.performCreate(Activity.java:7825)
        at android.app.Activity.performCreate(Activity.java:7814)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1306)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3245)

mateicristea88 pushed a commit to mateicristea88/trustchain-superapp that referenced this pull request May 13, 2020
@MattSkala MattSkala merged commit 78e06e5 into Tribler:master May 13, 2020
Tim-W added a commit that referenced this pull request Dec 17, 2020
mateicristea88 added a commit to mateicristea88/trustchain-superapp that referenced this pull request Feb 2, 2021
* Completely remove torrentstream-android and replace it with jlibtorrent dependency. Show track download progress per-track in the list.

* Fix seeking and close mediaplayer when end of track is reached

* Make distinction in progress bar to show when a file is fully done

* Change priority of selected track to 6 so that other tracks are still preloaded in the background

* Format upload/download rate DHT stats

* Fix seeking and close mediaplayer when end of track is reached

* Fix TrackLibrary and gradle issues

* Fix downloadProgress being either 0 or 1

* Change default torrent and change progress bars UI

* Set min sdk version to 22, add wan log, manual puncture test

* Update IPv8

* Lower min SDK to 22

* Update coroutines

* Fix lint errors

* Fix readme formatting

* Update ipv8

* Add contact list, ability to add a new contact

* Add conversation, message sending, acknowledgements

* Complete merge and remove dead code

* Add nearby contact exchange via QR code

* Fix lint

* Update IPv8

* Remove duplicate IPv8 overlay and trustchain init

* Implement contact deletion

* Update Gradle

* Select first piece of interested file as interested piece index

* Test

* Move jlibtorrent to the common module

* Retain public key on screen rotation

* Create fast forward/backward and improve UI

* Make Release a fragment and add it programatically. Fix audioplayer play button

* Rewrite Tracks UI, make it a fragment. Overall UI improvements

* Created new fragment structure, with nav graph and a NavGraphHost. MusicService is now the only Acitivity running Libtorrent, the rest of UI and interactions happen on Fragments.

* Add message attachments

* Re-implement torrentstream-android, implement ExoPlayer, implement release overview and routing, implement persistent local database of releases

* Cleanup ReleaseOverviewFragment

* Integrate TrackLibrary with MusicService to reduce complexity and to remove duplicate instance of TorrentSessionManager

* Multiple stability improvements in Release rendering

* Improve stability of torrentStream interactions with Release

* Show track info of selected track

* Select local tracks/paste magnet link combined in one DialogFragment, using a FAB

* Fix playing from local files, improve seeding and do not play immediately the first track without selecting it

* Convert all fetchMagnet results to a static Torrent file, so that they can be seeded continuously by the ContentSeeder, also after app reboots

* Layout

* Code cleanup

* Revert common module change

* Always orientate portrait mode

* Show file progress as much as possible

* Extract TorrentInfoName from magnet link, preload tracks with correct piece priorities, stability improvements

* Optimize import

* Fix message item layout

* Add post feed

* Add like and reply count

* Fix lint errors

* Bump version name

* Implement most functions of RemoteQueryCommunity and Metadata payloads

* Request Trustchain database content for the music app in the background iteratively, from all Trustchain peers

* Handle Searching for Playlists with simple keyword search

* Iteratively crawl trustchains with delays

* Return to stable version of kotlin-ipv8

* Remove dead code

* Fix lint checks

* Move all TrustChain interactions at MusicDAO to its own community: MusicCommunity

* Fix imports

* Fix indents

* Initial addresses for MusicDAO

* Rewrite how ReleaseCoverFragments are added to fix some bugs

* Cleanup

* Cleanup

* Fix port

* Show loading text in ReleaseOverview if there is no content yet

* Show up/download speeds, upgrade TorrentStreamAndroid dependency and use it as an AAR file

* Make full table row clickable in Track

* Improve layout of Track

* Improved Track and Release table layout

* Toggle button in action bar that shows the connectivity stats

* Show when a track is selected, but still buffering

* Optimize imports

* Reduce the amount of AudioPlayer.retry() calls to improve the user experience during track streaming

* Fix TorrentStream-Android dependency issues for Release APK build

* Fix loadingReleases visibility

* Allow for multi-file torrent creation and sharing

* Loading content text in Release

* Improve layout of TrackPlaying fragment

* Re-add track table dividers

* Fix lint errors

* BitcoinJ integration: Wallet fragment, blockchain syncing and public/private keypair generation

* Add tip artist dialog, and handle wallet public keys to be added to TrustChain

* Sending coins to other artists with Android Toasts as feedback messages

* Fix loading text and other issues with Playlist fragment

* Add a BTC/USDT conversion rate from Binance for the user, and fix several issues with TipArtistDialog

* Show tip button only when useful

* Code cleanup

* Fix crashes and navigation issues with searching, improve loading time of MusicService by moving work off main thread

* Remove unused import

* Initial code for fully distributed Keyword Search

* Implement WalletService with RegTest, using a static IP pointing to a DigitalOcean droplet, so we can test BTC transactions

* Fix bug with searching and introduce central config for crypto currency wallet

* Remove INITIAL_ADDRESSES from MusicCommunity because if it is offline the device will send infinite messages

* Fix stability bugs and make WalletService a Singleton

* Fix Toast messages in money transfers

* Change TTL for remote keyword search according to 'good' parameters from scientific experiments

* Add comments and improve layout

* Fix a certain issue with ContentSeeder sessionmanager clashing with TorrentStream sessionmanager

* Organize code into packages

* Move AudioPlayer to top-level

* Move AudioPlayer to own package

* Repackage musicdao

* Upgrade JLibtorrent and add some tests

* Add more tests

* Add many tests and refactor some code

* Optimize imports

* Fix ReleaseFactoryTest, code cleanup and upgrade outdated dep

* Fix issues with ContentSeederTest

* Create bitcoin faucet interactions and change USD conversion to Coins

* Hide Release creation button

* Fix input of Release block and fix Tribler#3

* Fix Tribler#4, add preload mechanics, fix Tribler#4 downloading/buffering progress bars of local tracks

* Only download in ContentSeeder after full completion of Release

* End-to-end functionality for seeding content, sending SwarmHealth messages and sorting playlist overview based on swarm health. Fix Tribler#6

* Push app-debug.apk

* Start WalletService at MusicDAO startup immediately, broadcast blocks to random peers, fixes Tribler#9, Tribler#11

* Fix PlaylistsOverviewFragment causing crashes

* Fix Tribler#15, fix Tribler#10

* Fix various issues with peer gossiping, fix Tribler#16, fix Tribler#11, fix various issues with TorrentStream SessionManager and ContentSeeder SessionManager clashing, fix startup crashes

* Fix Tribler#21

* Fix Tribler#22

* Fix Tribler#22

* Fix all tests and upgrade ipv8 package to 80% line coverage, fix Tribler#24

* Improve IPv8 tests

* Cleanup

* Improve test coverage for ContentSeeder

* Cleanup

* Add libs for CI

* Use Ubuntu build instead of MacOS

* Remove unneeded libs

* New try for CI

* Add JNI libs?

* Revert "Add JNI libs?"
Revert kotlin-ipv8 going in wrong state
This reverts commit 946e8fc

* Fix PostRepository in PeerChat

* Use gradle bash check instead of eskatos gradle command action

* Add libtorrent android libs

* Add more native android files

* Re-add linux jlibtorrent so files

* Add native jlibtorrent linux x86_64 SO file to musicdao/src/main/jniLibs

* Add native jlibtorrent linux x86_64 SO file to musicdao/src/main/jniLibs

* Remove jniLibs from Common

* Fix submodule

* Communicate 3 random blocks to peers every 3 seconds, fix Tribler#18

* Use Home button as back pressed button, fix Tribler#25

* Add cover art and improve layout

* Add cover art and improve layout

* Extract audio metadata using MP3 library

* Fix build

* Fix build

* Fix build

* Fix bug with Release Fragment metadata

* Fix bug with playing current track title

* Use file names instead of MP3 file tags for now

* Use file names instead of MP3 file tags for now

* Fix bug in ReleaseFragment metadata parsing

* Fix bug in ReleaseFragment metadata parsing

* Make stream errors silent errors

* Completely replace TorrentStream-Android by JLibtorrent, new priority system for torrent pieces, fix Tribler#35, fix Tribler#34

* Fix build

* Add DataFeeder

* Move musicdao-datafeeder to its own project

* Do not allow just 1 torrent, also use torrent.added files

* Fix old 2hr+ swarm health messages bug in DataFeeder; try to use custom bootstrap DHT node

* Fix Tribler#36, fix Tribler#33

* Update DataFeeder

* Fix isTorrentCompleted bug

* Fix Tribler#40, fix Tribler#38, fix Tribler#37

* Fix Tribler#41

* Fix test

* Fix build

* Fix build

* Fix build

* Prepare release 0.3

* Add Publish/nopublish option to datafeeder

* Add Publish/nopublish option to datafeeder

* Add Publish/nopublish option to datafeeder

* Add MusicGossipingService: gossiping data now happens continuously in the background, also when app is out of focus

* Bug fix for DataFeeder

* Fix a bug with releaseRefreshCount

* Fix torrent trackers and set high priority on last pieces of selected audio file

* Reduce swarm health battery usage

Co-authored-by: Matouš Skála <skala.matous@gmail.com>
Co-authored-by: Tim W <wissel.tim@gmail.com>
Co-authored-by: Tim Wissel <t.i.wissel@student.tudelft.nl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants