From 9130bb7fe0c223d57f432bcabd3ce55fcc3f10d4 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 25 Aug 2009 00:54:23 +0200 Subject: wrap upnp mediaserver --- src/paprefs.cc | 95 ++++++++- src/paprefs.glade | 614 +++++++++++++++++++++++++++--------------------------- 2 files changed, 393 insertions(+), 316 deletions(-) (limited to 'src') diff --git a/src/paprefs.cc b/src/paprefs.cc index 6a067d8..de100f1 100644 --- a/src/paprefs.cc +++ b/src/paprefs.cc @@ -36,7 +36,6 @@ public: MainWindow(BaseObjectType* cobject, const Glib::RefPtr& x); static MainWindow* create(); - Gtk::EventBox *titleEventBox; Gtk::Button *closeButton; Gtk::CheckButton @@ -48,7 +47,9 @@ public: *rtpReceiveCheckButton, *rtpSendCheckButton, *rtpLoopbackCheckButton, - *combineCheckButton; + *combineCheckButton, + *upnpMediaServerCheckButton, + *upnpNullSinkCheckButton; Gtk::RadioButton *rtpMikeRadioButton, @@ -60,30 +61,44 @@ public: bool ignoreChanges; void onCloseButtonClicked(); + void updateSensitive(); + void onChangeRemoteAccess(); void onChangeZeroconfDiscover(); void onChangeZeroconfRaopDiscover(); void onChangeRtpReceive(); void onChangeRtpSend(); void onChangeCombine(); + void onChangeUpnp(); + void readFromGConf(); + void checkForModules(); + void writeToGConfRemoteAccess(); void writeToGConfZeroconfDiscover(); void writeToGConfZeroconfRaopDiscover(); void writeToGConfRtpReceive(); void writeToGConfRtpSend(); void writeToGConfCombine(); + void writeToGConfUPnP(); + void onGConfChange(const Glib::ustring& key, const Gnome::Conf::Value& value); - bool rtpRecvAvailable, rtpSendAvailable, zeroconfPublishAvailable, zeroconfDiscoverAvailable, zeroconfRaopDiscoverAvailable, remoteAvailable; + bool + rtpRecvAvailable, + rtpSendAvailable, + zeroconfPublishAvailable, + zeroconfDiscoverAvailable, + zeroconfRaopDiscoverAvailable, + remoteAvailable, + upnpAvailable; }; MainWindow::MainWindow(BaseObjectType* cobject, const Glib::RefPtr& x) : Gtk::Window(cobject), ignoreChanges(true) { - x->get_widget("titleEventBox", titleEventBox); x->get_widget("closeButton", closeButton); x->get_widget("remoteAccessCheckButton", remoteAccessCheckButton); @@ -95,14 +110,13 @@ MainWindow::MainWindow(BaseObjectType* cobject, const Glib::RefPtrget_widget("rtpSendCheckButton", rtpSendCheckButton); x->get_widget("rtpLoopbackCheckButton", rtpLoopbackCheckButton); x->get_widget("combineCheckButton", combineCheckButton); + x->get_widget("upnpMediaServerCheckButton", upnpMediaServerCheckButton); + x->get_widget("upnpNullSinkCheckButton", upnpNullSinkCheckButton); x->get_widget("rtpMikeRadioButton", rtpMikeRadioButton); x->get_widget("rtpSpeakerRadioButton", rtpSpeakerRadioButton); x->get_widget("rtpNullSinkRadioButton", rtpNullSinkRadioButton); - Gdk::Color c("white"); - titleEventBox->modify_bg(Gtk::STATE_NORMAL, c); - checkForModules(); gconf = Gnome::Conf::Client::get_default_client(); @@ -130,6 +144,9 @@ MainWindow::MainWindow(BaseObjectType* cobject, const Glib::RefPtrsignal_clicked().connect(sigc::mem_fun(*this, &MainWindow::onChangeRtpSend)); combineCheckButton->signal_toggled().connect(sigc::mem_fun(*this, &MainWindow::onChangeCombine)); + + upnpMediaServerCheckButton->signal_toggled().connect(sigc::mem_fun(*this, &MainWindow::onChangeUpnp)); + upnpNullSinkCheckButton->signal_toggled().connect(sigc::mem_fun(*this, &MainWindow::onChangeUpnp)); } MainWindow* MainWindow::create() { @@ -161,6 +178,9 @@ void MainWindow::updateSensitive() { rtpMikeRadioButton->set_sensitive(b && rtpSendAvailable); rtpSpeakerRadioButton->set_sensitive(b && rtpSendAvailable); rtpNullSinkRadioButton->set_sensitive(b && rtpSendAvailable); + + upnpMediaServerCheckButton->set_sensitive(upnpAvailable); + upnpNullSinkCheckButton->set_sensitive(upnpAvailable && upnpMediaServerCheckButton->get_active()); } void MainWindow::onChangeRemoteAccess() { @@ -208,14 +228,21 @@ void MainWindow::onChangeRtpSend() { } void MainWindow::onChangeCombine() { - Gnome::Conf::ChangeSet changeSet; - if (ignoreChanges) return; writeToGConfCombine(); } +void MainWindow::onChangeUpnp() { + + if (ignoreChanges) + return; + + updateSensitive(); + writeToGConfUPnP(); +} + void MainWindow::writeToGConfCombine() { Gnome::Conf::ChangeSet changeSet; changeSet.set(PA_GCONF_PATH_MODULES"/combine/locked", true); @@ -361,7 +388,11 @@ void MainWindow::writeToGConfRtpSend() { if (rtpSendCheckButton->get_active()) { if (!mikeEnabled && !speakerEnabled) { changeSet.set(PA_GCONF_PATH_MODULES"/rtp-send/name0", Glib::ustring("module-null-sink")); - changeSet.set(PA_GCONF_PATH_MODULES"/rtp-send/args0", Glib::ustring("sink_name=rtp format=s16be channels=2 rate=44100 description=\"RTP Multicast Sink\"")); + changeSet.set(PA_GCONF_PATH_MODULES"/rtp-send/args0", Glib::ustring("sink_name=rtp " + "format=s16be " + "channels=2 " + "rate=44100 " + "sink_properties=\"device.description='RTP Multicast' device.bus='network' device.icon_name='network-server'\"")); changeSet.set(PA_GCONF_PATH_MODULES"/rtp-send/name1", Glib::ustring("module-rtp-send")); changeSet.set(PA_GCONF_PATH_MODULES"/rtp-send/args1", Glib::ustring(loopbackEnabled ? "source=rtp.monitor loop=1" : "source=rtp.monitor loop=0")); @@ -391,6 +422,42 @@ void MainWindow::writeToGConfRtpSend() { gconf->suggest_sync(); } +void MainWindow::writeToGConfUPnP() { + Gnome::Conf::ChangeSet changeSet; + + changeSet.set(PA_GCONF_PATH_MODULES"/upnp-media-server/locked", true); + gconf->change_set_commit(changeSet, true); + + if (upnpMediaServerCheckButton->get_active()) { + changeSet.set(PA_GCONF_PATH_MODULES"/upnp-media-server/name0", Glib::ustring("module-rygel-media-server")); + changeSet.set(PA_GCONF_PATH_MODULES"/upnp-media-server/args0", Glib::ustring("")); + + if (upnpNullSinkCheckButton->get_active()) { + changeSet.set(PA_GCONF_PATH_MODULES"/upnp-media-server/name1", Glib::ustring("module-null-sink")); + changeSet.set(PA_GCONF_PATH_MODULES"/upnp-media-server/args1", Glib::ustring("sink_name=upnp " + "format=s16be " + "channels=2 " + "rate=44100 " + "sink_properties=\"device.description='DLNA/UPnP Streaming' device.bus='network' device.icon_name='network-server'\"")); + changeSet.set(PA_GCONF_PATH_MODULES"/upnp-media-server/null-sink-enabled", true); + } else { + changeSet.unset(PA_GCONF_PATH_MODULES"/upnp-media-server/name1"); + changeSet.unset(PA_GCONF_PATH_MODULES"/upnp-media-server/args1"); + changeSet.set(PA_GCONF_PATH_MODULES"/upnp-media-server/null-sink-enabled", false); + } + + changeSet.set(PA_GCONF_PATH_MODULES"/upnp-media-server/enabled", true); + } else + changeSet.set(PA_GCONF_PATH_MODULES"/upnp-media-server/enabled", false); + + gconf->change_set_commit(changeSet, true); + + changeSet.set(PA_GCONF_PATH_MODULES"/upnp-media-server/locked", false); + gconf->change_set_commit(changeSet, true); + + gconf->suggest_sync(); +} + void MainWindow::onGConfChange(const Glib::ustring&, const Gnome::Conf::Value&) { readFromGConf(); } @@ -422,6 +489,9 @@ void MainWindow::readFromGConf() { combineCheckButton->set_active(gconf->get_bool(PA_GCONF_PATH_MODULES"/combine/enabled")); + upnpMediaServerCheckButton->set_active(gconf->get_bool(PA_GCONF_PATH_MODULES"/upnp-media-server/enabled")); + upnpNullSinkCheckButton->set_active(gconf->get_bool(PA_GCONF_PATH_MODULES"/upnp-media-server/null-sink-enabled")); + ignoreChanges = FALSE; updateSensitive(); @@ -440,6 +510,11 @@ void MainWindow::checkForModules() { rtpRecvAvailable = access(MODULESDIR "module-rtp-recv" SHREXT, F_OK) == 0; rtpSendAvailable = access(MODULESDIR "module-rtp-send" SHREXT, F_OK) == 0; + + upnpAvailable = + access(MODULESDIR "module-rygel-media-server" SHREXT, F_OK) == 0// && + // g_find_program_in_path("rygel") + ; } int main(int argc, char *argv[]) { diff --git a/src/paprefs.glade b/src/paprefs.glade index 33ab460..d570a4c 100644 --- a/src/paprefs.glade +++ b/src/paprefs.glade @@ -7,21 +7,31 @@ False preferences-desktop - + True + 12 + vertical + 12 - + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - + True 12 - 12 + vertical + 6 - + + Make discoverable _PulseAudio network sound devices available locally True - preferences-desktop - 6 + True + False + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + True + True False @@ -30,377 +40,333 @@ - + + Make discoverable Apple A_irTunes sound devices available locally True - 6 - - - True - 0 - 1 - <span size="18000" color="black"><b>PulseAudio Preferences</b></span> - True - - - 0 - - - - - True - 0 - 0 - <span color="black">View and modify the configuration of your local sound server</span> - True - - - 1 - - + True + False + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + True + True + False + False 1 + + + True + False + <i>Apple and AirTunes are trademarks of Apple Inc., registered in the U.S. and other countries.</i> + True + True + + + False + False + end + 2 + + - - - False - False - 0 - - - - - True - - - False - False - 1 - - - - - True - 12 - 12 - + True - True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Network _Access + True + + + False + tab + + + + + True + 12 + vertical + 6 - + + Enable _network access to local sound devices True - 12 - 6 - - - Enable _network access to local sound devices - True - True - False - True - True - - - False - False - 0 - - + True + False + True + True + + + False + False + 0 + + + + + True + 12 - + True - 12 + vertical + 6 - + + Allow other machines on the LAN to _discover local sound devices True - 6 - - - Allow other machines on the LAN to _discover local sound devices - True - True - False - True - True - - - False - False - 0 - - - - - Don't require _authentication - True - True - False - True - True - - - False - False - 1 - - + True + False + True + True + + False + False + 0 + + + + + Don't _require authentication + True + True + False + True + True + + + False + False + 1 + - - False - False - 1 - - - - - _Make discoverable network sound devices available locally - True - True - False - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - True - True - - - False - False - 2 - - - - - Make discoverable Apple Air_tunes sound devices available locally - True - True - False - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - True - True - - - False - False - 3 - - - - - True - False - 0 - <i>Apple and Airtunes are trademarks of Apple Inc., registered in the U.S. and other countries.</i> - True - - - 4 - + + False + False + 1 + - + + Make local sound devices available as DLNA/_UPnP Media Server True + True + False GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - N_etwork Access True + True - False - tab + False + False + 2 - + True - 12 - 6 - - - Enable Multicast/RTP _receiver - True - True - False - True - True - - - False - False - 0 - - + 12 - - Enable Multicast/RTP _sender + True - True - False - True - True - - - False - False - 1 - - - - - True - 12 + vertical - + + Create separate audio device for DLNA/UPnP media streaming True - 6 - - - Send audio from local _microphone - True - True - False - True - True - - - False - False - 0 - - - - - Send audio from local s_peakers - True - True - False - True - True - rtpMikeRadioButton - - - False - False - 1 - - - - - Create seperate audio _device for Multicast/RTP - True - True - False - True - True - rtpMikeRadioButton - - - False - False - 2 - - - - - _Loopback audio to local speakers - True - True - False - True - True - - - False - False - 3 - - + True + False + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + True + True + + False + False + 0 + - - 2 - - 1 + False + False + 3 + + + 1 + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Network _Server + True + + + 3 + False + tab + + + + + True + 12 + vertical + 6 - + + Enable Multicast/RTP re_ceiver True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - Multicast/R_TP + True + False True + True - 1 - False - tab + False + False + 0 - + + Enable Multicast/RTP s_ender True - 12 - 6 - - - Add _virtual output device for simultaneous output on all local sound cards - True - True - False - True - True - - - False - False - 0 - - + True + False + True + True - 2 + False + False + 1 - + True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - Sim_ultaneous Output - True + 12 + + + True + vertical + 6 + + + Send audio from local _microphone + True + True + False + True + True + True + + + False + False + 0 + + + + + Send audio from local spea_kers + True + True + False + True + True + rtpMikeRadioButton + + + False + False + 1 + + + + + Create separate audio device _for Multicast/RTP + True + True + False + True + True + rtpMikeRadioButton + + + False + False + 2 + + + + + _Loop back audio to local speakers + True + True + False + True + True + + + False + False + 3 + + + + 2 - False - tab - 0 + 2 + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Multicast/R_TP + True + + + 2 + False + tab - + True - end + 12 + vertical + 6 - - gtk-close + + Add _virtual output device for simultaneous output on all local sound cards True True - True False - True + True + True False @@ -409,16 +375,52 @@ + + 3 + + + + + True + Simultaneous _Output + True + + + 3 + False + tab + + + + + 0 + + + + + True + end + + + gtk-close + True + True + True + True + True + False False - end - 1 + 0 - 2 + False + False + end + 1 -- cgit