OLD | NEW |
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/filters/source_buffer_stream.h" | 5 #include "media/filters/source_buffer_stream.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 } | 245 } |
246 | 246 |
247 EXPECT_EQ(buffer->GetDecodeTimestamp() / frame_duration_, | 247 EXPECT_EQ(buffer->GetDecodeTimestamp() / frame_duration_, |
248 current_position); | 248 current_position); |
249 } | 249 } |
250 | 250 |
251 EXPECT_EQ(ending_position + 1, current_position); | 251 EXPECT_EQ(ending_position + 1, current_position); |
252 } | 252 } |
253 | 253 |
254 void CheckExpectedBuffers(const std::string& expected) { | 254 void CheckExpectedBuffers(const std::string& expected) { |
255 std::vector<std::string> timestamps; | 255 std::vector<std::string> timestamps = base::SplitString( |
256 base::SplitString(expected, ' ', ×tamps); | 256 expected, " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
257 std::stringstream ss; | 257 std::stringstream ss; |
258 const SourceBufferStream::Type type = stream_->GetType(); | 258 const SourceBufferStream::Type type = stream_->GetType(); |
259 base::TimeDelta active_splice_timestamp = kNoTimestamp(); | 259 base::TimeDelta active_splice_timestamp = kNoTimestamp(); |
260 for (size_t i = 0; i < timestamps.size(); i++) { | 260 for (size_t i = 0; i < timestamps.size(); i++) { |
261 scoped_refptr<StreamParserBuffer> buffer; | 261 scoped_refptr<StreamParserBuffer> buffer; |
262 SourceBufferStream::Status status = stream_->GetNextBuffer(&buffer); | 262 SourceBufferStream::Status status = stream_->GetNextBuffer(&buffer); |
263 | 263 |
264 if (i > 0) | 264 if (i > 0) |
265 ss << " "; | 265 ss << " "; |
266 | 266 |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 // K: | 477 // K: |
478 // Indicates the buffer is a keyframe. E.g., "0K 1|2K 2|4D2K 6 8". | 478 // Indicates the buffer is a keyframe. E.g., "0K 1|2K 2|4D2K 6 8". |
479 // | 479 // |
480 // S(a# ... y# z#) | 480 // S(a# ... y# z#) |
481 // Indicates a splice frame buffer should be created with timestamp z#. The | 481 // Indicates a splice frame buffer should be created with timestamp z#. The |
482 // preceding timestamps a# ... y# will be treated as the fade out preroll for | 482 // preceding timestamps a# ... y# will be treated as the fade out preroll for |
483 // the splice frame. If a timestamp within the preroll ends with C the config | 483 // the splice frame. If a timestamp within the preroll ends with C the config |
484 // id to use for that and subsequent preroll appends is incremented by one. | 484 // id to use for that and subsequent preroll appends is incremented by one. |
485 // The config id for non-splice frame appends will not be affected. | 485 // The config id for non-splice frame appends will not be affected. |
486 BufferQueue StringToBufferQueue(const std::string& buffers_to_append) { | 486 BufferQueue StringToBufferQueue(const std::string& buffers_to_append) { |
487 std::vector<std::string> timestamps; | 487 std::vector<std::string> timestamps = base::SplitString( |
488 base::SplitString(buffers_to_append, ' ', ×tamps); | 488 buffers_to_append, " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
489 | 489 |
490 CHECK_GT(timestamps.size(), 0u); | 490 CHECK_GT(timestamps.size(), 0u); |
491 | 491 |
492 bool splice_frame = false; | 492 bool splice_frame = false; |
493 size_t splice_config_id = stream_->append_config_index_; | 493 size_t splice_config_id = stream_->append_config_index_; |
494 BufferQueue pre_splice_buffers; | 494 BufferQueue pre_splice_buffers; |
495 BufferQueue buffers; | 495 BufferQueue buffers; |
496 for (size_t i = 0; i < timestamps.size(); i++) { | 496 for (size_t i = 0; i < timestamps.size(); i++) { |
497 bool is_keyframe = false; | 497 bool is_keyframe = false; |
498 bool has_preroll = false; | 498 bool has_preroll = false; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 } | 542 } |
543 | 543 |
544 int duration_in_ms = 0; | 544 int duration_in_ms = 0; |
545 size_t duration_pos = timestamps[i].find('D'); | 545 size_t duration_pos = timestamps[i].find('D'); |
546 if (duration_pos != std::string::npos) { | 546 if (duration_pos != std::string::npos) { |
547 CHECK(base::StringToInt(timestamps[i].substr(duration_pos + 1), | 547 CHECK(base::StringToInt(timestamps[i].substr(duration_pos + 1), |
548 &duration_in_ms)); | 548 &duration_in_ms)); |
549 timestamps[i] = timestamps[i].substr(0, duration_pos); | 549 timestamps[i] = timestamps[i].substr(0, duration_pos); |
550 } | 550 } |
551 | 551 |
552 std::vector<std::string> buffer_timestamps; | 552 std::vector<std::string> buffer_timestamps = base::SplitString( |
553 base::SplitString(timestamps[i], '|', &buffer_timestamps); | 553 timestamps[i], "|", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
554 | 554 |
555 if (buffer_timestamps.size() == 1) | 555 if (buffer_timestamps.size() == 1) |
556 buffer_timestamps.push_back(buffer_timestamps[0]); | 556 buffer_timestamps.push_back(buffer_timestamps[0]); |
557 | 557 |
558 CHECK_EQ(2u, buffer_timestamps.size()); | 558 CHECK_EQ(2u, buffer_timestamps.size()); |
559 | 559 |
560 int pts_in_ms = 0; | 560 int pts_in_ms = 0; |
561 int dts_in_ms = 0; | 561 int dts_in_ms = 0; |
562 CHECK(base::StringToInt(buffer_timestamps[0], &pts_in_ms)); | 562 CHECK(base::StringToInt(buffer_timestamps[0], &pts_in_ms)); |
563 CHECK(base::StringToInt(buffer_timestamps[1], &dts_in_ms)); | 563 CHECK(base::StringToInt(buffer_timestamps[1], &dts_in_ms)); |
(...skipping 3721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4285 CheckVideoConfig(new_config); | 4285 CheckVideoConfig(new_config); |
4286 } | 4286 } |
4287 | 4287 |
4288 // TODO(vrk): Add unit tests where keyframes are unaligned between streams. | 4288 // TODO(vrk): Add unit tests where keyframes are unaligned between streams. |
4289 // (crbug.com/133557) | 4289 // (crbug.com/133557) |
4290 | 4290 |
4291 // TODO(vrk): Add unit tests with end of stream being called at interesting | 4291 // TODO(vrk): Add unit tests with end of stream being called at interesting |
4292 // times. | 4292 // times. |
4293 | 4293 |
4294 } // namespace media | 4294 } // namespace media |
OLD | NEW |