henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1 | /* |
kjellander | 1afca73 | 2016-02-07 20:46:45 -0800 | [diff] [blame] | 2 | * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3 | * |
kjellander | 1afca73 | 2016-02-07 20:46:45 -0800 | [diff] [blame] | 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. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 9 | */ |
| 10 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 11 | #ifndef MEDIA_BASE_MEDIA_ENGINE_H_ |
| 12 | #define MEDIA_BASE_MEDIA_ENGINE_H_ |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 13 | |
kjellander | fcfc804 | 2016-01-14 11:01:09 -0800 | [diff] [blame] | 14 | #if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 15 | #include <CoreAudio/CoreAudio.h> |
| 16 | #endif |
| 17 | |
Sebastian Jansson | fa0aa39 | 2018-11-16 09:54:32 +0100 | [diff] [blame] | 18 | #include <memory> |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 19 | #include <string> |
| 20 | #include <vector> |
| 21 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 22 | #include "api/audio_codecs/audio_decoder_factory.h" |
| 23 | #include "api/audio_codecs/audio_encoder_factory.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 24 | #include "api/crypto/crypto_options.h" |
| 25 | #include "api/rtp_parameters.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 26 | #include "call/audio_state.h" |
| 27 | #include "media/base/codec.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 28 | #include "media/base/media_channel.h" |
| 29 | #include "media/base/video_common.h" |
Niels Möller | d8970db | 2017-09-29 13:40:39 +0200 | [diff] [blame] | 30 | #include "rtc_base/platform_file.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 31 | |
Fredrik Solenberg | 709ed67 | 2015-09-15 12:26:33 +0200 | [diff] [blame] | 32 | namespace webrtc { |
solenberg | ff97631 | 2016-03-30 23:28:51 -0700 | [diff] [blame] | 33 | class AudioDeviceModule; |
gyzhou | 95aa964 | 2016-12-13 14:06:26 -0800 | [diff] [blame] | 34 | class AudioMixer; |
peah | a9cc40b | 2017-06-29 08:32:09 -0700 | [diff] [blame] | 35 | class AudioProcessing; |
Fredrik Solenberg | 709ed67 | 2015-09-15 12:26:33 +0200 | [diff] [blame] | 36 | class Call; |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 37 | } // namespace webrtc |
Fredrik Solenberg | 709ed67 | 2015-09-15 12:26:33 +0200 | [diff] [blame] | 38 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 39 | namespace cricket { |
| 40 | |
Florent Castelli | c1a0bcb | 2019-01-29 14:26:48 +0100 | [diff] [blame] | 41 | webrtc::RTCError CheckRtpParametersValues( |
| 42 | const webrtc::RtpParameters& new_parameters); |
| 43 | |
| 44 | webrtc::RTCError CheckRtpParametersInvalidModificationAndValues( |
Florent Castelli | 892acf0 | 2018-10-01 22:47:20 +0200 | [diff] [blame] | 45 | const webrtc::RtpParameters& old_parameters, |
| 46 | const webrtc::RtpParameters& new_parameters); |
| 47 | |
Stefan Holmer | 9d69c3f | 2015-12-07 10:45:43 +0100 | [diff] [blame] | 48 | struct RtpCapabilities { |
Paulina Hensman | 11b34f4 | 2018-04-09 14:24:52 +0200 | [diff] [blame] | 49 | RtpCapabilities(); |
| 50 | ~RtpCapabilities(); |
isheriff | 6f8d686 | 2016-05-26 11:24:55 -0700 | [diff] [blame] | 51 | std::vector<webrtc::RtpExtension> header_extensions; |
Stefan Holmer | 9d69c3f | 2015-12-07 10:45:43 +0100 | [diff] [blame] | 52 | }; |
| 53 | |
Sebastian Jansson | 84848f2 | 2018-11-16 10:40:36 +0100 | [diff] [blame] | 54 | class VoiceEngineInterface { |
| 55 | public: |
| 56 | VoiceEngineInterface() = default; |
| 57 | virtual ~VoiceEngineInterface() = default; |
| 58 | RTC_DISALLOW_COPY_AND_ASSIGN(VoiceEngineInterface); |
| 59 | |
| 60 | // Initialization |
| 61 | // Starts the engine. |
| 62 | virtual void Init() = 0; |
| 63 | |
| 64 | // TODO(solenberg): Remove once VoE API refactoring is done. |
| 65 | virtual rtc::scoped_refptr<webrtc::AudioState> GetAudioState() const = 0; |
| 66 | |
| 67 | // MediaChannel creation |
| 68 | // Creates a voice media channel. Returns NULL on failure. |
| 69 | virtual VoiceMediaChannel* CreateMediaChannel( |
| 70 | webrtc::Call* call, |
| 71 | const MediaConfig& config, |
| 72 | const AudioOptions& options, |
| 73 | const webrtc::CryptoOptions& crypto_options) = 0; |
| 74 | |
| 75 | virtual const std::vector<AudioCodec>& send_codecs() const = 0; |
| 76 | virtual const std::vector<AudioCodec>& recv_codecs() const = 0; |
| 77 | virtual RtpCapabilities GetCapabilities() const = 0; |
| 78 | |
| 79 | // Starts AEC dump using existing file, a maximum file size in bytes can be |
| 80 | // specified. Logging is stopped just before the size limit is exceeded. |
| 81 | // If max_size_bytes is set to a value <= 0, no limit will be used. |
| 82 | virtual bool StartAecDump(rtc::PlatformFile file, int64_t max_size_bytes) = 0; |
| 83 | |
| 84 | // Stops recording AEC dump. |
| 85 | virtual void StopAecDump() = 0; |
| 86 | }; |
| 87 | |
| 88 | class VideoEngineInterface { |
| 89 | public: |
| 90 | VideoEngineInterface() = default; |
| 91 | virtual ~VideoEngineInterface() = default; |
| 92 | RTC_DISALLOW_COPY_AND_ASSIGN(VideoEngineInterface); |
| 93 | |
| 94 | // Creates a video media channel, paired with the specified voice channel. |
| 95 | // Returns NULL on failure. |
| 96 | virtual VideoMediaChannel* CreateMediaChannel( |
| 97 | webrtc::Call* call, |
| 98 | const MediaConfig& config, |
| 99 | const VideoOptions& options, |
| 100 | const webrtc::CryptoOptions& crypto_options) = 0; |
| 101 | |
| 102 | virtual std::vector<VideoCodec> codecs() const = 0; |
| 103 | virtual RtpCapabilities GetCapabilities() const = 0; |
| 104 | }; |
| 105 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 106 | // MediaEngineInterface is an abstraction of a media engine which can be |
| 107 | // subclassed to support different media componentry backends. |
| 108 | // It supports voice and video operations in the same class to facilitate |
| 109 | // proper synchronization between both media types. |
| 110 | class MediaEngineInterface { |
| 111 | public: |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 112 | virtual ~MediaEngineInterface() {} |
| 113 | |
| 114 | // Initialization |
| 115 | // Starts the engine. |
solenberg | ff97631 | 2016-03-30 23:28:51 -0700 | [diff] [blame] | 116 | virtual bool Init() = 0; |
Sebastian Jansson | 6eb8a16 | 2018-11-16 11:29:55 +0100 | [diff] [blame] | 117 | virtual VoiceEngineInterface& voice() = 0; |
| 118 | virtual VideoEngineInterface& video() = 0; |
| 119 | virtual const VoiceEngineInterface& voice() const = 0; |
| 120 | virtual const VideoEngineInterface& video() const = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 121 | }; |
| 122 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 123 | // CompositeMediaEngine constructs a MediaEngine from separate |
| 124 | // voice and video engine classes. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 125 | class CompositeMediaEngine : public MediaEngineInterface { |
| 126 | public: |
Sebastian Jansson | fa0aa39 | 2018-11-16 09:54:32 +0100 | [diff] [blame] | 127 | CompositeMediaEngine(std::unique_ptr<VoiceEngineInterface> audio_engine, |
| 128 | std::unique_ptr<VideoEngineInterface> video_engine); |
| 129 | ~CompositeMediaEngine() override; |
| 130 | bool Init() override; |
magjed | 2475ae2 | 2017-09-12 04:42:15 -0700 | [diff] [blame] | 131 | |
Sebastian Jansson | 6eb8a16 | 2018-11-16 11:29:55 +0100 | [diff] [blame] | 132 | VoiceEngineInterface& voice() override; |
| 133 | VideoEngineInterface& video() override; |
| 134 | const VoiceEngineInterface& voice() const override; |
| 135 | const VideoEngineInterface& video() const override; |
magjed | 2475ae2 | 2017-09-12 04:42:15 -0700 | [diff] [blame] | 136 | |
| 137 | private: |
Sebastian Jansson | fa0aa39 | 2018-11-16 09:54:32 +0100 | [diff] [blame] | 138 | std::unique_ptr<VoiceEngineInterface> voice_engine_; |
| 139 | std::unique_ptr<VideoEngineInterface> video_engine_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 140 | }; |
| 141 | |
Bjorn Mellem | 175aa2e | 2018-11-08 11:23:22 -0800 | [diff] [blame] | 142 | enum DataChannelType { |
| 143 | DCT_NONE = 0, |
| 144 | DCT_RTP = 1, |
| 145 | DCT_SCTP = 2, |
| 146 | DCT_MEDIA_TRANSPORT = 3 |
| 147 | }; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 148 | |
| 149 | class DataEngineInterface { |
| 150 | public: |
| 151 | virtual ~DataEngineInterface() {} |
deadbeef | 953c2ce | 2017-01-09 14:53:41 -0800 | [diff] [blame] | 152 | virtual DataMediaChannel* CreateChannel(const MediaConfig& config) = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 153 | virtual const std::vector<DataCodec>& data_codecs() = 0; |
| 154 | }; |
| 155 | |
skvlad | dc1c62c | 2016-03-16 19:07:43 -0700 | [diff] [blame] | 156 | webrtc::RtpParameters CreateRtpParametersWithOneEncoding(); |
Zach Stein | 3ca452b | 2018-01-18 10:01:24 -0800 | [diff] [blame] | 157 | webrtc::RtpParameters CreateRtpParametersWithEncodings(StreamParams sp); |
skvlad | dc1c62c | 2016-03-16 19:07:43 -0700 | [diff] [blame] | 158 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 159 | } // namespace cricket |
| 160 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 161 | #endif // MEDIA_BASE_MEDIA_ENGINE_H_ |