Home | History | Annotate | Download | only in source
      1 /*
      2  *  Copyright (c) 2012 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_UTILITY_SOURCE_FILE_PLAYER_IMPL_H_
     12 #define WEBRTC_MODULES_UTILITY_SOURCE_FILE_PLAYER_IMPL_H_
     13 
     14 #include "webrtc/common_audio/resampler/include/resampler.h"
     15 #include "webrtc/common_types.h"
     16 #include "webrtc/engine_configurations.h"
     17 #include "webrtc/modules/media_file/media_file.h"
     18 #include "webrtc/modules/media_file/media_file_defines.h"
     19 #include "webrtc/modules/utility/include/file_player.h"
     20 #include "webrtc/modules/utility/source/coder.h"
     21 #include "webrtc/system_wrappers/include/critical_section_wrapper.h"
     22 #include "webrtc/system_wrappers/include/tick_util.h"
     23 #include "webrtc/typedefs.h"
     24 
     25 namespace webrtc {
     26 class FilePlayerImpl : public FilePlayer
     27 {
     28 public:
     29     FilePlayerImpl(uint32_t instanceID, FileFormats fileFormat);
     30     ~FilePlayerImpl();
     31 
     32     virtual int Get10msAudioFromFile(
     33         int16_t* outBuffer,
     34         size_t& lengthInSamples,
     35         int frequencyInHz);
     36     virtual int32_t RegisterModuleFileCallback(FileCallback* callback);
     37     virtual int32_t StartPlayingFile(
     38         const char* fileName,
     39         bool loop,
     40         uint32_t startPosition,
     41         float volumeScaling,
     42         uint32_t notification,
     43         uint32_t stopPosition = 0,
     44         const CodecInst* codecInst = NULL);
     45     virtual int32_t StartPlayingFile(
     46         InStream& sourceStream,
     47         uint32_t startPosition,
     48         float volumeScaling,
     49         uint32_t notification,
     50         uint32_t stopPosition = 0,
     51         const CodecInst* codecInst = NULL);
     52     virtual int32_t StopPlayingFile();
     53     virtual bool IsPlayingFile() const;
     54     virtual int32_t GetPlayoutPosition(uint32_t& durationMs);
     55     virtual int32_t AudioCodec(CodecInst& audioCodec) const;
     56     virtual int32_t Frequency() const;
     57     virtual int32_t SetAudioScaling(float scaleFactor);
     58 
     59 protected:
     60     int32_t SetUpAudioDecoder();
     61 
     62     uint32_t _instanceID;
     63     const FileFormats _fileFormat;
     64     MediaFile& _fileModule;
     65 
     66     uint32_t _decodedLengthInMS;
     67 
     68 private:
     69     AudioCoder _audioDecoder;
     70 
     71     CodecInst _codec;
     72     int32_t _numberOf10MsPerFrame;
     73     int32_t _numberOf10MsInDecoder;
     74 
     75     Resampler _resampler;
     76     float _scaling;
     77 };
     78 }  // namespace webrtc
     79 #endif // WEBRTC_MODULES_UTILITY_SOURCE_FILE_PLAYER_IMPL_H_
     80