niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
leozwang@webrtc.org | 2559cbf | 2012-02-27 19:18:25 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 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 "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 | |
| 25 | namespace webrtc { |
| 26 | class VideoCoder; |
| 27 | class FrameScaler; |
| 28 | |
| 29 | class FilePlayerImpl : public FilePlayer |
| 30 | { |
| 31 | public: |
| 32 | FilePlayerImpl(WebRtc_UWord32 instanceID, FileFormats fileFormat); |
| 33 | ~FilePlayerImpl(); |
| 34 | |
andrew@webrtc.org | e59a0ac | 2012-05-08 17:12:40 +0000 | [diff] [blame] | 35 | virtual int Get10msAudioFromFile( |
| 36 | int16_t* outBuffer, |
| 37 | int& lengthInSamples, |
| 38 | int frequencyInHz); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 39 | virtual WebRtc_Word32 RegisterModuleFileCallback(FileCallback* callback); |
| 40 | virtual WebRtc_Word32 StartPlayingFile( |
leozwang@webrtc.org | 2559cbf | 2012-02-27 19:18:25 +0000 | [diff] [blame] | 41 | const char* fileName, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 42 | 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 | |
| 62 | protected: |
| 63 | WebRtc_Word32 SetUpAudioDecoder(); |
| 64 | |
| 65 | WebRtc_UWord32 _instanceID; |
| 66 | const FileFormats _fileFormat; |
| 67 | MediaFile& _fileModule; |
| 68 | |
| 69 | WebRtc_UWord32 _decodedLengthInMS; |
| 70 | |
| 71 | private: |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 72 | 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 |
| 83 | class VideoFilePlayerImpl: public FilePlayerImpl |
| 84 | { |
| 85 | public: |
| 86 | VideoFilePlayerImpl(WebRtc_UWord32 instanceID, FileFormats fileFormat); |
| 87 | ~VideoFilePlayerImpl(); |
| 88 | |
| 89 | // FilePlayer functions. |
| 90 | virtual WebRtc_Word32 TimeUntilNextVideoFrame(); |
leozwang@webrtc.org | 2559cbf | 2012-02-27 19:18:25 +0000 | [diff] [blame] | 91 | virtual WebRtc_Word32 StartPlayingVideoFile(const char* fileName, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 92 | 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 | |
| 101 | private: |
| 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.org | 105e071 | 2011-12-16 19:53:46 +0000 | [diff] [blame] | 111 | CriticalSectionWrapper* _critSec; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 112 | 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_ |