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

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

Issue 2509273002: Unify VideoCodecType to/from string functionality (Closed)
Patch Set: Rebase and update unknown string in WebRtcVideoEncoderFactory 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/modules/video_coding/utility/ivf_file_writer.cc ('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/common_video/h264/profile_level_id.h"
14 #include "webrtc/media/base/codec.h" 14 #include "webrtc/media/base/codec.h"
15 #if defined(WEBRTC_IOS) 15 #if defined(WEBRTC_IOS)
16 #include "webrtc/sdk/objc/Framework/Classes/h264_video_toolbox_encoder.h" 16 #include "webrtc/sdk/objc/Framework/Classes/h264_video_toolbox_encoder.h"
17 #include "webrtc/sdk/objc/Framework/Classes/h264_video_toolbox_decoder.h" 17 #include "webrtc/sdk/objc/Framework/Classes/h264_video_toolbox_decoder.h"
18 #endif 18 #endif
19 19
20 // TODO(kthelgason): delete this when CreateVideoDecoder takes
21 // a cricket::VideoCodec instead of webrtc::VideoCodecType.
22 static const char* NameFromCodecType(webrtc::VideoCodecType type) {
23 switch (type) {
24 case webrtc::kVideoCodecVP8:
25 return cricket::kVp8CodecName;
26 case webrtc::kVideoCodecVP9:
27 return cricket::kVp9CodecName;
28 case webrtc::kVideoCodecH264:
29 return cricket::kH264CodecName;
30 default:
31 return "Unknown codec";
32 }
33 }
34
35 namespace webrtc { 20 namespace webrtc {
36 21
37 // VideoToolboxVideoEncoderFactory 22 // VideoToolboxVideoEncoderFactory
38 23
39 VideoToolboxVideoEncoderFactory::VideoToolboxVideoEncoderFactory() { 24 VideoToolboxVideoEncoderFactory::VideoToolboxVideoEncoderFactory() {
40 // Hardware H264 encoding only supported on iOS for now. 25 // Hardware H264 encoding only supported on iOS for now.
41 #if defined(WEBRTC_IOS) 26 #if defined(WEBRTC_IOS)
42 // TODO(magjed): Push Constrained High profile as well when negotiation is 27 // TODO(magjed): Push Constrained High profile as well when negotiation is
43 // ready, http://crbug/webrtc/6337. 28 // ready, http://crbug/webrtc/6337.
44 cricket::VideoCodec constrained_baseline(cricket::kH264CodecName); 29 cricket::VideoCodec constrained_baseline(cricket::kH264CodecName);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 VideoToolboxVideoDecoderFactory::VideoToolboxVideoDecoderFactory() { 72 VideoToolboxVideoDecoderFactory::VideoToolboxVideoDecoderFactory() {
88 #if defined(WEBRTC_IOS) 73 #if defined(WEBRTC_IOS)
89 supported_codecs_.push_back(cricket::VideoCodec("H264")); 74 supported_codecs_.push_back(cricket::VideoCodec("H264"));
90 #endif 75 #endif
91 } 76 }
92 77
93 VideoToolboxVideoDecoderFactory::~VideoToolboxVideoDecoderFactory() {} 78 VideoToolboxVideoDecoderFactory::~VideoToolboxVideoDecoderFactory() {}
94 79
95 VideoDecoder* VideoToolboxVideoDecoderFactory::CreateVideoDecoder( 80 VideoDecoder* VideoToolboxVideoDecoderFactory::CreateVideoDecoder(
96 VideoCodecType type) { 81 VideoCodecType type) {
97 const auto codec = cricket::VideoCodec(NameFromCodecType(type)); 82 const rtc::Optional<const char*> codec_name = CodecTypeToPayloadName(type);
83 if (!codec_name) {
84 LOG(LS_ERROR) << "Invalid codec type: " << type;
85 return nullptr;
86 }
87 const cricket::VideoCodec codec(*codec_name);
98 #if defined(WEBRTC_IOS) 88 #if defined(WEBRTC_IOS)
99 if (FindMatchingCodec(supported_codecs_, codec)) { 89 if (FindMatchingCodec(supported_codecs_, codec)) {
100 LOG(LS_INFO) << "Creating HW decoder for " << codec.name; 90 LOG(LS_INFO) << "Creating HW decoder for " << codec.name;
101 return new H264VideoToolboxDecoder(); 91 return new H264VideoToolboxDecoder();
102 } 92 }
103 #endif 93 #endif
104 LOG(LS_INFO) << "No HW decoder found for codec " << codec.name; 94 LOG(LS_INFO) << "No HW decoder found for codec " << codec.name;
105 return nullptr; 95 return nullptr;
106 } 96 }
107 97
108 void VideoToolboxVideoDecoderFactory::DestroyVideoDecoder( 98 void VideoToolboxVideoDecoderFactory::DestroyVideoDecoder(
109 VideoDecoder* decoder) { 99 VideoDecoder* decoder) {
110 #if defined(WEBRTC_IOS) 100 #if defined(WEBRTC_IOS)
111 delete decoder; 101 delete decoder;
112 decoder = nullptr; 102 decoder = nullptr;
113 #endif 103 #endif
114 } 104 }
115 105
116 } // namespace webrtc 106 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/video_coding/utility/ivf_file_writer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698