blob: 96905a121d11e444eb863d663446c7cd0197e61f [file] [log] [blame]
Tim Nac63bf102020-02-21 11:09:08 -08001//
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
Tim Nac63bf102020-02-21 11:09:08 -080014namespace webrtc {
15
Tim Naccefde92020-03-03 09:29:22 -080016class VoipBase;
17class VoipCodec;
18class VoipNetwork;
19
Tim Nac63bf102020-02-21 11:09:08 -080020// VoipEngine interfaces
21//
22// These pointer interfaces are valid as long as VoipEngine is available.
23// Therefore, application must synchronize the usage within the life span of
24// created VoipEngine instance.
25//
26// auto voip_engine =
27// webrtc::VoipEngineBuilder()
28// .SetAudioEncoderFactory(CreateBuiltinAudioEncoderFactory())
29// .SetAudioDecoderFactory(CreateBuiltinAudioDecoderFactory())
30// .Create();
31//
Tim Naccefde92020-03-03 09:29:22 -080032// auto voip_base = voip_engine->Base();
33// auto voip_codec = voip_engine->Codec();
34// auto voip_network = voip_engine->Network();
Tim Nac63bf102020-02-21 11:09:08 -080035//
36// VoipChannel::Config config = { &app_transport_, 0xdeadc0de };
Tim Naccefde92020-03-03 09:29:22 -080037// int channel = voip_base.CreateChannel(config);
Tim Nac63bf102020-02-21 11:09:08 -080038//
39// // After SDP offer/answer, payload type and codec usage have been
40// // decided through negotiation.
Tim Naccefde92020-03-03 09:29:22 -080041// voip_codec.SetSendCodec(channel, ...);
42// voip_codec.SetReceiveCodecs(channel, ...);
Tim Nac63bf102020-02-21 11:09:08 -080043//
44// // Start Send/Playout on voip channel.
Tim Naccefde92020-03-03 09:29:22 -080045// voip_base.StartSend(channel);
46// voip_base.StartPlayout(channel);
Tim Nac63bf102020-02-21 11:09:08 -080047//
48// // Inject received rtp/rtcp thru voip network interface.
Tim Naccefde92020-03-03 09:29:22 -080049// voip_network.ReceivedRTPPacket(channel, rtp_data, rtp_size);
50// voip_network.ReceivedRTCPPacket(channel, rtcp_data, rtcp_size);
Tim Nac63bf102020-02-21 11:09:08 -080051//
52// // Stop and release voip channel.
Tim Naccefde92020-03-03 09:29:22 -080053// voip_base.StopSend(channel);
54// voip_base.StopPlayout(channel);
Tim Nac63bf102020-02-21 11:09:08 -080055//
Tim Naccefde92020-03-03 09:29:22 -080056// voip_base.ReleaseChannel(channel);
Tim Nac63bf102020-02-21 11:09:08 -080057//
58class VoipEngine {
59 public:
Tim Naccefde92020-03-03 09:29:22 -080060 virtual ~VoipEngine() = default;
61
Tim Nac63bf102020-02-21 11:09:08 -080062 // VoipBase is the audio session management interface that
63 // create/release/start/stop one-to-one audio media session.
Tim Naccefde92020-03-03 09:29:22 -080064 virtual VoipBase& Base() = 0;
Tim Nac63bf102020-02-21 11:09:08 -080065
66 // VoipNetwork provides injection APIs that would enable application
67 // to send and receive RTP/RTCP packets. There is no default network module
68 // that provides RTP transmission and reception.
Tim Naccefde92020-03-03 09:29:22 -080069 virtual VoipNetwork& Network() = 0;
Tim Nac63bf102020-02-21 11:09:08 -080070
71 // VoipCodec provides codec configuration APIs for encoder and decoders.
Tim Naccefde92020-03-03 09:29:22 -080072 virtual VoipCodec& Codec() = 0;
Tim Nac63bf102020-02-21 11:09:08 -080073};
74
75} // namespace webrtc
76
77#endif // API_VOIP_VOIP_ENGINE_H_