| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <deque> | 5 #include <deque> |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/thread.h" | 8 #include "base/thread.h" |
| 9 #include "media/base/filters.h" | 9 #include "media/base/filters.h" |
| 10 #include "media/base/mock_ffmpeg.h" | 10 #include "media/base/mock_ffmpeg.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 demuxer_ = factory_->Create<FFmpegDemuxer>(media_format); | 72 demuxer_ = factory_->Create<FFmpegDemuxer>(media_format); |
| 73 DCHECK(demuxer_); | 73 DCHECK(demuxer_); |
| 74 | 74 |
| 75 // Inject a filter host and message loop and prepare a data source. | 75 // Inject a filter host and message loop and prepare a data source. |
| 76 demuxer_->set_host(&host_); | 76 demuxer_->set_host(&host_); |
| 77 demuxer_->set_message_loop(&message_loop_); | 77 demuxer_->set_message_loop(&message_loop_); |
| 78 data_source_ = new StrictMock<MockDataSource>(); | 78 data_source_ = new StrictMock<MockDataSource>(); |
| 79 | 79 |
| 80 // Initialize FFmpeg fixtures. | 80 // Initialize FFmpeg fixtures. |
| 81 memset(&format_context_, 0, sizeof(format_context_)); | 81 memset(&format_context_, 0, sizeof(format_context_)); |
| 82 memset(&input_format_, 0, sizeof(input_format_)); |
| 82 memset(&streams_, 0, sizeof(streams_)); | 83 memset(&streams_, 0, sizeof(streams_)); |
| 83 memset(&codecs_, 0, sizeof(codecs_)); | 84 memset(&codecs_, 0, sizeof(codecs_)); |
| 84 | 85 |
| 85 // Initialize AVCodecContext structures. | 86 // Initialize AVCodecContext structures. |
| 86 codecs_[AV_STREAM_DATA].codec_type = CODEC_TYPE_DATA; | 87 codecs_[AV_STREAM_DATA].codec_type = CODEC_TYPE_DATA; |
| 87 codecs_[AV_STREAM_DATA].codec_id = CODEC_ID_NONE; | 88 codecs_[AV_STREAM_DATA].codec_id = CODEC_ID_NONE; |
| 88 | 89 |
| 89 codecs_[AV_STREAM_VIDEO].codec_type = CODEC_TYPE_VIDEO; | 90 codecs_[AV_STREAM_VIDEO].codec_type = CODEC_TYPE_VIDEO; |
| 90 codecs_[AV_STREAM_VIDEO].codec_id = CODEC_ID_THEORA; | 91 codecs_[AV_STREAM_VIDEO].codec_id = CODEC_ID_THEORA; |
| 91 codecs_[AV_STREAM_VIDEO].width = kWidth; | 92 codecs_[AV_STREAM_VIDEO].width = kWidth; |
| 92 codecs_[AV_STREAM_VIDEO].height = kHeight; | 93 codecs_[AV_STREAM_VIDEO].height = kHeight; |
| 93 | 94 |
| 94 codecs_[AV_STREAM_AUDIO].codec_type = CODEC_TYPE_AUDIO; | 95 codecs_[AV_STREAM_AUDIO].codec_type = CODEC_TYPE_AUDIO; |
| 95 codecs_[AV_STREAM_AUDIO].codec_id = CODEC_ID_VORBIS; | 96 codecs_[AV_STREAM_AUDIO].codec_id = CODEC_ID_VORBIS; |
| 96 codecs_[AV_STREAM_AUDIO].channels = kChannels; | 97 codecs_[AV_STREAM_AUDIO].channels = kChannels; |
| 97 codecs_[AV_STREAM_AUDIO].sample_rate = kSampleRate; | 98 codecs_[AV_STREAM_AUDIO].sample_rate = kSampleRate; |
| 98 | 99 |
| 100 input_format_.name = "foo"; |
| 101 format_context_.iformat = &input_format_; |
| 102 |
| 99 // Initialize AVStream and AVFormatContext structures. We set the time base | 103 // Initialize AVStream and AVFormatContext structures. We set the time base |
| 100 // of the streams such that duration is reported in microseconds. | 104 // of the streams such that duration is reported in microseconds. |
| 101 format_context_.nb_streams = AV_STREAM_MAX; | 105 format_context_.nb_streams = AV_STREAM_MAX; |
| 102 for (size_t i = 0; i < AV_STREAM_MAX; ++i) { | 106 for (size_t i = 0; i < AV_STREAM_MAX; ++i) { |
| 103 format_context_.streams[i] = &streams_[i]; | 107 format_context_.streams[i] = &streams_[i]; |
| 104 streams_[i].codec = &codecs_[i]; | 108 streams_[i].codec = &codecs_[i]; |
| 105 streams_[i].duration = kDurations[i]; | 109 streams_[i].duration = kDurations[i]; |
| 106 streams_[i].time_base.den = 1 * base::Time::kMicrosecondsPerSecond; | 110 streams_[i].time_base.den = 1 * base::Time::kMicrosecondsPerSecond; |
| 107 streams_[i].time_base.num = 1; | 111 streams_[i].time_base.num = 1; |
| 108 } | 112 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 // Fixture members. | 159 // Fixture members. |
| 156 scoped_refptr<FilterFactory> factory_; | 160 scoped_refptr<FilterFactory> factory_; |
| 157 scoped_refptr<FFmpegDemuxer> demuxer_; | 161 scoped_refptr<FFmpegDemuxer> demuxer_; |
| 158 scoped_refptr<StrictMock<MockDataSource> > data_source_; | 162 scoped_refptr<StrictMock<MockDataSource> > data_source_; |
| 159 StrictMock<MockFilterHost> host_; | 163 StrictMock<MockFilterHost> host_; |
| 160 StrictMock<MockFilterCallback> callback_; | 164 StrictMock<MockFilterCallback> callback_; |
| 161 MessageLoop message_loop_; | 165 MessageLoop message_loop_; |
| 162 | 166 |
| 163 // FFmpeg fixtures. | 167 // FFmpeg fixtures. |
| 164 AVFormatContext format_context_; | 168 AVFormatContext format_context_; |
| 169 AVInputFormat input_format_; |
| 165 AVCodecContext codecs_[AV_STREAM_MAX]; | 170 AVCodecContext codecs_[AV_STREAM_MAX]; |
| 166 AVStream streams_[AV_STREAM_MAX]; | 171 AVStream streams_[AV_STREAM_MAX]; |
| 167 MockFFmpeg mock_ffmpeg_; | 172 MockFFmpeg mock_ffmpeg_; |
| 168 | 173 |
| 169 private: | 174 private: |
| 170 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxerTest); | 175 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxerTest); |
| 171 }; | 176 }; |
| 172 | 177 |
| 173 // These durations are picked so that the demuxer chooses the longest supported | 178 // These durations are picked so that the demuxer chooses the longest supported |
| 174 // stream, which would be 30 in this case for the audio stream. | 179 // stream, which would be 30 in this case for the audio stream. |
| (...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 789 { | 794 { |
| 790 SCOPED_TRACE(""); | 795 SCOPED_TRACE(""); |
| 791 InitializeDemuxer(); | 796 InitializeDemuxer(); |
| 792 } | 797 } |
| 793 EXPECT_CALL(*data_source_, IsStreaming()) | 798 EXPECT_CALL(*data_source_, IsStreaming()) |
| 794 .WillOnce(Return(false)); | 799 .WillOnce(Return(false)); |
| 795 EXPECT_FALSE(demuxer_->IsStreaming()); | 800 EXPECT_FALSE(demuxer_->IsStreaming()); |
| 796 } | 801 } |
| 797 | 802 |
| 798 } // namespace media | 803 } // namespace media |
| OLD | NEW |