Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / media / cast / transport / transport_audio_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_AUDIO_SENDER_H_
6 #define MEDIA_CAST_TRANSPORT_TRANSPORT_AUDIO_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 "media/cast/transport/rtp_sender/rtp_sender.h"
13 #include "media/cast/transport/utility/transport_encryption_handler.h"
14
15 namespace media {
16 namespace cast {
17 namespace transport {
18
19 class PacedSender;
20
21 // It's only called from the main cast transport thread.
22 class TransportAudioSender : public base::NonThreadSafe {
23  public:
24   TransportAudioSender(
25       const CastTransportConfig& config,
26       base::TickClock* clock,
27       const scoped_refptr<base::TaskRunner>& transport_task_runner,
28       PacedSender* const paced_packet_sender);
29
30   virtual ~TransportAudioSender();
31
32   // Handles the encoded audio frames to be processed.
33   // Frames will be encrypted, packetized and transmitted to the network.
34   void InsertCodedAudioFrame(const EncodedAudioFrame* audio_frame,
35                              const base::TimeTicks& recorded_time);
36
37   // Retransmision request.
38   void ResendPackets(
39       const MissingFramesAndPacketsMap& missing_frames_and_packets);
40
41   bool initialized() const { return initialized_; }
42
43   // Subscribe callback to get RTP Audio stats.
44   void SubscribeAudioRtpStatsCallback(
45       const CastTransportRtpStatistics& callback);
46
47  private:
48   friend class LocalRtcpAudioSenderFeedback;
49
50   // Caller must allocate the destination |encrypted_frame|. The data member
51   // will be resized to hold the encrypted size.
52   bool EncryptAudioFrame(const EncodedAudioFrame& audio_frame,
53                          EncodedAudioFrame* encrypted_frame);
54
55   RtpSender rtp_sender_;
56   TransportEncryptionHandler encryptor_;
57   bool initialized_;
58
59   DISALLOW_IMPLICIT_CONSTRUCTORS(TransportAudioSender);
60 };
61
62 }  // namespace transport
63 }  // namespace cast
64 }  // namespace media
65
66 #endif  // MEDIA_CAST_TRANSPORT_TRANSPORT_AUDIO_SENDER_H_