OLD | NEW |
| (Empty) |
1 /* | |
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 #include "webrtc/video/audio_receive_stream.h" | |
12 | |
13 #include <string> | |
14 | |
15 #include "webrtc/base/checks.h" | |
16 #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimat
or.h" | |
17 #include "webrtc/system_wrappers/interface/tick_util.h" | |
18 | |
19 namespace webrtc { | |
20 std::string AudioReceiveStream::Config::Rtp::ToString() const { | |
21 std::stringstream ss; | |
22 ss << "{remote_ssrc: " << remote_ssrc; | |
23 ss << ", extensions: ["; | |
24 for (size_t i = 0; i < extensions.size(); ++i) { | |
25 ss << extensions[i].ToString(); | |
26 if (i != extensions.size() - 1) | |
27 ss << ", "; | |
28 } | |
29 ss << ']'; | |
30 ss << '}'; | |
31 return ss.str(); | |
32 } | |
33 | |
34 std::string AudioReceiveStream::Config::ToString() const { | |
35 std::stringstream ss; | |
36 ss << "{rtp: " << rtp.ToString(); | |
37 ss << ", voe_channel_id: " << voe_channel_id; | |
38 if (!sync_group.empty()) | |
39 ss << ", sync_group: " << sync_group; | |
40 ss << '}'; | |
41 return ss.str(); | |
42 } | |
43 | |
44 namespace internal { | |
45 AudioReceiveStream::AudioReceiveStream( | |
46 RemoteBitrateEstimator* remote_bitrate_estimator, | |
47 const webrtc::AudioReceiveStream::Config& config) | |
48 : remote_bitrate_estimator_(remote_bitrate_estimator), | |
49 config_(config), | |
50 rtp_header_parser_(RtpHeaderParser::Create()) { | |
51 RTC_DCHECK(config.voe_channel_id != -1); | |
52 RTC_DCHECK(remote_bitrate_estimator_ != nullptr); | |
53 RTC_DCHECK(rtp_header_parser_ != nullptr); | |
54 for (const auto& ext : config.rtp.extensions) { | |
55 // One-byte-extension local identifiers are in the range 1-14 inclusive. | |
56 RTC_DCHECK_GE(ext.id, 1); | |
57 RTC_DCHECK_LE(ext.id, 14); | |
58 if (ext.name == RtpExtension::kAudioLevel) { | |
59 RTC_CHECK(rtp_header_parser_->RegisterRtpHeaderExtension( | |
60 kRtpExtensionAudioLevel, ext.id)); | |
61 } else if (ext.name == RtpExtension::kAbsSendTime) { | |
62 RTC_CHECK(rtp_header_parser_->RegisterRtpHeaderExtension( | |
63 kRtpExtensionAbsoluteSendTime, ext.id)); | |
64 } else if (ext.name == RtpExtension::kTransportSequenceNumber) { | |
65 RTC_CHECK(rtp_header_parser_->RegisterRtpHeaderExtension( | |
66 kRtpExtensionTransportSequenceNumber, ext.id)); | |
67 } else { | |
68 RTC_NOTREACHED() << "Unsupported RTP extension."; | |
69 } | |
70 } | |
71 } | |
72 | |
73 webrtc::AudioReceiveStream::Stats AudioReceiveStream::GetStats() const { | |
74 return webrtc::AudioReceiveStream::Stats(); | |
75 } | |
76 | |
77 void AudioReceiveStream::Start() { | |
78 } | |
79 | |
80 void AudioReceiveStream::Stop() { | |
81 } | |
82 | |
83 void AudioReceiveStream::SignalNetworkState(NetworkState state) { | |
84 } | |
85 | |
86 bool AudioReceiveStream::DeliverRtcp(const uint8_t* packet, size_t length) { | |
87 return false; | |
88 } | |
89 | |
90 bool AudioReceiveStream::DeliverRtp(const uint8_t* packet, | |
91 size_t length, | |
92 const PacketTime& packet_time) { | |
93 RTPHeader header; | |
94 | |
95 if (!rtp_header_parser_->Parse(packet, length, &header)) { | |
96 return false; | |
97 } | |
98 | |
99 // Only forward if the parsed header has absolute sender time. RTP timestamps | |
100 // may have different rates for audio and video and shouldn't be mixed. | |
101 if (config_.combined_audio_video_bwe && | |
102 header.extension.hasAbsoluteSendTime) { | |
103 int64_t arrival_time_ms = TickTime::MillisecondTimestamp(); | |
104 if (packet_time.timestamp >= 0) | |
105 arrival_time_ms = (packet_time.timestamp + 500) / 1000; | |
106 size_t payload_size = length - header.headerLength; | |
107 remote_bitrate_estimator_->IncomingPacket(arrival_time_ms, payload_size, | |
108 header, false); | |
109 } | |
110 return true; | |
111 } | |
112 } // namespace internal | |
113 } // namespace webrtc | |
OLD | NEW |