| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_CAST_RECEIVER_FRAME_RECEIVER_H_ | 5 #ifndef MEDIA_CAST_RECEIVER_FRAME_RECEIVER_H_ |
| 6 #define MEDIA_CAST_RECEIVER_FRAME_RECEIVER_H_ | 6 #define MEDIA_CAST_RECEIVER_FRAME_RECEIVER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 // the sender, then receive and re-order packets on the receiver, then decode | 43 // the sender, then receive and re-order packets on the receiver, then decode |
| 44 // frame) can vary in duration and is typically very hard to predict. | 44 // frame) can vary in duration and is typically very hard to predict. |
| 45 // | 45 // |
| 46 // Each request for a frame includes a callback which FrameReceiver guarantees | 46 // Each request for a frame includes a callback which FrameReceiver guarantees |
| 47 // will be called at some point in the future unless the FrameReceiver is | 47 // will be called at some point in the future unless the FrameReceiver is |
| 48 // destroyed. Clients should generally limit the number of outstanding requests | 48 // destroyed. Clients should generally limit the number of outstanding requests |
| 49 // (perhaps to just one or two). | 49 // (perhaps to just one or two). |
| 50 // | 50 // |
| 51 // This class is not thread safe. Should only be called from the Main cast | 51 // This class is not thread safe. Should only be called from the Main cast |
| 52 // thread. | 52 // thread. |
| 53 class FrameReceiver : public RtpPayloadFeedback, | 53 class FrameReceiver : public RtpPayloadFeedback { |
| 54 public base::SupportsWeakPtr<FrameReceiver> { | |
| 55 public: | 54 public: |
| 56 FrameReceiver(const scoped_refptr<CastEnvironment>& cast_environment, | 55 FrameReceiver(const scoped_refptr<CastEnvironment>& cast_environment, |
| 57 const FrameReceiverConfig& config, | 56 const FrameReceiverConfig& config, |
| 58 EventMediaType event_media_type, | 57 EventMediaType event_media_type, |
| 59 CastTransport* const transport); | 58 CastTransport* const transport); |
| 60 | 59 |
| 61 ~FrameReceiver() final; | 60 ~FrameReceiver() final; |
| 62 | 61 |
| 63 // Request an encoded frame. | 62 // Request an encoded frame. |
| 64 // | 63 // |
| 65 // The given |callback| is guaranteed to be run at some point in the future, | 64 // The given |callback| is guaranteed to be run at some point in the future, |
| 66 // except for those requests still enqueued at destruction time. | 65 // except for those requests still enqueued at destruction time. |
| 67 void RequestEncodedFrame(const ReceiveEncodedFrameCallback& callback); | 66 void RequestEncodedFrame(const ReceiveEncodedFrameCallback& callback); |
| 68 | 67 |
| 69 // Called to deliver another packet, possibly a duplicate, and possibly | 68 // Called to deliver another packet, possibly a duplicate, and possibly |
| 70 // out-of-order. Returns true if the parsing of the packet succeeded. | 69 // out-of-order. Returns true if the parsing of the packet succeeded. |
| 71 bool ProcessPacket(std::unique_ptr<Packet> packet); | 70 bool ProcessPacket(std::unique_ptr<Packet> packet); |
| 72 | 71 |
| 72 base::WeakPtr<FrameReceiver> AsWeakPtr(); |
| 73 |
| 73 protected: | 74 protected: |
| 74 friend class FrameReceiverTest; // Invokes ProcessParsedPacket(). | 75 friend class FrameReceiverTest; // Invokes ProcessParsedPacket(). |
| 75 | 76 |
| 76 void ProcessParsedPacket(const RtpCastHeader& rtp_header, | 77 void ProcessParsedPacket(const RtpCastHeader& rtp_header, |
| 77 const uint8_t* payload_data, | 78 const uint8_t* payload_data, |
| 78 size_t payload_size); | 79 size_t payload_size); |
| 79 | 80 |
| 80 // RtpPayloadFeedback implementation. | 81 // RtpPayloadFeedback implementation. |
| 81 void CastFeedback(const RtcpCastMessage& cast_message) final; | 82 void CastFeedback(const RtcpCastMessage& cast_message) final; |
| 82 | 83 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 // NOTE: Weak pointers must be invalidated before all other member variables. | 205 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 205 base::WeakPtrFactory<FrameReceiver> weak_factory_; | 206 base::WeakPtrFactory<FrameReceiver> weak_factory_; |
| 206 | 207 |
| 207 DISALLOW_COPY_AND_ASSIGN(FrameReceiver); | 208 DISALLOW_COPY_AND_ASSIGN(FrameReceiver); |
| 208 }; | 209 }; |
| 209 | 210 |
| 210 } // namespace cast | 211 } // namespace cast |
| 211 } // namespace media | 212 } // namespace media |
| 212 | 213 |
| 213 #endif // MEDIA_CAST_RECEIVER_FRAME_RECEIVER_H_ | 214 #endif // MEDIA_CAST_RECEIVER_FRAME_RECEIVER_H_ |
| OLD | NEW |