Remove Unused AsTextButtonBorder RTTI helper.
[chromium-blink-merge.git] / media / cast / audio_sender / audio_sender.h
blob039983353d1221234d83ddb8c801f847530cf963
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_AUDIO_SENDER_H_
6 #define MEDIA_CAST_AUDIO_SENDER_H_
8 #include "base/callback.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h"
12 #include "base/threading/non_thread_safe.h"
13 #include "base/time/tick_clock.h"
14 #include "base/time/time.h"
15 #include "media/cast/cast_config.h"
16 #include "media/cast/rtcp/rtcp.h"
17 #include "media/cast/transport/rtp_sender/rtp_sender.h"
19 namespace media {
20 class AudioBus;
23 namespace media {
24 namespace cast {
26 class AudioEncoder;
27 class LocalRtcpAudioSenderFeedback;
28 class LocalRtpSenderStatistics;
30 // This class is not thread safe.
31 // It's only called from the main cast thread.
32 class AudioSender : public base::NonThreadSafe,
33 public base::SupportsWeakPtr<AudioSender> {
34 public:
35 AudioSender(scoped_refptr<CastEnvironment> cast_environment,
36 const AudioSenderConfig& audio_config,
37 transport::CastTransportSender* const transport_sender);
39 virtual ~AudioSender();
41 CastInitializationStatus InitializationResult() const {
42 return initialization_status_;
45 // The |audio_bus| must be valid until the |done_callback| is called.
46 // The callback is called from the main cast thread as soon as the encoder is
47 // done with |audio_bus|; it does not mean that the encoded data has been
48 // sent out.
49 void InsertAudio(const AudioBus* audio_bus,
50 const base::TimeTicks& recorded_time,
51 const base::Closure& done_callback);
53 // Only called from the main cast thread.
54 void IncomingRtcpPacket(scoped_ptr<Packet> packet);
56 protected:
57 void SendEncodedAudioFrame(
58 scoped_ptr<transport::EncodedAudioFrame> audio_frame,
59 const base::TimeTicks& recorded_time);
61 private:
62 friend class LocalRtcpAudioSenderFeedback;
64 void SendEncodedAudioFrameToTransport(
65 scoped_ptr<transport::EncodedAudioFrame> audio_frame,
66 const base::TimeTicks& recorded_time);
68 void ResendPackets(
69 const MissingFramesAndPacketsMap& missing_frames_and_packets);
71 void ResendPacketsOnTransportThread(
72 const transport::MissingFramesAndPacketsMap& missing_packets);
74 void ScheduleNextRtcpReport();
75 void SendRtcpReport();
77 void InitializeTimers();
79 base::WeakPtrFactory<AudioSender> weak_factory_;
81 scoped_refptr<CastEnvironment> cast_environment_;
82 transport::CastTransportSender* const transport_sender_;
83 scoped_refptr<AudioEncoder> audio_encoder_;
84 scoped_ptr<LocalRtpSenderStatistics> rtp_audio_sender_statistics_;
85 scoped_ptr<LocalRtcpAudioSenderFeedback> rtcp_feedback_;
86 Rtcp rtcp_;
87 bool timers_initialized_;
88 CastInitializationStatus initialization_status_;
90 DISALLOW_COPY_AND_ASSIGN(AudioSender);
93 } // namespace cast
94 } // namespace media
96 #endif // MEDIA_CAST_AUDIO_SENDER_H_