summaryrefslogtreecommitdiffstats
path: root/xbmc/network/dacp/dacp.cpp
blob: 890d1f23e6cc3e37539b67608b1fd2c00e3dcc94 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/*
 *  Copyright (C) 2015-2018 Team Kodi
 *  This file is part of Kodi - https://kodi.tv
 *
 *  SPDX-License-Identifier: GPL-2.0-or-later
 *  See LICENSES/README.md for more information.
 */

#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");
}