blob: 9ae383851539f4ab58a30a31bdf14bd067b1e1f8 [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
14#include "coder.h"
15#include "common_types.h"
16#include "critical_section_wrapper.h"
17#include "engine_configurations.h"
18#include "file_player.h"
19#include "media_file_defines.h"
20#include "media_file.h"
21#include "resampler.h"
22#include "tick_util.h"
23#include "typedefs.h"
24
25namespace webrtc {
26class VideoCoder;
27class FrameScaler;
28
29class FilePlayerImpl : public FilePlayer
30{
31public:
32 FilePlayerImpl(WebRtc_UWord32 instanceID, FileFormats fileFormat);
33 ~FilePlayerImpl();
34
andrew@webrtc.orge59a0ac2012-05-08 17:12:40 +000035 virtual int Get10msAudioFromFile(
36 int16_t* outBuffer,
37 int& lengthInSamples,
38 int frequencyInHz);
niklase@google.com470e71d2011-07-07 08:21:25 +000039 virtual WebRtc_Word32 RegisterModuleFileCallback(FileCallback* callback);
40 virtual WebRtc_Word32 StartPlayingFile(
leozwang@webrtc.org2559cbf2012-02-27 19:18:25 +000041 const char* fileName,
niklase@google.com470e71d2011-07-07 08:21:25 +000042 bool loop,
43 WebRtc_UWord32 startPosition,
44 float volumeScaling,
45 WebRtc_UWord32 notification,
46 WebRtc_UWord32 stopPosition = 0,
47 const CodecInst* codecInst = NULL);
48 virtual WebRtc_Word32 StartPlayingFile(
49 InStream& sourceStream,
50 WebRtc_UWord32 startPosition,
51 float volumeScaling,
52 WebRtc_UWord32 notification,
53 WebRtc_UWord32 stopPosition = 0,
54 const CodecInst* codecInst = NULL);
55 virtual WebRtc_Word32 StopPlayingFile();
56 virtual bool IsPlayingFile() const;
57 virtual WebRtc_Word32 GetPlayoutPosition(WebRtc_UWord32& durationMs);
58 virtual WebRtc_Word32 AudioCodec(CodecInst& audioCodec) const;
59 virtual WebRtc_Word32 Frequency() const;
60 virtual WebRtc_Word32 SetAudioScaling(float scaleFactor);
61
62protected:
63 WebRtc_Word32 SetUpAudioDecoder();
64
65 WebRtc_UWord32 _instanceID;
66 const FileFormats _fileFormat;
67 MediaFile& _fileModule;
68
69 WebRtc_UWord32 _decodedLengthInMS;
70
71private:
niklase@google.com470e71d2011-07-07 08:21:25 +000072 AudioCoder _audioDecoder;
73
74 CodecInst _codec;
75 WebRtc_Word32 _numberOf10MsPerFrame;
76 WebRtc_Word32 _numberOf10MsInDecoder;
77
78 Resampler _resampler;
79 float _scaling;
80};
81
82#ifdef WEBRTC_MODULE_UTILITY_VIDEO
83class VideoFilePlayerImpl: public FilePlayerImpl
84{
85public:
86 VideoFilePlayerImpl(WebRtc_UWord32 instanceID, FileFormats fileFormat);
87 ~VideoFilePlayerImpl();
88
89 // FilePlayer functions.
90 virtual WebRtc_Word32 TimeUntilNextVideoFrame();
leozwang@webrtc.org2559cbf2012-02-27 19:18:25 +000091 virtual WebRtc_Word32 StartPlayingVideoFile(const char* fileName,
niklase@google.com470e71d2011-07-07 08:21:25 +000092 bool loop,
93 bool videoOnly);
94 virtual WebRtc_Word32 StopPlayingFile();
95 virtual WebRtc_Word32 video_codec_info(VideoCodec& videoCodec) const;
96 virtual WebRtc_Word32 GetVideoFromFile(VideoFrame& videoFrame);
97 virtual WebRtc_Word32 GetVideoFromFile(VideoFrame& videoFrame,
98 const WebRtc_UWord32 outWidth,
99 const WebRtc_UWord32 outHeight);
100
101private:
102 WebRtc_Word32 SetUpVideoDecoder();
103
104 VideoCoder& _videoDecoder;
105 VideoCodec video_codec_info_;
106 WebRtc_Word32 _decodedVideoFrames;
107
108 EncodedVideoData& _encodedData;
109
110 FrameScaler& _frameScaler;
henrike@webrtc.org105e0712011-12-16 19:53:46 +0000111 CriticalSectionWrapper* _critSec;
niklase@google.com470e71d2011-07-07 08:21:25 +0000112 TickTime _startTime;
113 WebRtc_Word64 _accumulatedRenderTimeMs;
114 WebRtc_UWord32 _frameLengthMS;
115
116 WebRtc_Word32 _numberOfFramesRead;
117 bool _videoOnly;
118};
119#endif //WEBRTC_MODULE_UTILITY_VIDEO
120
121} // namespace webrtc
122#endif // WEBRTC_MODULES_UTILITY_SOURCE_FILE_PLAYER_IMPL_H_