blob: d223f6ad6c5ed4038bb9383bdcd5d27129185d86 [file] [log] [blame]
Tim Nac0df5fc2020-05-05 18:03:541/*
2 * Copyright (c) 2020 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 */
Tim Nac63bf102020-02-21 19:09:0810
11#ifndef API_VOIP_VOIP_ENGINE_H_
12#define API_VOIP_VOIP_ENGINE_H_
13
Tim Nac63bf102020-02-21 19:09:0814namespace webrtc {
15
Tim Naccefde92020-03-03 17:29:2216class VoipBase;
17class VoipCodec;
18class VoipNetwork;
Jason Longa5347292020-08-18 17:22:3919class VoipDtmf;
Tim Naf4347f72020-10-28 20:51:2420class VoipStatistics;
Tim Naa58cae32020-11-13 19:07:4321class VoipVolumeControl;
Tim Naccefde92020-03-03 17:29:2222
Tim Nac0df5fc2020-05-05 18:03:5423// VoipEngine is the main interface serving as the entry point for all VoIP
24// APIs. A single instance of VoipEngine should suffice the most of the need for
25// typical VoIP applications as it handles multiple media sessions including a
Tim Nab223cb62020-11-20 17:34:4726// specialized session type like ad-hoc conference. Below example code
Tim Nac0df5fc2020-05-05 18:03:5427// describes the typical sequence of API usage. Each API header contains more
28// description on what the methods are used for.
Tim Nac63bf102020-02-21 19:09:0829//
Tim Nac0df5fc2020-05-05 18:03:5430// // Caller is responsible of setting desired audio components.
31// VoipEngineConfig config;
32// config.encoder_factory = CreateBuiltinAudioEncoderFactory();
33// config.decoder_factory = CreateBuiltinAudioDecoderFactory();
34// config.task_queue_factory = CreateDefaultTaskQueueFactory();
35// config.audio_device =
36// AudioDeviceModule::Create(AudioDeviceModule::kPlatformDefaultAudio,
37// config.task_queue_factory.get());
38// config.audio_processing = AudioProcessingBuilder().Create();
Tim Nac63bf102020-02-21 19:09:0839//
Tim Nac0df5fc2020-05-05 18:03:5440// auto voip_engine = CreateVoipEngine(std::move(config));
Tim Nac63bf102020-02-21 19:09:0841//
Tim Nac0df5fc2020-05-05 18:03:5442// auto& voip_base = voip_engine->Base();
43// auto& voip_codec = voip_engine->Codec();
44// auto& voip_network = voip_engine->Network();
Tim Nac63bf102020-02-21 19:09:0845//
Tim Nab223cb62020-11-20 17:34:4746// ChannelId channel = voip_base.CreateChannel(&app_transport_);
Tim Nac63bf102020-02-21 19:09:0847//
Tim Nac0df5fc2020-05-05 18:03:5448// // After SDP offer/answer, set payload type and codecs that have been
49// // decided through SDP negotiation.
Tim Nab223cb62020-11-20 17:34:4750// // VoipResult handling omitted here.
51// voip_codec.SetSendCodec(channel, ...);
52// voip_codec.SetReceiveCodecs(channel, ...);
Tim Nac63bf102020-02-21 19:09:0853//
Tim Nac0df5fc2020-05-05 18:03:5454// // Start sending and playing RTP on voip channel.
Tim Nab223cb62020-11-20 17:34:4755// // VoipResult handling omitted here.
56// voip_base.StartSend(channel);
57// voip_base.StartPlayout(channel);
Tim Nac63bf102020-02-21 19:09:0858//
Tim Nac0df5fc2020-05-05 18:03:5459// // Inject received RTP/RTCP through VoipNetwork interface.
Tim Nab223cb62020-11-20 17:34:4760// // VoipResult handling omitted here.
61// voip_network.ReceivedRTPPacket(channel, ...);
62// voip_network.ReceivedRTCPPacket(channel, ...);
Tim Nac63bf102020-02-21 19:09:0863//
64// // Stop and release voip channel.
Tim Nab223cb62020-11-20 17:34:4765// // VoipResult handling omitted here.
66// voip_base.StopSend(channel);
67// voip_base.StopPlayout(channel);
68// voip_base.ReleaseChannel(channel);
Tim Nac63bf102020-02-21 19:09:0869//
Tim Nac63bf102020-02-21 19:09:0870class VoipEngine {
71 public:
Tim Naccefde92020-03-03 17:29:2272 virtual ~VoipEngine() = default;
73
Tim Nac63bf102020-02-21 19:09:0874 // VoipBase is the audio session management interface that
Tim Nac0df5fc2020-05-05 18:03:5475 // creates/releases/starts/stops an one-to-one audio media session.
Tim Naccefde92020-03-03 17:29:2276 virtual VoipBase& Base() = 0;
Tim Nac63bf102020-02-21 19:09:0877
78 // VoipNetwork provides injection APIs that would enable application
79 // to send and receive RTP/RTCP packets. There is no default network module
80 // that provides RTP transmission and reception.
Tim Naccefde92020-03-03 17:29:2281 virtual VoipNetwork& Network() = 0;
Tim Nac63bf102020-02-21 19:09:0882
83 // VoipCodec provides codec configuration APIs for encoder and decoders.
Tim Naccefde92020-03-03 17:29:2284 virtual VoipCodec& Codec() = 0;
Jason Longa5347292020-08-18 17:22:3985
86 // VoipDtmf provides DTMF event APIs to register and send DTMF events.
87 virtual VoipDtmf& Dtmf() = 0;
Tim Naf4347f72020-10-28 20:51:2488
89 // VoipStatistics provides performance metrics around audio decoding module
90 // and jitter buffer (NetEq).
91 virtual VoipStatistics& Statistics() = 0;
Tim Naa58cae32020-11-13 19:07:4392
93 // VoipVolumeControl provides various input/output volume control.
94 virtual VoipVolumeControl& VolumeControl() = 0;
Tim Nac63bf102020-02-21 19:09:0895};
96
97} // namespace webrtc
98
99#endif // API_VOIP_VOIP_ENGINE_H_