OLD | NEW |
| (Empty) |
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_INCLUDE_FILE_PLAYER_H_ | |
12 #define WEBRTC_MODULES_UTILITY_INCLUDE_FILE_PLAYER_H_ | |
13 | |
14 #pragma message("WARNING: utility/interface is DEPRECATED; use utility/include") | |
15 | |
16 #include "webrtc/common_types.h" | |
17 #include "webrtc/engine_configurations.h" | |
18 #include "webrtc/modules/include/module_common_types.h" | |
19 #include "webrtc/typedefs.h" | |
20 #include "webrtc/video_frame.h" | |
21 | |
22 namespace webrtc { | |
23 class FileCallback; | |
24 | |
25 class FilePlayer | |
26 { | |
27 public: | |
28 // The largest decoded frame size in samples (60ms with 32kHz sample rate). | |
29 enum {MAX_AUDIO_BUFFER_IN_SAMPLES = 60*32}; | |
30 enum {MAX_AUDIO_BUFFER_IN_BYTES = MAX_AUDIO_BUFFER_IN_SAMPLES*2}; | |
31 | |
32 // Note: will return NULL for unsupported formats. | |
33 static FilePlayer* CreateFilePlayer(const uint32_t instanceID, | |
34 const FileFormats fileFormat); | |
35 | |
36 static void DestroyFilePlayer(FilePlayer* player); | |
37 | |
38 // Read 10 ms of audio at |frequencyInHz| to |outBuffer|. |lengthInSamples| | |
39 // will be set to the number of samples read (not the number of samples per | |
40 // channel). | |
41 virtual int Get10msAudioFromFile( | |
42 int16_t* outBuffer, | |
43 size_t& lengthInSamples, | |
44 int frequencyInHz) = 0; | |
45 | |
46 // Register callback for receiving file playing notifications. | |
47 virtual int32_t RegisterModuleFileCallback( | |
48 FileCallback* callback) = 0; | |
49 | |
50 // API for playing audio from fileName to channel. | |
51 // Note: codecInst is used for pre-encoded files. | |
52 virtual int32_t StartPlayingFile( | |
53 const char* fileName, | |
54 bool loop, | |
55 uint32_t startPosition, | |
56 float volumeScaling, | |
57 uint32_t notification, | |
58 uint32_t stopPosition = 0, | |
59 const CodecInst* codecInst = NULL) = 0; | |
60 | |
61 // Note: codecInst is used for pre-encoded files. | |
62 virtual int32_t StartPlayingFile( | |
63 InStream& sourceStream, | |
64 uint32_t startPosition, | |
65 float volumeScaling, | |
66 uint32_t notification, | |
67 uint32_t stopPosition = 0, | |
68 const CodecInst* codecInst = NULL) = 0; | |
69 | |
70 virtual int32_t StopPlayingFile() = 0; | |
71 | |
72 virtual bool IsPlayingFile() const = 0; | |
73 | |
74 virtual int32_t GetPlayoutPosition(uint32_t& durationMs) = 0; | |
75 | |
76 // Set audioCodec to the currently used audio codec. | |
77 virtual int32_t AudioCodec(CodecInst& audioCodec) const = 0; | |
78 | |
79 virtual int32_t Frequency() const = 0; | |
80 | |
81 // Note: scaleFactor is in the range [0.0 - 2.0] | |
82 virtual int32_t SetAudioScaling(float scaleFactor) = 0; | |
83 | |
84 // Return the time in ms until next video frame should be pulled (by | |
85 // calling GetVideoFromFile(..)). | |
86 // Note: this API reads one video frame from file. This means that it should | |
87 // be called exactly once per GetVideoFromFile(..) API call. | |
88 virtual int32_t TimeUntilNextVideoFrame() { return -1;} | |
89 | |
90 virtual int32_t StartPlayingVideoFile( | |
91 const char* /*fileName*/, | |
92 bool /*loop*/, | |
93 bool /*videoOnly*/) { return -1;} | |
94 | |
95 virtual int32_t video_codec_info(VideoCodec& /*videoCodec*/) const | |
96 {return -1;} | |
97 | |
98 virtual int32_t GetVideoFromFile(VideoFrame& /*videoFrame*/) { return -1; } | |
99 | |
100 // Same as GetVideoFromFile(). videoFrame will have the resolution specified | |
101 // by the width outWidth and height outHeight in pixels. | |
102 virtual int32_t GetVideoFromFile(VideoFrame& /*videoFrame*/, | |
103 const uint32_t /*outWidth*/, | |
104 const uint32_t /*outHeight*/) { | |
105 return -1; | |
106 } | |
107 | |
108 protected: | |
109 virtual ~FilePlayer() {} | |
110 | |
111 }; | |
112 } // namespace webrtc | |
113 #endif // WEBRTC_MODULES_UTILITY_INCLUDE_FILE_PLAYER_H_ | |
OLD | NEW |