mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 1 | /* |
mflodman@webrtc.org | f7b6078 | 2012-02-16 14:50:24 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
niklas.enbom@webrtc.org | ef62929 | 2012-10-31 14:35:11 +0000 | [diff] [blame] | 11 | #ifndef WEBRTC_VIDEO_ENGINE_VIE_REMB_H_ |
| 12 | #define WEBRTC_VIDEO_ENGINE_VIE_REMB_H_ |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 13 | |
| 14 | #include <list> |
mflodman@webrtc.org | 1b1cd78 | 2012-06-28 06:34:08 +0000 | [diff] [blame] | 15 | #include <utility> |
mflodman@webrtc.org | f89fb9d | 2012-11-22 09:41:42 +0000 | [diff] [blame] | 16 | #include <vector> |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 17 | |
pbos@webrtc.org | f5d4cb1 | 2013-05-17 13:44:48 +0000 | [diff] [blame] | 18 | #include "webrtc/modules/interface/module.h" |
| 19 | #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h" |
| 20 | #include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h" |
| 21 | #include "webrtc/system_wrappers/interface/scoped_ptr.h" |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 22 | |
| 23 | namespace webrtc { |
| 24 | |
| 25 | class CriticalSectionWrapper; |
mflodman@webrtc.org | 9ec883e | 2012-03-05 17:12:41 +0000 | [diff] [blame] | 26 | class ProcessThread; |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 27 | class RtpRtcp; |
| 28 | |
stefan@webrtc.org | b586507 | 2013-02-01 14:33:42 +0000 | [diff] [blame] | 29 | class VieRemb : public RemoteBitrateObserver { |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 30 | public: |
stefan@webrtc.org | b586507 | 2013-02-01 14:33:42 +0000 | [diff] [blame] | 31 | VieRemb(); |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 32 | ~VieRemb(); |
| 33 | |
| 34 | // Called to add a receive channel to include in the REMB packet. |
| 35 | void AddReceiveChannel(RtpRtcp* rtp_rtcp); |
| 36 | |
| 37 | // Removes the specified channel from REMB estimate. |
| 38 | void RemoveReceiveChannel(RtpRtcp* rtp_rtcp); |
| 39 | |
mflodman@webrtc.org | f7b6078 | 2012-02-16 14:50:24 +0000 | [diff] [blame] | 40 | // Called to add a module that can generate and send REMB RTCP. |
| 41 | void AddRembSender(RtpRtcp* rtp_rtcp); |
| 42 | |
| 43 | // Removes a REMB RTCP sender. |
| 44 | void RemoveRembSender(RtpRtcp* rtp_rtcp); |
| 45 | |
mflodman@webrtc.org | 9ec883e | 2012-03-05 17:12:41 +0000 | [diff] [blame] | 46 | // Returns true if the instance is in use, false otherwise. |
| 47 | bool InUse() const; |
| 48 | |
stefan@webrtc.org | 3aece42 | 2012-10-18 11:12:39 +0000 | [diff] [blame] | 49 | // Called every time there is a new bitrate estimate for a receive channel |
| 50 | // group. This call will trigger a new RTCP REMB packet if the bitrate |
| 51 | // estimate has decreased or if no RTCP REMB packet has been sent for |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 52 | // a certain time interval. |
| 53 | // Implements RtpReceiveBitrateUpdate. |
solenberg@webrtc.org | 561990f | 2013-05-22 19:04:19 +0000 | [diff] [blame] | 54 | virtual void OnReceiveBitrateChanged(const std::vector<unsigned int>& ssrcs, |
stefan@webrtc.org | 4100b04 | 2012-11-19 10:09:20 +0000 | [diff] [blame] | 55 | unsigned int bitrate); |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 56 | |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 57 | private: |
| 58 | typedef std::list<RtpRtcp*> RtpModules; |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 59 | |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 60 | scoped_ptr<CriticalSectionWrapper> list_crit_; |
| 61 | |
| 62 | // The last time a REMB was sent. |
| 63 | int64_t last_remb_time_; |
mflodman@webrtc.org | 1fb39ba | 2012-08-13 17:05:14 +0000 | [diff] [blame] | 64 | unsigned int last_send_bitrate_; |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 65 | |
| 66 | // All RtpRtcp modules to include in the REMB packet. |
| 67 | RtpModules receive_modules_; |
| 68 | |
mflodman@webrtc.org | f7b6078 | 2012-02-16 14:50:24 +0000 | [diff] [blame] | 69 | // All modules that can send REMB RTCP. |
| 70 | RtpModules rtcp_sender_; |
| 71 | |
stefan@webrtc.org | 3aece42 | 2012-10-18 11:12:39 +0000 | [diff] [blame] | 72 | // The last bitrate update. |
| 73 | unsigned int bitrate_; |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 74 | }; |
| 75 | |
| 76 | } // namespace webrtc |
| 77 | |
niklas.enbom@webrtc.org | ef62929 | 2012-10-31 14:35:11 +0000 | [diff] [blame] | 78 | #endif // WEBRTC_VIDEO_ENGINE_VIE_REMB_H_ |