OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef MEDIA_BASE_ANDROID_MEDIA_CODEC_BRIDGE_H_ | |
6 #define MEDIA_BASE_ANDROID_MEDIA_CODEC_BRIDGE_H_ | |
7 | |
8 #include <jni.h> | |
9 | |
10 #include "base/file_descriptor_posix.h" | |
11 #include "base/shared_memory.h" | |
12 #include "media/base/media_export.h" | |
13 | |
14 namespace media { | |
15 | |
16 // This class serves as a bridge for native code to call java functions inside | |
17 // android mediaplayer class. For more information on android mediaplayer, check | |
18 // http://developer.android.com/reference/android/media/MediaPlayer.html | |
19 // The actual android mediaplayer instance is created lazily when Start(), | |
20 // Pause(), SeekTo() gets called. As a result, media information may not | |
21 // be available until one of those operations is performed. After that, we | |
22 // will cache those information in case the mediaplayer gets released. | |
23 class MEDIA_EXPORT WebAudioMediaCodecBridge { | |
24 public: | |
25 WebAudioMediaCodecBridge(base::SharedMemoryHandle input_fd, | |
felipeg
2013/03/29 17:18:29
Add a comment saying that this class takes ownersh
| |
26 base::FileDescriptor output_fd); | |
27 ~WebAudioMediaCodecBridge(); | |
28 | |
29 bool DecodeInMemoryAudioFile(); | |
30 static bool RegisterWebAudioMediaCodecBridge(JNIEnv* env); | |
31 static void RunWebAudioMediaCodec(base::SharedMemoryHandle input_fd, | |
32 base::FileDescriptor output_fd); | |
33 | |
34 void OnChunkDecoded(JNIEnv* env, | |
35 jobject /*java object*/, | |
36 jobject buf, | |
37 jint buf_size); | |
38 | |
39 void InitializeDestination(JNIEnv* env, | |
40 jobject /*java object*/, | |
41 jint number_of_channels, | |
42 jint sample_rate, | |
43 jlong duration_us, | |
44 jboolean is_vorbis); | |
45 | |
46 private: | |
47 // The encoded audio data is read from this file descriptor for the | |
48 // shared memory that holds the encoded data. | |
49 int input_fd_; | |
felipeg
2013/03/29 17:18:29
// Owned.
| |
50 | |
51 // The audio file information and decoded pcm data are written to | |
52 // this file descriptor. | |
53 int output_fd_; | |
54 }; | |
55 | |
56 } // namespace media | |
57 #endif // MEDIA_BASE_ANDROID_MEDIA_CODEC_BRIDGE_H_ | |
OLD | NEW |