blob: 6fc1c534ef9cedce85fecd49f52d1132c8a604bc [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
14#include <memory>
15
16#include "api/voip/voip_base.h"
17#include "api/voip/voip_codec.h"
18#include "api/voip/voip_network.h"
19
20namespace webrtc {
21
22// VoipEngine interfaces
23//
24// These pointer interfaces are valid as long as VoipEngine is available.
25// Therefore, application must synchronize the usage within the life span of
26// created VoipEngine instance.
27//
28// auto voip_engine =
29// webrtc::VoipEngineBuilder()
30// .SetAudioEncoderFactory(CreateBuiltinAudioEncoderFactory())
31// .SetAudioDecoderFactory(CreateBuiltinAudioDecoderFactory())
32// .Create();
33//
34// auto* voip_base = voip_engine->Base();
35// auto* voip_codec = voip_engine->Codec();
36// auto* voip_network = voip_engine->Network();
37//
38// VoipChannel::Config config = { &app_transport_, 0xdeadc0de };
39// int channel = voip_base->CreateChannel(config);
40//
41// // After SDP offer/answer, payload type and codec usage have been
42// // decided through negotiation.
43// voip_codec->SetSendCodec(channel, ...);
44// voip_codec->SetReceiveCodecs(channel, ...);
45//
46// // Start Send/Playout on voip channel.
47// voip_base->StartSend(channel);
48// voip_base->StartPlayout(channel);
49//
50// // Inject received rtp/rtcp thru voip network interface.
51// voip_network->ReceivedRTPPacket(channel, rtp_data, rtp_size);
52// voip_network->ReceivedRTCPPacket(channel, rtcp_data, rtcp_size);
53//
54// // Stop and release voip channel.
55// voip_base->StopSend(channel);
56// voip_base->StopPlayout(channel);
57//
58// voip_base->ReleaseChannel(channel);
59//
60class VoipEngine {
61 public:
62 // VoipBase is the audio session management interface that
63 // create/release/start/stop one-to-one audio media session.
64 virtual VoipBase* Base() = 0;
65
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.
69 virtual VoipNetwork* Network() = 0;
70
71 // VoipCodec provides codec configuration APIs for encoder and decoders.
72 virtual VoipCodec* Codec() = 0;
73
74 virtual ~VoipEngine() = default;
75};
76
77} // namespace webrtc
78
79#endif // API_VOIP_VOIP_ENGINE_H_