sri_build_encoder_factory.cpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
  3. *
  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
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #include "api/video_codecs/builtin_video_encoder_factory.h"
  11. #include <memory>
  12. #include <vector>
  13. #include "absl/strings/match.h"
  14. #include "api/video_codecs/sdp_video_format.h"
  15. #include "api/video_codecs/video_encoder.h"
  16. #include "media/base/codec.h"
  17. #include "media/base/media_constants.h"
  18. #include "media/engine/encoder_simulcast_proxy.h"
  19. #include "media/engine/internal_encoder_factory.h"
  20. #include "rtc_base/checks.h"
  21. #include "sri_build_encoder_factory.h"
  22. #include "absl/memory/memory.h"
  23. #include "media/engine/internal_decoder_factory.h"
  24. #include "rtc_base/logging.h"
  25. #include "modules/video_coding/codecs/h264/include/h264.h"
  26. #include "modules/video_coding/codecs/vp8/include/vp8.h"
  27. #include "modules/video_coding/codecs/vp9/include/vp9.h"
  28. #include "api/video_codecs/video_encoder_factory.h"
  29. #include "rtc_base/checks.h"
  30. #include "jetson_nv_encoder.h"
  31. namespace webrtc {
  32. class ExternalEncoderFactory : public webrtc::VideoEncoderFactory {
  33. public:
  34. std::vector<webrtc::SdpVideoFormat> GetSupportedFormats()
  35. const override {
  36. std::vector<webrtc::SdpVideoFormat> video_formats;
  37. for (const webrtc::SdpVideoFormat& h264_format : webrtc::SupportedH264Codecs())
  38. video_formats.push_back(h264_format);
  39. return video_formats;
  40. }
  41. ExternalEncoderFactory::CodecInfo QueryVideoEncoder(
  42. const webrtc::SdpVideoFormat& format) const override {
  43. CodecInfo codec_info = { false };
  44. // codec_info.is_hardware_accelerated = true;
  45. codec_info.has_internal_source = false;
  46. return codec_info;
  47. }
  48. std::unique_ptr<webrtc::VideoEncoder> CreateVideoEncoder(
  49. const webrtc::SdpVideoFormat& format) override {
  50. if (absl::EqualsIgnoreCase(format.name, cricket::kH264CodecName)) {
  51. if (webrtc::H264Encoder::IsSupported()) {
  52. printf("进入h264 encode \n");
  53. // if (xop::NvidiaD3D11Encoder::IsSupported()) {
  54. // return absl::make_unique<webrtc::NvEncoder>(cricket::VideoCodec(format));
  55. return absl::make_unique<webrtc::H264EncoderImpl_>(cricket::VideoCodec(format));
  56. // }
  57. // else if (xop::IntelD3DEncoder::IsSupported()) {
  58. // return absl::make_unique<webrtc::QsvEncoder>(cricket::VideoCodec(format));
  59. // }
  60. // else {
  61. // return webrtc::H264Encoder::Create(cricket::VideoCodec(format));
  62. // }
  63. }
  64. }
  65. return nullptr;
  66. }
  67. };
  68. std::unique_ptr<webrtc::VideoEncoderFactory> CreateExternalVideoEncoderFactory() {
  69. return std::make_unique<ExternalEncoderFactory>();
  70. }
  71. }