Chromium Code Reviews| Index: media/base/android/webaudio_media_codec_bridge.h |
| diff --git a/media/base/android/webaudio_media_codec_bridge.h b/media/base/android/webaudio_media_codec_bridge.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d49d83a220c8fe6f56868f6000244bcd45551f95 |
| --- /dev/null |
| +++ b/media/base/android/webaudio_media_codec_bridge.h |
| @@ -0,0 +1,58 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef MEDIA_BASE_ANDROID_MEDIA_CODEC_BRIDGE_H_ |
| +#define MEDIA_BASE_ANDROID_MEDIA_CODEC_BRIDGE_H_ |
| + |
| +#include <jni.h> |
| + |
| +#include "base/file_descriptor_posix.h" |
| +#include "base/shared_memory.h" |
| +#include "media/base/media_export.h" |
| + |
| +namespace media { |
| + |
| +// This class serves as a bridge for native code to call Java |
| +// functions in the Android MediaCodec class. See |
| +// http://developer.android.com/reference/android/media/MediaCodec.html. |
| +class MEDIA_EXPORT WebAudioMediaCodecBridge { |
| +public: |
| + // Create the bridge with the given file descriptors. We read from |
| + // |encoded_audio_handle| to get the encoded audio data. Audio file |
| + // information and decoded PCM samples are written to |pcm_output|. |
| + // We also take ownership of |pcm_output|. |
| + WebAudioMediaCodecBridge(base::SharedMemoryHandle encoded_audio_handle, |
| + base::FileDescriptor pcm_output); |
| + ~WebAudioMediaCodecBridge(); |
| + |
| + bool DecodeInMemoryAudioFile(); |
|
acolwell GONE FROM CHROMIUM
2013/04/04 20:53:52
nit: Add comment indicating what this method does
acolwell GONE FROM CHROMIUM
2013/04/04 20:53:52
nit: Can this be made private since it looks like
|
| + static bool RegisterWebAudioMediaCodecBridge(JNIEnv* env); |
|
acolwell GONE FROM CHROMIUM
2013/04/04 20:53:52
nit: Add comment indicating what this method does
|
| + static void RunWebAudioMediaCodec( |
| + base::SharedMemoryHandle encoded_audio_handle, |
| + base::FileDescriptor pcm_output); |
| + |
| + void OnChunkDecoded(JNIEnv* env, |
| + jobject /*java object*/, |
| + jobject buf, |
| + jint buf_size); |
| + |
| + void InitializeDestination(JNIEnv* env, |
| + jobject /*java object*/, |
| + jint channel_count, |
| + jint sample_rate, |
| + jlong duration_us, |
| + jboolean is_vorbis); |
| + |
| +private: |
| + // The encoded audio data is read from this file descriptor for the |
| + // shared memory that holds the encoded data. |
| + int encoded_audio_handle_; |
| + |
| + // The audio file information and decoded pcm data are written to |
| + // this file descriptor. Owned. |
| + int pcm_output_; |
| +}; |
|
acolwell GONE FROM CHROMIUM
2013/04/04 20:53:52
DISALLOW_COPY_AND_ASSIGN(WebAudioMediaCodecBridge)
|
| + |
| +} // namespace media |
| +#endif // MEDIA_BASE_ANDROID_MEDIA_CODEC_BRIDGE_H_ |