| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_VIDEO_RECEIVER_VIDEO_RECEIVER_H_ | 5 #ifndef MEDIA_CAST_VIDEO_RECEIVER_VIDEO_RECEIVER_H_ |
| 6 #define MEDIA_CAST_VIDEO_RECEIVER_VIDEO_RECEIVER_H_ | 6 #define MEDIA_CAST_VIDEO_RECEIVER_VIDEO_RECEIVER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 namespace cast { | 26 namespace cast { |
| 27 | 27 |
| 28 class Framer; | 28 class Framer; |
| 29 class LocalRtpVideoData; | 29 class LocalRtpVideoData; |
| 30 class LocalRtpVideoFeedback; | 30 class LocalRtpVideoFeedback; |
| 31 class PeerVideoReceiver; | 31 class PeerVideoReceiver; |
| 32 class Rtcp; | 32 class Rtcp; |
| 33 class RtpReceiverStatistics; | 33 class RtpReceiverStatistics; |
| 34 class VideoDecoder; | 34 class VideoDecoder; |
| 35 | 35 |
| 36 // Callback used by the video receiver to inform the audio receiver of the new |
| 37 // delay used to compute the playout and render times. |
| 38 typedef base::Callback<void(base::TimeDelta)> SetTargetDelayCallback; |
| 39 |
| 36 // Should only be called from the Main cast thread. | 40 // Should only be called from the Main cast thread. |
| 37 class VideoReceiver : public base::NonThreadSafe, | 41 class VideoReceiver : public base::NonThreadSafe, |
| 38 public base::SupportsWeakPtr<VideoReceiver> { | 42 public base::SupportsWeakPtr<VideoReceiver> { |
| 39 public: | 43 public: |
| 40 VideoReceiver(scoped_refptr<CastEnvironment> cast_environment, | 44 VideoReceiver(scoped_refptr<CastEnvironment> cast_environment, |
| 41 const VideoReceiverConfig& video_config, | 45 const VideoReceiverConfig& video_config, |
| 42 transport::PacedPacketSender* const packet_sender); | 46 transport::PacedPacketSender* const packet_sender, |
| 47 const SetTargetDelayCallback& target_delay_cb); |
| 43 | 48 |
| 44 virtual ~VideoReceiver(); | 49 virtual ~VideoReceiver(); |
| 45 | 50 |
| 46 // Request a raw frame. Will return frame via callback when available. | 51 // Request a raw frame. Will return frame via callback when available. |
| 47 void GetRawVideoFrame(const VideoFrameDecodedCallback& callback); | 52 void GetRawVideoFrame(const VideoFrameDecodedCallback& callback); |
| 48 | 53 |
| 49 // Request an encoded frame. Will return frame via callback when available. | 54 // Request an encoded frame. Will return frame via callback when available. |
| 50 void GetEncodedVideoFrame(const VideoFrameEncodedCallback& callback); | 55 void GetEncodedVideoFrame(const VideoFrameEncodedCallback& callback); |
| 51 | 56 |
| 52 // Insert a RTP packet to the video receiver. | 57 // Insert a RTP packet to the video receiver. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 | 96 |
| 92 // Schedule timing for the next RTCP report. | 97 // Schedule timing for the next RTCP report. |
| 93 void ScheduleNextRtcpReport(); | 98 void ScheduleNextRtcpReport(); |
| 94 | 99 |
| 95 // Actually send the next cast message. | 100 // Actually send the next cast message. |
| 96 void SendNextCastMessage(); | 101 void SendNextCastMessage(); |
| 97 | 102 |
| 98 // Actually send the next RTCP report. | 103 // Actually send the next RTCP report. |
| 99 void SendNextRtcpReport(); | 104 void SendNextRtcpReport(); |
| 100 | 105 |
| 106 // Update the target delay based on past information. Will also update the |
| 107 // rtcp module and the audio receiver. |
| 108 void UpdateTargetDelay(); |
| 109 |
| 101 scoped_ptr<VideoDecoder> video_decoder_; | 110 scoped_ptr<VideoDecoder> video_decoder_; |
| 102 scoped_refptr<CastEnvironment> cast_environment_; | 111 scoped_refptr<CastEnvironment> cast_environment_; |
| 103 | 112 |
| 104 // Subscribes to raw events. | 113 // Subscribes to raw events. |
| 105 // Processes raw audio events to be sent over to the cast sender via RTCP. | 114 // Processes raw audio events to be sent over to the cast sender via RTCP. |
| 106 ReceiverRtcpEventSubscriber event_subscriber_; | 115 ReceiverRtcpEventSubscriber event_subscriber_; |
| 107 | 116 |
| 108 scoped_ptr<Framer> framer_; | 117 scoped_ptr<Framer> framer_; |
| 109 const transport::VideoCodec codec_; | 118 const transport::VideoCodec codec_; |
| 110 base::TimeDelta target_delay_delta_; | 119 base::TimeDelta target_delay_delta_; |
| 111 base::TimeDelta frame_delay_; | 120 base::TimeDelta frame_delay_; |
| 112 scoped_ptr<LocalRtpVideoData> incoming_payload_callback_; | 121 scoped_ptr<LocalRtpVideoData> incoming_payload_callback_; |
| 113 scoped_ptr<LocalRtpVideoFeedback> incoming_payload_feedback_; | 122 scoped_ptr<LocalRtpVideoFeedback> incoming_payload_feedback_; |
| 114 RtpReceiver rtp_receiver_; | 123 RtpReceiver rtp_receiver_; |
| 115 scoped_ptr<Rtcp> rtcp_; | 124 scoped_ptr<Rtcp> rtcp_; |
| 116 scoped_ptr<RtpReceiverStatistics> rtp_video_receiver_statistics_; | 125 scoped_ptr<RtpReceiverStatistics> rtp_video_receiver_statistics_; |
| 117 base::TimeDelta time_offset_; // Sender-receiver offset estimation. | 126 base::TimeDelta time_offset_; // Sender-receiver offset estimation. |
| 118 int time_offset_counter_; | 127 int time_offset_counter_; |
| 119 transport::TransportEncryptionHandler decryptor_; | 128 transport::TransportEncryptionHandler decryptor_; |
| 120 std::list<VideoFrameEncodedCallback> queued_encoded_callbacks_; | 129 std::list<VideoFrameEncodedCallback> queued_encoded_callbacks_; |
| 121 bool time_incoming_packet_updated_; | 130 bool time_incoming_packet_updated_; |
| 122 base::TimeTicks time_incoming_packet_; | 131 base::TimeTicks time_incoming_packet_; |
| 123 uint32 incoming_rtp_timestamp_; | 132 uint32 incoming_rtp_timestamp_; |
| 124 base::TimeTicks last_render_time_; | 133 base::TimeTicks last_render_time_; |
| 134 SetTargetDelayCallback target_delay_cb_; |
| 125 | 135 |
| 126 // This mapping allows us to log kVideoAckSent as a frame event. In addition | 136 // This mapping allows us to log kVideoAckSent as a frame event. In addition |
| 127 // it allows the event to be transmitted via RTCP. | 137 // it allows the event to be transmitted via RTCP. |
| 128 RtpTimestamp frame_id_to_rtp_timestamp_[256]; | 138 RtpTimestamp frame_id_to_rtp_timestamp_[256]; |
| 129 | 139 |
| 130 base::WeakPtrFactory<VideoReceiver> weak_factory_; | 140 base::WeakPtrFactory<VideoReceiver> weak_factory_; |
| 131 | 141 |
| 132 DISALLOW_COPY_AND_ASSIGN(VideoReceiver); | 142 DISALLOW_COPY_AND_ASSIGN(VideoReceiver); |
| 133 }; | 143 }; |
| 134 | 144 |
| 135 } // namespace cast | 145 } // namespace cast |
| 136 } // namespace media | 146 } // namespace media |
| 137 | 147 |
| 138 #endif // MEDIA_CAST_VIDEO_RECEIVER_VIDEO_RECEIVER_H_ | 148 #endif // MEDIA_CAST_VIDEO_RECEIVER_VIDEO_RECEIVER_H_ |
| OLD | NEW |