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

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

Issue 1764813002: Catch CodecException in MediaCodecBridge and return MEDIA_CODEC_ERROR (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: dale's comment Created 4 years, 9 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_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 <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <set> 11 #include <set>
12 #include <string> 12 #include <string>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/time/time.h" 17 #include "base/time/time.h"
18 #include "media/base/android/media_codec_util.h" 18 #include "media/base/android/media_codec_util.h"
19 #include "media/base/media_export.h" 19 #include "media/base/media_export.h"
20 #include "ui/gfx/geometry/size.h"
20 21
21 namespace media { 22 namespace media {
22 23
23 struct SubsampleEntry; 24 struct SubsampleEntry;
24 25
25 // These must be in sync with MediaCodecBridge.MEDIA_CODEC_XXX constants in 26 // These must be in sync with MediaCodecBridge.MEDIA_CODEC_XXX constants in
26 // MediaCodecBridge.java. 27 // MediaCodecBridge.java.
27 enum MediaCodecStatus { 28 enum MediaCodecStatus {
28 MEDIA_CODEC_OK, 29 MEDIA_CODEC_OK,
29 MEDIA_CODEC_DEQUEUE_INPUT_AGAIN_LATER, 30 MEDIA_CODEC_DEQUEUE_INPUT_AGAIN_LATER,
(...skipping 12 matching lines...) Expand all
42 // http://developer.android.com/reference/android/media/MediaCodec.html 43 // http://developer.android.com/reference/android/media/MediaCodec.html
43 // Note: MediaCodec is only available on JB and greater. 44 // Note: MediaCodec is only available on JB and greater.
44 class MEDIA_EXPORT MediaCodecBridge { 45 class MEDIA_EXPORT MediaCodecBridge {
45 public: 46 public:
46 virtual ~MediaCodecBridge(); 47 virtual ~MediaCodecBridge();
47 48
48 // Resets both input and output, all indices previously returned in calls to 49 // Resets both input and output, all indices previously returned in calls to
49 // DequeueInputBuffer() and DequeueOutputBuffer() become invalid. 50 // DequeueInputBuffer() and DequeueOutputBuffer() become invalid.
50 // Please note that this clears all the inputs in the media codec. In other 51 // Please note that this clears all the inputs in the media codec. In other
51 // words, there will be no outputs until new input is provided. 52 // words, there will be no outputs until new input is provided.
52 // Returns MEDIA_CODEC_ERROR if an unexpected error happens, or Media_CODEC_OK 53 // Returns MEDIA_CODEC_ERROR if an unexpected error happens, or MEDIA_CODEC_OK
53 // otherwise. 54 // otherwise.
54 virtual MediaCodecStatus Reset() = 0; 55 virtual MediaCodecStatus Reset() = 0;
55 56
56 // Calls start() against the media codec instance. Returns whether media 57 // Calls start() against the media codec instance. Returns whether media
57 // codec was successfully started. 58 // codec was successfully started.
58 virtual bool Start() = 0; 59 virtual bool Start() = 0;
59 60
60 // Finishes the decode/encode session. The instance remains active 61 // Finishes the decode/encode session. The instance remains active
61 // and ready to be StartAudio/Video()ed again. HOWEVER, due to the buggy 62 // and ready to be StartAudio/Video()ed again. HOWEVER, due to the buggy
62 // vendor's implementation , b/8125974, Stop() -> StartAudio/Video() may not 63 // vendor's implementation , b/8125974, Stop() -> StartAudio/Video() may not
63 // work on some devices. For reliability, Stop() -> delete and recreate new 64 // work on some devices. For reliability, Stop() -> delete and recreate new
64 // instance -> StartAudio/Video() is recommended. 65 // instance -> StartAudio/Video() is recommended.
65 virtual void Stop() = 0; 66 virtual void Stop() = 0;
66 67
67 // Used for getting output format. This is valid after DequeueInputBuffer() 68 // Used for getting the output size. This is valid after DequeueInputBuffer()
68 // returns a format change by returning INFO_OUTPUT_FORMAT_CHANGED 69 // returns a format change by returning INFO_OUTPUT_FORMAT_CHANGED.
69 virtual void GetOutputFormat(int* width, int* height) = 0; 70 // Returns MEDIA_CODEC_ERROR if an error occurs, or MEDIA_CODEC_OK otherwise.
71 virtual MediaCodecStatus GetOutputSize(gfx::Size* size) = 0;
70 72
71 // Used for checking for new sampling rate after DequeueInputBuffer() returns 73 // Used for checking for new sampling rate after DequeueInputBuffer() returns
72 // INFO_OUTPUT_FORMAT_CHANGED 74 // INFO_OUTPUT_FORMAT_CHANGED
73 virtual int GetOutputSamplingRate() = 0; 75 // Returns MEDIA_CODEC_ERROR if an error occurs, or MEDIA_CODEC_OK otherwise.
76 virtual MediaCodecStatus GetOutputSamplingRate(int* sampling_rate) = 0;
74 77
75 // Submits a byte array to the given input buffer. Call this after getting an 78 // Submits a byte array to the given input buffer. Call this after getting an
76 // available buffer from DequeueInputBuffer(). If |data| is NULL, assume the 79 // available buffer from DequeueInputBuffer(). If |data| is NULL, assume the
77 // input buffer has already been populated (but still obey |size|). 80 // input buffer has already been populated (but still obey |size|).
78 // |data_size| must be less than kint32max (because Java). 81 // |data_size| must be less than kint32max (because Java).
79 virtual MediaCodecStatus QueueInputBuffer( 82 virtual MediaCodecStatus QueueInputBuffer(
80 int index, 83 int index,
81 const uint8_t* data, 84 const uint8_t* data,
82 size_t data_size, 85 size_t data_size,
83 const base::TimeDelta& presentation_time) = 0; 86 const base::TimeDelta& presentation_time) = 0;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 size_t* size, 140 size_t* size,
138 base::TimeDelta* presentation_time, 141 base::TimeDelta* presentation_time,
139 bool* end_of_stream, 142 bool* end_of_stream,
140 bool* key_frame) = 0; 143 bool* key_frame) = 0;
141 144
142 // Returns the buffer to the codec. If you previously specified a surface when 145 // Returns the buffer to the codec. If you previously specified a surface when
143 // configuring this video decoder you can optionally render the buffer. 146 // configuring this video decoder you can optionally render the buffer.
144 virtual void ReleaseOutputBuffer(int index, bool render) = 0; 147 virtual void ReleaseOutputBuffer(int index, bool render) = 0;
145 148
146 // Returns an input buffer's base pointer and capacity. 149 // Returns an input buffer's base pointer and capacity.
147 virtual void GetInputBuffer(int input_buffer_index, 150 virtual MediaCodecStatus GetInputBuffer(int input_buffer_index,
148 uint8_t** data, 151 uint8_t** data,
149 size_t* capacity) = 0; 152 size_t* capacity) = 0;
150 153
151 // Copy |num| bytes from output buffer |index|'s |offset| into the memory 154 // Copy |num| bytes from output buffer |index|'s |offset| into the memory
152 // region pointed to by |*dst|. To avoid overflows, the size of both source 155 // region pointed to by |dst|. To avoid overflows, the size of both source
153 // and destination must be at least |num| bytes, and should not overlap. 156 // and destination must be at least |num| bytes, and should not overlap.
154 virtual void CopyFromOutputBuffer(int index, 157 // Returns MEDIA_CODEC_ERROR if an error occurs, or MEDIA_CODEC_OK otherwise.
155 size_t offset, 158 virtual MediaCodecStatus CopyFromOutputBuffer(int index,
156 void* dst, 159 size_t offset,
157 size_t num) = 0; 160 void* dst,
161 size_t num) = 0;
158 162
159 protected: 163 protected:
160 MediaCodecBridge(); 164 MediaCodecBridge();
161 165
162 // Fills a particular input buffer; returns false if |data_size| exceeds the 166 // Fills a particular input buffer; returns false if |data_size| exceeds the
163 // input buffer's capacity (and doesn't touch the input buffer in that case). 167 // input buffer's capacity (and doesn't touch the input buffer in that case).
164 bool FillInputBuffer(int index, 168 bool FillInputBuffer(int index,
165 const uint8_t* data, 169 const uint8_t* data,
166 size_t data_size) WARN_UNUSED_RESULT; 170 size_t data_size) WARN_UNUSED_RESULT;
167 171
168 DISALLOW_COPY_AND_ASSIGN(MediaCodecBridge); 172 DISALLOW_COPY_AND_ASSIGN(MediaCodecBridge);
169 }; 173 };
170 174
171 } // namespace media 175 } // namespace media
172 176
173 #endif // MEDIA_BASE_ANDROID_MEDIA_CODEC_BRIDGE_H_ 177 #endif // MEDIA_BASE_ANDROID_MEDIA_CODEC_BRIDGE_H_
OLDNEW
« no previous file with comments | « media/base/android/java/src/org/chromium/media/MediaCodecBridge.java ('k') | media/base/android/media_codec_bridge.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698