deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef ORTC_ORTCRTPSENDERADAPTER_H_ |
| 12 | #define ORTC_ORTCRTPSENDERADAPTER_H_ |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 13 | |
| 14 | #include <memory> |
| 15 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 16 | #include "api/ortc/ortcrtpsenderinterface.h" |
| 17 | #include "api/rtcerror.h" |
| 18 | #include "api/rtpparameters.h" |
| 19 | #include "ortc/rtptransportcontrolleradapter.h" |
| 20 | #include "pc/rtpsender.h" |
| 21 | #include "rtc_base/constructormagic.h" |
Artem Titov | e41c433 | 2018-07-25 15:04:28 +0200 | [diff] [blame] | 22 | #include "rtc_base/third_party/sigslot/sigslot.h" |
deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame] | 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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 79 | #endif // ORTC_ORTCRTPSENDERADAPTER_H_ |