summaryrefslogtreecommitdiff
path: root/src/components/protocol_handler
diff options
context:
space:
mode:
authorSho Amano <samano@xevo.com>2017-08-10 23:13:38 +0900
committerSho Amano <samano@xevo.com>2017-08-11 10:45:51 +0900
commit6c3aa1059982dd9012edb6fb747f1ed77d000db4 (patch)
treeaf0181614dd86145b67accbb40d01fdb1ff4aa2b /src/components/protocol_handler
parent2f9746c4c3f09cc90be0fbaa7a9e58038fe363ec (diff)
downloadsdl_core-6c3aa1059982dd9012edb6fb747f1ed77d000db4.tar.gz
Append video releated parameters in Start Service ACK packet
Reflecting review comments.
Diffstat (limited to 'src/components/protocol_handler')
-rw-r--r--src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h49
-rw-r--r--src/components/protocol_handler/src/protocol_handler_impl.cc84
-rw-r--r--src/components/protocol_handler/test/protocol_handler_tm_test.cc20
3 files changed, 145 insertions, 8 deletions
diff --git a/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h b/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h
index c312d34aed..af12fc288d 100644
--- a/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h
+++ b/src/components/protocol_handler/include/protocol_handler/protocol_handler_impl.h
@@ -264,6 +264,29 @@ class ProtocolHandlerImpl
* mobile app for using when ending session
* \param service_type Type of session: RPC or BULK Data. RPC by default
* \param protection Protection flag
+ * \param additional_params Additional parameters added in the payload. Can
+ * be NULL.
+ */
+ void SendStartSessionAck(ConnectionID connection_id,
+ uint8_t session_id,
+ uint8_t protocol_version,
+ uint32_t hash_code,
+ uint8_t service_type,
+ bool protection,
+ const BsonObject* additional_params);
+
+ /**
+ * \brief Sends acknowledgement of starting session to mobile application
+ * with session number and hash code for second version of protocol
+ * was started
+ * \param connection_id Identifier of connection within which session
+ * \param session_id ID of session to be sent to mobile application
+ * \param protocol_version Version of protocol used for communication
+ * \param hash_code For second version of protocol: identifier of session
+ * to be sent to
+ * mobile app for using when ending session
+ * \param service_type Type of session: RPC or BULK Data. RPC by default
+ * \param protection Protection flag
* \param full_version full protocol version (major.minor.patch) used by the
* mobile proxy
*/
@@ -275,6 +298,32 @@ class ProtocolHandlerImpl
bool protection,
ProtocolPacket::ProtocolVersion& full_version);
+ /**
+ * \brief Sends acknowledgement of starting session to mobile application
+ * with session number and hash code for second version of protocol
+ * was started
+ * \param connection_id Identifier of connection within which session
+ * \param session_id ID of session to be sent to mobile application
+ * \param protocol_version Version of protocol used for communication
+ * \param hash_code For second version of protocol: identifier of session
+ * to be sent to
+ * mobile app for using when ending session
+ * \param service_type Type of session: RPC or BULK Data. RPC by default
+ * \param protection Protection flag
+ * \param full_version full protocol version (major.minor.patch) used by the
+ * mobile proxy
+ * \param additional_params Additional parameters added in the payload. Can
+ * be NULL.
+ */
+ void SendStartSessionAck(ConnectionID connection_id,
+ uint8_t session_id,
+ uint8_t protocol_version,
+ uint32_t hash_code,
+ uint8_t service_type,
+ bool protection,
+ ProtocolPacket::ProtocolVersion& full_version,
+ const BsonObject* additional_params);
+
const ProtocolHandlerSettings& get_settings() const OVERRIDE {
return settings_;
}
diff --git a/src/components/protocol_handler/src/protocol_handler_impl.cc b/src/components/protocol_handler/src/protocol_handler_impl.cc
index 4eb01cec12..a8f0c5a65d 100644
--- a/src/components/protocol_handler/src/protocol_handler_impl.cc
+++ b/src/components/protocol_handler/src/protocol_handler_impl.cc
@@ -212,8 +212,50 @@ void ProtocolHandlerImpl::SendStartSessionAck(
uint32_t hash_id,
uint8_t service_type,
bool protection,
+ const BsonObject* additional_params) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ ProtocolPacket::ProtocolVersion* fullVersion =
+ new ProtocolPacket::ProtocolVersion();
+ SendStartSessionAck(connection_id,
+ session_id,
+ protocol_version,
+ hash_id,
+ service_type,
+ protection,
+ *fullVersion,
+ additional_params);
+ delete fullVersion;
+}
+
+void ProtocolHandlerImpl::SendStartSessionAck(
+ ConnectionID connection_id,
+ uint8_t session_id,
+ uint8_t protocol_version,
+ uint32_t hash_id,
+ uint8_t service_type,
+ bool protection,
ProtocolPacket::ProtocolVersion& full_version) {
LOG4CXX_AUTO_TRACE(logger_);
+ SendStartSessionAck(connection_id,
+ session_id,
+ protocol_version,
+ hash_id,
+ service_type,
+ protection,
+ full_version,
+ NULL);
+}
+
+void ProtocolHandlerImpl::SendStartSessionAck(
+ ConnectionID connection_id,
+ uint8_t session_id,
+ uint8_t protocol_version,
+ uint32_t hash_id,
+ uint8_t service_type,
+ bool protection,
+ ProtocolPacket::ProtocolVersion& full_version,
+ const BsonObject* additional_params) {
+ LOG4CXX_AUTO_TRACE(logger_);
uint8_t maxProtocolVersion = SupportedSDLProtocolVersion();
@@ -259,6 +301,27 @@ void ProtocolHandlerImpl::SendStartSessionAck(
strncpy(protocolVersionString, (*minVersion).to_string().c_str(), 255);
bson_object_put_string(
&payloadObj, strings::protocol_version, protocolVersionString);
+ } else if (serviceTypeValue == kMobileNav && additional_params != NULL) {
+ BsonObject* input = const_cast<BsonObject*>(additional_params);
+ BsonElement* element = NULL;
+ if ((element = bson_object_get(input, "height")) != NULL &&
+ element->type == TYPE_INT32) {
+ bson_object_put_int32(
+ &payloadObj, "height", bson_object_get_int32(input, "height"));
+ }
+ if ((element = bson_object_get(input, "width")) != NULL &&
+ element->type == TYPE_INT32) {
+ bson_object_put_int32(
+ &payloadObj, "width", bson_object_get_int32(input, "width"));
+ }
+ char* protocol = bson_object_get_string(input, "videoProtocol");
+ if (protocol != NULL) {
+ bson_object_put_string(&payloadObj, "videoProtocol", protocol);
+ }
+ char* codec = bson_object_get_string(input, "videoCodec");
+ if (codec != NULL) {
+ bson_object_put_string(&payloadObj, "videoCodec", codec);
+ }
}
uint8_t* payloadBytes = bson_object_to_bytes(&payloadObj);
ptr->set_data(payloadBytes, bson_object_size(&payloadObj));
@@ -1483,6 +1546,15 @@ void ProtocolHandlerImpl::NotifySessionStartedResult(
return;
}
+ BsonObject input_param;
+ if (packet->service_type() == kMobileNav && packet->data() != NULL) {
+ // when video service is successfully started, copy input parameters
+ // ("width", "height", "videoProtocol", "videoCodec") to the ACK packet
+ input_param = bson_object_from_bytes(packet->data());
+ } else {
+ bson_object_initialize_default(&input_param);
+ }
+
#ifdef ENABLE_SECURITY
// for packet is encrypted and security plugin is enable
if (protection && security_manager_) {
@@ -1504,7 +1576,9 @@ void ProtocolHandlerImpl::NotifySessionStartedResult(
packet->protocol_version(),
hash_id,
packet->service_type(),
- PROTECTION_OFF);
+ PROTECTION_OFF,
+ &input_param);
+ bson_object_deinitialize(&input_param);
return;
}
ProtocolPacket::ProtocolVersion* fullVersion;
@@ -1540,7 +1614,8 @@ void ProtocolHandlerImpl::NotifySessionStartedResult(
hash_id,
packet->service_type(),
PROTECTION_ON,
- *fullVersion);
+ *fullVersion,
+ &input_param);
} else {
security_manager_->AddListener(
new StartSessionHandler(connection_key,
@@ -1559,6 +1634,7 @@ void ProtocolHandlerImpl::NotifySessionStartedResult(
}
}
delete fullVersion;
+ bson_object_deinitialize(&input_param);
LOG4CXX_DEBUG(logger_,
"Protection establishing for connection "
<< connection_key << " is in progress");
@@ -1597,8 +1673,10 @@ void ProtocolHandlerImpl::NotifySessionStartedResult(
packet->protocol_version(),
hash_id,
packet->service_type(),
- PROTECTION_OFF);
+ PROTECTION_OFF,
+ &input_param);
}
+ bson_object_deinitialize(&input_param);
}
RESULT_CODE ProtocolHandlerImpl::HandleControlMessageHeartBeat(
diff --git a/src/components/protocol_handler/test/protocol_handler_tm_test.cc b/src/components/protocol_handler/test/protocol_handler_tm_test.cc
index 7a7a8dd611..ce167f1177 100644
--- a/src/components/protocol_handler/test/protocol_handler_tm_test.cc
+++ b/src/components/protocol_handler/test/protocol_handler_tm_test.cc
@@ -654,12 +654,22 @@ TEST_F(ProtocolHandlerImplTest,
ByRef(empty))));
times++;
+ BsonObject bson_ack_params;
+ bson_object_initialize_default(&bson_ack_params);
+ bson_object_put_int64(&bson_ack_params, "mtu", maximum_payload_size);
+ bson_object_put_string(
+ &bson_ack_params, "videoProtocol", const_cast<char*>("RAW"));
+ bson_object_put_string(
+ &bson_ack_params, "videoCodec", const_cast<char*>("H264"));
+ std::vector<uint8_t> ack_params =
+ CreateVectorFromBsonObject(&bson_ack_params);
+ bson_object_deinitialize(&bson_ack_params);
+
EXPECT_CALL(transport_manager_mock,
- SendMessageToDevice(ControlMessage(
- FRAME_DATA_START_SERVICE_ACK,
- PROTECTION_OFF,
- connection_id1,
- _))) // skip checking of non-video parameters like mtu
+ SendMessageToDevice(ControlMessage(FRAME_DATA_START_SERVICE_ACK,
+ PROTECTION_OFF,
+ connection_id1,
+ Eq(ack_params))))
.WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(E_SUCCESS)));
times++;