OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2017 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/rtp_stream_receiver_controller.h" | 11 #include "webrtc/call/rtp_stream_receiver_controller.h" |
12 | |
13 #include "webrtc/rtc_base/logging.h" | |
14 #include "webrtc/rtc_base/ptr_util.h" | 12 #include "webrtc/rtc_base/ptr_util.h" |
15 | 13 |
16 namespace webrtc { | 14 namespace webrtc { |
17 | 15 |
18 RtpStreamReceiverController::Receiver::Receiver( | 16 RtpStreamReceiverController::Receiver::Receiver( |
19 RtpStreamReceiverController* controller, | 17 RtpStreamReceiverController* controller, |
20 uint32_t ssrc, | 18 uint32_t ssrc, |
21 RtpPacketSinkInterface* sink) | 19 RtpPacketSinkInterface* sink) |
22 : controller_(controller), sink_(sink) { | 20 : controller_(controller), sink_(sink) { |
23 const bool sink_added = controller_->AddSink(ssrc, sink_); | 21 controller_->AddSink(ssrc, sink_); |
24 if (!sink_added) { | |
25 LOG(LS_ERROR) << "RtpStreamReceiverController::Receiver::Receiver: Sink " | |
26 << "could not be added for SSRC=" << ssrc << "."; | |
27 } | |
28 } | 22 } |
29 | 23 |
30 RtpStreamReceiverController::Receiver::~Receiver() { | 24 RtpStreamReceiverController::Receiver::~Receiver() { |
31 // Don't require return value > 0, since for RTX we currently may | 25 // Don't require return value > 0, since for RTX we currently may |
32 // have multiple Receiver objects with the same sink. | 26 // have multiple Receiver objects with the same sink. |
33 // TODO(nisse): Consider adding a DCHECK when RtxReceiveStream is wired up. | 27 // TODO(nisse): Consider adding a DCHECK when RtxReceiveStream is wired up. |
34 controller_->RemoveSink(sink_); | 28 controller_->RemoveSink(sink_); |
35 } | 29 } |
36 | 30 |
37 RtpStreamReceiverController::RtpStreamReceiverController() = default; | 31 RtpStreamReceiverController::RtpStreamReceiverController() = default; |
38 RtpStreamReceiverController::~RtpStreamReceiverController() = default; | 32 RtpStreamReceiverController::~RtpStreamReceiverController() = default; |
39 | 33 |
40 std::unique_ptr<RtpStreamReceiverInterface> | 34 std::unique_ptr<RtpStreamReceiverInterface> |
41 RtpStreamReceiverController::CreateReceiver( | 35 RtpStreamReceiverController::CreateReceiver( |
42 uint32_t ssrc, | 36 uint32_t ssrc, |
43 RtpPacketSinkInterface* sink) { | 37 RtpPacketSinkInterface* sink) { |
44 return rtc::MakeUnique<Receiver>(this, ssrc, sink); | 38 return rtc::MakeUnique<Receiver>(this, ssrc, sink); |
45 } | 39 } |
46 | 40 |
47 bool RtpStreamReceiverController::OnRtpPacket(const RtpPacketReceived& packet) { | 41 bool RtpStreamReceiverController::OnRtpPacket(const RtpPacketReceived& packet) { |
48 rtc::CritScope cs(&lock_); | 42 rtc::CritScope cs(&lock_); |
49 return demuxer_.OnRtpPacket(packet); | 43 return demuxer_.OnRtpPacket(packet); |
50 } | 44 } |
51 | 45 |
52 bool RtpStreamReceiverController::AddSink(uint32_t ssrc, | 46 void RtpStreamReceiverController::AddSink(uint32_t ssrc, |
53 RtpPacketSinkInterface* sink) { | 47 RtpPacketSinkInterface* sink) { |
54 rtc::CritScope cs(&lock_); | 48 rtc::CritScope cs(&lock_); |
55 return demuxer_.AddSink(ssrc, sink); | 49 return demuxer_.AddSink(ssrc, sink); |
56 } | 50 } |
57 | 51 |
58 size_t RtpStreamReceiverController::RemoveSink( | 52 size_t RtpStreamReceiverController::RemoveSink( |
59 const RtpPacketSinkInterface* sink) { | 53 const RtpPacketSinkInterface* sink) { |
60 rtc::CritScope cs(&lock_); | 54 rtc::CritScope cs(&lock_); |
61 return demuxer_.RemoveSink(sink); | 55 return demuxer_.RemoveSink(sink); |
62 } | 56 } |
63 | 57 |
64 } // namespace webrtc | 58 } // namespace webrtc |
OLD | NEW |