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 21 matching lines...) Expand all Loading... | |
32 INFO_TRY_AGAIN_LATER = -1, | 32 INFO_TRY_AGAIN_LATER = -1, |
33 INFO_MEDIA_CODEC_ERROR = -1000, | 33 INFO_MEDIA_CODEC_ERROR = -1000, |
34 }; | 34 }; |
35 | 35 |
36 static const base::TimeDelta kTimeOutInfinity; | 36 static const base::TimeDelta kTimeOutInfinity; |
37 static const base::TimeDelta kTimeOutNoWait; | 37 static const base::TimeDelta kTimeOutNoWait; |
38 | 38 |
39 // Returns true if MediaCodec is available on the device. | 39 // Returns true if MediaCodec is available on the device. |
40 static bool IsAvailable(); | 40 static bool IsAvailable(); |
41 | 41 |
42 // Returns if MediaCodecBridge has a decoder that |is_secure| and can decode | |
ddorwin
2013/08/28 18:41:56
nit: "if" > "true if" or "whether"
xhwang
2013/08/30 05:32:38
Done.
| |
43 // |codec| type. | |
44 static bool CanDecode(const std::string& codec, bool is_secure); | |
45 | |
42 virtual ~MediaCodecBridge(); | 46 virtual ~MediaCodecBridge(); |
43 | 47 |
44 // Resets both input and output, all indices previously returned in calls to | 48 // Resets both input and output, all indices previously returned in calls to |
45 // DequeueInputBuffer() and DequeueOutputBuffer() become invalid. | 49 // DequeueInputBuffer() and DequeueOutputBuffer() become invalid. |
46 // Please note that this clears all the inputs in the media codec. In other | 50 // Please note that this clears all the inputs in the media codec. In other |
47 // words, there will be no outputs until new input is provided. | 51 // words, there will be no outputs until new input is provided. |
48 void Reset(); | 52 void Reset(); |
49 | 53 |
50 // Finishes the decode/encode session. The instance remains active | 54 // Finishes the decode/encode session. The instance remains active |
51 // and ready to be StartAudio/Video()ed again. HOWEVER, due to the buggy | 55 // and ready to be StartAudio/Video()ed again. HOWEVER, due to the buggy |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
93 // when configuring this video decoder you can optionally render the buffer. | 97 // when configuring this video decoder you can optionally render the buffer. |
94 void ReleaseOutputBuffer(int index, bool render); | 98 void ReleaseOutputBuffer(int index, bool render); |
95 | 99 |
96 // Gets output buffers from media codec and keeps them inside the java class. | 100 // Gets output buffers from media codec and keeps them inside the java class. |
97 // To access them, use DequeueOutputBuffer(). | 101 // To access them, use DequeueOutputBuffer(). |
98 void GetOutputBuffers(); | 102 void GetOutputBuffers(); |
99 | 103 |
100 static bool RegisterMediaCodecBridge(JNIEnv* env); | 104 static bool RegisterMediaCodecBridge(JNIEnv* env); |
101 | 105 |
102 protected: | 106 protected: |
103 explicit MediaCodecBridge(const char* mime); | 107 explicit MediaCodecBridge(const std::string& mime); |
104 | 108 |
105 // Calls start() against the media codec instance. Used in StartXXX() after | 109 // Calls start() against the media codec instance. Used in StartXXX() after |
106 // configuring media codec. | 110 // configuring media codec. |
107 void StartInternal(); | 111 void StartInternal(); |
108 | 112 |
109 jobject media_codec() { return j_media_codec_.obj(); } | 113 jobject media_codec() { return j_media_codec_.obj(); } |
110 | 114 |
111 private: | 115 private: |
112 // Fills a particular input buffer and returns the size of copied data. | 116 // Fills a particular input buffer and returns the size of copied data. |
113 size_t FillInputBuffer(int index, const uint8* data, int data_size); | 117 size_t FillInputBuffer(int index, const uint8* data, int data_size); |
(...skipping 16 matching lines...) Expand all Loading... | |
130 bool play_audio, jobject media_crypto); | 134 bool play_audio, jobject media_crypto); |
131 | 135 |
132 // Play the output buffer. This call must be called after | 136 // Play the output buffer. This call must be called after |
133 // DequeueOutputBuffer() and before ReleaseOutputBuffer. | 137 // DequeueOutputBuffer() and before ReleaseOutputBuffer. |
134 void PlayOutputBuffer(int index, size_t size); | 138 void PlayOutputBuffer(int index, size_t size); |
135 | 139 |
136 // Set the volume of the audio output. | 140 // Set the volume of the audio output. |
137 void SetVolume(double volume); | 141 void SetVolume(double volume); |
138 | 142 |
139 private: | 143 private: |
140 explicit AudioCodecBridge(const char* mime); | 144 explicit AudioCodecBridge(const std::string& mime); |
141 | 145 |
142 // Configure the java MediaFormat object with the extra codec data passed in. | 146 // Configure the java MediaFormat object with the extra codec data passed in. |
143 bool ConfigureMediaFormat(jobject j_format, const AudioCodec codec, | 147 bool ConfigureMediaFormat(jobject j_format, const AudioCodec codec, |
144 const uint8* extra_data, size_t extra_data_size); | 148 const uint8* extra_data, size_t extra_data_size); |
145 }; | 149 }; |
146 | 150 |
147 class MEDIA_EXPORT VideoCodecBridge : public MediaCodecBridge { | 151 class MEDIA_EXPORT VideoCodecBridge : public MediaCodecBridge { |
148 public: | 152 public: |
149 // Returns an VideoCodecBridge instance if |codec| is supported, or a NULL | 153 // Returns an VideoCodecBridge instance if |codec| is supported, or a NULL |
150 // pointer otherwise. | 154 // pointer otherwise. |
151 static VideoCodecBridge* Create(const VideoCodec codec); | 155 static VideoCodecBridge* Create(const VideoCodec codec); |
152 | 156 |
153 // Start the video codec bridge. | 157 // Start the video codec bridge. |
154 // TODO(qinmin): Pass codec specific data if available. | 158 // TODO(qinmin): Pass codec specific data if available. |
155 bool Start(const VideoCodec codec, const gfx::Size& size, jobject surface, | 159 bool Start(const VideoCodec codec, const gfx::Size& size, jobject surface, |
156 jobject media_crypto); | 160 jobject media_crypto); |
157 | 161 |
158 private: | 162 private: |
159 explicit VideoCodecBridge(const char* mime); | 163 explicit VideoCodecBridge(const std::string& mime); |
160 }; | 164 }; |
161 | 165 |
162 } // namespace media | 166 } // namespace media |
163 | 167 |
164 #endif // MEDIA_BASE_ANDROID_MEDIA_CODEC_BRIDGE_H_ | 168 #endif // MEDIA_BASE_ANDROID_MEDIA_CODEC_BRIDGE_H_ |
165 | 169 |
OLD | NEW |