Chromium Code Reviews| Index: webrtc/sdk/objc/Framework/Classes/PeerConnection/RTCRtpFragmentationHeader.mm |
| diff --git a/webrtc/sdk/objc/Framework/Classes/PeerConnection/RTCRtpFragmentationHeader.mm b/webrtc/sdk/objc/Framework/Classes/PeerConnection/RTCRtpFragmentationHeader.mm |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..eea07ec92efce4293a46bf65c6529354d91f8293 |
| --- /dev/null |
| +++ b/webrtc/sdk/objc/Framework/Classes/PeerConnection/RTCRtpFragmentationHeader.mm |
| @@ -0,0 +1,61 @@ |
| +/* |
| + * Copyright 2017 The WebRTC project authors. All Rights Reserved. |
| + * |
| + * Use of this source code is governed by a BSD-style license |
| + * that can be found in the LICENSE file in the root of the source |
| + * tree. An additional intellectual property rights grant can be found |
| + * in the file PATENTS. All contributing project authors may |
| + * be found in the AUTHORS file in the root of the source tree. |
| + */ |
| + |
| +#import "WebRTC/RTCVideoCodec.h" |
| + |
| +#include "webrtc/modules/include/module_common_types.h" |
| + |
| +@implementation RTCRtpFragmentationHeader |
| + |
| +@synthesize fragmentationOffset = _fragmentationOffset; |
| +@synthesize fragmentationLength = _fragmentationLength; |
| +@synthesize fragmentationTimeDiff = _fragmentationTimeDiff; |
| +@synthesize fragmentationPlType = _fragmentationPlType; |
| + |
| +- (instancetype)initWithFragmentationHeader: |
| + (const webrtc::RTPFragmentationHeader *__nullable)fragmentationHeader { |
|
Chuck
2017/07/14 14:57:29
What does nullable mean here for a native pointer?
|
| + if (self = [super init]) { |
| + if (fragmentationHeader) { |
| + int count = fragmentationHeader->fragmentationVectorSize; |
| + NSMutableArray *offsets = [NSMutableArray array]; |
| + NSMutableArray *lengths = [NSMutableArray array]; |
| + NSMutableArray *timeDiffs = [NSMutableArray array]; |
| + NSMutableArray *plTypes = [NSMutableArray array]; |
| + for (int i = 0; i < count; ++i) { |
| + [offsets addObject:@(fragmentationHeader->fragmentationOffset[i])]; |
| + [lengths addObject:@(fragmentationHeader->fragmentationLength[i])]; |
| + [timeDiffs addObject:@(fragmentationHeader->fragmentationTimeDiff[i])]; |
| + [plTypes addObject:@(fragmentationHeader->fragmentationPlType[i])]; |
| + } |
| + _fragmentationOffset = [offsets copy]; |
| + _fragmentationLength = [lengths copy]; |
| + _fragmentationTimeDiff = [timeDiffs copy]; |
| + _fragmentationPlType = [plTypes copy]; |
| + } |
| + } |
| + |
| + return self; |
| +} |
| + |
| +- (webrtc::RTPFragmentationHeader *)toCpp { |
| + webrtc::RTPFragmentationHeader *fragmentationHeader = new webrtc::RTPFragmentationHeader; |
|
Chuck
2017/07/14 14:57:29
In cases where we return a native pointer we shoul
|
| + fragmentationHeader->VerifyAndAllocateFragmentationHeader(_fragmentationOffset.count); |
| + for (NSUInteger i = 0; i < _fragmentationOffset.count; ++i) { |
| + fragmentationHeader->fragmentationOffset[i] = (size_t)_fragmentationOffset[i].unsignedIntValue; |
| + fragmentationHeader->fragmentationLength[i] = (size_t)_fragmentationLength[i].unsignedIntValue; |
| + fragmentationHeader->fragmentationTimeDiff[i] = |
| + (uint16_t)_fragmentationOffset[i].unsignedIntValue; |
| + fragmentationHeader->fragmentationPlType[i] = (uint8_t)_fragmentationOffset[i].unsignedIntValue; |
| + } |
| + |
| + return fragmentationHeader; |
| +} |
| + |
| +@end |