sri_build_encoder_factory.cpp 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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. namespace webrtc {
  31. class ExternalEncoderFactory : public webrtc::VideoEncoderFactory {
  32. public:
  33. std::vector<webrtc::SdpVideoFormat> GetSupportedFormats()
  34. const override {
  35. std::vector<webrtc::SdpVideoFormat> video_formats;
  36. for (const webrtc::SdpVideoFormat& h264_format : webrtc::SupportedH264Codecs())
  37. video_formats.push_back(h264_format);
  38. return video_formats;
  39. }
  40. ExternalEncoderFactory::CodecInfo QueryVideoEncoder(
  41. const webrtc::SdpVideoFormat& format) const override {
  42. CodecInfo codec_info = { false };
  43. // codec_info.is_hardware_accelerated = true;
  44. codec_info.has_internal_source = false;
  45. return codec_info;
  46. }
  47. std::unique_ptr<webrtc::VideoEncoder> CreateVideoEncoder(
  48. const webrtc::SdpVideoFormat& format) override {
  49. if (absl::EqualsIgnoreCase(format.name, cricket::kH264CodecName)) {
  50. if (webrtc::H264Encoder::IsSupported()) {
  51. printf("进入h264 encode \n");
  52. return absl::make_unique<webrtc::JetsonVideoEncoder>(cricket::VideoCodec(format));
  53. }
  54. }
  55. return nullptr;
  56. }
  57. };
  58. std::unique_ptr<webrtc::VideoEncoderFactory> CreateExternalVideoEncoderFactory() {
  59. return std::make_unique<ExternalEncoderFactory>();
  60. }
  61. }
  62. // /*
  63. // * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
  64. // *
  65. // * Use of this source code is governed by a BSD-style license
  66. // * that can be found in the LICENSE file in the root of the source
  67. // * tree. An additional intellectual property rights grant can be found
  68. // * in the file PATENTS. All contributing project authors may
  69. // * be found in the AUTHORS file in the root of the source tree.
  70. // */
  71. // #include "api/video_codecs/builtin_video_encoder_factory.h"
  72. // #include <memory>
  73. // #include <vector>
  74. // #include "absl/strings/match.h"
  75. // #include "api/video_codecs/sdp_video_format.h"
  76. // #include "api/video_codecs/video_encoder.h"
  77. // #include "media/base/codec.h"
  78. // #include "media/base/media_constants.h"
  79. // #include "media/engine/encoder_simulcast_proxy.h"
  80. // #include "media/engine/internal_encoder_factory.h"
  81. // #include "rtc_base/checks.h"
  82. // #include "sri_build_encoder_factory.h"
  83. // #include "absl/memory/memory.h"
  84. // #include "media/engine/internal_decoder_factory.h"
  85. // #include "rtc_base/logging.h"
  86. // #include "modules/video_coding/codecs/h264/include/h264.h"
  87. // #include "modules/video_coding/codecs/vp8/include/vp8.h"
  88. // #include "modules/video_coding/codecs/vp9/include/vp9.h"
  89. // #include "api/video_codecs/video_encoder_factory.h"
  90. // #include "rtc_base/checks.h"
  91. // namespace webrtc {
  92. // class ExternalEncoderFactory : public webrtc::VideoEncoderFactory {
  93. // public:
  94. // std::vector<webrtc::SdpVideoFormat> GetSupportedFormats()
  95. // const override {
  96. // std::vector<webrtc::SdpVideoFormat> video_formats;
  97. // for (const webrtc::SdpVideoFormat& vp9_format : webrtc::SupportedVP9Codecs())
  98. // video_formats.push_back(vp9_format);
  99. // return video_formats;
  100. // }
  101. // ExternalEncoderFactory::CodecInfo QueryVideoEncoder(
  102. // const webrtc::SdpVideoFormat& format) const override {
  103. // CodecInfo codec_info = { false };
  104. // // codec_info.is_hardware_accelerated = true;
  105. // codec_info.has_internal_source = false;
  106. // return codec_info;
  107. // }
  108. // std::unique_ptr<webrtc::VideoEncoder> CreateVideoEncoder(
  109. // const webrtc::SdpVideoFormat& format) override {
  110. // if (absl::EqualsIgnoreCase(format.name, cricket::kH264CodecName)) {
  111. // // if (webrtc::VP9Encoder::IsSupported()) {
  112. // // printf("VP9 encode \n");
  113. // return absl::make_unique<webrtc::VP9EncoderImpl_>(cricket::VideoCodec(format));
  114. // // return absl::make_unique<webrtc::H264EncoderImpl_>(cricket::VideoCodec(format));
  115. // // }
  116. // }
  117. // return nullptr;
  118. // }
  119. // };
  120. // std::unique_ptr<webrtc::VideoEncoderFactory> CreateExternalVideoEncoderFactory() {
  121. // return std::make_unique<ExternalEncoderFactory>();
  122. // }
  123. // }