blob: 575eed197f0cab012e57163a1d99b7dd34dfffd3 [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
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000011#ifndef WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_NETWORK_H_
12#define WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_NETWORK_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000013
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.orgbfacda62013-03-27 16:36:01 +000022#include "webrtc/common_types.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000023
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000024namespace webrtc {
niklase@google.com470e71d2011-07-07 08:21:25 +000025
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000026class Transport;
27class VideoEngine;
niklase@google.com470e71d2011-07-07 08:21:25 +000028
29// This enumerator describes VideoEngine packet timeout states.
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000030enum ViEPacketTimeout {
31 NoPacket = 0,
32 PacketReceived = 1
niklase@google.com470e71d2011-07-07 08:21:25 +000033};
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.orgd5a4d9b2012-01-02 13:04:05 +000039class 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.com470e71d2011-07-07 08:21:25 +000045
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000046 // 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.com470e71d2011-07-07 08:21:25 +000051};
52
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000053class WEBRTC_DLLEXPORT ViENetwork {
54 public:
55 // Default values.
56 enum { KDefaultSampleTimeSeconds = 2 };
niklase@google.com470e71d2011-07-07 08:21:25 +000057
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000058 // 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.com470e71d2011-07-07 08:21:25 +000062
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000063 // 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.com470e71d2011-07-07 08:21:25 +000067
stefan@webrtc.orgbfacda62013-03-27 16:36:01 +000068 // 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.orgd5a4d9b2012-01-02 13:04:05 +000073 // 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.com470e71d2011-07-07 08:21:25 +000077
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000078 // This function deregisters a used Transport for a specified channel.
79 virtual int DeregisterSendTransport(const int video_channel) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000080
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000081 // 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.com470e71d2011-07-07 08:21:25 +000087
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000088 // 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.com470e71d2011-07-07 08:21:25 +000093
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000094 // 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.com470e71d2011-07-07 08:21:25 +000098
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +000099 // 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.com470e71d2011-07-07 08:21:25 +0000104
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +0000105 // 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.com470e71d2011-07-07 08:21:25 +0000109
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +0000110 // Removes a registered instance of ViENetworkObserver.
111 virtual int DeregisterObserver(const int video_channel) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000112
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +0000113 // 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.com470e71d2011-07-07 08:21:25 +0000119
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +0000120 protected:
121 ViENetwork() {}
122 virtual ~ViENetwork() {}
niklase@google.com470e71d2011-07-07 08:21:25 +0000123};
mflodman@webrtc.orgd5a4d9b2012-01-02 13:04:05 +0000124
125} // namespace webrtc
126
127#endif // WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_NETWORK_H_