Revert "Omit calls to set composing region when pasting image."
[chromium-blink-merge.git] / media / cast / net / rtp / rtp_sender.h
blob675658109e31af5732cb07157cbefe65b956f849
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.
5 // This file contains the interface to the cast RTP sender.
7 #ifndef MEDIA_CAST_NET_RTP_RTP_SENDER_H_
8 #define MEDIA_CAST_NET_RTP_RTP_SENDER_H_
10 #include <map>
11 #include <set>
13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.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/net/cast_transport_defines.h"
19 #include "media/cast/net/cast_transport_sender.h"
20 #include "media/cast/net/pacing/paced_sender.h"
21 #include "media/cast/net/rtp/packet_storage.h"
22 #include "media/cast/net/rtp/rtp_packetizer.h"
24 namespace media {
25 namespace cast {
27 // This object is only called from the main cast thread.
28 // This class handles splitting encoded audio and video frames into packets and
29 // add an RTP header to each packet. The sent packets are stored until they are
30 // acknowledged by the remote peer or timed out.
31 class RtpSender {
32 public:
33 RtpSender(
34 const scoped_refptr<base::SingleThreadTaskRunner>& transport_task_runner,
35 PacedSender* const transport);
37 ~RtpSender();
39 // This must be called before sending any frames. Returns false if
40 // configuration is invalid.
41 bool Initialize(const CastTransportRtpConfig& config);
43 void SendFrame(const EncodedFrame& frame);
45 void ResendPackets(const MissingFramesAndPacketsMap& missing_packets,
46 bool cancel_rtx_if_not_in_list,
47 const DedupInfo& dedup_info);
49 // Returns the total number of bytes sent to the socket when the specified
50 // frame was just sent.
51 // Returns 0 if the frame cannot be found or the frame was only sent
52 // partially.
53 int64 GetLastByteSentForFrame(uint32 frame_id);
55 void CancelSendingFrames(const std::vector<uint32>& frame_ids);
57 void ResendFrameForKickstart(uint32 frame_id, base::TimeDelta dedupe_window);
59 size_t send_packet_count() const {
60 return packetizer_ ? packetizer_->send_packet_count() : 0;
62 size_t send_octet_count() const {
63 return packetizer_ ? packetizer_->send_octet_count() : 0;
65 uint32 ssrc() const { return config_.ssrc; }
67 private:
68 void UpdateSequenceNumber(Packet* packet);
70 RtpPacketizerConfig config_;
71 PacketStorage storage_;
72 scoped_ptr<RtpPacketizer> packetizer_;
73 PacedSender* const transport_;
74 scoped_refptr<base::SingleThreadTaskRunner> transport_task_runner_;
76 // NOTE: Weak pointers must be invalidated before all other member variables.
77 base::WeakPtrFactory<RtpSender> weak_factory_;
79 DISALLOW_COPY_AND_ASSIGN(RtpSender);
82 } // namespace cast
83 } // namespace media
85 #endif // MEDIA_CAST_NET_RTP_SENDER_RTP_SENDER_H_