1 // Copyright 2016 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef MEDIA_REMOTING_FAKE_MEDIA_RESOURCE_H_
6 #define MEDIA_REMOTING_FAKE_MEDIA_RESOURCE_H_
10 #include "base/containers/circular_deque.h"
11 #include "media/base/audio_decoder_config.h"
12 #include "media/base/demuxer_stream.h"
13 #include "media/base/media_resource.h"
14 #include "media/base/video_decoder_config.h"
15 #include "testing/gmock/include/gmock/gmock.h"
20 class FakeDemuxerStream : public DemuxerStream {
22 explicit FakeDemuxerStream(bool is_audio);
24 FakeDemuxerStream(const FakeDemuxerStream&) = delete;
25 FakeDemuxerStream& operator=(const FakeDemuxerStream&) = delete;
27 ~FakeDemuxerStream() override;
29 // DemuxerStream implementation.
30 MOCK_METHOD2(Read, void(uint32_t count, ReadCB read_cb));
31 void FakeRead(uint32_t count, ReadCB read_cb);
32 AudioDecoderConfig audio_decoder_config() override;
33 VideoDecoderConfig video_decoder_config() override;
34 Type type() const override;
35 StreamLiveness liveness() const override;
36 void EnableBitstreamConverter() override {}
37 bool SupportsConfigChanges() override;
39 void CreateFakeFrame(size_t size, bool key_frame, int pts_ms);
42 using BufferQueue = base::circular_deque<scoped_refptr<DecoderBuffer>>;
43 BufferQueue buffer_queue_;
44 ReadCB pending_read_cb_;
46 AudioDecoderConfig audio_config_;
47 VideoDecoderConfig video_config_;
50 // Audio only demuxer stream provider
51 class FakeMediaResource final : public MediaResource {
55 FakeMediaResource(const FakeMediaResource&) = delete;
56 FakeMediaResource& operator=(const FakeMediaResource&) = delete;
58 ~FakeMediaResource() override;
60 // MediaResource implementation.
61 std::vector<DemuxerStream*> GetAllStreams() override;
64 std::unique_ptr<FakeDemuxerStream> audio_stream_;
65 std::unique_ptr<FakeDemuxerStream> video_stream_;
68 } // namespace remoting
71 #endif // MEDIA_REMOTING_FAKE_MEDIA_RESOURCE_H_