| 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 "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 // (perhaps to just one or two). | 43 // (perhaps to just one or two). |
| 44 // | 44 // |
| 45 // This class is not thread safe. Should only be called from the Main cast | 45 // This class is not thread safe. Should only be called from the Main cast |
| 46 // thread. | 46 // thread. |
| 47 class FrameReceiver : public RtpPayloadFeedback, | 47 class FrameReceiver : public RtpPayloadFeedback, |
| 48 public base::SupportsWeakPtr<FrameReceiver> { | 48 public base::SupportsWeakPtr<FrameReceiver> { |
| 49 public: | 49 public: |
| 50 FrameReceiver(const scoped_refptr<CastEnvironment>& cast_environment, | 50 FrameReceiver(const scoped_refptr<CastEnvironment>& cast_environment, |
| 51 const FrameReceiverConfig& config, | 51 const FrameReceiverConfig& config, |
| 52 EventMediaType event_media_type, | 52 EventMediaType event_media_type, |
| 53 PacedPacketSender* const packet_sender); | 53 CastTransportSender* const transport); |
| 54 | 54 |
| 55 ~FrameReceiver() override; | 55 ~FrameReceiver() override; |
| 56 | 56 |
| 57 // Request an encoded frame. | 57 // Request an encoded frame. |
| 58 // | 58 // |
| 59 // The given |callback| is guaranteed to be run at some point in the future, | 59 // The given |callback| is guaranteed to be run at some point in the future, |
| 60 // except for those requests still enqueued at destruction time. | 60 // except for those requests still enqueued at destruction time. |
| 61 void RequestEncodedFrame(const ReceiveEncodedFrameCallback& callback); | 61 void RequestEncodedFrame(const ReceiveEncodedFrameCallback& callback); |
| 62 | 62 |
| 63 // Called to deliver another packet, possibly a duplicate, and possibly | 63 // Called to deliver another packet, possibly a duplicate, and possibly |
| 64 // out-of-order. Returns true if the parsing of the packet succeeded. | 64 // out-of-order. Returns true if the parsing of the packet succeeded. |
| 65 bool ProcessPacket(scoped_ptr<Packet> packet); | 65 bool ProcessPacket(scoped_ptr<Packet> packet); |
| 66 | 66 |
| 67 // TODO(miu): This is the wrong place for this, but the (de)serialization | |
| 68 // implementation needs to be consolidated first. | |
| 69 static bool ParseSenderSsrc(const uint8* packet, size_t length, uint32* ssrc); | |
| 70 | |
| 71 protected: | 67 protected: |
| 72 friend class FrameReceiverTest; // Invokes ProcessParsedPacket(). | 68 friend class FrameReceiverTest; // Invokes ProcessParsedPacket(). |
| 73 | 69 |
| 74 void ProcessParsedPacket(const RtpCastHeader& rtp_header, | 70 void ProcessParsedPacket(const RtpCastHeader& rtp_header, |
| 75 const uint8* payload_data, | 71 const uint8* payload_data, |
| 76 size_t payload_size); | 72 size_t payload_size); |
| 77 | 73 |
| 78 // RtpPayloadFeedback implementation. | 74 // RtpPayloadFeedback implementation. |
| 79 void CastFeedback(const RtcpCastMessage& cast_message) override; | 75 void CastFeedback(const RtcpCastMessage& cast_message) override; |
| 80 | 76 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 108 void ScheduleNextRtcpReport(); | 104 void ScheduleNextRtcpReport(); |
| 109 | 105 |
| 110 // Actually send the next cast message. | 106 // Actually send the next cast message. |
| 111 void SendNextCastMessage(); | 107 void SendNextCastMessage(); |
| 112 | 108 |
| 113 // Actually send the next RTCP report. | 109 // Actually send the next RTCP report. |
| 114 void SendNextRtcpReport(); | 110 void SendNextRtcpReport(); |
| 115 | 111 |
| 116 const scoped_refptr<CastEnvironment> cast_environment_; | 112 const scoped_refptr<CastEnvironment> cast_environment_; |
| 117 | 113 |
| 114 // Transport used to send data back. |
| 115 CastTransportSender* const transport_; |
| 116 |
| 118 // Deserializes a packet into a RtpHeader + payload bytes. | 117 // Deserializes a packet into a RtpHeader + payload bytes. |
| 119 RtpParser packet_parser_; | 118 RtpParser packet_parser_; |
| 120 | 119 |
| 121 // Accumulates packet statistics, including packet loss, counts, and jitter. | 120 // Accumulates packet statistics, including packet loss, counts, and jitter. |
| 122 ReceiverStats stats_; | 121 ReceiverStats stats_; |
| 123 | 122 |
| 124 // Partitions logged events by the type of media passing through. | 123 // Partitions logged events by the type of media passing through. |
| 125 EventMediaType event_media_type_; | 124 EventMediaType event_media_type_; |
| 126 | 125 |
| 127 // Subscribes to raw events. | 126 // Subscribes to raw events. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 // NOTE: Weak pointers must be invalidated before all other member variables. | 184 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 186 base::WeakPtrFactory<FrameReceiver> weak_factory_; | 185 base::WeakPtrFactory<FrameReceiver> weak_factory_; |
| 187 | 186 |
| 188 DISALLOW_COPY_AND_ASSIGN(FrameReceiver); | 187 DISALLOW_COPY_AND_ASSIGN(FrameReceiver); |
| 189 }; | 188 }; |
| 190 | 189 |
| 191 } // namespace cast | 190 } // namespace cast |
| 192 } // namespace media | 191 } // namespace media |
| 193 | 192 |
| 194 #endif // MEDIA_CAST_RECEIVER_FRAME_RECEIVER_H_ | 193 #endif // MEDIA_CAST_RECEIVER_FRAME_RECEIVER_H_ |
| OLD | NEW |