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

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

Issue 11973010: AndroidVDA by using Android's MediaCodec API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 11 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
(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 #include <string>
10
11 #include "base/android/scoped_java_ref.h"
12 //#include "base/callback.h"
13 //#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.
14
15 // 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.
16 // Android MediaCodec class. For more information on Android MediaCodec, check
17 // http://developer.android.com/reference/android/media/MediaCodec.html
18
19 namespace media {
20
21 class MediaCodecBridge {
22 public:
23 enum BufferFlag {
24 BUFFER_FLAG_END_OF_STREAM = 4,
25 BUFFER_FLAG_CODEC_CONFIG = 2,
26 BUFFER_FLAG_FLAG_SYNC_FRAME = 1,
27 };
28
29 enum DequeueBufferInfo {
30 INFO_OUTPUT_BUFFERS_CHANGED = -3,
31 INFO_OUTPUT_FORMAT_CHANGED = -2,
32 INFO_TRY_AGAIN_LATER = -1,
33 };
34
35 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.
36
37 ~MediaCodecBridge();
38
39 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.
40 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
41 int csd1_size, int encoder_delay, int encoder_padding,
42 int max_input_size);
43 void ConfigureVideo(const std::string& mime, int width, int height,
44 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.
45 jobject surface);
46
47 void Start();
48 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
49 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.
50 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++.
51
52 void GetOutputFormat(int* format, int* width, int* height);
53
54 void QueueInputBuffer(int index, int offset, int size,
55 int64 presentation_time_us, int flags);
56 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
57 int DequeueOutputBuffer(
58 int64 timeout_us, int* offset, int* size, int64* presentation_time_us,
59 int* flags);
60 void ReleaseOutputBuffer(int index, bool render);
61
62 int GetInputBuffers();
63 int GetOutputBuffers();
64
65 void PutToInputBuffer(int index, const uint8* data, int size);
66 void GetFromOutputBuffer(int index, int offset, uint8* data, int size);
67 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().
68 uint8* data0, int size0,
69 uint8* data1, int size1,
70 uint8* data2, int size2);
71
72 private:
73 // Java MediaCodec instance.
74 base::android::ScopedJavaGlobalRef<jobject> j_media_codec_;
75
76 base::android::ScopedJavaGlobalRef<jobjectArray> j_input_buffers_;
77 base::android::ScopedJavaGlobalRef<jobjectArray> j_output_buffers_;
78
79 int j_byte_array_size_;
80 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.
81
82 DISALLOW_COPY_AND_ASSIGN(MediaCodecBridge);
83 };
84
85 } // namespace media
86
87 #endif // MEDIA_BASE_ANDROID_MEDIA_CODEC_BRIDGE_H_
88
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698