Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(150)

Side by Side Diff: webrtc/api/rtpreceiverinterface.h

Issue 2770233003: Implemented the GetSources() in native code. (Closed)
Patch Set: Add a direct dependency to the webrtc/voice_engine/BUILD.gn Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include <vector>
18 19
19 #include "webrtc/api/mediatypes.h" 20 #include "webrtc/api/mediatypes.h"
20 #include "webrtc/api/mediastreaminterface.h" 21 #include "webrtc/api/mediastreaminterface.h"
21 #include "webrtc/api/proxy.h" 22 #include "webrtc/api/proxy.h"
22 #include "webrtc/api/rtpparameters.h" 23 #include "webrtc/api/rtpparameters.h"
23 #include "webrtc/base/refcount.h" 24 #include "webrtc/base/refcount.h"
24 #include "webrtc/base/scoped_ref_ptr.h" 25 #include "webrtc/base/scoped_ref_ptr.h"
25 26
26 namespace webrtc { 27 namespace webrtc {
27 28
29 enum class RtpSourceType {
30 SSRC,
31 CSRC,
32 };
33
34 class RtpSource {
35 public:
36 RtpSource() = delete;
37 RtpSource(int64_t timestamp_ms, uint32_t source_id, RtpSourceType source_type)
38 : timestamp_ms_(timestamp_ms),
39 source_id_(source_id),
40 source_type_(source_type) {}
41
42 int64_t timestamp_ms() const { return timestamp_ms_; }
43 void update_timestamp_ms(int64_t timestamp_ms) {
44 RTC_DCHECK_LE(timestamp_ms_, timestamp_ms);
45 timestamp_ms_ = timestamp_ms;
46 }
47
48 // The identifier of the source can be the CSRC or the SSRC.
49 uint32_t source_id() const { return source_id_; }
50
51 // The source can be either a contributing source or a synchronization source.
52 RtpSourceType source_type() const { return source_type_; }
53
54 // This isn't implemented yet and will always return an empty Optional.
55 // TODO(zhihuang): Implement this to return real audio level.
56 rtc::Optional<int8_t> audio_level() const { return rtc::Optional<int8_t>(); }
57
58 private:
59 int64_t timestamp_ms_;
60 uint32_t source_id_;
61 RtpSourceType source_type_;
62 };
63
28 class RtpReceiverObserverInterface { 64 class RtpReceiverObserverInterface {
29 public: 65 public:
30 // Note: Currently if there are multiple RtpReceivers of the same media type, 66 // Note: Currently if there are multiple RtpReceivers of the same media type,
31 // they will all call OnFirstPacketReceived at once. 67 // they will all call OnFirstPacketReceived at once.
32 // 68 //
33 // In the future, it's likely that an RtpReceiver will only call 69 // In the future, it's likely that an RtpReceiver will only call
34 // OnFirstPacketReceived when a packet is received specifically for its 70 // OnFirstPacketReceived when a packet is received specifically for its
35 // SSRC/mid. 71 // SSRC/mid.
36 virtual void OnFirstPacketReceived(cricket::MediaType media_type) = 0; 72 virtual void OnFirstPacketReceived(cricket::MediaType media_type) = 0;
37 73
(...skipping 16 matching lines...) Expand all
54 // but this API also applies them to receivers, similar to ORTC: 90 // but this API also applies them to receivers, similar to ORTC:
55 // http://ortc.org/wp-content/uploads/2016/03/ortc.html#rtcrtpparameters*. 91 // http://ortc.org/wp-content/uploads/2016/03/ortc.html#rtcrtpparameters*.
56 virtual RtpParameters GetParameters() const = 0; 92 virtual RtpParameters GetParameters() const = 0;
57 // Currently, doesn't support changing any parameters, but may in the future. 93 // Currently, doesn't support changing any parameters, but may in the future.
58 virtual bool SetParameters(const RtpParameters& parameters) = 0; 94 virtual bool SetParameters(const RtpParameters& parameters) = 0;
59 95
60 // Does not take ownership of observer. 96 // Does not take ownership of observer.
61 // Must call SetObserver(nullptr) before the observer is destroyed. 97 // Must call SetObserver(nullptr) before the observer is destroyed.
62 virtual void SetObserver(RtpReceiverObserverInterface* observer) = 0; 98 virtual void SetObserver(RtpReceiverObserverInterface* observer) = 0;
63 99
100 // TODO(zhihuang): Remove the default implementation once the subclasses
101 // implement this. Currently, the only relevant subclass is the
102 // content::FakeRtpReceiver in Chromium.
103 virtual std::vector<RtpSource> GetSources() const {
104 return std::vector<RtpSource>();
105 }
106
64 protected: 107 protected:
65 virtual ~RtpReceiverInterface() {} 108 virtual ~RtpReceiverInterface() {}
66 }; 109 };
67 110
68 // Define proxy for RtpReceiverInterface. 111 // Define proxy for RtpReceiverInterface.
69 // TODO(deadbeef): Move this to .cc file and out of api/. What threads methods 112 // TODO(deadbeef): Move this to .cc file and out of api/. What threads methods
70 // are called on is an implementation detail. 113 // are called on is an implementation detail.
71 BEGIN_SIGNALING_PROXY_MAP(RtpReceiver) 114 BEGIN_SIGNALING_PROXY_MAP(RtpReceiver)
72 PROXY_SIGNALING_THREAD_DESTRUCTOR() 115 PROXY_SIGNALING_THREAD_DESTRUCTOR()
73 PROXY_CONSTMETHOD0(rtc::scoped_refptr<MediaStreamTrackInterface>, track) 116 PROXY_CONSTMETHOD0(rtc::scoped_refptr<MediaStreamTrackInterface>, track)
74 PROXY_CONSTMETHOD0(cricket::MediaType, media_type) 117 PROXY_CONSTMETHOD0(cricket::MediaType, media_type)
75 PROXY_CONSTMETHOD0(std::string, id) 118 PROXY_CONSTMETHOD0(std::string, id)
76 PROXY_CONSTMETHOD0(RtpParameters, GetParameters); 119 PROXY_CONSTMETHOD0(RtpParameters, GetParameters);
77 PROXY_METHOD1(bool, SetParameters, const RtpParameters&) 120 PROXY_METHOD1(bool, SetParameters, const RtpParameters&)
78 PROXY_METHOD1(void, SetObserver, RtpReceiverObserverInterface*); 121 PROXY_METHOD1(void, SetObserver, RtpReceiverObserverInterface*);
79 END_PROXY_MAP() 122 PROXY_CONSTMETHOD0(std::vector<RtpSource>, GetSources);
123 END_PROXY_MAP()
80 124
81 } // namespace webrtc 125 } // namespace webrtc
82 126
83 #endif // WEBRTC_API_RTPRECEIVERINTERFACE_H_ 127 #endif // WEBRTC_API_RTPRECEIVERINTERFACE_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/api/test/mock_rtpreceiver.h » ('j') | webrtc/modules/rtp_rtcp/source/rtp_receiver_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698