Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: webrtc/call/flexfec_receive_stream.cc

Issue 2397843005: Add FlexfecReceiveStream. (Closed)
Patch Set: Fix {} consistency in config.cc Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/call/flexfec_receive_stream.h ('k') | webrtc/call/flexfec_receive_stream_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 {
26
27 // TODO(brandtr): Update this function when we support multistream protection.
28 std::unique_ptr<FlexfecReceiver> MaybeUpdateConfigAndCreateFlexfecReceiver(
29 FlexfecReceiveStream::Config* config,
30 RecoveredPacketReceiver* recovered_packet_callback) {
31 if (config->protected_media_ssrcs.empty()) {
32 LOG(LS_ERROR) << "No protected media SSRC supplied. "
33 << "This FlexfecReceiveStream will therefore be useless.";
34 return nullptr;
35 } else if (config->protected_media_ssrcs.size() > 1) {
36 LOG(LS_WARNING)
37 << "The supplied FlexfecConfig contained multiple protected "
38 "media streams, but our implementation currently only "
39 "supports protecting a single media stream. This "
40 "FlexfecReceiveStream will therefore only accept media "
41 "packets from the first supplied media stream, with SSRC "
42 << config->protected_media_ssrcs[0] << ".";
43 config->protected_media_ssrcs.resize(1);
44 }
45 return FlexfecReceiver::Create(config->flexfec_ssrc,
46 config->protected_media_ssrcs[0],
47 recovered_packet_callback);
48 }
49
50 } // namespace
51
52 namespace internal {
53
54 FlexfecReceiveStream::FlexfecReceiveStream(
55 Config configuration,
56 RecoveredPacketReceiver* recovered_packet_callback)
57 : started_(false),
58 config_(configuration),
59 receiver_(MaybeUpdateConfigAndCreateFlexfecReceiver(
60 &config_,
61 recovered_packet_callback)) {
62 LOG(LS_INFO) << "FlexfecReceiveStream: " << config_.ToString();
63 }
64
65 FlexfecReceiveStream::~FlexfecReceiveStream() {
66 LOG(LS_INFO) << "~FlexfecReceiveStream: " << config_.ToString();
67 Stop();
68 }
69
70 bool FlexfecReceiveStream::AddAndProcessReceivedPacket(const uint8_t* packet,
71 size_t packet_length) {
72 {
73 rtc::CritScope cs(&crit_);
74 if (!started_)
75 return false;
76 }
77 if (!receiver_)
78 return false;
79 return receiver_->AddAndProcessReceivedPacket(packet, packet_length);
80 }
81
82 void FlexfecReceiveStream::Start() {
83 rtc::CritScope cs(&crit_);
84 started_ = true;
85 }
86
87 void FlexfecReceiveStream::Stop() {
88 rtc::CritScope cs(&crit_);
89 started_ = false;
90 }
91
92 // TODO(brandtr): Implement this member function when we have designed the
93 // stats for FlexFEC.
94 FlexfecReceiveStream::Stats FlexfecReceiveStream::GetStats() const {
95 return webrtc::FlexfecReceiveStream::Stats();
96 }
97
98 } // namespace internal
99
100 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/call/flexfec_receive_stream.h ('k') | webrtc/call/flexfec_receive_stream_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698