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

Side by Side Diff: webrtc/sdk/objc/Framework/Classes/videotoolboxvideocodecfactory.cc

Issue 2484493002: Prepare iOS H264 HW encoder for High Profile (Closed)
Patch Set: Don't use default in switch Created 4 years, 1 month 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
« no previous file with comments | « webrtc/sdk/objc/Framework/Classes/h264_video_toolbox_encoder.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 #include "webrtc/sdk/objc/Framework/Classes/videotoolboxvideocodecfactory.h" 10 #include "webrtc/sdk/objc/Framework/Classes/videotoolboxvideocodecfactory.h"
11 11
12 #include "webrtc/base/logging.h" 12 #include "webrtc/base/logging.h"
13 #include "webrtc/common_video/h264/profile_level_id.h"
13 #include "webrtc/media/base/codec.h" 14 #include "webrtc/media/base/codec.h"
14 #if defined(WEBRTC_IOS) 15 #if defined(WEBRTC_IOS)
15 #include "webrtc/sdk/objc/Framework/Classes/h264_video_toolbox_encoder.h" 16 #include "webrtc/sdk/objc/Framework/Classes/h264_video_toolbox_encoder.h"
16 #include "webrtc/sdk/objc/Framework/Classes/h264_video_toolbox_decoder.h" 17 #include "webrtc/sdk/objc/Framework/Classes/h264_video_toolbox_decoder.h"
17 #endif 18 #endif
18 19
19 // TODO(kthelgason): delete this when CreateVideoDecoder takes 20 // TODO(kthelgason): delete this when CreateVideoDecoder takes
20 // a cricket::VideoCodec instead of webrtc::VideoCodecType. 21 // a cricket::VideoCodec instead of webrtc::VideoCodecType.
21 static const char* NameFromCodecType(webrtc::VideoCodecType type) { 22 static const char* NameFromCodecType(webrtc::VideoCodecType type) {
22 switch (type) { 23 switch (type) {
23 case webrtc::kVideoCodecVP8: 24 case webrtc::kVideoCodecVP8:
24 return cricket::kVp8CodecName; 25 return cricket::kVp8CodecName;
25 case webrtc::kVideoCodecVP9: 26 case webrtc::kVideoCodecVP9:
26 return cricket::kVp9CodecName; 27 return cricket::kVp9CodecName;
27 case webrtc::kVideoCodecH264: 28 case webrtc::kVideoCodecH264:
28 return cricket::kH264CodecName; 29 return cricket::kH264CodecName;
29 default: 30 default:
30 return "Unknown codec"; 31 return "Unknown codec";
31 } 32 }
32 } 33 }
33 34
34 namespace webrtc { 35 namespace webrtc {
35 36
36 // VideoToolboxVideoEncoderFactory 37 // VideoToolboxVideoEncoderFactory
37 38
38 VideoToolboxVideoEncoderFactory::VideoToolboxVideoEncoderFactory() { 39 VideoToolboxVideoEncoderFactory::VideoToolboxVideoEncoderFactory() {
39 // Hardware H264 encoding only supported on iOS for now. 40 // Hardware H264 encoding only supported on iOS for now.
40 #if defined(WEBRTC_IOS) 41 #if defined(WEBRTC_IOS)
41 supported_codecs_.push_back(cricket::VideoCodec(cricket::kH264CodecName)); 42 // TODO(magjed): Push Constrained High profile as well when negotiation is
43 // ready, http://crbug/webrtc/6337.
44 cricket::VideoCodec constrained_baseline(cricket::kH264CodecName);
45 // TODO(magjed): Enumerate actual level instead of using hardcoded level 3.1.
46 // Level 3.1 is 1280x720@30fps which is enough for now.
47 const H264::ProfileLevelId constrained_baseline_profile(
48 H264::kProfileConstrainedBaseline, H264::kLevel3_1);
49 constrained_baseline.SetParam(
50 cricket::kH264FmtpProfileLevelId,
51 *H264::ProfileLevelIdToString(constrained_baseline_profile));
52 constrained_baseline.SetParam(cricket::kH264FmtpLevelAsymmetryAllowed, "1");
53 constrained_baseline.SetParam(cricket::kH264FmtpPacketizationMode, "1");
54 supported_codecs_.push_back(constrained_baseline);
42 #endif 55 #endif
43 } 56 }
44 57
45 VideoToolboxVideoEncoderFactory::~VideoToolboxVideoEncoderFactory() {} 58 VideoToolboxVideoEncoderFactory::~VideoToolboxVideoEncoderFactory() {}
46 59
47 VideoEncoder* VideoToolboxVideoEncoderFactory::CreateVideoEncoder( 60 VideoEncoder* VideoToolboxVideoEncoderFactory::CreateVideoEncoder(
48 const cricket::VideoCodec& codec) { 61 const cricket::VideoCodec& codec) {
49 #if defined(WEBRTC_IOS) 62 #if defined(WEBRTC_IOS)
50 if (FindMatchingCodec(supported_codecs_, codec)) { 63 if (FindMatchingCodec(supported_codecs_, codec)) {
51 LOG(LS_INFO) << "Creating HW encoder for " << codec.name; 64 LOG(LS_INFO) << "Creating HW encoder for " << codec.name;
52 return new H264VideoToolboxEncoder(); 65 return new H264VideoToolboxEncoder(codec);
53 } 66 }
54 #endif 67 #endif
55 LOG(LS_INFO) << "No HW encoder found for codec " << codec.name; 68 LOG(LS_INFO) << "No HW encoder found for codec " << codec.name;
56 return nullptr; 69 return nullptr;
57 } 70 }
58 71
59 void VideoToolboxVideoEncoderFactory::DestroyVideoEncoder( 72 void VideoToolboxVideoEncoderFactory::DestroyVideoEncoder(
60 VideoEncoder* encoder) { 73 VideoEncoder* encoder) {
61 #if defined(WEBRTC_IOS) 74 #if defined(WEBRTC_IOS)
62 delete encoder; 75 delete encoder;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 107
95 void VideoToolboxVideoDecoderFactory::DestroyVideoDecoder( 108 void VideoToolboxVideoDecoderFactory::DestroyVideoDecoder(
96 VideoDecoder* decoder) { 109 VideoDecoder* decoder) {
97 #if defined(WEBRTC_IOS) 110 #if defined(WEBRTC_IOS)
98 delete decoder; 111 delete decoder;
99 decoder = nullptr; 112 decoder = nullptr;
100 #endif 113 #endif
101 } 114 }
102 115
103 } // namespace webrtc 116 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/sdk/objc/Framework/Classes/h264_video_toolbox_encoder.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698