diff options
author | scherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-12 20:46:25 +0000 |
---|---|---|
committer | scherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-12 20:46:25 +0000 |
commit | 025f804b7014f4f859cebbe9431942da42282cbd (patch) | |
tree | 5b3125fdf0b1e088b9d0ca2a2538c218f165370d | |
parent | 09b1639499698897c778544f8701b6caad7bd220 (diff) | |
download | chromium_src-025f804b7014f4f859cebbe9431942da42282cbd.zip chromium_src-025f804b7014f4f859cebbe9431942da42282cbd.tar.gz chromium_src-025f804b7014f4f859cebbe9431942da42282cbd.tar.bz2 |
Rename media::StreamSample::kInvalidTimestamp to media::kNoTimestamp.
Old name was overly verbose.
BUG=54110
TEST=compiles
Review URL: http://codereview.chromium.org/4877002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65989 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | media/base/buffers.cc | 5 | ||||
-rw-r--r-- | media/base/buffers.h | 6 | ||||
-rw-r--r-- | media/base/clock_impl.cc | 4 | ||||
-rw-r--r-- | media/base/seekable_buffer.cc | 4 | ||||
-rw-r--r-- | media/base/seekable_buffer.h | 3 | ||||
-rw-r--r-- | media/base/seekable_buffer_unittest.cc | 29 | ||||
-rw-r--r-- | media/filters/audio_renderer_algorithm_base.h | 4 | ||||
-rw-r--r-- | media/filters/ffmpeg_audio_decoder.cc | 16 | ||||
-rw-r--r-- | media/filters/ffmpeg_demuxer.cc | 2 | ||||
-rw-r--r-- | media/filters/ffmpeg_video_decoder.cc | 12 | ||||
-rw-r--r-- | media/filters/ffmpeg_video_decoder_unittest.cc | 14 | ||||
-rw-r--r-- | media/video/ffmpeg_video_allocator.cc | 4 | ||||
-rw-r--r-- | media/video/ffmpeg_video_decode_engine.cc | 4 | ||||
-rw-r--r-- | media/video/ffmpeg_video_decode_engine_unittest.cc | 4 | ||||
-rw-r--r-- | media/video/omx_video_decode_engine.cc | 4 |
15 files changed, 55 insertions, 60 deletions
diff --git a/media/base/buffers.cc b/media/base/buffers.cc index 18401d4..5b18ff7 100644 --- a/media/base/buffers.cc +++ b/media/base/buffers.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -6,8 +6,7 @@ namespace media { -// static -const base::TimeDelta StreamSample::kInvalidTimestamp = +const base::TimeDelta kNoTimestamp = base::TimeDelta::FromMicroseconds(kint64min); StreamSample::StreamSample() diff --git a/media/base/buffers.h b/media/base/buffers.h index 9149465..82667fe 100644 --- a/media/base/buffers.h +++ b/media/base/buffers.h @@ -33,11 +33,11 @@ namespace media { +// Indicates an invalid or missing timestamp. +extern const base::TimeDelta kNoTimestamp; + class StreamSample : public base::RefCountedThreadSafe<StreamSample> { public: - // Constant timestamp value to indicate an invalid or missing timestamp. - static const base::TimeDelta kInvalidTimestamp; - // Returns the timestamp of this buffer in microseconds. base::TimeDelta GetTimestamp() const { return timestamp_; diff --git a/media/base/clock_impl.cc b/media/base/clock_impl.cc index b853742..6744f09 100644 --- a/media/base/clock_impl.cc +++ b/media/base/clock_impl.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -33,7 +33,7 @@ base::TimeDelta ClockImpl::Pause() { } void ClockImpl::SetTime(const base::TimeDelta& time) { - if (time == StreamSample::kInvalidTimestamp) { + if (time == kNoTimestamp) { NOTREACHED(); return; } diff --git a/media/base/seekable_buffer.cc b/media/base/seekable_buffer.cc index bb61b78..8de39be 100644 --- a/media/base/seekable_buffer.cc +++ b/media/base/seekable_buffer.cc @@ -18,7 +18,7 @@ SeekableBuffer::SeekableBuffer(size_t backward_capacity, backward_bytes_(0), forward_capacity_(forward_capacity), forward_bytes_(0), - current_time_(StreamSample::kInvalidTimestamp) { + current_time_(kNoTimestamp) { current_buffer_ = buffers_.begin(); } @@ -31,7 +31,7 @@ void SeekableBuffer::Clear() { current_buffer_offset_ = 0; backward_bytes_ = 0; forward_bytes_ = 0; - current_time_ = StreamSample::kInvalidTimestamp; + current_time_ = kNoTimestamp; } diff --git a/media/base/seekable_buffer.h b/media/base/seekable_buffer.h index eff34e6..c1fd969 100644 --- a/media/base/seekable_buffer.h +++ b/media/base/seekable_buffer.h @@ -112,8 +112,7 @@ class SeekableBuffer { // timestamp for the current buffer is set to 0 or the data was added with // Append(const uint*, size_t), then returns value that corresponds to the // last position in a buffer that had timestamp set. - // StreamSample::kInvalidTimestamp is returned if no buffers we read - // from had timestamp set. + // kNoTimestamp is returned if no buffers we read from had timestamp set. base::TimeDelta current_time() const { return current_time_; } private: diff --git a/media/base/seekable_buffer_unittest.cc b/media/base/seekable_buffer_unittest.cc index 9602d50..b6f3132 100644 --- a/media/base/seekable_buffer_unittest.cc +++ b/media/base/seekable_buffer_unittest.cc @@ -9,7 +9,7 @@ #include "media/base/seekable_buffer.h" #include "testing/gtest/include/gtest/gtest.h" -namespace { +namespace media { class SeekableBufferTest : public testing::Test { public: @@ -291,9 +291,6 @@ TEST_F(SeekableBufferTest, AllMethods) { TEST_F(SeekableBufferTest, GetTime) { - const base::TimeDelta kInvalidTimestamp = - media::StreamSample::kInvalidTimestamp; - const struct { int64 first_time_useconds; int64 duration_useconds; @@ -301,15 +298,15 @@ TEST_F(SeekableBufferTest, GetTime) { int64 expected_time; } tests[] = { // Timestamps of 0 are treated as garbage. - { 0, 1000000, 0, kInvalidTimestamp.ToInternalValue() }, - { 0, 4000000, 0, kInvalidTimestamp.ToInternalValue() }, - { 0, 8000000, 0, kInvalidTimestamp.ToInternalValue() }, - { 0, 1000000, 4, kInvalidTimestamp.ToInternalValue() }, - { 0, 4000000, 4, kInvalidTimestamp.ToInternalValue() }, - { 0, 8000000, 4, kInvalidTimestamp.ToInternalValue() }, - { 0, 1000000, kWriteSize, kInvalidTimestamp.ToInternalValue() }, - { 0, 4000000, kWriteSize, kInvalidTimestamp.ToInternalValue() }, - { 0, 8000000, kWriteSize, kInvalidTimestamp.ToInternalValue() }, + { 0, 1000000, 0, kNoTimestamp.ToInternalValue() }, + { 0, 4000000, 0, kNoTimestamp.ToInternalValue() }, + { 0, 8000000, 0, kNoTimestamp.ToInternalValue() }, + { 0, 1000000, 4, kNoTimestamp.ToInternalValue() }, + { 0, 4000000, 4, kNoTimestamp.ToInternalValue() }, + { 0, 8000000, 4, kNoTimestamp.ToInternalValue() }, + { 0, 1000000, kWriteSize, kNoTimestamp.ToInternalValue() }, + { 0, 4000000, kWriteSize, kNoTimestamp.ToInternalValue() }, + { 0, 8000000, kWriteSize, kNoTimestamp.ToInternalValue() }, { 5, 1000000, 0, 5 }, { 5, 4000000, 0, 5 }, { 5, 8000000, 0, 5 }, @@ -321,8 +318,8 @@ TEST_F(SeekableBufferTest, GetTime) { { 5, 8000000, kWriteSize, 8000005 }, }; - // current_time() must initially return kInvalidTimestamp. - EXPECT_EQ(kInvalidTimestamp.ToInternalValue(), + // current_time() must initially return kNoTimestamp. + EXPECT_EQ(kNoTimestamp.ToInternalValue(), buffer_.current_time().ToInternalValue()); scoped_refptr<media::DataBuffer> buffer(new media::DataBuffer(kWriteSize)); @@ -348,4 +345,4 @@ TEST_F(SeekableBufferTest, GetTime) { } } -} // namespace +} // namespace media diff --git a/media/filters/audio_renderer_algorithm_base.h b/media/filters/audio_renderer_algorithm_base.h index c90822c..710a02d 100644 --- a/media/filters/audio_renderer_algorithm_base.h +++ b/media/filters/audio_renderer_algorithm_base.h @@ -57,8 +57,8 @@ class AudioRendererAlgorithmBase { // Clears |queue_|. virtual void FlushBuffers(); - // Returns the time of the next byte in our data or - // StreamSample::kInvalidTimestamp if current time is unknown. + // Returns the time of the next byte in our data or kNoTimestamp if current + // time is unknown. virtual base::TimeDelta GetTime(); // Enqueues a buffer. It is called from the owner of the algorithm after a diff --git a/media/filters/ffmpeg_audio_decoder.cc b/media/filters/ffmpeg_audio_decoder.cc index efd176e..2e8e9ad 100644 --- a/media/filters/ffmpeg_audio_decoder.cc +++ b/media/filters/ffmpeg_audio_decoder.cc @@ -29,7 +29,7 @@ const size_t FFmpegAudioDecoder::kOutputBufferSize = FFmpegAudioDecoder::FFmpegAudioDecoder() : codec_context_(NULL), - estimated_next_timestamp_(StreamSample::kInvalidTimestamp) { + estimated_next_timestamp_(kNoTimestamp) { } FFmpegAudioDecoder::~FFmpegAudioDecoder() { @@ -94,7 +94,7 @@ void FFmpegAudioDecoder::DoInitialize(DemuxerStream* demuxer_stream, void FFmpegAudioDecoder::DoSeek(base::TimeDelta time, Task* done_cb) { avcodec_flush_buffers(codec_context_); - estimated_next_timestamp_ = StreamSample::kInvalidTimestamp; + estimated_next_timestamp_ = kNoTimestamp; done_cb->Run(); delete done_cb; } @@ -151,8 +151,8 @@ void FFmpegAudioDecoder::DoDecode(Buffer* input) { // a whole bunch of AV_NOPTS_VALUE packets. Discard them until we find // something valid. Refer to http://crbug.com/49709 // TODO(hclam): remove this once fixing the issue in FFmpeg. - if (input->GetTimestamp() == StreamSample::kInvalidTimestamp && - estimated_next_timestamp_ == StreamSample::kInvalidTimestamp && + if (input->GetTimestamp() == kNoTimestamp && + estimated_next_timestamp_ == kNoTimestamp && !input->IsEndOfStream()) { DecoderBase<AudioDecoder, Buffer>::OnDecodeComplete(); return; @@ -201,12 +201,12 @@ void FFmpegAudioDecoder::DoDecode(Buffer* input) { result_buffer->SetDuration(duration); // Use an estimated timestamp unless the incoming buffer has a valid one. - if (input->GetTimestamp() == StreamSample::kInvalidTimestamp) { + if (input->GetTimestamp() == kNoTimestamp) { result_buffer->SetTimestamp(estimated_next_timestamp_); // Keep the estimated timestamp invalid until we get an incoming buffer // with a valid timestamp. This can happen during seeks, etc... - if (estimated_next_timestamp_ != StreamSample::kInvalidTimestamp) { + if (estimated_next_timestamp_ != kNoTimestamp) { estimated_next_timestamp_ += duration; } } else { @@ -223,8 +223,8 @@ void FFmpegAudioDecoder::DoDecode(Buffer* input) { // this can be a marker packet that only contains timestamp. In this case we // save the timestamp for later use. if (result && !input->IsEndOfStream() && - input->GetTimestamp() != StreamSample::kInvalidTimestamp && - input->GetDuration() != StreamSample::kInvalidTimestamp) { + input->GetTimestamp() != kNoTimestamp && + input->GetDuration() != kNoTimestamp) { estimated_next_timestamp_ = input->GetTimestamp() + input->GetDuration(); DecoderBase<AudioDecoder, Buffer>::OnDecodeComplete(); return; diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc index a70a0d5..116a20d 100644 --- a/media/filters/ffmpeg_demuxer.cc +++ b/media/filters/ffmpeg_demuxer.cc @@ -233,7 +233,7 @@ void FFmpegDemuxerStream::EnableBitstreamConverter() { base::TimeDelta FFmpegDemuxerStream::ConvertStreamTimestamp( const AVRational& time_base, int64 timestamp) { if (timestamp == static_cast<int64>(AV_NOPTS_VALUE)) - return StreamSample::kInvalidTimestamp; + return kNoTimestamp; return ConvertTimestamp(time_base, timestamp); } diff --git a/media/filters/ffmpeg_video_decoder.cc b/media/filters/ffmpeg_video_decoder.cc index 7ce8f1d..1629e78 100644 --- a/media/filters/ffmpeg_video_decoder.cc +++ b/media/filters/ffmpeg_video_decoder.cc @@ -283,7 +283,7 @@ void FFmpegVideoDecoder::OnReadCompleteTask(scoped_refptr<Buffer> buffer) { // TODO(ajwong): This push logic, along with the pop logic below needs to // be reevaluated to correctly handle decode errors. if (state_ == kNormal && !buffer->IsEndOfStream() && - buffer->GetTimestamp() != StreamSample::kInvalidTimestamp) { + buffer->GetTimestamp() != kNoTimestamp) { pts_heap_.Push(buffer->GetTimestamp()); } @@ -380,7 +380,7 @@ FFmpegVideoDecoder::TimeTuple FFmpegVideoDecoder::FindPtsAndDuration( // situation and set the timestamp to kInvalidTimestamp. DCHECK(frame); base::TimeDelta timestamp = frame->GetTimestamp(); - if (timestamp != StreamSample::kInvalidTimestamp && + if (timestamp != kNoTimestamp && timestamp.ToInternalValue() != 0) { pts.timestamp = timestamp; // We need to clean up the timestamp we pushed onto the |pts_heap|. @@ -390,19 +390,19 @@ FFmpegVideoDecoder::TimeTuple FFmpegVideoDecoder::FindPtsAndDuration( // If the frame did not have pts, try to get the pts from the |pts_heap|. pts.timestamp = pts_heap->Top(); pts_heap->Pop(); - } else if (last_pts.timestamp != StreamSample::kInvalidTimestamp && - last_pts.duration != StreamSample::kInvalidTimestamp) { + } else if (last_pts.timestamp != kNoTimestamp && + last_pts.duration != kNoTimestamp) { // Guess assuming this frame was the same as the last frame. pts.timestamp = last_pts.timestamp + last_pts.duration; } else { // Now we really have no clue!!! Mark an invalid timestamp and let the // video renderer handle it (i.e., drop frame). - pts.timestamp = StreamSample::kInvalidTimestamp; + pts.timestamp = kNoTimestamp; } // Fill in the duration, using the frame itself as the authoratative source. base::TimeDelta duration = frame->GetDuration(); - if (duration != StreamSample::kInvalidTimestamp && + if (duration != kNoTimestamp && duration.ToInternalValue() != 0) { pts.duration = duration; } else { diff --git a/media/filters/ffmpeg_video_decoder_unittest.cc b/media/filters/ffmpeg_video_decoder_unittest.cc index d94e90e..9c1cc4c 100644 --- a/media/filters/ffmpeg_video_decoder_unittest.cc +++ b/media/filters/ffmpeg_video_decoder_unittest.cc @@ -285,17 +285,17 @@ TEST_F(FFmpegVideoDecoderTest, FindPtsAndDuration) { AVRational time_base = {1, 2}; FFmpegVideoDecoder::TimeTuple last_pts; - last_pts.timestamp = StreamSample::kInvalidTimestamp; - last_pts.duration = StreamSample::kInvalidTimestamp; + last_pts.timestamp = kNoTimestamp; + last_pts.duration = kNoTimestamp; // Simulate an uninitialized |video_frame| and |last_pts| where we cannot // determine a timestamp at all. - video_frame_->SetTimestamp(StreamSample::kInvalidTimestamp); - video_frame_->SetDuration(StreamSample::kInvalidTimestamp); + video_frame_->SetTimestamp(kNoTimestamp); + video_frame_->SetDuration(kNoTimestamp); FFmpegVideoDecoder::TimeTuple result_pts = decoder_->FindPtsAndDuration(time_base, &pts_heap, last_pts, video_frame_.get()); - EXPECT_EQ(StreamSample::kInvalidTimestamp.InMicroseconds(), + EXPECT_EQ(kNoTimestamp.InMicroseconds(), result_pts.timestamp.InMicroseconds()); EXPECT_EQ(500000, result_pts.duration.InMicroseconds()); @@ -306,8 +306,8 @@ TEST_F(FFmpegVideoDecoderTest, FindPtsAndDuration) { // Simulate an uninitialized |video_frame| where |last_pts| will be used to // generate a timestamp and |time_base| will be used to generate a duration. - video_frame_->SetTimestamp(StreamSample::kInvalidTimestamp); - video_frame_->SetDuration(StreamSample::kInvalidTimestamp); + video_frame_->SetTimestamp(kNoTimestamp); + video_frame_->SetDuration(kNoTimestamp); result_pts = decoder_->FindPtsAndDuration(time_base, &pts_heap, last_pts, video_frame_.get()); diff --git a/media/video/ffmpeg_video_allocator.cc b/media/video/ffmpeg_video_allocator.cc index 0185629..5b57293 100644 --- a/media/video/ffmpeg_video_allocator.cc +++ b/media/video/ffmpeg_video_allocator.cc @@ -88,8 +88,8 @@ scoped_refptr<VideoFrame> FFmpegVideoAllocator::DecodeDone( codec_context->width, codec_context->height, 3, av_frame->data, av_frame->linesize, - StreamSample::kInvalidTimestamp, - StreamSample::kInvalidTimestamp, + kNoTimestamp, + kNoTimestamp, ffmpeg_video_frame, // |private_buffer_|. &frame); #endif diff --git a/media/video/ffmpeg_video_decode_engine.cc b/media/video/ffmpeg_video_decode_engine.cc index a03b416..a2009f4 100644 --- a/media/video/ffmpeg_video_decode_engine.cc +++ b/media/video/ffmpeg_video_decode_engine.cc @@ -105,8 +105,8 @@ void FFmpegVideoDecodeEngine::Initialize( VideoFrame::CreateFrame(VideoFrame::YV12, config.width, config.height, - StreamSample::kInvalidTimestamp, - StreamSample::kInvalidTimestamp, + kNoTimestamp, + kNoTimestamp, &video_frame); if (!video_frame.get()) { buffer_allocated = false; diff --git a/media/video/ffmpeg_video_decode_engine_unittest.cc b/media/video/ffmpeg_video_decode_engine_unittest.cc index 2902a10..b9ff34f 100644 --- a/media/video/ffmpeg_video_decode_engine_unittest.cc +++ b/media/video/ffmpeg_video_decode_engine_unittest.cc @@ -64,8 +64,8 @@ class FFmpegVideoDecodeEngineTest : public testing::Test, VideoFrame::CreateFrame(VideoFrame::YV12, kWidth, kHeight, - StreamSample::kInvalidTimestamp, - StreamSample::kInvalidTimestamp, + kNoTimestamp, + kNoTimestamp, &video_frame_); } diff --git a/media/video/omx_video_decode_engine.cc b/media/video/omx_video_decode_engine.cc index fc4ad3c6..1ffdf40 100644 --- a/media/video/omx_video_decode_engine.cc +++ b/media/video/omx_video_decode_engine.cc @@ -924,8 +924,8 @@ scoped_refptr<VideoFrame> OmxVideoDecodeEngine::CreateOmxBufferVideoFrame( VideoFrame::YV12, width_, height_, 3, data, strides, - StreamSample::kInvalidTimestamp, - StreamSample::kInvalidTimestamp, + kNoTimestamp, + kNoTimestamp, omx_buffer, &video_frame); |