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: media/filters/chunk_demuxer_unittest.cc

Issue 374203003: Invoke the seek callback during abort if needed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « media/filters/chunk_demuxer.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <algorithm> 5 #include <algorithm>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_split.h" 10 #include "base/strings/string_split.h"
(...skipping 2925 matching lines...) Expand 10 before | Expand all | Expand 10 after
2936 append_window_end_for_next_append_, 2936 append_window_end_for_next_append_,
2937 &timestamp_offset_map_[kSourceId]); 2937 &timestamp_offset_map_[kSourceId]);
2938 Ranges<base::TimeDelta> range_after_abort = 2938 Ranges<base::TimeDelta> range_after_abort =
2939 demuxer_->GetBufferedRanges(kSourceId); 2939 demuxer_->GetBufferedRanges(kSourceId);
2940 2940
2941 ASSERT_EQ(range_before_abort.size(), 1u); 2941 ASSERT_EQ(range_before_abort.size(), 1u);
2942 ASSERT_EQ(range_after_abort.size(), 1u); 2942 ASSERT_EQ(range_after_abort.size(), 1u);
2943 EXPECT_EQ(range_after_abort.start(0), range_before_abort.start(0)); 2943 EXPECT_EQ(range_after_abort.start(0), range_before_abort.start(0));
2944 EXPECT_GT(range_after_abort.end(0), range_before_abort.end(0)); 2944 EXPECT_GT(range_after_abort.end(0), range_before_abort.end(0));
2945 } 2945 }
2946
2947 TEST_F(ChunkDemuxerTest, SeekCompleteDuringAbort) {
2948 EXPECT_CALL(*this, DemuxerOpened());
2949 demuxer_->Initialize(
2950 &host_, CreateInitDoneCB(kInfiniteDuration(), PIPELINE_OK), true);
2951 EXPECT_EQ(ChunkDemuxer::kOk, AddIdForMp2tSource(kSourceId));
2952
2953 // For info:
2954 // DTS/PTS derived using dvbsnoop -s ts -if bear-1280x720.ts -tssubdecode
2955 // Video: first PES:
2956 // PTS: 126912 (0x0001efc0) [= 90 kHz-Timestamp: 0:00:01.4101]
2957 // DTS: 123909 (0x0001e405) [= 90 kHz-Timestamp: 0:00:01.3767]
2958 // Audio: first PES:
2959 // PTS: 126000 (0x0001ec30) [= 90 kHz-Timestamp: 0:00:01.4000]
2960 // DTS: 123910 (0x0001e406) [= 90 kHz-Timestamp: 0:00:01.3767]
2961 // Video: last PES:
2962 // PTS: 370155 (0x0005a5eb) [= 90 kHz-Timestamp: 0:00:04.1128]
2963 // DTS: 367152 (0x00059a30) [= 90 kHz-Timestamp: 0:00:04.0794]
2964 // Audio: last PES:
2965 // PTS: 353788 (0x000565fc) [= 90 kHz-Timestamp: 0:00:03.9309]
2966
2967 scoped_refptr<DecoderBuffer> buffer = ReadTestDataFile("bear-1280x720.ts");
2968 AppendData(kSourceId, buffer->data(), buffer->data_size());
2969
2970 // Confirm we're in the middle of parsing a media segment.
2971 ASSERT_TRUE(demuxer_->IsParsingMediaSegment(kSourceId));
2972
2973 // Seek to a time corresponding to buffers that will be emitted during the
2974 // abort.
2975 Seek(base::TimeDelta::FromMilliseconds(4110));
2976
wolenetz 2014/07/12 00:06:32 Hmm. Reviewing this post-commit, but it looks like
2977 // Abort on the Mpeg2 TS parser triggers the emission of the last video
2978 // buffer which is pending in the stream parser.
2979 demuxer_->Abort(kSourceId,
2980 append_window_start_for_next_append_,
2981 append_window_end_for_next_append_,
2982 &timestamp_offset_map_[kSourceId]);
2983 }
2984
2946 #endif 2985 #endif
2947 #endif 2986 #endif
2948 2987
2949 TEST_F(ChunkDemuxerTest, WebMIsParsingMediaSegmentDetection) { 2988 TEST_F(ChunkDemuxerTest, WebMIsParsingMediaSegmentDetection) {
2950 const uint8 kBuffer[] = { 2989 const uint8 kBuffer[] = {
2951 0x1F, 0x43, 0xB6, 0x75, 0x83, // CLUSTER (size = 3) 2990 0x1F, 0x43, 0xB6, 0x75, 0x83, // CLUSTER (size = 3)
2952 0xE7, 0x81, 0x01, // Cluster TIMECODE (value = 1) 2991 0xE7, 0x81, 0x01, // Cluster TIMECODE (value = 1)
2953 2992
2954 0x1F, 0x43, 0xB6, 0x75, 0xFF, // CLUSTER (size = unknown; really 3 due to:) 2993 0x1F, 0x43, 0xB6, 0x75, 0xFF, // CLUSTER (size = unknown; really 3 due to:)
2955 0xE7, 0x81, 0x02, // Cluster TIMECODE (value = 2) 2994 0xE7, 0x81, 0x02, // Cluster TIMECODE (value = 2)
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
3535 TEST_F(ChunkDemuxerTest, CuesBetweenClusters) { 3574 TEST_F(ChunkDemuxerTest, CuesBetweenClusters) {
3536 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO)); 3575 ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO));
3537 3576
3538 AppendCluster(GenerateCluster(0, 0, 4)); 3577 AppendCluster(GenerateCluster(0, 0, 4));
3539 AppendData(kCuesHeader, sizeof(kCuesHeader)); 3578 AppendData(kCuesHeader, sizeof(kCuesHeader));
3540 AppendCluster(GenerateCluster(46, 66, 5)); 3579 AppendCluster(GenerateCluster(46, 66, 5));
3541 CheckExpectedRanges(kSourceId, "{ [0,115) }"); 3580 CheckExpectedRanges(kSourceId, "{ [0,115) }");
3542 } 3581 }
3543 3582
3544 } // namespace media 3583 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/chunk_demuxer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698