Upstream version 5.34.92.0
[platform/framework/web/crosswalk.git] / src / media / cast / transport / transport_video_sender.h
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
3 // found in the LICENSE file.
4
5 #ifndef MEDIA_CAST_TRANSPORT_TRANSPORT_VIDEO_SENDER_H_
6 #define MEDIA_CAST_TRANSPORT_TRANSPORT_VIDEO_SENDER_H_
7
8 #include "base/callback.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/threading/non_thread_safe.h"
12 #include "base/time/tick_clock.h"
13 #include "media/cast/transport/cast_transport_config.h"
14 #include "media/cast/transport/rtp_sender/rtp_sender.h"
15
16 namespace crypto {
17 class Encryptor;
18 class SymmetricKey;
19 }
20
21 namespace media {
22 class VideoFrame;
23
24 namespace cast {
25 namespace transport {
26
27 class PacedSender;
28
29 // Not thread safe. Only called from the main cast transport thread.
30 // This class owns all objects related to sending coded video, objects that
31 // encrypt, create RTP packets and send to network.
32 class TransportVideoSender : public base::NonThreadSafe {
33  public:
34   TransportVideoSender(const CastTransportConfig& config,
35                        base::TickClock* clock,
36                        PacedSender* const paced_packet_sender);
37
38   virtual ~TransportVideoSender();
39
40   // Handles the encoded video frames to be processed.
41   // Frames will be encrypted, packetized and transmitted to the network.
42   void InsertCodedVideoFrame(const EncodedVideoFrame* coded_frame,
43                              const base::TimeTicks& capture_time);
44
45   // Retrieves video RTP statistics.
46   void GetStatistics(const base::TimeTicks& now, RtcpSenderInfo* sender_info);
47
48   // Retransmision request.
49   void ResendPackets(
50       const MissingFramesAndPacketsMap& missing_frames_and_packets);
51
52   bool initialized() const { return initialized_; }
53
54  private:
55   // Caller must allocate the destination |encrypted_video_frame| the data
56   // member will be resized to hold the encrypted size.
57   bool EncryptVideoFrame(const EncodedVideoFrame& encoded_frame,
58                          EncodedVideoFrame* encrypted_video_frame);
59
60   const base::TimeDelta rtp_max_delay_;
61
62   RtpSender rtp_sender_;
63   scoped_ptr<crypto::SymmetricKey> key_;
64   scoped_ptr<crypto::Encryptor> encryptor_;
65   std::string iv_mask_;
66
67   bool initialized_;
68
69   DISALLOW_IMPLICIT_CONSTRUCTORS(TransportVideoSender);
70 };
71
72 }  // namespace transport
73 }  // namespace cast
74 }  // namespace media
75
76 #endif  // MEDIA_CAST_TRANSPORT_TRANSPORT_VIDEO_SENDER_H_