You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.7 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  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. #import "RTCVideoCodecInfo.h"
  11. @implementation RTCVideoCodecInfo
  12. @synthesize name = _name;
  13. @synthesize parameters = _parameters;
  14. - (instancetype)initWithName:(NSString *)name {
  15. return [self initWithName:name parameters:nil];
  16. }
  17. - (instancetype)initWithName:(NSString *)name
  18. parameters:(nullable NSDictionary<NSString *, NSString *> *)parameters {
  19. if (self = [super init]) {
  20. _name = name;
  21. _parameters = (parameters ? parameters : @{});
  22. }
  23. return self;
  24. }
  25. - (BOOL)isEqualToCodecInfo:(RTCVideoCodecInfo *)info {
  26. if (!info ||
  27. ![self.name isEqualToString:info.name] ||
  28. ![self.parameters isEqualToDictionary:info.parameters]) {
  29. return NO;
  30. }
  31. return YES;
  32. }
  33. - (BOOL)isEqual:(id)object {
  34. if (self == object)
  35. return YES;
  36. if (![object isKindOfClass:[self class]])
  37. return NO;
  38. return [self isEqualToCodecInfo:object];
  39. }
  40. - (NSUInteger)hash {
  41. return [self.name hash] ^ [self.parameters hash];
  42. }
  43. #pragma mark - NSCoding
  44. - (instancetype)initWithCoder:(NSCoder *)decoder {
  45. return [self initWithName:[decoder decodeObjectForKey:@"name"]
  46. parameters:[decoder decodeObjectForKey:@"parameters"]];
  47. }
  48. - (void)encodeWithCoder:(NSCoder *)encoder {
  49. [encoder encodeObject:_name forKey:@"name"];
  50. [encoder encodeObject:_parameters forKey:@"parameters"];
  51. }
  52. @end