deadbeef | 6979b02 | 2015-09-24 23:47:53 | [diff] [blame] | 1 | /* |
kjellander | b24317b | 2016-02-10 15:54:43 | [diff] [blame] | 2 | * Copyright 2015 The WebRTC project authors. All Rights Reserved. |
deadbeef | 6979b02 | 2015-09-24 23:47:53 | [diff] [blame] | 3 | * |
kjellander | b24317b | 2016-02-10 15:54:43 | [diff] [blame] | 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. |
deadbeef | 6979b02 | 2015-09-24 23:47:53 | [diff] [blame] | 9 | */ |
| 10 | |
deadbeef | 70ab1a1 | 2015-09-28 23:53:55 | [diff] [blame] | 11 | // This file contains interfaces for RtpReceivers |
| 12 | // http://w3c.github.io/webrtc-pc/#rtcrtpreceiver-interface |
| 13 | |
Henrik Kjellander | 15583c1 | 2016-02-10 09:53:12 | [diff] [blame] | 14 | #ifndef WEBRTC_API_RTPRECEIVERINTERFACE_H_ |
| 15 | #define WEBRTC_API_RTPRECEIVERINTERFACE_H_ |
deadbeef | 70ab1a1 | 2015-09-28 23:53:55 | [diff] [blame] | 16 | |
| 17 | #include <string> |
| 18 | |
Henrik Kjellander | 15583c1 | 2016-02-10 09:53:12 | [diff] [blame] | 19 | #include "webrtc/api/mediastreaminterface.h" |
| 20 | #include "webrtc/api/proxy.h" |
Taylor Brandstetter | ba29c6a | 2016-06-27 23:30:35 | [diff] [blame] | 21 | #include "webrtc/api/rtpparameters.h" |
deadbeef | 70ab1a1 | 2015-09-28 23:53:55 | [diff] [blame] | 22 | #include "webrtc/base/refcount.h" |
| 23 | #include "webrtc/base/scoped_ref_ptr.h" |
zhihuang | 184a3fd | 2016-06-14 18:47:14 | [diff] [blame] | 24 | #include "webrtc/pc/mediasession.h" |
deadbeef | 70ab1a1 | 2015-09-28 23:53:55 | [diff] [blame] | 25 | |
| 26 | namespace webrtc { |
| 27 | |
zhihuang | 184a3fd | 2016-06-14 18:47:14 | [diff] [blame] | 28 | class RtpReceiverObserverInterface { |
| 29 | public: |
Taylor Brandstetter | ba29c6a | 2016-06-27 23:30:35 | [diff] [blame] | 30 | // Note: Currently if there are multiple RtpReceivers of the same media type, |
| 31 | // they will all call OnFirstPacketReceived at once. |
| 32 | // |
| 33 | // In the future, it's likely that an RtpReceiver will only call |
| 34 | // OnFirstPacketReceived when a packet is received specifically for its |
| 35 | // SSRC/mid. |
zhihuang | 184a3fd | 2016-06-14 18:47:14 | [diff] [blame] | 36 | virtual void OnFirstPacketReceived(cricket::MediaType media_type) = 0; |
| 37 | |
| 38 | protected: |
| 39 | virtual ~RtpReceiverObserverInterface() {} |
| 40 | }; |
| 41 | |
deadbeef | 70ab1a1 | 2015-09-28 23:53:55 | [diff] [blame] | 42 | class RtpReceiverInterface : public rtc::RefCountInterface { |
| 43 | public: |
| 44 | virtual rtc::scoped_refptr<MediaStreamTrackInterface> track() const = 0; |
| 45 | |
Taylor Brandstetter | ba29c6a | 2016-06-27 23:30:35 | [diff] [blame] | 46 | // Audio or video receiver? |
| 47 | virtual cricket::MediaType media_type() const = 0; |
| 48 | |
deadbeef | 70ab1a1 | 2015-09-28 23:53:55 | [diff] [blame] | 49 | // Not to be confused with "mid", this is a field we can temporarily use |
| 50 | // to uniquely identify a receiver until we implement Unified Plan SDP. |
| 51 | virtual std::string id() const = 0; |
| 52 | |
Taylor Brandstetter | db0cd9e | 2016-05-16 18:40:30 | [diff] [blame] | 53 | // The WebRTC specification only defines RTCRtpParameters in terms of senders, |
| 54 | // but this API also applies them to receivers, similar to ORTC: |
| 55 | // http://ortc.org/wp-content/uploads/2016/03/ortc.html#rtcrtpparameters*. |
| 56 | virtual RtpParameters GetParameters() const = 0; |
| 57 | virtual bool SetParameters(const RtpParameters& parameters) = 0; |
| 58 | |
Taylor Brandstetter | ba29c6a | 2016-06-27 23:30:35 | [diff] [blame] | 59 | // Does not take ownership of observer. |
| 60 | // Must call SetObserver(nullptr) before the observer is destroyed. |
zhihuang | 184a3fd | 2016-06-14 18:47:14 | [diff] [blame] | 61 | virtual void SetObserver(RtpReceiverObserverInterface* observer) = 0; |
| 62 | |
deadbeef | 70ab1a1 | 2015-09-28 23:53:55 | [diff] [blame] | 63 | protected: |
| 64 | virtual ~RtpReceiverInterface() {} |
| 65 | }; |
| 66 | |
| 67 | // Define proxy for RtpReceiverInterface. |
nisse | 72c8d2b | 2016-04-15 10:49:07 | [diff] [blame] | 68 | BEGIN_SIGNALING_PROXY_MAP(RtpReceiver) |
deadbeef | 70ab1a1 | 2015-09-28 23:53:55 | [diff] [blame] | 69 | PROXY_CONSTMETHOD0(rtc::scoped_refptr<MediaStreamTrackInterface>, track) |
Taylor Brandstetter | ba29c6a | 2016-06-27 23:30:35 | [diff] [blame] | 70 | PROXY_CONSTMETHOD0(cricket::MediaType, media_type) |
deadbeef | 70ab1a1 | 2015-09-28 23:53:55 | [diff] [blame] | 71 | PROXY_CONSTMETHOD0(std::string, id) |
Taylor Brandstetter | db0cd9e | 2016-05-16 18:40:30 | [diff] [blame] | 72 | PROXY_CONSTMETHOD0(RtpParameters, GetParameters); |
| 73 | PROXY_METHOD1(bool, SetParameters, const RtpParameters&) |
zhihuang | 184a3fd | 2016-06-14 18:47:14 | [diff] [blame] | 74 | PROXY_METHOD1(void, SetObserver, RtpReceiverObserverInterface*); |
nisse | 72c8d2b | 2016-04-15 10:49:07 | [diff] [blame] | 75 | END_SIGNALING_PROXY() |
deadbeef | 70ab1a1 | 2015-09-28 23:53:55 | [diff] [blame] | 76 | |
| 77 | } // namespace webrtc |
| 78 | |
Henrik Kjellander | 15583c1 | 2016-02-10 09:53:12 | [diff] [blame] | 79 | #endif // WEBRTC_API_RTPRECEIVERINTERFACE_H_ |