All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AudioDecoder.hh
Go to the documentation of this file.
1 /*
2 * Copyright 2013 Open Source Robotics Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17 
18 #ifndef _GAZEBO_AUDIO_DECODER_HH_
19 #define _GAZEBO_AUDIO_DECODER_HH_
20 
21 #include <stdint.h>
22 #include <string>
23 
24 struct AVFormatContext;
25 struct AVCodecContext;
26 struct AVCodec;
27 
28 namespace gazebo
29 {
30  namespace common
31  {
34 
38  {
40  public: AudioDecoder();
41 
43  public: virtual ~AudioDecoder();
44 
48  public: bool SetFile(const std::string &_filename);
49 
53  public: std::string GetFile() const;
54 
60  public: bool Decode(uint8_t **_outBuffer, unsigned int *_outBufferSize);
61 
64  public: int GetSampleRate();
65 
67  private: void Cleanup();
68 
70  private: AVFormatContext *formatCtx;
71 
73  private: AVCodecContext *codecCtx;
74 
76  private: AVCodec *codec;
77 
79  private: int audioStream;
80 
82  private: static bool initialized;
83 
85  private: std::string filename;
86  };
88  }
89 }
90 #endif