OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #ifndef MEDIA_FILTERS_FAKE_DEMUXER_STREAM_H_ | 5 #ifndef MEDIA_FILTERS_FAKE_DEMUXER_STREAM_H_ |
6 #define MEDIA_FILTERS_FAKE_DEMUXER_STREAM_H_ | 6 #define MEDIA_FILTERS_FAKE_DEMUXER_STREAM_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "media/base/audio_decoder_config.h" | 10 #include "media/base/audio_decoder_config.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 virtual ~FakeDemuxerStream(); | 28 virtual ~FakeDemuxerStream(); |
29 | 29 |
30 // DemuxerStream implementation. | 30 // DemuxerStream implementation. |
31 virtual void Read(const ReadCB& read_cb) OVERRIDE; | 31 virtual void Read(const ReadCB& read_cb) OVERRIDE; |
32 virtual AudioDecoderConfig audio_decoder_config() OVERRIDE; | 32 virtual AudioDecoderConfig audio_decoder_config() OVERRIDE; |
33 virtual VideoDecoderConfig video_decoder_config() OVERRIDE; | 33 virtual VideoDecoderConfig video_decoder_config() OVERRIDE; |
34 virtual Type type() OVERRIDE; | 34 virtual Type type() OVERRIDE; |
35 virtual void EnableBitstreamConverter() OVERRIDE; | 35 virtual void EnableBitstreamConverter() OVERRIDE; |
36 virtual bool SupportsConfigChanges() OVERRIDE; | 36 virtual bool SupportsConfigChanges() OVERRIDE; |
37 | 37 |
| 38 void Initialize(); |
| 39 |
38 int num_buffers_returned() const { return num_buffers_returned_; } | 40 int num_buffers_returned() const { return num_buffers_returned_; } |
39 | 41 |
40 // Upon the next read, holds the read callback until SatisfyRead() or Reset() | 42 // Upon the next read, holds the read callback until SatisfyRead() or Reset() |
41 // is called. | 43 // is called. |
42 void HoldNextRead(); | 44 void HoldNextRead(); |
43 | 45 |
44 // Upon the next config change read, holds the read callback until | 46 // Upon the next config change read, holds the read callback until |
45 // SatisfyRead() or Reset() is called. If there is no config change any more, | 47 // SatisfyRead() or Reset() is called. If there is no config change any more, |
46 // no read will be held. | 48 // no read will be held. |
47 void HoldNextConfigChangeRead(); | 49 void HoldNextConfigChangeRead(); |
48 | 50 |
49 // Satisfies the pending read with the next scheduled status and buffer. | 51 // Satisfies the pending read with the next scheduled status and buffer. |
50 void SatisfyRead(); | 52 void SatisfyRead(); |
51 | 53 |
52 // Satisfies pending read request and then holds the following read. | 54 // Satisfies pending read request and then holds the following read. |
53 void SatisfyReadAndHoldNext(); | 55 void SatisfyReadAndHoldNext(); |
54 | 56 |
55 // Satisfies the pending read (if any) with kAborted and NULL. This call | 57 // Satisfies the pending read (if any) with kAborted and NULL. This call |
56 // always clears |hold_next_read_|. | 58 // always clears |hold_next_read_|. |
57 void Reset(); | 59 void Reset(); |
58 | 60 |
| 61 // Reset() this demuxer stream and set the reading position to the start of |
| 62 // the stream. |
| 63 void SeekToStart(); |
| 64 |
59 private: | 65 private: |
60 void UpdateVideoDecoderConfig(); | 66 void UpdateVideoDecoderConfig(); |
61 void DoRead(); | 67 void DoRead(); |
62 | 68 |
63 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 69 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
64 | 70 |
| 71 const int num_configs_; |
| 72 const int num_buffers_in_one_config_; |
| 73 const bool config_changes_; |
| 74 const bool is_encrypted_; |
| 75 |
65 int num_configs_left_; | 76 int num_configs_left_; |
66 int num_buffers_in_one_config_; | |
67 bool config_changes_; | |
68 bool is_encrypted_; | |
69 | 77 |
70 // Number of frames left with the current decoder config. | 78 // Number of frames left with the current decoder config. |
71 int num_buffers_left_in_current_config_; | 79 int num_buffers_left_in_current_config_; |
72 | 80 |
73 int num_buffers_returned_; | 81 int num_buffers_returned_; |
74 | 82 |
75 base::TimeDelta current_timestamp_; | 83 base::TimeDelta current_timestamp_; |
76 base::TimeDelta duration_; | 84 base::TimeDelta duration_; |
77 | 85 |
78 gfx::Size next_coded_size_; | 86 gfx::Size next_coded_size_; |
79 VideoDecoderConfig video_decoder_config_; | 87 VideoDecoderConfig video_decoder_config_; |
80 | 88 |
81 ReadCB read_cb_; | 89 ReadCB read_cb_; |
82 | 90 |
83 int next_read_num_; | 91 int next_read_num_; |
84 // Zero-based number indicating which read operation should be held. -1 means | 92 // Zero-based number indicating which read operation should be held. -1 means |
85 // no read shall be held. | 93 // no read shall be held. |
86 int read_to_hold_; | 94 int read_to_hold_; |
87 | 95 |
88 DISALLOW_COPY_AND_ASSIGN(FakeDemuxerStream); | 96 DISALLOW_COPY_AND_ASSIGN(FakeDemuxerStream); |
89 }; | 97 }; |
90 | 98 |
91 } // namespace media | 99 } // namespace media |
92 | 100 |
93 #endif // MEDIA_FILTERS_FAKE_DEMUXER_STREAM_H_ | 101 #endif // MEDIA_FILTERS_FAKE_DEMUXER_STREAM_H_ |
OLD | NEW |