| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef MEDIA_REMOTING_FAKE_REMOTING_CONTROLLER_H_ | |
| 6 #define MEDIA_REMOTING_FAKE_REMOTING_CONTROLLER_H_ | |
| 7 | |
| 8 #include "media/base/decoder_buffer.h" | |
| 9 #include "media/mojo/interfaces/remoting.mojom.h" | |
| 10 #include "mojo/public/cpp/bindings/binding.h" | |
| 11 | |
| 12 namespace media { | |
| 13 | |
| 14 class RemotingSourceImpl; | |
| 15 | |
| 16 class FakeRemotingDataStreamSender : public mojom::RemotingDataStreamSender { | |
| 17 public: | |
| 18 FakeRemotingDataStreamSender( | |
| 19 mojom::RemotingDataStreamSenderRequest request, | |
| 20 mojo::ScopedDataPipeConsumerHandle consumer_handle); | |
| 21 ~FakeRemotingDataStreamSender() override; | |
| 22 | |
| 23 uint32_t consume_data_chunk_count() const { | |
| 24 return consume_data_chunk_count_; | |
| 25 } | |
| 26 uint32_t send_frame_count() const { return send_frame_count_; } | |
| 27 uint32_t cancel_in_flight_count() const { return cancel_in_flight_count_; } | |
| 28 void ResetHistory(); | |
| 29 bool ValidateFrameBuffer(size_t index, | |
| 30 size_t size, | |
| 31 bool key_frame, | |
| 32 int pts_ms); | |
| 33 | |
| 34 private: | |
| 35 // mojom::RemotingDataStreamSender implementation. | |
| 36 void ConsumeDataChunk(uint32_t offset, | |
| 37 uint32_t size, | |
| 38 uint32_t total_payload_size) final; | |
| 39 void SendFrame() final; | |
| 40 void CancelInFlightData() final; | |
| 41 | |
| 42 mojo::Binding<RemotingDataStreamSender> binding_; | |
| 43 mojo::ScopedDataPipeConsumerHandle consumer_handle_; | |
| 44 | |
| 45 std::vector<uint8_t> next_frame_data_; | |
| 46 std::vector<std::vector<uint8_t>> received_frame_list; | |
| 47 uint32_t consume_data_chunk_count_; | |
| 48 uint32_t send_frame_count_; | |
| 49 uint32_t cancel_in_flight_count_; | |
| 50 | |
| 51 DISALLOW_COPY_AND_ASSIGN(FakeRemotingDataStreamSender); | |
| 52 }; | |
| 53 | |
| 54 class FakeRemoter final : public mojom::Remoter { | |
| 55 public: | |
| 56 // |start_will_fail| indicates whether starting remoting will fail. | |
| 57 FakeRemoter(mojom::RemotingSourcePtr source, bool start_will_fail); | |
| 58 ~FakeRemoter() override; | |
| 59 | |
| 60 // mojom::Remoter implementations. | |
| 61 void Start() override; | |
| 62 void StartDataStreams( | |
| 63 mojo::ScopedDataPipeConsumerHandle audio_pipe, | |
| 64 mojo::ScopedDataPipeConsumerHandle video_pipe, | |
| 65 mojom::RemotingDataStreamSenderRequest audio_sender_request, | |
| 66 mojom::RemotingDataStreamSenderRequest video_sender_request) override; | |
| 67 void Stop(mojom::RemotingStopReason reason) override; | |
| 68 void SendMessageToSink(const std::vector<uint8_t>& message) override; | |
| 69 | |
| 70 private: | |
| 71 void Started(); | |
| 72 void StartFailed(); | |
| 73 void Stopped(mojom::RemotingStopReason reason); | |
| 74 | |
| 75 mojom::RemotingSourcePtr source_; | |
| 76 bool start_will_fail_; | |
| 77 | |
| 78 std::unique_ptr<FakeRemotingDataStreamSender> audio_stream_sender_; | |
| 79 std::unique_ptr<FakeRemotingDataStreamSender> video_stream_sender_; | |
| 80 | |
| 81 base::WeakPtrFactory<FakeRemoter> weak_factory_; | |
| 82 | |
| 83 DISALLOW_COPY_AND_ASSIGN(FakeRemoter); | |
| 84 }; | |
| 85 | |
| 86 class FakeRemoterFactory final : public mojom::RemoterFactory { | |
| 87 public: | |
| 88 // |start_will_fail| indicates whether starting remoting will fail. | |
| 89 explicit FakeRemoterFactory(bool start_will_fail); | |
| 90 ~FakeRemoterFactory() override; | |
| 91 | |
| 92 // mojom::RemoterFactory implementation. | |
| 93 void Create(mojom::RemotingSourcePtr source, | |
| 94 mojom::RemoterRequest request) override; | |
| 95 | |
| 96 private: | |
| 97 bool start_will_fail_; | |
| 98 | |
| 99 DISALLOW_COPY_AND_ASSIGN(FakeRemoterFactory); | |
| 100 }; | |
| 101 | |
| 102 scoped_refptr<RemotingSourceImpl> CreateRemotingSourceImpl( | |
| 103 bool start_will_fail); | |
| 104 | |
| 105 } // namespace media | |
| 106 | |
| 107 #endif // MEDIA_REMOTING_FAKE_REMOTING_CONTROLLER_H_ | |
| OLD | NEW |