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_ORTCRTPSENDERADAPTER_H_ |
| 12 #define WEBRTC_ORTC_ORTCRTPSENDERADAPTER_H_ |
| 13 |
| 14 #include <memory> |
| 15 |
| 16 #include "webrtc/api/ortc/ortcrtpsenderinterface.h" |
| 17 #include "webrtc/api/rtcerror.h" |
| 18 #include "webrtc/api/rtpparameters.h" |
| 19 #include "webrtc/base/constructormagic.h" |
| 20 #include "webrtc/base/sigslot.h" |
| 21 #include "webrtc/ortc/rtptransportcontrolleradapter.h" |
| 22 #include "webrtc/pc/rtpsender.h" |
| 23 |
| 24 namespace webrtc { |
| 25 |
| 26 // Implementation of OrtcRtpSenderInterface that works with RtpTransportAdapter, |
| 27 // and wraps a VideoRtpSender/AudioRtpSender that's normally used with the |
| 28 // PeerConnection. |
| 29 // |
| 30 // TODO(deadbeef): When BaseChannel is split apart into separate |
| 31 // "RtpSender"/"RtpTransceiver"/"RtpSender"/"RtpReceiver" objects, this adapter |
| 32 // object can be removed. |
| 33 class OrtcRtpSenderAdapter : public OrtcRtpSenderInterface { |
| 34 public: |
| 35 // Wraps |wrapped_sender| in a proxy that will safely call methods on the |
| 36 // correct thread. |
| 37 static std::unique_ptr<OrtcRtpSenderInterface> CreateProxy( |
| 38 std::unique_ptr<OrtcRtpSenderAdapter> wrapped_sender); |
| 39 |
| 40 // Should only be called by RtpTransportControllerAdapter. |
| 41 OrtcRtpSenderAdapter(cricket::MediaType kind, |
| 42 RtpTransportInterface* transport, |
| 43 RtpTransportControllerAdapter* rtp_transport_controller); |
| 44 ~OrtcRtpSenderAdapter() override; |
| 45 |
| 46 // OrtcRtpSenderInterface implementation. |
| 47 RTCError SetTrack(MediaStreamTrackInterface* track) override; |
| 48 rtc::scoped_refptr<MediaStreamTrackInterface> GetTrack() const override; |
| 49 |
| 50 RTCError SetTransport(RtpTransportInterface* transport) override; |
| 51 RtpTransportInterface* GetTransport() const override; |
| 52 |
| 53 RTCError Send(const RtpParameters& parameters) override; |
| 54 RtpParameters GetParameters() const override; |
| 55 |
| 56 cricket::MediaType GetKind() const override; |
| 57 |
| 58 // Used so that the RtpTransportControllerAdapter knows when it can |
| 59 // deallocate resources allocated for this object. |
| 60 sigslot::signal0<> SignalDestroyed; |
| 61 |
| 62 private: |
| 63 void CreateInternalSender(); |
| 64 |
| 65 cricket::MediaType kind_; |
| 66 RtpTransportInterface* transport_; |
| 67 RtpTransportControllerAdapter* rtp_transport_controller_; |
| 68 // Scoped refptr due to ref-counted interface, but we should be the only |
| 69 // reference holder. |
| 70 rtc::scoped_refptr<RtpSenderInternal> internal_sender_; |
| 71 rtc::scoped_refptr<MediaStreamTrackInterface> track_; |
| 72 RtpParameters last_applied_parameters_; |
| 73 |
| 74 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(OrtcRtpSenderAdapter); |
| 75 }; |
| 76 |
| 77 } // namespace webrtc |
| 78 |
| 79 #endif // WEBRTC_ORTC_ORTCRTPSENDERADAPTER_H_ |
OLD | NEW |