OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 // This file contains interfaces for RtpReceivers | 11 // This file contains interfaces for RtpReceivers |
12 // http://w3c.github.io/webrtc-pc/#rtcrtpreceiver-interface | 12 // http://w3c.github.io/webrtc-pc/#rtcrtpreceiver-interface |
13 | 13 |
14 #ifndef WEBRTC_API_RTPRECEIVERINTERFACE_H_ | 14 #ifndef WEBRTC_API_RTPRECEIVERINTERFACE_H_ |
15 #define WEBRTC_API_RTPRECEIVERINTERFACE_H_ | 15 #define WEBRTC_API_RTPRECEIVERINTERFACE_H_ |
16 | 16 |
17 #include <string> | 17 #include <string> |
18 | 18 |
19 #include "webrtc/api/mediastreaminterface.h" | 19 #include "webrtc/api/mediastreaminterface.h" |
20 #include "webrtc/api/proxy.h" | 20 #include "webrtc/api/proxy.h" |
| 21 #include "webrtc/api/rtpparameters.h" |
21 #include "webrtc/base/refcount.h" | 22 #include "webrtc/base/refcount.h" |
22 #include "webrtc/base/scoped_ref_ptr.h" | 23 #include "webrtc/base/scoped_ref_ptr.h" |
23 #include "webrtc/pc/mediasession.h" | 24 #include "webrtc/pc/mediasession.h" |
24 | 25 |
25 namespace webrtc { | 26 namespace webrtc { |
26 | 27 |
27 class RtpReceiverObserverInterface { | 28 class RtpReceiverObserverInterface { |
28 public: | 29 public: |
| 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. |
29 virtual void OnFirstPacketReceived(cricket::MediaType media_type) = 0; | 36 virtual void OnFirstPacketReceived(cricket::MediaType media_type) = 0; |
30 | 37 |
31 protected: | 38 protected: |
32 virtual ~RtpReceiverObserverInterface() {} | 39 virtual ~RtpReceiverObserverInterface() {} |
33 }; | 40 }; |
34 | 41 |
35 class RtpReceiverInterface : public rtc::RefCountInterface { | 42 class RtpReceiverInterface : public rtc::RefCountInterface { |
36 public: | 43 public: |
37 virtual rtc::scoped_refptr<MediaStreamTrackInterface> track() const = 0; | 44 virtual rtc::scoped_refptr<MediaStreamTrackInterface> track() const = 0; |
38 | 45 |
| 46 // Audio or video receiver? |
| 47 virtual cricket::MediaType media_type() const = 0; |
| 48 |
39 // Not to be confused with "mid", this is a field we can temporarily use | 49 // Not to be confused with "mid", this is a field we can temporarily use |
40 // to uniquely identify a receiver until we implement Unified Plan SDP. | 50 // to uniquely identify a receiver until we implement Unified Plan SDP. |
41 virtual std::string id() const = 0; | 51 virtual std::string id() const = 0; |
42 | 52 |
43 // The WebRTC specification only defines RTCRtpParameters in terms of senders, | 53 // The WebRTC specification only defines RTCRtpParameters in terms of senders, |
44 // but this API also applies them to receivers, similar to ORTC: | 54 // but this API also applies them to receivers, similar to ORTC: |
45 // http://ortc.org/wp-content/uploads/2016/03/ortc.html#rtcrtpparameters*. | 55 // http://ortc.org/wp-content/uploads/2016/03/ortc.html#rtcrtpparameters*. |
46 virtual RtpParameters GetParameters() const = 0; | 56 virtual RtpParameters GetParameters() const = 0; |
47 virtual bool SetParameters(const RtpParameters& parameters) = 0; | 57 virtual bool SetParameters(const RtpParameters& parameters) = 0; |
48 | 58 |
| 59 // Does not take ownership of observer. |
| 60 // Must call SetObserver(nullptr) before the observer is destroyed. |
49 virtual void SetObserver(RtpReceiverObserverInterface* observer) = 0; | 61 virtual void SetObserver(RtpReceiverObserverInterface* observer) = 0; |
50 | 62 |
51 virtual cricket::MediaType media_type() = 0; | |
52 | |
53 protected: | 63 protected: |
54 virtual ~RtpReceiverInterface() {} | 64 virtual ~RtpReceiverInterface() {} |
55 }; | 65 }; |
56 | 66 |
57 // Define proxy for RtpReceiverInterface. | 67 // Define proxy for RtpReceiverInterface. |
58 BEGIN_SIGNALING_PROXY_MAP(RtpReceiver) | 68 BEGIN_SIGNALING_PROXY_MAP(RtpReceiver) |
59 PROXY_CONSTMETHOD0(rtc::scoped_refptr<MediaStreamTrackInterface>, track) | 69 PROXY_CONSTMETHOD0(rtc::scoped_refptr<MediaStreamTrackInterface>, track) |
| 70 PROXY_CONSTMETHOD0(cricket::MediaType, media_type) |
60 PROXY_CONSTMETHOD0(std::string, id) | 71 PROXY_CONSTMETHOD0(std::string, id) |
61 PROXY_CONSTMETHOD0(RtpParameters, GetParameters); | 72 PROXY_CONSTMETHOD0(RtpParameters, GetParameters); |
62 PROXY_METHOD1(bool, SetParameters, const RtpParameters&) | 73 PROXY_METHOD1(bool, SetParameters, const RtpParameters&) |
63 PROXY_METHOD1(void, SetObserver, RtpReceiverObserverInterface*); | 74 PROXY_METHOD1(void, SetObserver, RtpReceiverObserverInterface*); |
64 PROXY_METHOD0(cricket::MediaType, media_type); | |
65 END_SIGNALING_PROXY() | 75 END_SIGNALING_PROXY() |
66 | 76 |
67 } // namespace webrtc | 77 } // namespace webrtc |
68 | 78 |
69 #endif // WEBRTC_API_RTPRECEIVERINTERFACE_H_ | 79 #endif // WEBRTC_API_RTPRECEIVERINTERFACE_H_ |
OLD | NEW |