1*d9f75844SAndroid Build Coastguard Worker /* 2*d9f75844SAndroid Build Coastguard Worker * Copyright (c) 2020 The WebRTC project authors. All Rights Reserved. 3*d9f75844SAndroid Build Coastguard Worker * 4*d9f75844SAndroid Build Coastguard Worker * Use of this source code is governed by a BSD-style license 5*d9f75844SAndroid Build Coastguard Worker * that can be found in the LICENSE file in the root of the source 6*d9f75844SAndroid Build Coastguard Worker * tree. An additional intellectual property rights grant can be found 7*d9f75844SAndroid Build Coastguard Worker * in the file PATENTS. All contributing project authors may 8*d9f75844SAndroid Build Coastguard Worker * be found in the AUTHORS file in the root of the source tree. 9*d9f75844SAndroid Build Coastguard Worker */ 10*d9f75844SAndroid Build Coastguard Worker 11*d9f75844SAndroid Build Coastguard Worker #ifndef API_VOIP_VOIP_ENGINE_H_ 12*d9f75844SAndroid Build Coastguard Worker #define API_VOIP_VOIP_ENGINE_H_ 13*d9f75844SAndroid Build Coastguard Worker 14*d9f75844SAndroid Build Coastguard Worker namespace webrtc { 15*d9f75844SAndroid Build Coastguard Worker 16*d9f75844SAndroid Build Coastguard Worker class VoipBase; 17*d9f75844SAndroid Build Coastguard Worker class VoipCodec; 18*d9f75844SAndroid Build Coastguard Worker class VoipNetwork; 19*d9f75844SAndroid Build Coastguard Worker class VoipDtmf; 20*d9f75844SAndroid Build Coastguard Worker class VoipStatistics; 21*d9f75844SAndroid Build Coastguard Worker class VoipVolumeControl; 22*d9f75844SAndroid Build Coastguard Worker 23*d9f75844SAndroid Build Coastguard Worker // VoipEngine is the main interface serving as the entry point for all VoIP 24*d9f75844SAndroid Build Coastguard Worker // APIs. A single instance of VoipEngine should suffice the most of the need for 25*d9f75844SAndroid Build Coastguard Worker // typical VoIP applications as it handles multiple media sessions including a 26*d9f75844SAndroid Build Coastguard Worker // specialized session type like ad-hoc conference. Below example code 27*d9f75844SAndroid Build Coastguard Worker // describes the typical sequence of API usage. Each API header contains more 28*d9f75844SAndroid Build Coastguard Worker // description on what the methods are used for. 29*d9f75844SAndroid Build Coastguard Worker // 30*d9f75844SAndroid Build Coastguard Worker // // Caller is responsible of setting desired audio components. 31*d9f75844SAndroid Build Coastguard Worker // VoipEngineConfig config; 32*d9f75844SAndroid Build Coastguard Worker // config.encoder_factory = CreateBuiltinAudioEncoderFactory(); 33*d9f75844SAndroid Build Coastguard Worker // config.decoder_factory = CreateBuiltinAudioDecoderFactory(); 34*d9f75844SAndroid Build Coastguard Worker // config.task_queue_factory = CreateDefaultTaskQueueFactory(); 35*d9f75844SAndroid Build Coastguard Worker // config.audio_device = 36*d9f75844SAndroid Build Coastguard Worker // AudioDeviceModule::Create(AudioDeviceModule::kPlatformDefaultAudio, 37*d9f75844SAndroid Build Coastguard Worker // config.task_queue_factory.get()); 38*d9f75844SAndroid Build Coastguard Worker // config.audio_processing = AudioProcessingBuilder().Create(); 39*d9f75844SAndroid Build Coastguard Worker // 40*d9f75844SAndroid Build Coastguard Worker // auto voip_engine = CreateVoipEngine(std::move(config)); 41*d9f75844SAndroid Build Coastguard Worker // 42*d9f75844SAndroid Build Coastguard Worker // auto& voip_base = voip_engine->Base(); 43*d9f75844SAndroid Build Coastguard Worker // auto& voip_codec = voip_engine->Codec(); 44*d9f75844SAndroid Build Coastguard Worker // auto& voip_network = voip_engine->Network(); 45*d9f75844SAndroid Build Coastguard Worker // 46*d9f75844SAndroid Build Coastguard Worker // ChannelId channel = voip_base.CreateChannel(&app_transport_); 47*d9f75844SAndroid Build Coastguard Worker // 48*d9f75844SAndroid Build Coastguard Worker // // After SDP offer/answer, set payload type and codecs that have been 49*d9f75844SAndroid Build Coastguard Worker // // decided through SDP negotiation. 50*d9f75844SAndroid Build Coastguard Worker // // VoipResult handling omitted here. 51*d9f75844SAndroid Build Coastguard Worker // voip_codec.SetSendCodec(channel, ...); 52*d9f75844SAndroid Build Coastguard Worker // voip_codec.SetReceiveCodecs(channel, ...); 53*d9f75844SAndroid Build Coastguard Worker // 54*d9f75844SAndroid Build Coastguard Worker // // Start sending and playing RTP on voip channel. 55*d9f75844SAndroid Build Coastguard Worker // // VoipResult handling omitted here. 56*d9f75844SAndroid Build Coastguard Worker // voip_base.StartSend(channel); 57*d9f75844SAndroid Build Coastguard Worker // voip_base.StartPlayout(channel); 58*d9f75844SAndroid Build Coastguard Worker // 59*d9f75844SAndroid Build Coastguard Worker // // Inject received RTP/RTCP through VoipNetwork interface. 60*d9f75844SAndroid Build Coastguard Worker // // VoipResult handling omitted here. 61*d9f75844SAndroid Build Coastguard Worker // voip_network.ReceivedRTPPacket(channel, ...); 62*d9f75844SAndroid Build Coastguard Worker // voip_network.ReceivedRTCPPacket(channel, ...); 63*d9f75844SAndroid Build Coastguard Worker // 64*d9f75844SAndroid Build Coastguard Worker // // Stop and release voip channel. 65*d9f75844SAndroid Build Coastguard Worker // // VoipResult handling omitted here. 66*d9f75844SAndroid Build Coastguard Worker // voip_base.StopSend(channel); 67*d9f75844SAndroid Build Coastguard Worker // voip_base.StopPlayout(channel); 68*d9f75844SAndroid Build Coastguard Worker // voip_base.ReleaseChannel(channel); 69*d9f75844SAndroid Build Coastguard Worker // 70*d9f75844SAndroid Build Coastguard Worker class VoipEngine { 71*d9f75844SAndroid Build Coastguard Worker public: 72*d9f75844SAndroid Build Coastguard Worker virtual ~VoipEngine() = default; 73*d9f75844SAndroid Build Coastguard Worker 74*d9f75844SAndroid Build Coastguard Worker // VoipBase is the audio session management interface that 75*d9f75844SAndroid Build Coastguard Worker // creates/releases/starts/stops an one-to-one audio media session. 76*d9f75844SAndroid Build Coastguard Worker virtual VoipBase& Base() = 0; 77*d9f75844SAndroid Build Coastguard Worker 78*d9f75844SAndroid Build Coastguard Worker // VoipNetwork provides injection APIs that would enable application 79*d9f75844SAndroid Build Coastguard Worker // to send and receive RTP/RTCP packets. There is no default network module 80*d9f75844SAndroid Build Coastguard Worker // that provides RTP transmission and reception. 81*d9f75844SAndroid Build Coastguard Worker virtual VoipNetwork& Network() = 0; 82*d9f75844SAndroid Build Coastguard Worker 83*d9f75844SAndroid Build Coastguard Worker // VoipCodec provides codec configuration APIs for encoder and decoders. 84*d9f75844SAndroid Build Coastguard Worker virtual VoipCodec& Codec() = 0; 85*d9f75844SAndroid Build Coastguard Worker 86*d9f75844SAndroid Build Coastguard Worker // VoipDtmf provides DTMF event APIs to register and send DTMF events. 87*d9f75844SAndroid Build Coastguard Worker virtual VoipDtmf& Dtmf() = 0; 88*d9f75844SAndroid Build Coastguard Worker 89*d9f75844SAndroid Build Coastguard Worker // VoipStatistics provides performance metrics around audio decoding module 90*d9f75844SAndroid Build Coastguard Worker // and jitter buffer (NetEq). 91*d9f75844SAndroid Build Coastguard Worker virtual VoipStatistics& Statistics() = 0; 92*d9f75844SAndroid Build Coastguard Worker 93*d9f75844SAndroid Build Coastguard Worker // VoipVolumeControl provides various input/output volume control. 94*d9f75844SAndroid Build Coastguard Worker virtual VoipVolumeControl& VolumeControl() = 0; 95*d9f75844SAndroid Build Coastguard Worker }; 96*d9f75844SAndroid Build Coastguard Worker 97*d9f75844SAndroid Build Coastguard Worker } // namespace webrtc 98*d9f75844SAndroid Build Coastguard Worker 99*d9f75844SAndroid Build Coastguard Worker #endif // API_VOIP_VOIP_ENGINE_H_ 100