Index: media/cast/video_receiver/video_receiver.h |
diff --git a/media/cast/video_receiver/video_receiver.h b/media/cast/video_receiver/video_receiver.h |
index ff7ccda9e455ade847b167a9fb5cffb49226e26b..360e7460c98ea39e466a662001ebb9727a87fd26 100644 |
--- a/media/cast/video_receiver/video_receiver.h |
+++ b/media/cast/video_receiver/video_receiver.h |
@@ -13,6 +13,7 @@ |
#include "base/threading/non_thread_safe.h" |
#include "base/time/tick_clock.h" |
#include "base/time/time.h" |
+#include "media/cast/base/clock_drift_smoother.h" |
#include "media/cast/cast_config.h" |
#include "media/cast/cast_environment.h" |
#include "media/cast/cast_receiver.h" |
@@ -41,10 +42,6 @@ class VideoDecoder; |
// each step of the pipeline (i.e., encode frame, then transmit/retransmit from |
// the sender, then receive and re-order packets on the receiver, then decode |
// frame) can vary in duration and is typically very hard to predict. |
-// Heuristics will determine when the targeted playout delay is insufficient in |
-// the current environment; and the receiver can then increase the playout |
-// delay, notifying the sender, to account for the extra variance. |
-// TODO(miu): Make the last sentence true. http://crbug.com/360111 |
// |
// Two types of frames can be requested: 1) A frame of decoded video data; or 2) |
// a frame of still-encoded video data, to be passed into an external video |
@@ -82,7 +79,7 @@ class VideoReceiver : public RtpReceiver, |
void IncomingPacket(scoped_ptr<Packet> packet); |
protected: |
- friend class VideoReceiverTest; // Invoked OnReceivedPayloadData(). |
+ friend class VideoReceiverTest; // Invokes OnReceivedPayloadData(). |
virtual void OnReceivedPayloadData(const uint8* payload_data, |
size_t payload_size, |
@@ -108,10 +105,10 @@ class VideoReceiver : public RtpReceiver, |
const VideoFrameDecodedCallback& callback, |
scoped_ptr<transport::EncodedFrame> encoded_frame); |
- // Return the playout time based on the current time and rtp timestamp. |
- base::TimeTicks GetPlayoutTime(base::TimeTicks now, uint32 rtp_timestamp); |
- |
- void InitializeTimers(); |
+ // Computes the playout time for a frame with the given |rtp_timestamp|. |
+ // Because lip-sync info is refreshed regularly, calling this method with the |
+ // same argument may return different results. |
+ base::TimeTicks GetPlayoutTime(uint32 rtp_timestamp) const; |
// Schedule timing for the next cast message. |
void ScheduleNextCastMessage(); |
@@ -145,17 +142,38 @@ class VideoReceiver : public RtpReceiver, |
// Processes raw audio events to be sent over to the cast sender via RTCP. |
ReceiverRtcpEventSubscriber event_subscriber_; |
+ // Configured audio codec. |
const transport::VideoCodec codec_; |
- const base::TimeDelta target_delay_delta_; |
+ |
+ // The total amount of time between a frame's capture/recording on the sender |
+ // and its playback on the receiver (i.e., shown to a user). This is fixed as |
+ // a value large enough to give the system sufficient time to encode, |
+ // transmit/retransmit, receive, decode, and render; given its run-time |
+ // environment (sender/receiver hardware performance, network conditions, |
+ // etc.). |
+ const base::TimeDelta target_playout_delay_; |
+ |
+ // Hack: This is used in logic that determines whether to skip frames. |
const base::TimeDelta expected_frame_duration_; |
+ |
+ // Set to false initially, then set to true after scheduling the periodic |
+ // sending of reports back to the sender. Reports are first scheduled just |
+ // after receiving a first packet (since the first packet identifies the |
+ // sender for the remainder of the session). |
+ bool reports_are_scheduled_; |
+ |
+ // Assembles packets into frames, providing this receiver with complete, |
+ // decodable EncodedFrames. |
Framer framer_; |
+ |
+ // Decodes frames into media::VideoFrame images for playback. |
scoped_ptr<VideoDecoder> video_decoder_; |
+ |
+ // Manages sending/receiving of RTCP packets, including sender/receiver |
+ // reports. |
Rtcp rtcp_; |
- base::TimeDelta time_offset_; // Sender-receiver offset estimation. |
- int time_offset_counter_; |
- bool time_incoming_packet_updated_; |
- base::TimeTicks time_incoming_packet_; |
- uint32 incoming_rtp_timestamp_; |
+ |
+ // Decrypts encrypted frames. |
transport::TransportEncryptionHandler decryptor_; |
// Outstanding callbacks to run to deliver on client requests for frames. |
@@ -169,6 +187,13 @@ class VideoReceiver : public RtpReceiver, |
// it allows the event to be transmitted via RTCP. |
RtpTimestamp frame_id_to_rtp_timestamp_[256]; |
+ // Lip-sync values used to compute the playout time of each frame from its RTP |
+ // timestamp. These are updated each time the first packet of a frame is |
+ // received. |
+ RtpTimestamp lip_sync_rtp_timestamp_; |
+ base::TimeTicks lip_sync_reference_time_; |
+ ClockDriftSmoother lip_sync_drift_; |
+ |
// NOTE: Weak pointers must be invalidated before all other member variables. |
base::WeakPtrFactory<VideoReceiver> weak_factory_; |