OLD | NEW |
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_MEDIA_CODEC_BRIDGE_H_ | 5 #ifndef MEDIA_BASE_ANDROID_MEDIA_CODEC_BRIDGE_H_ |
6 #define MEDIA_BASE_ANDROID_MEDIA_CODEC_BRIDGE_H_ | 6 #define MEDIA_BASE_ANDROID_MEDIA_CODEC_BRIDGE_H_ |
7 | 7 |
8 #include <jni.h> | 8 #include <jni.h> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 base::TimeDelta* presentation_time, bool* end_of_stream); | 78 base::TimeDelta* presentation_time, bool* end_of_stream); |
79 | 79 |
80 // Returns the buffer to the codec. If you previously specified a surface | 80 // Returns the buffer to the codec. If you previously specified a surface |
81 // when configuring this video decoder you can optionally render the buffer. | 81 // when configuring this video decoder you can optionally render the buffer. |
82 void ReleaseOutputBuffer(int index, bool render); | 82 void ReleaseOutputBuffer(int index, bool render); |
83 | 83 |
84 // Gets output buffers from media codec and keeps them inside the java class. | 84 // Gets output buffers from media codec and keeps them inside the java class. |
85 // To access them, use DequeueOutputBuffer(). | 85 // To access them, use DequeueOutputBuffer(). |
86 void GetOutputBuffers(); | 86 void GetOutputBuffers(); |
87 | 87 |
| 88 static bool RegisterMediaCodecBridge(JNIEnv* env); |
| 89 |
88 protected: | 90 protected: |
89 explicit MediaCodecBridge(const char* mime); | 91 explicit MediaCodecBridge(const char* mime); |
90 | 92 |
91 // Calls start() against the media codec instance. Used in StartXXX() after | 93 // Calls start() against the media codec instance. Used in StartXXX() after |
92 // configuring media codec. | 94 // configuring media codec. |
93 void StartInternal(); | 95 void StartInternal(); |
94 | 96 |
95 jobject media_codec() { return j_media_codec_.obj(); } | 97 jobject media_codec() { return j_media_codec_.obj(); } |
96 | 98 |
97 private: | 99 private: |
98 // Java MediaCodec instance. | 100 // Java MediaCodec instance. |
99 base::android::ScopedJavaGlobalRef<jobject> j_media_codec_; | 101 base::android::ScopedJavaGlobalRef<jobject> j_media_codec_; |
100 | 102 |
101 DISALLOW_COPY_AND_ASSIGN(MediaCodecBridge); | 103 DISALLOW_COPY_AND_ASSIGN(MediaCodecBridge); |
102 }; | 104 }; |
103 | 105 |
104 class AudioCodecBridge : public MediaCodecBridge { | 106 class AudioCodecBridge : public MediaCodecBridge { |
105 public: | 107 public: |
106 explicit AudioCodecBridge(const AudioCodec codec); | 108 // Returns an AudioCodecBridge instance if |codec| is supported, or a NULL |
| 109 // pointer otherwise. |
| 110 static AudioCodecBridge* Create(const AudioCodec codec); |
107 | 111 |
108 // Start the audio codec bridge. | 112 // Start the audio codec bridge. |
109 bool Start(const AudioCodec codec, int sample_rate, int channel_count, | 113 bool Start(const AudioCodec codec, int sample_rate, int channel_count, |
110 const uint8* extra_data, size_t extra_data_size, | 114 const uint8* extra_data, size_t extra_data_size, |
111 bool play_audio); | 115 bool play_audio); |
112 | 116 |
113 // Play the output buffer. This call must be called after | 117 // Play the output buffer. This call must be called after |
114 // DequeueOutputBuffer() and before ReleaseOutputBuffer. | 118 // DequeueOutputBuffer() and before ReleaseOutputBuffer. |
115 void PlayOutputBuffer(int index, size_t size); | 119 void PlayOutputBuffer(int index, size_t size); |
| 120 |
| 121 private: |
| 122 explicit AudioCodecBridge(const char* mime); |
116 }; | 123 }; |
117 | 124 |
118 class VideoCodecBridge : public MediaCodecBridge { | 125 class VideoCodecBridge : public MediaCodecBridge { |
119 public: | 126 public: |
120 explicit VideoCodecBridge(const VideoCodec codec); | 127 // Returns an VideoCodecBridge instance if |codec| is supported, or a NULL |
| 128 // pointer otherwise. |
| 129 static VideoCodecBridge* Create(const VideoCodec codec); |
121 | 130 |
122 // Start the video codec bridge. | 131 // Start the video codec bridge. |
123 // TODO(qinmin): Pass codec specific data if available. | 132 // TODO(qinmin): Pass codec specific data if available. |
124 bool Start( | 133 bool Start( |
125 const VideoCodec codec, const gfx::Size& size, jobject surface); | 134 const VideoCodec codec, const gfx::Size& size, jobject surface); |
| 135 |
| 136 private: |
| 137 explicit VideoCodecBridge(const char* mime); |
126 }; | 138 }; |
127 | 139 |
128 } // namespace media | 140 } // namespace media |
129 | 141 |
130 #endif // MEDIA_BASE_ANDROID_MEDIA_CODEC_BRIDGE_H_ | 142 #endif // MEDIA_BASE_ANDROID_MEDIA_CODEC_BRIDGE_H_ |
131 | 143 |
OLD | NEW |