OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #include "webrtc/call/flexfec_receive_stream.h" | 11 #include "webrtc/call/flexfec_receive_stream.h" |
12 | 12 |
13 #include "webrtc/base/checks.h" | 13 #include "webrtc/base/checks.h" |
14 #include "webrtc/base/logging.h" | 14 #include "webrtc/base/logging.h" |
15 | 15 |
16 namespace webrtc { | 16 namespace webrtc { |
17 | 17 |
18 std::string FlexfecReceiveStream::Stats::ToString(int64_t time_ms) const { | 18 std::string FlexfecReceiveStream::Stats::ToString(int64_t time_ms) const { |
19 std::stringstream ss; | 19 std::stringstream ss; |
20 ss << "FlexfecReceiveStream stats: " << time_ms | 20 ss << "FlexfecReceiveStream stats: " << time_ms |
21 << ", {flexfec_bitrate_bps: " << flexfec_bitrate_bps << "}"; | 21 << ", {flexfec_bitrate_bps: " << flexfec_bitrate_bps << "}"; |
22 return ss.str(); | 22 return ss.str(); |
23 } | 23 } |
24 | 24 |
25 namespace { | 25 namespace { |
26 | 26 |
27 // TODO(brandtr): Update this function when we support multistream protection. | 27 // TODO(brandtr): Update this function when we support multistream protection. |
28 std::unique_ptr<FlexfecReceiver> MaybeUpdateConfigAndCreateFlexfecReceiver( | 28 std::unique_ptr<FlexfecReceiver> MaybeCreateFlexfecReceiver( |
29 FlexfecReceiveStream::Config* config, | 29 const FlexfecReceiveStream::Config& config, |
30 RecoveredPacketReceiver* recovered_packet_callback) { | 30 RecoveredPacketReceiver* recovered_packet_callback) { |
31 if (config->protected_media_ssrcs.empty()) { | 31 if (config.flexfec_payload_type < 0) { |
32 LOG(LS_ERROR) << "No protected media SSRC supplied. " | 32 LOG(LS_WARNING) << "Invalid FlexFEC payload type given. " |
33 << "This FlexfecReceiveStream will therefore be useless."; | 33 << "This FlexfecReceiveStream will therefore be useless."; |
34 return nullptr; | 34 return nullptr; |
35 } else if (config->protected_media_ssrcs.size() > 1) { | 35 } |
| 36 RTC_DCHECK_GE(config.flexfec_payload_type, 0); |
| 37 RTC_DCHECK_LE(config.flexfec_payload_type, 127); |
| 38 if (config.flexfec_ssrc == 0) { |
| 39 LOG(LS_WARNING) << "Invalid FlexFEC SSRC given. " |
| 40 << "This FlexfecReceiveStream will therefore be useless."; |
| 41 return nullptr; |
| 42 } |
| 43 if (config.protected_media_ssrcs.empty()) { |
| 44 LOG(LS_WARNING) << "No protected media SSRC supplied. " |
| 45 << "This FlexfecReceiveStream will therefore be useless."; |
| 46 return nullptr; |
| 47 } |
| 48 |
| 49 if (config.protected_media_ssrcs.size() > 1) { |
36 LOG(LS_WARNING) | 50 LOG(LS_WARNING) |
37 << "The supplied FlexfecConfig contained multiple protected " | 51 << "The supplied FlexfecConfig contained multiple protected " |
38 "media streams, but our implementation currently only " | 52 "media streams, but our implementation currently only " |
39 "supports protecting a single media stream. This " | 53 "supports protecting a single media stream. " |
40 "FlexfecReceiveStream will therefore only accept media " | 54 "To avoid confusion, disabling FlexFEC completely."; |
41 "packets from the first supplied media stream, with SSRC " | 55 return nullptr; |
42 << config->protected_media_ssrcs[0] << "."; | |
43 config->protected_media_ssrcs.resize(1); | |
44 } | 56 } |
45 return std::unique_ptr<FlexfecReceiver>(new FlexfecReceiver( | 57 RTC_DCHECK_EQ(1U, config.protected_media_ssrcs.size()); |
46 config->flexfec_ssrc, config->protected_media_ssrcs[0], | 58 return std::unique_ptr<FlexfecReceiver>( |
47 recovered_packet_callback)); | 59 new FlexfecReceiver(config.flexfec_ssrc, config.protected_media_ssrcs[0], |
| 60 recovered_packet_callback)); |
48 } | 61 } |
49 | 62 |
50 } // namespace | 63 } // namespace |
51 | 64 |
52 namespace internal { | 65 namespace internal { |
53 | 66 |
54 FlexfecReceiveStream::FlexfecReceiveStream( | 67 FlexfecReceiveStream::FlexfecReceiveStream( |
55 Config configuration, | 68 Config configuration, |
56 RecoveredPacketReceiver* recovered_packet_callback) | 69 RecoveredPacketReceiver* recovered_packet_callback) |
57 : started_(false), | 70 : started_(false), |
58 config_(configuration), | 71 config_(configuration), |
59 receiver_(MaybeUpdateConfigAndCreateFlexfecReceiver( | 72 receiver_( |
60 &config_, | 73 MaybeCreateFlexfecReceiver(config_, recovered_packet_callback)) { |
61 recovered_packet_callback)) { | |
62 LOG(LS_INFO) << "FlexfecReceiveStream: " << config_.ToString(); | 74 LOG(LS_INFO) << "FlexfecReceiveStream: " << config_.ToString(); |
63 } | 75 } |
64 | 76 |
65 FlexfecReceiveStream::~FlexfecReceiveStream() { | 77 FlexfecReceiveStream::~FlexfecReceiveStream() { |
66 LOG(LS_INFO) << "~FlexfecReceiveStream: " << config_.ToString(); | 78 LOG(LS_INFO) << "~FlexfecReceiveStream: " << config_.ToString(); |
67 Stop(); | 79 Stop(); |
68 } | 80 } |
69 | 81 |
70 bool FlexfecReceiveStream::AddAndProcessReceivedPacket(const uint8_t* packet, | 82 bool FlexfecReceiveStream::AddAndProcessReceivedPacket(const uint8_t* packet, |
71 size_t packet_length) { | 83 size_t packet_length) { |
(...skipping 19 matching lines...) Expand all Loading... |
91 | 103 |
92 // TODO(brandtr): Implement this member function when we have designed the | 104 // TODO(brandtr): Implement this member function when we have designed the |
93 // stats for FlexFEC. | 105 // stats for FlexFEC. |
94 FlexfecReceiveStream::Stats FlexfecReceiveStream::GetStats() const { | 106 FlexfecReceiveStream::Stats FlexfecReceiveStream::GetStats() const { |
95 return webrtc::FlexfecReceiveStream::Stats(); | 107 return webrtc::FlexfecReceiveStream::Stats(); |
96 } | 108 } |
97 | 109 |
98 } // namespace internal | 110 } // namespace internal |
99 | 111 |
100 } // namespace webrtc | 112 } // namespace webrtc |
OLD | NEW |