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