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" |
11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
12 #include "media/cast/base/clock_drift_smoother.h" | |
13 #include "media/cast/cast_config.h" | 12 #include "media/cast/cast_config.h" |
14 #include "media/cast/cast_receiver.h" | 13 #include "media/cast/cast_receiver.h" |
15 #include "media/cast/framer/framer.h" | 14 #include "media/cast/common/clock_drift_smoother.h" |
| 15 #include "media/cast/common/transport_encryption_handler.h" |
16 #include "media/cast/logging/logging_defines.h" | 16 #include "media/cast/logging/logging_defines.h" |
17 #include "media/cast/rtcp/receiver_rtcp_event_subscriber.h" | 17 #include "media/cast/net/rtcp/receiver_rtcp_event_subscriber.h" |
18 #include "media/cast/rtcp/rtcp.h" | 18 #include "media/cast/net/rtcp/rtcp.h" |
19 #include "media/cast/rtp_receiver/receiver_stats.h" | 19 #include "media/cast/net/rtp/framer.h" |
20 #include "media/cast/rtp_receiver/rtp_parser/rtp_parser.h" | 20 #include "media/cast/net/rtp/receiver_stats.h" |
21 #include "media/cast/rtp_receiver/rtp_receiver_defines.h" | 21 #include "media/cast/net/rtp/rtp_parser.h" |
22 #include "media/cast/transport/utility/transport_encryption_handler.h" | 22 #include "media/cast/net/rtp/rtp_receiver_defines.h" |
23 | 23 |
24 namespace media { | 24 namespace media { |
25 namespace cast { | 25 namespace cast { |
26 | 26 |
27 class CastEnvironment; | 27 class CastEnvironment; |
28 | 28 |
29 // FrameReceiver receives packets out-of-order while clients make requests for | 29 // FrameReceiver receives packets out-of-order while clients make requests for |
30 // complete frames in-order. (A frame consists of one or more packets.) | 30 // complete frames in-order. (A frame consists of one or more packets.) |
31 // | 31 // |
32 // FrameReceiver also includes logic for computing the playout time for each | 32 // FrameReceiver also includes logic for computing the playout time for each |
(...skipping 10 matching lines...) Expand all 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 transport::PacedPacketSender* const packet_sender); | 53 PacedPacketSender* const packet_sender); |
54 | 54 |
55 virtual ~FrameReceiver(); | 55 virtual ~FrameReceiver(); |
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 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 | 145 |
146 // Assembles packets into frames, providing this receiver with complete, | 146 // Assembles packets into frames, providing this receiver with complete, |
147 // decodable EncodedFrames. | 147 // decodable EncodedFrames. |
148 Framer framer_; | 148 Framer framer_; |
149 | 149 |
150 // Manages sending/receiving of RTCP packets, including sender/receiver | 150 // Manages sending/receiving of RTCP packets, including sender/receiver |
151 // reports. | 151 // reports. |
152 Rtcp rtcp_; | 152 Rtcp rtcp_; |
153 | 153 |
154 // Decrypts encrypted frames. | 154 // Decrypts encrypted frames. |
155 transport::TransportEncryptionHandler decryptor_; | 155 TransportEncryptionHandler decryptor_; |
156 | 156 |
157 // Outstanding callbacks to run to deliver on client requests for frames. | 157 // Outstanding callbacks to run to deliver on client requests for frames. |
158 std::list<ReceiveEncodedFrameCallback> frame_request_queue_; | 158 std::list<ReceiveEncodedFrameCallback> frame_request_queue_; |
159 | 159 |
160 // True while there's an outstanding task to re-invoke | 160 // True while there's an outstanding task to re-invoke |
161 // EmitAvailableEncodedFrames(). | 161 // EmitAvailableEncodedFrames(). |
162 bool is_waiting_for_consecutive_frame_; | 162 bool is_waiting_for_consecutive_frame_; |
163 | 163 |
164 // This mapping allows us to log FRAME_ACK_SENT as a frame event. In addition | 164 // This mapping allows us to log FRAME_ACK_SENT as a frame event. In addition |
165 // it allows the event to be transmitted via RTCP. | 165 // it allows the event to be transmitted via RTCP. |
166 RtpTimestamp frame_id_to_rtp_timestamp_[256]; | 166 RtpTimestamp frame_id_to_rtp_timestamp_[256]; |
167 | 167 |
168 // Lip-sync values used to compute the playout time of each frame from its RTP | 168 // Lip-sync values used to compute the playout time of each frame from its RTP |
169 // timestamp. These are updated each time the first packet of a frame is | 169 // timestamp. These are updated each time the first packet of a frame is |
170 // received. | 170 // received. |
171 RtpTimestamp lip_sync_rtp_timestamp_; | 171 RtpTimestamp lip_sync_rtp_timestamp_; |
172 base::TimeTicks lip_sync_reference_time_; | 172 base::TimeTicks lip_sync_reference_time_; |
173 ClockDriftSmoother lip_sync_drift_; | 173 ClockDriftSmoother lip_sync_drift_; |
174 | 174 |
175 // NOTE: Weak pointers must be invalidated before all other member variables. | 175 // NOTE: Weak pointers must be invalidated before all other member variables. |
176 base::WeakPtrFactory<FrameReceiver> weak_factory_; | 176 base::WeakPtrFactory<FrameReceiver> weak_factory_; |
177 | 177 |
178 DISALLOW_COPY_AND_ASSIGN(FrameReceiver); | 178 DISALLOW_COPY_AND_ASSIGN(FrameReceiver); |
179 }; | 179 }; |
180 | 180 |
181 } // namespace cast | 181 } // namespace cast |
182 } // namespace media | 182 } // namespace media |
183 | 183 |
184 #endif // MEDIA_CAST_RECEIVER_FRAME_RECEIVER_H_ | 184 #endif // MEDIA_CAST_RECEIVER_FRAME_RECEIVER_H_ |
OLD | NEW |