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 | |
| 37 | #include "common_types.h" |
| 38 | |
| 39 | namespace webrtc { |
| 40 | |
| 41 | class VoiceEngine; |
| 42 | |
| 43 | // VoEConnectionObserver |
| 44 | class WEBRTC_DLLEXPORT VoEConnectionObserver |
| 45 | { |
| 46 | public: |
| 47 | // This method will be called peridically and deliver dead-or-alive |
| 48 | // notifications for a specified |channel| when the observer interface |
| 49 | // has been installed and activated. |
pbos@webrtc.org | 9213521 | 2013-05-14 08:31:39 +0000 | [diff] [blame^] | 50 | virtual void OnPeriodicDeadOrAlive(int channel, bool alive) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 51 | |
| 52 | protected: |
| 53 | virtual ~VoEConnectionObserver() {} |
| 54 | }; |
| 55 | |
| 56 | // VoENetwork |
| 57 | class WEBRTC_DLLEXPORT VoENetwork |
| 58 | { |
| 59 | public: |
| 60 | // Factory for the VoENetwork sub-API. Increases an internal |
| 61 | // reference counter if successful. Returns NULL if the API is not |
| 62 | // supported or if construction fails. |
| 63 | static VoENetwork* GetInterface(VoiceEngine* voiceEngine); |
| 64 | |
| 65 | // Releases the VoENetwork sub-API and decreases an internal |
| 66 | // reference counter. Returns the new reference count. This value should |
| 67 | // be zero for all sub-API:s before the VoiceEngine object can be safely |
| 68 | // deleted. |
| 69 | virtual int Release() = 0; |
| 70 | |
| 71 | // Installs and enables a user-defined external transport protocol for a |
| 72 | // specified |channel|. |
| 73 | virtual int RegisterExternalTransport( |
| 74 | int channel, Transport& transport) = 0; |
| 75 | |
| 76 | // Removes and disables a user-defined external transport protocol for a |
| 77 | // specified |channel|. |
| 78 | virtual int DeRegisterExternalTransport(int channel) = 0; |
| 79 | |
| 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 RTP-header must also be given to the VoiceEngine. |
| 83 | virtual int ReceivedRTPPacket( |
| 84 | int channel, const void* data, unsigned int length) = 0; |
| 85 | |
| 86 | // The packets received from the network should be passed to this |
| 87 | // function when external transport is enabled. Note that the data |
| 88 | // including the RTCP-header must also be given to the VoiceEngine. |
| 89 | virtual int ReceivedRTCPPacket( |
| 90 | int channel, const void* data, unsigned int length) = 0; |
| 91 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 92 | // Enables or disables warnings that report if packets have not been |
| 93 | // received in |timeoutSeconds| seconds for a specific |channel|. |
| 94 | virtual int SetPacketTimeoutNotification( |
| 95 | int channel, bool enable, int timeoutSeconds = 2) = 0; |
| 96 | |
| 97 | // Gets the current time-out notification status. |
| 98 | virtual int GetPacketTimeoutNotification( |
| 99 | int channel, bool& enabled, int& timeoutSeconds) = 0; |
| 100 | |
| 101 | // Installs the observer class implementation for a specified |channel|. |
| 102 | virtual int RegisterDeadOrAliveObserver( |
| 103 | int channel, VoEConnectionObserver& observer) = 0; |
| 104 | |
| 105 | // Removes the observer class implementation for a specified |channel|. |
| 106 | virtual int DeRegisterDeadOrAliveObserver(int channel) = 0; |
| 107 | |
| 108 | // Enables or disables the periodic dead-or-alive callback functionality |
| 109 | // for a specified |channel|. |
| 110 | virtual int SetPeriodicDeadOrAliveStatus( |
| 111 | int channel, bool enable, int sampleTimeSeconds = 2) = 0; |
| 112 | |
| 113 | // Gets the current dead-or-alive notification status. |
| 114 | virtual int GetPeriodicDeadOrAliveStatus( |
| 115 | int channel, bool& enabled, int& sampleTimeSeconds) = 0; |
| 116 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 117 | protected: |
| 118 | VoENetwork() {} |
| 119 | virtual ~VoENetwork() {} |
| 120 | }; |
| 121 | |
| 122 | } // namespace webrtc |
| 123 | |
| 124 | #endif // WEBRTC_VOICE_ENGINE_VOE_NETWORK_H |