Upstream version 11.40.271.0
[platform/framework/web/crosswalk.git] / src / third_party / webrtc / modules / audio_coding / codecs / opus / interface / audio_encoder_opus.h
1 /*
2  *  Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10
11 #ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_OPUS_INTERFACE_AUDIO_ENCODER_OPUS_H_
12 #define WEBRTC_MODULES_AUDIO_CODING_CODECS_OPUS_INTERFACE_AUDIO_ENCODER_OPUS_H_
13
14 #include <vector>
15
16 #include "webrtc/modules/audio_coding/codecs/opus/interface/opus_interface.h"
17 #include "webrtc/modules/audio_coding/codecs/audio_encoder.h"
18
19 namespace webrtc {
20
21 class AudioEncoderOpus : public AudioEncoder {
22  public:
23   struct Config {
24     Config();
25     bool IsOk() const;
26     int frame_size_ms;
27     int num_channels;
28   };
29
30   explicit AudioEncoderOpus(const Config& config);
31   virtual ~AudioEncoderOpus() OVERRIDE;
32
33   virtual int sample_rate_hz() const OVERRIDE;
34   virtual int num_channels() const OVERRIDE;
35   virtual int Num10MsFramesInNextPacket() const OVERRIDE;
36
37  protected:
38   virtual bool Encode(uint32_t timestamp,
39                       const int16_t* audio,
40                       size_t max_encoded_bytes,
41                       uint8_t* encoded,
42                       size_t* encoded_bytes,
43                       uint32_t* encoded_timestamp) OVERRIDE;
44
45  private:
46   const int num_10ms_frames_per_packet_;
47   const int num_channels_;
48   const int samples_per_10ms_frame_;
49   std::vector<int16_t> input_buffer_;
50   OpusEncInst* inst_;
51   uint32_t first_timestamp_in_buffer_;
52 };
53
54 }  // namespace webrtc
55 #endif  // WEBRTC_MODULES_AUDIO_CODING_CODECS_OPUS_INTERFACE_AUDIO_ENCODER_OPUS_H_