blob: 62887da13b87bedbe5db3362b2ffc35ebc0a9d00 [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
kwiberg9d7eb132016-08-16 04:08:30 -070011#ifndef WEBRTC_MODULES_UTILITY_SOURCE_FILE_PLAYER_IMPL_H_
12#define WEBRTC_MODULES_UTILITY_SOURCE_FILE_PLAYER_IMPL_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000013
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"
Henrik Kjellander0b9e29c2015-11-16 11:12:24 +010017#include "webrtc/modules/media_file/media_file.h"
18#include "webrtc/modules/media_file/media_file_defines.h"
kwiberg9d7eb132016-08-16 04:08:30 -070019#include "webrtc/modules/utility/include/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"
pbos@webrtc.org8b062002013-07-12 08:28:10 +000022#include "webrtc/typedefs.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000023
24namespace webrtc {
niklase@google.com470e71d2011-07-07 08:21:25 +000025class FilePlayerImpl : public FilePlayer
26{
27public:
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000028 FilePlayerImpl(uint32_t instanceID, FileFormats fileFormat);
niklase@google.com470e71d2011-07-07 08:21:25 +000029 ~FilePlayerImpl();
30
andrew@webrtc.orge59a0ac2012-05-08 17:12:40 +000031 virtual int Get10msAudioFromFile(
32 int16_t* outBuffer,
Peter Kastingdce40cf2015-08-24 14:52:23 -070033 size_t& lengthInSamples,
andrew@webrtc.orge59a0ac2012-05-08 17:12:40 +000034 int frequencyInHz);
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000035 virtual int32_t RegisterModuleFileCallback(FileCallback* callback);
36 virtual int32_t StartPlayingFile(
leozwang@webrtc.org2559cbf2012-02-27 19:18:25 +000037 const char* fileName,
niklase@google.com470e71d2011-07-07 08:21:25 +000038 bool loop,
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000039 uint32_t startPosition,
niklase@google.com470e71d2011-07-07 08:21:25 +000040 float volumeScaling,
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000041 uint32_t notification,
42 uint32_t stopPosition = 0,
niklase@google.com470e71d2011-07-07 08:21:25 +000043 const CodecInst* codecInst = NULL);
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000044 virtual int32_t StartPlayingFile(
niklase@google.com470e71d2011-07-07 08:21:25 +000045 InStream& sourceStream,
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000046 uint32_t startPosition,
niklase@google.com470e71d2011-07-07 08:21:25 +000047 float volumeScaling,
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000048 uint32_t notification,
49 uint32_t stopPosition = 0,
niklase@google.com470e71d2011-07-07 08:21:25 +000050 const CodecInst* codecInst = NULL);
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000051 virtual int32_t StopPlayingFile();
niklase@google.com470e71d2011-07-07 08:21:25 +000052 virtual bool IsPlayingFile() const;
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000053 virtual int32_t GetPlayoutPosition(uint32_t& durationMs);
54 virtual int32_t AudioCodec(CodecInst& audioCodec) const;
55 virtual int32_t Frequency() const;
56 virtual int32_t SetAudioScaling(float scaleFactor);
niklase@google.com470e71d2011-07-07 08:21:25 +000057
58protected:
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000059 int32_t SetUpAudioDecoder();
niklase@google.com470e71d2011-07-07 08:21:25 +000060
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000061 uint32_t _instanceID;
niklase@google.com470e71d2011-07-07 08:21:25 +000062 const FileFormats _fileFormat;
63 MediaFile& _fileModule;
64
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000065 uint32_t _decodedLengthInMS;
niklase@google.com470e71d2011-07-07 08:21:25 +000066
67private:
niklase@google.com470e71d2011-07-07 08:21:25 +000068 AudioCoder _audioDecoder;
69
70 CodecInst _codec;
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000071 int32_t _numberOf10MsPerFrame;
72 int32_t _numberOf10MsInDecoder;
niklase@google.com470e71d2011-07-07 08:21:25 +000073
74 Resampler _resampler;
75 float _scaling;
76};
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +000077} // namespace webrtc
kwiberg9d7eb132016-08-16 04:08:30 -070078#endif // WEBRTC_MODULES_UTILITY_SOURCE_FILE_PLAYER_IMPL_H_