diff options
author | Memphiz <memphis@machzwo.de> | 2015-05-07 14:51:23 +0200 |
---|---|---|
committer | Memphiz <memphis@machzwo.de> | 2015-07-06 21:39:57 +0200 |
commit | b539c5b14a6dafd2438c3dce8c7c98e379e04586 (patch) | |
tree | f57bd73a3fd4466489168094e8bc2ef0c53b5949 | |
parent | 71b54ec571f915a6ee786a3abd06bca21f1604ca (diff) |
[network/dacp] - add subset of DACP (Digital Audio Control Protocol)
implementation for usage with airtunes clients
-rw-r--r-- | xbmc/network/dacp/Makefile | 6 | ||||
-rw-r--r-- | xbmc/network/dacp/dacp.cpp | 108 | ||||
-rw-r--r-- | xbmc/network/dacp/dacp.h | 49 |
3 files changed, 163 insertions, 0 deletions
diff --git a/xbmc/network/dacp/Makefile b/xbmc/network/dacp/Makefile new file mode 100644 index 0000000000..73f01ab3ec --- /dev/null +++ b/xbmc/network/dacp/Makefile @@ -0,0 +1,6 @@ +SRCS=dacp.cpp + +LIB=dacp.a + +include ../../../Makefile.include +-include $(patsubst %.cpp,%.P,$(patsubst %.c,%.P,$(SRCS))) diff --git a/xbmc/network/dacp/dacp.cpp b/xbmc/network/dacp/dacp.cpp new file mode 100644 index 0000000000..3653ec6d60 --- /dev/null +++ b/xbmc/network/dacp/dacp.cpp @@ -0,0 +1,108 @@ +/* + * Copyright (C) 2015 Team Kodi + * http://kodi.tv + * + * 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 2, or (at your option) + * any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "dacp.h" +#include "filesystem/File.h" + +#define AIRTUNES_DACP_CMD_URI "ctrl-int/1/" + +// AirTunes related DACP implementation taken from http://nto.github.io/AirPlay.html#audio-remotecontrol + +CDACP::CDACP(const std::string &active_remote_header, const std::string &hostname, int port) +{ + m_dacpUrl.SetHostName(hostname); + m_dacpUrl.SetPort(port); + m_dacpUrl.SetProtocol("http"); + m_dacpUrl.SetProtocolOption("Active-Remote", active_remote_header); +} + +void CDACP::SendCmd(const std::string &cmd) +{ + m_dacpUrl.SetFileName(AIRTUNES_DACP_CMD_URI + cmd); + // issue the command + XFILE::CFile file; + file.Open(m_dacpUrl); + file.Write(NULL, 0); +} + +void CDACP::BeginFwd() +{ + SendCmd("beginff"); +} + +void CDACP::BeginRewnd() +{ + SendCmd("beginrew"); +} + +void CDACP::ToggleMute() +{ + SendCmd("mutetoggle"); +} + +void CDACP::NextItem() +{ + SendCmd("nextitem"); +} + +void CDACP::PrevItem() +{ + SendCmd("previtem"); +} + +void CDACP::Pause() +{ + SendCmd("pause"); +} + +void CDACP::PlayPause() +{ + SendCmd("playpause"); +} + +void CDACP::Play() +{ + SendCmd("play"); +} + +void CDACP::Stop() +{ + SendCmd("stop"); +} + +void CDACP::PlayResume() +{ + SendCmd("playresume"); +} + +void CDACP::ShuffleSongs() +{ + SendCmd("shuffle_songs"); +} + +void CDACP::VolumeDown() +{ + SendCmd("volumedown"); +} + +void CDACP::VolumeUp() +{ + SendCmd("volumeup"); +} diff --git a/xbmc/network/dacp/dacp.h b/xbmc/network/dacp/dacp.h new file mode 100644 index 0000000000..a53748903f --- /dev/null +++ b/xbmc/network/dacp/dacp.h @@ -0,0 +1,49 @@ +#pragma once + +/* + * Copyright (C) 2015 Team Kodi + * http://kodi.tv + * + * 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 2, or (at your option) + * any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include <string> +#include "URL.h" + +class CDACP +{ + public: + CDACP(const std::string &active_remote_header, const std::string &hostname, int port); + + void BeginFwd(); + void BeginRewnd(); + void ToggleMute(); + void NextItem(); + void PrevItem(); + void Pause(); + void PlayPause(); + void Play(); + void Stop(); + void PlayResume(); + void ShuffleSongs(); + void VolumeDown(); + void VolumeUp(); + + private: + void SendCmd(const std::string &cmd); + + CURL m_dacpUrl; +};
\ No newline at end of file |