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

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

Issue 10910293: Add is_encrypted() in VideoDecoderConfig. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 3 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/source_buffer_stream.cc ('k') | media/mp4/mp4_stream_parser.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 "media/filters/source_buffer_stream.h" 5 #include "media/filters/source_buffer_stream.h"
6 6
7 #include <string>
8
7 #include "base/logging.h" 9 #include "base/logging.h"
8 #include "media/base/data_buffer.h" 10 #include "media/base/data_buffer.h"
9 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
10 12
11 namespace media { 13 namespace media {
12 14
13 static const int kDefaultFramesPerSecond = 30; 15 static const int kDefaultFramesPerSecond = 30;
14 static const int kDefaultKeyframesPerSecond = 6; 16 static const int kDefaultKeyframesPerSecond = 6;
15 static const uint8 kDataA = 0x11; 17 static const uint8 kDataA = 0x11;
16 static const uint8 kDataB = 0x33; 18 static const uint8 kDataB = 0x33;
17 static const int kDataSize = 1; 19 static const int kDataSize = 1;
18 static const gfx::Size kCodedSize(320, 240); 20 static const gfx::Size kCodedSize(320, 240);
19 21
20 class SourceBufferStreamTest : public testing::Test { 22 class SourceBufferStreamTest : public testing::Test {
21 protected: 23 protected:
22 SourceBufferStreamTest() { 24 SourceBufferStreamTest() {
23 config_.Initialize(kCodecVP8, VIDEO_CODEC_PROFILE_UNKNOWN, 25 config_.Initialize(kCodecVP8, VIDEO_CODEC_PROFILE_UNKNOWN,
24 VideoFrame::YV12, kCodedSize, gfx::Rect(kCodedSize), 26 VideoFrame::YV12, kCodedSize, gfx::Rect(kCodedSize),
25 kCodedSize, NULL, 0, false); 27 kCodedSize, NULL, 0, false, false);
26 stream_.reset(new SourceBufferStream(config_)); 28 stream_.reset(new SourceBufferStream(config_));
27 SetStreamInfo(kDefaultFramesPerSecond, kDefaultKeyframesPerSecond); 29 SetStreamInfo(kDefaultFramesPerSecond, kDefaultKeyframesPerSecond);
28 } 30 }
29 31
30 void SetMemoryLimit(int buffers_of_data) { 32 void SetMemoryLimit(int buffers_of_data) {
31 stream_->set_memory_limit(buffers_of_data * kDataSize); 33 stream_->set_memory_limit(buffers_of_data * kDataSize);
32 } 34 }
33 35
34 void SetStreamInfo(int frames_per_second, int keyframes_per_second) { 36 void SetStreamInfo(int frames_per_second, int keyframes_per_second) {
35 frames_per_second_ = frames_per_second; 37 frames_per_second_ = frames_per_second;
(...skipping 1794 matching lines...) Expand 10 before | Expand all | Expand 10 after
1830 // Fulfill the seek by appending one buffer at 15. 1832 // Fulfill the seek by appending one buffer at 15.
1831 NewSegmentAppend(15, 1, &kDataA); 1833 NewSegmentAppend(15, 1, &kDataA);
1832 CheckExpectedBuffers(15, 15, &kDataA); 1834 CheckExpectedBuffers(15, 15, &kDataA);
1833 CheckExpectedRanges("{ [15,15) [20,28) }"); 1835 CheckExpectedRanges("{ [15,15) [20,28) }");
1834 } 1836 }
1835 1837
1836 TEST_F(SourceBufferStreamTest, ConfigChange_Basic) { 1838 TEST_F(SourceBufferStreamTest, ConfigChange_Basic) {
1837 gfx::Size kNewCodedSize(kCodedSize.width() * 2, kCodedSize.height() * 2); 1839 gfx::Size kNewCodedSize(kCodedSize.width() * 2, kCodedSize.height() * 2);
1838 VideoDecoderConfig new_config( 1840 VideoDecoderConfig new_config(
1839 kCodecVP8, VIDEO_CODEC_PROFILE_UNKNOWN, VideoFrame::YV12, kNewCodedSize, 1841 kCodecVP8, VIDEO_CODEC_PROFILE_UNKNOWN, VideoFrame::YV12, kNewCodedSize,
1840 gfx::Rect(kNewCodedSize), kNewCodedSize, NULL, 0); 1842 gfx::Rect(kNewCodedSize), kNewCodedSize, NULL, 0, false);
1841 ASSERT_FALSE(new_config.Matches(config_)); 1843 ASSERT_FALSE(new_config.Matches(config_));
1842 1844
1843 Seek(0); 1845 Seek(0);
1844 CheckConfig(config_); 1846 CheckConfig(config_);
1845 1847
1846 // Append 5 buffers at positions 0 through 4 1848 // Append 5 buffers at positions 0 through 4
1847 NewSegmentAppend(0, 5, &kDataA); 1849 NewSegmentAppend(0, 5, &kDataA);
1848 1850
1849 CheckConfig(config_); 1851 CheckConfig(config_);
1850 1852
(...skipping 26 matching lines...) Expand all
1877 CheckConfig(new_config); 1879 CheckConfig(new_config);
1878 EXPECT_EQ(stream_->GetNextBuffer(&buffer), SourceBufferStream::kSuccess); 1880 EXPECT_EQ(stream_->GetNextBuffer(&buffer), SourceBufferStream::kSuccess);
1879 } 1881 }
1880 } 1882 }
1881 1883
1882 TEST_F(SourceBufferStreamTest, ConfigChange_Seek) { 1884 TEST_F(SourceBufferStreamTest, ConfigChange_Seek) {
1883 scoped_refptr<StreamParserBuffer> buffer; 1885 scoped_refptr<StreamParserBuffer> buffer;
1884 gfx::Size kNewCodedSize(kCodedSize.width() * 2, kCodedSize.height() * 2); 1886 gfx::Size kNewCodedSize(kCodedSize.width() * 2, kCodedSize.height() * 2);
1885 VideoDecoderConfig new_config( 1887 VideoDecoderConfig new_config(
1886 kCodecVP8, VIDEO_CODEC_PROFILE_UNKNOWN, VideoFrame::YV12, kNewCodedSize, 1888 kCodecVP8, VIDEO_CODEC_PROFILE_UNKNOWN, VideoFrame::YV12, kNewCodedSize,
1887 gfx::Rect(kNewCodedSize), kNewCodedSize, NULL, 0); 1889 gfx::Rect(kNewCodedSize), kNewCodedSize, NULL, 0, false);
1888 1890
1889 Seek(0); 1891 Seek(0);
1890 NewSegmentAppend(0, 5, &kDataA); 1892 NewSegmentAppend(0, 5, &kDataA);
1891 stream_->UpdateVideoConfig(new_config); 1893 stream_->UpdateVideoConfig(new_config);
1892 NewSegmentAppend(5, 5, &kDataB); 1894 NewSegmentAppend(5, 5, &kDataB);
1893 1895
1894 // Seek to the start of the buffers with the new config and make sure a 1896 // Seek to the start of the buffers with the new config and make sure a
1895 // config change is signalled. 1897 // config change is signalled.
1896 CheckConfig(config_); 1898 CheckConfig(config_);
1897 Seek(5); 1899 Seek(5);
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
2043 CheckExpectedRanges("{ [0,4) [10,10) }"); 2045 CheckExpectedRanges("{ [0,4) [10,10) }");
2044 } 2046 }
2045 2047
2046 // TODO(vrk): Add unit tests where keyframes are unaligned between streams. 2048 // TODO(vrk): Add unit tests where keyframes are unaligned between streams.
2047 // (crbug.com/133557) 2049 // (crbug.com/133557)
2048 2050
2049 // TODO(vrk): Add unit tests with end of stream being called at interesting 2051 // TODO(vrk): Add unit tests with end of stream being called at interesting
2050 // times. 2052 // times.
2051 2053
2052 } // namespace media 2054 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/source_buffer_stream.cc ('k') | media/mp4/mp4_stream_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698