Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(935)

Side by Side Diff: webrtc/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoCodecH264.mm

Issue 2978623002: Implement H264 codec in Objective-C classes. (Closed)
Patch Set: Fix test after rebase. Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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/RTCVideoCodecH264.h"
12
13 #import <VideoToolbox/VideoToolbox.h>
14 #include <vector>
15
16 #import "RTCVideoCodec+Private.h"
17 #import "WebRTC/RTCVideoCodec.h"
18 #import "WebRTC/RTCVideoFrame.h"
19 #import "WebRTC/RTCVideoFrameBuffer.h"
20
21 #include "webrtc/rtc_base/timeutils.h"
22 #include "webrtc/sdk/objc/Framework/Classes/Video/objc_frame_buffer.h"
23 #include "webrtc/system_wrappers/include/field_trial.h"
24
25 const char kHighProfileExperiment[] = "WebRTC-H264HighProfile";
26 static NSString *kLevel31ConstrainedHigh = @"640c1f";
27 static NSString *kLevel31ConstrainedBaseline = @"42e01f";
28
29 bool IsHighProfileEnabled() {
30 return webrtc::field_trial::IsEnabled(kHighProfileExperiment);
31 }
32
33 // H264 specific settings.
34 @implementation RTCCodecSpecificInfoH264
35
36 @synthesize packetizationMode = _packetizationMode;
37
38 - (webrtc::CodecSpecificInfo)toCpp {
39 webrtc::CodecSpecificInfo codecSpecificInfo;
40 codecSpecificInfo.codecType = webrtc::kVideoCodecH264;
41 codecSpecificInfo.codec_name = "H264";
42 codecSpecificInfo.codecSpecific.H264.packetization_mode =
43 (webrtc::H264PacketizationMode)_packetizationMode;
44
45 return codecSpecificInfo;
46 }
47
48 @end
49
50 // Encoder factory.
51 @implementation RTCVideoEncoderFactoryH264
52
53 - (NSArray<RTCVideoCodecInfo *> *)supportedCodecs {
54 NSMutableArray<RTCVideoCodecInfo *> *codecs = [NSMutableArray array];
55 NSString *codecName = [NSString stringWithUTF8String:cricket::kH264CodecName];
56
57 if (IsHighProfileEnabled()) {
58 NSDictionary<NSString *, NSString *> *constrainedHighParams = @{
59 @"profile-level-id" : kLevel31ConstrainedHigh,
60 @"level-asymmetry-allowed" : @"1",
61 @"packetization-mode" : @"1",
62 // VideoToolbox does not have a constant for Constrained High.
63 @"videotoolbox-profile" : (__bridge NSString *)kVTProfileLevel_H264_High_3 _1,
64 };
65 RTCVideoCodecInfo *constrainedHighInfo =
66 [[RTCVideoCodecInfo alloc] initWithPayload:0
67 name:codecName
68 parameters:constrainedHighParams];
69 [codecs addObject:constrainedHighInfo];
70 }
71
72 NSDictionary<NSString *, NSString *> *constrainedBaselineParams = @{
73 @"profile-level-id" : kLevel31ConstrainedBaseline,
74 @"level-asymmetry-allowed" : @"1",
75 @"packetization-mode" : @"1",
76 // VideoToolbox does not have a constant for Constrained Baseline.
77 @"videotoolbox-profile" : (__bridge NSString *)kVTProfileLevel_H264_Baseline _3_1,
78 };
79 RTCVideoCodecInfo *constrainedBaselineInfo =
80 [[RTCVideoCodecInfo alloc] initWithPayload:0
81 name:codecName
82 parameters:constrainedBaselineParams];
83 [codecs addObject:constrainedBaselineInfo];
84
85 return [codecs copy];
86 }
87
88 - (id<RTCVideoEncoder>)createEncoder:(RTCVideoCodecInfo *)info {
89 return [[RTCVideoEncoderH264 alloc] initWithCodecInfo:info];
90 }
91
92 @end
93
94 // Decoder factory.
95 @implementation RTCVideoDecoderFactoryH264
96
97 - (id<RTCVideoDecoder>)createDecoder:(RTCVideoCodecInfo *)info {
98 return [[RTCVideoDecoderH264 alloc] init];
99 }
100
101 - (NSArray<RTCVideoCodecInfo *> *)supportedCodecs {
102 NSString *codecName = [NSString stringWithUTF8String:cricket::kH264CodecName];
103 return @[ [[RTCVideoCodecInfo alloc] initWithPayload:0 name:codecName paramete rs:@{}] ];
104 }
105
106 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698