Ignore title parameter for navigator.registerProtocolHandler
[chromium-blink-merge.git] / media / cast / audio_sender / audio_sender.h
blob1a2eedd3e4f47bdd853fc3bf0cb581e2d3281616
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/base/audio_bus.h"
16 #include "media/cast/cast_config.h"
17 #include "media/cast/rtcp/rtcp.h"
18 #include "media/cast/transport/rtp_sender/rtp_sender.h"
20 namespace media {
21 namespace cast {
23 class AudioEncoder;
24 class LocalRtcpAudioSenderFeedback;
26 // This class is not thread safe.
27 // It's only called from the main cast thread.
28 class AudioSender : public base::NonThreadSafe,
29 public base::SupportsWeakPtr<AudioSender> {
30 public:
31 AudioSender(scoped_refptr<CastEnvironment> cast_environment,
32 const AudioSenderConfig& audio_config,
33 transport::CastTransportSender* const transport_sender);
35 virtual ~AudioSender();
37 CastInitializationStatus InitializationResult() const {
38 return cast_initialization_cb_;
41 void InsertAudio(scoped_ptr<AudioBus> audio_bus,
42 const base::TimeTicks& recorded_time);
44 // Only called from the main cast thread.
45 void IncomingRtcpPacket(scoped_ptr<Packet> packet);
47 protected:
48 void SendEncodedAudioFrame(
49 scoped_ptr<transport::EncodedAudioFrame> audio_frame,
50 const base::TimeTicks& recorded_time);
52 private:
53 friend class LocalRtcpAudioSenderFeedback;
55 void ResendPackets(
56 const MissingFramesAndPacketsMap& missing_frames_and_packets);
58 void StoreStatistics(const transport::RtcpSenderInfo& sender_info,
59 base::TimeTicks time_sent,
60 uint32 rtp_timestamp);
62 void ScheduleNextRtcpReport();
63 void SendRtcpReport();
65 void InitializeTimers();
67 scoped_refptr<CastEnvironment> cast_environment_;
68 transport::CastTransportSender* const transport_sender_;
69 scoped_ptr<AudioEncoder> audio_encoder_;
70 RtpSenderStatistics rtp_stats_;
71 scoped_ptr<LocalRtcpAudioSenderFeedback> rtcp_feedback_;
72 Rtcp rtcp_;
73 bool timers_initialized_;
74 CastInitializationStatus cast_initialization_cb_;
76 // NOTE: Weak pointers must be invalidated before all other member variables.
77 base::WeakPtrFactory<AudioSender> weak_factory_;
79 DISALLOW_COPY_AND_ASSIGN(AudioSender);
82 } // namespace cast
83 } // namespace media
85 #endif // MEDIA_CAST_AUDIO_SENDER_H_