123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- /*
- * 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 <memory>
- #include <vector>
- #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"
- #include "jetson_nv_encoder.h"
- namespace webrtc {
- class ExternalEncoderFactory : public webrtc::VideoEncoderFactory {
- public:
- std::vector<webrtc::SdpVideoFormat> GetSupportedFormats()
- const override {
- std::vector<webrtc::SdpVideoFormat> 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<webrtc::VideoEncoder> CreateVideoEncoder(
- const webrtc::SdpVideoFormat& format) override {
- if (absl::EqualsIgnoreCase(format.name, cricket::kH264CodecName)) {
- if (webrtc::H264Encoder::IsSupported()) {
- printf("进入h264 encode \n");
- // if (xop::NvidiaD3D11Encoder::IsSupported()) {
- // return absl::make_unique<webrtc::NvEncoder>(cricket::VideoCodec(format));
- return absl::make_unique<webrtc::H264EncoderImpl_>(cricket::VideoCodec(format));
-
- // }
- // else if (xop::IntelD3DEncoder::IsSupported()) {
- // return absl::make_unique<webrtc::QsvEncoder>(cricket::VideoCodec(format));
- // }
- // else {
- // return webrtc::H264Encoder::Create(cricket::VideoCodec(format));
- // }
- }
- }
- return nullptr;
- }
- };
- std::unique_ptr<webrtc::VideoEncoderFactory> CreateExternalVideoEncoderFactory() {
- return std::make_unique<ExternalEncoderFactory>();
- }
- }
|