Module: sems Branch: master Commit: 957ad4d7fb5646f72b30e1603bf347bf9f90ae68 URL: https://github.com/sems-server/sems/commit/957ad4d7fb5646f72b30e1603bf347bf9f90ae68
Author: Stefan Sayer <stefan.sa...@googlemail.com> Committer: Stefan Sayer <stefan.sa...@googlemail.com> Date: 2015-06-09T00:12:13+02:00 dsm:mod_conference: conference.playMixInList action uses a playlist to mix in files into a list --- Modified: apps/dsm/mods/mod_conference/ModConference.cpp Modified: apps/dsm/mods/mod_conference/ModConference.h Modified: doc/dsm/mods/Readme.mod_conference.txt --- Diff: https://github.com/sems-server/sems/commit/957ad4d7fb5646f72b30e1603bf347bf9f90ae68.diff Patch: https://github.com/sems-server/sems/commit/957ad4d7fb5646f72b30e1603bf347bf9f90ae68.patch --- diff --git a/apps/dsm/mods/mod_conference/ModConference.cpp b/apps/dsm/mods/mod_conference/ModConference.cpp index 07a3e39..6137989 100644 --- a/apps/dsm/mods/mod_conference/ModConference.cpp +++ b/apps/dsm/mods/mod_conference/ModConference.cpp @@ -49,7 +49,8 @@ MOD_ACTIONEXPORT_BEGIN(MOD_CLS_NAME) { DEF_CMD("conference.teeleave", ConfTeeLeaveAction); DEF_CMD("conference.setupMixIn", ConfSetupMixInAction); - DEF_CMD("conference.playMixIn", ConfPlayMixInAction); + DEF_CMD("conference.playMixIn", ConfPlayMixInAction); + DEF_CMD("conference.playMixInList", ConfPlayMixInListAction); } MOD_ACTIONEXPORT_END; @@ -175,7 +176,8 @@ EXEC_ACTION_START(ConfJoinAction) { sc_sess->SET_ERRNO(DSM_ERRNO_UNKNOWN_ARG); } } EXEC_ACTION_END; - + +// get conference channel or other object (mixer etc) template<class T> static T* getDSMConfChannel(DSMSession* sc_sess, const char* key_name) { if (sc_sess->avar.find(key_name) == sc_sess->avar.end()) { @@ -399,3 +401,52 @@ EXEC_ACTION_START(ConfPlayMixInAction) { m->mixin(af); } EXEC_ACTION_END; + + +EXEC_ACTION_START(ConfPlayMixInListAction) { + string filename = resolveVars(arg, sess, sc_sess, event_params); + + bool has_playlist = true; + // get playlist + DSMDisposableT<AmPlaylist >* l_obj = + getDSMConfChannel<DSMDisposableT<AmPlaylist> >(sc_sess, CONF_AKEY_MIXLIST); + if (NULL == l_obj) { + // playlist newly setup + AmPlaylist* pl = new AmPlaylist(NULL); // no event receiver - no 'clear' event + l_obj = new DSMDisposableT<AmPlaylist >(pl); + AmArg c_arg; + c_arg.setBorrowedPointer(l_obj); + sc_sess->avar[CONF_AKEY_MIXLIST] = c_arg; + + // add to garbage collector + sc_sess->transferOwnership(l_obj); + has_playlist = false; + } + AmPlaylist* l = l_obj->get(); + + + DSMDisposableAudioFile* af = new DSMDisposableAudioFile(); + if(af->open(filename,AmAudioFile::Read)) { + ERROR("audio file '%s' could not be opened for reading.\n", + filename.c_str()); + delete af; + + throw DSMException("file", "path", filename); + } + sc_sess->transferOwnership(af); + + DBG("adding file '%s' to mixin playlist\n", filename.c_str()); + l->addToPlaylist(new AmPlaylistItem(af, NULL)); + + if (!has_playlist) { + // get mixin mixer + DSMDisposableT<AmAudioMixIn >* m_obj = + getDSMConfChannel<DSMDisposableT<AmAudioMixIn > >(sc_sess, CONF_AKEY_MIXER); + if (NULL == m_obj) { + throw DSMException("conference", "cause", "mixer not setup!\n"); + } + AmAudioMixIn* m = m_obj->get(); + // play from list + m->mixin(l); + } +} EXEC_ACTION_END; diff --git a/apps/dsm/mods/mod_conference/ModConference.h b/apps/dsm/mods/mod_conference/ModConference.h index c1e29b2..52d59fd 100644 --- a/apps/dsm/mods/mod_conference/ModConference.h +++ b/apps/dsm/mods/mod_conference/ModConference.h @@ -39,6 +39,7 @@ DECLARE_MODULE(MOD_CLS_NAME); #define CONF_AKEY_CHANNEL "conf.chan" #define CONF_AKEY_DEF_TEECHANNEL "conf.teechan" #define CONF_AKEY_MIXER "conf.mixer" +#define CONF_AKEY_MIXLIST "conf.mixlist" /** holds a conference channel */ class DSMConfChannel @@ -94,5 +95,6 @@ DEF_ACTION_1P(ConfTeeLeaveAction); DEF_ACTION_2P(ConfSetupMixInAction); DEF_ACTION_1P(ConfPlayMixInAction); +DEF_ACTION_1P(ConfPlayMixInListAction); #endif diff --git a/doc/dsm/mods/Readme.mod_conference.txt b/doc/dsm/mods/Readme.mod_conference.txt index 1df3b3e..71189df 100644 --- a/doc/dsm/mods/Readme.mod_conference.txt +++ b/doc/dsm/mods/Readme.mod_conference.txt @@ -48,3 +48,7 @@ conference.setupMixIn(float level, unsigned int seconds) conference.playMixIn(string filename) - mix in a file + +conference.playMixInList(string filename) + - add a file to the mix-in playlist + - the list is setup when this is called for the first time and set as mixin source _______________________________________________ Semsdev mailing list Semsdev@lists.iptel.org http://lists.iptel.org/mailman/listinfo/semsdev