summaryrefslogtreecommitdiffstats
path: root/media/cast/cast_defines.h
diff options
context:
space:
mode:
authormikhal@chromium.org <mikhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-19 16:30:58 +0000
committermikhal@chromium.org <mikhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-19 16:30:58 +0000
commit495ab48573b339d806269d13a2827d1a4f394c66 (patch)
tree699cebb50950fed38d8f8df882d9e50208058dc0 /media/cast/cast_defines.h
parent42c9f27f821346fe0cd04fb66ced6d3f4d2b144f (diff)
downloadchromium_src-495ab48573b339d806269d13a2827d1a4f394c66.zip
chromium_src-495ab48573b339d806269d13a2827d1a4f394c66.tar.gz
chromium_src-495ab48573b339d806269d13a2827d1a4f394c66.tar.bz2
Cast:Refactor SenderRtpStatistics
This cl removes the need for a designated stats callback, and shifts the handling of the rtp stats to the audio and video receivers. This cl is a first step in adding another callback to the transport which will return the last transmitted frame. BUG=353497 Review URL: https://codereview.chromium.org/203263002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@257994 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/cast/cast_defines.h')
-rw-r--r--media/cast/cast_defines.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/media/cast/cast_defines.h b/media/cast/cast_defines.h
index 2ee431e..8826e5d 100644
--- a/media/cast/cast_defines.h
+++ b/media/cast/cast_defines.h
@@ -12,6 +12,7 @@
#include "base/compiler_specific.h"
#include "base/logging.h"
#include "base/time/time.h"
+#include "media/cast/transport/cast_transport_config.h"
namespace media {
namespace cast {
@@ -172,6 +173,55 @@ inline uint32 GetVideoRtpTimestamp(const base::TimeTicks& time_ticks) {
return static_cast<uint32>(recorded_delta.InMilliseconds() * 90);
}
+class RtpSenderStatistics {
+ public:
+ explicit RtpSenderStatistics(int frequency)
+ : frequency_(frequency),
+ rtp_timestamp_(0) {
+ memset(&sender_info_, 0, sizeof(sender_info_));
+ }
+
+ ~RtpSenderStatistics() {}
+
+ void UpdateInfo(const base::TimeTicks& now) {
+ // Update RTP timestamp and return last stored statistics.
+ uint32 ntp_seconds = 0;
+ uint32 ntp_fraction = 0;
+ uint32 rtp_timestamp = 0;
+ if (rtp_timestamp_ > 0) {
+ base::TimeDelta time_since_last_send = now - time_sent_;
+ rtp_timestamp = rtp_timestamp_ + time_since_last_send.InMilliseconds() *
+ (frequency_ / 1000);
+ // Update NTP time to current time.
+ ConvertTimeTicksToNtp(now, &ntp_seconds, &ntp_fraction);
+ }
+ // Populate sender info.
+ sender_info_.rtp_timestamp = rtp_timestamp;
+ sender_info_.ntp_seconds = ntp_seconds;
+ sender_info_.ntp_fraction = ntp_fraction;
+ }
+
+ transport::RtcpSenderInfo sender_info() const {
+ return sender_info_;
+ }
+
+ void Store(transport::RtcpSenderInfo sender_info,
+ base::TimeTicks time_sent,
+ uint32 rtp_timestamp) {
+ sender_info_ = sender_info;
+ time_sent_ = time_sent;
+ rtp_timestamp_ = rtp_timestamp;
+}
+
+ private:
+ int frequency_;
+ transport::RtcpSenderInfo sender_info_;
+ base::TimeTicks time_sent_;
+ uint32 rtp_timestamp_;
+
+ DISALLOW_COPY_AND_ASSIGN(RtpSenderStatistics);
+};
+
} // namespace cast
} // namespace media