Skip to content

Commit fb14312

Browse files
kthelgasonCommit Bot
authored and
Commit Bot
committed
Reland of Injectable Obj-C video codecs (patchset #1 id:1 of https://codereview.webrtc.org/2980173002/ )
Reason for revert: Relanding after fixing issues with no video. Original issue's description: > Revert of Injectable Obj-C video codecs (patchset #2 id:370001 of https://codereview.webrtc.org/2979983002/ ) > > Reason for revert: > Still having problems with no video. Reverting. > Once no video is visible, no video is available from then on even if the callee app is in the foreground. > > > Original issue's description: > > Reland of Injectable Obj-C video codecs (patchset #1 id:1 of https://codereview.webrtc.org/2979973002/ ) > > > > Reason for revert: > > Fix the broken build file > > > > Original issue's description: > > > Revert of Injectable Obj-C video codecs (patchset #3 id:400001 of https://codereview.webrtc.org/2981583002/ ) > > > > > > Reason for revert: > > > Breaks bots. Build file incorrect. > > > > > > Original issue's description: > > > > Reland of Injectable Obj-C video codecs (patchset #1 id:1 of https://codereview.webrtc.org/2975963002/ ) > > > > > > > > Reason for revert: > > > > New CL for fixing the issues > > > > > > > > Original issue's description: > > > > > Revert of Injectable Obj-C video codecs (patchset #8 id:140001 of https://codereview.webrtc.org/2966023002/ ) > > > > > > > > > > Reason for revert: > > > > > Causes no video in certain scenarios. Please come up with a test plan or unit test to prevent such problems in the future. > > > > > > > > > > Original issue's description: > > > > > > Injectable Obj-C video codecs > > > > > > > > > > > > Initial CL for this effort, with a working RTCVideoEncoder/Decoder for H264 > > > > > > (wrapping the VideoToolbox codec). > > > > > > > > > > > > Some notes / things left to do: > > > > > > - There are some hard-coded references to codec types that are supported by > > > > > > webrtc::VideoCodec, cricket::VideoCodec, webrtc::CodecSpecificInfo etc > > > > > > since we need to convert to/from these types in ObjCVideoEncoder/Decoder. > > > > > > These types would need to be more codec agnostic to avoid this. > > > > > > - Most interfaces are borrowed from the design document for injectable > > > > > > codecs in Android. Some data in the corresponding C++ classes is discarded > > > > > > when converting to the Obj-C version, since it has fewer fields. I have not > > > > > > verified whether all data that we do keep is needed, or whether we might be > > > > > > losing anything useful in these conversions. > > > > > > - Implement the VideoToolbox codec code directly in the RTCVideoEncoderH264 > > > > > > classes, instead of wrapping webrtc::H264VideoToolboxEncoder / decoder. > > > > > > Eliminates converting between ObjC/C++ types outside the ObjCVideoEncoder/ > > > > > > Decoder wrapper classes. > > > > > > - List the injected codec factory's supported codecs in the list of codecs in > > > > > > AppRTCMobile. > > > > > > > > > > > > BUG=webrtc:7924 > > > > > > [email protected] > > > > > > > > > > > > Review-Url: https://codereview.webrtc.org/2966023002 . > > > > > > Cr-Commit-Position: refs/heads/master@{#18928} > > > > > > Committed: https://chromium.googlesource.com/external/webrtc/+/a0349c138db62c52435be84b6c837f5f4758e264 > > > > > > > > > > [email protected],[email protected] > > > > > # Not skipping CQ checks because original CL landed more than 1 days ago. > > > > > BUG=webrtc:7924 > > > > > NOTRY=true > > > > > > > > > > Review-Url: https://codereview.webrtc.org/2975963002 > > > > > Cr-Commit-Position: refs/heads/master@{#18979} > > > > > Committed: https://chromium.googlesource.com/external/webrtc/+/1095ada7ad56fe29b7b2bbc560a8f6475a7978ce > > > > > > > > [email protected] > > > > [email protected] > > > > # Skipping CQ checks because original CL landed less than 1 days ago. > > > > NOPRESUBMIT=true > > > > NOTREECHECKS=true > > > > NOTRY=true > > > > BUG=webrtc:7924 > > > > > > > > Review-Url: https://codereview.webrtc.org/2981583002 . > > > > Cr-Commit-Position: refs/heads/master@{#19002} > > > > Committed: https://chromium.googlesource.com/external/webrtc/+/a5f1de1e6541de03f944bcbf49be87c01f57a18b > > > > > > [email protected],[email protected],[email protected],[email protected] > > > # Skipping CQ checks because original CL landed less than 1 days ago. > > > NOPRESUBMIT=true > > > NOTREECHECKS=true > > > NOTRY=true > > > BUG=webrtc:7924 > > > > > > Review-Url: https://codereview.webrtc.org/2979973002 > > > Cr-Commit-Position: refs/heads/master@{#19004} > > > Committed: https://chromium.googlesource.com/external/webrtc/+/81d40ee1491d5229c2677cc04b1f40d67c2babef > > > > [email protected],[email protected],[email protected],[email protected] > > BUG=webrtc:7924 > > > > Review-Url: https://codereview.webrtc.org/2979983002 > > Cr-Commit-Position: refs/heads/master@{#19005} > > Committed: https://chromium.googlesource.com/external/webrtc/+/732a3437da4db7b452758b8e1cf26fce0ce3bf65 > > [email protected],[email protected],[email protected],[email protected],[email protected] > # Not skipping CQ checks because original CL landed more than 1 days ago. > BUG=webrtc:7924 > > Review-Url: https://codereview.webrtc.org/2980173002 > Cr-Commit-Position: refs/heads/master@{#19036} > Committed: https://chromium.googlesource.com/external/webrtc/+/860f7298166084d966749e22b69aa2fdcf4d4ed6 [email protected],[email protected],[email protected],[email protected],[email protected],[email protected] # Not skipping CQ checks because original CL landed more than 1 days ago. BUG=webrtc:7924 Review-Url: https://codereview.webrtc.org/2977213002 Cr-Commit-Position: refs/heads/master@{#19135}
1 parent 8337727 commit fb14312

24 files changed

+1506
-173
lines changed

webrtc/sdk/BUILD.gn

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ if (is_ios || is_mac) {
310310
sources = [
311311
"objc/Framework/Classes/PeerConnection/RTCPeerConnectionFactory+Private.h",
312312
"objc/Framework/Classes/PeerConnection/RTCPeerConnectionFactory.mm",
313+
"objc/Framework/Classes/PeerConnection/RTCVideoCodecH264.mm",
313314
]
314315

315316
public_configs = [ ":objc_common_config" ]
@@ -326,11 +327,15 @@ if (is_ios || is_mac) {
326327
":objc_peerconnectionfactory_base",
327328
":objc_video",
328329
":objc_videotoolbox",
330+
":objc_videotracksource",
329331
"../api:video_frame_api",
332+
"../api/video_codecs:video_codecs_api",
333+
"../media:rtc_audio_video",
330334
"../media:rtc_media_base",
331335
"../pc:create_pc_factory",
332336
"../pc:peerconnection",
333337
"../rtc_base:rtc_base",
338+
"../system_wrappers:field_trial_api",
334339
]
335340
}
336341

@@ -377,6 +382,7 @@ if (is_ios || is_mac) {
377382
"objc/Framework/Classes/PeerConnection/RTCDataChannel.mm",
378383
"objc/Framework/Classes/PeerConnection/RTCDataChannelConfiguration+Private.h",
379384
"objc/Framework/Classes/PeerConnection/RTCDataChannelConfiguration.mm",
385+
"objc/Framework/Classes/PeerConnection/RTCEncodedImage.mm",
380386
"objc/Framework/Classes/PeerConnection/RTCIceCandidate+Private.h",
381387
"objc/Framework/Classes/PeerConnection/RTCIceCandidate.mm",
382388
"objc/Framework/Classes/PeerConnection/RTCIceServer+Private.h",
@@ -404,6 +410,7 @@ if (is_ios || is_mac) {
404410
"objc/Framework/Classes/PeerConnection/RTCRtpCodecParameters.mm",
405411
"objc/Framework/Classes/PeerConnection/RTCRtpEncodingParameters+Private.h",
406412
"objc/Framework/Classes/PeerConnection/RTCRtpEncodingParameters.mm",
413+
"objc/Framework/Classes/PeerConnection/RTCRtpFragmentationHeader.mm",
407414
"objc/Framework/Classes/PeerConnection/RTCRtpParameters+Private.h",
408415
"objc/Framework/Classes/PeerConnection/RTCRtpParameters.mm",
409416
"objc/Framework/Classes/PeerConnection/RTCRtpReceiver+Private.h",
@@ -415,6 +422,9 @@ if (is_ios || is_mac) {
415422
"objc/Framework/Classes/PeerConnection/RTCSessionDescription.mm",
416423
"objc/Framework/Classes/PeerConnection/RTCTracing.mm",
417424
"objc/Framework/Classes/PeerConnection/RTCVideoCapturer.m",
425+
"objc/Framework/Classes/PeerConnection/RTCVideoCodec+Private.h",
426+
"objc/Framework/Classes/PeerConnection/RTCVideoCodec.mm",
427+
"objc/Framework/Classes/PeerConnection/RTCVideoEncoderSettings.mm",
418428
"objc/Framework/Classes/PeerConnection/RTCVideoFrame.mm",
419429
"objc/Framework/Classes/PeerConnection/RTCVideoRendererAdapter+Private.h",
420430
"objc/Framework/Classes/PeerConnection/RTCVideoRendererAdapter.h",
@@ -475,6 +485,7 @@ if (is_ios || is_mac) {
475485
"../api:video_frame_api",
476486
"../common_video",
477487
"../media:rtc_media_base",
488+
"../modules:module_api",
478489
"../pc:peerconnection",
479490
"../rtc_base:rtc_base",
480491
]
@@ -501,6 +512,8 @@ if (is_ios || is_mac) {
501512
"objc/Framework/UnitTests/RTCSessionDescriptionTest.mm",
502513
"objc/Framework/UnitTests/RTCTracingTest.mm",
503514
"objc/Framework/UnitTests/avformatmappertests.mm",
515+
"objc/Framework/UnitTests/objc_video_decoder_factory_tests.mm",
516+
"objc/Framework/UnitTests/objc_video_encoder_factory_tests.mm",
504517
]
505518
if (is_ios &&
506519
!(use_ios_simulator &&
@@ -518,7 +531,11 @@ if (is_ios || is_mac) {
518531
defines = [ "GTEST_RELATIVE_PATH" ]
519532
deps = [
520533
":objc_peerconnection",
534+
":objc_peerconnectionfactory",
535+
":objc_videotoolbox",
536+
":objc_videotracksource",
521537
"..//system_wrappers:system_wrappers_default",
538+
"../modules:module_api",
522539
"../rtc_base:rtc_base_tests_utils",
523540
"../system_wrappers:system_wrappers_default",
524541
"//third_party/ocmock",
@@ -553,6 +570,8 @@ if (is_ios || is_mac) {
553570

554571
common_objc_headers = [
555572
"objc/Framework/Headers/WebRTC/RTCAudioSession.h",
573+
"objc/Framework/Headers/WebRTC/RTCVideoCodec.h",
574+
"objc/Framework/Headers/WebRTC/RTCVideoCodecFactory.h",
556575
"objc/Framework/Headers/WebRTC/RTCAudioSessionConfiguration.h",
557576
"objc/Framework/Headers/WebRTC/RTCAVFoundationVideoSource.h",
558577
"objc/Framework/Headers/WebRTC/RTCAudioSource.h",
@@ -595,6 +614,7 @@ if (is_ios || is_mac) {
595614
"objc/Framework/Headers/WebRTC/RTCVideoTrack.h",
596615
"objc/Framework/Headers/WebRTC/RTCVideoViewShading.h",
597616
"objc/Framework/Headers/WebRTC/UIDevice+RTCDevice.h",
617+
"objc/Framework/Headers/WebRTC/RTCVideoCodecH264.h",
598618
"objc/Framework/Headers/WebRTC/WebRTC.h",
599619
]
600620
if (rtc_use_metal_rendering) {
@@ -681,8 +701,10 @@ if (is_ios || is_mac) {
681701
"objc/Framework/Classes/VideoToolbox/encoder.mm",
682702
"objc/Framework/Classes/VideoToolbox/nalu_rewriter.cc",
683703
"objc/Framework/Classes/VideoToolbox/nalu_rewriter.h",
684-
"objc/Framework/Classes/VideoToolbox/videocodecfactory.h",
685-
"objc/Framework/Classes/VideoToolbox/videocodecfactory.mm",
704+
"objc/Framework/Classes/VideoToolbox/objc_video_decoder_factory.h",
705+
"objc/Framework/Classes/VideoToolbox/objc_video_decoder_factory.mm",
706+
"objc/Framework/Classes/VideoToolbox/objc_video_encoder_factory.h",
707+
"objc/Framework/Classes/VideoToolbox/objc_video_encoder_factory.mm",
686708
"objc/Framework/Headers/WebRTC/RTCVideoFrameBuffer.h",
687709
]
688710

@@ -692,6 +714,7 @@ if (is_ios || is_mac) {
692714
":objc_common",
693715
":objc_video",
694716
":objc_videotracksource",
717+
"../api/video_codecs:video_codecs_api",
695718
"../common_video",
696719
"../media:rtc_media",
697720
"../media:rtc_media_base",

webrtc/sdk/objc/Framework/Classes/Common/helpers.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
#ifndef WEBRTC_SDK_OBJC_FRAMEWORK_CLASSES_COMMON_HELPERS_H_
1212
#define WEBRTC_SDK_OBJC_FRAMEWORK_CLASSES_COMMON_HELPERS_H_
1313

14-
#if defined(WEBRTC_IOS)
15-
1614
#include <string>
1715

1816
namespace webrtc {
@@ -33,6 +31,7 @@ std::string GetThreadInfo();
3331
// Example: <NSThread: 0x170066d80>{number = 1, name = main}
3432
std::string GetCurrentThreadDescription();
3533

34+
#if defined(WEBRTC_IOS)
3635
// Returns the current name of the operating system.
3736
std::string GetSystemName();
3837

@@ -46,6 +45,7 @@ double GetSystemVersion();
4645
// Returns the device type.
4746
// Examples: ”iPhone” and ”iPod touch”.
4847
std::string GetDeviceType();
48+
#endif // defined(WEBRTC_IOS)
4949

5050
// Returns a more detailed device name.
5151
// Examples: "iPhone 5s (GSM)" and "iPhone 6 Plus".
@@ -65,12 +65,12 @@ std::string GetOSVersionString();
6565
// Returns the number of processing cores available on the device.
6666
int GetProcessorCount();
6767

68+
#if defined(WEBRTC_IOS)
6869
// Indicates whether Low Power Mode is enabled on the iOS device.
6970
bool GetLowPowerModeEnabled();
71+
#endif
7072

7173
} // namespace ios
7274
} // namespace webrtc
7375

74-
#endif // defined(WEBRTC_IOS)
75-
7676
#endif // WEBRTC_SDK_OBJC_FRAMEWORK_CLASSES_COMMON_HELPERS_H_
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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+
#import "RTCVideoCodec+Private.h"
14+
15+
@implementation RTCEncodedImage
16+
17+
@synthesize buffer = _buffer;
18+
@synthesize encodedWidth = _encodedWidth;
19+
@synthesize encodedHeight = _encodedHeight;
20+
@synthesize timeStamp = _timeStamp;
21+
@synthesize captureTimeMs = _captureTimeMs;
22+
@synthesize ntpTimeMs = _ntpTimeMs;
23+
@synthesize isTimingFrame = _isTimingFrame;
24+
@synthesize encodeStartMs = _encodeStartMs;
25+
@synthesize encodeFinishMs = _encodeFinishMs;
26+
@synthesize frameType = _frameType;
27+
@synthesize rotation = _rotation;
28+
@synthesize completeFrame = _completeFrame;
29+
@synthesize qp = _qp;
30+
31+
- (instancetype)initWithNativeEncodedImage:(webrtc::EncodedImage)encodedImage {
32+
if (self = [super init]) {
33+
// Wrap the buffer in NSData without copying, do not take ownership.
34+
_buffer = [NSData dataWithBytesNoCopy:encodedImage._buffer
35+
length:encodedImage._length
36+
freeWhenDone:NO];
37+
_encodedWidth = encodedImage._encodedWidth;
38+
_encodedHeight = encodedImage._encodedHeight;
39+
_timeStamp = encodedImage._timeStamp;
40+
_captureTimeMs = encodedImage.capture_time_ms_;
41+
_ntpTimeMs = encodedImage.ntp_time_ms_;
42+
_isTimingFrame = encodedImage.timing_.is_timing_frame;
43+
_encodeStartMs = encodedImage.timing_.encode_start_ms;
44+
_encodeFinishMs = encodedImage.timing_.encode_finish_ms;
45+
_frameType = (RTCFrameType)encodedImage._frameType;
46+
_rotation = encodedImage.rotation_;
47+
_completeFrame = encodedImage._completeFrame;
48+
_qp = encodedImage.qp_ == -1 ? nil : @(encodedImage.qp_);
49+
}
50+
51+
return self;
52+
}
53+
54+
- (webrtc::EncodedImage)toCpp {
55+
// Return the pointer without copying.
56+
webrtc::EncodedImage encodedImage(
57+
(uint8_t *)_buffer.bytes, (size_t)_buffer.length, (size_t)_buffer.length);
58+
encodedImage._encodedWidth = _encodedWidth;
59+
encodedImage._encodedHeight = _encodedHeight;
60+
encodedImage._timeStamp = _timeStamp;
61+
encodedImage.capture_time_ms_ = _captureTimeMs;
62+
encodedImage.ntp_time_ms_ = _ntpTimeMs;
63+
encodedImage.timing_.is_timing_frame = _isTimingFrame;
64+
encodedImage.timing_.encode_start_ms = _encodeStartMs;
65+
encodedImage.timing_.encode_finish_ms = _encodeFinishMs;
66+
encodedImage._frameType = webrtc::FrameType(_frameType);
67+
encodedImage.rotation_ = webrtc::VideoRotation(_rotation);
68+
encodedImage._completeFrame = _completeFrame;
69+
encodedImage.qp_ = _qp ? _qp.intValue : -1;
70+
71+
return encodedImage;
72+
}
73+
74+
@end

webrtc/sdk/objc/Framework/Classes/PeerConnection/RTCPeerConnectionFactory.mm

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,23 @@
1111
#import "RTCPeerConnectionFactory+Private.h"
1212

1313
#import "NSString+StdString.h"
14+
#import "RTCAVFoundationVideoSource+Private.h"
1415
#import "RTCAudioSource+Private.h"
1516
#import "RTCAudioTrack+Private.h"
1617
#import "RTCMediaConstraints+Private.h"
1718
#import "RTCMediaStream+Private.h"
1819
#import "RTCPeerConnection+Private.h"
1920
#import "RTCVideoSource+Private.h"
2021
#import "RTCVideoTrack+Private.h"
21-
#import "RTCAVFoundationVideoSource+Private.h"
2222
#import "WebRTC/RTCLogging.h"
23+
#import "WebRTC/RTCVideoCodecFactory.h"
24+
#ifndef HAVE_NO_MEDIA
25+
#import "WebRTC/RTCVideoCodecH264.h"
26+
#endif
2327

2428
#include "Video/objcvideotracksource.h"
25-
#include "VideoToolbox/videocodecfactory.h"
29+
#include "VideoToolbox/objc_video_decoder_factory.h"
30+
#include "VideoToolbox/objc_video_encoder_factory.h"
2631
#include "webrtc/api/videosourceproxy.h"
2732
// Adding the nogncheck to disable the including header check.
2833
// The no-media version PeerConnectionFactory doesn't depend on media related
@@ -41,7 +46,17 @@ @implementation RTCPeerConnectionFactory {
4146
@synthesize nativeFactory = _nativeFactory;
4247

4348
- (instancetype)init {
44-
if ((self = [super init])) {
49+
#ifdef HAVE_NO_MEDIA
50+
return [self initWithEncoderFactory:nil decoderFactory:nil];
51+
#else
52+
return [self initWithEncoderFactory:[[RTCVideoEncoderFactoryH264 alloc] init]
53+
decoderFactory:[[RTCVideoDecoderFactoryH264 alloc] init]];
54+
#endif
55+
}
56+
57+
- (instancetype)initWithEncoderFactory:(nullable id<RTCVideoEncoderFactory>)encoderFactory
58+
decoderFactory:(nullable id<RTCVideoDecoderFactory>)decoderFactory {
59+
if (self = [super init]) {
4560
_networkThread = rtc::Thread::CreateWithSocketServer();
4661
BOOL result = _networkThread->Start();
4762
NSAssert(result, @"Failed to start network thread.");
@@ -68,14 +83,23 @@ - (instancetype)init {
6883
std::unique_ptr<webrtc::CallFactoryInterface>(),
6984
std::unique_ptr<webrtc::RtcEventLogFactoryInterface>());
7085
#else
71-
const auto encoder_factory = new webrtc::VideoToolboxVideoEncoderFactory();
72-
const auto decoder_factory = new webrtc::VideoToolboxVideoDecoderFactory();
86+
cricket::WebRtcVideoEncoderFactory *platform_encoder_factory = nullptr;
87+
cricket::WebRtcVideoDecoderFactory *platform_decoder_factory = nullptr;
88+
if (encoderFactory) {
89+
platform_encoder_factory = new webrtc::ObjCVideoEncoderFactory(encoderFactory);
90+
}
91+
if (decoderFactory) {
92+
platform_decoder_factory = new webrtc::ObjCVideoDecoderFactory(decoderFactory);
93+
}
7394

7495
// Ownership of encoder/decoder factories is passed on to the
7596
// peerconnectionfactory, that handles deleting them.
76-
_nativeFactory = webrtc::CreatePeerConnectionFactory(
77-
_networkThread.get(), _workerThread.get(), _signalingThread.get(),
78-
nullptr, encoder_factory, decoder_factory);
97+
_nativeFactory = webrtc::CreatePeerConnectionFactory(_networkThread.get(),
98+
_workerThread.get(),
99+
_signalingThread.get(),
100+
nullptr,
101+
platform_encoder_factory,
102+
platform_decoder_factory);
79103
#endif
80104
NSAssert(_nativeFactory, @"Failed to initialize PeerConnectionFactory!");
81105
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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 *)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+
- (std::unique_ptr<webrtc::RTPFragmentationHeader>)toCpp {
48+
auto fragmentationHeader =
49+
std::unique_ptr<webrtc::RTPFragmentationHeader>(new webrtc::RTPFragmentationHeader);
50+
fragmentationHeader->VerifyAndAllocateFragmentationHeader(_fragmentationOffset.count);
51+
for (NSUInteger i = 0; i < _fragmentationOffset.count; ++i) {
52+
fragmentationHeader->fragmentationOffset[i] = (size_t)_fragmentationOffset[i].unsignedIntValue;
53+
fragmentationHeader->fragmentationLength[i] = (size_t)_fragmentationLength[i].unsignedIntValue;
54+
fragmentationHeader->fragmentationTimeDiff[i] =
55+
(uint16_t)_fragmentationOffset[i].unsignedIntValue;
56+
fragmentationHeader->fragmentationPlType[i] = (uint8_t)_fragmentationOffset[i].unsignedIntValue;
57+
}
58+
59+
return fragmentationHeader;
60+
}
61+
62+
@end

0 commit comments

Comments
 (0)