OLD | NEW |
(Empty) | |
| 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 "WebRTC/RTCVideoCodec.h" |
| 12 |
| 13 #include "webrtc/modules/include/module_common_types.h" |
| 14 |
| 15 @implementation RTCRtpFragmentationHeader |
| 16 |
| 17 @synthesize fragmentationOffset = _fragmentationOffset; |
| 18 @synthesize fragmentationLength = _fragmentationLength; |
| 19 @synthesize fragmentationTimeDiff = _fragmentationTimeDiff; |
| 20 @synthesize fragmentationPlType = _fragmentationPlType; |
| 21 |
| 22 - (instancetype)initWithFragmentationHeader: |
| 23 (const webrtc::RTPFragmentationHeader *__nullable)fragmentationHeader { |
| 24 if (self = [super init]) { |
| 25 if (fragmentationHeader) { |
| 26 int count = fragmentationHeader->fragmentationVectorSize; |
| 27 NSMutableArray *offsets = [NSMutableArray array]; |
| 28 NSMutableArray *lengths = [NSMutableArray array]; |
| 29 NSMutableArray *timeDiffs = [NSMutableArray array]; |
| 30 NSMutableArray *plTypes = [NSMutableArray array]; |
| 31 for (int i = 0; i < count; ++i) { |
| 32 [offsets addObject:@(fragmentationHeader->fragmentationOffset[i])]; |
| 33 [lengths addObject:@(fragmentationHeader->fragmentationLength[i])]; |
| 34 [timeDiffs addObject:@(fragmentationHeader->fragmentationTimeDiff[i])]; |
| 35 [plTypes addObject:@(fragmentationHeader->fragmentationPlType[i])]; |
| 36 } |
| 37 _fragmentationOffset = [offsets copy]; |
| 38 _fragmentationLength = [lengths copy]; |
| 39 _fragmentationTimeDiff = [timeDiffs copy]; |
| 40 _fragmentationPlType = [plTypes copy]; |
| 41 } |
| 42 } |
| 43 |
| 44 return self; |
| 45 } |
| 46 |
| 47 - (webrtc::RTPFragmentationHeader *)toCpp { |
| 48 webrtc::RTPFragmentationHeader *fragmentationHeader = new webrtc::RTPFragmenta
tionHeader; |
| 49 fragmentationHeader->VerifyAndAllocateFragmentationHeader(_fragmentationOffset
.count); |
| 50 for (NSUInteger i = 0; i < _fragmentationOffset.count; ++i) { |
| 51 fragmentationHeader->fragmentationOffset[i] = (size_t)_fragmentationOffset[i
].unsignedIntValue; |
| 52 fragmentationHeader->fragmentationLength[i] = (size_t)_fragmentationLength[i
].unsignedIntValue; |
| 53 fragmentationHeader->fragmentationTimeDiff[i] = |
| 54 (uint16_t)_fragmentationOffset[i].unsignedIntValue; |
| 55 fragmentationHeader->fragmentationPlType[i] = (uint8_t)_fragmentationOffset[
i].unsignedIntValue; |
| 56 } |
| 57 |
| 58 return fragmentationHeader; |
| 59 } |
| 60 |
| 61 @end |
OLD | NEW |