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_WEBRTCMEDIAENGINE_H_ 12 #define MEDIA_ENGINE_WEBRTCMEDIAENGINE_H_ 13 14 #include <memory> 15 #include <string> 16 #include <vector> 17 18 #include "call/call.h" 19 #include "media/base/mediaengine.h" 20 21 namespace webrtc { 22 class AudioDecoderFactory; 23 class AudioDeviceModule; 24 class AudioMixer; 25 class AudioProcessing; 26 class VideoDecoderFactory; 27 class VideoEncoderFactory; 28 } 29 namespace cricket { 30 class WebRtcVideoDecoderFactory; 31 class WebRtcVideoEncoderFactory; 32 } 33 34 namespace cricket { 35 36 class WebRtcMediaEngineFactory { 37 public: 38 // These Create methods may be called on any thread, though the engine is 39 // only expected to be used on one thread, internally called the "worker 40 // thread". This is the thread Init must be called on. 41 // 42 // TODO(deadbeef): Change these to return an std::unique_ptr<>, to indicate 43 // that the caller owns the returned object. 44 static MediaEngineInterface* Create( 45 webrtc::AudioDeviceModule* adm, 46 const rtc::scoped_refptr<webrtc::AudioEncoderFactory>& 47 audio_encoder_factory, 48 const rtc::scoped_refptr<webrtc::AudioDecoderFactory>& 49 audio_decoder_factory, 50 WebRtcVideoEncoderFactory* video_encoder_factory, 51 WebRtcVideoDecoderFactory* video_decoder_factory); 52 static MediaEngineInterface* Create( 53 webrtc::AudioDeviceModule* adm, 54 const rtc::scoped_refptr<webrtc::AudioEncoderFactory>& 55 audio_encoder_factory, 56 const rtc::scoped_refptr<webrtc::AudioDecoderFactory>& 57 audio_decoder_factory, 58 WebRtcVideoEncoderFactory* video_encoder_factory, 59 WebRtcVideoDecoderFactory* video_decoder_factory, 60 rtc::scoped_refptr<webrtc::AudioMixer> audio_mixer, 61 rtc::scoped_refptr<webrtc::AudioProcessing> apm); 62 63 // Create a MediaEngineInterface with optional video codec factories. These 64 // video factories represents all video codecs, i.e. no extra internal video 65 // codecs will be added. 66 static std::unique_ptr<MediaEngineInterface> Create( 67 rtc::scoped_refptr<webrtc::AudioDeviceModule> adm, 68 rtc::scoped_refptr<webrtc::AudioEncoderFactory> audio_encoder_factory, 69 rtc::scoped_refptr<webrtc::AudioDecoderFactory> audio_decoder_factory, 70 std::unique_ptr<webrtc::VideoEncoderFactory> video_encoder_factory, 71 std::unique_ptr<webrtc::VideoDecoderFactory> video_decoder_factory, 72 rtc::scoped_refptr<webrtc::AudioMixer> audio_mixer, 73 rtc::scoped_refptr<webrtc::AudioProcessing> audio_processing); 74 }; 75 76 // Verify that extension IDs are within 1-byte extension range and are not 77 // overlapping. 78 bool ValidateRtpExtensions(const std::vector<webrtc::RtpExtension>& extensions); 79 80 // Discard any extensions not validated by the 'supported' predicate. Duplicate 81 // extensions are removed if 'filter_redundant_extensions' is set, and also any 82 // mutually exclusive extensions (see implementation for details) are removed. 83 std::vector<webrtc::RtpExtension> FilterRtpExtensions( 84 const std::vector<webrtc::RtpExtension>& extensions, 85 bool (*supported)(const std::string&), 86 bool filter_redundant_extensions); 87 88 webrtc::Call::Config::BitrateConfig GetBitrateConfigForCodec( 89 const Codec& codec); 90 91 } // namespace cricket 92 93 #endif // MEDIA_ENGINE_WEBRTCMEDIAENGINE_H_ 94