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_BASE_FAKE_DEMUXER_STREAM_H_ | 5 #ifndef MEDIA_BASE_FAKE_DEMUXER_STREAM_H_ |
6 #define MEDIA_BASE_FAKE_DEMUXER_STREAM_H_ | 6 #define MEDIA_BASE_FAKE_DEMUXER_STREAM_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.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" |
11 #include "media/base/demuxer_stream.h" | 11 #include "media/base/demuxer_stream.h" |
12 #include "media/base/demuxer_stream_provider.h" | 12 #include "media/base/media_resource.h" |
13 #include "media/base/video_decoder_config.h" | 13 #include "media/base/video_decoder_config.h" |
14 | 14 |
15 namespace base { | 15 namespace base { |
16 class SingleThreadTaskRunner; | 16 class SingleThreadTaskRunner; |
17 } // namespace base | 17 } // namespace base |
18 | 18 |
19 namespace media { | 19 namespace media { |
20 | 20 |
21 class FakeDemuxerStream : public DemuxerStream { | 21 class FakeDemuxerStream : public DemuxerStream { |
22 public: | 22 public: |
23 // Constructs an object that outputs |num_configs| different configs in | 23 // Constructs an object that outputs |num_configs| different configs in |
24 // sequence with |num_frames_in_one_config| buffers for each config. The | 24 // sequence with |num_frames_in_one_config| buffers for each config. The |
25 // output buffers are encrypted if |is_encrypted| is true. | 25 // output buffers are encrypted if |is_encrypted| is true. |
26 FakeDemuxerStream(int num_configs, | 26 FakeDemuxerStream(int num_configs, |
27 int num_buffers_in_one_config, | 27 int num_buffers_in_one_config, |
28 bool is_encrypted); | 28 bool is_encrypted); |
29 ~FakeDemuxerStream() override; | 29 ~FakeDemuxerStream() override; |
30 | 30 |
31 // DemuxerStream implementation. | 31 // DemuxerStream implementation. |
32 void Read(const ReadCB& read_cb) override; | 32 void Read(const ReadCB& read_cb) override; |
33 AudioDecoderConfig audio_decoder_config() override; | 33 AudioDecoderConfig audio_decoder_config() override; |
34 VideoDecoderConfig video_decoder_config() override; | 34 VideoDecoderConfig video_decoder_config() override; |
35 Type type() const override; | 35 Type type() const override; |
36 bool SupportsConfigChanges() override; | 36 bool SupportsConfigChanges() override; |
37 VideoRotation video_rotation() override; | 37 VideoRotation video_rotation() override; |
38 bool enabled() const override; | 38 bool enabled() const override; |
39 void set_enabled(bool enabled, base::TimeDelta timestamp) override; | 39 void set_enabled(bool enabled, base::TimeDelta timestamp) override; |
40 void SetStreamStatusChangeCB(const StreamStatusChangeCB& cb) override; | |
41 | 40 |
42 void Initialize(); | 41 void Initialize(); |
43 | 42 |
44 int num_buffers_returned() const { return num_buffers_returned_; } | 43 int num_buffers_returned() const { return num_buffers_returned_; } |
45 | 44 |
46 // Upon the next read, holds the read callback until SatisfyRead() or Reset() | 45 // Upon the next read, holds the read callback until SatisfyRead() or Reset() |
47 // is called. | 46 // is called. |
48 void HoldNextRead(); | 47 void HoldNextRead(); |
49 | 48 |
50 // Upon the next config change read, holds the read callback until | 49 // Upon the next config change read, holds the read callback until |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 ReadCB read_cb_; | 95 ReadCB read_cb_; |
97 | 96 |
98 int next_read_num_; | 97 int next_read_num_; |
99 // Zero-based number indicating which read operation should be held. -1 means | 98 // Zero-based number indicating which read operation should be held. -1 means |
100 // no read shall be held. | 99 // no read shall be held. |
101 int read_to_hold_; | 100 int read_to_hold_; |
102 | 101 |
103 DISALLOW_COPY_AND_ASSIGN(FakeDemuxerStream); | 102 DISALLOW_COPY_AND_ASSIGN(FakeDemuxerStream); |
104 }; | 103 }; |
105 | 104 |
106 class FakeDemuxerStreamProvider : public DemuxerStreamProvider { | 105 class FakeMediaResource : public MediaResource { |
107 public: | 106 public: |
108 // Note: FakeDemuxerStream currently only supports a fake video DemuxerStream. | 107 // Note: FakeDemuxerStream currently only supports a fake video DemuxerStream. |
109 FakeDemuxerStreamProvider(int num_video_configs, | 108 FakeMediaResource(int num_video_configs, |
110 int num_video_buffers_in_one_config, | 109 int num_video_buffers_in_one_config, |
111 bool is_video_encrypted); | 110 bool is_video_encrypted); |
112 ~FakeDemuxerStreamProvider() override; | 111 ~FakeMediaResource() override; |
113 | 112 |
114 // DemuxerStreamProvider implementation. | 113 // MediaResource implementation. |
115 DemuxerStream* GetStream(DemuxerStream::Type type) override; | 114 std::vector<DemuxerStream*> GetStreams() override; |
| 115 void SetStreamStatusChangeCB(const StreamStatusChangeCB& cb) override; |
116 | 116 |
117 private: | 117 private: |
118 FakeDemuxerStream fake_video_stream_; | 118 FakeDemuxerStream fake_video_stream_; |
119 | 119 |
120 DISALLOW_COPY_AND_ASSIGN(FakeDemuxerStreamProvider); | 120 DISALLOW_COPY_AND_ASSIGN(FakeMediaResource); |
121 }; | 121 }; |
122 | 122 |
123 } // namespace media | 123 } // namespace media |
124 | 124 |
125 #endif // MEDIA_BASE_FAKE_DEMUXER_STREAM_H_ | 125 #endif // MEDIA_BASE_FAKE_DEMUXER_STREAM_H_ |
OLD | NEW |