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

Side by Side Diff: media/filters/chunk_demuxer_unittest.cc

Issue 10803019: Chrome-side implementation of media source timestamp offset (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase ToT Created 8 years, 4 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') | media/filters/source_buffer_stream.cc » ('j') | 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "media/base/audio_decoder_config.h" 6 #include "media/base/audio_decoder_config.h"
7 #include "media/base/decoder_buffer.h" 7 #include "media/base/decoder_buffer.h"
8 #include "media/base/mock_callback.h" 8 #include "media/base/mock_callback.h"
9 #include "media/base/mock_demuxer_host.h" 9 #include "media/base/mock_demuxer_host.h"
10 #include "media/base/test_data_util.h" 10 #include "media/base/test_data_util.h"
(...skipping 2046 matching lines...) Expand 10 before | Expand all | Expand 10 after
2057 demuxer_->Seek(base::TimeDelta::FromMilliseconds(501), 2057 demuxer_->Seek(base::TimeDelta::FromMilliseconds(501),
2058 NewExpectedStatusCB(PIPELINE_OK)); 2058 NewExpectedStatusCB(PIPELINE_OK));
2059 demuxer_->Seek(base::TimeDelta::FromMilliseconds(801), 2059 demuxer_->Seek(base::TimeDelta::FromMilliseconds(801),
2060 NewExpectedStatusCB(PIPELINE_OK)); 2060 NewExpectedStatusCB(PIPELINE_OK));
2061 2061
2062 // Verify that no config change is signalled. 2062 // Verify that no config change is signalled.
2063 ExpectRead(stream, 801); 2063 ExpectRead(stream, 801);
2064 ASSERT_TRUE(video_config_1.Matches(stream->video_decoder_config())); 2064 ASSERT_TRUE(video_config_1.Matches(stream->video_decoder_config()));
2065 } 2065 }
2066 2066
2067 TEST_F(ChunkDemuxerTest, TestTimestampPositiveOffset) {
2068 ASSERT_TRUE(InitDemuxer(true, true, false));
2069
2070 ASSERT_TRUE(demuxer_->SetTimestampOffset(kSourceId, 30));
2071 scoped_ptr<Cluster> cluster(GenerateCluster(0, 2));
2072 ASSERT_TRUE(AppendData(cluster->data(), cluster->size()));
2073
2074 scoped_refptr<DemuxerStream> audio =
2075 demuxer_->GetStream(DemuxerStream::AUDIO);
2076 scoped_refptr<DemuxerStream> video =
2077 demuxer_->GetStream(DemuxerStream::VIDEO);
2078 GenerateExpectedReads(30000, 2, audio, video);
2079 }
2080
2081 TEST_F(ChunkDemuxerTest, TestTimestampNegativeOffset) {
2082 ASSERT_TRUE(InitDemuxer(true, true, false));
2083
2084 ASSERT_TRUE(demuxer_->SetTimestampOffset(kSourceId, -1));
2085 scoped_ptr<Cluster> cluster = GenerateCluster(1000, 2);
2086 ASSERT_TRUE(AppendData(cluster->data(), cluster->size()));
2087
2088 scoped_refptr<DemuxerStream> audio =
2089 demuxer_->GetStream(DemuxerStream::AUDIO);
2090 scoped_refptr<DemuxerStream> video =
2091 demuxer_->GetStream(DemuxerStream::VIDEO);
2092 GenerateExpectedReads(0, 2, audio, video);
2093 }
2094
2095 TEST_F(ChunkDemuxerTest, TestTimestampOffsetSeparateStreams) {
2096 std::string audio_id = "audio1";
2097 std::string video_id = "video1";
2098 ASSERT_TRUE(InitDemuxerAudioAndVideoSources(audio_id, video_id));
2099
2100 scoped_refptr<DemuxerStream> audio =
2101 demuxer_->GetStream(DemuxerStream::AUDIO);
2102 scoped_refptr<DemuxerStream> video =
2103 demuxer_->GetStream(DemuxerStream::VIDEO);
2104
2105 scoped_ptr<Cluster> cluster_a(
2106 GenerateSingleStreamCluster(
2107 2500, 2500 + kAudioBlockDuration * 4, kAudioTrackNum,
2108 kAudioBlockDuration));
2109
2110 scoped_ptr<Cluster> cluster_v(
2111 GenerateSingleStreamCluster(
2112 0, kVideoBlockDuration * 4, kVideoTrackNum, kVideoBlockDuration));
2113
2114 ASSERT_TRUE(demuxer_->SetTimestampOffset(audio_id, -2.5));
2115 ASSERT_TRUE(AppendData(audio_id, cluster_a->data(), cluster_a->size()));
2116 GenerateSingleStreamExpectedReads(0, 4, audio, kAudioBlockDuration);
2117
2118 ASSERT_TRUE(demuxer_->SetTimestampOffset(video_id, 27.3));
2119 ASSERT_TRUE(AppendData(video_id, cluster_v->data(), cluster_v->size()));
2120 GenerateSingleStreamExpectedReads(27300, 4, video, kVideoBlockDuration);
2121 }
2122
2123 TEST_F(ChunkDemuxerTest, TestTimestampOffsetMidParse) {
2124 ASSERT_TRUE(InitDemuxer(true, true, false));
2125
2126 scoped_ptr<Cluster> cluster = GenerateCluster(0, 2);
2127 // Append only part of the cluster data.
2128 ASSERT_TRUE(AppendData(cluster->data(), cluster->size() - 13));
2129
2130 // Setting a timestamp should fail because we're in the middle of a cluster.
2131 ASSERT_FALSE(demuxer_->SetTimestampOffset(kSourceId, 25));
2132 }
2067 } // namespace media 2133 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/chunk_demuxer.cc ('k') | media/filters/source_buffer_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698