1/* 2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11#import "RTCVideoCodecInfo.h" 12 13@implementation RTC_OBJC_TYPE (RTCVideoCodecInfo) 14 15@synthesize name = _name; 16@synthesize parameters = _parameters; 17 18- (instancetype)initWithName:(NSString *)name { 19 return [self initWithName:name parameters:nil]; 20} 21 22- (instancetype)initWithName:(NSString *)name 23 parameters:(nullable NSDictionary<NSString *, NSString *> *)parameters { 24 if (self = [super init]) { 25 _name = name; 26 _parameters = (parameters ? parameters : @{}); 27 } 28 29 return self; 30} 31 32- (BOOL)isEqualToCodecInfo:(RTC_OBJC_TYPE(RTCVideoCodecInfo) *)info { 33 if (!info || 34 ![self.name isEqualToString:info.name] || 35 ![self.parameters isEqualToDictionary:info.parameters]) { 36 return NO; 37 } 38 return YES; 39} 40 41- (BOOL)isEqual:(id)object { 42 if (self == object) 43 return YES; 44 if (![object isKindOfClass:[self class]]) 45 return NO; 46 return [self isEqualToCodecInfo:object]; 47} 48 49- (NSUInteger)hash { 50 return [self.name hash] ^ [self.parameters hash]; 51} 52 53#pragma mark - NSCoding 54 55- (instancetype)initWithCoder:(NSCoder *)decoder { 56 return [self initWithName:[decoder decodeObjectForKey:@"name"] 57 parameters:[decoder decodeObjectForKey:@"parameters"]]; 58} 59 60- (void)encodeWithCoder:(NSCoder *)encoder { 61 [encoder encodeObject:_name forKey:@"name"]; 62 [encoder encodeObject:_parameters forKey:@"parameters"]; 63} 64 65@end 66