Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EMP-19565 #19

Merged
merged 2 commits into from Mar 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,6 @@
# CHANGELOG

* `4.0.30` Release - [4.0.300](#40300)
* `4.0.20` Release - [4.0.200](#40200)
* `4.0.10` Release - [4.0.100](#40100)
* `4.0.00` Release - [4.0.000](#40000)
Expand All @@ -12,6 +13,9 @@
* `2.0.79` Release - [2.0.790](#20790)
* `0.73.x` Releases - [0.73.0](#07300)

## 4.0.300
#### Features
* `EMP-19565` Allow passing custom image info for assets to cast receiver/sender

## 4.0.200
#### Features
Expand Down
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -38,15 +38,15 @@ Once you have your Swift package set up, adding `iOSClientCast` as a dependency

```sh
dependencies: [
.package(url: "https://github.com/EricssonBroadcastServices/iOSClientCast", from: "4.0.1")
.package(url: "https://github.com/EricssonBroadcastServices/iOSClientCast", from: "4.0.3")
]
```

### CocoaPods
CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate `iOSClientCast` into your Xcode project using CocoaPods, specify it in your Podfile:

```sh
pod 'iOSClientCast', '~> 4.0.1'
pod 'iOSClientCast', '~> 4.0.3'
```


Expand Down
15 changes: 14 additions & 1 deletion Sources/iOSClientCast/Configuration/CustomData.swift
Expand Up @@ -33,15 +33,19 @@ public struct CustomData: Encodable {
/// X-Adobe-Primetime-MediaToken
public let adobePrimetimeToken: String?

/// If custom images should be used for the current playing asset.
public let customImages: [CustomImage]?

public init(customer: String, businessUnit: String,
locale:String? = nil, adParameters: CastAdsOptions? = nil, adobePrimetimeToken: String? = nil, subtitleLanguage: String? = nil, audioLanguage: String? = nil ) {
locale:String? = nil, adParameters: CastAdsOptions? = nil, adobePrimetimeToken: String? = nil, subtitleLanguage: String? = nil, audioLanguage: String? = nil, customImages: [CustomImage]? = nil ) {
self.customer = customer
self.businessUnit = businessUnit
self.locale = locale
self.adParameters = adParameters
self.adobePrimetimeToken = adobePrimetimeToken
self.subtitleLanguage = subtitleLanguage
self.audioLanguage = audioLanguage
self.customImages = customImages
}
}

Expand All @@ -54,6 +58,7 @@ extension CustomData {
case adobePrimetimeToken
case subtitleLanguage
case audioLanguage
case customImages
}
}

Expand All @@ -77,6 +82,14 @@ extension CustomData {
if let audioLanguage = audioLanguage {
json[CodingKeys.audioLanguage.rawValue] = audioLanguage
}

if let customImages = customImages {
var convertedImageObjects:[Any] = []
for customImage in customImages {
convertedImageObjects.append(customImage.toJson)
}
json[CodingKeys.customImages.rawValue] = convertedImageObjects
}
return json
}
}
95 changes: 95 additions & 0 deletions Sources/iOSClientCast/Configuration/CustomImage.swift
@@ -0,0 +1,95 @@
//
// CustomImage.swift
//
//
// Created by Udaya Sri Senarathne on 2023-03-08.
//

import Foundation



/// Supported image types
public enum ImageType: String {
case POSTER = "poster"
case BANNER = "banner"
case LOGO = "logo"
case THUMBNAIL = "thumbnail"
case COVER = "cover"
case OTHER = "other"
}

/// Supported Image Orientations
public enum ImageOrientation: String {
case Landscape = "landscape"
case Portrait = "portrait"
}

/// Custom Image/s to use for the current playing asset.
///
///
/// * `url` custom image url
/// * `type` ImageType.POSTER / ImageType.BANNER etc.
/// * `orientation` ImageOrientation.Landscape / ImageOrientation.Portrait
/// * `height` image height
/// * `width` image width
/// * `tags`tags
///
public struct CustomImage: Codable {

public let url: String
public let type: String?
public let orientation: String
public let height: Int
public let width: Int
public let tags: [String]?

public init(url: String, type: String? = nil ,
orientation:String, height: Int, width: Int, tags: [String]? = nil) {
self.url = url
self.type = type
self.orientation = orientation
self.height = height
self.width = width
self.tags = tags

}

public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(url, forKey: .url)
try container.encodeIfPresent(type, forKey: .type)
try container.encode(height, forKey: .height)
try container.encode(width, forKey: .width)
try container.encodeIfPresent(tags, forKey: .tags)
}

internal enum CodingKeys: String, CodingKey {
case url
case type
case orientation
case height
case width
case tags
}


public var toJson: [String: Any] {
var json = [String: Any]()

json[CodingKeys.url.rawValue] = url
json[CodingKeys.orientation.rawValue] = orientation
json[CodingKeys.height.rawValue] = height
json[CodingKeys.width.rawValue] = width


if let type = type {
json[CodingKeys.type.rawValue] = type
}
if let tags = tags {
json[CodingKeys.tags.rawValue] = tags
}
return json
}
}

4 changes: 3 additions & 1 deletion Tests/iOSClientCastTests/CustomDataSpec.swift
Expand Up @@ -20,11 +20,13 @@ class CustomDataSpec: QuickSpec {

let adParameters = CastAdsOptions(latitude: "latitude", longitude: "longitude", mute: true, consent: "consent", deviceMake: "apple", ifa: "ifa", gdprOptin: true)

let customImage = CustomImage(url: "https://sampleimage.jpeg", type: ImageType.BANNER.rawValue, orientation: ImageOrientation.Portrait.rawValue, height: 200, width: 300, tags: nil)

let data = CustomData(customer: "customer",
businessUnit: "businessUnit",
locale: "locale",
adParameters: adParameters,
adobePrimetimeToken: "adobePrimetimeToken", subtitleLanguage: "en", audioLanguage: "fr").toJson
adobePrimetimeToken: "adobePrimetimeToken", subtitleLanguage: "en", audioLanguage: "fr", customImages: [customImage]).toJson


expect(data["customer"] as? String).to(equal("customer"))
Expand Down
2 changes: 1 addition & 1 deletion iOSClientCast.podspec
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = "iOSClientCast"
spec.version = "4.0.200"
spec.version = "4.0.300"
spec.summary = "RedBeeMedia iOS SDK Google Cast Module"
spec.homepage = "https://github.com/EricssonBroadcastServices"
spec.license = { :type => "Apache", :file => "LICENSE" }
Expand Down
4 changes: 2 additions & 2 deletions iOSClientCast.xcodeproj/project.pbxproj
Expand Up @@ -507,7 +507,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 4.0.200;
MARKETING_VERSION = 4.0.300;
OTHER_LDFLAGS = "$(inherited)";
PRODUCT_BUNDLE_IDENTIFIER = com.emp.Cast;
PRODUCT_NAME = iOSClientCast;
Expand Down Expand Up @@ -549,7 +549,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 4.0.200;
MARKETING_VERSION = 4.0.300;
OTHER_LDFLAGS = "$(inherited)";
PRODUCT_BUNDLE_IDENTIFIER = com.emp.Cast;
PRODUCT_NAME = iOSClientCast;
Expand Down