Line data Source code
1 : /*
2 : * Copyright (c) 2013 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 : #ifndef WEBRTC_CALL_CALL_H_
11 : #define WEBRTC_CALL_CALL_H_
12 :
13 : #include <string>
14 : #include <vector>
15 :
16 : #include "webrtc/base/networkroute.h"
17 : #include "webrtc/base/platform_file.h"
18 : #include "webrtc/base/socket.h"
19 : #include "webrtc/call/audio_receive_stream.h"
20 : #include "webrtc/call/audio_send_stream.h"
21 : #include "webrtc/call/audio_state.h"
22 : #include "webrtc/call/flexfec_receive_stream.h"
23 : #include "webrtc/common_types.h"
24 : #include "webrtc/video_receive_stream.h"
25 : #include "webrtc/video_send_stream.h"
26 :
27 : namespace webrtc {
28 :
29 : class AudioProcessing;
30 : class RtcEventLog;
31 :
32 : const char* Version();
33 :
34 : enum class MediaType {
35 : ANY,
36 : AUDIO,
37 : VIDEO,
38 : DATA
39 : };
40 :
41 0 : class PacketReceiver {
42 : public:
43 : enum DeliveryStatus {
44 : DELIVERY_OK,
45 : DELIVERY_UNKNOWN_SSRC,
46 : DELIVERY_PACKET_ERROR,
47 : };
48 :
49 : virtual DeliveryStatus DeliverPacket(MediaType media_type,
50 : const uint8_t* packet,
51 : size_t length,
52 : const PacketTime& packet_time) = 0;
53 :
54 : protected:
55 0 : virtual ~PacketReceiver() {}
56 : };
57 :
58 : // A Call instance can contain several send and/or receive streams. All streams
59 : // are assumed to have the same remote endpoint and will share bitrate estimates
60 : // etc.
61 0 : class Call {
62 : public:
63 0 : struct Config {
64 0 : explicit Config(RtcEventLog* event_log) : event_log(event_log) {
65 0 : RTC_DCHECK(event_log);
66 0 : }
67 :
68 : static const int kDefaultStartBitrateBps;
69 :
70 : // Bitrate config used until valid bitrate estimates are calculated. Also
71 : // used to cap total bitrate used.
72 0 : struct BitrateConfig {
73 : int min_bitrate_bps = 0;
74 : int start_bitrate_bps = kDefaultStartBitrateBps;
75 : int max_bitrate_bps = -1;
76 : } bitrate_config;
77 :
78 : // AudioState which is possibly shared between multiple calls.
79 : // TODO(solenberg): Change this to a shared_ptr once we can use C++11.
80 : rtc::scoped_refptr<AudioState> audio_state;
81 :
82 : // Audio Processing Module to be used in this call.
83 : // TODO(solenberg): Change this to a shared_ptr once we can use C++11.
84 : AudioProcessing* audio_processing = nullptr;
85 :
86 : // RtcEventLog to use for this call. Required.
87 : // Use webrtc::RtcEventLog::CreateNull() for a null implementation.
88 : RtcEventLog* event_log = nullptr;
89 : };
90 :
91 : struct Stats {
92 : std::string ToString(int64_t time_ms) const;
93 :
94 : int send_bandwidth_bps = 0; // Estimated available send bandwidth.
95 : int max_padding_bitrate_bps = 0; // Cumulative configured max padding.
96 : int recv_bandwidth_bps = 0; // Estimated available receive bandwidth.
97 : int64_t pacer_delay_ms = 0;
98 : int64_t rtt_ms = -1;
99 : };
100 :
101 : static Call* Create(const Call::Config& config);
102 :
103 : virtual AudioSendStream* CreateAudioSendStream(
104 : const AudioSendStream::Config& config) = 0;
105 : virtual void DestroyAudioSendStream(AudioSendStream* send_stream) = 0;
106 :
107 : virtual AudioReceiveStream* CreateAudioReceiveStream(
108 : const AudioReceiveStream::Config& config) = 0;
109 : virtual void DestroyAudioReceiveStream(
110 : AudioReceiveStream* receive_stream) = 0;
111 :
112 : virtual VideoSendStream* CreateVideoSendStream(
113 : VideoSendStream::Config config,
114 : VideoEncoderConfig encoder_config) = 0;
115 : virtual void DestroyVideoSendStream(VideoSendStream* send_stream) = 0;
116 :
117 : virtual VideoReceiveStream* CreateVideoReceiveStream(
118 : VideoReceiveStream::Config configuration) = 0;
119 : virtual void DestroyVideoReceiveStream(
120 : VideoReceiveStream* receive_stream) = 0;
121 :
122 : virtual FlexfecReceiveStream* CreateFlexfecReceiveStream(
123 : const FlexfecReceiveStream::Config& config) = 0;
124 : virtual void DestroyFlexfecReceiveStream(
125 : FlexfecReceiveStream* receive_stream) = 0;
126 :
127 : // All received RTP and RTCP packets for the call should be inserted to this
128 : // PacketReceiver. The PacketReceiver pointer is valid as long as the
129 : // Call instance exists.
130 : virtual PacketReceiver* Receiver() = 0;
131 :
132 : // Returns the call statistics, such as estimated send and receive bandwidth,
133 : // pacing delay, etc.
134 : virtual Stats GetStats() const = 0;
135 :
136 : // TODO(pbos): Like BitrateConfig above this is currently per-stream instead
137 : // of maximum for entire Call. This should be fixed along with the above.
138 : // Specifying a start bitrate (>0) will currently reset the current bitrate
139 : // estimate. This is due to how the 'x-google-start-bitrate' flag is currently
140 : // implemented.
141 : virtual void SetBitrateConfig(
142 : const Config::BitrateConfig& bitrate_config) = 0;
143 :
144 : // TODO(skvlad): When the unbundled case with multiple streams for the same
145 : // media type going over different networks is supported, track the state
146 : // for each stream separately. Right now it's global per media type.
147 : virtual void SignalChannelNetworkState(MediaType media,
148 : NetworkState state) = 0;
149 :
150 : virtual void OnTransportOverheadChanged(
151 : MediaType media,
152 : int transport_overhead_per_packet) = 0;
153 :
154 : virtual void OnNetworkRouteChanged(
155 : const std::string& transport_name,
156 : const rtc::NetworkRoute& network_route) = 0;
157 :
158 : virtual void OnSentPacket(const rtc::SentPacket& sent_packet) = 0;
159 :
160 : virtual VoiceEngine* voice_engine() = 0;
161 :
162 0 : virtual ~Call() {}
163 : };
164 :
165 : } // namespace webrtc
166 :
167 : #endif // WEBRTC_CALL_CALL_H_
|