blob: f411db915162c46ca13601f0f1794c367b0f5562 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
leozwang@webrtc.org2559cbf2012-02-27 19:18:25 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
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
pbos@webrtc.org8b062002013-07-12 08:28:10 +000014#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/interface/media_file.h"
18#include "webrtc/modules/media_file/interface/media_file_defines.h"
19#include "webrtc/modules/utility/interface/file_player.h"
20#include "webrtc/modules/utility/source/coder.h"
Henrik Kjellander98f53512015-10-28 18:17:40 +010021#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
22#include "webrtc/system_wrappers/include/tick_util.h"
pbos@webrtc.org8b062002013-07-12 08:28:10 +000023#include "webrtc/typedefs.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000024
25namespace webrtc {
niklase@google.com470e71d2011-07-07 08:21:25 +000026class FilePlayerImpl : public FilePlayer
27{
28public:
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000029 FilePlayerImpl(uint32_t instanceID, FileFormats fileFormat);
niklase@google.com470e71d2011-07-07 08:21:25 +000030 ~FilePlayerImpl();
31
andrew@webrtc.orge59a0ac2012-05-08 17:12:40 +000032 virtual int Get10msAudioFromFile(
33 int16_t* outBuffer,
Peter Kastingdce40cf2015-08-24 14:52:23 -070034 size_t& lengthInSamples,
andrew@webrtc.orge59a0ac2012-05-08 17:12:40 +000035 int frequencyInHz);
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000036 virtual int32_t RegisterModuleFileCallback(FileCallback* callback);
37 virtual int32_t StartPlayingFile(
leozwang@webrtc.org2559cbf2012-02-27 19:18:25 +000038 const char* fileName,
niklase@google.com470e71d2011-07-07 08:21:25 +000039 bool loop,
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000040 uint32_t startPosition,
niklase@google.com470e71d2011-07-07 08:21:25 +000041 float volumeScaling,
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000042 uint32_t notification,
43 uint32_t stopPosition = 0,
niklase@google.com470e71d2011-07-07 08:21:25 +000044 const CodecInst* codecInst = NULL);
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000045 virtual int32_t StartPlayingFile(
niklase@google.com470e71d2011-07-07 08:21:25 +000046 InStream& sourceStream,
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000047 uint32_t startPosition,
niklase@google.com470e71d2011-07-07 08:21:25 +000048 float volumeScaling,
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000049 uint32_t notification,
50 uint32_t stopPosition = 0,
niklase@google.com470e71d2011-07-07 08:21:25 +000051 const CodecInst* codecInst = NULL);
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000052 virtual int32_t StopPlayingFile();
niklase@google.com470e71d2011-07-07 08:21:25 +000053 virtual bool IsPlayingFile() const;
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000054 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);
niklase@google.com470e71d2011-07-07 08:21:25 +000058
59protected:
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000060 int32_t SetUpAudioDecoder();
niklase@google.com470e71d2011-07-07 08:21:25 +000061
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000062 uint32_t _instanceID;
niklase@google.com470e71d2011-07-07 08:21:25 +000063 const FileFormats _fileFormat;
64 MediaFile& _fileModule;
65
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000066 uint32_t _decodedLengthInMS;
niklase@google.com470e71d2011-07-07 08:21:25 +000067
68private:
niklase@google.com470e71d2011-07-07 08:21:25 +000069 AudioCoder _audioDecoder;
70
71 CodecInst _codec;
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000072 int32_t _numberOf10MsPerFrame;
73 int32_t _numberOf10MsInDecoder;
niklase@google.com470e71d2011-07-07 08:21:25 +000074
75 Resampler _resampler;
76 float _scaling;
77};
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +000078} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +000079#endif // WEBRTC_MODULES_UTILITY_SOURCE_FILE_PLAYER_IMPL_H_