• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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  */
10 
11 #ifndef API_VOIP_VOIP_ENGINE_H_
12 #define API_VOIP_VOIP_ENGINE_H_
13 
14 namespace webrtc {
15 
16 class VoipBase;
17 class VoipCodec;
18 class VoipNetwork;
19 
20 // VoipEngine is the main interface serving as the entry point for all VoIP
21 // APIs. A single instance of VoipEngine should suffice the most of the need for
22 // typical VoIP applications as it handles multiple media sessions including a
23 // specialized session type like ad-hoc mesh conferencing. Below example code
24 // describes the typical sequence of API usage. Each API header contains more
25 // description on what the methods are used for.
26 //
27 //   // Caller is responsible of setting desired audio components.
28 //   VoipEngineConfig config;
29 //   config.encoder_factory = CreateBuiltinAudioEncoderFactory();
30 //   config.decoder_factory = CreateBuiltinAudioDecoderFactory();
31 //   config.task_queue_factory = CreateDefaultTaskQueueFactory();
32 //   config.audio_device =
33 //       AudioDeviceModule::Create(AudioDeviceModule::kPlatformDefaultAudio,
34 //                                 config.task_queue_factory.get());
35 //   config.audio_processing = AudioProcessingBuilder().Create();
36 //
37 //   auto voip_engine = CreateVoipEngine(std::move(config));
38 //   if (!voip_engine) return some_failure;
39 //
40 //   auto& voip_base = voip_engine->Base();
41 //   auto& voip_codec = voip_engine->Codec();
42 //   auto& voip_network = voip_engine->Network();
43 //
44 //   absl::optional<ChannelId> channel =
45 //       voip_base.CreateChannel(&app_transport_);
46 //   if (!channel) return some_failure;
47 //
48 //   // After SDP offer/answer, set payload type and codecs that have been
49 //   // decided through SDP negotiation.
50 //   voip_codec.SetSendCodec(*channel, ...);
51 //   voip_codec.SetReceiveCodecs(*channel, ...);
52 //
53 //   // Start sending and playing RTP on voip channel.
54 //   voip_base.StartSend(*channel);
55 //   voip_base.StartPlayout(*channel);
56 //
57 //   // Inject received RTP/RTCP through VoipNetwork interface.
58 //   voip_network.ReceivedRTPPacket(*channel, ...);
59 //   voip_network.ReceivedRTCPPacket(*channel, ...);
60 //
61 //   // Stop and release voip channel.
62 //   voip_base.StopSend(*channel);
63 //   voip_base.StopPlayout(*channel);
64 //   voip_base.ReleaseChannel(*channel);
65 //
66 // Current VoipEngine defines three sub-API classes and is subject to expand in
67 // near future.
68 class VoipEngine {
69  public:
70   virtual ~VoipEngine() = default;
71 
72   // VoipBase is the audio session management interface that
73   // creates/releases/starts/stops an one-to-one audio media session.
74   virtual VoipBase& Base() = 0;
75 
76   // VoipNetwork provides injection APIs that would enable application
77   // to send and receive RTP/RTCP packets. There is no default network module
78   // that provides RTP transmission and reception.
79   virtual VoipNetwork& Network() = 0;
80 
81   // VoipCodec provides codec configuration APIs for encoder and decoders.
82   virtual VoipCodec& Codec() = 0;
83 };
84 
85 }  // namespace webrtc
86 
87 #endif  // API_VOIP_VOIP_ENGINE_H_
88