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