| Alex Vakulenko | e4eec20 | 2017-01-27 14:41:04 -0800 | [diff] [blame] | 1 | #ifndef ANDROID_DVR_BUFFERHUBD_CONSUMER_CHANNEL_H_ | 
|  | 2 | #define ANDROID_DVR_BUFFERHUBD_CONSUMER_CHANNEL_H_ | 
|  | 3 |  | 
|  | 4 | #include "buffer_hub.h" | 
|  | 5 |  | 
|  | 6 | #include <pdx/rpc/buffer_wrapper.h> | 
|  | 7 | #include <private/dvr/bufferhub_rpc.h> | 
|  | 8 |  | 
|  | 9 | namespace android { | 
|  | 10 | namespace dvr { | 
|  | 11 |  | 
|  | 12 | // Consumer channels are attached to a Producer channel | 
|  | 13 | class ConsumerChannel : public BufferHubChannel { | 
|  | 14 | public: | 
|  | 15 | using Channel = pdx::Channel; | 
|  | 16 | using Message = pdx::Message; | 
|  | 17 |  | 
|  | 18 | ConsumerChannel(BufferHubService* service, int buffer_id, int channel_id, | 
|  | 19 | const std::shared_ptr<Channel> producer); | 
|  | 20 | ~ConsumerChannel() override; | 
|  | 21 |  | 
|  | 22 | bool HandleMessage(Message& message) override; | 
|  | 23 | void HandleImpulse(Message& message) override; | 
|  | 24 |  | 
|  | 25 | BufferInfo GetBufferInfo() const override; | 
|  | 26 |  | 
|  | 27 | bool OnProducerPosted(); | 
|  | 28 | void OnProducerClosed(); | 
|  | 29 |  | 
|  | 30 | private: | 
|  | 31 | using MetaData = pdx::rpc::BufferWrapper<std::uint8_t*>; | 
|  | 32 |  | 
|  | 33 | std::shared_ptr<ProducerChannel> GetProducer() const; | 
|  | 34 |  | 
| Corey Tabaka | cd52dd9 | 2017-04-07 18:03:57 -0700 | [diff] [blame] | 35 | pdx::Status<std::pair<BorrowedFence, MetaData>> OnConsumerAcquire( | 
| Alex Vakulenko | e4eec20 | 2017-01-27 14:41:04 -0800 | [diff] [blame] | 36 | Message& message, std::size_t metadata_size); | 
| Corey Tabaka | cd52dd9 | 2017-04-07 18:03:57 -0700 | [diff] [blame] | 37 | pdx::Status<void> OnConsumerRelease(Message& message, | 
|  | 38 | LocalFence release_fence); | 
|  | 39 | pdx::Status<void> OnConsumerSetIgnore(Message& message, bool ignore); | 
| Alex Vakulenko | e4eec20 | 2017-01-27 14:41:04 -0800 | [diff] [blame] | 40 |  | 
|  | 41 | bool handled_;  // True if we have processed RELEASE. | 
|  | 42 | bool ignored_;  // True if we are ignoring events. | 
|  | 43 | std::weak_ptr<Channel> producer_; | 
|  | 44 |  | 
|  | 45 | ConsumerChannel(const ConsumerChannel&) = delete; | 
|  | 46 | void operator=(const ConsumerChannel&) = delete; | 
|  | 47 | }; | 
|  | 48 |  | 
|  | 49 | }  // namespace dvr | 
|  | 50 | }  // namespace android | 
|  | 51 |  | 
|  | 52 | #endif  // ANDROID_DVR_BUFFERHUBD_CONSUMER_CHANNEL_H_ |