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> | |
the sun
2017/04/05 14:58:29
Why the need to add this?
Zhi Huang
2017/04/06 03:09:49
Oh, I missed this when removing the unique_ptr.
| |
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 enum class RtpSourceType { | |
hbos
2017/04/05 15:20:16
nit: With enum class you have to qualify the name
Zhi Huang
2017/04/06 03:09:49
Done.
| |
31 RTP_SSRC_SOURCE, | |
32 RTP_CSRC_SOURCE, | |
33 }; | |
34 | |
35 struct RtpSource { | |
hbos
2017/04/05 11:15:41
Considering the getters/setters and private member
the sun
2017/04/05 14:58:29
+1, make it a class!
Btw, thanks for not adding a
Zhi Huang
2017/04/06 03:09:49
Done.
| |
36 public: | |
37 RtpSource() = delete; | |
38 RtpSource(int64_t timestamp, uint32_t source_id, RtpSourceType source_type) | |
39 : timestamp_(timestamp), | |
40 source_id_(source_id), | |
41 source_type_(source_type) {} | |
42 | |
43 int64_t timestamp() const { return timestamp_; } | |
danilchap
2017/04/05 16:24:21
can you add units, is it timestamp_ms?
Zhi Huang
2017/04/06 03:09:49
Done.
| |
44 void update_timestamp(int64_t timestamp) { | |
45 RTC_DCHECK_LE(timestamp_, timestamp); | |
46 timestamp_ = timestamp; | |
47 } | |
48 | |
49 // The identifier of the source can be the CSRC or the SSRC. | |
50 uint32_t source_id() const { return source_id_; } | |
51 | |
52 // The source can be either a contributing source or a synchronization source. | |
53 RtpSourceType source_type() const { return source_type_; } | |
54 | |
55 // This isn't implemented yet and will always return an empty Optional. | |
56 // TODO(zhihuang): Implement this to return real audio level. | |
57 rtc::Optional<int8_t> audio_level() const { return rtc::Optional<int8_t>(); } | |
58 | |
59 private: | |
60 int64_t timestamp_; | |
61 uint32_t source_id_; | |
62 RtpSourceType source_type_; | |
63 }; | |
64 | |
28 class RtpReceiverObserverInterface { | 65 class RtpReceiverObserverInterface { |
29 public: | 66 public: |
30 // Note: Currently if there are multiple RtpReceivers of the same media type, | 67 // Note: Currently if there are multiple RtpReceivers of the same media type, |
31 // they will all call OnFirstPacketReceived at once. | 68 // they will all call OnFirstPacketReceived at once. |
32 // | 69 // |
33 // In the future, it's likely that an RtpReceiver will only call | 70 // In the future, it's likely that an RtpReceiver will only call |
34 // OnFirstPacketReceived when a packet is received specifically for its | 71 // OnFirstPacketReceived when a packet is received specifically for its |
35 // SSRC/mid. | 72 // SSRC/mid. |
36 virtual void OnFirstPacketReceived(cricket::MediaType media_type) = 0; | 73 virtual void OnFirstPacketReceived(cricket::MediaType media_type) = 0; |
37 | 74 |
(...skipping 16 matching lines...) Expand all Loading... | |
54 // but this API also applies them to receivers, similar to ORTC: | 91 // but this API also applies them to receivers, similar to ORTC: |
55 // http://ortc.org/wp-content/uploads/2016/03/ortc.html#rtcrtpparameters*. | 92 // http://ortc.org/wp-content/uploads/2016/03/ortc.html#rtcrtpparameters*. |
56 virtual RtpParameters GetParameters() const = 0; | 93 virtual RtpParameters GetParameters() const = 0; |
57 // Currently, doesn't support changing any parameters, but may in the future. | 94 // Currently, doesn't support changing any parameters, but may in the future. |
58 virtual bool SetParameters(const RtpParameters& parameters) = 0; | 95 virtual bool SetParameters(const RtpParameters& parameters) = 0; |
59 | 96 |
60 // Does not take ownership of observer. | 97 // Does not take ownership of observer. |
61 // Must call SetObserver(nullptr) before the observer is destroyed. | 98 // Must call SetObserver(nullptr) before the observer is destroyed. |
62 virtual void SetObserver(RtpReceiverObserverInterface* observer) = 0; | 99 virtual void SetObserver(RtpReceiverObserverInterface* observer) = 0; |
63 | 100 |
101 // TODO(zhihuang): Remove the default implementation once the subclasses | |
102 // implement this. Currently, the only relevant subclass is the | |
103 // content::FakeRtpReceiver in Chromium. | |
104 virtual std::vector<RtpSource> GetSources() { | |
the sun
2017/04/05 14:58:29
Make this method const:
virtual std::vector<RtpSou
Zhi Huang
2017/04/06 03:09:49
Done.
| |
105 return std::vector<RtpSource>(); | |
106 } | |
107 | |
64 protected: | 108 protected: |
65 virtual ~RtpReceiverInterface() {} | 109 virtual ~RtpReceiverInterface() {} |
66 }; | 110 }; |
67 | 111 |
68 // Define proxy for RtpReceiverInterface. | 112 // Define proxy for RtpReceiverInterface. |
69 // TODO(deadbeef): Move this to .cc file and out of api/. What threads methods | 113 // TODO(deadbeef): Move this to .cc file and out of api/. What threads methods |
70 // are called on is an implementation detail. | 114 // are called on is an implementation detail. |
71 BEGIN_SIGNALING_PROXY_MAP(RtpReceiver) | 115 BEGIN_SIGNALING_PROXY_MAP(RtpReceiver) |
72 PROXY_SIGNALING_THREAD_DESTRUCTOR() | 116 PROXY_SIGNALING_THREAD_DESTRUCTOR() |
73 PROXY_CONSTMETHOD0(rtc::scoped_refptr<MediaStreamTrackInterface>, track) | 117 PROXY_CONSTMETHOD0(rtc::scoped_refptr<MediaStreamTrackInterface>, track) |
74 PROXY_CONSTMETHOD0(cricket::MediaType, media_type) | 118 PROXY_CONSTMETHOD0(cricket::MediaType, media_type) |
75 PROXY_CONSTMETHOD0(std::string, id) | 119 PROXY_CONSTMETHOD0(std::string, id) |
76 PROXY_CONSTMETHOD0(RtpParameters, GetParameters); | 120 PROXY_CONSTMETHOD0(RtpParameters, GetParameters); |
77 PROXY_METHOD1(bool, SetParameters, const RtpParameters&) | 121 PROXY_METHOD1(bool, SetParameters, const RtpParameters&) |
78 PROXY_METHOD1(void, SetObserver, RtpReceiverObserverInterface*); | 122 PROXY_METHOD1(void, SetObserver, RtpReceiverObserverInterface*); |
79 END_PROXY_MAP() | 123 PROXY_METHOD0(std::vector<RtpSource>, GetSources); |
124 END_PROXY_MAP() | |
80 | 125 |
81 } // namespace webrtc | 126 } // namespace webrtc |
82 | 127 |
83 #endif // WEBRTC_API_RTPRECEIVERINTERFACE_H_ | 128 #endif // WEBRTC_API_RTPRECEIVERINTERFACE_H_ |
OLD | NEW |