niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2011 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 | // This sub-API supports the following functionalities: |
| 12 | // |
| 13 | // - External protocol support. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 14 | // - Packet timeout notification. |
| 15 | // - Dead-or-Alive connection observations. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 16 | // |
| 17 | // Usage example, omitting error checking: |
| 18 | // |
| 19 | // using namespace webrtc; |
| 20 | // VoiceEngine* voe = VoiceEngine::Create(); |
| 21 | // VoEBase* base = VoEBase::GetInterface(voe); |
| 22 | // VoENetwork* netw = VoENetwork::GetInterface(voe); |
| 23 | // base->Init(); |
| 24 | // int ch = base->CreateChannel(); |
| 25 | // ... |
| 26 | // netw->SetPeriodicDeadOrAliveStatus(ch, true); |
| 27 | // ... |
| 28 | // base->DeleteChannel(ch); |
| 29 | // base->Terminate(); |
| 30 | // base->Release(); |
| 31 | // netw->Release(); |
| 32 | // VoiceEngine::Delete(voe); |
| 33 | // |
| 34 | #ifndef WEBRTC_VOICE_ENGINE_VOE_NETWORK_H |
| 35 | #define WEBRTC_VOICE_ENGINE_VOE_NETWORK_H |
| 36 | |
aleloi | a8eb756 | 2016-11-28 07:02:13 -0800 | [diff] [blame^] | 37 | #include "webrtc/api/call/transport.h" |
pbos@webrtc.org | 956aa7e | 2013-05-21 13:52:32 +0000 | [diff] [blame] | 38 | #include "webrtc/common_types.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 39 | |
| 40 | namespace webrtc { |
| 41 | |
| 42 | class VoiceEngine; |
| 43 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 44 | // VoENetwork |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 45 | class WEBRTC_DLLEXPORT VoENetwork { |
| 46 | public: |
| 47 | // Factory for the VoENetwork sub-API. Increases an internal |
| 48 | // reference counter if successful. Returns NULL if the API is not |
| 49 | // supported or if construction fails. |
| 50 | static VoENetwork* GetInterface(VoiceEngine* voiceEngine); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 51 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 52 | // Releases the VoENetwork sub-API and decreases an internal |
| 53 | // reference counter. Returns the new reference count. This value should |
| 54 | // be zero for all sub-API:s before the VoiceEngine object can be safely |
| 55 | // deleted. |
| 56 | virtual int Release() = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 57 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 58 | // Installs and enables a user-defined external transport protocol for a |
Jelena Marusic | f353dd5 | 2015-05-06 15:04:22 +0200 | [diff] [blame] | 59 | // specified |channel|. Returns -1 in case of an error, 0 otherwise. |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 60 | virtual int RegisterExternalTransport(int channel, Transport& transport) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 61 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 62 | // Removes and disables a user-defined external transport protocol for a |
Jelena Marusic | f353dd5 | 2015-05-06 15:04:22 +0200 | [diff] [blame] | 63 | // specified |channel|. Returns -1 in case of an error, 0 otherwise. |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 64 | virtual int DeRegisterExternalTransport(int channel) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 65 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 66 | // The packets received from the network should be passed to this |
| 67 | // function when external transport is enabled. Note that the data |
| 68 | // including the RTP-header must also be given to the VoiceEngine. |
Jelena Marusic | f353dd5 | 2015-05-06 15:04:22 +0200 | [diff] [blame] | 69 | // Returns -1 in case of an error, 0 otherwise. |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 70 | virtual int ReceivedRTPPacket(int channel, |
| 71 | const void* data, |
| 72 | size_t length) = 0; |
| 73 | virtual int ReceivedRTPPacket(int channel, |
| 74 | const void* data, |
| 75 | size_t length, |
| 76 | const PacketTime& packet_time) { |
| 77 | return 0; |
| 78 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 79 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 80 | // The packets received from the network should be passed to this |
| 81 | // function when external transport is enabled. Note that the data |
| 82 | // including the RTCP-header must also be given to the VoiceEngine. |
Jelena Marusic | f353dd5 | 2015-05-06 15:04:22 +0200 | [diff] [blame] | 83 | // Returns -1 in case of an error, 0 otherwise. |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 84 | virtual int ReceivedRTCPPacket(int channel, |
| 85 | const void* data, |
| 86 | size_t length) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 87 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 88 | protected: |
| 89 | VoENetwork() {} |
| 90 | virtual ~VoENetwork() {} |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 91 | }; |
| 92 | |
pbos@webrtc.org | d900e8b | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 93 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 94 | |
| 95 | #endif // WEBRTC_VOICE_ENGINE_VOE_NETWORK_H |