tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

rtp_stream_receiver_controller.cc (2398B)


      1 /*
      2 *  Copyright (c) 2017 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 "call/rtp_stream_receiver_controller.h"
     12 
     13 #include <cstdint>
     14 #include <memory>
     15 
     16 #include "api/sequence_checker.h"
     17 #include "call/rtp_packet_sink_interface.h"
     18 #include "call/rtp_stream_receiver_controller_interface.h"
     19 #include "rtc_base/logging.h"
     20 
     21 namespace webrtc {
     22 
     23 RtpStreamReceiverController::Receiver::Receiver(
     24    RtpStreamReceiverController* controller,
     25    uint32_t ssrc,
     26    RtpPacketSinkInterface* sink)
     27    : controller_(controller), sink_(sink) {
     28  const bool sink_added = controller_->AddSink(ssrc, sink_);
     29  if (!sink_added) {
     30    RTC_LOG(LS_ERROR)
     31        << "RtpStreamReceiverController::Receiver::Receiver: Sink "
     32           "could not be added for SSRC="
     33        << ssrc << ".";
     34  }
     35 }
     36 
     37 RtpStreamReceiverController::Receiver::~Receiver() {
     38  // This may fail, if corresponding AddSink in the constructor failed.
     39  controller_->RemoveSink(sink_);
     40 }
     41 
     42 RtpStreamReceiverController::RtpStreamReceiverController() {}
     43 
     44 RtpStreamReceiverController::~RtpStreamReceiverController() = default;
     45 
     46 std::unique_ptr<RtpStreamReceiverInterface>
     47 RtpStreamReceiverController::CreateReceiver(uint32_t ssrc,
     48                                            RtpPacketSinkInterface* sink) {
     49  return std::make_unique<Receiver>(this, ssrc, sink);
     50 }
     51 
     52 bool RtpStreamReceiverController::OnRtpPacket(const RtpPacketReceived& packet) {
     53  RTC_DCHECK_RUN_ON(&demuxer_sequence_);
     54  return demuxer_.OnRtpPacket(packet);
     55 }
     56 
     57 void RtpStreamReceiverController::OnRecoveredPacket(
     58    const RtpPacketReceived& packet) {
     59  RTC_DCHECK_RUN_ON(&demuxer_sequence_);
     60  demuxer_.OnRtpPacket(packet);
     61 }
     62 
     63 bool RtpStreamReceiverController::AddSink(uint32_t ssrc,
     64                                          RtpPacketSinkInterface* sink) {
     65  RTC_DCHECK_RUN_ON(&demuxer_sequence_);
     66  return demuxer_.AddSink(ssrc, sink);
     67 }
     68 
     69 bool RtpStreamReceiverController::RemoveSink(
     70    const RtpPacketSinkInterface* sink) {
     71  RTC_DCHECK_RUN_ON(&demuxer_sequence_);
     72  return demuxer_.RemoveSink(sink);
     73 }
     74 
     75 }  // namespace webrtc