The goal with this new clock interface is to have something which is used all over WebRTC to make it easier to switch clock implementation depending on where the components are used. This is a first step in that direction. Next steps will be to, step by step, move all modules, video engine and voice engine over to the new interface, effectively deprecating the old clock interfaces. Long-term my vision is that we should be able to deprecate the clock of WebRTC and rely on the user providing the implementation. TEST=vie_auto_test, rtp_rtcp_unittests, trybots Review URL: https://webrtc-codereview.appspot.com/1041004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@3381 4adac7df-926f-26a2-2b94-8c16560cd09d
62 lines
1.5 KiB
C++
62 lines
1.5 KiB
C++
/*
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
|
|
#ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_BITRATE_H_
|
|
#define WEBRTC_MODULES_RTP_RTCP_SOURCE_BITRATE_H_
|
|
|
|
#include <stdio.h>
|
|
#include <list>
|
|
|
|
#include "webrtc/common_types.h"
|
|
#include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_config.h"
|
|
#include "webrtc/typedefs.h"
|
|
|
|
namespace webrtc {
|
|
|
|
class Clock;
|
|
|
|
class Bitrate {
|
|
public:
|
|
explicit Bitrate(Clock* clock);
|
|
|
|
// Calculates rates.
|
|
void Process();
|
|
|
|
// Update with a packet.
|
|
void Update(const WebRtc_Word32 bytes);
|
|
|
|
// Packet rate last second, updated roughly every 100 ms.
|
|
WebRtc_UWord32 PacketRate() const;
|
|
|
|
// Bitrate last second, updated roughly every 100 ms.
|
|
WebRtc_UWord32 BitrateLast() const;
|
|
|
|
// Bitrate last second, updated now.
|
|
WebRtc_UWord32 BitrateNow() const;
|
|
|
|
protected:
|
|
Clock& clock_;
|
|
|
|
private:
|
|
WebRtc_UWord32 packet_rate_;
|
|
WebRtc_UWord32 bitrate_;
|
|
WebRtc_UWord8 bitrate_next_idx_;
|
|
WebRtc_Word64 packet_rate_array_[10];
|
|
WebRtc_Word64 bitrate_array_[10];
|
|
WebRtc_Word64 bitrate_diff_ms_[10];
|
|
WebRtc_Word64 time_last_rate_update_;
|
|
WebRtc_UWord32 bytes_count_;
|
|
WebRtc_UWord32 packet_count_;
|
|
};
|
|
|
|
} // namespace webrtc
|
|
|
|
#endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_BITRATE_H_
|