ginga 1.0
The Ginga iTV middleware
Loading...
Searching...
No Matches
WebServices.h
1/* Copyright (C) 2006-2018 PUC-Rio/Laboratorio TeleMidia
2
3This file is part of Ginga (Ginga-NCL).
4
5Ginga is free software: you can redistribute it and/or modify it
6under the terms of the GNU General Public License as published by
7the Free Software Foundation, either version 2 of the License, or
8(at your option) any later version.
9
10Ginga is distributed in the hope that it will be useful, but WITHOUT
11ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
13License for more details.
14
15You should have received a copy of the GNU General Public License
16along with Ginga. If not, see <https://www.gnu.org/licenses/>. */
17
18#ifndef WEBSERVICES_H
19#define WEBSERVICES_H
20
21#include "aux-ginga.h"
22#include <libgssdp/gssdp.h>
23#include <libsoup/soup.h>
24#include "Event.h"
25
26namespace ginga {
27class Formatter;
28class Document;
29class Media;
30
34typedef enum
35{
36 WS_STATE_STARTED,
37 WS_STATE_STOPPED,
38} WebServicesState;
39
44{
45public:
47 bool isValid ();
48 string location;
49 string deviceType;
50 list<string> supportedFormats;
51 list<string> recognizedableEvents;
52};
53
54#define SSDP_ST "urn:schemas-sbtvd-org:service:GingaCCWebServices:1"
55#define SSDP_UUID "uuid:1234abcd-12ab-12ab-12ab-1234567abc13"
56#define WS_NAME "TeleMidia GingaCC-WebServices"
57#define WS_ROUTE_LOC "/location"
58#define WS_ROUTE_PLAYER "/remote-mediaplayer"
59#define WS_ROUTE_APPS "/current-service/apps/"
60#define WS_PORT_DEFAULT 44642
61#define WS_JSON_REMOTE_PLAYER \
62 "{\
63 \"location\" : \"%s\", \
64 \"deviceType\" : \"%s\", \
65 \"supportedFormats\" : %s, \
66 \"recognizableEvents\" : %s, \
67 }"
68
69#define WS_JSON_ACT \
70 "{\
71 \"action\": \"%s\",\
72 }"
73#define WS_JSON_ACT_WITH_INTERFACE \
74 "{\
75 \"action\": \"%s\",\
76 \"interface\": \"%s\",\
77 }"
78#define WS_JSON_ACT_WITH_INTERFACE_VALUE \
79 "{\
80 \"action\": \"%s\",\
81 \"interface\": \"%s\",\
82 \"value\": \"%s\"\
83 }"
84
85#define TRACE_SOUP_REQ_MSG(msg) \
86 G_STMT_START \
87 { \
88 SoupMessageHeadersIter it; \
89 const gchar *name; \
90 const gchar *value; \
91 soup_message_headers_iter_init (&it, msg->request_headers); \
92 while (soup_message_headers_iter_next (&it, &name, &value)) \
93 TRACE ("request header %s: %s", name, value); \
94 TRACE ("request body:\n%s\n", msg->request_body->data); \
95 } \
96 G_STMT_END
97
103{
104public:
105 explicit WebServices (Formatter *);
106 ~WebServices ();
107 bool start ();
108 bool stop ();
109 WebServicesState getState ();
110 bool machMediaThenSetPlayerRemote (PlayerRemoteData &);
111 Formatter *getFormatter ();
112 const char *host_addr;
113 guint host_port;
114
115private:
116 Formatter *_formatter;
117 WebServicesState _state;
118 map<Media *, PlayerRemoteData> _playerMap;
119 GSSDPClient *_client;
120 GSSDPResourceGroup *_resource_group;
121 SoupServer *_server;
122};
123
124}
125
126#endif // WebServices_H
NCL document.
Definition Document.h:35
Interface between libginga and the external world.
Definition Formatter.h:39
Definition Media.h:27
PlayerRemoteData.
Definition WebServices.h:44
WebSercices.
Definition WebServices.h:103
WebServices(Formatter *)
Creates a new WebServices.
Definition WebServices.cpp:35