OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 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 #ifndef WEBRTC_ORTC_ORTCRTPRECEIVERADAPTER_H_ |
| 12 #define WEBRTC_ORTC_ORTCRTPRECEIVERADAPTER_H_ |
| 13 |
| 14 #include <memory> |
| 15 |
| 16 #include "webrtc/api/ortc/ortcrtpreceiverinterface.h" |
| 17 #include "webrtc/api/rtcerror.h" |
| 18 #include "webrtc/api/rtpparameters.h" |
| 19 #include "webrtc/base/constructormagic.h" |
| 20 #include "webrtc/base/thread.h" |
| 21 #include "webrtc/ortc/rtptransportcontrolleradapter.h" |
| 22 #include "webrtc/pc/rtpreceiver.h" |
| 23 |
| 24 namespace webrtc { |
| 25 |
| 26 // Implementation of OrtcRtpReceiverInterface that works with |
| 27 // RtpTransportAdapter, and wraps a VideoRtpReceiver/AudioRtpReceiver that's |
| 28 // normally used with the PeerConnection. |
| 29 // |
| 30 // TODO(deadbeef): When BaseChannel is split apart into separate |
| 31 // "RtpReceiver"/"RtpTransceiver"/"RtpReceiver"/"RtpReceiver" objects, this |
| 32 // adapter object can be removed. |
| 33 class OrtcRtpReceiverAdapter : public OrtcRtpReceiverInterface { |
| 34 public: |
| 35 // Doesn't take ownership of |transport| or |rtp_transport_controller|. |
| 36 // |
| 37 // "Create" method is used (as opposed to just a constructor) because |
| 38 // applying the parameters may fail. |
| 39 // |
| 40 // |worker_thread| can't be null, and is needed for the video track |
| 41 // implementation. |
| 42 static RTCErrorOr<std::unique_ptr<OrtcRtpReceiverInterface>> CreateProxied( |
| 43 cricket::MediaType kind, |
| 44 RtpTransportInterface* transport); |
| 45 ~OrtcRtpReceiverAdapter() override; |
| 46 |
| 47 // OrtcRtpReceiverInterface implementation. |
| 48 rtc::scoped_refptr<MediaStreamTrackInterface> GetTrack() const override; |
| 49 |
| 50 RTCError SetTransport(RtpTransportInterface* transport) override; |
| 51 RtpTransportInterface* GetTransport() const override; |
| 52 |
| 53 RTCError Receive(const RtpParameters& parameters) override; |
| 54 RtpParameters GetParameters() const override; |
| 55 |
| 56 cricket::MediaType GetKind() const override; |
| 57 |
| 58 private: |
| 59 // Methods called internally be Create factory method. |
| 60 OrtcRtpReceiverAdapter( |
| 61 cricket::MediaType kind, |
| 62 RtpTransportInterface* transport, |
| 63 RtpTransportControllerAdapter* rtp_transport_controller); |
| 64 void MaybeRecreateInternalReceiver(); |
| 65 |
| 66 cricket::MediaType kind_; |
| 67 RtpTransportInterface* transport_; |
| 68 RtpTransportControllerAdapter* rtp_transport_controller_; |
| 69 // Scoped refptr due to ref-counted interface, but we should be the only |
| 70 // reference holder. |
| 71 rtc::scoped_refptr<RtpReceiverInternal> internal_receiver_; |
| 72 RtpParameters last_applied_parameters_; |
| 73 |
| 74 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(OrtcRtpReceiverAdapter); |
| 75 }; |
| 76 |
| 77 } // namespace webrtc |
| 78 |
| 79 #endif // WEBRTC_ORTC_ORTCRTPRECEIVERADAPTER_H_ |
OLD | NEW |