Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(955)

Side by Side Diff: media/base/decoder_buffer_queue.cc

Issue 2158923004: Convert media constants to constexpr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/base/decoder_buffer_queue.h" 5 #include "media/base/decoder_buffer_queue.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "media/base/decoder_buffer.h" 8 #include "media/base/decoder_buffer.h"
9 #include "media/base/timestamp_constants.h" 9 #include "media/base/timestamp_constants.h"
10 10
11 namespace media { 11 namespace media {
12 12
13 DecoderBufferQueue::DecoderBufferQueue() 13 DecoderBufferQueue::DecoderBufferQueue()
14 : earliest_valid_timestamp_(kNoTimestamp()), 14 : earliest_valid_timestamp_(kNoTimestamp), data_size_(0) {}
15 data_size_(0) {
16 }
17 15
18 DecoderBufferQueue::~DecoderBufferQueue() {} 16 DecoderBufferQueue::~DecoderBufferQueue() {}
19 17
20 void DecoderBufferQueue::Push(const scoped_refptr<DecoderBuffer>& buffer) { 18 void DecoderBufferQueue::Push(const scoped_refptr<DecoderBuffer>& buffer) {
21 CHECK(!buffer->end_of_stream()); 19 CHECK(!buffer->end_of_stream());
22 20
23 queue_.push_back(buffer); 21 queue_.push_back(buffer);
24 22
25 data_size_ += buffer->data_size(); 23 data_size_ += buffer->data_size();
26 24
27 // TODO(scherkus): FFmpeg returns some packets with no timestamp after 25 // TODO(scherkus): FFmpeg returns some packets with no timestamp after
28 // seeking. Fix and turn this into CHECK(). See http://crbug.com/162192 26 // seeking. Fix and turn this into CHECK(). See http://crbug.com/162192
29 if (buffer->timestamp() == kNoTimestamp()) { 27 if (buffer->timestamp() == kNoTimestamp) {
30 DVLOG(1) << "Buffer has no timestamp"; 28 DVLOG(1) << "Buffer has no timestamp";
31 return; 29 return;
32 } 30 }
33 31
34 if (earliest_valid_timestamp_ == kNoTimestamp()) { 32 if (earliest_valid_timestamp_ == kNoTimestamp) {
35 earliest_valid_timestamp_ = buffer->timestamp(); 33 earliest_valid_timestamp_ = buffer->timestamp();
36 } 34 }
37 35
38 if (buffer->timestamp() < earliest_valid_timestamp_) { 36 if (buffer->timestamp() < earliest_valid_timestamp_) {
39 DVLOG(2) 37 DVLOG(2)
40 << "Out of order timestamps: " 38 << "Out of order timestamps: "
41 << buffer->timestamp().InMicroseconds() 39 << buffer->timestamp().InMicroseconds()
42 << " vs. " 40 << " vs. "
43 << earliest_valid_timestamp_.InMicroseconds(); 41 << earliest_valid_timestamp_.InMicroseconds();
44 return; 42 return;
(...skipping 16 matching lines...) Expand all
61 in_order_queue_.pop_front(); 59 in_order_queue_.pop_front();
62 } 60 }
63 61
64 return buffer; 62 return buffer;
65 } 63 }
66 64
67 void DecoderBufferQueue::Clear() { 65 void DecoderBufferQueue::Clear() {
68 queue_.clear(); 66 queue_.clear();
69 data_size_ = 0; 67 data_size_ = 0;
70 in_order_queue_.clear(); 68 in_order_queue_.clear();
71 earliest_valid_timestamp_ = kNoTimestamp(); 69 earliest_valid_timestamp_ = kNoTimestamp;
72 } 70 }
73 71
74 bool DecoderBufferQueue::IsEmpty() { 72 bool DecoderBufferQueue::IsEmpty() {
75 return queue_.empty(); 73 return queue_.empty();
76 } 74 }
77 75
78 base::TimeDelta DecoderBufferQueue::Duration() { 76 base::TimeDelta DecoderBufferQueue::Duration() {
79 if (in_order_queue_.size() < 2) 77 if (in_order_queue_.size() < 2)
80 return base::TimeDelta(); 78 return base::TimeDelta();
81 79
82 base::TimeDelta start = in_order_queue_.front()->timestamp(); 80 base::TimeDelta start = in_order_queue_.front()->timestamp();
83 base::TimeDelta end = in_order_queue_.back()->timestamp(); 81 base::TimeDelta end = in_order_queue_.back()->timestamp();
84 return end - start; 82 return end - start;
85 } 83 }
86 84
87 } // namespace media 85 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698