1b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org/*
2b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
3b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org *
4b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org *  Use of this source code is governed by a BSD-style license
5b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org *  that can be found in the LICENSE file in the root of the source
6b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org *  tree. An additional intellectual property rights grant can be found
7b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org *  in the file PATENTS.  All contributing project authors may
8b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org *  be found in the AUTHORS file in the root of the source tree.
9b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org */
10b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
11b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org#ifndef WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_NETWORK_H_
12b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org#define WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_NETWORK_H_
13b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
14b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// This sub-API supports the following functionalities:
15b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org//  - Configuring send and receive addresses.
16b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org//  - External transport support.
17b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org//  - Port and address filters.
18b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org//  - Windows GQoS functions and ToS functions.
19b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org//  - Packet timeout notification.
20b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org//  - Dead‐or‐Alive connection observations.
21b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
22dca71b270896a8501d9f12506e7da48cde9abb20stefan@webrtc.org#include "webrtc/common_types.h"
23b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
24b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.orgnamespace webrtc {
25b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
26b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.orgclass Transport;
27b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.orgclass VideoEngine;
28b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
29b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org// This enumerator describes VideoEngine packet timeout states.
30b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.orgenum ViEPacketTimeout {
31b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  NoPacket = 0,
32b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  PacketReceived = 1
33b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org};
34b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
35b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.orgclass WEBRTC_DLLEXPORT ViENetwork {
36b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org public:
37b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  // Default values.
38b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  enum { KDefaultSampleTimeSeconds = 2 };
39b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
40b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  // Factory for the ViENetwork sub‐API and increases an internal reference
41b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  // counter if successful. Returns NULL if the API is not supported or if
42b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  // construction fails.
43b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  static ViENetwork* GetInterface(VideoEngine* video_engine);
44b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
45b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  // Releases the ViENetwork sub-API and decreases an internal reference
46b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  // counter.Returns the new reference count. This value should be zero
47b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  // for all sub-API:s before the VideoEngine object can be safely deleted.
48b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  virtual int Release() = 0;
49b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
50dca71b270896a8501d9f12506e7da48cde9abb20stefan@webrtc.org  // Inform the engine about if the network adapter is currently transmitting
51dca71b270896a8501d9f12506e7da48cde9abb20stefan@webrtc.org  // packets or not.
52dca71b270896a8501d9f12506e7da48cde9abb20stefan@webrtc.org  virtual void SetNetworkTransmissionState(const int video_channel,
53dca71b270896a8501d9f12506e7da48cde9abb20stefan@webrtc.org                                           const bool is_transmitting) = 0;
54dca71b270896a8501d9f12506e7da48cde9abb20stefan@webrtc.org
55b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  // This function registers a user implementation of Transport to use for
56b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  // sending RTP and RTCP packets on this channel.
57b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  virtual int RegisterSendTransport(const int video_channel,
58b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org                                    Transport& transport) = 0;
59b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
60b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  // This function deregisters a used Transport for a specified channel.
61b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  virtual int DeregisterSendTransport(const int video_channel) = 0;
62b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
63b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  // When using external transport for a channel, received RTP packets should
64b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  // be passed to VideoEngine using this function. The input should contain
65b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  // the RTP header and payload.
66b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  virtual int ReceivedRTPPacket(const int video_channel,
67b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org                                const void* data,
68efeb8ce7e183005e557a2d107203e2057cec26a8wu@webrtc.org                                const int length,
69efeb8ce7e183005e557a2d107203e2057cec26a8wu@webrtc.org                                const PacketTime& packet_time) = 0;
70b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
71b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  // When using external transport for a channel, received RTCP packets should
72b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  // be passed to VideoEngine using this function.
73b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  virtual int ReceivedRTCPPacket(const int video_channel,
74b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org                                 const void* data,
75b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org                                 const int length) = 0;
76b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
77b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  // This function sets the Maximum Transition Unit (MTU) for a channel. The
78b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  // RTP packet will be packetized based on this MTU to optimize performance
79b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  // over the network.
80b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  virtual int SetMTU(int video_channel, unsigned int mtu) = 0;
81b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
82fec6b6e5999edec8c90efae54357f1aae6a4c7ddsolenberg@webrtc.org  // Forward (audio) packet to bandwidth estimator for the given video channel,
83fec6b6e5999edec8c90efae54357f1aae6a4c7ddsolenberg@webrtc.org  // for aggregated audio+video BWE.
84fec6b6e5999edec8c90efae54357f1aae6a4c7ddsolenberg@webrtc.org  virtual int ReceivedBWEPacket(const int video_channel,
85fec6b6e5999edec8c90efae54357f1aae6a4c7ddsolenberg@webrtc.org      int64_t arrival_time_ms, int payload_size, const RTPHeader& header) {
86fec6b6e5999edec8c90efae54357f1aae6a4c7ddsolenberg@webrtc.org    return 0;
87fec6b6e5999edec8c90efae54357f1aae6a4c7ddsolenberg@webrtc.org  }
88fec6b6e5999edec8c90efae54357f1aae6a4c7ddsolenberg@webrtc.org
895d8c95410ed920ebc224686bb8db2fc358c0e0c0stefan@webrtc.org  // TODO(holmer): Remove the default implementation when this has been fixed
905d8c95410ed920ebc224686bb8db2fc358c0e0c0stefan@webrtc.org  // in fakewebrtcvideoengine.cc.
915d8c95410ed920ebc224686bb8db2fc358c0e0c0stefan@webrtc.org  virtual bool SetBandwidthEstimationConfig(int video_channel,
925d8c95410ed920ebc224686bb8db2fc358c0e0c0stefan@webrtc.org                                            const webrtc::Config& config) {
935d8c95410ed920ebc224686bb8db2fc358c0e0c0stefan@webrtc.org    return false;
945d8c95410ed920ebc224686bb8db2fc358c0e0c0stefan@webrtc.org  }
955d8c95410ed920ebc224686bb8db2fc358c0e0c0stefan@webrtc.org
96b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org protected:
97b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  ViENetwork() {}
98b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org  virtual ~ViENetwork() {}
99b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org};
100b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
101b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org}  // namespace webrtc
102b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org
103b015cbede88899f67a53fbbe581b02ce8e32794andrew@webrtc.org#endif  // WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_NETWORK_H_
104