Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(221)

Side by Side Diff: media/base/android/webaudio_media_codec_bridge.h

Issue 1372203002: Throttle media decoding after excessive Android media server crashes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: new infobar text per UI review Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MEDIA_BASE_ANDROID_WEBAUDIO_MEDIA_CODEC_BRIDGE_H_ 5 #ifndef MEDIA_BASE_ANDROID_WEBAUDIO_MEDIA_CODEC_BRIDGE_H_
6 #define MEDIA_BASE_ANDROID_WEBAUDIO_MEDIA_CODEC_BRIDGE_H_ 6 #define MEDIA_BASE_ANDROID_WEBAUDIO_MEDIA_CODEC_BRIDGE_H_
7 7
8 #include <jni.h> 8 #include <jni.h>
9 9
10 #include "base/callback.h"
10 #include "base/file_descriptor_posix.h" 11 #include "base/file_descriptor_posix.h"
11 #include "base/memory/shared_memory.h" 12 #include "base/memory/shared_memory.h"
12 #include "media/base/media_export.h" 13 #include "media/base/media_export.h"
13 14
14 namespace media { 15 namespace media {
15 16
16 // This class serves as a bridge for native code to call Java 17 // This class serves as a bridge for native code to call Java
17 // functions in the Android MediaCodec class. See 18 // functions in the Android MediaCodec class. See
18 // http://developer.android.com/reference/android/media/MediaCodec.html. 19 // http://developer.android.com/reference/android/media/MediaCodec.html.
19 class MEDIA_EXPORT WebAudioMediaCodecBridge { 20 class MEDIA_EXPORT WebAudioMediaCodecBridge {
20 public: 21 public:
21 // Create the bridge with the given file descriptors. We read from 22 // Create the bridge with the given file descriptors. We read from
22 // |encoded_audio_handle| to get the encoded audio data. Audio file 23 // |encoded_audio_handle| to get the encoded audio data. Audio file
23 // information and decoded PCM samples are written to |pcm_output|. 24 // information and decoded PCM samples are written to |pcm_output|.
24 // We also take ownership of |pcm_output|. 25 // We also take ownership of |pcm_output|.
25 WebAudioMediaCodecBridge(base::SharedMemoryHandle encoded_audio_handle, 26 WebAudioMediaCodecBridge(base::SharedMemoryHandle encoded_audio_handle,
26 base::FileDescriptor pcm_output, 27 base::FileDescriptor pcm_output,
27 uint32_t data_size); 28 uint32_t data_size);
28 ~WebAudioMediaCodecBridge(); 29 ~WebAudioMediaCodecBridge();
29 30
30 // Inform JNI about this bridge. Returns true if registration 31 // Inform JNI about this bridge. Returns true if registration
31 // succeeded. 32 // succeeded.
32 static bool RegisterWebAudioMediaCodecBridge(JNIEnv* env); 33 static bool RegisterWebAudioMediaCodecBridge(JNIEnv* env);
33 34
34 // Start MediaCodec to process the encoded data in 35 // Start MediaCodec to process the encoded data in
35 // |encoded_audio_handle|. The PCM samples are sent to |pcm_output|. 36 // |encoded_audio_handle|. The PCM samples are sent to |pcm_output|.
36 static void RunWebAudioMediaCodec( 37 static void RunWebAudioMediaCodec(
37 base::SharedMemoryHandle encoded_audio_handle, 38 base::SharedMemoryHandle encoded_audio_handle,
38 base::FileDescriptor pcm_output, 39 base::FileDescriptor pcm_output,
39 uint32_t data_size); 40 uint32_t data_size,
41 base::Closure on_decode_finished_cb);
40 42
41 void OnChunkDecoded(JNIEnv* env, 43 void OnChunkDecoded(JNIEnv* env,
42 jobject /*java object*/, 44 jobject /*java object*/,
43 jobject buf, 45 jobject buf,
44 jint buf_size, 46 jint buf_size,
45 jint input_channel_count, 47 jint input_channel_count,
46 jint output_channel_count); 48 jint output_channel_count);
47 49
48 void InitializeDestination(JNIEnv* env, 50 void InitializeDestination(JNIEnv* env,
49 jobject /*java object*/, 51 jobject /*java object*/,
(...skipping 21 matching lines...) Expand all
71 int pcm_output_; 73 int pcm_output_;
72 74
73 // The length of the encoded data. 75 // The length of the encoded data.
74 uint32_t data_size_; 76 uint32_t data_size_;
75 77
76 DISALLOW_COPY_AND_ASSIGN(WebAudioMediaCodecBridge); 78 DISALLOW_COPY_AND_ASSIGN(WebAudioMediaCodecBridge);
77 }; 79 };
78 80
79 } // namespace media 81 } // namespace media
80 #endif // MEDIA_BASE_ANDROID_WEBAUDIO_MEDIA_CODEC_BRIDGE_H_ 82 #endif // MEDIA_BASE_ANDROID_WEBAUDIO_MEDIA_CODEC_BRIDGE_H_
OLDNEW
« no previous file with comments | « media/base/android/video_decoder_job.cc ('k') | media/base/android/webaudio_media_codec_bridge.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698