webrtc_media_engine.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Copyright (c) 2011 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. #ifndef MEDIA_ENGINE_WEBRTC_MEDIA_ENGINE_H_
  11. #define MEDIA_ENGINE_WEBRTC_MEDIA_ENGINE_H_
  12. #include <memory>
  13. #include <string>
  14. #include <vector>
  15. #include "api/audio/audio_mixer.h"
  16. #include "api/audio_codecs/audio_decoder_factory.h"
  17. #include "api/audio_codecs/audio_encoder_factory.h"
  18. #include "api/rtp_parameters.h"
  19. #include "api/task_queue/task_queue_factory.h"
  20. #include "api/transport/bitrate_settings.h"
  21. #include "api/transport/webrtc_key_value_config.h"
  22. #include "api/video_codecs/video_decoder_factory.h"
  23. #include "api/video_codecs/video_encoder_factory.h"
  24. #include "media/base/codec.h"
  25. #include "media/base/media_engine.h"
  26. #include "modules/audio_device/include/audio_device.h"
  27. #include "modules/audio_processing/include/audio_processing.h"
  28. #include "rtc_base/system/rtc_export.h"
  29. namespace cricket {
  30. struct MediaEngineDependencies {
  31. MediaEngineDependencies() = default;
  32. MediaEngineDependencies(const MediaEngineDependencies&) = delete;
  33. MediaEngineDependencies(MediaEngineDependencies&&) = default;
  34. MediaEngineDependencies& operator=(const MediaEngineDependencies&) = delete;
  35. MediaEngineDependencies& operator=(MediaEngineDependencies&&) = default;
  36. ~MediaEngineDependencies() = default;
  37. webrtc::TaskQueueFactory* task_queue_factory = nullptr;
  38. rtc::scoped_refptr<webrtc::AudioDeviceModule> adm;
  39. rtc::scoped_refptr<webrtc::AudioEncoderFactory> audio_encoder_factory;
  40. rtc::scoped_refptr<webrtc::AudioDecoderFactory> audio_decoder_factory;
  41. rtc::scoped_refptr<webrtc::AudioMixer> audio_mixer;
  42. rtc::scoped_refptr<webrtc::AudioProcessing> audio_processing;
  43. std::unique_ptr<webrtc::VideoEncoderFactory> video_encoder_factory;
  44. std::unique_ptr<webrtc::VideoDecoderFactory> video_decoder_factory;
  45. const webrtc::WebRtcKeyValueConfig* trials = nullptr;
  46. };
  47. // CreateMediaEngine may be called on any thread, though the engine is
  48. // only expected to be used on one thread, internally called the "worker
  49. // thread". This is the thread Init must be called on.
  50. RTC_EXPORT std::unique_ptr<MediaEngineInterface> CreateMediaEngine(
  51. MediaEngineDependencies dependencies);
  52. // Verify that extension IDs are within 1-byte extension range and are not
  53. // overlapping.
  54. bool ValidateRtpExtensions(const std::vector<webrtc::RtpExtension>& extensions);
  55. // Discard any extensions not validated by the 'supported' predicate. Duplicate
  56. // extensions are removed if 'filter_redundant_extensions' is set, and also any
  57. // mutually exclusive extensions (see implementation for details) are removed.
  58. std::vector<webrtc::RtpExtension> FilterRtpExtensions(
  59. const std::vector<webrtc::RtpExtension>& extensions,
  60. bool (*supported)(absl::string_view),
  61. bool filter_redundant_extensions,
  62. const webrtc::WebRtcKeyValueConfig& trials);
  63. webrtc::BitrateConstraints GetBitrateConfigForCodec(const Codec& codec);
  64. } // namespace cricket
  65. #endif // MEDIA_ENGINE_WEBRTC_MEDIA_ENGINE_H_