blob: 356a3a39289910fa98aa7fc852e66e0e07535ed7 [file] [log] [blame]
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +02001/*
2 * Copyright (c) 2015 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_AUDIO_RECEIVE_STREAM_H_
12#define WEBRTC_AUDIO_RECEIVE_STREAM_H_
13
Fredrik Solenberg04f49312015-06-08 13:04:56 +020014#include <map>
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +020015#include <string>
16#include <vector>
17
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +020018#include "webrtc/config.h"
Jelena Marusiccd670222015-07-16 09:30:09 +020019#include "webrtc/stream.h"
solenbergcf18b342015-10-01 08:13:42 -070020#include "webrtc/transport.h"
Fredrik Solenberg04f49312015-06-08 13:04:56 +020021#include "webrtc/typedefs.h"
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +020022
23namespace webrtc {
24
Fredrik Solenberg04f49312015-06-08 13:04:56 +020025class AudioDecoder;
26
Fredrik Solenberga4527c82015-12-03 13:06:20 +010027// WORK IN PROGRESS
28// This class is under development and is not yet intended for for use outside
29// of WebRtc/Libjingle. Please use the VoiceEngine API instead.
30// See: https://bugs.chromium.org/p/webrtc/issues/detail?id=4690
31
Jelena Marusiccd670222015-07-16 09:30:09 +020032class AudioReceiveStream : public ReceiveStream {
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +020033 public:
Fredrik Solenberg4f4ec0a2015-10-22 10:49:27 +020034 struct Stats {
35 uint32_t remote_ssrc = 0;
36 int64_t bytes_rcvd = 0;
37 uint32_t packets_rcvd = 0;
38 uint32_t packets_lost = 0;
39 float fraction_lost = 0.0f;
40 std::string codec_name;
41 uint32_t ext_seqnum = 0;
42 uint32_t jitter_ms = 0;
43 uint32_t jitter_buffer_ms = 0;
44 uint32_t jitter_buffer_preferred_ms = 0;
45 uint32_t delay_estimate_ms = 0;
46 int32_t audio_level = -1;
47 float expand_rate = 0.0f;
48 float speech_expand_rate = 0.0f;
49 float secondary_decoded_rate = 0.0f;
50 float accelerate_rate = 0.0f;
51 float preemptive_expand_rate = 0.0f;
52 int32_t decoding_calls_to_silence_generator = 0;
53 int32_t decoding_calls_to_neteq = 0;
54 int32_t decoding_normal = 0;
55 int32_t decoding_plc = 0;
56 int32_t decoding_cng = 0;
57 int32_t decoding_plc_cng = 0;
58 int64_t capture_start_ntp_time_ms = 0;
59 };
Fredrik Solenberg04f49312015-06-08 13:04:56 +020060
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +020061 struct Config {
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +020062 std::string ToString() const;
63
64 // Receive-stream specific RTP settings.
65 struct Rtp {
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +020066 std::string ToString() const;
67
68 // Synchronization source (stream identifier) to be received.
Fredrik Solenberg04f49312015-06-08 13:04:56 +020069 uint32_t remote_ssrc = 0;
70
71 // Sender SSRC used for sending RTCP (such as receiver reports).
72 uint32_t local_ssrc = 0;
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +020073
74 // RTP header extensions used for the received stream.
75 std::vector<RtpExtension> extensions;
76 } rtp;
Fredrik Solenberg04f49312015-06-08 13:04:56 +020077
solenbergcf18b342015-10-01 08:13:42 -070078 Transport* receive_transport = nullptr;
79 Transport* rtcp_send_transport = nullptr;
80
81 // Underlying VoiceEngine handle, used to map AudioReceiveStream to lower-
82 // level components.
83 // TODO(solenberg): Remove when VoiceEngine channels are created outside
84 // of Call.
pbos8fc7fa72015-07-15 08:02:58 -070085 int voe_channel_id = -1;
86
87 // Identifier for an A/V synchronization group. Empty string to disable.
88 // TODO(pbos): Synchronize streams in a sync group, not just one video
89 // stream to one audio stream. Tracked by issue webrtc:4762.
90 std::string sync_group;
91
Fredrik Solenberg04f49312015-06-08 13:04:56 +020092 // Decoders for every payload that we can receive. Call owns the
93 // AudioDecoder instances once the Config is submitted to
94 // Call::CreateReceiveStream().
95 // TODO(solenberg): Use unique_ptr<> once our std lib fully supports C++11.
96 std::map<uint8_t, AudioDecoder*> decoder_map;
pbos6bb1b6e2015-07-24 07:10:18 -070097
98 // TODO(pbos): Remove config option once combined A/V BWE is always on.
99 bool combined_audio_video_bwe = false;
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +0200100 };
101
Fredrik Solenberg04f49312015-06-08 13:04:56 +0200102 virtual Stats GetStats() const = 0;
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +0200103};
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +0200104} // namespace webrtc
105
106#endif // WEBRTC_AUDIO_RECEIVE_STREAM_H_