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