| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 | 10 |
| 11 #include "webrtc/video_encoder.h" | 11 #include "webrtc/media/engine/videoencodersoftwarefallbackwrapper.h" |
| 12 | 12 |
| 13 #include "webrtc/base/checks.h" | |
| 14 #include "webrtc/base/logging.h" | 13 #include "webrtc/base/logging.h" |
| 15 #include "webrtc/modules/video_coding/codecs/h264/include/h264.h" | 14 #include "webrtc/modules/video_coding/include/video_error_codes.h" |
| 16 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h" | |
| 17 #include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h" | |
| 18 | 15 |
| 19 namespace webrtc { | 16 namespace webrtc { |
| 20 VideoEncoder* VideoEncoder::Create(VideoEncoder::EncoderType codec_type) { | |
| 21 RTC_DCHECK(IsSupportedSoftware(codec_type)); | |
| 22 switch (codec_type) { | |
| 23 case kH264: | |
| 24 return H264Encoder::Create(); | |
| 25 case kVp8: | |
| 26 return VP8Encoder::Create(); | |
| 27 case kVp9: | |
| 28 return VP9Encoder::Create(); | |
| 29 case kUnsupportedCodec: | |
| 30 RTC_NOTREACHED(); | |
| 31 return nullptr; | |
| 32 } | |
| 33 RTC_NOTREACHED(); | |
| 34 return nullptr; | |
| 35 } | |
| 36 | |
| 37 bool VideoEncoder::IsSupportedSoftware(EncoderType codec_type) { | |
| 38 switch (codec_type) { | |
| 39 case kH264: | |
| 40 return H264Encoder::IsSupported(); | |
| 41 case kVp8: | |
| 42 return true; | |
| 43 case kVp9: | |
| 44 return VP9Encoder::IsSupported(); | |
| 45 case kUnsupportedCodec: | |
| 46 RTC_NOTREACHED(); | |
| 47 return false; | |
| 48 } | |
| 49 RTC_NOTREACHED(); | |
| 50 return false; | |
| 51 } | |
| 52 | |
| 53 VideoEncoder::EncoderType VideoEncoder::CodecToEncoderType( | |
| 54 VideoCodecType codec_type) { | |
| 55 switch (codec_type) { | |
| 56 case kVideoCodecH264: | |
| 57 return VideoEncoder::kH264; | |
| 58 case kVideoCodecVP8: | |
| 59 return VideoEncoder::kVp8; | |
| 60 case kVideoCodecVP9: | |
| 61 return VideoEncoder::kVp9; | |
| 62 default: | |
| 63 return VideoEncoder::kUnsupportedCodec; | |
| 64 } | |
| 65 } | |
| 66 | 17 |
| 67 VideoEncoderSoftwareFallbackWrapper::VideoEncoderSoftwareFallbackWrapper( | 18 VideoEncoderSoftwareFallbackWrapper::VideoEncoderSoftwareFallbackWrapper( |
| 68 VideoCodecType codec_type, | 19 VideoCodecType codec_type, |
| 69 webrtc::VideoEncoder* encoder) | 20 webrtc::VideoEncoder* encoder) |
| 70 : rates_set_(false), | 21 : rates_set_(false), |
| 71 channel_parameters_set_(false), | 22 channel_parameters_set_(false), |
| 72 encoder_type_(CodecToEncoderType(codec_type)), | 23 encoder_type_(CodecToEncoderType(codec_type)), |
| 73 encoder_(encoder), | 24 encoder_(encoder), |
| 74 callback_(nullptr) {} | 25 callback_(nullptr) {} |
| 75 | 26 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 return encoder_->OnDroppedFrame(); | 157 return encoder_->OnDroppedFrame(); |
| 207 } | 158 } |
| 208 | 159 |
| 209 bool VideoEncoderSoftwareFallbackWrapper::SupportsNativeHandle() const { | 160 bool VideoEncoderSoftwareFallbackWrapper::SupportsNativeHandle() const { |
| 210 if (fallback_encoder_) | 161 if (fallback_encoder_) |
| 211 return fallback_encoder_->SupportsNativeHandle(); | 162 return fallback_encoder_->SupportsNativeHandle(); |
| 212 return encoder_->SupportsNativeHandle(); | 163 return encoder_->SupportsNativeHandle(); |
| 213 } | 164 } |
| 214 | 165 |
| 215 } // namespace webrtc | 166 } // namespace webrtc |
| OLD | NEW |