OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MEDIA_CAST_SENDER_AUDIO_SENDER_H_ | 5 #ifndef MEDIA_CAST_SENDER_AUDIO_SENDER_H_ |
6 #define MEDIA_CAST_SENDER_AUDIO_SENDER_H_ | 6 #define MEDIA_CAST_SENDER_AUDIO_SENDER_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 // packets, congestion control, audio encoder, parsing and sending of | 26 // packets, congestion control, audio encoder, parsing and sending of |
27 // RTCP packets. | 27 // RTCP packets. |
28 // Additionally it posts a bunch of delayed tasks to the main thread for various | 28 // Additionally it posts a bunch of delayed tasks to the main thread for various |
29 // timeouts. | 29 // timeouts. |
30 class AudioSender : public FrameSender, | 30 class AudioSender : public FrameSender, |
31 public base::NonThreadSafe, | 31 public base::NonThreadSafe, |
32 public base::SupportsWeakPtr<AudioSender> { | 32 public base::SupportsWeakPtr<AudioSender> { |
33 public: | 33 public: |
34 AudioSender(scoped_refptr<CastEnvironment> cast_environment, | 34 AudioSender(scoped_refptr<CastEnvironment> cast_environment, |
35 const AudioSenderConfig& audio_config, | 35 const AudioSenderConfig& audio_config, |
| 36 const StatusChangeCallback& status_change_cb, |
36 CastTransportSender* const transport_sender); | 37 CastTransportSender* const transport_sender); |
37 | 38 |
38 ~AudioSender() override; | 39 ~AudioSender() override; |
39 | 40 |
40 CastInitializationStatus InitializationResult() const { | |
41 return cast_initialization_status_; | |
42 } | |
43 | |
44 // Note: It is not guaranteed that |audio_frame| will actually be encoded and | 41 // Note: It is not guaranteed that |audio_frame| will actually be encoded and |
45 // sent, if AudioSender detects too many frames in flight. Therefore, clients | 42 // sent, if AudioSender detects too many frames in flight. Therefore, clients |
46 // should be careful about the rate at which this method is called. | 43 // should be careful about the rate at which this method is called. |
47 // | |
48 // Note: It is invalid to call this method if InitializationResult() returns | |
49 // anything but STATUS_AUDIO_INITIALIZED. | |
50 void InsertAudio(scoped_ptr<AudioBus> audio_bus, | 44 void InsertAudio(scoped_ptr<AudioBus> audio_bus, |
51 const base::TimeTicks& recorded_time); | 45 const base::TimeTicks& recorded_time); |
52 | 46 |
53 protected: | 47 protected: |
54 int GetNumberOfFramesInEncoder() const override; | 48 int GetNumberOfFramesInEncoder() const override; |
55 base::TimeDelta GetInFlightMediaDuration() const override; | 49 base::TimeDelta GetInFlightMediaDuration() const override; |
56 void OnAck(uint32 frame_id) override; | 50 void OnAck(uint32 frame_id) override; |
57 | 51 |
58 private: | 52 private: |
59 // Called by the |audio_encoder_| with the next EncodedFrame to send. | 53 // Called by the |audio_encoder_| with the next EncodedFrame to send. |
(...skipping 10 matching lines...) Expand all Loading... |
70 // NOTE: Weak pointers must be invalidated before all other member variables. | 64 // NOTE: Weak pointers must be invalidated before all other member variables. |
71 base::WeakPtrFactory<AudioSender> weak_factory_; | 65 base::WeakPtrFactory<AudioSender> weak_factory_; |
72 | 66 |
73 DISALLOW_COPY_AND_ASSIGN(AudioSender); | 67 DISALLOW_COPY_AND_ASSIGN(AudioSender); |
74 }; | 68 }; |
75 | 69 |
76 } // namespace cast | 70 } // namespace cast |
77 } // namespace media | 71 } // namespace media |
78 | 72 |
79 #endif // MEDIA_CAST_SENDER_AUDIO_SENDER_H_ | 73 #endif // MEDIA_CAST_SENDER_AUDIO_SENDER_H_ |
OLD | NEW |