rtp_receiver.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * Copyright 2015 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. // This file contains classes that implement RtpReceiverInterface.
  11. // An RtpReceiver associates a MediaStreamTrackInterface with an underlying
  12. // transport (provided by cricket::VoiceChannel/cricket::VideoChannel)
  13. #ifndef PC_RTP_RECEIVER_H_
  14. #define PC_RTP_RECEIVER_H_
  15. #include <stdint.h>
  16. #include <string>
  17. #include <vector>
  18. #include "absl/types/optional.h"
  19. #include "api/crypto/frame_decryptor_interface.h"
  20. #include "api/media_stream_interface.h"
  21. #include "api/media_types.h"
  22. #include "api/rtp_parameters.h"
  23. #include "api/rtp_receiver_interface.h"
  24. #include "api/scoped_refptr.h"
  25. #include "api/video/video_frame.h"
  26. #include "api/video/video_sink_interface.h"
  27. #include "api/video/video_source_interface.h"
  28. #include "media/base/media_channel.h"
  29. #include "media/base/video_broadcaster.h"
  30. #include "pc/video_track_source.h"
  31. #include "rtc_base/ref_counted_object.h"
  32. #include "rtc_base/thread.h"
  33. namespace webrtc {
  34. // Internal class used by PeerConnection.
  35. class RtpReceiverInternal : public RtpReceiverInterface {
  36. public:
  37. virtual void Stop() = 0;
  38. // Sets the underlying MediaEngine channel associated with this RtpSender.
  39. // A VoiceMediaChannel should be used for audio RtpSenders and
  40. // a VideoMediaChannel should be used for video RtpSenders.
  41. // Must call SetMediaChannel(nullptr) before the media channel is destroyed.
  42. virtual void SetMediaChannel(cricket::MediaChannel* media_channel) = 0;
  43. // Configures the RtpReceiver with the underlying media channel, with the
  44. // given SSRC as the stream identifier.
  45. virtual void SetupMediaChannel(uint32_t ssrc) = 0;
  46. // Configures the RtpReceiver with the underlying media channel to receive an
  47. // unsignaled receive stream.
  48. virtual void SetupUnsignaledMediaChannel() = 0;
  49. virtual void set_transport(
  50. rtc::scoped_refptr<DtlsTransportInterface> dtls_transport) = 0;
  51. // This SSRC is used as an identifier for the receiver between the API layer
  52. // and the WebRtcVideoEngine, WebRtcVoiceEngine layer.
  53. virtual uint32_t ssrc() const = 0;
  54. // Call this to notify the RtpReceiver when the first packet has been received
  55. // on the corresponding channel.
  56. virtual void NotifyFirstPacketReceived() = 0;
  57. // Set the associated remote media streams for this receiver. The remote track
  58. // will be removed from any streams that are no longer present and added to
  59. // any new streams.
  60. virtual void set_stream_ids(std::vector<std::string> stream_ids) = 0;
  61. // TODO(https://crbug.com/webrtc/9480): Remove SetStreams() in favor of
  62. // set_stream_ids() as soon as downstream projects are no longer dependent on
  63. // stream objects.
  64. virtual void SetStreams(
  65. const std::vector<rtc::scoped_refptr<MediaStreamInterface>>& streams) = 0;
  66. // Returns an ID that changes if the attached track changes, but
  67. // otherwise remains constant. Used to generate IDs for stats.
  68. // The special value zero means that no track is attached.
  69. virtual int AttachmentId() const = 0;
  70. protected:
  71. static int GenerateUniqueId();
  72. static std::vector<rtc::scoped_refptr<MediaStreamInterface>>
  73. CreateStreamsFromIds(std::vector<std::string> stream_ids);
  74. static void MaybeAttachFrameDecryptorToMediaChannel(
  75. const absl::optional<uint32_t>& ssrc,
  76. rtc::Thread* worker_thread,
  77. rtc::scoped_refptr<webrtc::FrameDecryptorInterface> frame_decryptor,
  78. cricket::MediaChannel* media_channel,
  79. bool stopped);
  80. };
  81. } // namespace webrtc
  82. #endif // PC_RTP_RECEIVER_H_