OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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/video/encoder_state_feedback.h" | 11 #include "webrtc/video/encoder_state_feedback.h" |
12 | 12 |
13 #include "webrtc/base/checks.h" | 13 #include "webrtc/base/checks.h" |
14 #include "webrtc/video/vie_encoder.h" | 14 #include "webrtc/video/vie_encoder.h" |
15 | 15 |
16 namespace webrtc { | 16 namespace webrtc { |
17 | 17 |
18 EncoderStateFeedback::EncoderStateFeedback() : vie_encoder_(nullptr) {} | 18 EncoderStateFeedback::EncoderStateFeedback() : vie_encoder_(nullptr) {} |
19 | 19 |
20 void EncoderStateFeedback::Init(const std::vector<uint32_t>& ssrcs, | 20 void EncoderStateFeedback::Init(const std::vector<uint32_t>& ssrcs, |
21 ViEEncoder* encoder) { | 21 ViEEncoder* encoder) { |
22 RTC_DCHECK(!ssrcs.empty()); | 22 RTC_DCHECK(!ssrcs.empty()); |
23 rtc::CritScope lock(&crit_); | 23 rtc::CritScope lock(&crit_); |
24 ssrcs_ = ssrcs; | 24 ssrcs_ = ssrcs; |
25 vie_encoder_ = encoder; | 25 vie_encoder_ = encoder; |
26 } | 26 } |
27 | 27 |
28 void EncoderStateFeedback::TearDown() { | |
29 rtc::CritScope lock(&crit_); | |
30 RTC_DCHECK(vie_encoder_); | |
31 ssrcs_.clear(); | |
32 vie_encoder_ = nullptr; | |
33 } | |
34 | |
35 bool EncoderStateFeedback::HasSsrc(uint32_t ssrc) { | 28 bool EncoderStateFeedback::HasSsrc(uint32_t ssrc) { |
36 for (uint32_t registered_ssrc : ssrcs_) { | 29 for (uint32_t registered_ssrc : ssrcs_) { |
37 if (registered_ssrc == ssrc) | 30 if (registered_ssrc == ssrc) |
38 return true; | 31 return true; |
39 } | 32 } |
40 return false; | 33 return false; |
41 } | 34 } |
42 | 35 |
43 void EncoderStateFeedback::OnReceivedIntraFrameRequest(uint32_t ssrc) { | 36 void EncoderStateFeedback::OnReceivedIntraFrameRequest(uint32_t ssrc) { |
44 rtc::CritScope lock(&crit_); | 37 rtc::CritScope lock(&crit_); |
(...skipping 30 matching lines...) Expand all Loading... |
75 return; | 68 return; |
76 rtc::CritScope lock(&crit_); | 69 rtc::CritScope lock(&crit_); |
77 if (ssrcs_.empty()) // Encoder not yet attached (or detached for teardown). | 70 if (ssrcs_.empty()) // Encoder not yet attached (or detached for teardown). |
78 return; | 71 return; |
79 // SSRC shouldn't change to something we haven't already registered with the | 72 // SSRC shouldn't change to something we haven't already registered with the |
80 // encoder. | 73 // encoder. |
81 RTC_DCHECK(HasSsrc(new_ssrc)); | 74 RTC_DCHECK(HasSsrc(new_ssrc)); |
82 } | 75 } |
83 | 76 |
84 } // namespace webrtc | 77 } // namespace webrtc |
OLD | NEW |