Tim Na | c63bf10 | 2020-02-21 11:09:08 -0800 | [diff] [blame] | 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 | |
Tim Na | c63bf10 | 2020-02-21 11:09:08 -0800 | [diff] [blame] | 14 | namespace webrtc { |
| 15 | |
Tim Na | ccefde9 | 2020-03-03 09:29:22 -0800 | [diff] [blame^] | 16 | class VoipBase; |
| 17 | class VoipCodec; |
| 18 | class VoipNetwork; |
| 19 | |
Tim Na | c63bf10 | 2020-02-21 11:09:08 -0800 | [diff] [blame] | 20 | // 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 Na | ccefde9 | 2020-03-03 09:29:22 -0800 | [diff] [blame^] | 32 | // auto voip_base = voip_engine->Base(); |
| 33 | // auto voip_codec = voip_engine->Codec(); |
| 34 | // auto voip_network = voip_engine->Network(); |
Tim Na | c63bf10 | 2020-02-21 11:09:08 -0800 | [diff] [blame] | 35 | // |
| 36 | // VoipChannel::Config config = { &app_transport_, 0xdeadc0de }; |
Tim Na | ccefde9 | 2020-03-03 09:29:22 -0800 | [diff] [blame^] | 37 | // int channel = voip_base.CreateChannel(config); |
Tim Na | c63bf10 | 2020-02-21 11:09:08 -0800 | [diff] [blame] | 38 | // |
| 39 | // // After SDP offer/answer, payload type and codec usage have been |
| 40 | // // decided through negotiation. |
Tim Na | ccefde9 | 2020-03-03 09:29:22 -0800 | [diff] [blame^] | 41 | // voip_codec.SetSendCodec(channel, ...); |
| 42 | // voip_codec.SetReceiveCodecs(channel, ...); |
Tim Na | c63bf10 | 2020-02-21 11:09:08 -0800 | [diff] [blame] | 43 | // |
| 44 | // // Start Send/Playout on voip channel. |
Tim Na | ccefde9 | 2020-03-03 09:29:22 -0800 | [diff] [blame^] | 45 | // voip_base.StartSend(channel); |
| 46 | // voip_base.StartPlayout(channel); |
Tim Na | c63bf10 | 2020-02-21 11:09:08 -0800 | [diff] [blame] | 47 | // |
| 48 | // // Inject received rtp/rtcp thru voip network interface. |
Tim Na | ccefde9 | 2020-03-03 09:29:22 -0800 | [diff] [blame^] | 49 | // voip_network.ReceivedRTPPacket(channel, rtp_data, rtp_size); |
| 50 | // voip_network.ReceivedRTCPPacket(channel, rtcp_data, rtcp_size); |
Tim Na | c63bf10 | 2020-02-21 11:09:08 -0800 | [diff] [blame] | 51 | // |
| 52 | // // Stop and release voip channel. |
Tim Na | ccefde9 | 2020-03-03 09:29:22 -0800 | [diff] [blame^] | 53 | // voip_base.StopSend(channel); |
| 54 | // voip_base.StopPlayout(channel); |
Tim Na | c63bf10 | 2020-02-21 11:09:08 -0800 | [diff] [blame] | 55 | // |
Tim Na | ccefde9 | 2020-03-03 09:29:22 -0800 | [diff] [blame^] | 56 | // voip_base.ReleaseChannel(channel); |
Tim Na | c63bf10 | 2020-02-21 11:09:08 -0800 | [diff] [blame] | 57 | // |
| 58 | class VoipEngine { |
| 59 | public: |
Tim Na | ccefde9 | 2020-03-03 09:29:22 -0800 | [diff] [blame^] | 60 | virtual ~VoipEngine() = default; |
| 61 | |
Tim Na | c63bf10 | 2020-02-21 11:09:08 -0800 | [diff] [blame] | 62 | // VoipBase is the audio session management interface that |
| 63 | // create/release/start/stop one-to-one audio media session. |
Tim Na | ccefde9 | 2020-03-03 09:29:22 -0800 | [diff] [blame^] | 64 | virtual VoipBase& Base() = 0; |
Tim Na | c63bf10 | 2020-02-21 11:09:08 -0800 | [diff] [blame] | 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. |
Tim Na | ccefde9 | 2020-03-03 09:29:22 -0800 | [diff] [blame^] | 69 | virtual VoipNetwork& Network() = 0; |
Tim Na | c63bf10 | 2020-02-21 11:09:08 -0800 | [diff] [blame] | 70 | |
| 71 | // VoipCodec provides codec configuration APIs for encoder and decoders. |
Tim Na | ccefde9 | 2020-03-03 09:29:22 -0800 | [diff] [blame^] | 72 | virtual VoipCodec& Codec() = 0; |
Tim Na | c63bf10 | 2020-02-21 11:09:08 -0800 | [diff] [blame] | 73 | }; |
| 74 | |
| 75 | } // namespace webrtc |
| 76 | |
| 77 | #endif // API_VOIP_VOIP_ENGINE_H_ |