[Windows] Fix driver version detection of AMD RDNA+ GPU on Windows 10
[xbmc.git] / xbmc / network / AirPlayServer.h
blob986616b22176176228313cc6b7f203597a229b73
1 /*
2 * Many concepts and protocol specification in this code are taken from
3 * the Boxee project. http://www.boxee.tv
5 * Copyright (C) 2011-2018 Team Kodi
6 * This file is part of Kodi - https://kodi.tv
8 * SPDX-License-Identifier: GPL-2.0-or-later
9 * See LICENSES/README.md for more information.
12 #pragma once
14 #include "interfaces/IAnnouncer.h"
15 #include "network/Network.h"
16 #include "threads/CriticalSection.h"
17 #include "threads/Thread.h"
18 #include "utils/HttpParser.h"
20 #include <map>
21 #include <vector>
23 #include <sys/socket.h>
25 class CVariant;
27 #define AIRPLAY_SERVER_VERSION_STR "101.28"
29 class CAirPlayServer : public CThread, public ANNOUNCEMENT::IAnnouncer
31 public:
32 // IAnnouncer IF
33 void Announce(ANNOUNCEMENT::AnnouncementFlag flag,
34 const std::string& sender,
35 const std::string& message,
36 const CVariant& data) override;
38 //AirPlayServer impl.
39 static bool StartServer(int port, bool nonlocal);
40 static void StopServer(bool bWait);
41 static bool IsRunning();
42 static bool SetCredentials(bool usePassword, const std::string& password);
43 static bool IsPlaying(){ return m_isPlaying > 0;}
44 static void backupVolume();
45 static void restoreVolume();
46 static int m_isPlaying;
48 protected:
49 void Process() override;
51 private:
52 CAirPlayServer(int port, bool nonlocal);
53 ~CAirPlayServer() override;
54 bool SetInternalCredentials(bool usePassword, const std::string& password);
55 bool Initialize();
56 void Deinitialize();
57 void AnnounceToClients(int state);
59 class CTCPClient
61 public:
62 CTCPClient();
63 ~CTCPClient();
64 //Copying a CCriticalSection is not allowed, so copy everything but that
65 //when adding a member variable, make sure to copy it in CTCPClient::Copy
66 CTCPClient(const CTCPClient& client);
67 CTCPClient& operator=(const CTCPClient& client);
68 void PushBuffer(CAirPlayServer *host, const char *buffer,
69 int length, std::string &sessionId,
70 std::map<std::string, int> &reverseSockets);
71 void ComposeReverseEvent(std::string& reverseHeader, std::string& reverseBody, int state);
73 void Disconnect();
75 int m_socket;
76 struct sockaddr_storage m_cliaddr;
77 socklen_t m_addrlen;
78 CCriticalSection m_critSection;
79 int m_sessionCounter;
80 std::string m_sessionId;
82 private:
83 int ProcessRequest( std::string& responseHeader,
84 std::string& response);
86 void ComposeAuthRequestAnswer(std::string& responseHeader, std::string& responseBody);
87 bool checkAuthorization(const std::string& authStr, const std::string& method, const std::string& uri);
88 void Copy(const CTCPClient& client);
90 HttpParser* m_httpParser;
91 bool m_bAuthenticated;
92 int m_lastEvent;
93 std::string m_authNonce;
96 CCriticalSection m_connectionLock;
97 std::vector<CTCPClient> m_connections;
98 std::map<std::string, int> m_reverseSockets;
99 std::vector<SOCKET> m_ServerSockets;
100 int m_port;
101 bool m_nonlocal;
102 bool m_usePassword;
103 std::string m_password;
104 int m_origVolume;
106 static CCriticalSection ServerInstanceLock;
107 static CAirPlayServer *ServerInstance;