summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--media/base/buffers.h10
-rwxr-xr-xmedia/base/data_buffer.cc11
-rwxr-xr-xmedia/base/data_buffer.h14
-rw-r--r--media/base/data_buffer_unittest.cc19
-rw-r--r--media/base/synchronizer.cc8
5 files changed, 34 insertions, 28 deletions
diff --git a/media/base/buffers.h b/media/base/buffers.h
index bdfb726..cbee337 100644
--- a/media/base/buffers.h
+++ b/media/base/buffers.h
@@ -27,23 +27,25 @@
#ifndef MEDIA_BASE_BUFFERS_H_
#define MEDIA_BASE_BUFFERS_H_
+#include "base/basictypes.h"
#include "base/ref_counted.h"
+#include "base/time.h"
namespace media {
class StreamSample : public base::RefCountedThreadSafe<StreamSample> {
public:
// Returns the timestamp of this buffer in microseconds.
- virtual int64 GetTimestamp() const = 0;
+ virtual base::TimeDelta GetTimestamp() const = 0;
// Returns the duration of this buffer in microseconds.
- virtual int64 GetDuration() const = 0;
+ virtual base::TimeDelta GetDuration() const = 0;
// Sets the timestamp of this buffer in microseconds.
- virtual void SetTimestamp(int64 timestamp) = 0;
+ virtual void SetTimestamp(const base::TimeDelta& timestamp) = 0;
// Sets the duration of this buffer in microseconds.
- virtual void SetDuration(int64 duration) = 0;
+ virtual void SetDuration(const base::TimeDelta& duration) = 0;
protected:
friend class base::RefCountedThreadSafe<StreamSample>;
diff --git a/media/base/data_buffer.cc b/media/base/data_buffer.cc
index c5c290d..ae5314a 100755
--- a/media/base/data_buffer.cc
+++ b/media/base/data_buffer.cc
@@ -8,7 +8,8 @@
namespace media {
DataBuffer::DataBuffer(char* data, size_t buffer_size, size_t data_size,
- int64 timestamp, int64 duration)
+ const base::TimeDelta& timestamp,
+ const base::TimeDelta& duration)
: data_(data),
buffer_size_(buffer_size),
data_size_(data_size),
@@ -23,19 +24,19 @@ DataBuffer::~DataBuffer() {
delete [] data_;
}
-int64 DataBuffer::GetTimestamp() const {
+base::TimeDelta DataBuffer::GetTimestamp() const {
return timestamp_;
}
-void DataBuffer::SetTimestamp(int64 timestamp) {
+void DataBuffer::SetTimestamp(const base::TimeDelta& timestamp) {
timestamp_ = timestamp;
}
-int64 DataBuffer::GetDuration() const {
+base::TimeDelta DataBuffer::GetDuration() const {
return duration_;
}
-void DataBuffer::SetDuration(int64 duration) {
+void DataBuffer::SetDuration(const base::TimeDelta& duration) {
duration_ = duration;
}
diff --git a/media/base/data_buffer.h b/media/base/data_buffer.h
index 5c220c0..7aa5df8 100755
--- a/media/base/data_buffer.h
+++ b/media/base/data_buffer.h
@@ -17,13 +17,13 @@ namespace media {
class DataBuffer : public WritableBuffer {
public:
DataBuffer(char* data, size_t buffer_size, size_t data_size,
- int64 timestamp, int64 duration);
+ const base::TimeDelta& timestamp, const base::TimeDelta& duration);
// StreamSample implementation.
- virtual int64 GetTimestamp() const;
- virtual void SetTimestamp(int64 timestamp);
- virtual int64 GetDuration() const;
- virtual void SetDuration(int64 duration);
+ virtual base::TimeDelta GetTimestamp() const;
+ virtual void SetTimestamp(const base::TimeDelta& timestamp);
+ virtual base::TimeDelta GetDuration() const;
+ virtual void SetDuration(const base::TimeDelta& duration);
// Buffer implementation.
virtual const char* GetData() const;
@@ -41,8 +41,8 @@ class DataBuffer : public WritableBuffer {
char* data_;
size_t buffer_size_;
size_t data_size_;
- int64 timestamp_;
- int64 duration_;
+ base::TimeDelta timestamp_;
+ base::TimeDelta duration_;
};
} // namespace media
diff --git a/media/base/data_buffer_unittest.cc b/media/base/data_buffer_unittest.cc
index 809d7ff..9836ced 100644
--- a/media/base/data_buffer_unittest.cc
+++ b/media/base/data_buffer_unittest.cc
@@ -14,6 +14,10 @@ TEST(DataBufferTest, Basic) {
const size_t kDataSize = arraysize(kData);
const char kNewData[] = "chromium";
const size_t kNewDataSize = arraysize(kNewData);
+ const base::TimeDelta kTimestampA = base::TimeDelta::FromMicroseconds(1337);
+ const base::TimeDelta kDurationA = base::TimeDelta::FromMicroseconds(1667);
+ const base::TimeDelta kTimestampB = base::TimeDelta::FromMicroseconds(1234);
+ const base::TimeDelta kDurationB = base::TimeDelta::FromMicroseconds(5678);
// Create our buffer and copy some data into it.
char* data = new char[kBufferSize];
@@ -23,16 +27,17 @@ TEST(DataBufferTest, Basic) {
// Create a DataBuffer.
scoped_refptr<DataBuffer> buffer;
- buffer = new DataBuffer(data, kBufferSize, kDataSize, 1337, 1667);
+ buffer = new DataBuffer(data, kBufferSize, kDataSize,
+ kTimestampA, kDurationA);
ASSERT_TRUE(buffer.get());
// Test StreamSample implementation.
- EXPECT_EQ(1337, buffer->GetTimestamp());
- EXPECT_EQ(1667, buffer->GetDuration());
- buffer->SetTimestamp(1234);
- buffer->SetDuration(5678);
- EXPECT_EQ(1234, buffer->GetTimestamp());
- EXPECT_EQ(5678, buffer->GetDuration());
+ EXPECT_TRUE(kTimestampA == buffer->GetTimestamp());
+ EXPECT_TRUE(kDurationA == buffer->GetDuration());
+ buffer->SetTimestamp(kTimestampB);
+ buffer->SetDuration(kDurationB);
+ EXPECT_TRUE(kTimestampB == buffer->GetTimestamp());
+ EXPECT_TRUE(kDurationB == buffer->GetDuration());
// Test Buffer implementation.
ASSERT_EQ(data, buffer->GetData());
diff --git a/media/base/synchronizer.cc b/media/base/synchronizer.cc
index f233c7b..a8caffa 100644
--- a/media/base/synchronizer.cc
+++ b/media/base/synchronizer.cc
@@ -33,12 +33,10 @@ void Synchronizer::CalculateDelay(base::TimeDelta time,
base::TimeDelta render_delta = rendering_stop_ - rendering_start_;
// The duration to display the sample |now|.
- base::TimeDelta duration =
- base::TimeDelta::FromMicroseconds(now->GetDuration());
+ base::TimeDelta duration = now->GetDuration();
// The presentation timestamp (pts) of the sample |now|.
- base::TimeDelta now_pts =
- base::TimeDelta::FromMicroseconds(now->GetTimestamp());
+ base::TimeDelta now_pts = now->GetTimestamp();
// The presentation timestamp (pts) of the next sample.
base::TimeDelta next_pts;
@@ -50,7 +48,7 @@ void Synchronizer::CalculateDelay(base::TimeDelta time,
// We also use |next| to get the exact next timestamp as opposed to assuming
// it will be |now| + |now|'s duration, which may not always be true.
if (next) {
- next_pts = base::TimeDelta::FromMicroseconds(next->GetTimestamp());
+ next_pts = next->GetTimestamp();
duration = next_pts - now_pts;
// Timestamps appear out of order, so skip this frame.