rtp_stream_receiver_controller.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. #ifndef CALL_RTP_STREAM_RECEIVER_CONTROLLER_H_
  11. #define CALL_RTP_STREAM_RECEIVER_CONTROLLER_H_
  12. #include <memory>
  13. #include "call/rtp_demuxer.h"
  14. #include "call/rtp_stream_receiver_controller_interface.h"
  15. #include "rtc_base/deprecated/recursive_critical_section.h"
  16. namespace webrtc {
  17. class RtpPacketReceived;
  18. // This class represents the RTP receive parsing and demuxing, for a
  19. // single RTP session.
  20. // TODO(nisse): Add RTCP processing, we should aim to terminate RTCP
  21. // and not leave any RTCP processing to individual receive streams.
  22. // TODO(nisse): Extract per-packet processing, including parsing and
  23. // demuxing, into a separate class.
  24. class RtpStreamReceiverController
  25. : public RtpStreamReceiverControllerInterface {
  26. public:
  27. RtpStreamReceiverController();
  28. ~RtpStreamReceiverController() override;
  29. // Implements RtpStreamReceiverControllerInterface.
  30. std::unique_ptr<RtpStreamReceiverInterface> CreateReceiver(
  31. uint32_t ssrc,
  32. RtpPacketSinkInterface* sink) override;
  33. // Thread-safe wrappers for the corresponding RtpDemuxer methods.
  34. bool AddSink(uint32_t ssrc, RtpPacketSinkInterface* sink) override;
  35. size_t RemoveSink(const RtpPacketSinkInterface* sink) override;
  36. // TODO(nisse): Not yet responsible for parsing.
  37. bool OnRtpPacket(const RtpPacketReceived& packet);
  38. private:
  39. class Receiver : public RtpStreamReceiverInterface {
  40. public:
  41. Receiver(RtpStreamReceiverController* controller,
  42. uint32_t ssrc,
  43. RtpPacketSinkInterface* sink);
  44. ~Receiver() override;
  45. private:
  46. RtpStreamReceiverController* const controller_;
  47. RtpPacketSinkInterface* const sink_;
  48. };
  49. // TODO(nisse): Move to a TaskQueue for synchronization. When used
  50. // by Call, we expect construction and all methods but OnRtpPacket
  51. // to be called on the same thread, and OnRtpPacket to be called
  52. // by a single, but possibly distinct, thread. But applications not
  53. // using Call may have use threads differently.
  54. rtc::RecursiveCriticalSection lock_;
  55. RtpDemuxer demuxer_ RTC_GUARDED_BY(&lock_);
  56. };
  57. } // namespace webrtc
  58. #endif // CALL_RTP_STREAM_RECEIVER_CONTROLLER_H_