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#ifndef WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_NETWORK_H_
12#define WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_NETWORK_H_
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
22#include "webrtc/common_types.h"
23
24namespace webrtc {
25
26class Transport;
27class VideoEngine;
28
29// This enumerator describes VideoEngine packet timeout states.
30enum ViEPacketTimeout {
31  NoPacket = 0,
32  PacketReceived = 1
33};
34
35class WEBRTC_DLLEXPORT ViENetwork {
36 public:
37  // Default values.
38  enum { KDefaultSampleTimeSeconds = 2 };
39
40  // Factory for the ViENetwork sub‐API and increases an internal reference
41  // counter if successful. Returns NULL if the API is not supported or if
42  // construction fails.
43  static ViENetwork* GetInterface(VideoEngine* video_engine);
44
45  // Releases the ViENetwork sub-API and decreases an internal reference
46  // counter.Returns the new reference count. This value should be zero
47  // for all sub-API:s before the VideoEngine object can be safely deleted.
48  virtual int Release() = 0;
49
50  // Inform the engine about if the network adapter is currently transmitting
51  // packets or not.
52  virtual void SetNetworkTransmissionState(const int video_channel,
53                                           const bool is_transmitting) = 0;
54
55  // This function registers a user implementation of Transport to use for
56  // sending RTP and RTCP packets on this channel.
57  virtual int RegisterSendTransport(const int video_channel,
58                                    Transport& transport) = 0;
59
60  // This function deregisters a used Transport for a specified channel.
61  virtual int DeregisterSendTransport(const int video_channel) = 0;
62
63  // When using external transport for a channel, received RTP packets should
64  // be passed to VideoEngine using this function. The input should contain
65  // the RTP header and payload.
66  virtual int ReceivedRTPPacket(const int video_channel,
67                                const void* data,
68                                const int length,
69                                const PacketTime& packet_time) = 0;
70
71  // When using external transport for a channel, received RTCP packets should
72  // be passed to VideoEngine using this function.
73  virtual int ReceivedRTCPPacket(const int video_channel,
74                                 const void* data,
75                                 const int length) = 0;
76
77  // This function sets the Maximum Transition Unit (MTU) for a channel. The
78  // RTP packet will be packetized based on this MTU to optimize performance
79  // over the network.
80  virtual int SetMTU(int video_channel, unsigned int mtu) = 0;
81
82  // Forward (audio) packet to bandwidth estimator for the given video channel,
83  // for aggregated audio+video BWE.
84  virtual int ReceivedBWEPacket(const int video_channel,
85      int64_t arrival_time_ms, int payload_size, const RTPHeader& header) {
86    return 0;
87  }
88
89  // TODO(holmer): Remove the default implementation when this has been fixed
90  // in fakewebrtcvideoengine.cc.
91  virtual bool SetBandwidthEstimationConfig(int video_channel,
92                                            const webrtc::Config& config) {
93    return false;
94  }
95
96 protected:
97  ViENetwork() {}
98  virtual ~ViENetwork() {}
99};
100
101}  // namespace webrtc
102
103#endif  // WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_NETWORK_H_
104