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

Side by Side Diff: chromecast/media/cma/pipeline/av_pipeline_impl.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chromecast/media/cma/pipeline/av_pipeline_impl.h" 5 #include "chromecast/media/cma/pipeline/av_pipeline_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 23 matching lines...) Expand all
34 const int kNoCallbackId = -1; 34 const int kNoCallbackId = -1;
35 35
36 } // namespace 36 } // namespace
37 37
38 AvPipelineImpl::AvPipelineImpl(MediaPipelineBackend::Decoder* decoder, 38 AvPipelineImpl::AvPipelineImpl(MediaPipelineBackend::Decoder* decoder,
39 const AvPipelineClient& client) 39 const AvPipelineClient& client)
40 : bytes_decoded_since_last_update_(0), 40 : bytes_decoded_since_last_update_(0),
41 decoder_(decoder), 41 decoder_(decoder),
42 client_(client), 42 client_(client),
43 state_(kUninitialized), 43 state_(kUninitialized),
44 buffered_time_(::media::kNoTimestamp()), 44 buffered_time_(::media::kNoTimestamp),
45 playable_buffered_time_(::media::kNoTimestamp()), 45 playable_buffered_time_(::media::kNoTimestamp),
46 enable_feeding_(false), 46 enable_feeding_(false),
47 pending_read_(false), 47 pending_read_(false),
48 cast_cdm_context_(NULL), 48 cast_cdm_context_(NULL),
49 player_tracker_callback_id_(kNoCallbackId), 49 player_tracker_callback_id_(kNoCallbackId),
50 weak_factory_(this) { 50 weak_factory_(this) {
51 DCHECK(decoder_); 51 DCHECK(decoder_);
52 decoder_->SetDelegate(this); 52 decoder_->SetDelegate(this);
53 weak_this_ = weak_factory_.GetWeakPtr(); 53 weak_this_ = weak_factory_.GetWeakPtr();
54 thread_checker_.DetachFromThread(); 54 thread_checker_.DetachFromThread();
55 } 55 }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 } 115 }
116 DCHECK_EQ(state_, kStopped); 116 DCHECK_EQ(state_, kStopped);
117 set_state(kFlushing); 117 set_state(kFlushing);
118 118
119 flush_cb_ = flush_cb; 119 flush_cb_ = flush_cb;
120 // Remove any pending buffer. 120 // Remove any pending buffer.
121 pending_buffer_ = nullptr; 121 pending_buffer_ = nullptr;
122 pushed_buffer_ = nullptr; 122 pushed_buffer_ = nullptr;
123 // Remove any frames left in the frame provider. 123 // Remove any frames left in the frame provider.
124 pending_read_ = false; 124 pending_read_ = false;
125 buffered_time_ = ::media::kNoTimestamp(); 125 buffered_time_ = ::media::kNoTimestamp;
126 playable_buffered_time_ = ::media::kNoTimestamp(); 126 playable_buffered_time_ = ::media::kNoTimestamp;
127 non_playable_frames_.clear(); 127 non_playable_frames_.clear();
128 128
129 frame_provider_->Flush(base::Bind(&AvPipelineImpl::OnFlushDone, weak_this_)); 129 frame_provider_->Flush(base::Bind(&AvPipelineImpl::OnFlushDone, weak_this_));
130 } 130 }
131 131
132 void AvPipelineImpl::OnFlushDone() { 132 void AvPipelineImpl::OnFlushDone() {
133 CMALOG(kLogControl) << __FUNCTION__; 133 CMALOG(kLogControl) << __FUNCTION__;
134 DCHECK(thread_checker_.CalledOnValidThread()); 134 DCHECK(thread_checker_.CalledOnValidThread());
135 if (state_ == kError) { 135 if (state_ == kError) {
136 // Flush callback is reset on error. 136 // Flush callback is reset on error.
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 PushPendingBuffer(); 249 PushPendingBuffer();
250 } 250 }
251 251
252 void AvPipelineImpl::PushPendingBuffer() { 252 void AvPipelineImpl::PushPendingBuffer() {
253 DCHECK(pending_buffer_); 253 DCHECK(pending_buffer_);
254 DCHECK(!pushed_buffer_); 254 DCHECK(!pushed_buffer_);
255 255
256 if (!pending_buffer_->end_of_stream() && buffering_state_.get()) { 256 if (!pending_buffer_->end_of_stream() && buffering_state_.get()) {
257 base::TimeDelta timestamp = 257 base::TimeDelta timestamp =
258 base::TimeDelta::FromMicroseconds(pending_buffer_->timestamp()); 258 base::TimeDelta::FromMicroseconds(pending_buffer_->timestamp());
259 if (timestamp != ::media::kNoTimestamp()) 259 if (timestamp != ::media::kNoTimestamp)
260 buffering_state_->SetMaxRenderingTime(timestamp); 260 buffering_state_->SetMaxRenderingTime(timestamp);
261 } 261 }
262 262
263 pushed_buffer_ = pending_buffer_; 263 pushed_buffer_ = pending_buffer_;
264 pending_buffer_ = nullptr; 264 pending_buffer_ = nullptr;
265 MediaPipelineBackend::BufferStatus status = 265 MediaPipelineBackend::BufferStatus status =
266 decoder_->PushBuffer(pushed_buffer_.get()); 266 decoder_->PushBuffer(pushed_buffer_.get());
267 267
268 if (status != MediaPipelineBackend::kBufferPending) 268 if (status != MediaPipelineBackend::kBufferPending)
269 OnPushBufferComplete(status); 269 OnPushBufferComplete(status);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 341
342 void AvPipelineImpl::OnDataBuffered( 342 void AvPipelineImpl::OnDataBuffered(
343 const scoped_refptr<DecoderBufferBase>& buffer, 343 const scoped_refptr<DecoderBufferBase>& buffer,
344 bool is_at_max_capacity) { 344 bool is_at_max_capacity) {
345 DCHECK(thread_checker_.CalledOnValidThread()); 345 DCHECK(thread_checker_.CalledOnValidThread());
346 346
347 if (!buffering_state_.get()) 347 if (!buffering_state_.get())
348 return; 348 return;
349 349
350 if (!buffer->end_of_stream() && 350 if (!buffer->end_of_stream() &&
351 (buffered_time_ == ::media::kNoTimestamp() || 351 (buffered_time_ == ::media::kNoTimestamp ||
352 buffered_time_ < 352 buffered_time_ <
353 base::TimeDelta::FromMicroseconds(buffer->timestamp()))) { 353 base::TimeDelta::FromMicroseconds(buffer->timestamp()))) {
354 buffered_time_ = base::TimeDelta::FromMicroseconds(buffer->timestamp()); 354 buffered_time_ = base::TimeDelta::FromMicroseconds(buffer->timestamp());
355 } 355 }
356 356
357 if (is_at_max_capacity) 357 if (is_at_max_capacity)
358 buffering_state_->NotifyMaxCapacity(buffered_time_); 358 buffering_state_->NotifyMaxCapacity(buffered_time_);
359 359
360 // No need to update the list of playable frames, 360 // No need to update the list of playable frames,
361 // if we are already blocking on a frame. 361 // if we are already blocking on a frame.
(...skipping 15 matching lines...) Expand all
377 non_playable_frame->decrypt_config(); 377 non_playable_frame->decrypt_config();
378 if (decrypt_config && 378 if (decrypt_config &&
379 !(cast_cdm_context_ && 379 !(cast_cdm_context_ &&
380 cast_cdm_context_->GetDecryptContext(decrypt_config->key_id()) 380 cast_cdm_context_->GetDecryptContext(decrypt_config->key_id())
381 .get())) { 381 .get())) {
382 // The frame is still not playable. All the following are thus not 382 // The frame is still not playable. All the following are thus not
383 // playable. 383 // playable.
384 break; 384 break;
385 } 385 }
386 386
387 if (playable_buffered_time_ == ::media::kNoTimestamp() || 387 if (playable_buffered_time_ == ::media::kNoTimestamp ||
388 playable_buffered_time_ < base::TimeDelta::FromMicroseconds( 388 playable_buffered_time_ < base::TimeDelta::FromMicroseconds(
389 non_playable_frame->timestamp())) { 389 non_playable_frame->timestamp())) {
390 playable_buffered_time_ = 390 playable_buffered_time_ =
391 base::TimeDelta::FromMicroseconds(non_playable_frame->timestamp()); 391 base::TimeDelta::FromMicroseconds(non_playable_frame->timestamp());
392 buffering_state_->SetBufferedTime(playable_buffered_time_); 392 buffering_state_->SetBufferedTime(playable_buffered_time_);
393 } 393 }
394 } 394 }
395 395
396 // The frame is playable: remove it from the list of non playable frames. 396 // The frame is playable: remove it from the list of non playable frames.
397 non_playable_frames_.pop_front(); 397 non_playable_frames_.pop_front();
398 } 398 }
399 } 399 }
400 400
401 } // namespace media 401 } // namespace media
402 } // namespace chromecast 402 } // namespace chromecast
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698