blob: c667c7f321e78f855cca0c1c29f34ab16c8632c4 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
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.com470e71d2011-07-07 08:21:25 +000014// - Packet timeout notification.
15// - Dead-or-Alive connection observations.
niklase@google.com470e71d2011-07-07 08:21:25 +000016//
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
pbos@webrtc.org956aa7e2013-05-21 13:52:32 +000037#include "webrtc/common_types.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000038
39namespace webrtc {
40
41class VoiceEngine;
42
niklase@google.com470e71d2011-07-07 08:21:25 +000043// VoENetwork
Jelena Marusic0d266052015-05-04 14:15:32 +020044class WEBRTC_DLLEXPORT VoENetwork {
45 public:
46 // Factory for the VoENetwork sub-API. Increases an internal
47 // reference counter if successful. Returns NULL if the API is not
48 // supported or if construction fails.
49 static VoENetwork* GetInterface(VoiceEngine* voiceEngine);
niklase@google.com470e71d2011-07-07 08:21:25 +000050
Jelena Marusic0d266052015-05-04 14:15:32 +020051 // Releases the VoENetwork sub-API and decreases an internal
52 // reference counter. Returns the new reference count. This value should
53 // be zero for all sub-API:s before the VoiceEngine object can be safely
54 // deleted.
55 virtual int Release() = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000056
Jelena Marusic0d266052015-05-04 14:15:32 +020057 // Installs and enables a user-defined external transport protocol for a
Jelena Marusicf353dd52015-05-06 15:04:22 +020058 // specified |channel|. Returns -1 in case of an error, 0 otherwise.
Jelena Marusic0d266052015-05-04 14:15:32 +020059 virtual int RegisterExternalTransport(int channel, Transport& transport) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000060
Jelena Marusic0d266052015-05-04 14:15:32 +020061 // Removes and disables a user-defined external transport protocol for a
Jelena Marusicf353dd52015-05-06 15:04:22 +020062 // specified |channel|. Returns -1 in case of an error, 0 otherwise.
Jelena Marusic0d266052015-05-04 14:15:32 +020063 virtual int DeRegisterExternalTransport(int channel) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000064
Jelena Marusic0d266052015-05-04 14:15:32 +020065 // The packets received from the network should be passed to this
66 // function when external transport is enabled. Note that the data
67 // including the RTP-header must also be given to the VoiceEngine.
Jelena Marusicf353dd52015-05-06 15:04:22 +020068 // Returns -1 in case of an error, 0 otherwise.
Jelena Marusic0d266052015-05-04 14:15:32 +020069 virtual int ReceivedRTPPacket(int channel,
70 const void* data,
71 size_t length) = 0;
72 virtual int ReceivedRTPPacket(int channel,
73 const void* data,
74 size_t length,
75 const PacketTime& packet_time) {
76 return 0;
77 }
niklase@google.com470e71d2011-07-07 08:21:25 +000078
Jelena Marusic0d266052015-05-04 14:15:32 +020079 // The packets received from the network should be passed to this
80 // function when external transport is enabled. Note that the data
81 // including the RTCP-header must also be given to the VoiceEngine.
Jelena Marusicf353dd52015-05-06 15:04:22 +020082 // Returns -1 in case of an error, 0 otherwise.
Jelena Marusic0d266052015-05-04 14:15:32 +020083 virtual int ReceivedRTCPPacket(int channel,
84 const void* data,
85 size_t length) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000086
Jelena Marusic0d266052015-05-04 14:15:32 +020087 protected:
88 VoENetwork() {}
89 virtual ~VoENetwork() {}
niklase@google.com470e71d2011-07-07 08:21:25 +000090};
91
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +000092} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +000093
94#endif // WEBRTC_VOICE_ENGINE_VOE_NETWORK_H