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.

77 lines
2.7 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. * Copyright 2016 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 "RTCRtpParameters+Private.h"
  11. #import "RTCRtcpParameters+Private.h"
  12. #import "RTCRtpCodecParameters+Private.h"
  13. #import "RTCRtpEncodingParameters+Private.h"
  14. #import "RTCRtpHeaderExtension+Private.h"
  15. #import "helpers/NSString+StdString.h"
  16. @implementation RTCRtpParameters
  17. @synthesize transactionId = _transactionId;
  18. @synthesize rtcp = _rtcp;
  19. @synthesize headerExtensions = _headerExtensions;
  20. @synthesize encodings = _encodings;
  21. @synthesize codecs = _codecs;
  22. - (instancetype)init {
  23. return [super init];
  24. }
  25. - (instancetype)initWithNativeParameters:
  26. (const webrtc::RtpParameters &)nativeParameters {
  27. if (self = [self init]) {
  28. _transactionId = [NSString stringForStdString:nativeParameters.transaction_id];
  29. _rtcp = [[RTCRtcpParameters alloc] initWithNativeParameters:nativeParameters.rtcp];
  30. NSMutableArray *headerExtensions = [[NSMutableArray alloc] init];
  31. for (const auto &headerExtension : nativeParameters.header_extensions) {
  32. [headerExtensions
  33. addObject:[[RTCRtpHeaderExtension alloc] initWithNativeParameters:headerExtension]];
  34. }
  35. _headerExtensions = headerExtensions;
  36. NSMutableArray *encodings = [[NSMutableArray alloc] init];
  37. for (const auto &encoding : nativeParameters.encodings) {
  38. [encodings addObject:[[RTCRtpEncodingParameters alloc]
  39. initWithNativeParameters:encoding]];
  40. }
  41. _encodings = encodings;
  42. NSMutableArray *codecs = [[NSMutableArray alloc] init];
  43. for (const auto &codec : nativeParameters.codecs) {
  44. [codecs addObject:[[RTCRtpCodecParameters alloc]
  45. initWithNativeParameters:codec]];
  46. }
  47. _codecs = codecs;
  48. }
  49. return self;
  50. }
  51. - (webrtc::RtpParameters)nativeParameters {
  52. webrtc::RtpParameters parameters;
  53. parameters.transaction_id = [NSString stdStringForString:_transactionId];
  54. parameters.rtcp = [_rtcp nativeParameters];
  55. for (RTCRtpHeaderExtension *headerExtension in _headerExtensions) {
  56. parameters.header_extensions.push_back(headerExtension.nativeParameters);
  57. }
  58. for (RTCRtpEncodingParameters *encoding in _encodings) {
  59. parameters.encodings.push_back(encoding.nativeParameters);
  60. }
  61. for (RTCRtpCodecParameters *codec in _codecs) {
  62. parameters.codecs.push_back(codec.nativeParameters);
  63. }
  64. return parameters;
  65. }
  66. @end