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 <memory> |
17 #include <string> | 18 #include <string> |
| 19 #include <vector> |
18 | 20 |
19 #include "webrtc/api/mediatypes.h" | 21 #include "webrtc/api/mediatypes.h" |
20 #include "webrtc/api/mediastreaminterface.h" | 22 #include "webrtc/api/mediastreaminterface.h" |
21 #include "webrtc/api/proxy.h" | 23 #include "webrtc/api/proxy.h" |
22 #include "webrtc/api/rtpparameters.h" | 24 #include "webrtc/api/rtpparameters.h" |
23 #include "webrtc/base/refcount.h" | 25 #include "webrtc/base/refcount.h" |
24 #include "webrtc/base/scoped_ref_ptr.h" | 26 #include "webrtc/base/scoped_ref_ptr.h" |
25 | 27 |
26 namespace webrtc { | 28 namespace webrtc { |
27 | 29 |
| 30 struct RtpContributingSource { |
| 31 public: |
| 32 RtpContributingSource() : timestamp_(0), ssrc_(0) {} |
| 33 |
| 34 int64_t timestamp() { return timestamp_; } |
| 35 void set_timestamp(int64_t timestamp) { timestamp_ = timestamp; } |
| 36 |
| 37 uint32_t source() { return csrc_ ? *csrc_ : ssrc_; } |
| 38 |
| 39 uint32_t ssrc() { return ssrc_; } |
| 40 void set_ssrc(uint32_t ssrc) { ssrc_ = ssrc; } |
| 41 void set_csrc(uint32_t csrc) { csrc_ = rtc::Optional<uint32_t>(csrc); } |
| 42 |
| 43 // This isn't implemented yet and will always return an empty Optional. |
| 44 // TODO(zhihuang): Implement this to return real audio level. |
| 45 rtc::Optional<int8_t> audio_level() { return audio_level_; } |
| 46 |
| 47 private: |
| 48 int64_t timestamp_; |
| 49 uint32_t ssrc_; |
| 50 rtc::Optional<uint32_t> csrc_; |
| 51 rtc::Optional<int8_t> audio_level_; |
| 52 }; |
| 53 |
28 class RtpReceiverObserverInterface { | 54 class RtpReceiverObserverInterface { |
29 public: | 55 public: |
30 // Note: Currently if there are multiple RtpReceivers of the same media type, | 56 // Note: Currently if there are multiple RtpReceivers of the same media type, |
31 // they will all call OnFirstPacketReceived at once. | 57 // they will all call OnFirstPacketReceived at once. |
32 // | 58 // |
33 // In the future, it's likely that an RtpReceiver will only call | 59 // In the future, it's likely that an RtpReceiver will only call |
34 // OnFirstPacketReceived when a packet is received specifically for its | 60 // OnFirstPacketReceived when a packet is received specifically for its |
35 // SSRC/mid. | 61 // SSRC/mid. |
36 virtual void OnFirstPacketReceived(cricket::MediaType media_type) = 0; | 62 virtual void OnFirstPacketReceived(cricket::MediaType media_type) = 0; |
37 | 63 |
(...skipping 16 matching lines...) Expand all Loading... |
54 // but this API also applies them to receivers, similar to ORTC: | 80 // but this API also applies them to receivers, similar to ORTC: |
55 // http://ortc.org/wp-content/uploads/2016/03/ortc.html#rtcrtpparameters*. | 81 // http://ortc.org/wp-content/uploads/2016/03/ortc.html#rtcrtpparameters*. |
56 virtual RtpParameters GetParameters() const = 0; | 82 virtual RtpParameters GetParameters() const = 0; |
57 // Currently, doesn't support changing any parameters, but may in the future. | 83 // Currently, doesn't support changing any parameters, but may in the future. |
58 virtual bool SetParameters(const RtpParameters& parameters) = 0; | 84 virtual bool SetParameters(const RtpParameters& parameters) = 0; |
59 | 85 |
60 // Does not take ownership of observer. | 86 // Does not take ownership of observer. |
61 // Must call SetObserver(nullptr) before the observer is destroyed. | 87 // Must call SetObserver(nullptr) before the observer is destroyed. |
62 virtual void SetObserver(RtpReceiverObserverInterface* observer) = 0; | 88 virtual void SetObserver(RtpReceiverObserverInterface* observer) = 0; |
63 | 89 |
| 90 // TODO(zhihuang): Remove the default implementation once the subclasses |
| 91 // implement this. Currently, the only relevant subclass is the |
| 92 // content::FakeRtpReceiver in Chromium. |
| 93 virtual std::vector<RtpContributingSource> GetContributingSources() { |
| 94 return std::vector<RtpContributingSource>(); |
| 95 } |
| 96 |
64 protected: | 97 protected: |
65 virtual ~RtpReceiverInterface() {} | 98 virtual ~RtpReceiverInterface() {} |
66 }; | 99 }; |
67 | 100 |
68 // Define proxy for RtpReceiverInterface. | 101 // Define proxy for RtpReceiverInterface. |
69 // TODO(deadbeef): Move this to .cc file and out of api/. What threads methods | 102 // TODO(deadbeef): Move this to .cc file and out of api/. What threads methods |
70 // are called on is an implementation detail. | 103 // are called on is an implementation detail. |
71 BEGIN_SIGNALING_PROXY_MAP(RtpReceiver) | 104 BEGIN_SIGNALING_PROXY_MAP(RtpReceiver) |
72 PROXY_SIGNALING_THREAD_DESTRUCTOR() | 105 PROXY_SIGNALING_THREAD_DESTRUCTOR() |
73 PROXY_CONSTMETHOD0(rtc::scoped_refptr<MediaStreamTrackInterface>, track) | 106 PROXY_CONSTMETHOD0(rtc::scoped_refptr<MediaStreamTrackInterface>, track) |
74 PROXY_CONSTMETHOD0(cricket::MediaType, media_type) | 107 PROXY_CONSTMETHOD0(cricket::MediaType, media_type) |
75 PROXY_CONSTMETHOD0(std::string, id) | 108 PROXY_CONSTMETHOD0(std::string, id) |
76 PROXY_CONSTMETHOD0(RtpParameters, GetParameters); | 109 PROXY_CONSTMETHOD0(RtpParameters, GetParameters); |
77 PROXY_METHOD1(bool, SetParameters, const RtpParameters&) | 110 PROXY_METHOD1(bool, SetParameters, const RtpParameters&) |
78 PROXY_METHOD1(void, SetObserver, RtpReceiverObserverInterface*); | 111 PROXY_METHOD1(void, SetObserver, RtpReceiverObserverInterface*); |
79 END_PROXY_MAP() | 112 PROXY_METHOD0(std::vector<RtpContributingSource>, GetContributingSources); |
| 113 END_PROXY_MAP() |
80 | 114 |
81 } // namespace webrtc | 115 } // namespace webrtc |
82 | 116 |
83 #endif // WEBRTC_API_RTPRECEIVERINTERFACE_H_ | 117 #endif // WEBRTC_API_RTPRECEIVERINTERFACE_H_ |
OLD | NEW |