OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/text_renderer.h" | 5 #include "media/base/text_renderer.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 } | 83 } |
84 | 84 |
85 void TextRenderer::Flush(const base::Closure& callback) { | 85 void TextRenderer::Flush(const base::Closure& callback) { |
86 DCHECK(task_runner_->BelongsToCurrentThread()); | 86 DCHECK(task_runner_->BelongsToCurrentThread()); |
87 DCHECK_EQ(pending_read_count_, 0); | 87 DCHECK_EQ(pending_read_count_, 0); |
88 DCHECK(state_ == kPaused) << "state_ " << state_; | 88 DCHECK(state_ == kPaused) << "state_ " << state_; |
89 | 89 |
90 for (TextTrackStateMap::iterator itr = text_track_state_map_.begin(); | 90 for (TextTrackStateMap::iterator itr = text_track_state_map_.begin(); |
91 itr != text_track_state_map_.end(); ++itr) { | 91 itr != text_track_state_map_.end(); ++itr) { |
92 pending_eos_set_.insert(itr->first); | 92 pending_eos_set_.insert(itr->first); |
| 93 itr->second->text_ranges_.Flush(); |
93 } | 94 } |
94 DCHECK_EQ(pending_eos_set_.size(), text_track_state_map_.size()); | 95 DCHECK_EQ(pending_eos_set_.size(), text_track_state_map_.size()); |
95 callback.Run(); | 96 callback.Run(); |
96 } | 97 } |
97 | 98 |
98 void TextRenderer::Stop(const base::Closure& cb) { | 99 void TextRenderer::Stop(const base::Closure& cb) { |
99 DCHECK(task_runner_->BelongsToCurrentThread()); | 100 DCHECK(task_runner_->BelongsToCurrentThread()); |
100 DCHECK(!cb.is_null()); | 101 DCHECK(!cb.is_null()); |
101 DCHECK(state_ == kPlaying || | 102 DCHECK(state_ == kPlaying || |
102 state_ == kPausePending || | 103 state_ == kPausePending || |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 | 300 |
300 case kPaused: | 301 case kPaused: |
301 case kStopped: | 302 case kStopped: |
302 case kUninitialized: | 303 case kUninitialized: |
303 case kEnded: | 304 case kEnded: |
304 NOTREACHED(); | 305 NOTREACHED(); |
305 return; | 306 return; |
306 } | 307 } |
307 | 308 |
308 base::TimeDelta start = text_cue->timestamp(); | 309 base::TimeDelta start = text_cue->timestamp(); |
309 base::TimeDelta end = start + text_cue->duration(); | |
310 | 310 |
311 state->text_track->addWebVTTCue(start, end, | 311 if (state->text_ranges_.AddCue(start)) { |
312 text_cue->id(), | 312 base::TimeDelta end = start + text_cue->duration(); |
313 text_cue->text(), | 313 |
314 text_cue->settings()); | 314 state->text_track->addWebVTTCue(start, end, |
| 315 text_cue->id(), |
| 316 text_cue->text(), |
| 317 text_cue->settings()); |
| 318 } |
315 | 319 |
316 if (state_ == kPlaying) { | 320 if (state_ == kPlaying) { |
317 Read(state, text_stream); | 321 Read(state, text_stream); |
318 return; | 322 return; |
319 } | 323 } |
320 | 324 |
321 if (pending_read_count_ == 0) { | 325 if (pending_read_count_ == 0) { |
322 DCHECK_EQ(state_, kPausePending) << "state_ " << state_; | 326 DCHECK_EQ(state_, kPausePending) << "state_ " << state_; |
323 state_ = kPaused; | 327 state_ = kPaused; |
324 base::ResetAndReturn(&pause_cb_).Run(); | 328 base::ResetAndReturn(&pause_cb_).Run(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 | 361 |
358 TextRenderer::TextTrackState::TextTrackState(scoped_ptr<TextTrack> tt) | 362 TextRenderer::TextTrackState::TextTrackState(scoped_ptr<TextTrack> tt) |
359 : read_state(kReadIdle), | 363 : read_state(kReadIdle), |
360 text_track(tt.Pass()) { | 364 text_track(tt.Pass()) { |
361 } | 365 } |
362 | 366 |
363 TextRenderer::TextTrackState::~TextTrackState() { | 367 TextRenderer::TextTrackState::~TextTrackState() { |
364 } | 368 } |
365 | 369 |
366 } // namespace media | 370 } // namespace media |
OLD | NEW |