Skip to content

Commit 88dd3a5

Browse files
authored
Merge pull request #302 from LuxoftSDL/feature/0296_possibility_to_update_video_streaming_capabilities
Feature/0296 possibility to update video streaming capabilities
2 parents 88907de + d379570 commit 88dd3a5

File tree

11 files changed

+472
-2
lines changed

11 files changed

+472
-2
lines changed

lib/js/src/rpc/RpcCreator.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ import { GetWayPoints } from './messages/GetWayPoints.js';
9191
import { GetWayPointsResponse } from './messages/GetWayPointsResponse.js';
9292
import { ListFiles } from './messages/ListFiles.js';
9393
import { ListFilesResponse } from './messages/ListFilesResponse.js';
94+
import { OnAppCapabilityUpdated } from './messages/OnAppCapabilityUpdated.js';
9495
import { OnAppInterfaceUnregistered } from './messages/OnAppInterfaceUnregistered.js';
9596
import { OnAppServiceData } from './messages/OnAppServiceData.js';
9697
import { OnAudioPassThru } from './messages/OnAudioPassThru.js';
@@ -759,6 +760,11 @@ class RpcCreator {
759760
message = new OnSystemCapabilityUpdated(params);
760761
}
761762
break;
763+
case FunctionID.OnAppCapabilityUpdated:
764+
if (messageType === MessageType.notification) {
765+
message = new OnAppCapabilityUpdated(params);
766+
}
767+
break;
762768
case FunctionID.OnUpdateFile:
763769
if (messageType === MessageType.notification) {
764770
message = new OnUpdateFile(params);
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/* eslint-disable camelcase */
2+
/*
3+
* Copyright (c) 2020, SmartDeviceLink Consortium, Inc.
4+
* All rights reserved.
5+
*
6+
* Redistribution and use in source and binary forms, with or without
7+
* modification, are permitted provided that the following conditions are met:
8+
*
9+
* Redistributions of source code must retain the above copyright notice, this
10+
* list of conditions and the following disclaimer.
11+
*
12+
* Redistributions in binary form must reproduce the above copyright notice,
13+
* this list of conditions and the following
14+
* disclaimer in the documentation and/or other materials provided with the
15+
* distribution.
16+
*
17+
* Neither the name of the SmartDeviceLink Consortium Inc. nor the names of
18+
* its contributors may be used to endorse or promote products derived
19+
* from this software without specific prior written permission.
20+
*
21+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31+
* POSSIBILITY OF SUCH DAMAGE.
32+
*/
33+
34+
import { Enum } from '../../util/Enum.js';
35+
36+
/**
37+
* Enumerations of all available app capability types
38+
* @typedef {Enum} AppCapabilityType
39+
* @property {Object} _MAP
40+
*/
41+
class AppCapabilityType extends Enum {
42+
/**
43+
* Constructor for AppCapabilityType.
44+
* @class
45+
* @since SmartDeviceLink 7.1.0
46+
*/
47+
constructor () {
48+
super();
49+
}
50+
51+
/**
52+
* Get the enum value for VIDEO_STREAMING.
53+
* @returns {String} - The enum value.
54+
*/
55+
static get VIDEO_STREAMING () {
56+
return AppCapabilityType._MAP.VIDEO_STREAMING;
57+
}
58+
59+
/**
60+
* Get the value for the given enum key
61+
* @param {*} key - A key to find in the map of the subclass
62+
* @returns {*} - Returns a value if found, or null if not found
63+
*/
64+
static valueForKey (key) {
65+
return AppCapabilityType._valueForKey(key, AppCapabilityType._MAP);
66+
}
67+
68+
/**
69+
* Get the key for the given enum value
70+
* @param {*} value - A primitive value to find the matching key for in the map of the subclass
71+
* @returns {*} - Returns a key if found, or null if not found
72+
*/
73+
static keyForValue (value) {
74+
return AppCapabilityType._keyForValue(value, AppCapabilityType._MAP);
75+
}
76+
77+
/**
78+
* Retrieve all enumerated values for this class
79+
* @returns {*} - Returns an array of values
80+
*/
81+
static values () {
82+
return Object.values(AppCapabilityType._MAP);
83+
}
84+
}
85+
86+
AppCapabilityType._MAP = Object.freeze({
87+
'VIDEO_STREAMING': 'VIDEO_STREAMING',
88+
});
89+
90+
export { AppCapabilityType };

lib/js/src/rpc/enums/FunctionID.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,14 @@ class FunctionID extends Enum {
813813
return FunctionID._MAP.OnSubtleAlertPressed;
814814
}
815815

816+
/**
817+
* Get the enum value for OnAppCapabilityUpdated.
818+
* @returns {Number} - The enum value.
819+
*/
820+
static get OnAppCapabilityUpdated () {
821+
return FunctionID._MAP.OnAppCapabilityUpdated;
822+
}
823+
816824
/**
817825
* Get the enum value for OnUpdateFile.
818826
* @since SmartDeviceLink 7.0.0
@@ -982,10 +990,11 @@ FunctionID._MAP = Object.freeze({
982990
'OnSubtleAlertPressed': 0x8014,
983991
'OnUpdateFile': 0x8015,
984992
'OnUpdateSubMenu': 0x8016,
993+
'OnAppCapabilityUpdated': 0x8017,
985994
'EncodedSyncPData': 0x10000,
986995
'SyncPData': 0x10001,
987996
'OnEncodedSyncPData': 0x18000,
988997
'OnSyncPData': 0x18001,
989998
});
990999

991-
export { FunctionID };
1000+
export { FunctionID };
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/* eslint-disable camelcase */
2+
/*
3+
* Copyright (c) 2020, SmartDeviceLink Consortium, Inc.
4+
* All rights reserved.
5+
*
6+
* Redistribution and use in source and binary forms, with or without
7+
* modification, are permitted provided that the following conditions are met:
8+
*
9+
* Redistributions of source code must retain the above copyright notice, this
10+
* list of conditions and the following disclaimer.
11+
*
12+
* Redistributions in binary form must reproduce the above copyright notice,
13+
* this list of conditions and the following
14+
* disclaimer in the documentation and/or other materials provided with the
15+
* distribution.
16+
*
17+
* Neither the name of the SmartDeviceLink Consortium Inc. nor the names of
18+
* its contributors may be used to endorse or promote products derived
19+
* from this software without specific prior written permission.
20+
*
21+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31+
* POSSIBILITY OF SUCH DAMAGE.
32+
*/
33+
34+
import { AppCapability } from '../structs/AppCapability.js';
35+
import { FunctionID } from '../enums/FunctionID.js';
36+
import { RpcNotification } from '../RpcNotification.js';
37+
38+
/**
39+
* A notification to inform SDL Core that a specific app capability has changed.
40+
*/
41+
class OnAppCapabilityUpdated extends RpcNotification {
42+
/**
43+
* Initalizes an instance of OnAppCapabilityUpdated.
44+
* @class
45+
* @param {object} parameters - An object map of parameters.
46+
* @since SmartDeviceLink 7.1.0
47+
*/
48+
constructor (parameters) {
49+
super(parameters);
50+
this.setFunctionId(FunctionID.OnAppCapabilityUpdated);
51+
}
52+
53+
/**
54+
* Set the AppCapability
55+
* @param {AppCapability} capability - The app capability that has been updated - The desired AppCapability.
56+
* @returns {OnAppCapabilityUpdated} - The class instance for method chaining.
57+
*/
58+
setAppCapability (capability) {
59+
this._validateType(AppCapability, capability);
60+
this.setParameter(OnAppCapabilityUpdated.KEY_APP_CAPABILITY, capability);
61+
return this;
62+
}
63+
64+
/**
65+
* Get the AppCapability
66+
* @returns {AppCapability} - the KEY_APP_CAPABILITY value
67+
*/
68+
getAppCapability () {
69+
return this.getObject(AppCapability, OnAppCapabilityUpdated.KEY_APP_CAPABILITY);
70+
}
71+
}
72+
73+
OnAppCapabilityUpdated.KEY_APP_CAPABILITY = 'appCapability';
74+
75+
export { OnAppCapabilityUpdated };
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/* eslint-disable camelcase */
2+
/*
3+
* Copyright (c) 2020, SmartDeviceLink Consortium, Inc.
4+
* All rights reserved.
5+
*
6+
* Redistribution and use in source and binary forms, with or without
7+
* modification, are permitted provided that the following conditions are met:
8+
*
9+
* Redistributions of source code must retain the above copyright notice, this
10+
* list of conditions and the following disclaimer.
11+
*
12+
* Redistributions in binary form must reproduce the above copyright notice,
13+
* this list of conditions and the following
14+
* disclaimer in the documentation and/or other materials provided with the
15+
* distribution.
16+
*
17+
* Neither the name of the SmartDeviceLink Consortium Inc. nor the names of
18+
* its contributors may be used to endorse or promote products derived
19+
* from this software without specific prior written permission.
20+
*
21+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31+
* POSSIBILITY OF SUCH DAMAGE.
32+
*/
33+
34+
import { AppCapabilityType } from '../enums/AppCapabilityType.js';
35+
import { RpcStruct } from '../RpcStruct.js';
36+
import { VideoStreamingCapability } from './VideoStreamingCapability.js';
37+
38+
class AppCapability extends RpcStruct {
39+
/**
40+
* Initalizes an instance of AppCapability.
41+
* @class
42+
* @param {object} parameters - An object map of parameters.
43+
* @since SmartDeviceLink 7.1.0
44+
*/
45+
constructor (parameters) {
46+
super(parameters);
47+
}
48+
49+
/**
50+
* Set the AppCapabilityType
51+
* @param {AppCapabilityType} type - Used as a descriptor of what data to expect in this struct. The corresponding param to this enum should be included and the only other param included. - The desired AppCapabilityType.
52+
* @returns {AppCapability} - The class instance for method chaining.
53+
*/
54+
setAppCapabilityType (type) {
55+
this._validateType(AppCapabilityType, type);
56+
this.setParameter(AppCapability.KEY_APP_CAPABILITY_TYPE, type);
57+
return this;
58+
}
59+
60+
/**
61+
* Get the AppCapabilityType
62+
* @returns {AppCapabilityType} - the KEY_APP_CAPABILITY_TYPE value
63+
*/
64+
getAppCapabilityType () {
65+
return this.getObject(AppCapabilityType, AppCapability.KEY_APP_CAPABILITY_TYPE);
66+
}
67+
68+
/**
69+
* Set the VideoStreamingCapability
70+
* @param {VideoStreamingCapability} capability - Describes supported capabilities for video streaming - The desired VideoStreamingCapability.
71+
* @returns {AppCapability} - The class instance for method chaining.
72+
*/
73+
setVideoStreamingCapability (capability) {
74+
this._validateType(VideoStreamingCapability, capability);
75+
this.setParameter(AppCapability.KEY_VIDEO_STREAMING_CAPABILITY, capability);
76+
return this;
77+
}
78+
79+
/**
80+
* Get the VideoStreamingCapability
81+
* @returns {VideoStreamingCapability} - the KEY_VIDEO_STREAMING_CAPABILITY value
82+
*/
83+
getVideoStreamingCapability () {
84+
return this.getObject(VideoStreamingCapability, AppCapability.KEY_VIDEO_STREAMING_CAPABILITY);
85+
}
86+
}
87+
88+
AppCapability.KEY_APP_CAPABILITY_TYPE = 'appCapabilityType';
89+
AppCapability.KEY_VIDEO_STREAMING_CAPABILITY = 'videoStreamingCapability';
90+
91+
export { AppCapability };

lib/js/src/rpc/structs/VideoStreamingCapability.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,27 @@ class VideoStreamingCapability extends RpcStruct {
202202
getPreferredFPS () {
203203
return this.getParameter(VideoStreamingCapability.KEY_PREFERRED_FPS);
204204
}
205+
206+
/**
207+
* Set the AdditionalVideoStreamingCapabilities
208+
* @since SmartDeviceLink 7.1.0
209+
* @param {VideoStreamingCapability[]} capabilities - Contains information about this system's video streaming capabilities. - The desired AdditionalVideoStreamingCapabilities.
210+
* {'array_min_size': 1, 'array_max_size': 100}
211+
* @returns {VideoStreamingCapability} - The class instance for method chaining.
212+
*/
213+
setAdditionalVideoStreamingCapabilities (capabilities) {
214+
this._validateType(VideoStreamingCapability, capabilities, true);
215+
this.setParameter(VideoStreamingCapability.KEY_ADDITIONAL_VIDEO_STREAMING_CAPABILITIES, capabilities);
216+
return this;
217+
}
218+
219+
/**
220+
* Get the AdditionalVideoStreamingCapabilities
221+
* @returns {VideoStreamingCapability[]} - the KEY_ADDITIONAL_VIDEO_STREAMING_CAPABILITIES value
222+
*/
223+
getAdditionalVideoStreamingCapabilities () {
224+
return this.getObject(VideoStreamingCapability, VideoStreamingCapability.KEY_ADDITIONAL_VIDEO_STREAMING_CAPABILITIES);
225+
}
205226
}
206227

207228
VideoStreamingCapability.KEY_PREFERRED_RESOLUTION = 'preferredResolution';
@@ -212,5 +233,6 @@ VideoStreamingCapability.KEY_DIAGONAL_SCREEN_SIZE = 'diagonalScreenSize';
212233
VideoStreamingCapability.KEY_PIXEL_PER_INCH = 'pixelPerInch';
213234
VideoStreamingCapability.KEY_SCALE = 'scale';
214235
VideoStreamingCapability.KEY_PREFERRED_FPS = 'preferredFPS';
236+
VideoStreamingCapability.KEY_ADDITIONAL_VIDEO_STREAMING_CAPABILITIES = 'additionalVideoStreamingCapabilities';
215237

216-
export { VideoStreamingCapability };
238+
export { VideoStreamingCapability };

tests/Test.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ const ClimateData = SDL.rpc.structs.ClimateData;
3636
const KeyboardLayoutCapability = SDL.rpc.structs.KeyboardLayoutCapability;
3737
const DynamicUpdateCapabilities = SDL.rpc.structs.DynamicUpdateCapabilities;
3838
const KeyboardCapabilities = SDL.rpc.structs.KeyboardCapabilities;
39+
const AppCapability = SDL.rpc.structs.AppCapability;
40+
const VideoStreamingCapability = SDL.rpc.structs.VideoStreamingCapability;
3941

4042
// enums
4143
const SpeechCapabilities = SDL.rpc.enums.SpeechCapabilities;
@@ -71,6 +73,7 @@ const KeyboardLayout = SDL.rpc.enums.KeyboardLayout;
7173
const KeypressMode = SDL.rpc.enums.KeypressMode;
7274
const KeyboardInputMask = SDL.rpc.enums.KeyboardInputMask;
7375
const MenuLayout = SDL.rpc.enums.MenuLayout;
76+
const AppCapabilityType = SDL.rpc.enums.AppCapabilityType;
7477

7578
class Test {
7679
constructor () {
@@ -612,4 +615,21 @@ const JSON_KEYBOARDCAPABILITIES = Test.JSON_KEYBOARDCAPABILITIES = {
612615
[KeyboardCapabilities.KEY_SUPPORTED_KEYBOARDS]: Test.JSON_KEYBOARDLAYOUTCAPABILITY_LIST,
613616
};
614617

618+
const GENERAL_VIDEO_STREAMING_CAPABILITY = Test.GENERAL_VIDEO_STREAMING_CAPABILITY = new VideoStreamingCapability()
619+
.setAdditionalVideoStreamingCapabilities([new VideoStreamingCapability()]);
620+
621+
const JSON_VIDEO_STREAMING_CAPABILITY = Test.JSON_VIDEO_STREAMING_CAPABILITY = {
622+
[VideoStreamingCapability.KEY_ADDITIONAL_VIDEO_STREAMING_CAPABILITIES]: [new VideoStreamingCapability().getParameters()],
623+
};
624+
625+
const GENERAL_APP_CAPABILITY_TYPE = Test.GENERAL_APP_CAPABILITY_TYPE = AppCapabilityType.VIDEO_STREAMING;
626+
const GENERAL_APP_CAPABILITY = Test.GENERAL_APP_CAPABILITY = new AppCapability()
627+
.setAppCapabilityType(Test.GENERAL_APP_CAPABILITY_TYPE)
628+
.setVideoStreamingCapability(Test.GENERAL_VIDEO_STREAMING_CAPABILITY);
629+
630+
const JSON_APP_CAPABILITY = Test.JSON_APP_CAPABILITY = {
631+
[AppCapability.KEY_APP_CAPABILITY_TYPE]: Test.GENERAL_APP_CAPABILITY_TYPE,
632+
[AppCapability.KEY_VIDEO_STREAMING_CAPABILITY]: Test.JSON_VIDEO_STREAMING_CAPABILITY,
633+
};
634+
615635
module.exports = Test;

0 commit comments

Comments
 (0)