This repository has been archived by the owner on Sep 30, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 75
/
SAPDirectory.h
153 lines (126 loc) · 3.16 KB
/
SAPDirectory.h
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#pragma once
/*
* SAP-Announcement Support for XBMC
* Copyright (c) 2008 elupus (Joakim Plate)
*
* 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 of the License, 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 this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "IDirectory.h"
#include "threads/Thread.h"
#include "threads/CriticalSection.h"
namespace SDP
{
struct sdp_desc_time
{
std::string active;
std::string repeat;
};
struct sdp_desc_media
{
std::string name;
std::string title;
std::string connection;
std::vector<std::string> attributes;
};
struct sdp_desc_origin
{
std::string username;
int sessionid;
int sessionver;
std::string nettype;
std::string addrtype;
std::string address;
};
struct sdp_desc
{
std::string version;
std::string origin;
std::string name;
std::string info;
std::string bandwidth;
std::vector<std::string> attributes;
std::vector<sdp_desc_time> times;
std::vector<sdp_desc_media> media;
};
struct sap_desc
{
int version;
int addrtype;
int msgtype;
int encrypted;
int compressed;
int authlen;
int msgid;
std::string origin;
std::string payload_type;
void clear()
{
version = 0;
addrtype = 0;
msgtype = 0;
encrypted = 0;
compressed = 0;
authlen = 0;
msgid = 0;
origin.clear();
payload_type.clear();
}
};
int parse_sap(const char* data, struct sap_desc *h);
int parse_sdp(const char* data, struct sdp_desc *sdp);
int parse_sdp_origin(const char* data, struct sdp_desc_origin *o);
}
namespace XFILE { class CSAPFile; }
namespace XFILE { class CSAPDirectory; }
class CSAPSessions
: CThread
{
public:
CSAPSessions();
~CSAPSessions();
void StopThread(bool bWait = true);
protected:
friend class XFILE::CSAPDirectory;
friend class XFILE::CSAPFile;
struct CSession
{
std::string origin;
int msgid;
unsigned int timeout;
std::string payload_origin;
std::string payload_type;
std::string payload;
std::string path;
};
std::vector<CSession> m_sessions;
CCriticalSection m_section;
private:
void Process();
bool ParseAnnounce(char* data, int len);
SOCKET m_socket;
};
extern CSAPSessions g_sapsessions;
namespace XFILE
{
class CSAPDirectory
: public IDirectory
{
public:
CSAPDirectory(void);
virtual ~CSAPDirectory(void);
virtual bool GetDirectory(const CStdString& strPath, CFileItemList &items);
virtual bool IsAllowed(const CStdString &strFile) const { return true; };
};
}