blob: b078da985c9d18a06886220d249f8a9094fc5abb [file] [log] [blame]
deadbeefe814a0d2017-02-25 18:15:09 -08001/*
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 Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef ORTC_ORTCRTPSENDERADAPTER_H_
12#define ORTC_ORTCRTPSENDERADAPTER_H_
deadbeefe814a0d2017-02-25 18:15:09 -080013
14#include <memory>
15
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020016#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 Titove41c4332018-07-25 15:04:28 +020022#include "rtc_base/third_party/sigslot/sigslot.h"
deadbeefe814a0d2017-02-25 18:15:09 -080023
24namespace 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.
33class 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 Bonadei92ea95e2017-09-15 06:47:31 +020079#endif // ORTC_ORTCRTPSENDERADAPTER_H_