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 | |
mflodman@webrtc.org | d5a4d9b | 2012-01-02 13:04:05 +0000 | [diff] [blame] | 11 | #ifndef WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_NETWORK_H_ |
| 12 | #define WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_NETWORK_H_ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 13 | |
| 14 | // This sub-API supports the following functionalities: |
| 15 | // - Configuring send and receive addresses. |
| 16 | // - External transport support. |
| 17 | // - Port and address filters. |
| 18 | // - Windows GQoS functions and ToS functions. |
| 19 | // - Packet timeout notification. |
| 20 | // - Dead‐or‐Alive connection observations. |
| 21 | |
stefan@webrtc.org | bfacda6 | 2013-03-27 16:36:01 +0000 | [diff] [blame] | 22 | #include "webrtc/common_types.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 23 | |
mflodman@webrtc.org | d5a4d9b | 2012-01-02 13:04:05 +0000 | [diff] [blame] | 24 | namespace webrtc { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 25 | |
mflodman@webrtc.org | d5a4d9b | 2012-01-02 13:04:05 +0000 | [diff] [blame] | 26 | class Transport; |
| 27 | class VideoEngine; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 28 | |
| 29 | // This enumerator describes VideoEngine packet timeout states. |
mflodman@webrtc.org | d5a4d9b | 2012-01-02 13:04:05 +0000 | [diff] [blame] | 30 | enum ViEPacketTimeout { |
| 31 | NoPacket = 0, |
| 32 | PacketReceived = 1 |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 33 | }; |
| 34 | |
| 35 | // This class declares an abstract interface for a user defined observer. It is |
| 36 | // up to the VideoEngine user to implement a derived class which implements the |
| 37 | // observer class. The observer is registered using RegisterObserver() and |
| 38 | // deregistered using DeregisterObserver(). |
mflodman@webrtc.org | d5a4d9b | 2012-01-02 13:04:05 +0000 | [diff] [blame] | 39 | class WEBRTC_DLLEXPORT ViENetworkObserver { |
| 40 | public: |
| 41 | // This method will be called periodically delivering a dead‐or‐alive |
| 42 | // decision for a specified channel. |
| 43 | virtual void OnPeriodicDeadOrAlive(const int video_channel, |
| 44 | const bool alive) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 45 | |
mflodman@webrtc.org | d5a4d9b | 2012-01-02 13:04:05 +0000 | [diff] [blame] | 46 | // This method is called once if a packet timeout occurred. |
| 47 | virtual void PacketTimeout(const int video_channel, |
| 48 | const ViEPacketTimeout timeout) = 0; |
| 49 | protected: |
| 50 | virtual ~ViENetworkObserver() {} |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 51 | }; |
| 52 | |
mflodman@webrtc.org | d5a4d9b | 2012-01-02 13:04:05 +0000 | [diff] [blame] | 53 | class WEBRTC_DLLEXPORT ViENetwork { |
| 54 | public: |
| 55 | // Default values. |
| 56 | enum { KDefaultSampleTimeSeconds = 2 }; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 57 | |
mflodman@webrtc.org | d5a4d9b | 2012-01-02 13:04:05 +0000 | [diff] [blame] | 58 | // Factory for the ViENetwork sub‐API and increases an internal reference |
| 59 | // counter if successful. Returns NULL if the API is not supported or if |
| 60 | // construction fails. |
| 61 | static ViENetwork* GetInterface(VideoEngine* video_engine); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 62 | |
mflodman@webrtc.org | d5a4d9b | 2012-01-02 13:04:05 +0000 | [diff] [blame] | 63 | // Releases the ViENetwork sub-API and decreases an internal reference |
| 64 | // counter.Returns the new reference count. This value should be zero |
| 65 | // for all sub-API:s before the VideoEngine object can be safely deleted. |
| 66 | virtual int Release() = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 67 | |
stefan@webrtc.org | bfacda6 | 2013-03-27 16:36:01 +0000 | [diff] [blame] | 68 | // Inform the engine about if the network adapter is currently transmitting |
| 69 | // packets or not. |
| 70 | virtual void SetNetworkTransmissionState(const int video_channel, |
| 71 | const bool is_transmitting) = 0; |
| 72 | |
mflodman@webrtc.org | d5a4d9b | 2012-01-02 13:04:05 +0000 | [diff] [blame] | 73 | // This function registers a user implementation of Transport to use for |
| 74 | // sending RTP and RTCP packets on this channel. |
| 75 | virtual int RegisterSendTransport(const int video_channel, |
| 76 | Transport& transport) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 77 | |
mflodman@webrtc.org | d5a4d9b | 2012-01-02 13:04:05 +0000 | [diff] [blame] | 78 | // This function deregisters a used Transport for a specified channel. |
| 79 | virtual int DeregisterSendTransport(const int video_channel) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 80 | |
mflodman@webrtc.org | d5a4d9b | 2012-01-02 13:04:05 +0000 | [diff] [blame] | 81 | // When using external transport for a channel, received RTP packets should |
| 82 | // be passed to VideoEngine using this function. The input should contain |
| 83 | // the RTP header and payload. |
| 84 | virtual int ReceivedRTPPacket(const int video_channel, |
| 85 | const void* data, |
| 86 | const int length) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 87 | |
mflodman@webrtc.org | d5a4d9b | 2012-01-02 13:04:05 +0000 | [diff] [blame] | 88 | // When using external transport for a channel, received RTCP packets should |
| 89 | // be passed to VideoEngine using this function. |
| 90 | virtual int ReceivedRTCPPacket(const int video_channel, |
| 91 | const void* data, |
| 92 | const int length) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 93 | |
mflodman@webrtc.org | d5a4d9b | 2012-01-02 13:04:05 +0000 | [diff] [blame] | 94 | // This function sets the Maximum Transition Unit (MTU) for a channel. The |
| 95 | // RTP packet will be packetized based on this MTU to optimize performance |
| 96 | // over the network. |
| 97 | virtual int SetMTU(int video_channel, unsigned int mtu) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 98 | |
mflodman@webrtc.org | d5a4d9b | 2012-01-02 13:04:05 +0000 | [diff] [blame] | 99 | // This function enables or disables warning reports if packets have not |
| 100 | // been received for a specified time interval. |
| 101 | virtual int SetPacketTimeoutNotification(const int video_channel, |
| 102 | bool enable, |
| 103 | int timeout_seconds) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 104 | |
mflodman@webrtc.org | d5a4d9b | 2012-01-02 13:04:05 +0000 | [diff] [blame] | 105 | // Registers an instance of a user implementation of the ViENetwork |
| 106 | // observer. |
| 107 | virtual int RegisterObserver(const int video_channel, |
| 108 | ViENetworkObserver& observer) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 109 | |
mflodman@webrtc.org | d5a4d9b | 2012-01-02 13:04:05 +0000 | [diff] [blame] | 110 | // Removes a registered instance of ViENetworkObserver. |
| 111 | virtual int DeregisterObserver(const int video_channel) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 112 | |
mflodman@webrtc.org | d5a4d9b | 2012-01-02 13:04:05 +0000 | [diff] [blame] | 113 | // This function enables or disables the periodic dead‐or‐alive callback |
| 114 | // functionality for a specified channel. |
| 115 | virtual int SetPeriodicDeadOrAliveStatus( |
| 116 | const int video_channel, |
| 117 | const bool enable, |
| 118 | const unsigned int sample_time_seconds = KDefaultSampleTimeSeconds) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 119 | |
mflodman@webrtc.org | d5a4d9b | 2012-01-02 13:04:05 +0000 | [diff] [blame] | 120 | protected: |
| 121 | ViENetwork() {} |
| 122 | virtual ~ViENetwork() {} |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 123 | }; |
mflodman@webrtc.org | d5a4d9b | 2012-01-02 13:04:05 +0000 | [diff] [blame] | 124 | |
| 125 | } // namespace webrtc |
| 126 | |
| 127 | #endif // WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_NETWORK_H_ |