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_RTPRECEIVERSHIM_H_ |
| 12 #define WEBRTC_ORTC_RTPRECEIVERSHIM_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/rtptransportcontrollershim.h" |
| 22 #include "webrtc/ortc/rtptransportshim.h" |
| 23 #include "webrtc/pc/rtpreceiver.h" |
| 24 |
| 25 namespace webrtc { |
| 26 |
| 27 // Implementation of OrtcRtpReceiverInterface that works with RtpTransportShim, |
| 28 // and wraps a VideoRtpReceiver/AudioRtpReceiver that's normally used with the |
| 29 // PeerConnection. |
| 30 // |
| 31 // TODO(deadbeef): When BaseChannel is split apart into separate |
| 32 // "RtpReceiver"/"RtpTransceiver"/"RtpReceiver"/"RtpReceiver" objects, this shim |
| 33 // object can be removed. |
| 34 class RtpReceiverShim : public OrtcRtpReceiverInterface { |
| 35 public: |
| 36 // Doesn't take ownership of |transport| or |rtp_transport_controller|. |
| 37 // |
| 38 // "Create" method is used (as opposed to just a constructor) because |
| 39 // applying the parameters may fail. |
| 40 // |
| 41 // |worker_thread| can't be null, and is needed for the video track |
| 42 // implementation. |
| 43 static RTCErrorOr<std::unique_ptr<OrtcRtpReceiverInterface>> CreateProxied( |
| 44 cricket::MediaType kind, |
| 45 RtpTransportShim* transport); |
| 46 ~RtpReceiverShim() override; |
| 47 |
| 48 // OrtcRtpReceiverInterface implementation. |
| 49 rtc::scoped_refptr<MediaStreamTrackInterface> GetTrack() const override; |
| 50 |
| 51 RTCError SetTransport(RtpTransportInterface* transport) override; |
| 52 RtpTransportInterface* GetTransport() const override; |
| 53 |
| 54 RTCError Receive(const RtpParameters& parameters) override; |
| 55 RtpParameters GetParameters() const override; |
| 56 |
| 57 cricket::MediaType GetKind() const override; |
| 58 |
| 59 private: |
| 60 // Methods called internally be Create factory method. |
| 61 RtpReceiverShim(cricket::MediaType kind, |
| 62 RtpTransportShim* transport, |
| 63 RtpTransportControllerShim* rtp_transport_controller); |
| 64 void MaybeRecreateInternalReceiver(); |
| 65 |
| 66 cricket::MediaType kind_; |
| 67 RtpTransportShim* transport_; |
| 68 RtpTransportControllerShim* 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(RtpReceiverShim); |
| 75 }; |
| 76 |
| 77 } // namespace webrtc |
| 78 |
| 79 #endif // WEBRTC_ORTC_RTPRECEIVERSHIM_H_ |
OLD | NEW |