aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLarry Sachs <larry.j.sachs@intel.com>2018-09-28 11:59:38 -0700
committerLarry Sachs <larry.j.sachs@intel.com>2018-10-02 11:18:57 -0700
commit8b407ead22b8344dea2558584161ed896eda9b6e (patch)
tree3dab8b617440b450415ffe8ebcf5ae2397cef8bc
parenteecbba1d495db37a244d402ac50ead5f09c1c4fc (diff)
Add support for Media Control and Audio Resourcesiot-lite
Change-Id: I35689204a03670ab371d903323e816f19525c32e Signed-off-by: Larry Sachs <larry.j.sachs@intel.com>
-rw-r--r--examples/iot-lite/SConscript2
-rw-r--r--examples/iot-lite/UpnpAvTransportService.cpp616
-rw-r--r--examples/iot-lite/UpnpAvTransportService.h54
-rw-r--r--examples/iot-lite/UpnpBridgeIotLite.cpp2
-rw-r--r--examples/iot-lite/UpnpConnector.cpp8
-rw-r--r--examples/iot-lite/UpnpConnector.h1
-rw-r--r--examples/iot-lite/UpnpDimmingService.cpp4
-rw-r--r--examples/iot-lite/UpnpInternal.h15
-rw-r--r--examples/iot-lite/UpnpManager.cpp10
-rw-r--r--examples/iot-lite/UpnpPowerSwitchService.cpp2
-rw-r--r--examples/iot-lite/UpnpRenderingControlService.cpp199
-rw-r--r--examples/iot-lite/UpnpRenderingControlService.h52
-rw-r--r--examples/iot-lite/UpnpService.cpp62
-rw-r--r--include/UpnpConstants.h1
14 files changed, 994 insertions, 34 deletions
diff --git a/examples/iot-lite/SConscript b/examples/iot-lite/SConscript
index c8b96eb..94bc6e1 100644
--- a/examples/iot-lite/SConscript
+++ b/examples/iot-lite/SConscript
@@ -57,6 +57,8 @@ upnp_iot_lite_bridge_cpp = ['UpnpBridgeIotLite.cpp',
'UpnpService.cpp',
'UpnpDimmingService.cpp',
'UpnpPowerSwitchService.cpp',
+ 'UpnpAvTransportService.cpp',
+ 'UpnpRenderingControlService.cpp',
'UpnpException.cpp']
upnp_iot_lite_bridge_obj = env_upnp_iot_lite_bridge.Object(upnp_iot_lite_bridge_cpp)
diff --git a/examples/iot-lite/UpnpAvTransportService.cpp b/examples/iot-lite/UpnpAvTransportService.cpp
new file mode 100644
index 0000000..0b62ace
--- /dev/null
+++ b/examples/iot-lite/UpnpAvTransportService.cpp
@@ -0,0 +1,616 @@
+//******************************************************************
+//
+// Copyright 2018 Intel Corporation All Rights Reserved.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+#include <algorithm>
+#include <cmath>
+
+#include "UpnpAvTransportService.h"
+
+static const string MODULE = "UpnpAvTransportService";
+
+// AV Transport Service
+
+static const char *playStatePropertyName = "play_state";
+static const char *mediaSpeedPropertyName = "media_speed";
+static const char *mediaLocationPropertyName = "media_location";
+static const char *lastActionPropertyName = "action";
+static const char *actionsPropertyName = "actions";
+static const char *actionPropertyName = "action";
+
+static const char *getCurrentTransportActionsAction = "GetCurrentTransportActions";
+static const char *getPositionInfoAction = "GetPositionInfo";
+static const char *getTransportInfoAction = "GetTransportInfo";
+
+static const char *instanceIdParamName = "InstanceID";
+
+static const char *actionsParamName = "Actions";
+
+static const char *trackParamName = "Track";
+static const char *trackDurationParamName = "TrackDuration";
+static const char *trackMetadataParamName = "TrackMetaData";
+static const char *trackUriParamName = "TrackURI";
+static const char *relTimeParamName = "RelTime";
+static const char *absTimeParamName = "AbsTime";
+static const char *relCountParamName = "RelCount";
+static const char *absCountParamName = "AbsCount";
+
+static const char *currentTransportStateParamName = "CurrentTransportState";
+static const char *currentTransportStatusParamName = "CurrentTransportStatus";
+static const char *currentSpeedParamName = "CurrentSpeed";
+
+static const char *stopAction = "stop";
+static const char *playAction = "play";
+static const char *pauseAction = "pause";
+static const char *fastforwardAction = "fastforward";
+static const char *rewindAction = "rewind";
+static const char *stepforwardAction = "stepforward";
+static const char *stepbackwardAction = "stepbackward";
+static const char *seekAction = "seek";
+
+static const char *upnpStopAction = "Stop";
+static const char *upnpPlayAction = "Play";
+static const char *upnpPauseAction = "Pause";
+static const char *upnpSeekAction = "Seek";
+
+static const char *speedParamName = "Speed";
+static const char *unitParamName = "Unit";
+static const char *targetParamName = "Target";
+
+static const char *unitAbsTime = "ABS_TIME";
+static const char *unitRelTime = "REL_TIME";
+
+static const int defaultInstanceID = 0;
+
+void UpnpAvTransport::processGetRequest(oc_request_t *request, oc_interface_mask_t interface, void *user_data, oc_status_t return_status)
+{
+ DEBUG_PRINT("request->resource->name=" << oc_string(request->resource->name));
+ GUPnPServiceInfo *serviceInfo = (GUPnPServiceInfo *)user_data;
+ GUPnPServiceProxy *proxy = GUPNP_SERVICE_PROXY(serviceInfo);
+
+ char *currentTransportStateValue = NULL;
+ char *currentTransportStatusValue = NULL;
+ char *currentSpeedValue = NULL;
+
+ int64_t trackValue = 0;
+ char *trackDurationValue = NULL;
+ char *trackMetadataValue = NULL;
+ char *trackUriValue = NULL;
+ char *relTimeValue = NULL;
+ char *absTimeValue = NULL;
+ int64_t relCountValue = 0;
+ int64_t absCountValue = 0;
+
+ char *currentActionsValue = NULL;
+
+ bool playStateValue = false;
+ double mediaSpeedValue = 0;
+ char *mediaLocationValue = NULL;
+ const char *lastActionValue = NULL;
+
+ GError *error = NULL;
+
+ // get playState, mediaSpeed (from Upnp TransportInfo)
+ if (! gupnp_service_proxy_send_action(proxy, getTransportInfoAction, &error,
+ // IN args
+ instanceIdParamName, G_TYPE_UINT, defaultInstanceID,
+ NULL,
+ // OUT args
+ currentTransportStateParamName, G_TYPE_STRING, &currentTransportStateValue,
+ currentTransportStatusParamName, G_TYPE_STRING, &currentTransportStatusValue,
+ currentSpeedParamName, G_TYPE_STRING, &currentSpeedValue,
+ NULL))
+ {
+ ERROR_PRINT(getTransportInfoAction << " action failed");
+ if (error)
+ {
+ DEBUG_PRINT("Error message: " << error->message);
+ g_error_free(error);
+ }
+ }
+
+ playStateValue = (strstr(currentTransportStateValue, playAction) ||
+ strstr(currentTransportStateValue, upnpPlayAction) ||
+ strstr(currentTransportStateValue, "PLAY"))
+ && (! strstr(currentTransportStateValue, "_PLAY"));
+
+ oc_rep_start_root_object();
+ oc_process_baseline_interface(request->resource);
+ DEBUG_PRINT("oc_rep_set_boolean " << playStatePropertyName << ": " << playStateValue);
+ oc_rep_set_boolean(root, play_state, playStateValue);
+
+
+ if (char *delim = strstr(currentSpeedValue, "/"))
+ {
+ // Upnp TransportPlaySpeed is expressed as a fraction
+ char numerator[10];
+ char denominator[10];
+ memset(numerator, '\0', sizeof(numerator));
+ memset(denominator, '\0', sizeof(denominator));
+ strncpy(numerator, currentSpeedValue, delim-currentSpeedValue);
+ strncpy(denominator, delim+1, strlen(currentSpeedValue)-strlen(numerator)-1);
+ mediaSpeedValue = atof(numerator) / atof(denominator);
+ }
+ else
+ {
+ mediaSpeedValue = atof(currentSpeedValue);
+ }
+
+ DEBUG_PRINT("oc_rep_set_double " << mediaSpeedPropertyName << ": " << mediaSpeedValue);
+ oc_rep_set_double(root, media_speed, mediaSpeedValue);
+
+ // get mediaLocation (from Upnp PositionInfo)
+ if (! gupnp_service_proxy_send_action(proxy, getPositionInfoAction, &error,
+ // IN args
+ instanceIdParamName, G_TYPE_UINT, defaultInstanceID,
+ NULL,
+ // OUT args
+ trackParamName, G_TYPE_UINT, &trackValue,
+ trackDurationParamName, G_TYPE_STRING, &trackDurationValue,
+ trackMetadataParamName, G_TYPE_STRING, &trackMetadataValue,
+ trackUriParamName, G_TYPE_STRING, &trackUriValue,
+ relTimeParamName, G_TYPE_STRING, &relTimeValue,
+ absTimeParamName, G_TYPE_STRING, &absTimeValue,
+ relCountParamName, G_TYPE_UINT, &relCountValue,
+ absCountParamName, G_TYPE_UINT, &absCountValue,
+ NULL))
+ {
+ ERROR_PRINT(getPositionInfoAction << " action failed");
+ if (error)
+ {
+ DEBUG_PRINT("Error message: " << error->message);
+ g_error_free(error);
+ }
+ }
+
+ mediaLocationValue = relTimeValue;
+
+ DEBUG_PRINT("oc_rep_set_text_string " << mediaLocationPropertyName << ": " << mediaLocationValue);
+ oc_rep_set_text_string(root, media_location, mediaLocationValue);
+
+ // get actions (from Upnp CurrentTransportActions)
+ if (! gupnp_service_proxy_send_action(proxy, getCurrentTransportActionsAction, &error,
+ // IN args
+ instanceIdParamName, G_TYPE_UINT, defaultInstanceID,
+ NULL,
+ // OUT args
+ actionsParamName, G_TYPE_STRING, &currentActionsValue,
+ NULL))
+ {
+ ERROR_PRINT(getCurrentTransportActionsAction << " action failed");
+ if (error)
+ {
+ DEBUG_PRINT("Error message: " << error->message);
+ g_error_free(error);
+ }
+ }
+
+ // Upnp returns csv list of action names, needs to be array of oic.r.media.action
+ vector<char*> actions;
+ char *token;
+ token = strtok(currentActionsValue, ",");
+ while (token) {
+ actions.push_back(token);
+ token = strtok(NULL, ",");
+ }
+
+ if (!actions.empty())
+ {
+ oc_string_array_t array;
+ oc_new_string_array(&array, actions.size());
+ for (unsigned int i = 0; i < actions.size(); ++i) {
+ DEBUG_PRINT(actionsPropertyName << "[" << i << "]");
+ DEBUG_PRINT("\t" << actionPropertyName << "=" << actions[i]);
+ oc_string_array_add_item(array, actions[i]);
+ }
+
+ DEBUG_PRINT("oc_string_array allocated size = " << oc_string_array_get_allocated_size(array));
+ for (unsigned int i = 0; i < oc_string_array_get_allocated_size(array); ++i) {
+ DEBUG_PRINT("array[" << i << "] = " << oc_string_array_get_item(array, i));
+ }
+ oc_rep_set_string_array(root, actions, array);
+ oc_free_string_array(&array);
+ }
+
+ // get lastAction (derived from playStateValue, mediaSpeedValue, and currentTransportState)
+ if (playStateValue)
+ {
+ if (mediaSpeedValue > 1)
+ {
+ lastActionValue = fastforwardAction;
+ }
+ else if (mediaSpeedValue == 1)
+ {
+ lastActionValue = playAction;
+ }
+ else if (mediaSpeedValue > 0)
+ {
+ lastActionValue = stepforwardAction;
+ }
+ else if (mediaSpeedValue <= -1)
+ {
+ lastActionValue = rewindAction;
+ }
+ else if (mediaSpeedValue < 0)
+ {
+ lastActionValue = stepbackwardAction;
+ }
+ else // (mediaSpeedValue == 0)
+ {
+ // unexpected play with zero speed
+ lastActionValue = pauseAction;
+ }
+ }
+ else
+ {
+ if (strstr(currentTransportStateValue, stopAction) ||
+ strstr(currentTransportStateValue, upnpStopAction) || strstr(currentTransportStateValue, "STOP") ||
+ strstr(currentTransportStateValue, "NO_MEDIA")) {
+ lastActionValue = stopAction;
+ }
+ else
+ {
+ lastActionValue = pauseAction;
+ }
+ }
+
+ DEBUG_PRINT("oc_rep_set_text_string " << lastActionPropertyName << ": " << lastActionValue);
+ oc_rep_set_text_string(root, action, lastActionValue);
+
+ g_free(currentTransportStateValue);
+ g_free(currentTransportStatusValue);
+ g_free(currentSpeedValue);
+
+ g_free(trackDurationValue);
+ g_free(trackMetadataValue);
+ g_free(trackUriValue);
+ g_free(relTimeValue);
+ g_free(absTimeValue);
+
+ g_free(currentActionsValue);
+
+ oc_rep_end_root_object();
+ oc_send_response(request, return_status);
+}
+
+void UpnpAvTransport::processGetRequest(oc_request_t *request, oc_interface_mask_t interface, void *user_data)
+{
+ processGetRequest(request, interface, user_data, OC_STATUS_OK);
+}
+
+void UpnpAvTransport::processPostRequest(oc_request_t *request, oc_interface_mask_t interface, void *user_data)
+{
+ DEBUG_PRINT("request->resource->name=" << oc_string(request->resource->name));
+ GUPnPServiceInfo *serviceInfo = (GUPnPServiceInfo *)user_data;
+ GUPnPServiceProxy *proxy = GUPNP_SERVICE_PROXY(serviceInfo);
+
+ bool playStateValue = false;
+ bool playStateValueIsPresent = false;
+
+ double mediaSpeedValue = 0;
+ bool mediaSpeedValueIsPresent = false;
+
+ char *mediaLocationValue = NULL;
+ bool mediaLocationValueIsPresent = false;
+
+ char *lastActionValue = NULL;
+ bool lastActionValueIsPresent = false;
+
+ bool doUpnpStop = false;
+ bool doUpnpPlay = false;
+ bool doUpnpPause = false;
+ bool doUpnpSeek = false;
+
+ int upnpPlaySpeedAsInt = 1;
+ int upnpPlaySpeedAsFract = 0;
+ char *upnpPlaySpeed = NULL;
+ char *upnpMediaLocation = NULL;
+
+ // determine the incoming parameters
+ oc_rep_t *rep = request->request_payload;
+ while (rep) {
+ DEBUG_PRINT("key=" << oc_string(rep->name) << ", rep type=" << rep->type);
+ char *key = (char *)(rep->name).ptr;
+// DEBUG_PRINT("char *key=" << key);
+ if (strncmp(key, playStatePropertyName, (rep->name).size) == 0) {
+ switch (rep->type)
+ {
+ case OC_REP_BOOL:
+ playStateValue = rep->value.boolean;
+ DEBUG_PRINT("New " << playStatePropertyName << ": " << playStateValue);
+ playStateValueIsPresent = true;
+ break;
+ default:
+ DEBUG_PRINT("Unexpected rep type: " << rep->type);
+ oc_send_response(request, OC_STATUS_BAD_REQUEST);
+ return;
+ }
+ }
+ if (strncmp(key, mediaSpeedPropertyName, (rep->name).size) == 0) {
+ switch (rep->type)
+ {
+ case OC_REP_DOUBLE:
+ mediaSpeedValue = rep->value.double_p;
+ DEBUG_PRINT("New " << mediaSpeedPropertyName << ": " << mediaSpeedValue);
+ mediaSpeedValueIsPresent = true;
+ break;
+ default:
+ DEBUG_PRINT("Unexpected rep type: " << rep->type);
+ oc_send_response(request, OC_STATUS_BAD_REQUEST);
+ return;
+ }
+ }
+ if (strncmp(key, mediaLocationPropertyName, (rep->name).size) == 0) {
+ switch (rep->type)
+ {
+ case OC_REP_STRING:
+ mediaLocationValue = (char *)(rep->value.string).ptr;
+ DEBUG_PRINT("New " << mediaLocationPropertyName << ": " << mediaLocationValue);
+ mediaLocationValueIsPresent = true;
+ break;
+ default:
+ DEBUG_PRINT("Unexpected rep type: " << rep->type);
+ oc_send_response(request, OC_STATUS_BAD_REQUEST);
+ return;
+ }
+ }
+ if (strncmp(key, lastActionPropertyName, (rep->name).size) == 0) {
+ switch (rep->type)
+ {
+ case OC_REP_STRING:
+ lastActionValue = (char *)(rep->value.string).ptr;
+ DEBUG_PRINT("New " << lastActionPropertyName << ": " << lastActionValue);
+ mediaLocationValueIsPresent = true;
+ break;
+ default:
+ DEBUG_PRINT("Unexpected rep type: " << rep->type);
+ oc_send_response(request, OC_STATUS_BAD_REQUEST);
+ return;
+ }
+ }
+
+ rep = rep->next;
+ }
+
+ if (playStateValueIsPresent || mediaSpeedValueIsPresent || mediaLocationValueIsPresent || lastActionValueIsPresent)
+ {
+ // determine upnp action from action parameter (if present)
+ if (lastActionValueIsPresent)
+ {
+ string lowerCase = string(lastActionValue);
+ transform(lowerCase.begin(), lowerCase.end(), lowerCase.begin(), ::tolower);
+ const char *lowerCaseAction = lowerCase.c_str();
+
+ if (strstr(lowerCaseAction, stopAction))
+ {
+ doUpnpStop = true;
+ }
+ else if (strstr(lowerCaseAction, playAction))
+ {
+ doUpnpPlay = true;
+ }
+ else if (strstr(lowerCaseAction, pauseAction))
+ {
+ doUpnpPause = true;
+ }
+ else if (strstr(lowerCaseAction, fastforwardAction))
+ {
+ doUpnpPlay = true;
+ upnpPlaySpeedAsInt = 2;
+ // upnpPlaySpeed may be reset below if mediaSpeed is present
+ }
+ else if (strstr(lowerCaseAction, rewindAction))
+ {
+ doUpnpPlay = true;
+ upnpPlaySpeedAsInt = -1;
+ // upnpPlaySpeed may be reset below if mediaSpeed is present
+ }
+ else if (strstr(lowerCaseAction, stepforwardAction))
+ {
+ doUpnpSeek = true;
+ // TODO: how to handle?
+ }
+ else if (strstr(lowerCaseAction, stepbackwardAction))
+ {
+ doUpnpSeek = true;
+ // TODO: how to handle?
+ }
+ else if (strstr(lowerCaseAction, seekAction))
+ {
+ doUpnpSeek = true;
+ // upnp seek location is expected to be set below
+ }
+ else
+ {
+ // Unknown action
+ ERROR_PRINT("Unknown action " << lastActionValue);
+ }
+ }
+
+ // determine upnp action from playState parameter (if present)
+ if (playStateValueIsPresent)
+ {
+ if (playStateValue)
+ {
+ doUpnpPlay = true;
+ }
+ else
+ {
+ doUpnpPause = true;
+ }
+ }
+
+ // determine upnp play speed from mediaSpeed parameter (if present)
+ if (mediaSpeedValueIsPresent)
+ {
+ if ((mediaSpeedValue >= 1) || (mediaSpeedValue <= -1))
+ {
+ upnpPlaySpeedAsInt = lround(mediaSpeedValue);
+ doUpnpPlay = true;
+ }
+ else if ((mediaSpeedValue > 0) || (mediaSpeedValue < 0))
+ {
+ upnpPlaySpeedAsFract = lround(10.0 / (mediaSpeedValue * 10.0)); // approx
+ doUpnpPlay = true;
+ }
+ else
+ {
+ // media play speed is zero
+ doUpnpPause = true;
+ }
+ }
+
+ // determine upnp media location from mediaLocation parameter (if present)
+ if (mediaLocationValueIsPresent)
+ {
+ doUpnpSeek = true;
+ upnpMediaLocation = mediaLocationValue;
+ }
+
+ // convert mediaSpeed double to upnp play speed string
+ char playSpeedString[10];
+ memset(playSpeedString, '\0', sizeof(playSpeedString));
+ upnpPlaySpeed = playSpeedString;
+
+ if (upnpPlaySpeedAsFract)
+ {
+ char denominator[10];
+ memset(denominator, '\0', sizeof(denominator));
+ if (upnpPlaySpeedAsFract < 0)
+ {
+ char *denomOffset = &denominator[3];
+ sprintf(denominator, "%s", "-1/");
+ sprintf(denomOffset, "%d", abs(upnpPlaySpeedAsFract));
+ }
+ else
+ {
+ char *denomOffset = &denominator[2];
+ sprintf(denominator, "%s", "1/");
+ sprintf(denomOffset, "%d", upnpPlaySpeedAsFract);
+ }
+ strcpy(upnpPlaySpeed, denominator);
+ }
+ else
+ {
+ char integerValue[10];
+ memset(integerValue, '\0', sizeof(integerValue));
+ sprintf(integerValue, "%d", upnpPlaySpeedAsInt);
+ strcpy(upnpPlaySpeed, integerValue);
+ }
+
+ DEBUG_PRINT(speedParamName << ": " << upnpPlaySpeed);
+ if (upnpMediaLocation)
+ {
+ DEBUG_PRINT(targetParamName << ": " << upnpMediaLocation);
+ }
+
+ // execute upnp action
+ GError *error = NULL;
+ if (doUpnpStop)
+ {
+ if (! gupnp_service_proxy_send_action(proxy, upnpStopAction, &error,
+ // IN args
+ instanceIdParamName, G_TYPE_UINT, defaultInstanceID,
+ NULL,
+ // OUT args
+ NULL))
+ {
+ ERROR_PRINT(upnpStopAction << " action failed");
+ if (error)
+ {
+ DEBUG_PRINT("Error message: " << error->message);
+ g_error_free(error);
+ }
+ }
+ }
+ else if (doUpnpPause)
+ {
+ if (! gupnp_service_proxy_send_action(proxy, upnpPauseAction, &error,
+ // IN args
+ instanceIdParamName, G_TYPE_UINT, defaultInstanceID,
+ NULL,
+ // OUT args
+ NULL))
+ {
+ ERROR_PRINT(upnpPauseAction << " action failed");
+ if (error)
+ {
+ DEBUG_PRINT("Error message: " << error->message);
+ g_error_free(error);
+ }
+ }
+ }
+ else if (doUpnpPlay)
+ {
+ if (! gupnp_service_proxy_send_action(proxy, upnpPlayAction, &error,
+ // IN args
+ instanceIdParamName, G_TYPE_UINT, defaultInstanceID,
+ speedParamName, G_TYPE_STRING, upnpPlaySpeed,
+ NULL,
+ // OUT args
+ NULL))
+ {
+ ERROR_PRINT(upnpPlayAction << " action failed");
+ if (error)
+ {
+ DEBUG_PRINT("Error message: " << error->message);
+ g_error_free(error);
+ }
+ }
+ }
+ else if (doUpnpSeek)
+ {
+ if (! gupnp_service_proxy_send_action(proxy, upnpSeekAction, &error,
+ // IN args
+ instanceIdParamName, G_TYPE_UINT, defaultInstanceID,
+ unitParamName, G_TYPE_STRING, unitAbsTime,
+ targetParamName, G_TYPE_STRING, upnpMediaLocation,
+ NULL,
+ // OUT args
+ NULL))
+ {
+ // absolute time failed, try again as relative time
+ if (! gupnp_service_proxy_send_action(proxy, upnpSeekAction, &error,
+ // IN args
+ instanceIdParamName, G_TYPE_UINT, defaultInstanceID,
+ unitParamName, G_TYPE_STRING, unitRelTime,
+ targetParamName, G_TYPE_STRING, upnpMediaLocation,
+ NULL,
+ // OUT args
+ NULL))
+ {
+ ERROR_PRINT(upnpSeekAction << " action failed");
+ if (error)
+ {
+ DEBUG_PRINT("Error message: " << error->message);
+ g_error_free(error);
+ }
+ }
+ }
+ }
+ }
+
+ // load return payload with all values
+ processGetRequest(request, interface, user_data, OC_STATUS_CHANGED);
+}
+
+void UpnpAvTransport::processPutRequest(oc_request_t *request, oc_interface_mask_t interface, void *user_data)
+{
+ return processPostRequest(request, interface, user_data);
+}
diff --git a/examples/iot-lite/UpnpAvTransportService.h b/examples/iot-lite/UpnpAvTransportService.h
new file mode 100644
index 0000000..4294121
--- /dev/null
+++ b/examples/iot-lite/UpnpAvTransportService.h
@@ -0,0 +1,54 @@
+//******************************************************************
+//
+// Copyright 2018 Intel Corporation All Rights Reserved.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+#ifndef UPNP_AV_TRANSPORT_SERVICE_H_
+#define UPNP_AV_TRANSPORT_SERVICE_H_
+
+#include <string>
+#include <map>
+
+#include <gupnp.h>
+
+#include "UpnpResource.h"
+#include "UpnpInternal.h"
+#include "UpnpService.h"
+
+using namespace std;
+
+class UpnpAvTransport: public UpnpService
+{
+
+ public:
+ UpnpAvTransport(GUPnPServiceInfo *serviceInfo,
+ UpnpRequestState *requestState):
+ UpnpService(serviceInfo, UPNP_OIC_TYPE_MEDIA_CONTROL, requestState)
+ {
+ }
+
+ static void processGetRequest(oc_request_t *request, oc_interface_mask_t interface, void *user_data);
+ static void processPostRequest(oc_request_t *request, oc_interface_mask_t interface, void *user_data);
+ static void processPutRequest(oc_request_t *request, oc_interface_mask_t interface, void *user_data);
+
+ private:
+ static void processGetRequest(oc_request_t *request, oc_interface_mask_t interface, void *user_data, oc_status_t return_status);
+
+};
+
+#endif // UPNP_AV_TRANSPORT_SERVICE_H_
diff --git a/examples/iot-lite/UpnpBridgeIotLite.cpp b/examples/iot-lite/UpnpBridgeIotLite.cpp
index ffd819e..5f0dae7 100644
--- a/examples/iot-lite/UpnpBridgeIotLite.cpp
+++ b/examples/iot-lite/UpnpBridgeIotLite.cpp
@@ -21,7 +21,7 @@
#include "UpnpConnector.h"
#define OC_SERVER
-
+#define OC_DYNAMIC_ALLOCATION
#include <oc_api.h>
#include <pthread.h>
diff --git a/examples/iot-lite/UpnpConnector.cpp b/examples/iot-lite/UpnpConnector.cpp
index fb1a0c6..b0356ce 100644
--- a/examples/iot-lite/UpnpConnector.cpp
+++ b/examples/iot-lite/UpnpConnector.cpp
@@ -29,6 +29,7 @@
#include <boost/regex.hpp>
#define OC_SERVER
+#define OC_DYNAMIC_ALLOCATION
#include <oc_core_res.h>
#include <UpnpConstants.h>
@@ -302,7 +303,8 @@ void UpnpConnector::onDeviceProxyAvailable(GUPnPControlPoint *controlPoint,
if (pUpnpResource != nullptr && !pUpnpResource->isRegistered())
{
- if (pUpnpResource->getResourceType() == UPNP_OIC_TYPE_DEVICE_LIGHT)
+ if (pUpnpResource->getResourceType() == UPNP_OIC_TYPE_DEVICE_LIGHT ||
+ pUpnpResource->getResourceType() == UPNP_OIC_TYPE_DEVICE_AV_PLAYER)
{
int ret = oc_add_device("/oic/d", pUpnpResource->getResourceType().c_str(),
pUpnpResource->getName().c_str(), "ocf.1.0.0", "ocf.res.1.0.0,ocf.sh.1.0.0",
@@ -312,7 +314,7 @@ void UpnpConnector::onDeviceProxyAvailable(GUPnPControlPoint *controlPoint,
{
s_deviceIndexLookup[pUpnpResource->getUdn()] = ++s_deviceIndex;
pUpnpResource->setRegistered(true);
- DEBUG_PRINT("Added light device " << pUpnpResource->getName());
+ DEBUG_PRINT("Added " << pUpnpResource->getResourceType() << " device " << pUpnpResource->getName());
// for (std::map< string, int >::iterator iter = s_deviceIndexLookup.begin(); iter != s_deviceIndexLookup.end(); ++iter)
// std::cout << iter->first << " => " << iter->second << '\n';
@@ -321,7 +323,7 @@ void UpnpConnector::onDeviceProxyAvailable(GUPnPControlPoint *controlPoint,
{
pUpnpResource->setRegistered(false);
unregisterDeviceResource(udn);
- DEBUG_PRINT("Failed to add light device " << pUpnpResource->getName());
+ DEBUG_PRINT("Failed to add " << pUpnpResource->getResourceType() << " device " << pUpnpResource->getName());
return;
}
}
diff --git a/examples/iot-lite/UpnpConnector.h b/examples/iot-lite/UpnpConnector.h
index 21ae473..7f0457c 100644
--- a/examples/iot-lite/UpnpConnector.h
+++ b/examples/iot-lite/UpnpConnector.h
@@ -27,6 +27,7 @@
#include <gupnp-service-proxy.h>
#define OC_SERVER
+#define OC_DYNAMIC_ALLOCATION
#include <oc_api.h>
using namespace std;
diff --git a/examples/iot-lite/UpnpDimmingService.cpp b/examples/iot-lite/UpnpDimmingService.cpp
index a311d4c..4140a71 100644
--- a/examples/iot-lite/UpnpDimmingService.cpp
+++ b/examples/iot-lite/UpnpDimmingService.cpp
@@ -53,7 +53,7 @@ void UpnpDimming::processGetRequest(oc_request_t *request, oc_interface_mask_t i
oc_rep_start_root_object();
oc_process_baseline_interface(request->resource);
- DEBUG_PRINT("oc_rep_set_int " << brightnessLevelName << " " << brightnessLevelValue);
+ DEBUG_PRINT("oc_rep_set_int " << brightnessLevelName << ": " << brightnessLevelValue);
oc_rep_set_int(root, brightness, brightnessLevelValue);
oc_rep_end_root_object();
oc_send_response(request, OC_STATUS_OK);
@@ -90,7 +90,7 @@ void UpnpDimming::processPostRequest(oc_request_t *request, oc_interface_mask_t
GError *error = NULL;
if (! gupnp_service_proxy_send_action(proxy, "SetLoadLevelTarget", &error,
// IN args
- "newLoadlevelTarget", G_TYPE_BOOLEAN, brightnessLevelValue,
+ "newLoadlevelTarget", G_TYPE_UINT, brightnessLevelValue,
NULL,
// OUT args (none)
NULL))
diff --git a/examples/iot-lite/UpnpInternal.h b/examples/iot-lite/UpnpInternal.h
index bf6a21f..dd8eba1 100644
--- a/examples/iot-lite/UpnpInternal.h
+++ b/examples/iot-lite/UpnpInternal.h
@@ -28,6 +28,8 @@
#include <string>
#include <vector>
+#define OC_SERVER
+#define OC_DYNAMIC_ALLOCATION
#include <oc_api.h>
#include <UpnpConstants.h>
@@ -56,6 +58,7 @@ static std::map<std::string, std::string > UpnpSearchPatternMap =
{UPNP_OIC_TYPE_BRIGHTNESS, UPNP_PREFIX_SERVICE + ":.*(?:[Dd]imming).*"},
{UPNP_OIC_TYPE_POWER_SWITCH, UPNP_PREFIX_SERVICE + ":.*(?:[Ss]witch[Pp]ower).*"},
// Media Control
+ {UPNP_OIC_TYPE_DEVICE_AV_PLAYER, UPNP_PREFIX_DEVICE + ":.*(?:[Mm]edia[Rr]enderer).*"},
{UPNP_OIC_TYPE_AUDIO, UPNP_PREFIX_SERVICE + ":.*(?:[Rr]endering[Cc]ontrol).*"},
{UPNP_OIC_TYPE_MEDIA_CONTROL, UPNP_PREFIX_SERVICE + ":.*(?:[Aa][Vv][Tt]ransport).*"}
};
@@ -71,11 +74,12 @@ static std::map<std::string, std::string > UpnpInterfaceMap =
{UPNP_OIC_TYPE_POWER_SWITCH, "oic.if.a"},
{UPNP_OIC_TYPE_BRIGHTNESS, "oic.if.a"},
// Media Control
- {UPNP_OIC_TYPE_DEVICE_MEDIA_RENDERER, "oic.if.baseline"},
- {UPNP_OIC_TYPE_DEVICE_MEDIA_SERVER, "oic.if.baseline"},
+ {UPNP_OIC_TYPE_DEVICE_AV_PLAYER, "oic.if.baseline"},
+ {UPNP_OIC_TYPE_AUDIO, "oic.if.a"},
+ {UPNP_OIC_TYPE_MEDIA_CONTROL, "oic.if.a"}
};
-// URI prexfix map
+// URI prefix map
// TODO and TBD
static std::map<std::string, std::string > UpnpUriPrefixMap =
{
@@ -83,8 +87,9 @@ static std::map<std::string, std::string > UpnpUriPrefixMap =
{UPNP_OIC_TYPE_BRIGHTNESS, UPNP_OIC_URI_PREFIX_BRIGHTNESS},
{UPNP_OIC_TYPE_POWER_SWITCH, UPNP_OIC_URI_PREFIX_POWER_SWITCH},
- {UPNP_OIC_TYPE_AV_TRANSPORT, UPNP_OIC_URI_PREFIX_AV_TRANSPORT},
- {UPNP_OIC_TYPE_RENDERING_CONTROL, UPNP_OIC_URI_PREFIX_RENDERING_CONTROL}
+ {UPNP_OIC_TYPE_DEVICE_AV_PLAYER, UPNP_OIC_URI_PREFIX_MEDIA_RENDERER},
+ {UPNP_OIC_TYPE_AUDIO, UPNP_OIC_URI_PREFIX_AUDIO},
+ {UPNP_OIC_TYPE_MEDIA_CONTROL, UPNP_OIC_URI_PREFIX_MEDIA_CONTROL}
};
#define ERROR_PRINT(x) do { std::cerr << MODULE << ":" << __func__ << "(): ERROR: " << x << std::endl; } while (0)
diff --git a/examples/iot-lite/UpnpManager.cpp b/examples/iot-lite/UpnpManager.cpp
index 8571686..02391b7 100644
--- a/examples/iot-lite/UpnpManager.cpp
+++ b/examples/iot-lite/UpnpManager.cpp
@@ -25,6 +25,8 @@
#include "UpnpDimmingService.h"
#include "UpnpPowerSwitchService.h"
+#include "UpnpAvTransportService.h"
+#include "UpnpRenderingControlService.h"
using namespace std;
@@ -367,6 +369,14 @@ std::shared_ptr<UpnpService> UpnpManager::generateService(GUPnPServiceInfo *ser
{
return (std::make_shared < UpnpDimming > (serviceInfo, requestState));
}
+ else if (resourceType == UPNP_OIC_TYPE_AUDIO)
+ {
+ return (std::make_shared < UpnpRenderingControl > (serviceInfo, requestState));
+ }
+ else if (resourceType == UPNP_OIC_TYPE_MEDIA_CONTROL)
+ {
+ return (std::make_shared < UpnpAvTransport > (serviceInfo, requestState));
+ }
else
{
//throw an exception
diff --git a/examples/iot-lite/UpnpPowerSwitchService.cpp b/examples/iot-lite/UpnpPowerSwitchService.cpp
index 103498a..20e5a36 100644
--- a/examples/iot-lite/UpnpPowerSwitchService.cpp
+++ b/examples/iot-lite/UpnpPowerSwitchService.cpp
@@ -53,7 +53,7 @@ void UpnpPowerSwitch::processGetRequest(oc_request_t *request, oc_interface_mask
oc_rep_start_root_object();
oc_process_baseline_interface(request->resource);
- DEBUG_PRINT("oc_rep_set_boolean " << powerSwitchStateName << " " << powerSwitchStateValue);
+ DEBUG_PRINT("oc_rep_set_boolean " << powerSwitchStateName << ": " << powerSwitchStateValue);
oc_rep_set_boolean(root, value, powerSwitchStateValue);
oc_rep_end_root_object();
oc_send_response(request, OC_STATUS_OK);
diff --git a/examples/iot-lite/UpnpRenderingControlService.cpp b/examples/iot-lite/UpnpRenderingControlService.cpp
new file mode 100644
index 0000000..8bcefa9
--- /dev/null
+++ b/examples/iot-lite/UpnpRenderingControlService.cpp
@@ -0,0 +1,199 @@
+//******************************************************************
+//
+// Copyright 2018 Intel Corporation All Rights Reserved.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+#include "UpnpRenderingControlService.h"
+
+static const string MODULE = "UpnpRenderingControlService";
+
+// Rendering Control Service
+
+static const char *mutePropertyName = "mute";
+static const char *volumePropertyName = "volume";
+
+static const char *getMuteAction = "GetMute";
+static const char *setMuteAction = "SetMute";
+static const char *getVolumeAction = "GetVolume";
+static const char *setVolumeAction = "SetVolume";
+
+static const char *instanceIdParamName = "InstanceID";
+static const char *channelParamName = "Channel";
+static const char *currentMuteParamName = "CurrentMute";
+static const char *desiredMuteParamName = "DesiredMute";
+static const char *currentVolumeParamName = "CurrentVolume";
+static const char *desiredVolumeParamName = "DesiredVolume";
+
+static const int defaultInstanceID = 0;
+static const char *defaultChannel = "Master";
+
+void UpnpRenderingControl::processGetRequest(oc_request_t *request, oc_interface_mask_t interface, void *user_data)
+{
+ DEBUG_PRINT("request->resource->name=" << oc_string(request->resource->name));
+ GUPnPServiceInfo *serviceInfo = (GUPnPServiceInfo *)user_data;
+ GUPnPServiceProxy *proxy = GUPNP_SERVICE_PROXY(serviceInfo);
+
+ bool muteValue = false;
+ int volumeValue = 0;
+ GError *error = NULL;
+
+ // get mute
+ if (! gupnp_service_proxy_send_action(proxy, getMuteAction, &error,
+ // IN args
+ instanceIdParamName, G_TYPE_UINT, defaultInstanceID,
+ channelParamName, G_TYPE_STRING, defaultChannel,
+ NULL,
+ // OUT args
+ currentMuteParamName, G_TYPE_BOOLEAN, &muteValue,
+ NULL))
+ {
+ ERROR_PRINT(getMuteAction << " action failed");
+ if (error)
+ {
+ DEBUG_PRINT("Error message: " << error->message);
+ g_error_free(error);
+ }
+ oc_send_response(request, OC_STATUS_INTERNAL_SERVER_ERROR);
+ return;
+ }
+
+ oc_rep_start_root_object();
+ oc_process_baseline_interface(request->resource);
+ DEBUG_PRINT("oc_rep_set_boolean " << mutePropertyName << ": " << muteValue);
+ oc_rep_set_boolean(root, mute, muteValue);
+
+ // get volume
+ if (! gupnp_service_proxy_send_action(proxy, getVolumeAction, &error,
+ // IN args
+ instanceIdParamName, G_TYPE_UINT, defaultInstanceID,
+ channelParamName, G_TYPE_STRING, defaultChannel,
+ NULL,
+ // OUT args
+ currentVolumeParamName, G_TYPE_UINT, &volumeValue,
+ NULL))
+ {
+ ERROR_PRINT(getVolumeAction << " action failed");
+ if (error)
+ {
+ DEBUG_PRINT("Error message: " << error->message);
+ g_error_free(error);
+ }
+ oc_send_response(request, OC_STATUS_INTERNAL_SERVER_ERROR);
+ return;
+ }
+
+ DEBUG_PRINT("oc_rep_set_int " << volumePropertyName << ": " << volumeValue);
+ oc_rep_set_int(root, volume, volumeValue);
+ oc_rep_end_root_object();
+ oc_send_response(request, OC_STATUS_OK);
+}
+
+void UpnpRenderingControl::processPostRequest(oc_request_t *request, oc_interface_mask_t interface, void *user_data)
+{
+ DEBUG_PRINT("request->resource->name=" << oc_string(request->resource->name));
+ GUPnPServiceInfo *serviceInfo = (GUPnPServiceInfo *)user_data;
+ GUPnPServiceProxy *proxy = GUPNP_SERVICE_PROXY(serviceInfo);
+
+ bool muteValue = false;
+ int volumeValue = 0;
+ oc_rep_t *rep = request->request_payload;
+ while (rep) {
+ DEBUG_PRINT("key=" << oc_string(rep->name) << ", rep type=" << rep->type);
+ char *key = (char *)(rep->name).ptr;
+// DEBUG_PRINT("char *key=" << key);
+ if (strncmp(key, mutePropertyName, (rep->name).size) == 0) {
+ switch (rep->type)
+ {
+ case OC_REP_BOOL:
+ muteValue = rep->value.boolean;
+ DEBUG_PRINT("New " << mutePropertyName << ": " << muteValue);
+ break;
+ default:
+ DEBUG_PRINT("Unexpected rep type: " << rep->type);
+ oc_send_response(request, OC_STATUS_BAD_REQUEST);
+ return;
+ }
+ }
+ if (strncmp(key, volumePropertyName, (rep->name).size) == 0) {
+ switch (rep->type)
+ {
+ case OC_REP_INT:
+ volumeValue = rep->value.integer;
+ DEBUG_PRINT("New " << volumePropertyName << ": " << volumeValue);
+ break;
+ default:
+ DEBUG_PRINT("Unexpected rep type: " << rep->type);
+ oc_send_response(request, OC_STATUS_BAD_REQUEST);
+ return;
+ }
+ }
+ rep = rep->next;
+ }
+
+ GError *error = NULL;
+
+ // set mute
+ if (!gupnp_service_proxy_send_action(proxy, setMuteAction, &error,
+ // IN args
+ instanceIdParamName, G_TYPE_UINT, defaultInstanceID,
+ channelParamName, G_TYPE_STRING, defaultChannel,
+ desiredMuteParamName, G_TYPE_BOOLEAN, muteValue,
+ NULL,
+ // OUT args (none)
+ NULL))
+ {
+ ERROR_PRINT(setMuteAction << " action failed");
+ if (error)
+ {
+ DEBUG_PRINT("Error message: " << error->message);
+ g_error_free(error);
+ }
+ oc_send_response(request, OC_STATUS_INTERNAL_SERVER_ERROR);
+ return;
+ }
+ DEBUG_PRINT("Set " << mutePropertyName << ": " << muteValue);
+
+ // set volume
+ if (!gupnp_service_proxy_send_action(proxy, setVolumeAction, &error,
+ // IN args
+ instanceIdParamName, G_TYPE_UINT, defaultInstanceID,
+ channelParamName, G_TYPE_STRING, defaultChannel,
+ desiredVolumeParamName, G_TYPE_UINT, volumeValue,
+ NULL,
+ // OUT args (none)
+ NULL))
+ {
+ ERROR_PRINT(setVolumeAction << " action failed");
+ if (error)
+ {
+ DEBUG_PRINT("Error message: " << error->message);
+ g_error_free(error);
+ }
+ oc_send_response(request, OC_STATUS_INTERNAL_SERVER_ERROR);
+ return;
+ }
+ DEBUG_PRINT("Set " << volumePropertyName << ": " << volumeValue);
+
+ oc_send_response(request, OC_STATUS_CHANGED);
+}
+
+
+void UpnpRenderingControl::processPutRequest(oc_request_t *request, oc_interface_mask_t interface, void *user_data)
+{
+ return processPostRequest(request, interface, user_data);
+}
diff --git a/examples/iot-lite/UpnpRenderingControlService.h b/examples/iot-lite/UpnpRenderingControlService.h
new file mode 100644
index 0000000..288e8a2
--- /dev/null
+++ b/examples/iot-lite/UpnpRenderingControlService.h
@@ -0,0 +1,52 @@
+//******************************************************************
+//
+// Copyright 2018 Intel Corporation All Rights Reserved.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+#ifndef UPNP_RENDERING_CONTROL_H_
+#define UPNP_RENDERING_CONTROL_H_
+
+#include <string>
+#include <map>
+
+#include <gupnp.h>
+
+#include "UpnpResource.h"
+#include "UpnpInternal.h"
+#include "UpnpService.h"
+
+using namespace std;
+
+class UpnpRenderingControl: public UpnpService
+{
+
+ public:
+ UpnpRenderingControl(GUPnPServiceInfo *serviceInfo, UpnpRequestState *requestState) :
+ UpnpService(serviceInfo, UPNP_OIC_TYPE_AUDIO, requestState)
+ {
+ }
+
+ static void processGetRequest(oc_request_t *request, oc_interface_mask_t interface, void *user_data);
+ static void processPostRequest(oc_request_t *request, oc_interface_mask_t interface, void *user_data);
+ static void processPutRequest(oc_request_t *request, oc_interface_mask_t interface, void *user_data);
+
+ private:
+
+};
+
+#endif
diff --git a/examples/iot-lite/UpnpService.cpp b/examples/iot-lite/UpnpService.cpp
index d4ce851..5b3b51d 100644
--- a/examples/iot-lite/UpnpService.cpp
+++ b/examples/iot-lite/UpnpService.cpp
@@ -29,6 +29,8 @@
#include "UpnpDimmingService.h"
#include "UpnpPowerSwitchService.h"
+#include "UpnpAvTransportService.h"
+#include "UpnpRenderingControlService.h"
using namespace std;
@@ -178,17 +180,25 @@ void UpnpService::processGetRequest(oc_request_t *request, oc_interface_mask_t i
for (int i = 0; i < (int)oc_string_array_get_allocated_size(request->resource->types); i++)
{
-// size_t size = oc_string_array_get_item_size(request->resource->types, i);
- const char *type = oc_string_array_get_item(request->resource->types, i);
- DEBUG_PRINT("request->resource->type[" << i << "]=" << type);
- if (string(type) == UPNP_OIC_TYPE_POWER_SWITCH)
- {
- return UpnpPowerSwitch::processGetRequest(request, interface, user_data);
- }
- if (string(type) == UPNP_OIC_TYPE_BRIGHTNESS)
- {
- return UpnpDimming::processGetRequest(request, interface, user_data);
- }
+// size_t size = oc_string_array_get_item_size(request->resource->types, i);
+ const char *type = oc_string_array_get_item(request->resource->types, i);
+ DEBUG_PRINT("request->resource->type[" << i << "]=" << type);
+ if (string(type) == UPNP_OIC_TYPE_POWER_SWITCH)
+ {
+ return UpnpPowerSwitch::processGetRequest(request, interface, user_data);
+ }
+ if (string(type) == UPNP_OIC_TYPE_BRIGHTNESS)
+ {
+ return UpnpDimming::processGetRequest(request, interface, user_data);
+ }
+ if (string(type) == UPNP_OIC_TYPE_AUDIO)
+ {
+ return UpnpRenderingControl::processGetRequest(request, interface, user_data);
+ }
+ if (string(type) == UPNP_OIC_TYPE_MEDIA_CONTROL)
+ {
+ return UpnpAvTransport::processGetRequest(request, interface, user_data);
+ }
}
}
@@ -217,17 +227,25 @@ void UpnpService::processPostRequest(oc_request_t *request, oc_interface_mask_t
for (int i = 0; i < (int)oc_string_array_get_allocated_size(request->resource->types); i++)
{
-// size_t size = oc_string_array_get_item_size(request->resource->types, i);
- const char *type = oc_string_array_get_item(request->resource->types, i);
- DEBUG_PRINT("request->resource->type[" << i << "]=" << type);
- if (string(type) == UPNP_OIC_TYPE_POWER_SWITCH)
- {
- return UpnpPowerSwitch::processPostRequest(request, interface, user_data);
- }
- if (string(type) == UPNP_OIC_TYPE_BRIGHTNESS)
- {
- return UpnpDimming::processPostRequest(request, interface, user_data);
- }
+// size_t size = oc_string_array_get_item_size(request->resource->types, i);
+ const char *type = oc_string_array_get_item(request->resource->types, i);
+ DEBUG_PRINT("request->resource->type[" << i << "]=" << type);
+ if (string(type) == UPNP_OIC_TYPE_POWER_SWITCH)
+ {
+ return UpnpPowerSwitch::processPostRequest(request, interface, user_data);
+ }
+ if (string(type) == UPNP_OIC_TYPE_BRIGHTNESS)
+ {
+ return UpnpDimming::processPostRequest(request, interface, user_data);
+ }
+ if (string(type) == UPNP_OIC_TYPE_AUDIO)
+ {
+ return UpnpRenderingControl::processPostRequest(request, interface, user_data);
+ }
+ if (string(type) == UPNP_OIC_TYPE_MEDIA_CONTROL)
+ {
+ return UpnpAvTransport::processPostRequest(request, interface, user_data);
+ }
}
}
diff --git a/include/UpnpConstants.h b/include/UpnpConstants.h
index 8eb601b..0c62e2b 100644
--- a/include/UpnpConstants.h
+++ b/include/UpnpConstants.h
@@ -33,6 +33,7 @@ static const std::string UPNP_OIC_TYPE_DEVICE_INET_GATEWAY = "oic.d.inet.
static const std::string UPNP_OIC_TYPE_DEVICE_WAN = "oic.d.wan";
static const std::string UPNP_OIC_TYPE_DEVICE_WAN_CONNECTION = "oic.d.wan.connection";
static const std::string UPNP_OIC_TYPE_DEVICE_LAN = "oic.d.lan";
+static const std::string UPNP_OIC_TYPE_DEVICE_AV_PLAYER = "oic.d.avplayer";
static const std::string UPNP_OIC_TYPE_DEVICE_MEDIA_RENDERER = "oic.d.media.renderer";
static const std::string UPNP_OIC_TYPE_DEVICE_MEDIA_SERVER = "oic.d.media.server";