Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright (c) 2016 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/call/flexfec_receive_stream.h" | |
| 12 | |
| 13 #include "webrtc/base/checks.h" | |
| 14 #include "webrtc/base/logging.h" | |
| 15 | |
| 16 namespace webrtc { | |
| 17 | |
| 18 std::string FlexfecReceiveStream::Stats::ToString(int64_t time_ms) const { | |
| 19 std::stringstream ss; | |
| 20 ss << "FlexfecReceiveStream stats: " << time_ms | |
| 21 << ", {flexfec_bitrate_bps: " << flexfec_bitrate_bps << "}"; | |
| 22 return ss.str(); | |
| 23 } | |
| 24 | |
| 25 namespace internal { | |
| 26 | |
| 27 FlexfecReceiveStream::FlexfecReceiveStream( | |
| 28 Config configuration, | |
| 29 RecoveredPacketReceiver* recovered_packet_callback) | |
| 30 : config_(configuration), | |
| 31 recovered_packet_callback_(recovered_packet_callback) { | |
| 32 if (config_.protected_media_ssrcs.empty()) { | |
|
stefan-webrtc
2016/10/18 18:22:24
Break this out to a helper function so you can do:
brandtr
2016/10/19 08:37:23
Good idea! Done.
| |
| 33 LOG(LS_ERROR) << "No protected media SSRC supplied. " | |
| 34 << "This FlexfecReceiveStream will therefore be useless."; | |
| 35 receiver_ = nullptr; | |
| 36 } else { | |
| 37 // TODO(brandtr): Remove when we support multistream protection. | |
| 38 if (config_.protected_media_ssrcs.size() > 1) { | |
| 39 LOG(LS_WARNING) | |
| 40 << "The supplied FlexfecConfig contained multiple protected " | |
| 41 "media streams, but our implementation currently only " | |
| 42 "supports protecting a single media stream. This " | |
| 43 "FlexfecReceiveStream will therefore only accept media " | |
| 44 "packets from the first supplied media stream, with SSRC " | |
| 45 << config_.protected_media_ssrcs[0] << "."; | |
| 46 config_.protected_media_ssrcs.resize(1); | |
| 47 } | |
| 48 receiver_ = FlexfecReceiver::Create(config_.flexfec_ssrc, | |
| 49 config_.protected_media_ssrcs[0], | |
| 50 recovered_packet_callback_); | |
| 51 } | |
| 52 | |
| 53 LOG(LS_INFO) << "FlexfecReceiveStream: " << config_.ToString(); | |
| 54 } | |
| 55 | |
| 56 FlexfecReceiveStream::~FlexfecReceiveStream() { | |
| 57 LOG(LS_INFO) << "~FlexfecReceiveStream: " << config_.ToString(); | |
| 58 Stop(); | |
| 59 } | |
| 60 | |
| 61 bool FlexfecReceiveStream::AddAndProcessReceivedPacket(const uint8_t* packet, | |
| 62 size_t packet_length) { | |
| 63 { | |
| 64 rtc::CritScope cs(&crit_); | |
| 65 if (!started_) | |
| 66 return false; | |
| 67 } | |
| 68 if (!receiver_) | |
| 69 return false; | |
| 70 return receiver_->AddAndProcessReceivedPacket(packet, packet_length); | |
| 71 } | |
| 72 | |
| 73 void FlexfecReceiveStream::Start() { | |
| 74 rtc::CritScope cs(&crit_); | |
| 75 started_ = true; | |
| 76 } | |
| 77 | |
| 78 void FlexfecReceiveStream::Stop() { | |
| 79 rtc::CritScope cs(&crit_); | |
| 80 started_ = false; | |
| 81 } | |
| 82 | |
| 83 // TODO(brandtr): Implement this member function when we have designed the | |
| 84 // stats for FlexFEC. | |
| 85 FlexfecReceiveStream::Stats FlexfecReceiveStream::GetStats() const { | |
| 86 return webrtc::FlexfecReceiveStream::Stats(); | |
| 87 } | |
| 88 | |
| 89 } // namespace internal | |
| 90 | |
| 91 } // namespace webrtc | |
| OLD | NEW |