Index: media/base/android/media_codec_bridge.h |
diff --git a/media/base/android/media_codec_bridge.h b/media/base/android/media_codec_bridge.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..73b94a2245f4013077a7d9ecd63c51698fe0bc6c |
--- /dev/null |
+++ b/media/base/android/media_codec_bridge.h |
@@ -0,0 +1,88 @@ |
+// 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 <string> |
+ |
+#include "base/android/scoped_java_ref.h" |
+//#include "base/callback.h" |
+//#include "base/memory/ref_counted.h" |
Ami GONE FROM CHROMIUM
2013/01/23 01:32:32
remove prev 2 lines
dwkang1
2013/01/28 14:54:30
Done.
|
+ |
+// This class serves as a bridge for native code to call java functions inside |
Ami GONE FROM CHROMIUM
2013/01/23 01:32:32
Move down to immediately precede class declaration
dwkang1
2013/01/28 14:54:30
Done.
|
+// Android MediaCodec class. For more information on Android MediaCodec, check |
+// http://developer.android.com/reference/android/media/MediaCodec.html |
+ |
+namespace media { |
+ |
+class MediaCodecBridge { |
+ public: |
+ enum BufferFlag { |
+ BUFFER_FLAG_END_OF_STREAM = 4, |
+ BUFFER_FLAG_CODEC_CONFIG = 2, |
+ BUFFER_FLAG_FLAG_SYNC_FRAME = 1, |
+ }; |
+ |
+ enum DequeueBufferInfo { |
+ INFO_OUTPUT_BUFFERS_CHANGED = -3, |
+ INFO_OUTPUT_FORMAT_CHANGED = -2, |
+ INFO_TRY_AGAIN_LATER = -1, |
+ }; |
+ |
+ explicit MediaCodecBridge(const std::string& type); |
Ami GONE FROM CHROMIUM
2013/01/23 01:32:32
s/type/mime_type/
Ami GONE FROM CHROMIUM
2013/01/23 01:32:32
It seems wrong to me for this to be a ctor and not
dwkang1
2013/01/28 14:54:30
Done.
|
+ |
+ ~MediaCodecBridge(); |
+ |
+ void ConfigureAudio(const std::string& mime, int sample_rate, |
Ami GONE FROM CHROMIUM
2013/01/23 01:32:32
s/mime/mime_type/
dwkang1
2013/01/28 14:54:30
Done.
|
+ int channel_count, const uint8* csd0, int csd0_size, const uint8* csd1, |
Ami GONE FROM CHROMIUM
2013/01/23 01:32:32
What's up with these csd0/1 params?
(why exactly 2
dwkang1
2013/01/28 14:54:30
Actually, they are optional params for codec speci
|
+ int csd1_size, int encoder_delay, int encoder_padding, |
+ int max_input_size); |
+ void ConfigureVideo(const std::string& mime, int width, int height, |
+ const uint8* csd0, int csd0_size, const uint8* csd1, int csd1_size, |
Ami GONE FROM CHROMIUM
2013/01/23 01:32:32
Ditto csd questions, and in fact I think you shoul
dwkang1
2013/01/28 14:54:30
Ditto.
|
+ jobject surface); |
+ |
+ void Start(); |
+ void Flush(); |
Ami GONE FROM CHROMIUM
2013/01/23 01:32:32
I think MediaCodec.flush() is something media:: co
dwkang1
2013/01/28 14:54:30
Actually, mediacodec's flush is somewhat different
|
+ void Stop(); |
Ami GONE FROM CHROMIUM
2013/01/23 01:32:32
Stop() is irreversible in most media:: code. Plea
dwkang1
2013/01/28 14:54:30
Done.
|
+ void Release(); |
Ami GONE FROM CHROMIUM
2013/01/23 01:32:32
Again, please document what this does. Why would
dwkang1
2013/01/28 14:54:30
Agreed that this is not necessary in C++.
|
+ |
+ void GetOutputFormat(int* format, int* width, int* height); |
+ |
+ void QueueInputBuffer(int index, int offset, int size, |
+ int64 presentation_time_us, int flags); |
+ int DequeueInputBuffer(int64 timeout_us); |
Ami GONE FROM CHROMIUM
2013/01/23 01:32:32
document API
(I'll stop commenting on this explici
Ami GONE FROM CHROMIUM
2013/01/23 01:32:32
I question the value of providing a "waiting" API
dwkang1
2013/01/28 14:54:30
I made AVDA use 0us for timeout, but I think havi
|
+ int DequeueOutputBuffer( |
+ int64 timeout_us, int* offset, int* size, int64* presentation_time_us, |
+ int* flags); |
+ void ReleaseOutputBuffer(int index, bool render); |
+ |
+ int GetInputBuffers(); |
+ int GetOutputBuffers(); |
+ |
+ void PutToInputBuffer(int index, const uint8* data, int size); |
+ void GetFromOutputBuffer(int index, int offset, uint8* data, int size); |
+ void GetFromOutputBuffer(int index, |
Ami GONE FROM CHROMIUM
2013/01/23 01:32:32
Neither of the GetFromOutputBuffer methods is call
dwkang1
2013/01/28 14:54:30
Done. Surface is passed when we call configure().
|
+ uint8* data0, int size0, |
+ uint8* data1, int size1, |
+ uint8* data2, int size2); |
+ |
+ private: |
+ // Java MediaCodec instance. |
+ base::android::ScopedJavaGlobalRef<jobject> j_media_codec_; |
+ |
+ base::android::ScopedJavaGlobalRef<jobjectArray> j_input_buffers_; |
+ base::android::ScopedJavaGlobalRef<jobjectArray> j_output_buffers_; |
+ |
+ int j_byte_array_size_; |
+ base::android::ScopedJavaGlobalRef<jbyteArray> j_byte_array_; |
Ami GONE FROM CHROMIUM
2013/01/23 01:32:32
Unused (both prev lines)?
dwkang1
2013/01/28 14:54:30
Done.
|
+ |
+ DISALLOW_COPY_AND_ASSIGN(MediaCodecBridge); |
+}; |
+ |
+} // namespace media |
+ |
+#endif // MEDIA_BASE_ANDROID_MEDIA_CODEC_BRIDGE_H_ |
+ |