forked from andoma/movian
-
Notifications
You must be signed in to change notification settings - Fork 0
/
upnp_connectionmanager.c
113 lines (99 loc) · 2.91 KB
/
upnp_connectionmanager.c
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
/*
* Copyright (C) 2007-2015 Lonelycoder AB
*
* 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 3 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, see <https://www.gnu.org/licenses/>.
*
* This program is also available under a commercial proprietary license.
* For more information, contact [email protected]
*/
#include <stdio.h>
#include "networking/http_server.h"
#include "htsmsg/htsmsg_xml.h"
#include "event.h"
#include "misc/str.h"
#include "api/lastfm.h"
#include "upnp.h"
/**
*
*/
static htsmsg_t *
cm_GetProtocolInfo(http_connection_t *hc, htsmsg_t *args,
const char *myhost, int myport)
{
htsmsg_t *out = htsmsg_create_map();
htsmsg_add_str(out, "Source", "");
htsmsg_add_str(out, "Sink", "http-get:*:*:*");
return out;
}
/**
*
*/
static htsmsg_t *
cm_GetCurrentConnectionInfo(http_connection_t *hc, htsmsg_t *args,
const char *myhost, int myport)
{
const char *uri = htsmsg_get_str(args, "ConnectionID");
if(uri == NULL || strcmp(uri, "0"))
return UPNP_CONTROL_INVALID_ARGS;
htsmsg_t *out = htsmsg_create_map();
htsmsg_add_u32(out, "RcsID", 0);
htsmsg_add_u32(out, "AVTransportID", 0);
htsmsg_add_str(out, "ProtocolInfo", "");
htsmsg_add_str(out, "PeerConnectionManager", "");
htsmsg_add_s32(out, "PeerConnectionID", -1);
htsmsg_add_str(out, "Direction", "Input");
htsmsg_add_str(out, "Status", "OK");
return out;
}
/**
*
*/
static htsmsg_t *
cm_GetCurrentConnectionIDs(http_connection_t *hc, htsmsg_t *args,
const char *myhost, int myport)
{
#if 0
const char *uri = htsmsg_get_str(args, "ConnectionID");
if(uri == NULL || strcmp(uri, "0"))
return UPNP_CONTROL_INVALID_ARGS;
#endif
htsmsg_t *out = htsmsg_create_map();
htsmsg_add_str(out, "ConnectionIDs", "0");
return out;
}
/**
*
*/
static htsmsg_t *
cm_generate_props(upnp_local_service_t *uls, const char *myhost, int myport)
{
htsmsg_t *r = htsmsg_create_map();
htsmsg_add_str(r, "SourceProtocolInfo", "");
htsmsg_add_str(r, "SinkProtocolInfo", "http-get:*:*:*");
htsmsg_add_str(r, "CurrentConnectionIDs", "0");
return r;
}
/**
*
*/
upnp_local_service_t upnp_ConnectionManager_2 = {
.uls_name = "ConnectionManager",
.uls_version = 2,
.uls_generate_props = cm_generate_props,
.uls_methods = {
{ "GetProtocolInfo", cm_GetProtocolInfo },
{ "GetCurrentConnectionInfo", cm_GetCurrentConnectionInfo },
{ "GetCurrentConnectionIDs", cm_GetCurrentConnectionIDs },
}
};