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 <memory> |
| 9 |
8 #include "base/callback.h" | 10 #include "base/callback.h" |
9 #include "base/macros.h" | 11 #include "base/macros.h" |
10 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
13 #include "base/threading/non_thread_safe.h" | 14 #include "base/threading/non_thread_safe.h" |
14 #include "base/time/tick_clock.h" | 15 #include "base/time/tick_clock.h" |
15 #include "base/time/time.h" | 16 #include "base/time/time.h" |
16 #include "media/base/audio_bus.h" | 17 #include "media/base/audio_bus.h" |
17 #include "media/cast/cast_config.h" | 18 #include "media/cast/cast_config.h" |
18 #include "media/cast/cast_defines.h" | 19 #include "media/cast/cast_defines.h" |
19 #include "media/cast/cast_sender.h" | 20 #include "media/cast/cast_sender.h" |
20 #include "media/cast/sender/frame_sender.h" | 21 #include "media/cast/sender/frame_sender.h" |
21 | 22 |
(...skipping 15 matching lines...) Expand all Loading... |
37 AudioSender(scoped_refptr<CastEnvironment> cast_environment, | 38 AudioSender(scoped_refptr<CastEnvironment> cast_environment, |
38 const AudioSenderConfig& audio_config, | 39 const AudioSenderConfig& audio_config, |
39 const StatusChangeCallback& status_change_cb, | 40 const StatusChangeCallback& status_change_cb, |
40 CastTransport* const transport_sender); | 41 CastTransport* const transport_sender); |
41 | 42 |
42 ~AudioSender() final; | 43 ~AudioSender() final; |
43 | 44 |
44 // Note: It is not guaranteed that |audio_frame| will actually be encoded and | 45 // 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 | 46 // sent, if AudioSender detects too many frames in flight. Therefore, clients |
46 // should be careful about the rate at which this method is called. | 47 // should be careful about the rate at which this method is called. |
47 void InsertAudio(scoped_ptr<AudioBus> audio_bus, | 48 void InsertAudio(std::unique_ptr<AudioBus> audio_bus, |
48 const base::TimeTicks& recorded_time); | 49 const base::TimeTicks& recorded_time); |
49 | 50 |
50 protected: | 51 protected: |
51 int GetNumberOfFramesInEncoder() const final; | 52 int GetNumberOfFramesInEncoder() const final; |
52 base::TimeDelta GetInFlightMediaDuration() const final; | 53 base::TimeDelta GetInFlightMediaDuration() const final; |
53 | 54 |
54 private: | 55 private: |
55 // Called by the |audio_encoder_| with the next EncodedFrame to send. | 56 // Called by the |audio_encoder_| with the next EncodedFrame to send. |
56 void OnEncodedAudioFrame(int encoder_bitrate, | 57 void OnEncodedAudioFrame(int encoder_bitrate, |
57 scoped_ptr<SenderEncodedFrame> encoded_frame, | 58 std::unique_ptr<SenderEncodedFrame> encoded_frame, |
58 int samples_skipped); | 59 int samples_skipped); |
59 | 60 |
60 // Encodes AudioBuses into EncodedFrames. | 61 // Encodes AudioBuses into EncodedFrames. |
61 scoped_ptr<AudioEncoder> audio_encoder_; | 62 std::unique_ptr<AudioEncoder> audio_encoder_; |
62 | 63 |
63 // The number of audio samples enqueued in |audio_encoder_|. | 64 // The number of audio samples enqueued in |audio_encoder_|. |
64 int samples_in_encoder_; | 65 int samples_in_encoder_; |
65 | 66 |
66 // NOTE: Weak pointers must be invalidated before all other member variables. | 67 // NOTE: Weak pointers must be invalidated before all other member variables. |
67 base::WeakPtrFactory<AudioSender> weak_factory_; | 68 base::WeakPtrFactory<AudioSender> weak_factory_; |
68 | 69 |
69 DISALLOW_COPY_AND_ASSIGN(AudioSender); | 70 DISALLOW_COPY_AND_ASSIGN(AudioSender); |
70 }; | 71 }; |
71 | 72 |
72 } // namespace cast | 73 } // namespace cast |
73 } // namespace media | 74 } // namespace media |
74 | 75 |
75 #endif // MEDIA_CAST_SENDER_AUDIO_SENDER_H_ | 76 #endif // MEDIA_CAST_SENDER_AUDIO_SENDER_H_ |
OLD | NEW |