summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Keeler <jacob.keeler@livioradio.com>2017-09-26 13:06:20 -0400
committerGitHub <noreply@github.com>2017-09-26 13:06:20 -0400
commita0b988640af96278f4ff128968e2f4cb1b791b3f (patch)
tree2cd887f57244781c6c138cae28824d1ef191b306
parent66009e95ebb95fa027e6d7b3693ecd771ebf2139 (diff)
parent694b039b12c4129096e3ad5ba8681f4151df2792 (diff)
downloadsdl_core-a0b988640af96278f4ff128968e2f4cb1b791b3f.tar.gz
Merge pull request #1784 from smartdevicelink/fix/video_capabilities_validation
Validate outgoing video params
-rw-r--r--src/components/protocol_handler/src/protocol_handler_impl.cc31
1 files changed, 28 insertions, 3 deletions
diff --git a/src/components/protocol_handler/src/protocol_handler_impl.cc b/src/components/protocol_handler/src/protocol_handler_impl.cc
index 7f30017856..35a3fb032a 100644
--- a/src/components/protocol_handler/src/protocol_handler_impl.cc
+++ b/src/components/protocol_handler/src/protocol_handler_impl.cc
@@ -1538,12 +1538,37 @@ void ProtocolHandlerImpl::NotifySessionStartedResult(
}
BsonObject start_session_ack_params;
+ bson_object_initialize_default(&start_session_ack_params);
// when video service is successfully started, copy input parameters
// ("width", "height", "videoProtocol", "videoCodec") to the ACK packet
if (packet->service_type() == kMobileNav && packet->data() != NULL) {
- start_session_ack_params = bson_object_from_bytes(packet->data());
- } else {
- bson_object_initialize_default(&start_session_ack_params);
+ BsonObject req_param = bson_object_from_bytes(packet->data());
+ BsonElement* element = NULL;
+
+ if ((element = bson_object_get(&req_param, strings::height)) != NULL &&
+ element->type == TYPE_INT32) {
+ bson_object_put_int32(&start_session_ack_params,
+ strings::height,
+ bson_object_get_int32(&req_param, strings::height));
+ }
+ if ((element = bson_object_get(&req_param, strings::width)) != NULL &&
+ element->type == TYPE_INT32) {
+ bson_object_put_int32(&start_session_ack_params,
+ strings::width,
+ bson_object_get_int32(&req_param, strings::width));
+ }
+ char* protocol =
+ bson_object_get_string(&req_param, strings::video_protocol);
+ if (protocol != NULL) {
+ bson_object_put_string(
+ &start_session_ack_params, strings::video_protocol, protocol);
+ }
+ char* codec = bson_object_get_string(&req_param, strings::video_codec);
+ if (codec != NULL) {
+ bson_object_put_string(
+ &start_session_ack_params, strings::video_codec, codec);
+ }
+ bson_object_deinitialize(&req_param);
}
ProtocolPacket::ProtocolVersion* fullVersion;