Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Commit

Permalink
add initialized to decode nullable metadata in TrackData.swift
Browse files Browse the repository at this point in the history
  • Loading branch information
karkakol committed Mar 25, 2024
1 parent d860181 commit b8cee6a
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions Sources/MembraneRTC/Types/TrackData.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
public struct TrackData: Codable{
public struct TrackData: Codable {
public let metadata: Metadata
public let simulcastConfig: SimulcastConfig?
public init (metadata : Metadata, simulcastConfig : SimulcastConfig? = nil) {

public init(metadata: Metadata, simulcastConfig: SimulcastConfig? = nil) {
self.metadata = metadata
self.simulcastConfig = simulcastConfig
}


public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
self.metadata = try container.decodeIfPresent(Metadata.self, forKey: .metadata) ?? Metadata()
self.simulcastConfig = try container.decodeIfPresent(SimulcastConfig.self, forKey: .simulcastConfig)
}

func copyWith(metadata: Metadata? = nil, simulcastConfig: SimulcastConfig? = nil) -> TrackData {
return TrackData(
metadata: metadata ?? self.metadata,
Expand Down

0 comments on commit b8cee6a

Please sign in to comment.