Remove Unused AsTextButtonBorder RTTI helper.
[chromium-blink-merge.git] / media / cast / video_receiver / video_receiver.h
blob38c8bc1db404df7d53f6405aa2834e48979c91bc
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
3 // found in the LICENSE file.
5 #ifndef MEDIA_CAST_VIDEO_RECEIVER_VIDEO_RECEIVER_H_
6 #define MEDIA_CAST_VIDEO_RECEIVER_VIDEO_RECEIVER_H_
8 #include "base/basictypes.h"
9 #include "base/callback.h"
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/threading/non_thread_safe.h"
14 #include "base/time/tick_clock.h"
15 #include "base/time/time.h"
16 #include "media/cast/cast_config.h"
17 #include "media/cast/cast_environment.h"
18 #include "media/cast/cast_receiver.h"
19 #include "media/cast/rtcp/receiver_rtcp_event_subscriber.h"
20 #include "media/cast/rtcp/rtcp.h"
21 #include "media/cast/rtp_receiver/rtp_receiver.h"
22 #include "media/cast/rtp_receiver/rtp_receiver_defines.h"
23 #include "media/cast/transport/utility/transport_encryption_handler.h"
25 namespace media {
26 namespace cast {
28 class Framer;
29 class LocalRtpVideoData;
30 class LocalRtpVideoFeedback;
31 class PeerVideoReceiver;
32 class Rtcp;
33 class RtpReceiverStatistics;
34 class VideoDecoder;
36 // Should only be called from the Main cast thread.
37 class VideoReceiver : public base::NonThreadSafe,
38 public base::SupportsWeakPtr<VideoReceiver> {
39 public:
40 VideoReceiver(scoped_refptr<CastEnvironment> cast_environment,
41 const VideoReceiverConfig& video_config,
42 transport::PacedPacketSender* const packet_sender);
44 virtual ~VideoReceiver();
46 // Request a raw frame. Will return frame via callback when available.
47 void GetRawVideoFrame(const VideoFrameDecodedCallback& callback);
49 // Request an encoded frame. Will return frame via callback when available.
50 void GetEncodedVideoFrame(const VideoFrameEncodedCallback& callback);
52 // Insert a RTP packet to the video receiver.
53 void IncomingPacket(scoped_ptr<Packet> packet);
55 protected:
56 void IncomingParsedRtpPacket(const uint8* payload_data,
57 size_t payload_size,
58 const RtpCastHeader& rtp_header);
60 void DecodeVideoFrameThread(
61 scoped_ptr<transport::EncodedVideoFrame> encoded_frame,
62 const base::TimeTicks render_time,
63 const VideoFrameDecodedCallback& frame_decoded_callback);
65 private:
66 friend class LocalRtpVideoData;
67 friend class LocalRtpVideoFeedback;
69 void CastFeedback(const RtcpCastMessage& cast_message);
71 void DecodeVideoFrame(const VideoFrameDecodedCallback& callback,
72 scoped_ptr<transport::EncodedVideoFrame> encoded_frame,
73 const base::TimeTicks& render_time);
75 bool DecryptVideoFrame(scoped_ptr<transport::EncodedVideoFrame>* video_frame);
77 bool PullEncodedVideoFrame(
78 bool next_frame,
79 scoped_ptr<transport::EncodedVideoFrame>* encoded_frame,
80 base::TimeTicks* render_time);
82 void PlayoutTimeout();
84 // Returns Render time based on current time and the rtp timestamp.
85 base::TimeTicks GetRenderTime(base::TimeTicks now, uint32 rtp_timestamp);
87 void InitializeTimers();
89 // Schedule timing for the next cast message.
90 void ScheduleNextCastMessage();
92 // Schedule timing for the next RTCP report.
93 void ScheduleNextRtcpReport();
95 // Actually send the next cast message.
96 void SendNextCastMessage();
98 // Actually send the next RTCP report.
99 void SendNextRtcpReport();
101 scoped_ptr<VideoDecoder> video_decoder_;
102 scoped_refptr<CastEnvironment> cast_environment_;
104 // Subscribes to raw events.
105 // Processes raw audio events to be sent over to the cast sender via RTCP.
106 ReceiverRtcpEventSubscriber event_subscriber_;
108 scoped_ptr<Framer> framer_;
109 const transport::VideoCodec codec_;
110 base::TimeDelta target_delay_delta_;
111 base::TimeDelta frame_delay_;
112 scoped_ptr<LocalRtpVideoData> incoming_payload_callback_;
113 scoped_ptr<LocalRtpVideoFeedback> incoming_payload_feedback_;
114 RtpReceiver rtp_receiver_;
115 scoped_ptr<Rtcp> rtcp_;
116 scoped_ptr<RtpReceiverStatistics> rtp_video_receiver_statistics_;
117 base::TimeDelta time_offset_; // Sender-receiver offset estimation.
118 transport::TransportEncryptionHandler decryptor_;
119 std::list<VideoFrameEncodedCallback> queued_encoded_callbacks_;
120 bool time_incoming_packet_updated_;
121 base::TimeTicks time_incoming_packet_;
122 uint32 incoming_rtp_timestamp_;
123 base::TimeTicks last_render_time_;
125 base::WeakPtrFactory<VideoReceiver> weak_factory_;
127 DISALLOW_COPY_AND_ASSIGN(VideoReceiver);
130 } // namespace cast
131 } // namespace media
133 #endif // MEDIA_CAST_VIDEO_RECEIVER_VIDEO_RECEIVER_H_