summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Fischer <joeljfischer@gmail.com>2017-08-04 13:17:11 -0400
committerJoel Fischer <joeljfischer@gmail.com>2017-08-04 13:17:11 -0400
commit7fcb08c82260a3b9fcded68c71634a78ad134bae (patch)
tree1a645961d3f5ed427e26a4510992991d1e485445
parent8fb6b6e25c530a55d2ae206718d53a865814f514 (diff)
downloadsdl_ios-7fcb08c82260a3b9fcded68c71634a78ad134bae.tar.gz
Video control frame payloads use enums instead of regular strings
-rw-r--r--SmartDeviceLink/SDLControlFramePayloadVideoStartService.h13
-rw-r--r--SmartDeviceLink/SDLControlFramePayloadVideoStartService.m16
-rw-r--r--SmartDeviceLink/SDLControlFramePayloadVideoStartServiceAck.h12
-rw-r--r--SmartDeviceLink/SDLControlFramePayloadVideoStartServiceAck.m16
4 files changed, 38 insertions, 19 deletions
diff --git a/SmartDeviceLink/SDLControlFramePayloadVideoStartService.h b/SmartDeviceLink/SDLControlFramePayloadVideoStartService.h
index 175ec1f72..30ea57e8f 100644
--- a/SmartDeviceLink/SDLControlFramePayloadVideoStartService.h
+++ b/SmartDeviceLink/SDLControlFramePayloadVideoStartService.h
@@ -10,6 +10,11 @@
#import "SDLControlFramePayloadType.h"
+@class SDLVideoStreamingCodec;
+@class SDLVideoStreamingProtocol;
+
+NS_ASSUME_NONNULL_BEGIN
+
@interface SDLControlFramePayloadVideoStartService : NSObject <SDLControlFramePayloadType>
/// Desired height in pixels from the client requesting the video service to start
@@ -19,9 +24,13 @@
@property (assign, nonatomic, readonly) int32_t width;
/// Desired video protocol to be used. See VideoStreamingProtocol RPC
-@property (copy, nonatomic, readonly) NSString *videoProtocol;
+@property (copy, nonatomic, readonly, nullable) SDLVideoStreamingCodec *videoCodec;
/// Desired video codec to be used. See VideoStreamingCodec RPC
-@property (copy, nonatomic, readonly) NSString *videoCodec;
+@property (copy, nonatomic, readonly, nullable) SDLVideoStreamingProtocol *videoProtocol;
+
+- (instancetype)initWithVideoHeight:(int32_t)height width:(int32_t)width protocol:(nullable SDLVideoStreamingProtocol *)protocol codec:(nullable SDLVideoStreamingCodec *)codec;
@end
+
+NS_ASSUME_NONNULL_END
diff --git a/SmartDeviceLink/SDLControlFramePayloadVideoStartService.m b/SmartDeviceLink/SDLControlFramePayloadVideoStartService.m
index 013f36dd2..47ed8301a 100644
--- a/SmartDeviceLink/SDLControlFramePayloadVideoStartService.m
+++ b/SmartDeviceLink/SDLControlFramePayloadVideoStartService.m
@@ -10,6 +10,8 @@
#import "bson_object.h"
#import "SDLControlFramePayloadConstants.h"
+#import "SDLVideoStreamingCodec.h"
+#import "SDLVideoStreamingProtocol.h"
NS_ASSUME_NONNULL_BEGIN
@@ -18,14 +20,14 @@ NS_ASSUME_NONNULL_BEGIN
@property (assign, nonatomic, readwrite) int32_t height;
@property (assign, nonatomic, readwrite) int32_t width;
-@property (copy, nonatomic, readwrite) NSString *videoProtocol;
-@property (copy, nonatomic, readwrite) NSString *videoCodec;
+@property (copy, nonatomic, readwrite, nullable) SDLVideoStreamingCodec *videoCodec;
+@property (copy, nonatomic, readwrite, nullable) SDLVideoStreamingProtocol *videoProtocol;
@end
@implementation SDLControlFramePayloadVideoStartService
-- (instancetype)initWithVideoHeight:(int32_t)height width:(int32_t)width protocol:(NSString *)protocol codec:(NSString *)codec {
+- (instancetype)initWithVideoHeight:(int32_t)height width:(int32_t)width protocol:(nullable SDLVideoStreamingProtocol *)protocol codec:(nullable SDLVideoStreamingCodec *)codec {
self = [super init];
if (!self) return nil;
@@ -71,11 +73,11 @@ NS_ASSUME_NONNULL_BEGIN
}
if (self.videoProtocol != nil) {
- bson_object_put_string(&payloadObject, SDLControlFrameVideoProtocolKey, (char *)self.videoProtocol.UTF8String);
+ bson_object_put_string(&payloadObject, SDLControlFrameVideoProtocolKey, (char *)self.videoProtocol.value.UTF8String);
}
if (self.videoCodec != nil) {
- bson_object_put_string(&payloadObject, SDLControlFrameVideoCodecKey, (char *)self.videoCodec.UTF8String);
+ bson_object_put_string(&payloadObject, SDLControlFrameVideoCodecKey, (char *)self.videoCodec.value.UTF8String);
}
BytePtr bsonData = bson_object_to_bytes(&payloadObject);
@@ -94,12 +96,12 @@ NS_ASSUME_NONNULL_BEGIN
char *utf8String = bson_object_get_string(&payloadObject, SDLControlFrameVideoProtocolKey);
if (utf8String != NULL) {
- self.videoProtocol = [NSString stringWithUTF8String:utf8String];
+ self.videoProtocol = [SDLVideoStreamingProtocol valueOf:[NSString stringWithUTF8String:utf8String]];
}
utf8String = bson_object_get_string(&payloadObject, SDLControlFrameVideoCodecKey);
if (utf8String != NULL) {
- self.videoCodec = [NSString stringWithUTF8String:utf8String];
+ self.videoProtocol = [SDLVideoStreamingProtocol valueOf:[NSString stringWithUTF8String:utf8String]];
}
bson_object_deinitialize(&payloadObject);
diff --git a/SmartDeviceLink/SDLControlFramePayloadVideoStartServiceAck.h b/SmartDeviceLink/SDLControlFramePayloadVideoStartServiceAck.h
index 68d39d6a6..0fed3ebf3 100644
--- a/SmartDeviceLink/SDLControlFramePayloadVideoStartServiceAck.h
+++ b/SmartDeviceLink/SDLControlFramePayloadVideoStartServiceAck.h
@@ -10,6 +10,10 @@
#import "SDLControlFramePayloadType.h"
+@class SDLVideoStreamingCodec;
+@class SDLVideoStreamingProtocol;
+
+NS_ASSUME_NONNULL_BEGIN
@interface SDLControlFramePayloadVideoStartServiceAck : NSObject <SDLControlFramePayloadType>
@@ -23,11 +27,13 @@
@property (assign, nonatomic, readonly) int32_t width;
/// Accepted video protocol to be used. See VideoStreamingProtocol RPC
-@property (copy, nonatomic, readonly) NSString *videoProtocol;
+@property (copy, nonatomic, readonly, nullable) SDLVideoStreamingProtocol *videoProtocol;
/// Accepted video codec to be used. See VideoStreamingCodec RPC
-@property (copy, nonatomic, readonly) NSString *videoCodec;
+@property (copy, nonatomic, readonly, nullable) SDLVideoStreamingCodec *videoCodec;
-- (instancetype)initWithMTU:(int64_t)mtu videoHeight:(int32_t)height width:(int32_t)width protocol:(NSString *)protocol codec:(NSString *)codec;
+- (instancetype)initWithMTU:(int64_t)mtu videoHeight:(int32_t)height width:(int32_t)width protocol:(SDLVideoStreamingProtocol *)protocol codec:(SDLVideoStreamingCodec *)codec;
@end
+
+NS_ASSUME_NONNULL_END
diff --git a/SmartDeviceLink/SDLControlFramePayloadVideoStartServiceAck.m b/SmartDeviceLink/SDLControlFramePayloadVideoStartServiceAck.m
index e26d310a6..d669f65d2 100644
--- a/SmartDeviceLink/SDLControlFramePayloadVideoStartServiceAck.m
+++ b/SmartDeviceLink/SDLControlFramePayloadVideoStartServiceAck.m
@@ -10,6 +10,8 @@
#import "bson_object.h"
#import "SDLControlFramePayloadConstants.h"
+#import "SDLVideoStreamingCodec.h"
+#import "SDLVideoStreamingProtocol.h"
@interface SDLControlFramePayloadVideoStartServiceAck ()
@@ -17,14 +19,14 @@
@property (assign, nonatomic, readwrite) int64_t mtu;
@property (assign, nonatomic, readwrite) int32_t height;
@property (assign, nonatomic, readwrite) int32_t width;
-@property (copy, nonatomic, readwrite) NSString *videoProtocol;
-@property (copy, nonatomic, readwrite) NSString *videoCodec;
+@property (copy, nonatomic, readwrite) SDLVideoStreamingProtocol *videoProtocol;
+@property (copy, nonatomic, readwrite) SDLVideoStreamingCodec *videoCodec;
@end
@implementation SDLControlFramePayloadVideoStartServiceAck
-- (instancetype)initWithMTU:(int64_t)mtu videoHeight:(int32_t)height width:(int32_t)width protocol:(NSString *)protocol codec:(NSString *)codec {
+- (instancetype)initWithMTU:(int64_t)mtu videoHeight:(int32_t)height width:(int32_t)width protocol:(SDLVideoStreamingProtocol *)protocol codec:(SDLVideoStreamingCodec *)codec {
self = [super init];
if (!self) return nil;
@@ -77,11 +79,11 @@
}
if (self.videoProtocol != nil) {
- bson_object_put_string(&payloadObject, SDLControlFrameVideoProtocolKey, (char *)self.videoProtocol.UTF8String);
+ bson_object_put_string(&payloadObject, SDLControlFrameVideoProtocolKey, (char *)self.videoProtocol.value.UTF8String);
}
if (self.videoCodec != nil) {
- bson_object_put_string(&payloadObject, SDLControlFrameVideoCodecKey, (char *)self.videoCodec.UTF8String);
+ bson_object_put_string(&payloadObject, SDLControlFrameVideoCodecKey, (char *)self.videoCodec.value.UTF8String);
}
BytePtr bsonData = bson_object_to_bytes(&payloadObject);
@@ -101,12 +103,12 @@
char *utf8String = bson_object_get_string(&payloadObject, SDLControlFrameVideoProtocolKey);
if (utf8String != NULL) {
- self.videoProtocol = [NSString stringWithUTF8String:utf8String];
+ self.videoProtocol = [SDLVideoStreamingProtocol valueOf:[NSString stringWithUTF8String:utf8String]];
}
utf8String = bson_object_get_string(&payloadObject, SDLControlFrameVideoCodecKey);
if (utf8String != NULL) {
- self.videoCodec = [NSString stringWithUTF8String:utf8String];
+ self.videoCodec = [SDLVideoStreamingCodec valueOf:[NSString stringWithUTF8String:utf8String]];
}
bson_object_deinitialize(&payloadObject);