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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 PacedPacketSender* const packet_sender); |
54 | 54 |
55 virtual ~FrameReceiver(); | 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 | 67 // TODO(miu): This is the wrong place for this, but the (de)serialization |
68 // implementation needs to be consolidated first. | 68 // implementation needs to be consolidated first. |
69 static bool ParseSenderSsrc(const uint8* packet, size_t length, uint32* ssrc); | 69 static bool ParseSenderSsrc(const uint8* packet, size_t length, uint32* ssrc); |
70 | 70 |
71 protected: | 71 protected: |
72 friend class FrameReceiverTest; // Invokes ProcessParsedPacket(). | 72 friend class FrameReceiverTest; // Invokes ProcessParsedPacket(). |
73 | 73 |
74 void ProcessParsedPacket(const RtpCastHeader& rtp_header, | 74 void ProcessParsedPacket(const RtpCastHeader& rtp_header, |
75 const uint8* payload_data, | 75 const uint8* payload_data, |
76 size_t payload_size); | 76 size_t payload_size); |
77 | 77 |
78 // RtpPayloadFeedback implementation. | 78 // RtpPayloadFeedback implementation. |
79 virtual void CastFeedback(const RtcpCastMessage& cast_message) override; | 79 void CastFeedback(const RtcpCastMessage& cast_message) override; |
80 | 80 |
81 private: | 81 private: |
82 // Processes ready-to-consume packets from |framer_|, decrypting each packet's | 82 // Processes ready-to-consume packets from |framer_|, decrypting each packet's |
83 // payload data, and then running the enqueued callbacks in order (one for | 83 // payload data, and then running the enqueued callbacks in order (one for |
84 // each packet). This method may post a delayed task to re-invoke itself in | 84 // each packet). This method may post a delayed task to re-invoke itself in |
85 // the future to wait for missing/incomplete frames. | 85 // the future to wait for missing/incomplete frames. |
86 void EmitAvailableEncodedFrames(); | 86 void EmitAvailableEncodedFrames(); |
87 | 87 |
88 // Clears the |is_waiting_for_consecutive_frame_| flag and invokes | 88 // Clears the |is_waiting_for_consecutive_frame_| flag and invokes |
89 // EmitAvailableEncodedFrames(). | 89 // EmitAvailableEncodedFrames(). |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 // NOTE: Weak pointers must be invalidated before all other member variables. | 185 // NOTE: Weak pointers must be invalidated before all other member variables. |
186 base::WeakPtrFactory<FrameReceiver> weak_factory_; | 186 base::WeakPtrFactory<FrameReceiver> weak_factory_; |
187 | 187 |
188 DISALLOW_COPY_AND_ASSIGN(FrameReceiver); | 188 DISALLOW_COPY_AND_ASSIGN(FrameReceiver); |
189 }; | 189 }; |
190 | 190 |
191 } // namespace cast | 191 } // namespace cast |
192 } // namespace media | 192 } // namespace media |
193 | 193 |
194 #endif // MEDIA_CAST_RECEIVER_FRAME_RECEIVER_H_ | 194 #endif // MEDIA_CAST_RECEIVER_FRAME_RECEIVER_H_ |
OLD | NEW |