Remove Unused AsTextButtonBorder RTTI helper.
[chromium-blink-merge.git] / media / cast / audio_sender / audio_encoder.h
blob7c2b4f3b0940aee1e27ea8c702ce9c690a81f806
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_AUDIO_ENCODER_H_
6 #define MEDIA_CAST_AUDIO_SENDER_AUDIO_ENCODER_H_
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/threading/thread_checker.h"
11 #include "media/cast/cast_config.h"
12 #include "media/cast/cast_environment.h"
14 namespace base {
15 class TimeTicks;
18 namespace media {
19 class AudioBus;
22 namespace media {
23 namespace cast {
25 class AudioEncoder : public base::RefCountedThreadSafe<AudioEncoder> {
26 public:
27 typedef base::Callback<void(scoped_ptr<transport::EncodedAudioFrame>,
28 const base::TimeTicks&)> FrameEncodedCallback;
30 AudioEncoder(const scoped_refptr<CastEnvironment>& cast_environment,
31 const AudioSenderConfig& audio_config,
32 const FrameEncodedCallback& frame_encoded_callback);
34 CastInitializationStatus InitializationResult() const;
36 // The |audio_bus| must be valid until the |done_callback| is called.
37 // The callback is called from the main cast thread as soon as the encoder is
38 // done with |audio_bus|; it does not mean that the encoded data has been
39 // sent out.
40 void InsertAudio(const AudioBus* audio_bus,
41 const base::TimeTicks& recorded_time,
42 const base::Closure& done_callback);
44 protected:
45 virtual ~AudioEncoder();
47 private:
48 friend class base::RefCountedThreadSafe<AudioEncoder>;
50 class ImplBase;
51 class OpusImpl;
52 class Pcm16Impl;
54 // Invokes |impl_|'s encode method on the AUDIO_ENCODER thread while holding
55 // a ref-count on AudioEncoder.
56 void EncodeAudio(const AudioBus* audio_bus,
57 const base::TimeTicks& recorded_time,
58 const base::Closure& done_callback);
60 const scoped_refptr<CastEnvironment> cast_environment_;
61 scoped_ptr<ImplBase> impl_;
63 // Used to ensure only one thread invokes InsertAudio().
64 base::ThreadChecker insert_thread_checker_;
66 DISALLOW_COPY_AND_ASSIGN(AudioEncoder);
69 } // namespace cast
70 } // namespace media
72 #endif // MEDIA_CAST_AUDIO_SENDER_AUDIO_ENCODER_H_