// /* // * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. // * // * Use of this source code is governed by a BSD-style license // * that can be found in the LICENSE file in the root of the source // * tree. An additional intellectual property rights grant can be found // * in the file PATENTS. All contributing project authors may // * be found in the AUTHORS file in the root of the source tree. // */ #include "api/video_codecs/builtin_video_encoder_factory.h" #include #include #include "absl/strings/match.h" #include "api/video_codecs/sdp_video_format.h" #include "api/video_codecs/video_encoder.h" #include "media/base/codec.h" #include "media/base/media_constants.h" #include "media/engine/encoder_simulcast_proxy.h" #include "media/engine/internal_encoder_factory.h" #include "rtc_base/checks.h" #include "sri_build_encoder_factory.h" #include "absl/memory/memory.h" #include "media/engine/internal_decoder_factory.h" #include "rtc_base/logging.h" #include "modules/video_coding/codecs/h264/include/h264.h" #include "modules/video_coding/codecs/vp8/include/vp8.h" #include "modules/video_coding/codecs/vp9/include/vp9.h" #include "api/video_codecs/video_encoder_factory.h" #include "rtc_base/checks.h" namespace webrtc { class ExternalEncoderFactory : public webrtc::VideoEncoderFactory { public: std::vector GetSupportedFormats() const override { std::vector video_formats; for (const webrtc::SdpVideoFormat& h264_format : webrtc::SupportedH264Codecs()) video_formats.push_back(h264_format); return video_formats; } ExternalEncoderFactory::CodecInfo QueryVideoEncoder( const webrtc::SdpVideoFormat& format) const override { CodecInfo codec_info = { false }; // codec_info.is_hardware_accelerated = true; codec_info.has_internal_source = false; return codec_info; } std::unique_ptr CreateVideoEncoder( const webrtc::SdpVideoFormat& format) override { if (absl::EqualsIgnoreCase(format.name, cricket::kH264CodecName)) { if (webrtc::H264Encoder::IsSupported()) { // printf("进入h264 encode \n"); // return absl::make_unique(cricket::VideoCodec(format)); //jetson nvenc加速 return absl::make_unique(cricket::VideoCodec(format)); } } return nullptr; } }; std::unique_ptr CreateExternalVideoEncoderFactory() { return std::make_unique(); } }