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

Add Mud Sound Protocol (MSP) Support #3132

Merged
merged 84 commits into from
Dec 7, 2019
Merged

Add Mud Sound Protocol (MSP) Support #3132

merged 84 commits into from
Dec 7, 2019

Conversation

mpconley
Copy link
Contributor

@mpconley mpconley commented Sep 29, 2019

Brief overview of PR changes/additions

Please see the wiki for the best description of what is delivered:

Mud Sound Protocol (MSP) support leveraging QMediaPlayer and QMediaPlayerList for MSP for Lua, MSP via GMCP (Client.Media) and across TELOPT 90.

This MSP implementation is nearly identical to the specification found at the ZMud site.

Mudlet will parse the triggers, download a corresponding sound, store it in the profile for the game in a media folder and categorized subfolders, then play it. This has the capability to use wildcards/randomize, repeat sounds, and continue music as mentioned in the specification.

Motivation for adding to Mudlet

I am rewriting the world for StickMUD and plan to enhance the experience with more sound, such as changing music files per area / terrain / map as an example.

In a similar way that servers could push UIs and maps, this PR will push sounds and let the server guide how those sounds are orchestrated.

Other info (issues closed, discussion etc)

  • I did not touch stopSounds() or playSound() from mudlet.cpp. Nothing will change for anyone using sound triggers today.
  • There are two new toggles in the Settings page to enable/disable Client.Media and MSP.
  • I chose to store the sounds in a folder call media.

Please test Client.Media (GMCP) and MSP by logging into StickMUD at telnet://stickmud.com:7680 with a new character, going east, 2 up and trying out this test plan:

pull lever A with gmcp
pull lever B with gmcp
... through ...
pull lever O with gmcp

delete your media folder under the StickMUD profile

pull lever A with lua
pull lever B with lua
... through ...
pull lever O with lua

delete your media folder under the StickMUD profile

pull lever A with telopt
pull lever B with telopt
... through ...
pull lever O with telopt

@mpconley mpconley requested a review from a team as a code owner September 29, 2019 04:45
@mpconley mpconley requested a review from a team September 29, 2019 04:45
@add-deployment-links
Copy link

add-deployment-links bot commented Sep 29, 2019

Hey there! Thanks for helping Mudlet improve. 🌟

Test versions

You can directly test the changes here:

No need to install anything - just unzip and run.
Let us know if it works well, and if it doesn't, please give details.

@demonnic
Copy link
Member

I like the sound of this.
Ok, now the pun's out of the way, do you have an easy way to test the functionality?

@mpconley
Copy link
Contributor Author

Coming soon! I will make something nice and simple to test and present the various scenarios.

src/Host.cpp Show resolved Hide resolved
src/XMLimport.cpp Show resolved Hide resolved
src/ctelnet.cpp Show resolved Hide resolved
src/ctelnet.cpp Outdated Show resolved Hide resolved
src/dlgProfilePreferences.cpp Show resolved Hide resolved
src/mudlet.cpp Outdated Show resolved Hide resolved
src/mudlet.cpp Outdated Show resolved Hide resolved
src/mudlet.cpp Outdated Show resolved Hide resolved
src/mudlet.cpp Outdated Show resolved Hide resolved
src/mudlet.cpp Outdated Show resolved Hide resolved
@mpconley
Copy link
Contributor Author

mpconley commented Oct 9, 2019

I created some tests and have a couple things to resolve.

@vadi2
Copy link
Member

vadi2 commented Oct 9, 2019

Where at?

@vadi2 vadi2 mentioned this pull request Oct 16, 2019
@mpconley
Copy link
Contributor Author

This pull request is ready for review after reading the specification here: https://www.zuggsoft.com/zmud/msp.htm. Use the PR version of Mudlet, login to StickMUD, create a character, move two rooms to escape the newbie area, then go up into the tree. Use "pull lever A", "pull lever B" through "pull lever I" to do the testing. The only trouble this is having on Mac at least is that the first time the sound is downloaded it makes no sound, until you pull the lever again. Does anyone have ideas on how we could add some delay in the downloadMSPFile to resolve this?

@mpconley
Copy link
Contributor Author

mpconley commented Nov 30, 2019

Please review the wiki links:

Please test Client.Media (GMCP) and MSP by logging into StickMUD at telnet://stickmud.com:7680 with a new character, going east, 2 up and trying out this test plan:

pull lever A with gmcp
pull lever B with gmcp
... through ...
pull lever O with gmcp

delete your media folder under the StickMUD profile

pull lever A with lua
pull lever B with lua
... through ...
pull lever O with lua

delete your media folder under the StickMUD profile

pull lever A with telopt
pull lever B with telopt
... through ...
pull lever O with telopt

@demonnic
Copy link
Member

demonnic commented Dec 2, 2019

I am not hearing any sound, using the testing version for 211f7d2 commit. lever B and C with telopt download cow.wav but I do not hear it. lever D crashes Mudlet with a segfault. Ubuntu 18.04.3 LTS

(gdb) backtrace
#0  0x00007ffff7f034b4 in QMediaPlayer::setMedia(QMediaContent const&, QIODevice*) () from /tmp/.mount_InsighFyodKJ/lib/libQt5Multimedia.so.5
#1  0x00007ffff7f036e2 in QMediaPlayer::setPlaylist(QMediaPlaylist*) () from /tmp/.mount_InsighFyodKJ/lib/libQt5Multimedia.so.5
#2  0x00000000008397ad in TMedia::play(TMediaData&) ()
#3  0x000000000083ad35 in TMedia::playMedia(TMediaData&) ()
#4  0x00000000005c2a01 in cTelnet::setMSPVariables(QByteArray const&) ()
#5  0x00000000005c96ec in cTelnet::processTelnetCommand(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) ()
#6  0x00000000005cc51a in cTelnet::processSocketData(char*, int) ()
#7  0x00000000005cca6e in cTelnet::handle_socket_signal_readyRead() ()
#8  0x00007ffff58e1996 in QMetaObject::activate(QObject*, int, int, void**) () from /tmp/.mount_InsighFyodKJ/lib/libQt5Core.so.5
#9  0x00007ffff5dc4d41 in ?? () from /tmp/.mount_InsighFyodKJ/lib/libQt5Network.so.5
#10 0x00007ffff58e1669 in QMetaObject::activate(QObject*, int, int, void**) () from /tmp/.mount_InsighFyodKJ/lib/libQt5Core.so.5
#11 0x00007ffff5d8dff3 in ?? () from /tmp/.mount_InsighFyodKJ/lib/libQt5Network.so.5
#12 0x00007ffff5d8e0ac in ?? () from /tmp/.mount_InsighFyodKJ/lib/libQt5Network.so.5
#13 0x00007ffff5da1691 in ?? () from /tmp/.mount_InsighFyodKJ/lib/libQt5Network.so.5
#14 0x00007ffff65d059c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /tmp/.mount_InsighFyodKJ/lib/libQt5Widgets.so.5
#15 0x00007ffff65d7c20 in QApplication::notify(QObject*, QEvent*) () from /tmp/.mount_InsighFyodKJ/lib/libQt5Widgets.so.5
#16 0x00007ffff58b3d28 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /tmp/.mount_InsighFyodKJ/lib/libQt5Core.so.5
#17 0x00007ffff590ecf8 in ?? () from /tmp/.mount_InsighFyodKJ/lib/libQt5Core.so.5
#18 0x00007ffff6b31417 in g_main_context_dispatch () from /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#19 0x00007ffff6b31650 in ?? () from /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#20 0x00007ffff6b316dc in g_main_context_iteration () from /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#21 0x00007ffff590e05f in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /tmp/.mount_InsighFyodKJ/lib/libQt5Core.so.5
#22 0x00007ffff58b20ba in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /tmp/.mount_InsighFyodKJ/lib/libQt5Core.so.5
#23 0x00007ffff58bb174 in QCoreApplication::exec() () from /tmp/.mount_InsighFyodKJ/lib/libQt5Core.so.5
#24 0x000000000045a6d1 in main ()

@mpconley
Copy link
Contributor Author

mpconley commented Dec 3, 2019

I found a Windows 10 machine to test on an also had issues playing the cow, lightning and death sounds. The city and water sounds played fine. This could be due to differences in how memory is managed on the other OS's - so I am going to try to harden the code with some more checks. If I could get Windows working 100% perhaps the odds will be in my favor that Linux will be healthy again too.

@demonnic
Copy link
Member

demonnic commented Dec 4, 2019

tested the latest version, it downloads the files as it should for all three options, but I'm still not hearing any sounds playing with any of them. no longer crashes.

@mpconley
Copy link
Contributor Author

mpconley commented Dec 4, 2019

I removed a lot of unnecessary pointers to make direct references. The only pointers needed were for external resources like QMediaPlayer. I am not sure if that will help this play on more OS yet or not.

There is still one known bug where something with a lower priority than what is already playing is being allowed to play (which should not because it is a lower priority). There is a List of TMediaPlayer, which is a wrapper class holding TMediaData and the QMediaPlayer. It looks like the references are getting wiped out after something plays, so it is not possible to compare things right. More troubleshooting needed.

@mpconley
Copy link
Contributor Author

mpconley commented Dec 5, 2019

I resolved the issue with priority and now everything tests out with MSP on Mac. The issue was that I was storing TMediaPlayer objects in the (session) List that were low priority and were never played. By moving that code back to not save the playing TMediaPlayer until the time it was used to start playing something the problem was resolved and now GMCP, lua and telopt MSP are working fine on Mac. I am going to try a Windows run as soon as the build is ready.

@mpconley
Copy link
Contributor Author

mpconley commented Dec 5, 2019

Client.Media, lua and telopt MSP are working now as intended on Mac and Windows! Linux still needs some help, but I believe that is a platform problem and not this PR.

@mpconley
Copy link
Contributor Author

mpconley commented Dec 5, 2019

Latest (hopefully last) changes are good on MacOS and Windows

@demonnic
Copy link
Member

demonnic commented Dec 7, 2019

I have checked this on Windows 10 as well and it all functions as described.

Copy link
Member

@vadi2 vadi2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't finished review and there's a few coding improvements I'd like to see, but it works and has been tested, and that is enough for the experimental preview in Mudlet!

@@ -6678,6 +6678,30 @@ int TLuaInterpreter::sendATCP(lua_State* L)
return 1;
}

// Documentation: https://wiki.mudlet.org/w/Manual:Lua_Functions#receiveMSP
int TLuaInterpreter::receiveMSP(lua_State* L)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would handleMSP be better name for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is sendGMCP, so I made receiveMSP - if we have a handleXXX example elsewhere, then for consistency perhaps yes.

src/TMedia.cpp Outdated Show resolved Hide resolved
src/ctelnet.cpp Show resolved Hide resolved
src/ctelnet.cpp Show resolved Hide resolved
return fileUrl;
}

bool TMedia::processUrl(TMediaData& mediaData)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function name is pretty generic and on my first read through, I had no clue what it did except modify state of the host (and for some reason this is done on every MSP call) - confusing :O

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This handling could be reconsidered after the dust settles. A couple other functions have Url in the name, and most are bound inside processUrl, so there is a good bit going on within its scope. For the MSP protocol, every call, when combined with "Off" as a fileName, could need some handling. It's not the end of the world, but what we'll see here for games that advertise MSP as a TELOPT, and the player has not downloaded the files manually from their game that only supports zip files, there could be some output in the error log about not being to download a file from www.<thegame.com>/media. Like was done with map downloads, we're suggesting a default Url (undocumented) where one was not set, to try and download the file from.

src/Host.h Show resolved Hide resolved
@vadi2 vadi2 merged commit a2248a3 into Mudlet:development Dec 7, 2019
dicene pushed a commit to dicene/Mudlet that referenced this pull request Feb 19, 2020
* Add Mud Sound Protocol (MSP) Support

* Adjust URL to http, remove extra return

* Resolving code compliance checks

* Resolving code compliance checks

* Resolving code compliance checks

* Resolving code compliance checks

* Resolving code compliance checks

* Wildcards, CLAZY, slashes, break, nullptr and paths

* Resolved directory creation issue, downloads working

* Enhanced MSP with QAudio::CustomRole

* Backed out QAudio, Possible final revisions

* Updated Protocol Preferences in Settings

* Code compliance

* Code compliance

* Code compliance

* Trigger Windows & Linux builds

* Updated download methodology

* Code compliance

* Code compliance

* Resolving conflict

* Code compliance

* Introducing TMedia

* Code Compliance

* Code Compliance

* Sets .wav and .mid correctly

* Typo resolved

* Security checks

* GMCP Support

* Code compliance

* Added lua receiveMSP()

* Code compliance

* Resolving conflict

* Updated CMakeLists.txt

* Updated CMakeLists.txt

* Updated CMakeLists.txt

* Code compliance

* Registered receiveMSP

* Code compliance

* Undo missing GNU

* Refined code

* Enhance GMCP Support

* Enhance GMCP Support

* Enhance GMCP Support

* Code compliance

* Added Suppression

* Code compliance

* Enhanced suppression

* Implemented Priority

* Added Validation

* Code compliance

* Resolved bug

* Introducing GMCP.Media

* Code compliance

* Code compliance

* GMCP volume bug resolved

* mediaLocation by protocol

* List fix

* MediaKey constraints

* matchMediaKeyAndStopMediaVariants

* Code dedupe

* Code dedupe

* Resolving priority bug

* Bug fixes

* bool mediaContinue

* Trialing Video

* Untrialed video

* Untrialed video

* Removed target (no video)

* Minor update

* Documentation links

* Code compliance

* Wiki reference update

* Resolve bug in XMLImport.cpp

* Fix unintialised TMediaPlayer

* Removed pointers

* Fixed priority

* Removed folder making from tag

* Changed sub-directory generation

* Adjust label names in preferences
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.

5 participants