Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / media / cast / sender / audio_encoder.h
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
3 // found in the LICENSE file.
4
5 #ifndef MEDIA_CAST_SENDER_AUDIO_ENCODER_H_
6 #define MEDIA_CAST_SENDER_AUDIO_ENCODER_H_
7
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/threading/thread_checker.h"
11 #include "media/base/audio_bus.h"
12 #include "media/cast/cast_environment.h"
13
14 namespace base {
15 class TimeTicks;
16 }
17
18 namespace media {
19 namespace cast {
20
21 class AudioEncoder {
22  public:
23   // Callback to deliver each EncodedFrame, plus the number of audio samples
24   // skipped since the last frame.
25   typedef base::Callback<void(scoped_ptr<EncodedFrame>, int)>
26       FrameEncodedCallback;
27
28   AudioEncoder(const scoped_refptr<CastEnvironment>& cast_environment,
29                int num_channels,
30                int sampling_rate,
31                int bitrate,
32                Codec codec,
33                const FrameEncodedCallback& frame_encoded_callback);
34   virtual ~AudioEncoder();
35
36   CastInitializationStatus InitializationResult() const;
37
38   int GetSamplesPerFrame() const;
39   base::TimeDelta GetFrameDuration() const;
40
41   void InsertAudio(scoped_ptr<AudioBus> audio_bus,
42                    const base::TimeTicks& recorded_time);
43
44  private:
45   class ImplBase;
46   class OpusImpl;
47   class Pcm16Impl;
48   class AppleAacImpl;
49
50   const scoped_refptr<CastEnvironment> cast_environment_;
51   scoped_refptr<ImplBase> impl_;
52
53   // Used to ensure only one thread invokes InsertAudio().
54   base::ThreadChecker insert_thread_checker_;
55
56   DISALLOW_COPY_AND_ASSIGN(AudioEncoder);
57 };
58
59 }  // namespace cast
60 }  // namespace media
61
62 #endif  // MEDIA_CAST_SENDER_AUDIO_ENCODER_H_